:root {
  --desk: #22262b;
  --panel: #2b3037;
  --panel-2: #343a42;
  --ink: #e8eaed;
  --ink-dim: #9aa2ac;
  --accent: #f4b23e;
  --accent-ink: #241a05;
  --sel: #37a4e8;
  --axes: #3ddc84;
  --tape: #35d2d2;
  --danger: #e46a5a;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--desk);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
body { position: fixed; inset: 0; display: flex; flex-direction: column; }

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

/* ---------- Topbar ---------- */
#topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border-bottom: 1px solid rgba(0,0,0,0.35);
  flex-wrap: wrap;
}
.brand { font-weight: 700; letter-spacing: 0.4px; margin-right: 6px; white-space: nowrap; }
.brand .dot { color: var(--accent); }

.tbtn {
  min-width: 44px; min-height: 44px;
  padding: 0 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.tbtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tbtn:disabled { opacity: 0.35; cursor: default; }
.tbtn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tbtn.axesActive { background: var(--axes); border-color: var(--axes); color: #0a2a18; }
.tbtn.tapeActive { background: var(--tape); border-color: var(--tape); color: #063030; }

.sel {
  min-height: 44px; padding: 0 10px;
  background: var(--panel-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  -webkit-appearance: none; appearance: none;
}
.spacer { flex: 1; }

#objChip { display: inline-flex; align-items: center; gap: 8px; }
#objDot { width: 14px; height: 14px; border-radius: 50%; background: #ff5a5a; box-shadow: 0 0 0 2px rgba(255,255,255,0.25); }

/* ---------- Main split ---------- */
#main { flex: 1; display: flex; min-height: 0; }
#stageCol { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#stageWrap {
  flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 10px;
}
#stageBox {
  position: relative;
  background: #000;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 0 34px rgba(255,244,214,0.10), 0 10px 30px rgba(0,0,0,0.5);
  touch-action: none;
  overflow: hidden;
}
#vcanvas { display: block; width: 100%; height: 100%; }
#ytBox { position: absolute; inset: 0; display: none; }
#ytBox iframe { width: 100%; height: 100%; }
#overlay { position: absolute; inset: 0; touch-action: none; }
#loupe {
  position: absolute; width: 132px; height: 132px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-shadow: 0 6px 18px rgba(0,0,0,0.55);
  background: #000;
  pointer-events: none; display: none; z-index: 5;
}

/* ---------- Start card ---------- */
#startCard {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(180deg, rgba(34,38,43,0.0), rgba(34,38,43,0.25));
  color: var(--ink);
  text-align: center; padding: 20px;
}
#startCard h2 { margin: 0; font-weight: 600; }
#startCard p { margin: 0; color: var(--ink-dim); max-width: 420px; }
.bigBtn {
  min-height: 52px; padding: 0 18px;
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--accent); color: var(--accent-ink);
  border: none; border-radius: 12px; font-weight: 600; cursor: pointer;
}
.bigBtn.secondary { background: var(--panel-2); color: var(--ink); border: 1px solid rgba(255,255,255,0.14); }
.bigBtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#ytForm { display: none; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
/* Hinweis vor dem Laden: YouTube bekommt die IP-Adresse (siehe Datenschutzerklärung).
   Mit #ytForm davor, sonst gewinnt "#startCard p { max-width }" und er rutscht neben den Knopf. */
#ytForm .ytHinweis { flex-basis: 100%; max-width: none; margin: 2px 0 0; font-size: 13px; line-height: 1.4; opacity: 0.75; text-align: center; }
#ytUrl { min-height: 48px; width: min(420px, 80vw); padding: 0 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.14); background: var(--panel-2); }

