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

:root {
  --bg: #000;
  --panel: #0e0e12;
  --text: #e0ddd8;
  --text-dim: #7a7a84;
  --accent: #c4a882;
  --accent-dim: rgba(196,168,130,0.4);
  --blue: #82b4c4;
  --tension-low: #4a9ead;
  --tension-mid: #e8c468;
  --tension-high: #e87272;
  --font: 'Inter', -apple-system, sans-serif;
}

html, body, #app { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.screen { display: none; width: 100%; height: 100%; position: relative; }
.screen.active { display: flex; }

/* ===== SHARED BUTTONS ===== */
.btn-start {
  background: var(--accent);
  color: #000;
  border: none;
  padding: 16px 44px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  border-radius: 60px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}
.btn-start:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(196,168,130,0.25); }
.btn-start.small { padding: 10px 24px; font-size: 13px; }

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--font);
  padding: 12px 24px;
  border-radius: 60px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent-dim); }

/* ===== LANDING ===== */
#screen-landing {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(196,168,130,0.05) 0%, transparent 60%);
}
.landing { text-align: center; max-width: 580px; padding: 40px 24px; }
.brand {
  font-size: 13px; font-weight: 500; letter-spacing: 6px;
  color: var(--accent); text-transform: lowercase; margin-bottom: 40px;
}
.landing h1 { font-size: 2.8rem; font-weight: 300; line-height: 1.2; letter-spacing: -0.5px; margin-bottom: 20px; }
.sub { font-size: 15px; color: var(--text-dim); line-height: 1.7; margin: 0 auto 40px; max-width: 480px; }
.sub em { color: var(--text); font-style: normal; }
.landing .btn-ghost { margin-left: 12px; }
.note { margin-top: 24px; font-size: 12px; color: var(--text-dim); }

/* ===== MAIN VIEW ===== */
#screen-main { flex-direction: column; align-items: center; justify-content: center; }

#cam {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  object-fit: cover; opacity: 0; pointer-events: none;
}
#canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

/* Top bar */
.top-bar {
  position: absolute; top: 0; left: 0; right: 0;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: 16px; padding: 20px 24px; z-index: 10;
}
.top-right { display: flex; align-items: center; gap: 8px; }
.session-time {
  font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; margin-right: 6px;
}
.pill {
  background: rgba(20,20,24,0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-dim);
  font-size: 12px; font-family: var(--font); font-weight: 500;
  padding: 9px 16px; border-radius: 60px; cursor: pointer; transition: all 0.2s;
  white-space: nowrap;
}
.pill:hover { color: var(--text); border-color: var(--accent-dim); }
.pill.primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 600; }
.pill.primary:hover { box-shadow: 0 4px 20px rgba(196,168,130,0.3); }

.info-text {
  font-size: 14px; color: rgba(255,255,255,0.7); text-align: center;
  font-weight: 300; letter-spacing: 0.3px; text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  line-height: 1.4; min-height: 20px;
}

.pill .ico { display: none; }
.hud-dock { display: contents; }
.te-name .short { display: none; }

/* Calibration overlay */
.calib-overlay {
  position: absolute; inset: 0; display: none; flex-direction: column;
  align-items: center; justify-content: center; gap: 28px; z-index: 9;
  background: rgba(0,0,0,0.35); pointer-events: none;
}
.calib-overlay.visible { display: flex; }
.calib-ring {
  --p: 0; position: relative;
  width: 120px; height: 120px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 360deg), rgba(255,255,255,0.08) 0);
  display: grid; place-items: center;
}
.calib-ring::before { content: ''; position: absolute; width: 104px; height: 104px; border-radius: 50%; background: #000; }
.calib-ring span { position: relative; font-size: 34px; font-weight: 300; color: var(--accent); }
.calib-text { font-size: 15px; color: rgba(255,255,255,0.75); font-weight: 300; text-align: center; max-width: 320px; line-height: 1.5; }

/* Mode bar */
.mode-bar {
  position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px;
  background: rgba(20,20,24,0.85); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.06); border-radius: 60px; padding: 6px; z-index: 10;
}
.mode-btn {
  background: transparent; border: none; color: var(--text-dim);
  font-size: 13px; font-family: var(--font); font-weight: 500;
  padding: 10px 20px; border-radius: 60px; cursor: pointer; transition: all 0.2s;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active { background: rgba(196,168,130,0.15); color: var(--accent); }

/* Tension readout */
.tension-readout {
  position: absolute; top: 50%; right: 28px; transform: translateY(-50%);
  display: none; flex-direction: column; gap: 14px; z-index: 10;
  background: rgba(10,10,14,0.55); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.06); border-radius: 16px; padding: 16px 18px;
}
.tension-readout.visible { display: flex; }
.tension-zone { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.tz-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(255,255,255,0.35); }
.tz-val { font-size: 22px; font-weight: 300; font-variant-numeric: tabular-nums; transition: color 0.3s; }
.tz-legend { font-size: 9px; color: rgba(255,255,255,0.25); letter-spacing: 0.5px; text-align: right; margin-top: 4px; }

