:root {
  --bg: #05070f;
  --panel: rgba(14, 18, 34, 0.86);
  --panel-solid: #0e1222;
  --line: rgba(160, 180, 255, 0.16);
  --text: #e9edfb;
  --muted: #9aa5c4;
  --accent: #ffd27a;
  --accent-ink: #1d1606;
  --blue: #9fb8ff;
  --ok: #7fe0a4;
  --warn: #ffb36b;
  --bad: #ff7d7d;
  --radius: 18px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Bühne ---------- */
#stage { position: fixed; inset: 0; overflow: hidden; touch-action: none; background: var(--bg); }
#video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transform-origin: 50% 50%; opacity: 0; transition: opacity .4s;
}
#video.on { opacity: 1; }
#freeze { position: absolute; inset: 0; width: 100%; height: 100%; }
#sky { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.top, .bottom {
  position: absolute; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding-left: calc(14px + var(--sal)); padding-right: calc(14px + var(--sar));
  pointer-events: none;
}
.top > *, .bottom > * { pointer-events: auto; }
.top { top: 0; padding-top: calc(10px + var(--sat)); }
.bottom { bottom: 0; padding-bottom: calc(14px + var(--sab)); }

.round {
  width: 50px; height: 50px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); display: grid; place-items: center; cursor: pointer;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.round.small { width: 44px; height: 44px; }
.round svg { width: 24px; height: 24px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.round.small svg { width: 18px; height: 18px; }
.round[aria-pressed="true"] { border-color: var(--accent); }
.round[aria-pressed="true"] svg { stroke: var(--accent); }

.pill {
  display: inline-flex; align-items: center; gap: 8px; max-width: 70vw; min-height: 40px;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); font-size: 14px; color: var(--text); cursor: pointer;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.pill span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }

.readout {
  min-width: 0; flex: 1; text-align: center; font-size: 15px; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px #000, 0 0 8px #000; color: var(--text); pointer-events: none;
}
.readout small { display: block; color: var(--accent); font-size: 13px; }
.readout small.focus { color: #cfe0ff; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round.cap { width: 56px; height: 56px; border-radius: 18px; grid-template-rows: 1fr auto; padding: 6px 0 4px; gap: 0; }
.round.cap svg { width: 22px; height: 22px; align-self: end; }
.caption { font-size: 10.5px; line-height: 1; color: var(--muted); letter-spacing: .2px; }
.round.cap[aria-pressed="true"] .caption { color: var(--accent); }
.raise {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); pointer-events: none !important;
  display: grid; justify-items: center; gap: 6px; color: var(--accent); font-weight: 600; font-size: 17px;
  text-shadow: 0 1px 4px #000; animation: bob 1.4s ease-in-out infinite;
}
.raise svg { width: 54px; height: 54px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 3px #000); }
@keyframes bob { 0%, 100% { transform: translate(-50%, -46%); opacity: .75; } 50% { transform: translate(-50%, -56%); opacity: 1; } }
.cardmoon { float: right; width: 56px; height: 56px; margin: 2px 0 0 10px; }
.card .row { justify-content: flex-end; }
.sheet .tonightlist { list-style: none; margin: 4px 0 8px; padding: 0; }
.tn-head { margin: 14px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--blue); }
.tn-item {
  display: grid; width: 100%; text-align: left; gap: 1px; padding: 10px 12px; margin: 4px 0; min-height: 52px;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); cursor: pointer;
}
.tn-item:active { background: rgba(255, 210, 122, .12); }
.tn-name { font-weight: 650; font-size: 16px; }
.tn-kind { font-size: 13px; color: var(--muted); }
.tn-pos { font-size: 14px; color: var(--accent); font-variant-numeric: tabular-nums; }
.start { transition: opacity .45s ease; }
.start.leaving { opacity: 0; pointer-events: none; }

.hint {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(66px + var(--sat)); width: min(92vw, 440px);
  padding: 10px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line);
  font-size: 14px; text-align: center; color: var(--text);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

.timebar, .alignbar {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(80px + var(--sab)); width: min(94vw, 460px);
  padding: 12px 16px 10px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.alignbar { border-color: rgba(255, 210, 122, 0.5); }
.alignbar p { margin: 0 0 10px; font-size: 15px; }
.timelabel { font-variant-numeric: tabular-nums; font-weight: 600; }
.timebar .scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

input[type="range"] {
  width: 100%; height: 36px; margin: 6px 0 0; background: transparent; -webkit-appearance: none; appearance: none;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: rgba(160, 180, 255, 0.25); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; margin-top: -11px; border-radius: 50%;
  background: var(--accent); border: 0; box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: rgba(160, 180, 255, 0.25); }
input[type="range"]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); border: 0; }

/* ---------- Buttons ---------- */
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.btn {
  min-height: 48px; padding: 12px 18px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06); color: var(--text); font-weight: 600; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 44px; padding: 8px 14px; font-size: 15px; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn.big { width: 100%; min-height: 56px; font-size: 18px; border-radius: 16px; }
.btn.link { background: none; border: 0; color: var(--blue); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: .55; }
.btn:active { transform: scale(.98); }

