/* Lo-fi black & white wireframe theme. */
:root {
  --ink: #000; --paper: #fff; --muted: #666; --line: #000;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); -webkit-text-size-adjust: 100%; }

.topbar { padding: 16px 18px 4px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 1.3rem; font-weight: 700; }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 0.8rem; }

.app { max-width: 620px; margin: 0 auto; padding: 14px 16px 30px; }
.screen { display: flex; flex-direction: column; gap: 12px; }
.lead { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.4; }
.muted-note { color: var(--muted); font-size: 0.82rem; margin: 4px 0 0; }

.screen-head { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.back { background: none; border: 0; color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; padding: 4px 2px; }
.screen-title { margin: 0; font-size: 1.15rem; text-align: center; flex: 1; }

/* Home / menu cards */
.card-btn, .menu-btn {
  text-align: left; display: flex; flex-direction: column; gap: 4px; position: relative;
  padding: 16px; border: 2px solid var(--line); border-radius: 6px;
  background: var(--paper); color: var(--ink); font: inherit; cursor: pointer;
}
.card-title { font-size: 1.1rem; font-weight: 700; }
.card-desc, .menu-desc { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }
.menu-title { font-weight: 700; }
.menu-btn.disabled { opacity: 0.5; cursor: default; }
.badge { position: absolute; top: 12px; right: 12px; font-size: 0.66rem; font-weight: 700; border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; }
.badge.big { position: static; align-self: flex-start; }
.plan-list { margin: 4px 0; padding-left: 18px; color: var(--muted); font-size: 0.86rem; line-height: 1.6; }

/* Buttons */
.btn { flex: 1 1 auto; min-width: 90px; padding: 11px 12px; border: 2px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.exit { width: 100%; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; }

/* Segmented toggles */
.segmented { display: flex; gap: 0; border: 2px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented.small { flex: 0 0 auto; }
.seg { flex: 1; padding: 9px 12px; border: 0; border-right: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; }
.seg:last-child { border-right: 0; }
.seg.active { background: var(--ink); color: var(--paper); }

/* Phone-style stage (Exercise + Error test) */
.phone { align-items: stretch; }
.ex-title { margin: 6px 0 0; font-size: 1.5rem; font-weight: 800; text-align: center; }
.ex-sub { margin: 0; text-align: center; color: var(--ink); font-size: 1rem; }
.ex-headermsg { margin: 0; text-align: center; font-weight: 700; }
.phone-stage { position: relative; width: 100%; max-width: 360px; margin: 4px auto; aspect-ratio: 3 / 4; border: 2px solid var(--line); border-radius: 6px; overflow: hidden; background: #eee; }
.cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam.hidden { opacity: 0; }
.overlay-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.demo-overlay { position: absolute; inset: 0; margin: auto; max-width: 78%; max-height: 82%; object-fit: contain; opacity: 0.6; pointer-events: none; }
.indication { position: absolute; left: 16%; right: 16%; bottom: 20%; height: 22%; border: 2px solid var(--ink); }
.speaking { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); width: 66px; height: 66px; border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; }
.correction-overlay { position: absolute; left: 8%; right: 8%; top: 10%; background: rgba(255,255,255,0.88); border: 2px solid var(--ink); padding: 8px 10px; font-size: 0.88rem; font-weight: 700; text-align: center; }

/* Test controls (Exercise AB) */
.test-controls { display: flex; flex-direction: column; gap: 8px; border: 1px dashed var(--line); border-radius: 6px; padding: 10px; }
.ctl-row { display: flex; align-items: center; gap: 10px; }
.ctl-label { width: 70px; font-size: 0.8rem; font-weight: 700; }

/* Breath-tracking visualisation (Training) */
.stage { position: relative; background: #eee; border-radius: 6px; overflow: hidden; border: 2px solid var(--line); aspect-ratio: 4 / 3; }
.view { display: block; width: 100%; height: 100%; object-fit: cover; touch-action: none; }
.hint { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 6px 8px; font-size: 0.78rem; background: rgba(255,255,255,0.85); }
.viz { display: flex; gap: 12px; height: 140px; }
.level { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 46px; }
.level-track { flex: 1; width: 100%; border: 2px solid var(--line); border-radius: 4px; display: flex; align-items: flex-end; overflow: hidden; }
.level-fill { width: 100%; height: 0%; background: var(--ink); }
.level-label, .wave-label { font-size: 0.7rem; color: var(--muted); }
.wave-wrap { flex: 1; display: flex; flex-direction: column; gap: 6px; border: 2px solid var(--line); border-radius: 4px; padding: 6px; }
.wave { flex: 1; width: 100%; height: 100%; display: block; }

/* Checklist */
.checklist { display: flex; flex-direction: column; gap: 8px; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 2px solid var(--line); border-radius: 6px; font-size: 0.9rem; cursor: pointer; }
.check-item input { width: 18px; height: 18px; accent-color: #000; }

.status { color: var(--muted); font-size: 0.84rem; margin: 4px 2px 0; min-height: 1.2em; }
.debug { color: var(--muted); font-size: 0.72rem; margin: 2px; white-space: pre-wrap; }
.foot { max-width: 620px; margin: 0 auto; padding: 14px 16px; font-size: 0.74rem; line-height: 1.4; color: var(--muted); border-top: 1px solid var(--line); }

/* --- Demo overlays (Exercise) --- */
.demo-2d-panel { position: absolute; top: 10%; left: 50%; transform: translateX(-50%);
  width: 62%; height: 44%; background: rgba(110,110,110,0.45); border-radius: 18px;
  display: flex; align-items: center; justify-content: center; pointer-events: none; }
.demo-2d { max-width: 92%; max-height: 92%; object-fit: contain; }
.demo-3d { position: absolute; top: 6px; right: 6px; width: 34%; max-height: 42%; object-fit: contain; opacity: 1; pointer-events: none; }

/* Speaking circle sits near the bottom edge of the grey panel on the Exercise screen. */
.speaking.ex-speaking { top: auto; bottom: 10%; }

/* --- Error box / auto belly box: positioned by JS --- */
.error-box { position: absolute; border: 3px solid var(--ink); display: none; pointer-events: none; }
