/* 站桩 posture coach — deliberate dark, calm look.
   Color roles follow the validated reference palette (dark mode):
   surface #1a1a19, page #0d0d0d, status good #0ca30c, warning #fab219. */

:root {
  color-scheme: dark;
  --page:        #0d0d0d;
  --surface:     #1a1a19;
  --surface-2:   #222220;
  --ink:         #ffffff;
  --ink-2:       #c3c2b7;
  --ink-muted:   #898781;
  --hairline:    rgba(255, 255, 255, 0.10);
  --grid:        #2c2c2a;
  --good:        #0ca30c;
  --warn:        #fab219;
  --jade:        #199e70;
  --jade-soft:   rgba(25, 158, 112, 0.18);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  background: var(--page);
  color: var(--ink-2);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- header ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: calc(1rem + var(--safe-t)) calc(1.5rem + var(--safe-r)) 1rem calc(1.5rem + var(--safe-l));
  border-bottom: 1px solid var(--hairline);
}

.brand { display: flex; align-items: center; gap: 0.9rem; }

.hanzi {
  font-size: 2rem;
  color: var(--jade);
  line-height: 1;
  user-select: none;
}

h1 { font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.sub { font-size: 0.8rem; color: var(--ink-muted); }

.controls { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface);
}

.seg {
  font: inherit;
  font-size: 0.82rem;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  padding: 0.45rem 0.95rem;
  cursor: pointer;
}
.seg.active { background: var(--jade-soft); color: var(--ink); }

.btn {
  font: inherit;
  font-size: 0.85rem;
  color: #06230b;
  background: var(--jade);
  border: 0;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  color: #04160d;
  font-weight: 600;
}
.btn:hover { filter: brightness(1.1); }
.btn:active, .seg:active, .preset:active, .chip:active { transform: translateY(1px); }
:is(.btn, .seg, .preset, .chip, .stage-btn, summary, .checklist li):focus-visible {
  outline: 2px solid var(--jade);
  outline-offset: 2px;
}

.btn.ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--hairline);
  font-weight: 500;
}
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.small { font-size: 0.78rem; padding: 0.35rem 0.7rem; }
.btn.icon { padding: 0.4rem 0.6rem; font-size: 1rem; line-height: 1; }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}
.toggle input { display: none; }
.knob {
  width: 34px; height: 19px;
  border-radius: 999px;
  background: var(--grid);
  position: relative;
  transition: background 0.2s;
}
.knob::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--ink-2);
  transition: transform 0.2s;
}
.toggle input:checked + .knob { background: var(--jade); }
.toggle input:checked + .knob::after { transform: translateX(15px); background: #fff; }

/* ---------- layout ---------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
  gap: 1.25rem;
  padding: 1.25rem 1.5rem;
  align-items: start;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

@media (max-width: 940px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- stage ---------- */

.stage { min-width: 0; }

/* The stage takes the stream's own shape (--ar, set from the camera), so a
   phone held upright gets a tall stage, not a letterboxed strip. Video and
   overlay both `contain` into the same box, so the skeleton stays on the body
   whatever shape the box ends up. */
.video-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  aspect-ratio: var(--ar, 4 / 3);
  max-height: calc(100vh - 11rem);
  max-height: calc(100svh - 11rem);
  width: 100%;
}
.video-wrap video,
.video-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.video-wrap.mirrored video,
.video-wrap.mirrored canvas { transform: scaleX(-1); }

.veil {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 13, 13, 0.72);
  z-index: 3;
  text-align: center;
}
.veil-inner p { color: var(--ink-2); font-size: 0.9rem; }
.cal-count { font-size: 3rem; color: var(--ink); font-weight: 200; }

