/* tour.css: Camera Tour (pages/tour.js) — handoff ฉบับ 4 "Scanner" · every colour comes from tokens.css
   Full-screen camera, one-handed (controls in the bottom third, mic on the thumb side: data-hand), readable in sun.
   HUD rules (ข้อ A/B/G): no border-radius except the round mic · primary = amber chamfer · secondary = cyan line ·
   Latin labels uppercase in Chakra Petch, Thai sentences in Anuphan and NEVER letter-spaced (.th / .t-prog-th) ·
   Arabic digits only · no glow / blur / gradient wash / glitch / scanline / typewriter · panels over the camera are opaque.
   Two schemes (Settings → DISPLAY, or the sun button on the live screen):
     night (default) = the design: --panel-solid, --text, --muted, --scan, --amber
     sun = tour-only daylight HUD: the --sun-* tokens (PTTEP panel, navy-black text, PTTEP deep blue + deep PPE orange).
   Contrast (WCAG, computed):
     night  text/panel 14.4 · muted/panel 5.1 · scan/panel 6.8 · amber/panel 6.6 · bg-on-amber 7.4 · danger text 7.1
     sun    see the --sun-* block in tokens.css
   Arrow / viewfinder / reticle: coloured stroke over a 2× wider --bg outline → readable on any camera image. */

body.tour-mode { overflow: hidden; }
body.tour-mode main#view { padding: 0; max-width: none; }

.tour {
  --t-bg: var(--bg);
  --t-panel: var(--panel-solid);
  --t-line: var(--line-strong);
  --t-text: var(--text);
  --t-text-2: var(--muted);
  --t-hud: var(--scan);             /* labels, brackets, focus, info */
  --t-btn: var(--amber);            /* primary fill (chamfer) + "alive": progress, mic, live dot */
  --t-on-btn: var(--on-amber);
  --t-ok: var(--ok);
  --t-danger: var(--danger);
  --t-danger-bg: var(--danger-strong);
  --t-danger-text: var(--on-danger-strong);
  --t-outline: var(--bg);           /* outline under arrow / viewfinder so they read on any camera image */
  --t-track: var(--track);
  --t-soft: var(--scan-soft);
  color: var(--t-text);
  font-family: var(--font-ui);
}
/* live tour (camera running): fixed full screen over everything, no app chrome (body.focus-mode.tour-mode) */
.tour.live {
  position: fixed; inset: 0; z-index: 40;
  background: var(--t-bg);
  display: flex; flex-direction: column;
  overflow: hidden;
}
/* TOUR tab page in SUN (intro / setup / errors): light page body; header + tab bar keep their own background */
body.tour-sun { background-color: var(--sun-bg); background-image: none; }
.tour[data-contrast="sun"] {
  color-scheme: light;
  --t-bg: var(--sun-bg);
  --t-panel: var(--sun-bg);
  --t-line: var(--sun-line);
  --t-text: var(--sun-text);
  --t-text-2: var(--sun-muted);
  --t-hud: var(--sun-hud);
  --t-btn: var(--sun-btn);
  --t-on-btn: var(--sun-on-btn);
  --t-ok: var(--sun-ok);
  --t-danger: var(--sun-danger);
  --t-danger-bg: var(--sun-danger);
  --t-danger-text: var(--sun-on-danger);
  --t-outline: var(--bg);
  --t-track: var(--sun-track);
  --t-soft: var(--sun-hud-soft);
}
.tour :focus-visible { outline: 2px solid var(--t-hud); outline-offset: 2px; }
.tour .lbl { color: var(--t-hud); }
.tour .lbl.muted { color: var(--t-text-2); }
.tour .th, .tour .t-prog-th { letter-spacing: 0; text-transform: none; }
.tour .mock-flag {
  font-family: var(--font-hud); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  min-height: 28px; padding: 0 10px; display: inline-flex; align-items: center;
  background: var(--t-panel); color: var(--t-btn); border: 1px solid var(--t-btn);
}
.t-num { font-family: var(--font-hud); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- buttons */
.t-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px;
  border: 1px solid var(--t-line); background: var(--t-panel); color: var(--t-hud);
  font-family: var(--font-hud); font-size: 14px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  cursor: pointer; text-decoration: none; text-align: center;
  transition: transform 140ms var(--ease-out), background-color 120ms ease;
}
.t-btn:active { transform: scale(.97); }
.t-btn .ico { width: 20px; height: 20px; }
.t-btn.primary { background: var(--t-btn); border-color: transparent; color: var(--t-on-btn); clip-path: var(--chamfer); font-weight: 700; letter-spacing: .14em; }
.t-btn.th { text-transform: none; letter-spacing: 0; font-family: var(--font-ui); font-size: 15px; }
.t-btn.big { min-height: 58px; font-size: 15px; padding: 0 28px; }
.t-btn.block { width: 100%; }
.t-btn.ghost { background: transparent; border-color: transparent; }
.t-btn[disabled] { opacity: .5; cursor: not-allowed; clip-path: none; }
.t-icon {
  width: 48px; height: 48px; display: grid; place-items: center; flex: 0 0 auto;
  border: 1px solid var(--t-line); background: var(--t-panel); color: var(--t-hud); cursor: pointer;
  transition: transform 140ms var(--ease-out);
}
.t-icon:active { transform: scale(.95); }
.t-icon .ico { width: 22px; height: 22px; }
.t-icon[aria-pressed="true"] { border-color: var(--t-hud); background: var(--t-soft); }
.t-pill-btn {
  white-space: nowrap; flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  min-height: 48px; padding: 0 14px 0 10px; border: 1px solid var(--t-line);
  background: var(--t-panel); color: var(--t-hud); cursor: pointer; text-decoration: none;
  font-family: var(--font-hud); font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
}
.t-pill-btn .ico { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- screens without the camera */
.t-screen {
  flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top) + 20px) max(20px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 24px) max(20px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 20px;
  max-width: 520px; width: 100%; margin: 0 auto;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
}
.tour[data-contrast="sun"] .t-screen { background-image: none; }

