/* Oberfläche (Controller, Viewer-HUD, Startseite) */
:root {
  --bg: #0b1020;
  --bg-2: #0f172a;
  --panel: #121a2e;
  --panel-2: #182238;
  --field: #0d1426;
  --border: rgba(148, 163, 184, 0.18);
  --text: #e6edf7;
  --muted: #94a3b8;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
body { min-height: 100%; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent-2); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  min-height: 40px;
  transition: background 120ms ease, transform 120ms ease, border-color 120ms ease;
  white-space: nowrap;
}
button:hover { background: #1f2a44; }
button:active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); border-color: transparent; color: #1a1200; font-weight: 700; }
button.primary:hover { background: var(--accent-2); }
button.danger:hover { border-color: var(--danger); color: #fca5a5; }
button.big { min-height: 52px; font-size: 1.1rem; padding: 0.6rem 1.4rem; }
button.active { border-color: var(--accent); color: var(--accent-2); }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  background: var(--field);
  color: var(--text);
  min-height: 40px;
}
input[type="number"] { width: 5.5rem; text-align: right; }
select { appearance: auto; }
textarea {
  min-height: 55vh;
  resize: vertical;
  line-height: 1.55;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  tab-size: 2;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: #2a3650; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); border: 2px solid #1a1200;
  margin-top: -8px; cursor: pointer;
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: #2a3650; }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--accent); border: 2px solid #1a1200; cursor: pointer; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

.row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }

.pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.75rem; border-radius: 999px;
  border: 1px solid var(--border); background: rgba(15, 23, 42, 0.6);
  font-size: 0.85rem; white-space: nowrap;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--accent); }
.dot.bad { background: var(--danger); }

