:root {
  --bg: #080b12;
  --bg-card: rgba(15, 21, 34, 0.88);
  --bg-elev: rgba(24, 33, 52, 0.92);
  --border: rgba(148, 163, 184, 0.16);
  --border-hi: rgba(56, 189, 248, 0.45);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --radius: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 18% 12%, rgba(14, 165, 233, 0.14), transparent 36%),
    radial-gradient(circle at 86% 85%, rgba(239, 68, 68, 0.11), transparent 38%),
    linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
  background-size: auto, auto, 34px 34px, 34px 34px;
  pointer-events: none;
  z-index: -1;
}

.container {
  max-width: 1420px;
  margin: 0 auto;
  padding: 0 18px;
}

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.accent { color: var(--accent); }
.green { color: var(--green); }
.amber { color: var(--amber); }
.red { color: var(--red); }
.hidden { display: none !important; }

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(8, 11, 18, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 11px;
  padding-bottom: 11px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0284c7, #ef4444);
  display: grid;
  place-items: center;
  font-size: 20px;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
}

.brand h1 { font-size: 1.1rem; line-height: 1.15; letter-spacing: -0.02em; }
.subtitle { font-size: 0.75rem; color: var(--muted); }

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.preset-label { font-size: 0.78rem; color: var(--muted); margin-right: 2px; }

.preset-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.6);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.preset-btn:hover { color: #fff; border-color: rgba(148, 163, 184, 0.4); }
.preset-btn.active {
  color: #fff;
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.22);
  box-shadow: 0 0 12px rgba(14, 165, 233, 0.22);
}

.top-actions { display: flex; align-items: center; gap: 8px; }

.btn-audio {
  appearance: none;
  border: 1px solid rgba(52, 211, 153, 0.45);
  background: rgba(16, 185, 129, 0.16);
  color: #a7f3d0;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-audio:hover { background: rgba(16, 185, 129, 0.28); color: #fff; }
.btn-audio.on {
  background: linear-gradient(135deg, #10b981, #0ea5e9);
  border-color: transparent;
  color: #041016;
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.4);
}

.btn-gh {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.65);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}
.btn-gh:hover { border-color: var(--border-hi); }

/* Main Grid */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 36px;
  align-items: start;
}

.stage-column, .tuner-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* Shift Light Bar */
.shift-light-bar {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 8px;
  padding: 10px 16px;
  background: rgba(10, 15, 26, 0.92);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.led {
  height: 10px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.55);
  transition: background 0.05s linear, box-shadow 0.05s linear;
}

.led.g.lit { background: #22c55e; box-shadow: 0 0 12px #22c55e; }
.led.y.lit { background: #facc15; box-shadow: 0 0 12px #facc15; }
.led.r.lit { background: #ef4444; box-shadow: 0 0 16px #ef4444; }

/* Stage Card */
.stage-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.stage-meta { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

.tag {
  font-size: 0.76rem;
  font-family: var(--font-mono);
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--border);
  color: var(--text);
}

.tag.accent { color: #7dd3fc; border-color: rgba(56, 189, 248, 0.45); background: rgba(14, 165, 233, 0.14); }
.tag.warn { color: #fecaca; border-color: rgba(239, 68, 68, 0.7); background: rgba(239, 68, 68, 0.25); animation: blink 0.25s infinite alternate; }

@keyframes blink { from { opacity: 0.65; } to { opacity: 1; } }

.stage-view-controls { display: flex; align-items: center; gap: 12px; }
.toggle-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--muted);
  cursor: pointer;
}
.toggle-mini input { accent-color: var(--accent); cursor: pointer; }

.btn-mini {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.75);
  color: var(--text);
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 0.78rem;
  cursor: pointer;
}
.btn-mini:hover { border-color: var(--border-hi); }

.canvas-wrap {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #060911;
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.canvas-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Telemetry Strip */
.telemetry-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.tele-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}

.tele-label { font-size: 0.72rem; color: var(--muted); }
.tele-val { font-family: var(--font-mono); font-size: 1.05rem; font-weight: 800; }
.tele-val small { font-size: 0.72rem; font-weight: 500; color: var(--muted); }

.gear-pill {
  display: inline-block;
  min-width: 24px;
  text-align: center;
  padding: 0 6px;
  border-radius: 5px;
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
  margin-right: 4px;
}

/* Cockpit Controls */
.cockpit-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 18px;
}

.zone-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.throttle-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-rev {
  flex: 1;
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #f97316);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  box-shadow: 0 4px 18px rgba(239, 68, 68, 0.35);
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}

.btn-rev:active, .btn-rev.pressed {
  transform: scale(0.98);
  box-shadow: 0 0 26px rgba(249, 115, 22, 0.75);
}

.btn-blip {
  appearance: none;
  border: 1px solid rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.14);
  color: #fde68a;
  border-radius: 10px;
  padding: 0 13px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-blip:hover { background: rgba(251, 191, 36, 0.25); }

.cruise-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  margin-bottom: 4px;
}

.gear-buttons {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.gear-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.7);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 800;
  padding: 9px 0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.gear-btn:hover { color: #fff; border-color: var(--border-hi); }
.gear-btn.active {
  background: linear-gradient(135deg, #0284c7, #6366f1);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.quick-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.chip-mini {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.6);
  color: var(--muted);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.chip-mini:hover { color: #fff; border-color: var(--accent); }

/* Sub Visuals */
.sub-visuals {
  display: grid;
  grid-template-columns: 0.82fr 1.18fr;
  gap: 14px;
}

.sub-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.sub-head h3 { font-size: 0.9rem; font-weight: 700; }

/* Right Tuner Panel */
.tuner-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.tuner-tab {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.55);
  color: var(--muted);
  padding: 8px 6px;
  border-radius: 9px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
}

.tuner-tab.active {
  color: #fff;
  border-color: var(--accent);
  background: rgba(14, 165, 233, 0.22);
}

.tuner-pane { display: none; flex-direction: column; gap: 12px; }
.tuner-pane.active { display: flex; }

.field { display: flex; flex-direction: column; gap: 5px; }
.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

.field label { font-size: 0.82rem; color: var(--muted); }

select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(10, 16, 28, 0.95);
  color: var(--text);
  font-size: 0.84rem;
  outline: none;
}
select:focus { border-color: var(--accent); }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="range"]:disabled { opacity: 0.35; cursor: not-allowed; }

.hint-text {
  font-size: 0.78rem;
  color: var(--muted);
  background: rgba(14, 165, 233, 0.08);
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  border-radius: 6px;
}

.phase-sliders {
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: rgba(10, 16, 28, 0.65);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
}

.spec-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: rgba(10, 16, 28, 0.7);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.spec-summary div { display: flex; flex-direction: column; font-size: 0.76rem; }
.spec-summary strong { font-size: 0.88rem; margin-top: 2px; }

.toggle-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px;
  border-radius: 10px;
  background: rgba(10, 16, 28, 0.7);
  border: 1px solid var(--border);
  cursor: pointer;
}
.toggle-card input { margin-top: 4px; accent-color: var(--red); }
.toggle-card strong { display: block; font-size: 0.85rem; color: var(--text); }
.toggle-card span { font-size: 0.76rem; }

.tips-card h3 { font-size: 0.9rem; margin-bottom: 8px; }
.tips-card ul { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 0.8rem; color: var(--muted); }

kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: #f8fafc;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 16px 0 26px;
  font-size: 0.8rem;
  color: var(--muted);
}
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.footer a { color: var(--accent); text-decoration: none; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
  .telemetry-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .cockpit-grid, .sub-visuals { grid-template-columns: 1fr; }
  .telemetry-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
