:root {
  --glass: rgba(10, 16, 28, 0.72);
  --glass-strong: rgba(10, 16, 28, 0.9);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8eef7;
  --muted: #94a3b8;
  --horizon: #4fd6ff;
  --eye: #ffb347;
  --warn: #ff6b6b;
  --ok: #7ee081;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--text); font-family: var(--sans); }
#cesium { position: fixed; inset: 0; }
#hud { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.cesium-viewer-bottom { left: auto !important; right: 8px; bottom: 4px !important; opacity: 0.75; }
.cesium-credit-logoContainer { display: none !important; }

.label { display: block; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.value { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 15px; }

#readout {
  position: fixed; top: 12px; left: 12px; z-index: 5; padding: 12px 14px; border-radius: 12px;
  background: var(--glass); backdrop-filter: blur(8px); border: 1px solid var(--line); min-width: 220px;
}
.horizon-big { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 8px; }
.horizon-big .value { font-size: 28px; color: var(--horizon); font-weight: 600; }
.horizon-big .sub { display: block; font-size: 11px; color: var(--muted); }
#readout .grid { display: grid; grid-template-columns: repeat(3, auto); gap: 6px 14px; }
.flags { margin-top: 6px; font-size: 11px; font-family: var(--mono); min-height: 14px; }
.flags .warn { color: var(--warn); font-weight: 700; }
.flags .on { color: var(--ok); }

#tape { position: fixed; left: 12px; top: 50%; transform: translateY(-30%); z-index: 4; width: 70px; height: 280px; pointer-events: none; }
#tape-canvas { width: 100%; height: 100%; }

#panel-toggle { position: fixed; top: 12px; right: 12px; z-index: 7; }
#panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 360px; z-index: 6; overflow-y: auto;
  padding: 56px 18px 24px; background: var(--glass-strong); backdrop-filter: blur(10px);
  border-left: 1px solid var(--line); transition: transform 0.25s ease;
}
#panel.closed { transform: translateX(100%); }
#panel h2 { margin: 0 0 12px; font-size: 18px; }
#panel h3 { margin: 18px 0 8px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
#panel canvas { width: 100%; height: auto; display: block; border-radius: 8px; background: rgba(0, 0, 0, 0.35); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.stats .value { font-size: 16px; }
.note { font-size: 11px; color: var(--muted); margin: 6px 0 0; min-height: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip, button.primary {
  font: 500 12px var(--sans); color: var(--text); background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; cursor: pointer;
}
.chip:hover { background: rgba(79, 214, 255, 0.18); border-color: rgba(79, 214, 255, 0.5); }
.chip.active { background: rgba(79, 214, 255, 0.25); border-color: var(--horizon); }
button.primary { font-size: 15px; padding: 12px 22px; background: var(--horizon); color: #04121c; border: none; font-weight: 700; }

.settings { display: grid; gap: 8px; font-size: 13px; }
.settings label { display: grid; gap: 4px; color: var(--muted); }
.settings label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.settings select { font: 13px var(--sans); color: var(--text); background: #111a2b; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }

.fr24 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; font-size: 13px; }
.fr24 > *, .fr24 .field, .results { min-width: 0; }
.fr24 .row > .chip { flex: 0 0 auto; }
.fr24 .row { display: flex; gap: 6px; align-items: center; }
.fr24 .row.wrap { flex-wrap: wrap; gap: 6px 14px; }
.fr24 .field { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.fr24 input[type=password], .fr24 input[type=text], .fr24 input[type=url], .fr24 input:not([type]), .fr24 select {
  flex: 1; min-width: 0; font: 13px var(--mono); color: var(--text); background: #111a2b;
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px;
}
.fr24 select { flex: 0 0 auto; font-family: var(--sans); }
.fr24 .check { display: flex; align-items: center; gap: 6px; color: var(--text); }
.fr24 details.adv summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.fr24 details.adv { display: grid; gap: 6px; }
.fr24 details.adv[open] > *:not(summary) { margin-top: 6px; }
.fr24 .note.err { color: var(--warn); }
.results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; max-height: 220px; overflow-y: auto; }
.results button {
  text-align: left; font: 12px var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(255,255,255,0.05);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; cursor: pointer;
}
.results button:hover, .results button.active { border-color: var(--horizon); background: rgba(79,214,255,0.14); }
.follow { border: 1px solid rgba(255,107,107,0.5); background: rgba(255,107,107,0.08); border-radius: 10px; padding: 10px; display: grid; gap: 6px; }
.follow-title { font: 600 14px var(--mono); }
.follow-title::before { content: "● "; color: var(--warn); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.muted { color: var(--muted); font-size: 11px; }
.route { display: grid; gap: 4px; border-top: 1px solid var(--line); padding-top: 8px; }
.route-row { display: grid; grid-template-columns: 10px 34px minmax(0, 1fr); gap: 6px; align-items: baseline; font-size: 12px; }
.route-row .label { display: inline; }
.route-row .rv { font-family: var(--mono); overflow-wrap: anywhere; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.from { background: #7ee081; } .dot.to { background: #ffd166; }
.atc { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 8px; }
.atc a { color: var(--horizon); }
.atc .chip { text-decoration: none; color: var(--text); }
.atc .chip::after { content: " ↗"; color: var(--muted); }
.flags .live { color: #ff8f8f; font-weight: 700; }

details#math { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 13px; line-height: 1.5; color: #cbd5e1; }
details#math summary { cursor: pointer; font-weight: 600; color: var(--text); }
.eq { font-family: var(--mono); background: rgba(79, 214, 255, 0.08); border-left: 3px solid var(--horizon); padding: 6px 10px; border-radius: 4px; color: var(--text); }
.credits { font-size: 10px; color: var(--muted); margin-top: 18px; line-height: 1.5; }

.help {
  position: fixed; bottom: 10px; left: 12px; z-index: 4; font-size: 11px; color: #cbd5e1;
  background: var(--glass); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap;
}
#toast {
  position: fixed; top: 18px; left: 50%; transform: translate(-50%, -80px); z-index: 9; padding: 8px 16px; border-radius: 999px;
  background: var(--glass-strong); border: 1px solid var(--line); font-size: 13px; transition: transform 0.25s ease; pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); }

#intro { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(4, 10, 20, 0.55), rgba(0, 0, 0, 0.85)); }
#intro .card { max-width: 440px; margin: 16px; padding: 26px; border-radius: 16px; background: var(--glass-strong); border: 1px solid var(--line); text-align: center; }
#intro h1 { margin: 0 0 10px; font-size: 24px; }
#intro p { line-height: 1.5; color: #cbd5e1; }
#intro .small { font-size: 12px; color: var(--muted); }
#intro.hidden { display: none; }

/* Touch controls */
#touch { position: fixed; inset: auto 0 0 0; height: 0; z-index: 8; }
#stick { position: fixed; left: 22px; bottom: 28px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); touch-action: none; }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(79, 214, 255, 0.55); }
#throttle { position: fixed; right: 22px; bottom: 28px; width: 54px; height: 150px; border-radius: 14px; background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); overflow: hidden; touch-action: none; }
#throttle-fill { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(255, 179, 71, 0.55); }
#throttle span { position: absolute; top: 6px; width: 100%; text-align: center; font-size: 10px; color: var(--muted); }
#touch-buttons { position: fixed; right: 90px; bottom: 30px; display: grid; gap: 8px; }

@media (max-width: 760px), (pointer: coarse) {
  .help { display: none; }
  #panel { width: 100%; top: auto; height: 62%; border-left: none; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; padding-top: 18px; }
  #panel.closed { transform: translateY(100%); }
  #panel { z-index: 9; }
  #panel-toggle { z-index: 10; }
  #toast { z-index: 11; }
  #readout { min-width: 0; padding: 8px 10px; top: max(8px, env(safe-area-inset-top)); left: 8px; }
  #readout .grid { grid-template-columns: repeat(3, auto); gap: 4px 10px; }
  .value { font-size: 13px; }
  .horizon-big .value { font-size: 22px; }
  #tape { display: none; }
  #panel-toggle { top: max(8px, env(safe-area-inset-top)); right: 8px; }
}
