/* studio.css: VOICE (Voice Studio อ่านตาม/ชวนคุย/เทรน) + SYSTEM (admin) — handoff ฉบับ 4 ข้อ D "VOICE"
   tokens จาก tokens.css, components จาก style.css · ไม่มี radius ยกเว้นปุ่มอัดวงกลม · ไม่มี glow/blur/gradient wash
   ภาษาไทยห้ามถ่างช่องไฟ: ป้าย HUD ภาษาอังกฤษใช้ .lbl, ข้อความไทยใช้ --font-ui / .th */

/* ------------------------------------------------------------------ page root */
.vx .page-head h1 { letter-spacing: .14em; }
.vx .empty h3 { letter-spacing: 0; font-family: var(--font-ui); }
.vx .stat .k { letter-spacing: var(--lbl-track); }
/* the "switch to mode X" button that lib/state.js puts under a gated control has a Thai label */
.vx .gate-why .btn span, .sys .gate-why .btn span { letter-spacing: 0; text-transform: none; }

/* VOICE header: 02 / CHAPTER + VOICE 30px + Thai tag line */
.v-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s-3); flex-wrap: wrap; }
.v-head-t { display: flex; flex-direction: column; gap: 2px; }
.v-title { font-family: var(--font-hud); font-size: 30px; font-weight: var(--fw-bold); letter-spacing: .14em; line-height: 1.1; }
.v-tag { font-size: 13px; color: var(--muted); padding-bottom: 4px; }
.v-lock { margin-top: var(--s-4); }

