: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; }
.hidden { display: none !important; }

.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);
}

/* ---------- Header ---------- */
.hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; min-height: 64px;
  background: var(--bg-primary);
  border-bottom: 1px solid #23232f;
}
.hdr-title { font-size: 25px; font-weight: 600; letter-spacing: 0.3px; }

.status-pill {
  font-size: 14px; font-weight: 600;
  padding: 7px 15px; border-radius: 999px;
  background: var(--bg-tertiary); color: var(--text-secondary);
  border: 1px solid #2a2a3a; font-variant-numeric: tabular-nums;
}
.status-pill[data-state="active"] { color: #04130c; background: var(--accent-secondary); border-color: var(--accent-secondary); }
.status-pill[data-state="searching"] { color: #001a20; background: var(--accent); border-color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.status-pill[data-state="demo"] { color: #001a20; background: var(--accent); border-color: var(--accent); }
.status-pill[data-state="denied"],
.status-pill[data-state="unavailable"],
.status-pill[data-state="no-altitude"] { color: #fff; background: var(--danger); border-color: var(--danger); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---------- Home main ---------- */
.home-main {
  flex: 1; display: flex; align-items: center; gap: 24px;
  padding: 18px 28px;
}

.tape {
  display: flex; flex-direction: column; align-items: center;
  height: 100%; max-height: 300px; justify-content: space-between;
}
.tape-track {
  position: relative; flex: 1; width: 12px; margin: 10px 0;
  background: var(--bg-tertiary); border-radius: 999px;
}
.tape-track::before {
  content: ""; position: absolute; inset: 0; border-radius: 999px;
  background: linear-gradient(to top, rgba(0, 212, 255, 0.18), rgba(0, 255, 136, 0.18));
}
.tape-marker {
  position: absolute; left: 50%; bottom: 50%;
  transform: translate(-50%, 50%);
  width: 30px; height: 8px; border-radius: 4px;
  background: var(--accent); box-shadow: 0 0 14px var(--focus-glow);
  transition: bottom 0.4s ease;
}
.tape-label { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.readout {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.alt-line { display: flex; align-items: baseline; gap: 8px; }
.alt-value {
  font-size: 84px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -2px;
}
.alt-unit { font-size: 30px; font-weight: 600; color: var(--text-secondary); }
.alt-sub { margin-top: 12px; font-size: 18px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.latlon { margin-top: 6px; font-size: 14px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- Footer / buttons ---------- */
.foot { padding: 0 24px 24px; display: flex; flex-direction: column; gap: 12px; }

.btn {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-tertiary); color: var(--text-primary);
  font-family: inherit; font-size: 18px; font-weight: 600;
  border-radius: var(--radius-md); min-height: 56px;
  border: 2px solid transparent;
}
.btn-primary { background: var(--accent); color: #04222a; min-height: 84px; font-size: 22px; }
.btn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ---------- Generic padded screen ---------- */
.pad { flex: 1; padding: 22px 26px 24px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.pad .btn-primary { margin-top: auto; }
.hint { font-size: 16px; color: var(--text-secondary); line-height: 1.4; }

/* ---------- Calibrate ---------- */
.cal-readout { display: flex; align-items: baseline; justify-content: center; gap: 8px; padding: 6px 0; }
.cal-meta { display: flex; justify-content: space-between; font-size: 15px; color: var(--text-secondary); }
.cal-meta b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.cal-steppers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.step { font-size: 20px; min-height: 64px; }

/* ---------- Stats ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
}
.stat-k { font-size: 14px; color: var(--text-secondary); }
.stat-v { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-v.up { color: var(--accent-secondary); }
.stat-v.down { color: var(--accent); }

/* ---------- Settings rows ---------- */
.row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-secondary); border-radius: var(--radius-md);
  padding: 0 20px; min-height: 64px;
  color: var(--text-primary); font-family: inherit; font-size: 18px; text-align: left;
}
.row-k { font-weight: 500; }
.row-v { color: var(--accent); font-weight: 600; }

/* ---------- Info ---------- */
.info-text p { font-size: 17px; line-height: 1.5; color: var(--text-secondary); }
.info-text .muted { color: var(--text-muted); font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  .focusable, .tape-marker { transition: none; }
  .status-pill[data-state="searching"] { animation: none; }
}
