/* Matches the macOS app's design system exactly: solid fills, one hairline for
   elevation, no gradients, no glow, no shadows. Hue carries breath state and
   nothing else; metrics stay grey until they cross a threshold worth reacting
   to. Token values are lifted from Sources/HRVTuner/Theme.swift. */

:root {
  --bg:       #07080c;
  --bg-lift:  #0b0d12;
  --surface:  #0e1016;
  --hairline: rgba(255, 255, 255, 0.075);

  --text:  #e8eaf0;
  --text2: #8a90a0;
  --text3: #565c6b;

  --inhale: #5ac8e0;
  --exhale: #7fd4b0;
  --hold:   #aaa5e6;
  --empty:  #656d82;

  --good: #71d79d;
  --warn: #e0a85a;
  --bad:  #e0685a;
  --hr:   #e57173;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  --round: ui-rounded, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* Must outrank the `display: flex` on #viewBreathe below — an explicit display
   value beats the hidden attribute's UA default, which silently left the
   Breathe view rendering underneath Analyze. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; }

button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
p { margin: 0 0 9px; }
p:last-child { margin-bottom: 0; }

.label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text3);
}
.mono { font-family: var(--mono); font-size: 11.5px; }
.num { font-family: var(--round); font-variant-numeric: tabular-nums; }
.dim { color: var(--text3); }
.spacer { flex: 1 1 auto; }
.sep { width: 1px; height: 16px; background: var(--hairline); }

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

header {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 18px; border-bottom: 1px solid var(--hairline);
  flex: none; flex-wrap: wrap;
}
.link { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text2); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); flex: none; }
.dot.on { background: var(--good); }
.scene { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.scene #sceneName { font-size: 11.5px; color: var(--text); white-space: nowrap; }
.scene .mono { color: var(--text3); white-space: nowrap; }

.btn {
  background: rgba(255,255,255,.09); border: 1px solid var(--hairline);
  color: var(--text); border-radius: 7px; padding: 6px 12px;
  font-size: 12px; font-weight: 500;
}
.btn:hover:not(:disabled) { background: rgba(255,255,255,.14); }
.btn.primary { background: var(--inhale); color: #07080c; border-color: transparent; font-weight: 600; }
.btn.icon { padding: 4px 9px; }
.linkbtn {
  background: none; border: none; color: var(--text2);
  font-size: 11.5px; padding: 11px 0 0;
}
.linkbtn:hover { color: var(--text); }

.modes {
  display: flex; gap: 2px; padding: 2px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 8px;
}
.mode {
  background: none; border: none; color: var(--text2);
  font-size: 11.5px; padding: 5px 11px; border-radius: 6px;
}
.mode.on { background: rgba(255,255,255,.10); color: var(--text); font-weight: 600; }

.timer {
  display: flex; align-items: center; gap: 8px; padding: 5px 9px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 8px;
}
.timer.done { border-color: rgba(113,215,157,.4); }
.timer .clock {
  font-family: var(--round); font-variant-numeric: tabular-nums;
  font-size: 13px; font-weight: 500; min-width: 46px; color: var(--text2);
}
.timer.running .clock { color: var(--text); }
.timer.done .clock { color: var(--good); }
.timer .bar { width: 58px; height: 3px; background: rgba(255,255,255,.08); border-radius: 2px; overflow: hidden; }
.timer .bar i { display: block; height: 100%; width: 0; background: var(--inhale); }
.timer.done .bar i { background: var(--good); }
.timer select { background: none; border: none; color: var(--text3); font: inherit; font-size: 11.5px; padding: 0; }

/* ---------- breathe ---------- */

#viewBreathe { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.breathe-stack {
  flex: 1 1 auto; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0; padding: 16px; min-height: 0;
}

.orb-wrap { width: min(42vh, 420px); aspect-ratio: 1; flex: none; }
.orb-wrap.small { width: 132px; }
.orb-wrap canvas { width: 100%; height: 100%; display: block; }

.phase { display: flex; align-items: baseline; gap: 12px; margin-top: 14px; }
.word { font-size: 14px; font-weight: 500; letter-spacing: 3.4px; }
.word.sm { font-size: 11px; letter-spacing: 2.4px; margin-top: 8px; }
.phase .left { font-family: var(--round); font-variant-numeric: tabular-nums; font-size: 14px; color: var(--text3); }

.coherence { text-align: center; margin-top: 26px; }
.coherence .value {
  font-family: var(--round); font-variant-numeric: tabular-nums;
  font-size: 58px; font-weight: 600; line-height: 1; color: var(--text3);
}
.coherence .label { margin-top: 6px; }
.coherence .meter {
  position: relative; width: 232px; height: 5px; margin: 10px auto 0;
  background: rgba(255,255,255,.07); border-radius: 3px;
}
.coherence .meter i { display: block; height: 100%; width: 0; background: var(--text3); border-radius: 3px; }
.coherence .meter b {
  position: absolute; left: 85%; top: -3px;
  width: 1.5px; height: 11px; background: rgba(255,255,255,.35);
}
.coherence .hint { font-size: 11.5px; color: var(--text3); margin-top: 8px; height: 16px; }

.strip {
  display: flex; flex: none; padding: 13px 0; background: var(--bg-lift);
  border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
}
.strip .cell { flex: 1; text-align: center; }
.strip .cell .v {
  font-family: var(--round); font-variant-numeric: tabular-nums;
  font-size: 19px; font-weight: 500; margin-top: 3px;
}
.strip .cell .u { font-size: 10px; color: var(--text3); margin-left: 4px; font-weight: 400; }

.transport {
  display: flex; align-items: center; gap: 12px; flex: none;
  padding: 10px 18px; background: var(--bg);
}
.spk { font-size: 11px; filter: grayscale(1); opacity: .55; }
input[type="range"] { accent-color: var(--text2); width: 150px; }
.chk { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--text2); }