/* Symmetry meter */
.symmetry-meter {
  position: absolute; top: 50%; left: 28px; transform: translateY(-50%);
  display: none; flex-direction: column; align-items: center; gap: 10px; z-index: 10;
}
.symmetry-meter.visible { display: flex; }
.sym-bar { width: 6px; height: 200px; background: rgba(255,255,255,0.06); border-radius: 3px; position: relative; overflow: hidden; }
.sym-fill { --pct: 0; position: absolute; bottom: 0; left: 0; width: 100%; height: calc(var(--pct) * 1%); background: var(--accent); border-radius: 3px; transition: height 0.3s, width 0.3s, background 0.3s; }
.sym-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: rgba(255,255,255,0.35); writing-mode: vertical-rl; transform: rotate(180deg); }

/* ===== FINDINGS ===== */
#screen-findings { display: none; overflow-y: auto; justify-content: center; }
#screen-findings.active { display: flex; }
.findings { width: 100%; max-width: 760px; padding: 56px 24px 80px; }
.f-head { text-align: center; margin-bottom: 36px; }
.f-head .brand { margin-bottom: 20px; }
.f-head h2 { font-size: 2rem; font-weight: 300; letter-spacing: -0.3px; margin-bottom: 10px; }
.f-meta { font-size: 12px; color: var(--text-dim); }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 40px; }
.tile {
  background: var(--panel); border: 1px solid rgba(255,255,255,0.06); border-radius: 16px;
  padding: 20px 16px; text-align: center;
}
.tile-v { font-size: 34px; font-weight: 300; color: var(--accent); line-height: 1.1; margin-bottom: 8px; }
.tile-v.tile-text { font-size: 16px; font-weight: 500; padding: 9px 0; }
.tile-l { font-size: 12px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.tile-s { font-size: 11px; color: var(--text-dim); line-height: 1.4; }

.f-section { margin-bottom: 40px; }
.f-section h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 2.5px; color: var(--accent);
  font-weight: 500; margin-bottom: 18px;
}