/* ---------------------------------------------------------------- the TOUR tab page (not live): normal page flow */
.t-page { display: flex; flex-direction: column; gap: 20px; max-width: 720px; }
.t-head { margin-bottom: 0; flex-wrap: nowrap; align-items: center; }
.t-head .titles { flex: 1 1 auto; }
.tour[data-contrast="sun"] .t-head h1 { color: var(--t-text); }
.tour[data-contrast="sun"] .t-head .kicker { color: var(--t-hud); }
.t-last { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.t-last-text { margin: 0; color: var(--t-text-2); line-height: 1.6; }
.t-last .t-list { margin-top: 2px; }
.t-screen .t-top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.t-kicker { font-family: var(--font-hud); font-size: var(--lbl-size); font-weight: 600; letter-spacing: var(--lbl-track); text-transform: uppercase; color: var(--t-hud); margin: 0; }
.t-h1 { font-family: var(--font-hud); font-weight: 600; font-size: 1.875rem; line-height: 1.25; letter-spacing: .04em; margin: 4px 0 0; }
.t-lead { color: var(--t-text-2); font-size: 1rem; line-height: 1.7; margin: 0; }
.t-steps-list { list-style: none; margin: 0; padding: 0; }
.t-steps-list li { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: baseline; padding: 12px 0; border-top: 1px solid var(--t-line); }
.t-steps-list li:last-child { border-bottom: 1px solid var(--t-line); }
.t-steps-list b { color: var(--t-hud); font-family: var(--font-hud); font-weight: 600; font-size: 15px; letter-spacing: .08em; }
.t-steps-list span { font-family: var(--font-hud); font-size: 16px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
.t-steps-list small { display: block; font-family: var(--font-ui); text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--t-text-2); font-size: .9375rem; margin-top: 2px; }
/* READY 3 แห่งพร้อมทัวร์ · 10 ประโยค */
.t-ready { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; color: var(--t-text-2); font-size: .9375rem; }
.t-ready .t-num { color: var(--t-btn); font-size: 1.5rem; line-height: 1; }
/* setup summary (wizard opens from EDIT) */
.t-setup { padding: 12px 14px 6px; }
.t-setup-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.t-setup .t-edit { min-height: 44px; padding: 0 10px; margin-right: -10px; }
.t-setup-first { margin: 0 0 6px; color: var(--t-text-2); font-size: .9375rem; line-height: 1.55; }
.t-setup-rows { display: grid; }
.t-kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 40px; border-top: 1px solid var(--t-line); }
.t-kv .v { font-family: var(--font-hud); font-weight: 600; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; }
.t-note { color: var(--t-text-2); font-size: .875rem; line-height: 1.6; margin: 0; display: flex; gap: 8px; align-items: flex-start; }
.t-note .ico { width: 18px; height: 18px; margin-top: 3px; flex: 0 0 auto; color: var(--t-hud); }
.t-actions { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
/* intro: START TOUR always in the thumb zone, even when the explanation scrolls */
/* sits just above the tab bar (--nav-h + safe area); main#view's own bottom padding leaves room below it */
.t-actions.sticky {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 2;
  margin: 0 calc(-1 * var(--edge)); padding: 12px var(--edge);
  background: var(--t-bg); border-top: 1px solid var(--t-line);
}
@media (min-width: 900px) { .t-actions.sticky { position: static; margin: 0; padding: 4px 0 0; max-width: 420px; border-top: 0; background: transparent; } }
.t-checks { list-style: none; margin: 0; padding: 0; display: grid; }
.t-checks li { display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--t-line); }
.t-checks li > span:first-of-type { font-family: var(--font-hud); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; font-size: 14px; }
.t-checks li .st { margin-left: auto; color: var(--t-text-2); font-family: var(--font-hud); font-weight: 500; font-size: .875rem; letter-spacing: 0; text-align: right; }
.t-checks li[data-st="ok"] .st { color: var(--t-ok); }
.t-checks li[data-st="bad"] .st { color: var(--t-danger); }
.t-checks li[data-st="wait"] .ico { color: var(--t-btn); }
.t-checks .ico { width: 22px; height: 22px; color: var(--t-hud); }
.t-bar { height: 6px; background: var(--t-track); overflow: hidden; }
.t-bar > span { display: block; height: 100%; width: 100%; background: var(--t-btn); transform-origin: left; transform: scaleX(0); transition: transform 200ms var(--ease-out); }
.t-big-ico { width: 64px; height: 64px; color: var(--t-hud); }
.t-big-ico .ico { width: 64px; height: 64px; stroke-width: 1.5; }
.t-list { list-style: none; margin: 8px 0 0; padding: 0; }
.t-list li { display: flex; align-items: center; gap: 12px; min-height: 56px; border-top: 1px solid var(--t-line); font-family: var(--font-hud); font-weight: 600; font-size: 17px; }
.t-list li:last-child { border-bottom: 1px solid var(--t-line); }
.t-list li .t-num { color: var(--t-hud); font-size: 14px; letter-spacing: .08em; width: 28px; }
.t-list li .ico { color: var(--t-ok); width: 22px; height: 22px; margin-left: auto; }