.phase-badge {
  position: absolute;
  left: 12px; top: 12px;
  z-index: 2;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  color: var(--ink);
  background: rgba(13, 13, 13, 0.62);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(4px);
}
.phase-badge.jade { border-color: rgba(25,158,112,0.6); color: #7fd8b4; }
.phase-badge.warn { border-color: rgba(250,178,25,0.6); color: var(--warn); }

.stage-btn {
  position: absolute;
  right: 10px; top: 10px;
  z-index: 2;
  width: 40px; height: 40px;
  border-radius: 50%;
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: rgba(13, 13, 13, 0.62);
  border: 1px solid var(--hairline);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

/* Glanceable from where you stand: the clock and the spoken cue. */
.hud {
  position: absolute;
  right: 14px; bottom: 12px;
  z-index: 2;
  pointer-events: none;
}
.hud-time {
  font-size: clamp(2rem, 7vw, 3.6rem);
  font-weight: 200;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.9);
}
.caption {
  position: absolute;
  left: 50%; top: 14px;
  transform: translate(-50%, -6px);
  z-index: 2;
  max-width: min(90%, 36rem);
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  font-size: clamp(0.95rem, 2.6vw, 1.3rem);
  line-height: 1.35;
  text-align: center;
  color: var(--ink);
  background: rgba(13, 13, 13, 0.7);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.caption.show { opacity: 1; transform: translate(-50%, 0); }
.caption:empty { display: none; }
/* while a caption shows, move the phase badge out of its way */
.video-wrap:has(.caption.show) .phase-badge { top: auto; bottom: 12px; }

.spinner {
  width: 28px; height: 28px;
  margin: 0 auto 0.8rem;
  border: 3px solid var(--grid);
  border-top-color: var(--jade);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.status-bar {
  margin-top: 0.6rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  color: var(--ink-2);
}
.status-bar.ok { border-color: rgba(12, 163, 12, 0.4); }
.status-bar.warn { border-color: rgba(250, 178, 25, 0.45); color: var(--warn); }

.stage-hint { margin-top: 0.5rem; font-size: 0.78rem; color: var(--ink-muted); }

/* ---------- panel tiles ---------- */

.panel { display: flex; flex-direction: column; gap: 1rem; }

.row { display: grid; grid-template-columns: auto 1fr; gap: 1rem; }

.tile, .card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 0.9rem 1rem;
}

.score-tile {
  position: relative;
  width: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.ring { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: var(--grid); }
.ring-fg {
  stroke: var(--jade);
  stroke-linecap: round;
  stroke-dasharray: 226.2;   /* 2π·36 */
  stroke-dashoffset: 226.2;
  transition: stroke-dashoffset 0.4s ease, stroke 0.4s ease;
}
.score-text {
  position: absolute;
  top: 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.score-num { font-size: 1.25rem; color: var(--ink); font-weight: 600; }
.score-label { font-size: 0.6rem; color: var(--ink-muted); letter-spacing: 0.05em; }
.score-word { font-size: 0.78rem; color: var(--ink-2); min-height: 1.1em; }

.still-tile { display: flex; flex-direction: column; justify-content: center; gap: 0.55rem; }

.tile-head, .card-head {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.tile-sub { font-size: 0.72rem; font-weight: 400; color: var(--ink-muted); }
.tile-foot { font-size: 0.78rem; color: var(--ink-2); }

.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--grid);
  overflow: hidden;
}
.meter.slim { height: 5px; margin-top: 0.6rem; }
.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--jade);
  transition: width 0.35s ease, background 0.35s ease;
}
.meter-fill.jade { background: var(--jade); }

/* ---------- checklist ---------- */

.checklist { list-style: none; display: flex; flex-direction: column; }

.checklist li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  column-gap: 0.6rem;
  padding: 0.5rem 0.3rem;
  margin: 0 -0.3rem;
  border-bottom: 1px solid var(--hairline);
  align-items: baseline;
  cursor: pointer;
  border-radius: 6px;
  transition: opacity 0.25s, background 0.2s;
}
.checklist li:hover { background: var(--surface-2); }
.checklist li:last-child { border-bottom: 0; }
.checklist.focused li:not(.focus) { opacity: 0.42; }
.checklist li.focus .check-label { color: var(--ink); }
.checklist .dot { grid-column: 1; grid-row: 1; }
.checklist .check-label { grid-column: 2; grid-row: 1; }
.focus-pill {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--jade);
  border: 1px solid rgba(25,158,112,0.5);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  visibility: hidden;
}
.checklist li.focus .focus-pill { visibility: visible; }
.focus-note { font-size: 0.74rem; color: var(--ink-muted); margin: 0.35rem 0 0.4rem; line-height: 1.4; }
.focus-note.active { color: var(--jade); }