.zrow { display: grid; grid-template-columns: 130px 1fr 90px; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.zname { font-size: 13px; }
.zbars { display: flex; flex-direction: column; gap: 5px; }
.zbar { position: relative; height: 10px; background: rgba(255,255,255,0.05); border-radius: 5px; }
.zfill { height: 100%; border-radius: 5px; transition: width 0.6s ease; }
.zfill.move { background: var(--blue); opacity: 0.8; }
.zbar span { position: absolute; right: -34px; top: -3px; font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; width: 30px; }
.zpct { font-size: 11px; color: var(--text-dim); text-align: right; }
.legend { font-size: 11px; color: var(--text-dim); margin-top: 14px; line-height: 1.6; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.sw.held { background: var(--tension-mid); }
.sw.move { background: var(--blue); }

.f-list { display: flex; flex-direction: column; gap: 10px; }
.finding { background: var(--panel); border: 1px solid rgba(255,255,255,0.06); border-left: 3px solid var(--text-dim); border-radius: 12px; padding: 16px 18px; }
.finding.warn { border-left-color: var(--tension-mid); }
.finding.good { border-left-color: var(--tension-low); }
.finding.info { border-left-color: var(--blue); }
.f-title { font-size: 14px; font-weight: 500; margin-bottom: 5px; }
.f-body { font-size: 13px; color: var(--text-dim); line-height: 1.6; }

.reco { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.reco li { font-size: 13px; line-height: 1.6; padding-left: 22px; position: relative; color: var(--text); }
.reco li::before { content: '→'; position: absolute; left: 0; color: var(--accent); }
.f-note { font-size: 11px; color: var(--text-dim); margin-top: 16px; }

.f-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.f-link { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 28px; }
.f-link a { color: var(--accent); text-decoration: none; }

/* ===== SNAPSHOT ===== */
.snapshot-view { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; gap: 24px; }
#snapshot-canvas { max-width: 80%; max-height: 60vh; border-radius: 12px; box-shadow: 0 8px 40px rgba(0,0,0,0.5); }
.snapshot-meta { font-size: 13px; color: var(--text-dim); text-align: center; line-height: 1.6; }
.snapshot-actions { display: flex; gap: 16px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 96px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: rgba(30,30,36,0.95); color: var(--text); font-size: 13px;
  padding: 10px 18px; border-radius: 60px; border: 1px solid rgba(255,255,255,0.08);
  opacity: 0; pointer-events: none; transition: all 0.25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== CAMERA ERROR ===== */
.cam-error {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.88); z-index: 30; padding: 24px;
}
.cam-error.visible { display: flex; }
.cam-error-box {
  max-width: 420px; text-align: center;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px; padding: 32px 28px;
}
.cam-error-box h3 { font-size: 18px; font-weight: 400; margin-bottom: 12px; }
.cam-error-box p { font-size: 13px; color: var(--text-dim); line-height: 1.65; margin-bottom: 24px; }
.cam-error-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cam-error-actions .btn-start { text-decoration: none; display: inline-block; }

/* ===== EMBED MODE ===== */
.embed-only { display: none; }
body.embed .embed-only { display: block; }
body.embed .full-only { display: none; }
body.embed .landing { padding: 28px 20px; }
body.embed .brand { margin-bottom: 24px; }
body.embed .sub { margin-bottom: 28px; }
body.embed .findings { padding: 36px 24px 56px; }

/* ===== TAPE SIMULATOR ===== */
.tape-panel {
  position: absolute; top: 50%; left: 24px; transform: translateY(-50%);
  display: none; flex-direction: column; gap: 12px; z-index: 10; width: 208px;
  background: rgba(10,10,14,0.62); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.07); border-radius: 16px; padding: 16px;
}
.tape-panel.visible { display: flex; }
.tp-head {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.6px;
  color: rgba(255,255,255,0.35);
}
.tape-list { display: flex; flex-direction: column; gap: 3px; }
.tape-btn {
  background: transparent; border: 1px solid transparent; color: var(--text-dim);
  font-family: var(--font); font-size: 12.5px; font-weight: 500; text-align: left;
  padding: 8px 11px; border-radius: 9px; cursor: pointer; transition: all 0.15s;
}
.tape-btn:hover { color: var(--text); background: rgba(255,255,255,0.04); }
.tape-btn.active {
  background: rgba(232,196,104,0.14); color: var(--tension-mid);
  border-color: rgba(232,196,104,0.28);
}

.tape-sides { display: flex; gap: 3px; }
.side-btn {
  flex: 1; background: rgba(255,255,255,0.04); border: none; color: var(--text-dim);
  font-family: var(--font); font-size: 11px; padding: 6px 0; border-radius: 7px;
  cursor: pointer; transition: all 0.15s;
}
.side-btn:hover { color: var(--text); }
.side-btn.active { background: rgba(196,168,130,0.2); color: var(--accent); }

.tape-tension { display: flex; flex-direction: column; gap: 6px; }
.tt-head {
  display: flex; justify-content: space-between; font-size: 10px;
  text-transform: uppercase; letter-spacing: 1.4px; color: rgba(255,255,255,0.35);
}
.tt-head span:last-child { color: var(--tension-mid); letter-spacing: 0.6px; }
#tape-tension {
  -webkit-appearance: none; appearance: none; width: 100%; height: 3px;
  background: rgba(255,255,255,0.14); border-radius: 3px; outline: none; cursor: pointer;
}
#tape-tension::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 13px; height: 13px;
  border-radius: 50%; background: var(--tension-mid); cursor: pointer;
}
#tape-tension::-moz-range-thumb {
  width: 13px; height: 13px; border: none; border-radius: 50%;
  background: var(--tension-mid); cursor: pointer;
}

