:root {
  --bg: #0c1612;
  --raise: #14241c;
  --line: rgba(244, 239, 228, 0.16);
  --ink: #f4efe4;
  --muted: #b7c4b8;
  --green: #3ddc97;
  --amber: #ffb020;
  --red: #e23d2b;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(61, 220, 151, 0.08), transparent 55%),
    var(--bg);
  color: var(--ink);
}

button, input, select { font: inherit; color: inherit; }

button {
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid transparent;
  padding: 0 16px;
  background: var(--raise);
  cursor: pointer;
}

button:disabled { opacity: 0.45; cursor: not-allowed; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.primary {
  background: var(--ink);
  color: #102117;
  font-weight: 700;
}

.ghost {
  background: transparent;
  border-color: var(--line);
}

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding:
    calc(16px + env(safe-area-inset-top))
    16px
    calc(28px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.brand { margin: 0; line-height: 0; }

.logo {
  display: block;
  height: 64px;
  width: auto;
  max-width: min(340px, 74vw);
  object-fit: contain;
  border-radius: 14px;
}

.eyebrow, .label {
  margin: 0 0 2px;
  color: var(--amber);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h2, p { margin: 0; }

h2 { font-size: 1rem; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 68dvh;
  border-radius: 20px;
  overflow: hidden;
  background: #050a08;
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
}

video,
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050a08;
}

.stage-empty {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  margin: 0;
  color: var(--muted);
  text-align: center;
  text-shadow: 0 1px 8px #000;
  pointer-events: none;
}

.stage.live .stage-empty { display: none; }

.badge {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 3;
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(8, 16, 12, 0.78);
  font-size: 0.85rem;
  font-weight: 700;
}

.badge.armed { color: var(--green); }
.badge.flight { color: var(--amber); }
.badge.lost { color: #ffb4a8; }

.panel { min-width: 0; padding-top: 16px; }

.readout { min-height: 9.5rem; }

.mph {
  font-size: clamp(4.6rem, 22vw, 7.4rem);
  line-height: 0.86;
  font-weight: 760;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
}

.unit {
  margin-top: 4px;
  color: var(--amber);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.kmh {
  margin-top: 4px;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.meta {
  margin-top: 8px;
  color: var(--muted);
  min-height: 2.7em;
}

.readout.pop .mph { animation: pop 0.45s ease; }

@keyframes pop {
  from { transform: scale(0.96); color: var(--amber); }
  to { transform: none; color: inherit; }
}

.actions, .subactions, .presets, .chips, .segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions { margin-top: 14px; }
.actions button { flex: 1 1 10rem; }

.chips { margin-top: 12px; min-height: 2rem; }

.chips span, .presets button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.chips span {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.chips span.warn {
  color: var(--amber);
  border-color: rgba(255, 176, 32, 0.5);
}

.presets { margin-top: 10px; }

.presets button {
  min-height: 40px;
  padding: 0 12px;
}

.presets button[aria-pressed="true"],
.segmented button[aria-pressed="true"] {
  background: var(--ink);
  color: #102117;
  border-color: transparent;
  font-weight: 700;
}

.segmented { margin-top: 8px; }
.segmented button { flex: 1; background: transparent; border-color: var(--line); }

.label { margin-top: 16px; }

.field {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.field span, .field small, .check, .note, .history li span, .stage-empty {
  color: var(--muted);
}

input[type="number"], select {
  width: 100%;
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0c1612;
  padding: 0 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--green); }

.subactions { margin-top: 8px; }

.subactions button {
  min-height: 40px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
}

.history { margin-top: 18px; }

.history ol {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.history li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--raise);
}

.history strong { font-variant-numeric: tabular-nums; }

.history .empty { background: transparent; padding-left: 0; }

.help {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

summary { cursor: pointer; font-weight: 700; }

.help ol {
  margin: 10px 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.note { margin-top: 8px; }

@media (min-width: 880px) {
  main {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
    gap: 22px;
    align-items: start;
  }

  .stage { position: sticky; top: 12px; }
  .panel { padding-top: 0; }
  .logo { height: 78px; max-width: 420px; }
}

@media (prefers-reduced-motion: reduce) {
  .readout.pop .mph { animation: none; }
}
