:root {
  --bg: #f6f5f2; --panel: #fff; --ink: #1d1f24; --muted: #6b6f78; --line: #e4e2dc;
  --accent: #e8423b; --accent-ink: #fff; --ok: #1f8a5b; --warn: #c27c0e; --bad: #c0392b;
  --soft: #f0eee9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b; --panel: #1e2126; --ink: #ecebe7; --muted: #9a9ea6; --line: #2e3238;
    --soft: #262a30;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 "Noto Sans Thai", "Sukhumvit Set", system-ui, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 14px; }
button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.rec { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.block { width: 100%; }
button:disabled { opacity: .5; cursor: default; }
.muted { color: var(--muted); font-size: 13px; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); }
.status { font-size: 13px; color: var(--muted); }
.status::before { content: "●"; margin-right: 6px; color: var(--warn); }
.status.ok::before { color: var(--ok); }
.status.bad::before { color: var(--bad); }

.layout { display: grid; grid-template-columns: 340px 1fr; min-height: calc(100vh - 49px); }
.side { border-right: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--soft); border-radius: 10px; padding: 3px; }
.tabs button { border: 0; background: transparent; }
.tabs button.on { background: var(--panel); box-shadow: 0 1px 2px #0002; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; overflow: auto; }
.list li { padding: 10px 12px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.list li:hover { background: var(--soft); }
.list li.on { background: var(--soft); border-color: var(--line); }
.list .top { display: flex; justify-content: space-between; gap: 8px; }
.list .sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint { font-size: 12px; color: var(--muted); margin-top: auto; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

.main { padding: 24px; display: flex; justify-content: center; align-items: flex-start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: 100%; max-width: 760px; }
.center { text-align: center; margin-top: 10vh; }
.who { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--soft); }
.chip.hot { background: #e8423b22; color: var(--accent); }
.chip.warm { background: #c27c0e22; color: var(--warn); }
.chip.cold { background: #3b82f622; color: #3b82f6; }
.timer { font-size: 44px; font-variant-numeric: tabular-nums; text-align: center; margin: 12px 0; }
.pulse { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: p 1s infinite; margin-right: 6px; }
@keyframes p { 50% { opacity: .2; } }
.steps { list-style: none; padding: 0; }
.steps li { padding: 4px 0; color: var(--muted); }
.steps li.done { color: var(--ok); }
.steps li.doing { color: var(--ink); font-weight: 600; }

.score { display: flex; align-items: center; gap: 16px; padding: 14px; background: var(--soft); border-radius: 10px; margin-bottom: 16px; }
.score > b { font-size: 36px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sec { margin: 16px 0 0; }
.sec h4 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sec ul { margin: 0; padding-left: 18px; }
.req { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 14px; }
.req dt { color: var(--muted); }
.req dd { margin: 0; }
.flag { color: var(--bad); }
.viewing { padding: 10px 12px; border-radius: 8px; background: #1f8a5b1a; color: var(--ok); }
.transcript { max-height: 260px; overflow: auto; font-size: 14px; background: var(--soft); border-radius: 8px; padding: 10px; }
.transcript p { margin: 0 0 6px; }
.transcript span { color: var(--muted); font-size: 12px; margin-right: 6px; }
audio { width: 100%; margin-top: 8px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.err { color: var(--bad); font-size: 13px; min-height: 1em; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); width: min(520px, calc(100vw - 32px)); padding: 20px; }
dialog::backdrop { background: #0006; }
dialog h3 { margin: 0; }
dialog label { display: block; font-size: 13px; color: var(--muted); margin-top: 10px; }
dialog input, dialog select, dialog textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .list { max-height: 40vh; }
  .main { padding: 16px; }
  .grid, .row { grid-template-columns: 1fr; }
  .brand .muted { display: none; }
}