/* setup wizard inside the tour (lib/wizard.js renders; the tour root is the scroll box) */
.t-wz .wizard { width: 100%; }
/* sun: re-point the shared tokens inside the wizard so style.css/wizard.css components follow the daylight scheme */
.tour[data-contrast="sun"] .t-wz, body.tour-sun .wizard {
  --bg: var(--sun-bg); --panel: var(--sun-bg); --panel-solid: var(--sun-bg); --text: var(--sun-text); --muted: var(--sun-muted);
  --scan: var(--sun-hud); --amber: var(--sun-btn); --on-amber: var(--sun-on-btn); --track: var(--sun-track);
  --line: var(--sun-line-soft); --line-strong: var(--sun-line); --line-field: var(--sun-line); --focus: var(--sun-hud);
  --scan-soft: var(--sun-hud-soft); --amber-soft: var(--sun-btn-soft);
  background: var(--sun-bg); color: var(--sun-text);
}
.tour[data-contrast="sun"] .t-wz .wz-foot { background: var(--sun-bg); }
.t-choices { display: flex; flex-direction: column; gap: 8px; }
.t-choices.row { flex-direction: row; }
.t-choices.row .t-choice { flex: 1 1 0; }
.t-choice { display: block; position: relative; cursor: pointer; }
.t-choice input { position: absolute; opacity: 0; pointer-events: none; }
.t-choice-box {
  display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; padding: 10px 14px;
  border: 1px solid var(--t-line); border-top: 2px solid var(--t-track); background: var(--t-panel);
  transition: background-color 120ms ease;
}
.t-choice .k { font-family: var(--font-hud); font-weight: 600; font-size: 14px; letter-spacing: .12em; text-transform: uppercase; color: var(--t-text); }
.t-choices.row .t-choice .k { text-align: center; }
.t-choice .th-d { font-size: .9375rem; line-height: 1.5; color: var(--t-text-2); }
.t-choice input:checked + .t-choice-box { background: var(--t-soft); border-color: var(--t-hud); border-top-color: var(--t-hud); }
.t-choice input:checked + .t-choice-box .k { color: var(--t-hud); }
.t-choice input:focus-visible + .t-choice-box { outline: 2px solid var(--t-hud); outline-offset: 2px; }