.tape-note {
  font-size: 11px; line-height: 1.55; color: rgba(255,255,255,0.42);
  border-top: 1px solid rgba(255,255,255,0.07); padding-top: 10px;
}

.tape-effect {
  position: absolute; top: 50%; right: 24px; transform: translateY(-50%);
  display: none; flex-direction: column; gap: 8px; z-index: 10; width: 208px;
  background: rgba(10,10,14,0.62); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.07); border-radius: 16px; padding: 16px;
}
.tape-effect.visible { display: flex; }
.te-head {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1.6px;
  color: rgba(255,255,255,0.35); margin-bottom: 2px;
}
.te-head span { color: var(--blue); letter-spacing: 0.6px; }
.te-row { display: grid; grid-template-columns: 1fr 46px 34px; align-items: center; gap: 7px; padding: 3px 0; }
.te-name { font-size: 11.5px; color: var(--text-dim); }
.te-bar { height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; overflow: hidden; }
.te-bar i { display: block; height: 100%; background: var(--blue); border-radius: 2px; transition: width 0.25s; }
.te-val { font-size: 11px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.te-foot {
  font-size: 9.5px; line-height: 1.5; color: rgba(255,255,255,0.28);
  border-top: 1px solid rgba(255,255,255,0.07); padding-top: 9px; margin-top: 4px;
}

}

/* ===== TAPE SOURCE + SCANNER ===== */
.tape-src { display: flex; gap: 3px; margin-bottom: 2px; }
.src-btn {
  flex: 1; background: rgba(255,255,255,0.04); border: none; color: var(--text-dim);
  font-family: var(--font); font-size: 11px; font-weight: 500; padding: 7px 4px;
  border-radius: 7px; cursor: pointer; transition: all 0.15s;
}
.src-btn:hover { color: var(--text); }
.src-btn.active { background: rgba(196,168,130,0.2); color: var(--accent); }
.src-btn.wide { width: 100%; flex: none; margin-top: 8px; }

.btn-scan {
  width: 100%; background: var(--accent); color: #000; border: none;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  padding: 11px 0; border-radius: 9px; cursor: pointer; transition: all 0.15s;
}
.btn-scan:hover { box-shadow: 0 6px 20px rgba(196,168,130,0.28); }

