: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; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--bg-tertiary);
  flex: 0 0 auto;
}
.title {
  font-size: 22px; font-weight: 700; letter-spacing: 4px;
  color: var(--text-primary);
}
.hint { font-size: 13px; color: var(--text-muted); letter-spacing: 1px; }
.badge {
  font-size: 13px; font-weight: 700; letter-spacing: 2px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--bg-tertiary); color: var(--text-secondary);
}
.badge[data-state="live"] { color: var(--accent-secondary); background: rgba(0,255,136,0.12); }
.badge[data-state="demo"] { color: var(--accent); background: rgba(0,212,255,0.12); }
.badge[data-state="off"]  { color: var(--text-muted); }

/* ---------- compass (home) ---------- */
.compass {
  flex: 1 1 auto; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.dial, .rose, .readout {
  position: absolute; top: 50%; left: 50%;
}
.dial {
  width: 392px; height: 392px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 50% 50%, var(--bg-secondary) 0%, var(--bg-primary) 72%, var(--bg-tertiary) 100%);
  border: 2px solid var(--bg-tertiary);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.7);
}
.rose {
  width: 360px; height: 360px;
  transform: translate(-50%, -50%) rotate(0deg);
  will-change: transform;
}
.tick {
  position: absolute; left: 50%; top: 50%;
  width: 2px; height: 9px; margin-left: -1px; margin-top: -4.5px;
  background: var(--text-muted);
  transform-origin: 50% 50%;
}
.tick-major { height: 16px; margin-top: -8px; background: var(--text-secondary); }
.tick-card  { height: 22px; margin-top: -11px; width: 3px; margin-left: -1.5px; background: var(--accent); }
.rose-label {
  position: absolute; left: 50%; top: 50%;
  width: 36px; height: 36px; margin-left: -18px; margin-top: -18px;
  line-height: 36px; text-align: center;
  font-size: 26px; font-weight: 800; color: var(--text-primary);
  transform-origin: 50% 50%;
}
.rose-label.rose-n { color: var(--accent); text-shadow: 0 0 12px var(--focus-glow); }
.rose-num {
  position: absolute; left: 50%; top: 50%;
  width: 34px; height: 18px; margin-left: -17px; margin-top: -9px;
  line-height: 18px; text-align: center;
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  transform-origin: 50% 50%;
}
.readout {
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.readout-deg {
  font-size: 68px; font-weight: 800; line-height: 1;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.readout-card {
  margin-top: 6px; font-size: 30px; font-weight: 700;
  letter-spacing: 3px; color: var(--accent-secondary);
}
.index {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -204px);
  width: 0; height: 0;
  border-left: 13px solid transparent;
  border-right: 13px solid transparent;
  border-top: 20px solid var(--accent);
  filter: drop-shadow(0 0 8px var(--focus-glow));
}

/* ---------- nav ---------- */
.nav {
  flex: 0 0 auto;
  display: flex; gap: 8px;
  padding: 12px 14px 16px;
  background: var(--bg-primary);
  border-top: 1px solid var(--bg-tertiary);
}
.navbtn {
  flex: 1 1 0; min-height: 88px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
}
.navbtn:focus { background: var(--bg-tertiary); }
.navbtn-label { font-size: 16px; font-weight: 700; letter-spacing: 1px; }
.navbtn-sub { font-size: 11px; color: var(--text-secondary); letter-spacing: 0.5px; }

/* ---------- bearing ---------- */
.bear-body {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 10px 20px;
}
.bear-dial { position: relative; width: 230px; height: 230px; }
.bear-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--bg-secondary) 0%, var(--bg-primary) 78%);
  border: 2px solid var(--bg-tertiary);
}
.bear-ahead {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 8px solid transparent; border-right: 8px solid transparent;
  border-bottom: 12px solid var(--text-muted);
}
.bear-arrow {
  position: absolute; top: 50%; left: 50%;
  width: 6px; height: 96px; margin-left: -3px; margin-top: -96px;
  transform-origin: 50% 100%;
  background: linear-gradient(to top, transparent, var(--accent) 30%);
  border-radius: 3px;
  will-change: transform;
}
.bear-arrow::after {
  content: ""; position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 9px solid transparent; border-right: 9px solid transparent;
  border-bottom: 16px solid var(--accent);
  filter: drop-shadow(0 0 6px var(--focus-glow));
}
.bear-arrow.on-target { background: linear-gradient(to top, transparent, var(--accent-secondary) 30%); }
.bear-arrow.on-target::after { border-bottom-color: var(--accent-secondary); }
.bear-arrow.idle { display: none; }
.bear-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 30px; font-weight: 800; color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.bear-guide {
  font-size: 30px; font-weight: 800; letter-spacing: 2px;
  color: var(--accent); text-align: center; min-height: 36px;
}
.bear-guide.on-target { color: var(--accent-secondary); }
.bear-guide.muted { color: var(--text-muted); }
.bear-rows { display: flex; gap: 14px; width: 100%; max-width: 420px; }
.kv {
  flex: 1; background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 12px 16px; display: flex; flex-direction: column; gap: 4px;
}
.kv span { font-size: 12px; color: var(--text-secondary); letter-spacing: 1px; text-transform: uppercase; }
.kv b { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- calibrate ---------- */
.cal-body {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px; padding: 20px 40px; text-align: center;
}
.cal-stage { position: relative; width: 180px; height: 150px; }
.cal-track {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle 44px at 50% 38px, transparent 40px, var(--bg-tertiary) 41px, transparent 46px),
    radial-gradient(circle 44px at 50% 112px, transparent 40px, var(--bg-tertiary) 41px, transparent 46px);
  opacity: 0.7;
}
.cal-dot {
  position: absolute; top: 0; left: 0;
  width: 16px; height: 16px; border-radius: 50%; margin: -8px;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
  offset-path: path("M90,38 C140,38 140,112 90,112 C40,112 40,38 90,38 C140,38 140,112 90,112 C40,112 40,38 90,38");
  offset-distance: 0%;
  animation: trace 3.4s linear infinite;
}
@keyframes trace { from { offset-distance: 0%; } to { offset-distance: 100%; } }
.cal-text { font-size: 22px; line-height: 1.5; color: var(--text-primary); max-width: 460px; }
.cal-sub { font-size: 16px; color: var(--text-secondary); }
.cal-sub.ok { color: var(--accent-secondary); }