/* ---------- Topbar / Layout (Controller + Startseite) ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 16, 32, 0.9);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.brand .muted { font-weight: 400; }

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 5fr) minmax(360px, 7fr);
  gap: 1rem;
  padding: 1rem 1.25rem 3rem;
  align-items: start;
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  textarea { min-height: 40vh; }
}
.col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.panel-head .row { justify-content: flex-end; }

details.help { margin-top: 0.75rem; color: var(--muted); font-size: 0.88rem; }
details.help summary { cursor: pointer; color: var(--text); }
details.help code { background: var(--field); padding: 0.1rem 0.35rem; border-radius: 5px; color: var(--accent-2); }
details.help ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }

/* ---------- Vorschau ---------- */
.preview-root {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
  background: #000;
  border: 1px solid var(--border);
  cursor: grab;
}
.preview-root:active { cursor: grabbing; }
.preview-scale { transform-origin: top left; }
.preview-root:fullscreen { border: 0; border-radius: 0; background: #000; cursor: default; }
.preview-root:fullscreen .preview-scale { transform: none !important; }
.preview-info { font-size: 0.85rem; color: var(--muted); }

.transport { display: grid; gap: 0.75rem; margin-top: 0.85rem; }
.transport .controls { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.transport label { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; color: var(--muted); font-size: 0.9rem; }
.transport label strong { color: var(--text); font-variant-numeric: tabular-nums; }
.speed-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 0.5rem; align-items: center; }
.speed-row button { min-width: 44px; padding: 0.4rem; font-size: 1.1rem; }
.section-row { display: grid; grid-template-columns: auto 1fr auto; gap: 0.5rem; align-items: center; }
.progress { height: 6px; border-radius: 3px; background: #2a3650; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: var(--accent); transition: width 120ms linear; }

/* ---------- Einstellungen ---------- */
.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem 1rem;
}
.control { display: flex; flex-direction: column; gap: 0.1rem; }
.control > span { display: flex; justify-content: space-between; font-size: 0.88rem; color: var(--muted); }
.control > span strong { color: var(--text); font-variant-numeric: tabular-nums; }
.control.check { flex-direction: row; align-items: center; gap: 0.6rem; min-height: 40px; cursor: pointer; }
.control.check > span { color: var(--text); }
.control select { min-height: 38px; }

/* ---------- Verbinden ---------- */
.connect-grid { display: grid; grid-template-columns: 150px 1fr; gap: 1rem; align-items: start; }
.connect-grid img { width: 150px; height: 150px; border-radius: 8px; background: #fff; padding: 6px; display: block; }
.url-box {
  font-family: ui-monospace, Menlo, monospace; font-size: 0.85rem;
  background: var(--field); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.5rem 0.65rem; word-break: break-all; user-select: all;
}
@media (max-width: 520px) { .connect-grid { grid-template-columns: 1fr; } }

/* ---------- Voice ---------- */
.voice-status { color: var(--muted); font-size: 0.9rem; min-height: 1.4em; }
.voice-transcript { font-size: 0.9rem; color: var(--text); opacity: 0.85; min-height: 1.4em; font-style: italic; }

kbd {
  display: inline-block; padding: 0.05rem 0.4rem; border-radius: 5px;
  border: 1px solid var(--border); background: var(--field); font-family: inherit; font-size: 0.85em;
}
.shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.35rem 1rem; font-size: 0.88rem; color: var(--muted); }

/* ---------- Overlay (Zugangsschlüssel / Hinweise) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 6, 15, 0.86);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
  backdrop-filter: blur(6px);
}
.overlay .card {
  width: min(440px, 100%);
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  padding: 1.5rem; display: flex; flex-direction: column; gap: 0.9rem;
}
.overlay .card h2 { font-size: 1.2rem; }
.overlay .error { color: #fca5a5; font-size: 0.9rem; min-height: 1.3em; }

/* ---------- Viewer ---------- */
body.viewer { background: #000; overflow: hidden; height: 100dvh; touch-action: manipulation; overscroll-behavior: none; }
.stage-root { position: fixed; inset: 0; background: #000; overflow: hidden; }
body.viewer .tp-stage { width: 100%; height: 100%; }

.hud {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  pointer-events: none;
  transition: opacity 250ms ease;
}
.hud.hidden { opacity: 0; }
.hud > * { pointer-events: auto; }
.hud.hidden > * { pointer-events: none; }
.hud-left, .hud-right {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(15, 23, 42, 0.78); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.35rem 0.6rem;
  backdrop-filter: blur(10px);
}
.hud-left { font-size: 0.85rem; color: var(--muted); padding-right: 0.9rem; }
.hud-right button { min-width: 46px; min-height: 46px; border-radius: 999px; padding: 0; font-size: 1.15rem; }
.hud-right button.primary { min-width: 64px; }
.hint {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 20; max-width: min(520px, calc(100% - 32px));
  background: rgba(15, 23, 42, 0.9); border: 1px solid var(--border); border-radius: 14px;
  padding: 0.75rem 1rem; font-size: 0.9rem; color: var(--text);
  display: flex; gap: 0.75rem; align-items: center;
}
.hint button { flex-shrink: 0; }
.viewer-progress { position: fixed; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,0.08); z-index: 15; }
.viewer-progress > div { height: 100%; width: 0; background: var(--accent); }

/* ---------- Startseite ---------- */
.landing { max-width: 880px; margin: 0 auto; padding: 3rem 1.25rem 4rem; display: flex; flex-direction: column; gap: 2rem; }
.landing h1 { font-size: 2.2rem; }
.landing .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.landing .card-link {
  display: block; text-decoration: none; color: inherit;
  background: var(--panel); border: 1px solid var(--border); border-radius: 18px; padding: 1.5rem;
  transition: border-color 120ms ease, transform 120ms ease;
}
.landing .card-link:hover { border-color: var(--accent); transform: translateY(-2px); }
.landing .card-link h2 { font-size: 1.3rem; margin-bottom: 0.4rem; }
.landing ol { padding-left: 1.2rem; color: var(--muted); display: grid; gap: 0.35rem; }