.v-wrap { display: grid; gap: var(--s-6); margin-top: var(--s-4); }
.v-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.v-more { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.v-more > .card + .card { margin-top: 0; }
body.focus-mode .v-more { display: none; }
@media (min-width: 900px) {
  .v-wrap { grid-template-columns: minmax(0, 560px) minmax(0, 1fr); align-items: start; gap: 40px; }
  body.focus-mode .v-wrap { grid-template-columns: minmax(0, 640px); justify-content: center; }
  body.focus-mode .vx > .v-head { max-width: 640px; margin: 0 auto; }
}

/* levels: 3 joined cells (style.css .levels/.level) + English name + Thai target */
.v-levels { list-style: none; margin: 0; padding: 0; gap: 4px; }
.v-levels .level { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.v-levels .lv { font-size: var(--lbl-size); letter-spacing: var(--lbl-track); color: var(--muted); }
.v-levels .ln { font-family: var(--font-hud); font-size: 13px; font-weight: var(--fw-semibold); letter-spacing: .08em; line-height: 1.3; overflow-wrap: anywhere; }
.v-levels .ld { font-size: 12px; color: var(--muted); line-height: 1.4; margin: 0; }
.v-levels .level:not(.done):not(.current) .ln { color: var(--muted); }

/* counters + clip grid + coverage */
.v-progress { display: flex; flex-direction: column; gap: 10px; }
.v-count { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.v-clipsn { display: flex; align-items: baseline; gap: 8px; margin: 0; }
.v-n { font-family: var(--font-hud); font-size: 52px; font-weight: var(--fw-semibold); line-height: 1; font-variant-numeric: tabular-nums; }
.v-of { color: var(--muted); }
.v-clipsn .v-of { font-size: 20px; }
.v-time { margin: 0 0 4px; font-size: 15px; }
.v-clips { display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 3px; }
.v-clips > span { height: 9px; border: 1px solid var(--track); }
.v-clips > span.on { background: var(--amber); border-color: var(--amber); }
.v-clips > span.now { border: 1.5px solid var(--scan); }
/* current clip blinks (opacity only) while recording — ข้อ G; reduced motion: the global rule stops it */
.v-clips.rec > span.now { animation: v-now 1600ms ease-in-out infinite; }
@keyframes v-now { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.v-cov { margin: 0; }
.v-cov-v { color: var(--text); }

/* sentence card: --panel + corner brackets + label + Anuphan 22/500 */
.v-card {
  background: var(--panel); border: 1px solid var(--line);
  padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px;
}
.v-card.recording { border-color: color-mix(in srgb, var(--amber) 60%, transparent); }
.v-read { font-family: var(--font-ui); font-size: 22px; line-height: 1.6; font-weight: var(--fw-medium); word-break: keep-all; overflow-wrap: anywhere; max-width: var(--read-max); }
.v-why { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.v-why:empty { display: none; }

/* record zone: waveform from real levels + REPLAY · reticle record · SKIP */
.v-zone { display: flex; flex-direction: column; gap: 14px; }
.v-wave { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.v-wave > span { width: 3px; height: calc(var(--h, .5) * 100%); background: var(--idle-bar); transition: background-color 200ms ease; }
.v-wave.on > span { height: 100%; background: var(--amber); transform: scaleY(.06); transform-origin: center; }
.v-wave.hot > span { background: var(--danger); }
.v-rig { display: flex; flex-direction: column; gap: 8px; }
.v-rig > .gate-why { justify-content: center; text-align: center; }
.v-rec-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; }
.v-side { display: flex; min-width: 0; }
.v-side.end { justify-content: flex-end; }
.v-reticle { position: relative; width: 104px; height: 104px; display: flex; align-items: center; justify-content: center; color: var(--scan); }
.v-ret-svg { position: absolute; inset: 0; width: 104px; height: 104px; max-width: none; pointer-events: none; }
.v-reticle .gate { display: contents; }
.v-rec {
  position: relative; width: 80px; height: 80px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: var(--amber); display: flex; align-items: center; justify-content: center;
  transition: transform 140ms var(--ease-out), background-color var(--dur-2) ease;
}
.v-rec:active { transform: scale(.95); }
.v-rec:focus-visible { outline: 2px solid var(--scan); outline-offset: 4px; }
.v-rec .shape { width: 26px; height: 26px; background: var(--bg); border-radius: 50%; transition: border-radius 200ms var(--ease-in-out), transform 200ms var(--ease-in-out); }
.v-rec .dots { display: none; }
.v-rec[data-state="recording"] .shape { border-radius: 4px; transform: scale(.8); }
/* sound rings while recording */
.v-rec[data-state="recording"]::before, .v-rec[data-state="recording"]::after {
  content: ""; position: absolute; inset: 0; border: 1.5px solid var(--amber); border-radius: 50%;
  animation: v-ring 1600ms ease-out infinite; pointer-events: none;
}
.v-rec[data-state="recording"]::after { animation-delay: 800ms; }
@keyframes v-ring { from { transform: scale(1); opacity: .7; } to { transform: scale(1.5); opacity: 0; } }
.v-rec[data-state="busy"] { background: var(--track); cursor: progress; }
.v-rec[data-state="busy"] .shape { display: none; }
.v-rec[data-state="busy"] .dots { display: inline-flex; }
.v-rec[disabled]:not([data-state="busy"]) { background: var(--track); cursor: not-allowed; }
.v-rec[disabled]:not([data-state="busy"]) .shape { background: var(--muted); }
@media (prefers-reduced-motion: reduce) {
  .v-rec:active, .v-rec[data-state="recording"] .shape { transform: none; }
  .v-rec[data-state="recording"]::before, .v-rec[data-state="recording"]::after { display: none; }
  /* waveform holds still in amber = "recording" (3.1 ข้อ 6.1) — beats the inline scaleY the rAF loop writes */
  .v-wave.on > span { height: calc(var(--h, .5) * 100%); transform: none !important; }
}
/* REPLAY / SKIP: .lbl text buttons, ≥ 48px */
.btn.v-tbtn {
  min-width: 84px; min-height: 48px; padding: 0 4px; gap: 6px; justify-content: flex-start;
  border-color: transparent; background: none; color: var(--text);
  font-size: 12px; letter-spacing: var(--lbl-track);
}
.btn.v-tbtn.end { justify-content: flex-end; }
.btn.v-tbtn .ico { width: 16px; height: 16px; }
.btn.v-tbtn[disabled] { color: var(--muted); background: none; border-color: transparent; }
.v-hint { margin: 0; text-align: center; font-size: 14px; color: var(--muted); min-height: 1.6em; }
.v-keys { display: none; text-align: center; }
@media (hover: hover) and (pointer: fine) { .v-keys { display: block; } }

/* session bar (focus mode): takes the app bar's place with the same height, so nothing jumps */
.v-sbar { display: flex; flex-direction: column; justify-content: center; gap: 6px; height: 64px; }
.v-sbar-row { display: flex; align-items: center; gap: var(--s-2); }
.v-sbar-mid { flex: 1 1 auto; display: flex; align-items: baseline; gap: var(--s-2); min-width: 0; }
.v-timer { font-size: 15px; }
.v-sbar-lv { white-space: nowrap; }
.btn.v-end { padding: 0 var(--s-2); min-height: var(--touch); color: var(--text); }
@media (min-width: 900px) { .v-sbar { height: 88px; max-width: 640px; margin: 0 auto; } }

/* QC result: panel + left line by meaning + English code + Thai title */
.qc { background: var(--panel); border: 1px solid var(--line); border-left: 2px solid var(--scan); padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); color: var(--text); }
.qc.pass { border-left-color: var(--ok); }
.qc.fail { border-left-color: var(--danger); }
.qc.queued, .qc.review { border-left-color: var(--amber); }
.qc .qc-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.qc .qc-title > .lbl { color: var(--scan); }
.qc.pass .qc-title > .lbl { color: var(--ok); }
.qc.fail .qc-title > .lbl { color: var(--danger); }
.qc.queued .qc-title > .lbl, .qc.review .qc-title > .lbl { color: var(--amber); }
.qc .qc-t { font-family: var(--font-ui); font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.qc ul { margin: 0; padding-left: 1.2em; }
.qc .heard { background: var(--surface-2); padding: var(--s-3); font-size: var(--fs-md); }
.qc .heard .k { font-size: var(--fs-xs); color: var(--muted); display: block; }
.qc .btns { display: flex; flex-wrap: wrap; gap: var(--s-2); }
mark.d { background: var(--mark-sub); color: inherit; padding: 0 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone; text-decoration: underline wavy var(--danger); text-underline-offset: 6px; }
mark.d.del { background: var(--danger-soft); color: var(--danger-text); text-decoration: line-through 2px var(--danger); }
.hyp ins { text-decoration: none; background: var(--danger-soft); color: var(--danger-text); padding: 0 2px; }
.break { display: flex; flex-direction: column; gap: var(--s-2); }

/* mic VU meter (SETUP): flat track, zones, square fill */
.vu { display: flex; flex-direction: column; gap: 4px; }
.vu-track { position: relative; height: 12px; background: var(--track); overflow: hidden; }
.vu-zone { position: absolute; top: 0; bottom: 0; }
.vu-zone.good { background: color-mix(in srgb, var(--ok) 18%, transparent); }
.vu-zone.hot { background: color-mix(in srgb, var(--danger) 22%, transparent); }
.vu-fill { position: absolute; left: 0; top: 3px; bottom: 3px; background: var(--muted); width: 0; } /* follows the live level directly — no width transition (layout property) */
.vu-fill.good { background: var(--ok); } .vu-fill.hot { background: var(--danger); } .vu-fill.low { background: var(--idle-bar); }
.vu-peak { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .7; left: 0; }
.vu-labels { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--muted); }

/* card header: English code (cyan .lbl look) + Thai line */
.v-ch { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-3); }
.v-ch-t { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.v-ch h2 { font-family: var(--font-hud); font-size: var(--lbl-size); font-weight: var(--fw-semibold); letter-spacing: var(--lbl-track); text-transform: uppercase; color: var(--scan); line-height: 1.4; }
.v-ch p { color: var(--muted); font-size: var(--fs-sm); }
.v-sub { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; font-size: inherit; font-family: var(--font-ui); font-weight: 400; }
.card.v-danger { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

/* more: other modes as rows (English code + Thai line) */
.v-acts { display: flex; flex-direction: column; }
.v-acts > * + * { border-top: 1px solid var(--line); }
.v-act {
  all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: var(--s-3);
  min-height: 56px; padding: var(--s-3) 4px; cursor: pointer; transition: background-color 120ms ease;
}
.v-act:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.v-act:active { background: var(--scan-hover); }
@media (hover: hover) and (pointer: fine) { .v-act:hover { background: var(--scan-hover); } }
.v-act-t { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.v-act-t > .lbl { color: var(--scan); }
.v-act-d { font-size: var(--fs-sm); color: var(--muted); }
.v-act > .ico { width: 18px; height: 18px; color: var(--muted); }
.v-act[disabled] { cursor: not-allowed; }
.v-act[disabled] .v-act-t > .lbl { color: var(--muted); }
.v-acts .gate { gap: 0; }
.v-acts .gate-why { padding: 0 4px var(--s-3); }
.v-share { display: flex; flex-direction: column; gap: 4px; max-width: 220px; margin-top: 4px; }

.units { display: grid; gap: var(--s-2); }
.unit { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s-3); align-items: center; }
.unit .u-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.unit .u-ex { font-size: var(--fs-xs); color: var(--muted); }
.unit .u-n { font-size: var(--fs-xs); color: var(--muted); text-align: right; }
.unit .meter { grid-column: 1 / -1; }

/* consent: WHAT / WHERE / WHO / DELETE */
.v-infos { display: flex; flex-direction: column; gap: var(--s-3); }
.v-info { border-left: 2px solid var(--scan); padding: 8px 12px; background: var(--panel); display: flex; flex-direction: column; gap: 4px; }
.v-info-h { display: flex; align-items: center; gap: 8px; color: var(--scan); }
.v-info-h .ico { width: 18px; height: 18px; }
.v-info-b { font-size: var(--fs-sm); display: flex; flex-direction: column; gap: 6px; }
.v-paths { grid-template-columns: max-content minmax(0, 1fr); }
.v-paths dd, .v-path { overflow-wrap: anywhere; word-break: break-all; }

/* wizard steps inside VOICE (consent / setup): Thai checkbox text must not get the HUD label look */
.vx .wz-field > label.check { font-family: var(--font-ui); font-size: var(--fs-md); font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--text); }
.v-switch { padding: 4px 0; }
.v-switch-t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.v-switch-t > .lbl { color: var(--text); }
.v-tips { margin: 0; padding-left: 1.2em; }

/* interview — Q&A pattern: question with a cyan lead line, the user = "YOU ·" + muted Thai (no bubbles) */
.v-stage { max-width: 720px; }
.v-q { display: flex; flex-direction: column; gap: 8px; }
.v-q-t { font-family: var(--font-ui); font-size: clamp(1.25rem, 1rem + 1.4vw, 1.6rem); line-height: 1.6; font-weight: var(--fw-medium); }
.v-you { font-size: 14px; color: var(--muted); margin: 0; }
.v-you > .lbl { color: var(--muted); }
.v-you-row { flex-wrap: wrap; }
.v-len { width: 100%; }
.v-segs { display: grid; gap: var(--s-2); }
.v-seg { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); background: var(--panel); border-left: 2px solid var(--line-strong); }
.v-seg .textarea { min-height: 64px; }
.v-saved { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; border-left: 2px solid var(--ok); }
.v-saved.bad { border-left-color: var(--danger); }

/* train / eval / review */
.v-details > summary { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-height: var(--touch); cursor: pointer; list-style: none; }
.v-details > summary::-webkit-details-marker { display: none; }
.v-details > summary::before { content: "+"; font-family: var(--font-hud); color: var(--scan); width: 12px; }
.v-details[open] > summary::before { content: "−"; }
.v-details[open] > summary { margin-bottom: var(--s-2); }
.v-details > .hint { margin-top: var(--s-2); }
.v-2col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.v-3col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.v-3col .btn { padding: 0 6px; font-size: 13px; letter-spacing: .1em; }
.v-bigrow { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px var(--s-3); }
.v-big { font-family: var(--font-hud); font-size: 30px; font-weight: var(--fw-semibold); line-height: 1.1; font-variant-numeric: tabular-nums; }
.v-quote { display: flex; flex-direction: column; gap: 4px; padding: var(--s-3); background: var(--surface-2); }
.v-quote-t { font-family: var(--font-ui); font-size: 20px; line-height: 1.6; font-weight: var(--fw-medium); }
.v-rank { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; }
.v-rank .n { font-size: 28px; min-width: 2ch; color: var(--muted); }
.v-rank.first .n { color: var(--amber); }
.v-read-sm { font-family: var(--font-ui); font-size: 17px; font-weight: var(--fw-medium); line-height: 1.6; }
.feat-name { font-weight: var(--fw-semibold); }

/* ------------------------------------------------------------------ SYSTEM (admin) */
/* collapsible groups (owner 2026-11-13): h2 > button[aria-expanded] + region · header ≥ 44 px · status stays visible closed */
.sys-groups { display: flex; flex-direction: column; gap: var(--s-2); }
.sys-grp { background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.sys-grp.is-open { border-color: var(--line-strong); }
.sys-grp-h { margin: 0; font: inherit; }
.sys-grp-btn {
  all: unset; box-sizing: border-box; display: flex; align-items: center; gap: var(--s-3); width: 100%;
  min-height: 52px; padding: var(--s-2) var(--s-4); cursor: pointer; transition: background-color var(--dur-1) ease;
  -webkit-tap-highlight-color: transparent;
}
.sys-grp-btn:active { background: var(--scan-hover); }
@media (hover: hover) and (pointer: fine) { .sys-grp-btn:hover { background: var(--scan-hover); } }
.sys-grp-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.sys-grp-code { flex: 0 0 auto; font-family: var(--font-hud); font-size: 13px; font-weight: var(--fw-semibold); letter-spacing: var(--lbl-track); color: var(--scan); line-height: 1.3; }
.sys-grp-st {
  flex: 1 1 auto; min-width: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-hud); font-size: 12px; font-weight: var(--fw-semibold); letter-spacing: .08em; color: var(--muted);
  font-variant-numeric: tabular-nums; line-height: 1.3;
}
.sys-grp-st.is-ok { color: var(--ok-text); }
.sys-grp-st.is-warn, .sys-grp-st.is-live { color: var(--amber); }
.sys-grp-st.is-danger { color: var(--danger-text); }
.sys-grp-chev { width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted); transition: transform var(--dur-2) var(--ease-out); }
.sys-grp-btn[aria-expanded="true"] .sys-grp-chev { transform: rotate(180deg); color: var(--scan); }
.sys-grp-body { border-top: 1px solid var(--line); padding: var(--s-4); min-width: 0; }
.sys-grp-body.in { animation: sys-grp-in 180ms var(--ease-out); }
@keyframes sys-grp-in { from { opacity: 0; transform: translateY(-4px); } }
.sys-grp-body > .v-ch:first-child p { max-width: var(--read-max); }
@media (min-width: 720px) {
  .sys-grp-btn { padding: var(--s-2) var(--s-5); }
  .sys-grp-body { padding: var(--s-5); }
}
@media (prefers-reduced-motion: reduce) { .sys-grp-body.in { animation: none; } .sys-grp-chev { transition: none; } }
/* SETTINGS › GUIDE VOICE */
.gv-kv { grid-template-columns: max-content minmax(0, 1fr); align-items: baseline; }
.gv-kv dd { min-width: 0; overflow-wrap: anywhere; }
.gv-id { font-family: var(--font-mono); font-size: var(--fs-sm); }
.gv-row { gap: var(--s-2) var(--s-3); padding-left: 0; padding-right: 0; }
.gv-row .li-body { flex: 1 1 auto; }
/* phones: PLAY becomes a 44 px icon button (its aria-label still says ฟัง/หยุด) so a row stays one line */
@media (max-width: 479px) {
  .gv-play { width: var(--touch); padding: 0; } .gv-play > span { display: none; } .gv-row { gap: var(--s-2); }
  .gv-use > .ico { display: none; }
}
.gv-row .li-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gv-n { flex: 0 0 auto; min-width: 2.4ch; font-size: 20px; color: var(--muted); }
.gv-list li.is-current .gv-n { color: var(--amber); }
.gv-end { margin-left: auto; gap: var(--s-1); }
.gv-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; justify-content: space-between; }
.gv-job { padding: var(--s-3); border-left: 2px solid var(--amber); background: var(--amber-soft); }
.gv .empty { padding: var(--s-5) var(--s-3); }

/* grid children must be allowed to shrink (the eval table scrolls inside its own box) */
.vx .grid-2 > * { min-width: 0; }
.vx .v-rig > .gate-why > span:not(.subtle) { flex: 0 1 auto; max-width: calc(100% - 28px); }
.v-q .mock-flag, .v-card .mock-flag { margin-left: 8px; }
/* touch targets ≥ 44px on VOICE / SYSTEM (style.css .btn-sm is 36px) */
.vx .btn-sm, .vx .gate-why button { min-height: var(--touch); }
.vx .table td.num { white-space: nowrap; }
/* the gate reason moved out of .gate (under the reticle row) keeps style.css's .gate .gate-why look */
.vx .v-rig > .gate-why { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; font-size: var(--fs-xs); color: var(--text-2); line-height: 1.45; }
.vx .v-rig > .gate-why .ico { width: 16px; height: 16px; color: var(--amber); flex: 0 0 auto; }
.vx .v-rig > .gate-why.off .ico { color: var(--danger); }
.vx .v-rig > .gate-why .btn .ico { color: inherit; }