.scan-result { margin-top: 11px; display: flex; flex-direction: column; gap: 7px; }
.sr-empty { font-size: 11.5px; line-height: 1.5; color: rgba(255,255,255,0.35); }
.sr-title {
  font-size: 13px; font-weight: 500; color: var(--accent);
  padding-bottom: 7px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sr-title.miss { color: var(--tension-mid); }
.sr-note {
  font-size: 11.5px; line-height: 1.55; color: var(--text-dim);
  padding-left: 10px; border-left: 2px solid rgba(255,255,255,0.12);
}
.sr-note.ok { border-left-color: var(--tension-low); color: rgba(224,221,216,0.85); }
.sr-note.warn { border-left-color: var(--tension-mid); }
.sr-note.bad { border-left-color: var(--tension-high); }
.sr-note.info { border-left-color: var(--blue); }

/* ===== PHONE LAYOUT =====
   Everything that used to float beside the face moves into a dock at the bottom,
   so the face itself is never covered. */
@media (max-width: 720px) {
  .landing h1 { font-size: 2rem; }
  .landing .btn-ghost { margin: 12px 0 0; display: block; width: 100%; }

  /* Top bar collapses to icons */
  .top-bar { grid-template-columns: auto 1fr auto; padding: 12px 12px 0; gap: 8px; }
  .info-text { grid-column: 1 / -1; order: 3; font-size: 13px; padding: 6px 4px 0; }
  .session-time { display: none; }
  .pill { padding: 9px 12px; font-size: 13px; }
  .pill .lbl { display: none; }
  .pill .ico { display: inline; }
  .pill.primary { padding: 9px 16px; font-size: 12px; }

  .mode-bar { bottom: 12px; padding: 4px; gap: 0; left: 10px; right: 10px; transform: none; justify-content: space-between; }
  .mode-btn { padding: 9px 6px; font-size: 12px; flex: 1; }

  /* The dock */
  .hud-dock {
    display: flex; flex-direction: column; gap: 6px;
    position: absolute; left: 10px; right: 10px; bottom: 66px; z-index: 10;
    max-height: 48vh; pointer-events: none;
  }
  .hud-dock > * { position: static !important; transform: none !important; width: auto !important; pointer-events: auto; }

  /* Tension: one row of chips */
  .tension-readout { flex-direction: row; justify-content: space-between; gap: 2px; padding: 8px 8px 6px; border-radius: 14px; }
  .tension-zone { align-items: center; flex: 1; gap: 1px; }
  .tz-label { font-size: 8px; letter-spacing: 1px; }
  .tz-val { font-size: 18px; }
  .tz-legend { display: none; }

  /* Symmetry: horizontal bar */
  .symmetry-meter {
    flex-direction: row; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px;
    background: rgba(10,10,14,0.55); border: 1px solid rgba(255,255,255,0.06);
  }
  .sym-bar { width: 100%; height: 6px; flex: 1; }
  .sym-fill { bottom: 0; left: 0; height: 100%; width: calc(var(--pct) * 1%); }
  .sym-label { writing-mode: horizontal-tb; transform: none; white-space: nowrap; }

  /* Tape controls: horizontal chips, scrollable if the verdict is long */
  .tape-panel { padding: 8px 10px; gap: 7px; border-radius: 14px; overflow-y: auto; max-height: 34vh; }
  .tp-head { display: none; }
  .tape-list { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; scrollbar-width: none; }
  .tape-list::-webkit-scrollbar { display: none; }
  .tape-btn { white-space: nowrap; font-size: 11.5px; padding: 7px 10px; }
  .tape-sides { gap: 4px; }
  .tape-tension { flex-direction: row; align-items: center; gap: 10px; }
  .tt-head { flex: none; gap: 6px; }
  .tape-note { display: none; }
  .scan-result { margin-top: 8px; gap: 5px; }
  .sr-title { font-size: 12.5px; padding-bottom: 5px; }
  .sr-note { font-size: 11px; line-height: 1.45; }
  .btn-scan { padding: 9px 0; font-size: 12.5px; }
  .src-btn.wide { margin-top: 6px; }

  /* Tape effect: one row of chips */
  .tape-effect { flex-direction: column; gap: 4px; padding: 7px 10px 6px; border-radius: 14px; }
  .te-head { margin-bottom: 0; font-size: 9px; }
  #te-rows { display: flex; gap: 3px; }
  .te-row { display: flex; flex-direction: column; align-items: center; flex: 1; gap: 2px; padding: 0; }
  .te-name .full { display: none; }
  .te-name .short { display: inline; font-size: 8.5px; letter-spacing: 0.6px; text-transform: uppercase; }
  .te-val { font-size: 13px; text-align: center; }
  .te-bar { width: 100%; height: 3px; }
  .te-foot { display: none; }

  /* Findings page */
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .zrow { grid-template-columns: 90px 1fr 70px; gap: 10px; }
  .zbar span { right: -30px; }
}

/* Collapse toggle — only meaningful on phones, where the panel sits over the face */
.tp-collapse { display: none; }
@media (max-width: 720px) {
  .tp-collapse {
    display: inline-flex; align-items: center; justify-content: center;
    flex: none; width: 32px; background: rgba(255,255,255,0.04); border: none;
    color: var(--text-dim); font-size: 13px; border-radius: 7px; cursor: pointer;
  }
  .tape-panel.collapsed > :not(.tape-src) { display: none !important; }
}

/* ===== ROLLOUT ===== */
.mode-btn[hidden] { display: none !important; }
body.single-mode .mode-bar { display: none; }
@media (max-width: 720px) {
  body.single-mode .hud-dock { bottom: 14px; }   /* no mode bar to clear */
}
