:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.topbar {
  padding: 28px 32px 18px;
  border-bottom: 1px solid #23232f;
  background: var(--bg-primary);
  flex-shrink: 0;
}
.topbar.slim {
  padding: 20px 28px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.title { font-size: 40px; font-weight: 800; letter-spacing: -0.5px; }
.title.sm { font-size: 30px; font-weight: 700; }
.subtitle { margin-top: 6px; font-size: 18px; color: var(--text-secondary); }
.content {
  flex: 1; display: flex; flex-direction: column; gap: 16px;
  padding: 22px 28px; overflow: hidden;
}
.content.menu { justify-content: center; }
.content.pad { gap: 18px; }
.center-col { align-items: center; justify-content: center; text-align: center; }

/* ---------- cards / buttons ---------- */
.card {
  display: flex; align-items: center; gap: 18px;
  width: 100%;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  min-height: 88px;
  text-align: left;
  font-family: inherit;
}
.card-action { border: 2px solid transparent; }
.card.primary { background: linear-gradient(135deg, #0d2a33, #103a44); }
.card.primary .card-ico { color: var(--accent); }
.card-ico {
  font-size: 30px; width: 46px; height: 46px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-secondary);
}
.card-text { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.card-title { font-size: 24px; font-weight: 700; }
.card-sub { font-size: 16px; color: var(--text-secondary); }
.card-val { font-size: 30px; color: var(--text-muted); flex-shrink: 0; }
.stop-btn { justify-content: center; background: var(--bg-tertiary); margin-top: auto; }
.stop-btn .card-title { color: var(--danger); font-size: 26px; }

/* ---------- monitor ---------- */
.pill {
  font-size: 20px; font-weight: 800; letter-spacing: 1px;
  padding: 8px 20px; border-radius: 999px;
  background: rgba(0,255,136,0.15); color: var(--accent-secondary);
  border: 1px solid rgba(0,255,136,0.4);
  transition: all 0.2s ease;
}
.pill.warn {
  background: rgba(255,180,0,0.16); color: #ffb400; border-color: rgba(255,180,0,0.5);
}
.pill.bad {
  background: rgba(255,68,102,0.18); color: var(--danger); border-color: rgba(255,68,102,0.55);
}
.src-tag {
  font-size: 13px; font-weight: 700; letter-spacing: 1.5px;
  color: var(--text-muted); border: 1px solid #2a2a38;
  padding: 5px 10px; border-radius: 6px;
}
.monitor-body { gap: 12px; align-items: center; }
.head-stage {
  width: 100%; display: flex; justify-content: center;
  height: 188px; flex-shrink: 0;
}
.head-svg { height: 188px; width: auto; }
.head-svg .ref-line { stroke: #2c2c3a; stroke-width: 2; stroke-dasharray: 5 7; }
.head-svg .ground { stroke: #2c2c3a; stroke-width: 3; stroke-linecap: round; }
.head-svg .spine { stroke: var(--accent); stroke-width: 8; stroke-linecap: round; }
.head-svg .skull { fill: var(--bg-tertiary); stroke: var(--accent); stroke-width: 5; }
.head-svg .nose { fill: var(--accent); }
.head-svg .eye { fill: var(--text-primary); }
#head-group { transition: transform 0.12s linear; }
.head-svg.warn .spine, .head-svg.warn .skull, .head-svg.warn .nose { stroke: #ffb400; }
.head-svg.warn .nose { fill: #ffb400; }
.head-svg.bad .spine, .head-svg.bad .skull, .head-svg.bad .nose { stroke: var(--danger); }
.head-svg.bad .nose { fill: var(--danger); }

.readout { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.deg { font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.deg-label { font-size: 15px; font-weight: 700; letter-spacing: 2px; color: var(--text-secondary); }

.bar-wrap { width: 100%; }
.bar-track {
  position: relative; width: 100%; height: 16px;
  background: var(--bg-tertiary); border-radius: 999px; overflow: hidden;
}
.bar-fill {
  position: absolute; left: 0; top: 0; height: 100%; width: 0%;
  background: var(--accent-secondary); border-radius: 999px;
  transition: width 0.12s linear, background 0.2s ease;
}
.bar-fill.warn { background: #ffb400; }
.bar-fill.bad { background: var(--danger); }
.bar-thresh {
  position: absolute; top: -3px; width: 3px; height: 22px;
  background: var(--text-primary); border-radius: 2px; left: 41%;
}
.bar-legend {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--text-muted); margin-top: 5px;
}

.stats { display: flex; gap: 14px; width: 100%; }
.stat {
  flex: 1; background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.stat-num { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 13px; color: var(--text-secondary); letter-spacing: 0.5px; }

/* ---------- alert overlay ---------- */
.alert-overlay {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center;
  box-shadow: inset 0 0 120px 40px rgba(255,68,102,0.55);
  border: 6px solid var(--danger);
  pointer-events: none;
}
.alert-overlay.active { display: flex; animation: flash 0.7s steps(1) infinite; }
.alert-text {
  font-size: 64px; font-weight: 900; text-align: center; letter-spacing: 2px;
  color: var(--danger); text-shadow: 0 0 24px rgba(255,68,102,0.7);
}
@keyframes flash { 50% { opacity: 0.25; } }

/* ---------- calibrate ---------- */
.lead { font-size: 22px; line-height: 1.45; color: var(--text-primary); }
.center-col .lead { max-width: 480px; }
.cal-big {
  font-size: 120px; color: var(--accent);
  width: 180px; height: 180px; display: flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums; font-weight: 700;
}
.cal-big.counting { color: var(--accent-secondary); }
.cal-big.done { color: var(--accent-secondary); }

/* ---------- about ---------- */
.info-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.info-list li {
  font-size: 19px; color: var(--text-secondary); line-height: 1.4;
  padding-left: 22px; position: relative;
}
.info-list li::before { content: "›"; position: absolute; left: 0; color: var(--accent); font-weight: 800; }
.info-list b { color: var(--text-primary); }
.muted-note { font-size: 16px; color: var(--text-muted); line-height: 1.4; margin-top: 4px; }