/* ---------- settings ---------- */
.set-body {
  flex: 1 1 auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 20px 22px;
}
.row {
  min-height: 72px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-secondary); border-radius: var(--radius-md);
  color: var(--text-primary); text-align: left;
}
.row.focusable:focus { background: var(--bg-tertiary); }
.row-static { cursor: default; }
.row-label { font-size: 19px; font-weight: 600; }
.row-val {
  font-size: 19px; font-weight: 700; color: var(--accent);
  letter-spacing: 1px; font-variant-numeric: tabular-nums;
}
.row-danger .row-val { color: var(--danger); font-size: 24px; }
.stepper { display: flex; align-items: center; gap: 14px; }
.step {
  width: 52px; height: 52px; border-radius: 10px;
  background: var(--bg-tertiary); color: var(--text-primary);
  font-size: 26px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.step:focus { background: var(--bg-primary); }
.stepper .row-val { min-width: 72px; text-align: center; }

/* ---------- help ---------- */
.help-body {
  flex: 1 1 auto;
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px 22px; overflow: hidden;
}
.help-card {
  background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 16px 20px;
}
.help-card h2 {
  font-size: 16px; font-weight: 700; letter-spacing: 1px;
  color: var(--accent); margin-bottom: 6px;
}
.help-card p { font-size: 17px; line-height: 1.5; color: var(--text-secondary); }
.help-card b { color: var(--text-primary); }