/* ---------------------------------------------------------------- live camera screen */
.t-live { position: absolute; inset: 0; background: var(--camera-bg); }
.t-cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--camera-bg); }
.t-layer {
  position: absolute; inset: 0; display: flex; flex-direction: column; pointer-events: none;
  padding: calc(env(safe-area-inset-top) + 10px) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
}
.t-layer > * { pointer-events: auto; }
.t-top { display: flex; align-items: center; gap: 8px; }
.t-state {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  background: var(--t-panel); color: var(--t-hud); border: 1px solid var(--t-line);
  font-family: var(--font-hud); font-weight: 600; font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.t-state .dot { width: 8px; height: 8px; background: var(--t-hud); flex: 0 0 auto; }
.t-state[data-tone="live"] .dot { background: var(--t-btn); }
.t-state[data-tone="off"] .dot { background: var(--t-danger); }
.t-top .spacer { flex: 1 1 auto; }
.t-end { color: var(--t-text); }

.t-banners { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.t-banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px;
  background: var(--t-panel); color: var(--t-text); border: 1px solid var(--t-line); border-left: 3px solid var(--t-hud);
  font-size: .9375rem; line-height: 1.5;
}
.t-banner[hidden] { display: none; }
.t-banner .ico { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 2px; color: var(--t-hud); }
.t-banner strong { display: block; font-family: var(--font-hud); font-weight: 600; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--t-hud); }
.t-banner .sub { display: block; }
.t-banner.danger { background: var(--t-danger-bg); color: var(--t-danger-text); border-color: var(--t-danger-bg); }
.t-banner.danger .ico, .t-banner.danger strong { color: var(--t-danger-text); }

/* centre: viewfinder brackets + arrow + instruction */
.t-guide { position: relative; flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 0; padding: 18px 10px; pointer-events: none; }
.t-guide > * { pointer-events: auto; }
.t-vf { position: absolute; inset: 6px 0; pointer-events: none; transition: opacity 200ms var(--ease-out); }
.t-vf .c { position: absolute; width: 44px; height: 44px; }
.t-vf .c svg { width: 100%; height: 100%; display: block; overflow: visible; }
.t-vf .c.tl { left: 0; top: 0; }
.t-vf .c.tr { right: 0; top: 0; transform: rotate(90deg); }
.t-vf .c.br { right: 0; bottom: 0; transform: rotate(180deg); }
.t-vf .c.bl { left: 0; bottom: 0; transform: rotate(270deg); }
.t-vf .o { stroke: var(--t-outline); stroke-width: 8; fill: none; stroke-linecap: square; }
.t-vf .f { stroke: var(--scan); stroke-width: 3; fill: none; stroke-linecap: square; }
.tour[data-vf="dim"] .t-vf { opacity: .45; }

.t-arrow { width: min(46vw, 200px); height: min(46vw, 200px); flex: 0 1 auto; transition: transform 200ms var(--ease-in-out), opacity 200ms var(--ease-out); }
.t-arrow svg { width: 100%; height: 100%; display: block; overflow: visible; }
.t-arrow .o { stroke: var(--t-outline); stroke-width: 24; fill: none; stroke-linecap: square; stroke-linejoin: miter; }
.t-arrow .f { stroke: var(--amber); stroke-width: 12; fill: none; stroke-linecap: square; stroke-linejoin: miter; }
.t-arrow[data-dir="left"] { transform: rotate(180deg); }
.t-arrow[data-dir="up"] { transform: rotate(-90deg); }
.t-arrow[data-dir="down"] { transform: rotate(90deg); }
.t-arrow[data-bit="1"] { transform: scale(.78); }
.t-arrow[data-dir="left"][data-bit="1"] { transform: rotate(180deg) scale(.78); }
.t-arrow[hidden] { display: none; }