/* ---------- Sheets ---------- */
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100vw, 520px); max-height: 82vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 8px calc(20px + var(--sar)) calc(20px + var(--sab)) calc(20px + var(--sal));
  background: rgba(12, 16, 30, 0.97); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0; z-index: 10;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .45);
  animation: up .22s ease-out;
  touch-action: pan-y;
}
@keyframes up { from { transform: translate(-50%, 30px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .25); margin: 4px auto 10px; }
.sheet h2 { margin: 4px 0 2px; font-size: 24px; letter-spacing: .2px; }
.sheet h3 { margin: 18px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--blue); }
.sheet section { border-top: 1px solid var(--line); margin-top: 12px; }
.sheet section:first-of-type { border-top: 0; }
.sheethead { display: flex; align-items: center; justify-content: space-between; }
.sub { margin: 0 0 10px; color: var(--accent); font-weight: 500; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0 0 10px; font-size: 15px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; }
.fact { margin: 6px 0 16px; font-size: 16px; line-height: 1.5; }
.small { font-size: 14px; }
.muted { color: var(--muted); }
.license { white-space: pre-line; font-size: 12px; }
.sheet ul { padding-left: 20px; }
.sheet li { margin: 6px 0; }

.toggle { display: flex; align-items: center; gap: 12px; min-height: 46px; cursor: pointer; }
.toggle input {
  -webkit-appearance: none; appearance: none; flex: none; width: 48px; height: 28px; border-radius: 14px; margin: 0;
  background: rgba(160, 180, 255, 0.25); position: relative; transition: background .2s;
}
.toggle input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: transform .2s;
}
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(20px); }
.slider { display: block; padding: 6px 0; }
.slider span { display: flex; justify-content: space-between; }
output { font-variant-numeric: tabular-nums; color: var(--accent); }

/* ---------- Start ---------- */
.start {
  position: fixed; inset: 0; overflow-y: auto; z-index: 5;
  display: flex; flex-direction: column; justify-content: center; gap: 14px;
  padding: calc(28px + var(--sat)) calc(24px + var(--sar)) calc(28px + var(--sab)) calc(24px + var(--sal));
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(80, 100, 200, .35), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(255, 190, 110, .12), transparent 60%),
    var(--bg);
}
.start > * { width: 100%; max-width: 440px; margin-left: auto; margin-right: auto; }
.starthead { text-align: center; }
.logo { width: 72px; height: 72px; fill: var(--accent); }
.logo-line { fill: none; stroke: var(--blue); stroke-width: 1.4; opacity: .7; }
.start h1 { margin: 6px 0 6px; font-size: 38px; letter-spacing: .5px; font-weight: 700; }
.lead { margin: 0; color: #cfd6ef; font-size: 17px; }
.steps { margin: 6px auto 8px; padding: 0 0 0 22px; color: #cfd6ef; font-size: 15px; }
.steps li { margin: 8px 0; }
.steps strong { color: var(--text); }
.err { color: var(--bad); text-align: center; }
.err .btn { margin: 8px 4px 0; color: var(--text); }
.inapp { padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(255, 179, 107, .5); background: rgba(255, 179, 107, .08); font-size: 15px; }
.inapp p { margin: 0 0 10px; }
.inapp .row { justify-content: flex-start; }
.urlbox { width: 100%; margin-top: 8px; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: #000; color: var(--text); font: 14px ui-monospace, monospace; }
.hint.important { border-color: rgba(255, 179, 107, .6); }
.updatebar {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(66px + var(--sat)); z-index: 2;
  padding: 10px 16px; min-height: 44px; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--panel); color: var(--accent); font-size: 14px; cursor: pointer;
}
.permlist { list-style: none; padding: 0; margin: 0; }
.permlist .perm { padding: 6px 0; border-bottom: 1px solid var(--line); }
.permlist .perm:last-child { border-bottom: 0; }
.permhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 15px; }
.perm.ok .permhead span::before, .perm.bad .permhead span::before, .perm.warn .permhead span::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle;
}
.perm.ok .permhead span::before { background: var(--ok); }
.perm.bad .permhead span::before { background: var(--bad); }
.perm.warn .permhead span::before { background: var(--warn); }
.perm p { margin: 4px 0 2px; }
.note { margin: -4px 0 4px 60px; }
.dim { opacity: .5; }
.toggle small { display: block; font-size: 13px; color: var(--muted); }

/* ---------- Rotlicht ---------- */
/* Bedienelemente im Rotlicht neutral, damit der Multiply-Filter nichts verschluckt */
body.red { --blue: #e8e8e8; --accent: #ffffff; --muted: #c8c8c8; --accent-ink: #000; }
#redFilter {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: #ff0000; mix-blend-mode: multiply;
}

/* Querformat / niedrige Höhe: Leisten einzeilig, damit die Bildmitte (Fadenkreuz) frei bleibt */
@media (max-height: 500px) {
  .alignbar { display: flex; align-items: center; gap: 14px; width: min(92vw, 720px); bottom: calc(76px + var(--sab)); padding: 8px 12px; }
  .alignbar p { margin: 0; font-size: 14px; flex: 1; }
  .alignbar .row { flex-wrap: nowrap; }
  .timebar { bottom: calc(76px + var(--sab)); padding: 8px 14px 6px; }
  .sheet { max-height: 92vh; }
}

@media (min-width: 700px) {
  .readout { font-size: 16px; }
}
.toggle input:disabled { opacity: .4; }

/* Debug-Overlay */
.debug {
  position: absolute; left: calc(8px + var(--sal)); right: calc(8px + var(--sar)); top: calc(118px + var(--sat));
  margin: 0; padding: 8px 10px; border-radius: 10px; background: rgba(0, 0, 0, .62); color: #b8ffcf;
  font: 11px/1.35 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; pointer-events: none !important; z-index: 3;
}
.safeprobe { position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none;
  padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