/* ---------- analyze ---------- */

#viewAnalyze { flex: 1 1 auto; overflow-y: auto; padding: 14px; }
.cols { display: flex; gap: 12px; align-items: flex-start; max-width: 1180px; margin: 0 auto; }
.col-left { width: 286px; flex: none; display: flex; flex-direction: column; gap: 12px; }
.col-right { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 880px) { .cols { flex-direction: column; } .col-left { width: 100%; } }

.panel {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: 14px; padding: 14px;
}
.panel.center { display: flex; flex-direction: column; align-items: center; }
.panel .big { font-size: 15px; font-weight: 500; margin-top: 3px; }

.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.kv { margin-top: 9px; }
.kv .r { display: flex; justify-content: space-between; align-items: baseline; padding: 3.5px 0; }
.kv .r .k { font-size: 13px; color: var(--text2); }
.kv .r .val { font-family: var(--round); font-variant-numeric: tabular-nums; font-size: 13px; }
.kv .r.hero .val { font-size: 15px; font-weight: 600; color: var(--inhale); }
.kv hr { border: none; border-top: 1px solid var(--hairline); margin: 9px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.chip {
  background: rgba(255,255,255,.05); border: 1px solid var(--hairline);
  color: var(--text2); border-radius: 7px; padding: 6px 11px; font-size: 11.5px;
}
.chip:hover { background: rgba(255,255,255,.09); }
.chip.on { background: var(--inhale); border-color: transparent; color: #07080c; font-weight: 600; }
.chip small { display: block; font-size: 9.5px; opacity: .72; font-weight: 400; }

.chart canvas { width: 100%; height: 122px; display: block; margin-top: 8px; }
.chart-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.chart-head .hint { font-size: 10px; color: var(--text3); }

.note { font-size: 11.5px; color: var(--text3); line-height: 1.55; margin-top: 11px; }
.note strong { color: var(--text2); }

.banner {
  margin: 12px 18px 0; padding: 10px 14px; border-radius: 10px; font-size: 12.5px;
  background: rgba(224,168,90,.09); border: 1px solid rgba(224,168,90,.3); color: var(--text);
}
.banner.bad { background: rgba(224,104,90,.09); border-color: rgba(224,104,90,.3); }