.t-panel { background: var(--t-panel); color: var(--t-text); border: 1px solid var(--t-line); }
/* featured panel: corner brackets (top-left + bottom-right), 2px HUD colour (ข้อ B) */
.t-bracket { position: relative; }
.t-bracket::before, .t-bracket::after { content: ""; position: absolute; width: var(--bracket); height: var(--bracket); pointer-events: none; }
.t-bracket::before { top: -1px; left: -1px; border-top: 2px solid var(--t-hud); border-left: 2px solid var(--t-hud); }
.t-bracket::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--t-hud); border-right: 2px solid var(--t-hud); }
.t-instr { padding: 14px 18px 16px; text-align: center; max-width: 100%; width: min(100%, 420px); }
.t-instr .big { font-family: var(--font-hud); font-weight: 600; font-size: 1.75rem; line-height: 1.3; margin: 0; }
.t-instr .mid { font-size: 1.125rem; font-weight: 500; line-height: 1.5; margin: 0; }
.t-instr .sub { color: var(--t-text-2); font-size: 1rem; margin: 4px 0 0; line-height: 1.55; }
.t-instr .who { color: var(--t-text-2); font-size: .9375rem; line-height: 1.55; margin: 0 0 10px; text-align: left; }
.t-instr .who b { font-family: var(--font-hud); font-weight: 600; letter-spacing: .16em; color: var(--t-hud); font-size: 12px; margin-right: 6px; }
/* the guide's words: Anuphan 18/500 + a 2px cyan lead line on the left (ข้อ D) — no typewriter */
.t-instr .say { font-size: 1.125rem; line-height: 1.65; font-weight: 500; margin: 0; text-align: left; border-left: 2px solid var(--t-hud); padding-left: 12px; max-height: 40vh; overflow-y: auto; }
.t-instr .t-bar { margin-top: 12px; }
.t-instr .t-bar > span { transition: transform 100ms linear; }
.t-instr[hidden] { display: none; }
.tour[data-answer="1"] .t-guide { justify-content: flex-end; }
.t-dots { display: inline-flex; gap: 6px; margin-left: 8px; vertical-align: middle; }
.t-dots i { width: 7px; height: 7px; background: var(--t-hud); animation: t-dot 1200ms infinite; }
.t-dots i:nth-child(2) { animation-delay: 200ms; } .t-dots i:nth-child(3) { animation-delay: 400ms; }
@keyframes t-dot { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.t-thinking { font-family: var(--font-hud); font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--t-hud); font-size: 14px; margin: 0; }

/* perch row (above the toasts / bottom panel): the mascot on the side away from the mic · photo 1 on the mic side.
   Never over the viewfinder centre, the arrow or the thumb controls; data-hand="left" mirrors it. */
.t-perch { display: flex; align-items: flex-end; gap: 8px; pointer-events: none; min-height: 0; }
.t-perch > * { pointer-events: auto; }
.t-perch .spacer { flex: 1 1 auto; pointer-events: none; }
.tour[data-hand="left"] .t-perch { flex-direction: row-reverse; }
.t-mascot { position: relative; width: 96px; height: 136px; flex: 0 0 auto; margin: 0 0 8px; }
.t-mascot[hidden] { display: none; }
/* the selected robot body (mascot/body.js, SVG, ≤ 30 fps here) standing on a small opaque HUD plate:
   the camera image can be anything (dark ground, bright sky), the plate gives the body the same backdrop as on
   the Q&A screen — night: --panel-solid behind the cyan visor · sun: the light panel behind the dark body */
.t-mascot .mb, .t-mascot-cv, .t-mascot .mb-raven-cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.t-mascot::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 58%; background: var(--t-panel); border: 1px solid var(--t-line); border-bottom: 2px solid var(--t-hud); pointer-events: none; }
.t-mascot::after { content: ""; position: absolute; left: -1px; bottom: calc(58% - 12px); width: var(--bracket); height: var(--bracket); border-top: 2px solid var(--t-hud); border-left: 2px solid var(--t-hud); pointer-events: none; }
.t-mascot .raven-fallback { position: absolute; left: 0; top: 24px; width: 96px; height: 80px; }
/* AUTO SWITCH (ADR 0033): each body in its own layer; the next mascot fades in over the shown one in 200 ms, no
   particles (the overlay is a still picture, ADR 0020) · .now = jump to the end of the fade (an input came) */
