/* BSN Chat: large type, high contrast, big tap targets (CEO 2026-11-11 "ดีไซน์ให้อ่านง่าย") */
/* Themes (CEO 2026-11-11 "ขอพื้นหลังช่องแชทเป็นสีขาว และเปลี่ยนธีมได้"): white is the default; data-theme picks
   light, dark or the phone's own setting ("auto"), and data-accent picks the main color in both. */
:root {
  --a-l: #1D2C78; --a-d: #9CB0FF;
  --bg: #EEF1F7; --surface: #FFFFFF; --fg: #141A33; --muted: #4E5675; --line: #D5DAE8;
  --accent: var(--a-l); --on-accent: #FFFFFF; --gm: #FFFFFF; --decide: #9A4A00; --decide-bg: #FFF1DC;
  --ok: #17703F; --ok-bg: #E3F4EA; --bad: #B3261E; --bad-bg: #FDE8E6; --warn-bg: #FFF4D6; --chip: #E7EBF7;
  --font: "Sarabun", "Noto Sans Thai", system-ui, sans-serif;
}
:root[data-accent="green"] { --a-l: #0F6E45; --a-d: #6FDDA2; }
:root[data-accent="pink"] { --a-l: #B0175A; --a-d: #FF8DBA; }
:root[data-accent="orange"] { --a-l: #B4440E; --a-d: #FFB37A; }
:root[data-accent="purple"] { --a-l: #5B21B6; --a-d: #C4A8FF; }
:root[data-accent="black"] { --a-l: #1F2328; --a-d: #E6E8EC; }
:root[data-theme="dark"] {
  --bg: #0D1222; --surface: #161D35; --fg: #EDF0FA; --muted: #A3ABCB; --line: #2C365A;
  --accent: var(--a-d); --on-accent: #0D1222; --gm: #1B2342; --decide: #FFC27A; --decide-bg: #3A2A12;
  --ok: #6FDDA2; --ok-bg: #133325; --bad: #FF8A80; --bad-bg: #3A1614; --warn-bg: #3A3212; --chip: #232D52; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0D1222; --surface: #161D35; --fg: #EDF0FA; --muted: #A3ABCB; --line: #2C365A;
    --accent: var(--a-d); --on-accent: #0D1222; --gm: #1B2342; --decide: #FFC27A; --decide-bg: #3A2A12;
    --ok: #6FDDA2; --ok-bg: #133325; --bad: #FF8A80; --bad-bg: #3A1614; --warn-bg: #3A3212; --chip: #232D52; color-scheme: dark;
  }
}
.swatches { display: flex; gap: 12px; padding: 8px 12px 12px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; }
.swatch[aria-pressed="true"] { border-color: var(--fg); }
.sheet-body button.on { background: var(--chip); font-weight: 700; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--bg); color: var(--fg); font: 17px/1.6 var(--font); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.avatar { border-radius: 50%; object-fit: cover; background: var(--surface); flex: none; }

/* install bar */
#installBar { display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; background: var(--warn-bg); font-size: .95rem; }
#installBar img { border-radius: 8px; }
#installBar span { flex: 1; min-width: 0; }
#installBtn { background: var(--accent); color: var(--on-accent); border: 0; border-radius: 99px; padding: 8px 16px; font-weight: 700; }
#installBar .x { background: none; border: 0; padding: 8px; }

/* gate screens */
.gate { align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.gate h1 { margin: 0; font-size: 1.6rem; }
.gate p { margin: 0; max-width: 30ch; }
.hint { color: var(--muted); font-size: .95rem; }
.stackform { display: flex; flex-direction: column; gap: 10px; width: min(300px, 100%); }
.stackform input { font-size: 1.3rem; padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); text-align: center; letter-spacing: .15em; }
.stackform input::placeholder { letter-spacing: 0; font-size: 1rem; }
.stackform button { background: var(--accent); color: var(--on-accent); border: 0; border-radius: 12px; padding: 13px 16px; font-weight: 700; }
.error { color: var(--bad); min-height: 1.6em; font-weight: 600; }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 10px; }

/* header and tabs */
header { display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px; background: var(--accent); color: var(--on-accent); }
header .avatar.big { border: 2px solid rgba(255,255,255,.7); }
.who { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.who b { font-size: 1.15rem; }
.who span { font-size: .85rem; opacity: .9; }
.ghost { background: transparent; border: 1.5px solid currentColor; color: inherit; border-radius: 99px; padding: 6px 12px; font-size: .9rem; }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border-bottom: 1px solid var(--line); }
.tabs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 6px; background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); font-size: .82rem; font-weight: 600; min-width: 0; }
.tabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs .glyph { font-size: 1.25rem; line-height: 26px; font-weight: 400; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.badge { position: absolute; top: 3px; left: calc(50% + 8px); background: #E5484D; color: #fff; border-radius: 99px; font-size: .72rem; font-style: normal; min-width: 20px; padding: 0 6px; line-height: 20px; }

/* chat */
#list, #work { flex: 1; overflow-y: auto; padding: 12px 6px 16px; display: flex; flex-direction: column; gap: 10px; }
.day { align-self: center; font-size: .8rem; color: var(--muted); background: var(--chip); border-radius: 99px; padding: 2px 12px; }
.row { display: flex; gap: 6px; align-items: flex-end; max-width: 100%; }
.row .avatar { width: 34px; height: 34px; }
.stack { display: flex; flex-direction: column; min-width: 0; }
.sender { font-size: .82rem; color: var(--muted); margin: 0 0 3px 4px; }
.msg { max-width: 94%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.row .msg { max-width: 100%; }
.msg.in { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.msg.out { background: var(--gm); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: 0 1px 1px rgba(20,26,51,.04); }
.msg .time { display: block; font-size: .75rem; opacity: .7; margin-top: 4px; text-align: right; }
.msg.pending { opacity: .75; }
.decide { display: block; margin: 8px 0 2px; padding: 8px 10px; border-radius: 10px; background: var(--decide-bg); color: var(--decide); font-weight: 700; white-space: normal; }
.msg.typing { color: var(--muted); font-style: italic; }
.msg.typing .dots { display: inline-block; margin-left: 6px; letter-spacing: 2px; animation: blink 1.2s infinite; font-style: normal; }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .msg.typing .dots { animation: none; } }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { border: 1.5px solid var(--accent); color: var(--accent); background: transparent; border-radius: 99px; padding: 7px 14px; font-size: .95rem; font-weight: 600; min-height: 40px; }

/* files, pictures, clips */
.media { display: block; max-width: 100%; max-height: 320px; border-radius: 12px; margin: 2px 0 4px; background: var(--chip); }
video.media { width: 100%; }
.filecard { display: flex; align-items: center; gap: 10px; background: var(--chip); color: var(--fg); border: 0; border-radius: 12px; padding: 10px 12px; text-align: left; width: 100%; min-height: 52px; }
.msg.in .filecard { background: rgba(255,255,255,.16); color: inherit; }
.filecard .ext { font-size: 1.6rem; }
.filecard .meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.filecard .meta b { overflow-wrap: anywhere; }
.filecard .meta small { opacity: .75; }
.progress { height: 6px; border-radius: 99px; background: rgba(127,127,127,.25); overflow: hidden; margin-top: 6px; }
.progress i { display: block; height: 100%; width: 0; background: currentColor; transition: width .2s; }

/* composer */
.quick { margin: 0; padding: 8px 10px 0; background: var(--surface); border-top: 1px solid var(--line); flex-wrap: nowrap; overflow-x: auto; }
.quick .chip { flex: none; min-height: 36px; padding: 5px 12px; font-size: .9rem; }
.quick[hidden] { display: none; }
#sendForm { display: flex; gap: 4px; align-items: flex-end; padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line); }
#text { flex: 1; resize: none; max-height: 9em; min-height: 46px; border: 1.5px solid var(--line); border-radius: 22px; padding: 10px 14px; background: var(--bg); line-height: 1.45; }
.icon { display: grid; place-items: center; width: 44px; height: 46px; background: transparent; border: 0; font-size: 1.45rem; cursor: pointer; user-select: none; }
.round { width: 46px; height: 46px; border-radius: 50%; border: 0; font-size: 1.3rem; flex: none; touch-action: none; user-select: none; }
.send { background: var(--accent); color: var(--on-accent); }
.mic { background: var(--chip); }
.mic.on { background: var(--bad); }
#recording { position: fixed; left: 12px; right: 12px; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); background: var(--bad); color: #fff; padding: 12px 14px; border-radius: 14px; text-align: center; font-weight: 600; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; max-width: calc(100% - 32px); font-size: .95rem; z-index: 5; }
#viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 10; display: grid; place-items: center; padding: 48px 8px 16px; }
#viewerBody img, #viewerBody video { max-width: 100%; max-height: calc(100vh - 80px); border-radius: 8px; }
#viewerClose { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 12px; background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 50%; width: 44px; height: 44px; font-size: 1.2rem; }

/* hold a message: reply, listen, copy, take back (CEO 2026-11-11) */
.round-ghost { width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 1.1rem; }
#speakBtn[aria-pressed="true"] { background: var(--on-accent); color: var(--accent); }
.quote { display: block; border-left: 4px solid currentColor; padding: 4px 10px; margin-bottom: 6px; border-radius: 6px; background: rgba(127,127,127,.14); font-size: .9rem; opacity: .9; white-space: normal; }
.quote b { display: block; font-size: .8rem; }
.msg.gone { background: transparent !important; color: var(--muted) !important; border: 1.5px dashed var(--line) !important; font-style: italic; }
.read { font-size: .75rem; margin-right: 6px; opacity: .85; }
#replyBar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-top: 1px solid var(--line); }
#replyBar .rb { flex: 1; min-width: 0; border-left: 4px solid var(--accent); padding-left: 10px; display: flex; flex-direction: column; }
#replyBar .rb b { font-size: .85rem; color: var(--accent); }
#replyBar .rb span { font-size: .9rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#replyBar button { background: none; border: 0; padding: 8px; font-size: 1.1rem; }
#sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 8; display: flex; align-items: flex-end; }
.sheet-body { width: 100%; background: var(--surface); border-radius: 20px 20px 0 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 4px; }
.sheet-body .peek { color: var(--muted); font-size: .9rem; padding: 6px 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-body button { text-align: left; background: none; border: 0; padding: 14px 12px; font-size: 1.05rem; border-radius: 12px; }
.sheet-body button:active { background: var(--chip); }
.sheet-body button.danger { color: var(--bad); }

/* work tab */
.section { display: flex; flex-direction: column; gap: 10px; }
.section h2 { margin: 6px 2px 0; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }
.section h2 .count { background: var(--accent); color: var(--on-accent); border-radius: 99px; padding: 0 9px; font-size: .85rem; }
.empty { color: var(--muted); padding: 4px 2px 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.card.approve { border-left: 5px solid var(--decide); }
.card h3 { margin: 0; font-size: 1.05rem; line-height: 1.45; }
.card .sub { color: var(--muted); font-size: .9rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: .95rem; margin: 0; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 700; min-height: 44px; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.bad { background: var(--bad-bg); color: var(--bad); }
.btn.plain { background: var(--chip); color: var(--fg); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.note { width: 100%; min-height: 70px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; background: var(--bg); resize: vertical; }
.bar { height: 8px; border-radius: 99px; background: var(--chip); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); }
.tasks { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tasks li { display: flex; gap: 8px; align-items: flex-start; font-size: .93rem; }
.tasks .avatar { width: 26px; height: 26px; margin-top: 2px; }
.tasks .t { flex: 1; min-width: 0; }
.st { display: inline-block; border-radius: 99px; padding: 0 8px; font-size: .78rem; font-weight: 700; background: var(--chip); color: var(--muted); margin-left: 4px; }
.st.COMPLETED { background: var(--ok-bg); color: var(--ok); }
.st.BLOCKED, .st.FAILED { background: var(--bad-bg); color: var(--bad); }
.problem { color: var(--bad); font-size: .88rem; }
.verdict { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; border-radius: 99px; padding: 6px 14px; font-weight: 700; font-size: .95rem; }
.verdict.APPROVED { background: var(--ok-bg); color: var(--ok); }
.verdict.REJECTED, .verdict.CANCELLED { background: var(--bad-bg); color: var(--bad); }
.verdict.REVISION_REQUESTED, .verdict.SENT { background: var(--decide-bg); color: var(--decide); }
.card.done { opacity: .85; border-left-color: var(--line); }
/* CEO 2026-11-12: clips play inside the chat bubble */
.vbox { width: min(78vw, 340px); margin: 2px 0 4px; }
.vbox video.media { max-height: 60vh; background: #000; }
.vtile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 100%; aspect-ratio: 9 / 12; max-height: 52vh;
  border: 0; border-radius: 12px; background: linear-gradient(160deg, #1b2c63, #0b1530); color: #fff; padding: 14px; text-align: center; }
.vtile .play { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: rgba(255,255,255,.92); color: #1b2c63; font-size: 1.6rem; padding-left: 4px; }
.vtile b { overflow-wrap: anywhere; font-size: .95rem; }
.vtile small { opacity: .8; }
.vtile .progress { width: 80%; color: #ffb347; }
.vtile:disabled { opacity: 1; }