/* ---------- Transport ---------- */
#transport {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: var(--panel);
  border-top: 1px solid rgba(0,0,0,0.35);
  flex-wrap: wrap;
}
#timeline { flex: 1; min-width: 140px; height: 44px; -webkit-appearance: none; appearance: none; background: transparent; }
#timeline::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--panel-2); }
#timeline::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); margin-top: -10px; border: 2px solid #1c1608;
}
#timeInfo { font-variant-numeric: tabular-nums; color: var(--ink-dim); white-space: nowrap; }
#timeInfo b { color: var(--ink); font-weight: 600; }

/* ---------- Side panel ---------- */
#panel {
  width: 380px; max-width: 46vw;
  background: var(--panel);
  border-left: 1px solid rgba(0,0,0,0.35);
  display: none; flex-direction: column; min-height: 0;
}
#panel.open { display: flex; }
#panelTabs { display: flex; gap: 6px; padding: 8px; }
.ptab { flex: 1; }
#panelBody { flex: 1; overflow: auto; padding: 0 10px 10px; -webkit-overflow-scrolling: touch; }
#panelTools { display: flex; gap: 6px; padding: 0 8px 8px; flex-wrap: wrap; align-items: center; }

table.daten { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
table.daten th, table.daten td { padding: 6px 8px; text-align: right; border-bottom: 1px solid rgba(255,255,255,0.08); }
table.daten th { position: sticky; top: 0; background: var(--panel-2); color: var(--ink); font-weight: 600; }
table.daten tr.now td { background: rgba(244,178,62,0.16); }
table.daten td:first-child, table.daten th:first-child { text-align: left; }

#chartBox { background: var(--panel-2); border-radius: var(--radius); padding: 6px; }
#chartBox svg { display: block; width: 100%; height: auto; }
.axisLine { stroke: rgba(255,255,255,0.55); stroke-width: 1; }
.gridLine { stroke: rgba(255,255,255,0.10); stroke-width: 1; }
.tickText { fill: var(--ink-dim); font-size: 11px; }
.axLabel { fill: var(--ink); font-size: 12px; }
.dataDot { cursor: pointer; }
.dataLine { fill: none; stroke-width: 1.5; opacity: 0.8; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 13px;
  background: rgba(228,106,90,0.18); color: #ffb4a8;
}
.badge.ok { background: rgba(61,220,132,0.15); color: #9af0c0; }

/* ---------- Menu / overlays ---------- */
#menuOverlay, #confirmOverlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(10,12,14,0.6);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
#menuOverlay.open, #confirmOverlay.open { display: flex; }
.sheet {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 14px;
  width: min(460px, 94vw);
  max-height: 86vh; overflow: auto;
  display: flex; flex-direction: column; gap: 10px;
}
.sheet h3 { margin: 4px 2px 2px; font-size: 15px; color: var(--ink-dim); font-weight: 600; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .grow { flex: 1; }
.menuBtn {
  min-height: 48px; padding: 0 12px;
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  cursor: pointer; text-align: left; width: 100%;
}
.menuBtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.num { width: 92px; min-height: 44px; padding: 0 8px; border-radius: var(--radius); border: 1px solid rgba(255,255,255,0.1); background: var(--panel-2); }
label.chk { display: flex; align-items: center; gap: 10px; min-height: 44px; }
label.chk input { width: 22px; height: 22px; }

/* ---------- Toast & banner ---------- */
#toast {
  position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%);
  background: rgba(20,22,25,0.95); color: var(--ink);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 10px 16px; border-radius: 999px;
  z-index: 50; display: none; max-width: 90vw; text-align: center;
}
#restoreBanner {
  position: fixed; left: 50%; top: 66px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px; padding: 10px 12px; z-index: 40;
  display: none; gap: 8px; align-items: center; flex-wrap: wrap; max-width: 94vw;
}
#restoreBanner.open { display: flex; }

/* ---------- Narrow layout (iPad portrait / phone) ---------- */
@media (max-width: 900px) {
  #main { flex-direction: column; }
  #panel { width: 100%; max-width: none; border-left: none; border-top: 1px solid rgba(0,0,0,0.35); height: 46%; }
}

[hidden] { display: none !important; }