/* .t-mascot > : must beat mascot.css .mb-host { position: relative } (the body module marks its host) */
.t-mascot > .t-mascot-layer { position: absolute; inset: 0; transition: opacity 200ms ease-out; }
.t-mascot-layer.dim { opacity: 0; }
.t-mascot-layer.now { transition: none; }
/* left hand: the mascot sits on the right edge — mirror the drawing so it still faces the middle of the screen */
.tour[data-hand="left"] .t-mascot .mb, .tour[data-hand="left"] .t-mascot-cv, .tour[data-hand="left"] .t-mascot .mb-raven-cv, .tour[data-hand="left"] .t-mascot .raven-fallback { transform: scaleX(-1); }

/* photo 1 of the place being lined up (GET /tour/anchor/{sha}.jpg) */
.t-anchor { align-self: flex-end; width: 112px; margin: 0 0 8px; padding: 4px; }
.t-anchor[hidden] { display: none; }
.t-anchor img { display: block; width: 100%; height: auto; max-height: 140px; object-fit: contain; background: var(--t-track); }
.t-anchor figcaption { font-family: var(--font-hud); font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--t-hud); padding: 4px 2px 0; text-align: center; }

/* toasts above the bottom panel = thumb zone (undo · replay · resume) */
.t-toasts { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.t-undo, .t-replay, .t-resume { display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 14px; position: relative; overflow: hidden; }
.t-undo[hidden], .t-replay[hidden], .t-resume[hidden] { display: none; }
.t-undo .txt, .t-replay .txt, .t-resume .txt { flex: 1 1 auto; min-width: 0; font-size: .9375rem; line-height: 1.45; color: var(--t-text-2); }
.t-undo .txt b, .t-replay .txt b { display: block; font-family: var(--font-hud); font-weight: 600; font-size: 15px; color: var(--t-text); }
.t-undo .t-btn, .t-replay .t-btn, .t-resume .t-btn { min-height: 48px; padding: 0 16px; white-space: nowrap; }
.t-undo .countdown { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--t-btn); transform-origin: left; }
.t-undo .countdown.run { animation: t-countdown var(--t-undo-ms, 5000ms) linear forwards; }
@keyframes t-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* bottom panel: place + progress + mic (thumb zone; data-hand="left" mirrors it) */
.t-bottom {
  display: flex; align-items: flex-end; gap: 12px;
  margin: 0 calc(-1 * max(12px, env(safe-area-inset-right))) 0 calc(-1 * max(12px, env(safe-area-inset-left)));
  padding: 12px max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 12px) max(16px, env(safe-area-inset-left));
  background: var(--t-panel); border-top: 1px solid var(--t-line);
}
.tour[data-hand="left"] .t-bottom { flex-direction: row-reverse; }
.t-place { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-self: center; }
.t-name { font-family: var(--font-hud); font-weight: 600; font-size: 1.5rem; line-height: 1.25; margin: 0; overflow-wrap: break-word; text-wrap: balance; }
.t-name.none { color: var(--t-text-2); font-size: 1.125rem; }
.t-prog { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; color: var(--t-text-2); }
.t-prog-k { font-family: var(--font-hud); font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--t-btn); }
.t-prog-k:empty, .t-prog-th:empty { display: none; }
.t-prog-th { font-size: .875rem; }
/* segment cells (ข้อ D VOICE grid): done amber · current cyan outline blinking · rest track */
.t-foot { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.t-foot:empty { display: none; }
.t-foot i { width: 14px; height: 9px; border: 1px solid var(--t-track); }
.t-foot i.done { background: var(--t-btn); border-color: var(--t-btn); }
.t-foot i.now { border-color: var(--t-hud); animation: t-now 1600ms infinite; }
@keyframes t-now { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.t-caption { font-size: 1.0625rem; line-height: 1.6; margin: 2px 0 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.t-caption:empty { display: none; }
.t-caption.muted { color: var(--t-text-2); font-size: .9375rem; }
.t-caption.one { -webkit-line-clamp: 1; }

/* mic: round amber button (the only radius besides nothing) inside a static reticle; sweep turns only while LISTENING */
.t-mic-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 0 0 auto; width: 112px; }
.t-mic-ret { position: relative; width: 108px; height: 108px; display: grid; place-items: center; }
.t-mic-ret > svg, .t-mic-sweep { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.t-mic-ret > svg { overflow: visible; }
.t-mic-ret > svg .o { display: none; }
.t-mic-ret > svg .f { stroke: var(--t-hud); stroke-width: 1.5; fill: none; }
.t-mic-ret.off > svg .f { stroke: var(--t-track); }
.t-mic-sweep { opacity: 0; transition: opacity 200ms var(--ease-out); }
.t-mic-sweep svg { width: 100%; height: 100%; display: block; overflow: visible; }
.t-mic-sweep .o { display: none; }
.t-mic-sweep .f { stroke: var(--t-hud); stroke-width: 2; stroke-linecap: square; }
.t-mic-ret.listening .t-mic-sweep { opacity: 1; animation: t-sweep 2400ms linear infinite; }
@keyframes t-sweep { to { transform: rotate(360deg); } }
.t-mic {
  width: 80px; height: 80px; border-radius: 50%; border: 0; display: grid; place-items: center; position: relative; z-index: 1; cursor: pointer;
  background: var(--t-panel); color: var(--t-btn); box-shadow: inset 0 0 0 2px var(--t-btn);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 140ms var(--ease-out), background-color 120ms ease;
}
.t-mic .ico { width: 34px; height: 34px; }
.t-mic:active { transform: scale(.95); }
.t-mic.on { background: var(--t-btn); color: var(--t-on-btn); }
.t-mic[disabled] { box-shadow: inset 0 0 0 2px var(--t-track); color: var(--t-text-2); cursor: not-allowed; }
.t-mic-label { font-size: .8125rem; line-height: 1.35; text-align: center; color: var(--t-text-2); }
.t-mic-label .cmd { display: block; font-family: var(--font-hud); font-weight: 600; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--t-hud); }
.t-mic-label .hf-row { display: inline-flex; align-items: center; gap: 6px; }
.t-hf { display: inline-flex; gap: 3px; align-items: center; height: 14px; }
.t-hf i { width: 3px; height: 14px; background: var(--t-btn); transform: scaleY(.25); transition: transform 90ms linear; }

.t-debug {
  position: absolute; left: max(12px, env(safe-area-inset-left)); top: calc(env(safe-area-inset-top) + 64px); z-index: 2;
  margin: 0; padding: 8px 10px; max-width: calc(100% - 24px); font: 12px/1.45 var(--font-mono);
  background: var(--bg-deep); color: var(--text); border: 1px solid var(--line-strong); white-space: pre-wrap; pointer-events: auto;
}
.t-debug[hidden] { display: none; }
.t-debug .dir { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.t-debug .dir button { font: 12px var(--font-ui); min-height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); background: var(--panel-solid); color: var(--scan); cursor: pointer; }
.t-debug .dir button[aria-pressed="true"] { background: var(--amber); color: var(--on-amber); border-color: var(--amber); }

/* settings sheet content (the sheet itself is the app's dialog, always night) */
.t-set .seg { width: 100%; }
.t-set .seg label { flex: 1 1 0; }
.t-set .seg label span { justify-content: center; width: 100%; }
.t-set .fps-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.t-set .fps-row input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--amber); min-height: 44px; }
.t-adv { border-top: 1px solid var(--line); padding-top: 4px; }
.t-adv > summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; list-style: none; }
.t-adv > summary::before { content: "+"; font-family: var(--font-hud); margin-right: 10px; color: var(--scan); }
.t-adv[open] > summary::before { content: "−"; }
.t-adv > summary::-webkit-details-marker { display: none; }

@media (min-width: 900px) {
  .t-layer { padding-left: 24px; padding-right: 24px; }
  .t-bottom { margin-left: -24px; margin-right: -24px; padding-left: 24px; padding-right: 24px; }
  .t-bottom > .t-place { max-width: 760px; }
}
@media (prefers-reduced-motion: reduce) {
  .t-foot i.now { animation: none; }
  /* opacity-only state dots keep blinking (v3.1 §6.1, same as .dots); live level bars hold still */
  .t-dots i { animation-duration: 1200ms !important; animation-iteration-count: infinite !important; }
  .t-hf i { transition: none; transform: scaleY(.5) !important; }
  .t-mic-ret.listening .t-mic-sweep { animation: none; }   /* static sweep line */
  .t-undo .countdown.run { animation: none; }
  .t-arrow, .t-btn, .t-icon, .t-mic, .t-vf, .t-mic-sweep, .t-mascot > .t-mascot-layer { transition: none; }
  .t-btn:active, .t-icon:active, .t-mic:active { transform: none; }
}
.t-adv .btn { min-height: var(--touch); }
.t-set .switch > .th { font-family: var(--font-ui); font-size: 1rem; font-weight: 400; color: var(--text); }