.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--grid);
  align-self: center;
  transition: background 0.3s;
}
.dot.good { background: var(--good); }
.dot.adjust { background: var(--warn); }
.dot.unmeasured { background: transparent; border: 1px solid var(--ink-muted); }

.check-label { font-size: 0.83rem; color: var(--ink); }
.check-msg {
  grid-column: 2;
  font-size: 0.76rem;
  color: var(--ink-muted);
  min-height: 1em;
}
.check-msg.adjust { color: var(--warn); }

/* ---------- timer ---------- */

.presets { display: flex; align-items: center; gap: 0.4rem; margin: 0.7rem 0; flex-wrap: wrap; }
.preset {
  font: inherit;
  font-size: 0.8rem;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
}
.preset.active { background: var(--jade-soft); color: var(--ink); border-color: rgba(25,158,112,0.5); }
.preset:disabled, .chip:disabled { opacity: 0.45; cursor: default; }

.length-row { display: flex; align-items: center; gap: 0.7rem; margin: -0.2rem 0 0.8rem; }
.length-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--jade);
  cursor: pointer;
}
.length-row input[type="range"]:disabled { opacity: 0.45; cursor: default; }
.length-label {
  font-size: 0.78rem;
  color: var(--ink-2);
  min-width: 3.6rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.preset-unit { font-size: 0.75rem; color: var(--ink-muted); }

.timer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.timer {
  font-size: 1.7rem;
  font-weight: 200;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.timer-btns { display: flex; gap: 0.5rem; }
.phase { font-size: 0.74rem; color: var(--ink-muted); margin-top: 0.1rem; min-height: 1em; }
.phase.live { color: var(--jade); }
.phase.warn { color: var(--warn); }
.session-tools { display: flex; gap: 0.5rem; margin-top: 0.7rem; flex-wrap: wrap; }

/* ---------- tips / closing ---------- */

.tip-card .card-head .tile-sub { text-align: right; }
.tip-card .tip {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--ink-2);
  margin-top: 0.5rem;
  font-style: italic;
}

.closing { border-color: rgba(25, 158, 112, 0.45); }
.closing p { font-size: 0.85rem; line-height: 1.5; margin-top: 0.5rem; }

/* ---------- summary / history ---------- */

.summary { border-color: rgba(25, 158, 112, 0.45); }
.summary-list, .history-list { list-style: none; margin-top: 0.5rem; }
.summary-list li { font-size: 0.85rem; line-height: 1.6; color: var(--ink-2); }
.next-step { font-size: 0.82rem; color: var(--jade); margin-top: 0.5rem; line-height: 1.45; min-height: 0; }
.next-step:empty { display: none; }

.history-list li {
  display: grid;
  grid-template-columns: minmax(7.2rem, auto) 3.2rem 1fr auto;
  gap: 0.6rem;
  font-size: 0.78rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.history-list li:last-child { border-bottom: 0; }
.history-list .h-date { color: var(--ink-muted); }
.history-list .h-partial { color: var(--warn); }
.history-list .h-bar {
  align-self: center;
  height: 6px;
  border-radius: 999px;
  background: var(--grid);
  overflow: hidden;
}
.history-list .h-bar span { display: block; height: 100%; background: var(--jade); border-radius: 999px; }
.history-list .h-score { color: var(--ink-muted); }

/* ---------- settings dialog ---------- */

.settings {
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 1.1rem 1.3rem 1.3rem;
  width: min(520px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
}
.settings::backdrop { background: rgba(0, 0, 0, 0.6); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.settings h2 { font-size: 1rem; color: var(--ink); font-weight: 600; }
.settings h3 {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 1rem 0 0.5rem;
  font-weight: 600;
}
.settings section + section { border-top: 1px solid var(--hairline); }
.field {
  display: grid;
  grid-template-columns: 9rem 1fr;
  align-items: center;
  gap: 0.6rem;
  margin: 0.45rem 0;
  font-size: 0.85rem;
}
.field > span { color: var(--ink-2); }
.field select, .settings select {
  font: inherit;
  font-size: 0.82rem;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  max-width: 100%;
}
.field-row { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; margin: 0.45rem 0; }
.check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; margin: 0.4rem 0; cursor: pointer; }
.check.indent { margin-left: 1.4rem; color: var(--ink-muted); }
.check input { accent-color: var(--jade); }
.hint { font-size: 0.74rem; color: var(--ink-muted); line-height: 1.45; margin: 0.3rem 0 0; }

/* ---------- footer ---------- */

.foot {
  padding: 0.9rem calc(1.5rem + var(--safe-r)) calc(1.3rem + var(--safe-b)) calc(1.5rem + var(--safe-l));
  border-top: 1px solid var(--hairline);
}
.foot p { font-size: 0.75rem; color: var(--ink-muted); max-width: 72ch; }

/* ---------- intention chips ---------- */

.intentions { display: flex; align-items: center; gap: 0.4rem; margin: 0 0 0.8rem; flex-wrap: wrap; }
.chip {
  font: inherit;
  font-size: 0.74rem;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  cursor: pointer;
}
.chip:hover { color: var(--ink-2); background: var(--surface-2); }
.chip.active { color: var(--ink); background: var(--jade-soft); border-color: rgba(25,158,112,0.5); }

/* ---------- open session / hidden clock ---------- */

.timer.open::after { content: " open"; font-size: 0.8rem; color: var(--ink-muted); font-weight: 400; }
.timer.veiled { letter-spacing: 0.3em; color: var(--ink-muted); }

/* ---------- guide card ---------- */

.guide details { border-top: 1px solid var(--hairline); }
.guide details:first-of-type { border-top: 0; margin-top: 0.3rem; }
.guide summary {
  cursor: pointer;
  padding: 0.55rem 0;
  font-size: 0.85rem;
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after { content: "+"; color: var(--ink-muted); font-size: 0.9rem; }
.guide details[open] summary::after { content: "–"; }
.guide ol, .guide ul { margin: 0 0 0.7rem 1.1rem; }
.guide li { font-size: 0.8rem; color: var(--ink-2); line-height: 1.5; padding: 0.12rem 0; }
.guide li .fix { display: block; color: var(--ink-muted); font-size: 0.75rem; }
.guide .badge {
  display: inline-block;
  margin-left: 0.4rem;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--jade);
  border: 1px solid rgba(25,158,112,0.45);
  border-radius: 999px;
  padding: 0 0.35rem;
  vertical-align: 0.1em;
}
.guide .principle { margin: 0.2rem 0 0.6rem; }
.guide .principle h4 { font-size: 0.8rem; color: var(--ink); font-weight: 600; margin-bottom: 0.15rem; }
.guide .principle ul { margin-left: 1.1rem; }
.guide .formula { font-size: 0.8rem; color: var(--jade); margin: 0.2rem 0 0.6rem; }

/* ---------- the session card leads the panel ---------- */

.session-card { border-color: rgba(25, 158, 112, 0.35); }
.session-card .timer { font-size: 2.2rem; }
.session-card #startBtn { padding: 0.65rem 1.3rem; font-size: 0.95rem; }

/* ---------- phone dock ---------- */

.dock { display: none; }
.phone-only { display: none; }

/* ---------- touch ---------- */

@media (pointer: coarse) {
  .phone-only { display: block; }
  #stageHint { display: none; } /* the phone-specific hint replaces it */
  /* 44 px targets, per the platform guidelines */
  .seg { padding: 0.65rem 1rem; }
  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; padding: 0.45rem 0.8rem; }
  .btn.icon { min-width: 44px; }
  .preset { min-width: 44px; min-height: 40px; font-size: 0.88rem; }
  .chip { min-height: 36px; padding: 0.35rem 0.8rem; font-size: 0.8rem; }
  .checklist li { padding: 0.65rem 0.3rem; }
  .checklist li:hover, .chip:hover { background: transparent; }
  .guide summary { padding: 0.8rem 0; }
  .toggle { min-height: 44px; }
  .length-row input[type="range"] { height: 32px; }
  .field select, .settings select { min-height: 40px; font-size: 16px; } /* 16px: no iOS zoom-on-focus */
  .check { min-height: 36px; }
  .check input { width: 20px; height: 20px; }
}

/* ---------- narrow screens (phones) ---------- */

@media (max-width: 640px) {
  .topbar { gap: 0.6rem; padding-top: calc(0.7rem + var(--safe-t)); padding-bottom: 0.7rem; padding-left: calc(1rem + var(--safe-l)); padding-right: calc(1rem + var(--safe-r)); }
  .hanzi { font-size: 1.6rem; }
  h1 { font-size: 0.98rem; }
  .sub { display: none; }
  .controls { width: 100%; gap: 0.5rem; justify-content: space-between; }
  .controls .segmented { flex: 1; }
  .controls .seg { flex: 1; padding-left: 0.4rem; padding-right: 0.4rem; }
  #calibrateBtn { padding-left: 0.7rem; padding-right: 0.7rem; }
  .toggle .knob + * { display: none; }

  .layout { padding: 0.75rem calc(0.75rem + var(--safe-r)) 0.75rem calc(0.75rem + var(--safe-l)); gap: 0.9rem; }
  .video-wrap { border-radius: 12px; max-height: calc(100svh - 9rem); }
  .stage-hint { font-size: 0.8rem; }
  .row { grid-template-columns: 1fr 1.4fr; gap: 0.75rem; }
  .score-tile { width: auto; }
  .still-tile .tile-head { flex-direction: column; align-items: flex-start; gap: 0.1rem; }
  .card-head { flex-wrap: wrap; }
  .timer-row { flex-wrap: wrap; }
  .timer-btns { flex-wrap: wrap; }
  .history-list li { grid-template-columns: 6.4rem 3rem 1fr auto; gap: 0.4rem; }
  .field { grid-template-columns: 1fr; gap: 0.3rem; }
  .field select, .settings select { width: 100%; min-width: 0; text-overflow: ellipsis; }
  .settings { width: 100vw; max-width: 100vw; max-height: 100svh; height: 100svh; margin: 0; border-radius: 0; padding: calc(1rem + var(--safe-t)) calc(1rem + var(--safe-r)) calc(1.5rem + var(--safe-b)) calc(1rem + var(--safe-l)); }
  .settings .segmented { width: 100%; }
  .settings .seg { flex: 1; }

  /* the dock appears once the session card's Begin button has scrolled away,
     and always while a session runs */
  .dock {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem calc(1rem + var(--safe-r)) calc(0.6rem + var(--safe-b)) calc(1rem + var(--safe-l));
    background: rgba(20, 20, 19, 0.92);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--hairline);
    transform: translateY(110%);
    transition: transform 0.25s ease;
  }
  body.card-away .dock { transform: none; }
  body.card-away .foot { padding-bottom: calc(5rem + var(--safe-b)); }
  .dock-clock { flex: 1; display: flex; flex-direction: column; min-width: 0; }
  .dock-time { font-size: 1.4rem; font-weight: 200; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.1; }
  .dock-phase { font-size: 0.72rem; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dock-phase.live { color: var(--jade); }
  .dock-phase.warn { color: var(--warn); }
  .dock .btn { min-width: 6rem; }
}

/* phone on its side: one-line header, video and panel side by side */
@media (max-height: 520px) and (orientation: landscape) {
  .topbar { flex-wrap: nowrap; padding-top: calc(0.4rem + var(--safe-t)); padding-bottom: 0.4rem; gap: 0.6rem; }
  .brand h1, .sub { display: none; }
  .hanzi { font-size: 1.4rem; }
  .controls { flex-wrap: nowrap; gap: 0.5rem; }
  .seg { padding-top: 0.45rem; padding-bottom: 0.45rem; }
  .btn { min-height: 38px; }
  .layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); padding-top: 0.6rem; }
  .video-wrap { max-height: calc(100svh - 4.5rem); }
  .stage { position: sticky; top: 0.5rem; }
  .status-bar { font-size: 0.8rem; padding: 0.35rem 0.7rem; }
  .stage-hint { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.01ms !important; }
}

/* ---------- while standing: hide the setup, keep the controls ---------- */

body.practising .session-card :is(.presets, .length-row, .intentions),
body.practising .session-card .card-head .tile-sub { display: none; }
