/* Milchbar – die Nachtbar mit nur einem Stammgast */
:root {
  color-scheme: dark;
  --bg: #170d22;
  --bg-card: #22142f;
  --bg-input: #2e1d3f;
  --line: #3e2a53;
  --text: #fbefe4;
  --muted: #b9a6c9;
  --neon: #ff5fa8;
  --neon-glow: rgba(255, 95, 168, 0.55);
  --neon-soft: rgba(255, 95, 168, 0.14);
  --mint: #7ff0d0;
  --amber: #ffc46b;
  --danger: #ff7a7a;
  --radius: 20px;
  --tabbar-h: 54px;
  --bar-bg: #1c1029;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-sign: "Snell Roundhand", "Brush Script MT", "Segoe Script", "Dancing Script", cursive;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 95, 168, 0.20), transparent 60%),
    radial-gradient(80% 50% at 100% 100%, rgba(127, 240, 208, 0.07), transparent 60%),
    var(--bg);
  -webkit-tap-highlight-color: transparent;
}

/* Onboarding & Co.: ganz normale Seite */
#app.no-tabs {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 32px);
}

/* App mit Tab-Leiste: fester Rahmen in Bildschirmhöhe. Nur #view scrollt, und #view endet genau
   über der Leiste – dadurch kann (auch auf iPhones mit Safari-Leiste/Home-Balken) nichts dahinter verschwinden. */
/* An allen vier Bildschirmkanten festgemacht statt "100vh": iPhones im Home-Bildschirm-Modus melden
   die Höhe teils zu klein, dann bliebe unten ein leerer Streifen. */
body.locked { overflow: hidden; }
#app.shell {
  position: fixed;
  top: 0; right: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(255, 95, 168, 0.20), transparent 60%),
    radial-gradient(80% 50% at 100% 100%, rgba(127, 240, 208, 0.07), transparent 60%),
    var(--bg);
}
/* iPhone-Home-Bildschirm-App: Manche iOS-Versionen geben der App nicht die volle Höhe – unter der
   Tab-Leiste bleibt ein Streifen, den iOS mit dem Seitenhintergrund füllt. Der bekommt die Farbe der
   Leiste, damit er wie ein Teil davon aussieht. */
html.in-app { background: var(--bar-bg); }
html.in-app body { background: transparent; }
/* Wenn der Streifen da ist (vom Handy gemessen), hält iOS den Home-Balken-Bereich schon frei →
   kein zusätzlicher Abstand in der Leiste, sonst wäre er doppelt. */
html.vp-short .tabbar { padding-bottom: 4px; }
#view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 16px;
}
.view-inner { max-width: 520px; margin: 0 auto; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.8em; }
small, .muted { color: var(--muted); }
b, strong { font-weight: 700; }
a { color: var(--neon); }

/* ---------- Neon-Schild ---------- */
.neon {
  font-family: var(--font-sign);
  font-weight: 400;
  color: #fff3f9;
  text-shadow:
    0 0 4px #fff,
    0 0 10px var(--neon),
    0 0 22px var(--neon),
    0 0 40px var(--neon-glow);
  letter-spacing: 0.01em;
}
.sign { text-align: center; padding: 28px 0 18px; }
.sign .neon { font-size: clamp(3.2rem, 16vw, 4.6rem); margin: 0; animation: flicker 7s infinite; }
.sign .tagline { color: var(--muted); margin-top: 4px; font-size: 0.98rem; }
.topbar { display: flex; align-items: center; justify-content: center; padding: 4px 0 10px; }
.topbar .neon { font-size: 2.1rem; margin: 0; }

@keyframes flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: 0.55; }
  94% { opacity: 1; }
  96% { opacity: 0.7; }
  97% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .sign .neon { animation: none; }
}

.splash { min-height: 70dvh; display: grid; place-items: center; }
.splash .neon { font-size: 4rem; }

/* ---------- Karten ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.card.glow {
  border-color: rgba(255, 95, 168, 0.45);
  box-shadow: 0 0 0 1px rgba(255, 95, 168, 0.12), 0 10px 40px -12px var(--neon-glow);
}
.card.running {
  border-color: rgba(127, 240, 208, 0.5);
  box-shadow: 0 10px 40px -14px rgba(127, 240, 208, 0.55);
}
.label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}
.big {
  font-size: clamp(2.3rem, 11vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  margin: 2px 0 8px;
}
.running .big { color: var(--mint); }
.sub { color: var(--muted); }
.sub b { color: var(--text); font-weight: 600; }
.hero { text-align: center; padding: 24px 18px; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 16px;
  min-height: 48px;
  padding: 12px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.block { width: 100%; }
.btn.xl { min-height: 64px; font-size: 1.2rem; border-radius: 20px; }
.btn.primary { background: var(--neon); color: #2a0a1b; box-shadow: 0 8px 26px -8px var(--neon-glow); }
.btn.mint { background: var(--mint); color: #082b22; box-shadow: 0 8px 26px -10px rgba(127, 240, 208, 0.7); }
.btn.secondary { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger-ghost { background: transparent; color: var(--danger); padding-left: 4px; padding-right: 4px; }
.btn.link {
  background: none; color: var(--muted); min-height: 40px; padding: 8px; font-weight: 500;
  text-decoration: underline; text-underline-offset: 3px;
}
.btn.small { min-height: 38px; padding: 8px 14px; font-size: 0.95rem; border-radius: 12px; white-space: nowrap; }
.stack { display: grid; gap: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.center { text-align: center; }

/* ---------- Segment-Auswahl (Links/Rechts/Beide) ---------- */
.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: var(--bg-input);
  padding: 5px;
  border-radius: 16px;
  margin-bottom: 14px;
}
.seg button, .seg label span {
  font: inherit;
  font-weight: 600;
  display: block;
  text-align: center;
  border: 0;
  border-radius: 12px;
  padding: 11px 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.seg button[aria-pressed="true"], .seg input:checked + span {
  background: var(--text);
  color: var(--bg);
}
.seg label { display: block; }
.seg.two { grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
.hint.mode-hint { margin: 0 0 14px; }
.hint.warn { color: var(--amber); margin: 0 0 12px; }
.switch-row.big-switch { padding: 6px 0 4px; }
.switch-row.big-switch span { font-size: 1.05rem; }
input[type="checkbox"].switch:disabled { opacity: 0.45; cursor: not-allowed; }
h3 small { font-weight: 500; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:focus-visible + span { outline: 2px solid var(--neon); }
.next-side { margin: 0 0 10px; color: var(--muted); }
.next-side b { color: var(--amber); }

/* ---------- Formulare ---------- */
.field { display: grid; gap: 6px; margin: 0 0 14px; border: 0; padding: 0; }
.field > span, .field > legend { font-size: 0.92rem; color: var(--muted); padding: 0; }
input[type="text"], input[type="number"], input[type="time"], input[type="datetime-local"] {
  font: inherit;
  width: 100%;
  color: var(--text);
  background: var(--bg-input);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 50px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
input:focus { border-color: var(--neon); }
input::placeholder { color: #8a779b; }
input.code-input { text-transform: uppercase; letter-spacing: 0.15em; font-weight: 700; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0 12px; cursor: pointer; }
.switch-row span { font-weight: 600; }
input[type="checkbox"].switch {
  -webkit-appearance: none; appearance: none;
  width: 54px; height: 32px; border-radius: 99px; flex-shrink: 0;
  background: var(--bg-input); border: 1.5px solid var(--line);
  position: relative; cursor: pointer; transition: background 0.2s;
}
input[type="checkbox"].switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 23px; height: 23px; border-radius: 50%;
  background: var(--muted); transition: transform 0.2s, background 0.2s;
}
input[type="checkbox"].switch:checked { background: var(--neon); border-color: var(--neon); }
input[type="checkbox"].switch:checked::after { transform: translateX(22px); background: #fff; }

.interval { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.interval input { width: 76px; text-align: center; }
.times { display: flex; align-items: center; gap: 8px; }
.times input { flex: 1 1 0; min-width: 0; padding-left: 8px; padding-right: 8px; text-align: center; }
.dimmed { opacity: 0.45; pointer-events: none; }
.hint { font-size: 0.9rem; color: var(--muted); margin: 8px 0 0; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 16px; }
.chip {
  font: inherit; font-size: 0.9rem; font-weight: 600;
  border: 1.5px solid var(--line); background: transparent; color: var(--text);
  border-radius: 99px; padding: 6px 12px; cursor: pointer;
}
.chip:active { background: var(--neon-soft); }

/* ---------- Hinweise / Status ---------- */
.notice { display: flex; gap: 12px; align-items: flex-start; }
.notice .icon { font-size: 1.5rem; line-height: 1.2; }
.notice p { margin: 0; }
.notice .btn { margin-top: 10px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat { background: var(--bg-card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.stat .num { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 0.82rem; color: var(--muted); }

ol.steps { padding-left: 1.3em; margin: 0 0 14px; }
ol.steps li { margin-bottom: 8px; }
.share-glyph {
  display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; vertical-align: -0.35em;
  border: 1.5px solid var(--text); border-radius: 5px; font-size: 0.8em;
}
.code-box { text-align: center; background: var(--bg-input); border-radius: 16px; padding: 14px; margin-top: 8px; }
.code-box strong { display: block; font-size: 1.8rem; letter-spacing: 0.12em; color: var(--amber); margin: 4px 0; }

.qr { background: #fff; border-radius: 16px; padding: 10px; width: 200px; margin: 6px auto 12px; }
.qr svg { display: block; width: 100%; height: auto; }

/* ---------- Verlauf ---------- */
.page-title { font-size: 1.5rem; margin: 6px 0 14px; }
.day { margin-bottom: 18px; }
.day h3 { display: flex; justify-content: space-between; font-size: 0.95rem; color: var(--muted); margin: 0 4px 8px; font-weight: 600; }
.feed-list { list-style: none; margin: 0; padding: 0; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.feed-list li + li { border-top: 1px solid var(--line); }
.feed-row {
  font: inherit; color: inherit; background: none; border: 0; width: 100%; text-align: left; cursor: pointer;
  display: grid; grid-template-columns: 3.4em 2.6em 1fr auto; align-items: center; gap: 10px;
  padding: 13px 14px; min-height: 56px;
}
.feed-row:active { background: var(--neon-soft); }
.feed-row .time { font-weight: 800; font-variant-numeric: tabular-nums; }
.feed-row .meta { color: var(--muted); font-size: 0.92rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-row .gap { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-grid; place-items: center; font-weight: 800; font-size: 0.85rem;
  min-width: 2.3em; height: 1.9em; border-radius: 99px; padding: 0 6px;
}
.badge.L { background: rgba(255, 95, 168, 0.18); color: var(--neon); }
.badge.R { background: rgba(255, 196, 107, 0.18); color: var(--amber); }
.badge.B { background: rgba(127, 240, 208, 0.16); color: var(--mint); }
.badge.live { background: var(--mint); color: #082b22; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .icon { font-size: 2.6rem; display: block; margin-bottom: 8px; }

/* ---------- Tab-Leiste ---------- */
.tabbar {
  flex: 0 0 auto;
  position: relative; z-index: 10;
  display: flex; justify-content: center;
  background: var(--bar-bg);
  border-top: 1px solid var(--line);
  /* Home-Balken-Bereich nicht komplett freihalten (wie bei Apples eigenen Tab-Leisten) – spart Platz */
  padding-bottom: max(4px, calc(env(safe-area-inset-bottom) - 14px));
}
.tabbar .inner { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; max-width: 520px; }
.tabbar button {
  font: inherit; font-size: 0.72rem; font-weight: 600; color: var(--muted);
  background: none; border: 0; height: var(--tabbar-h); cursor: pointer;
  display: grid; place-content: center; gap: 1px;
}
.tabbar button .ico { font-size: 1.3rem; line-height: 1; }
.tabbar button[aria-current="page"] { color: var(--neon); }
.tabbar button[aria-current="page"] .ico { filter: drop-shadow(0 0 6px var(--neon-glow)); }

/* ---------- Dialog ---------- */
dialog {
  width: min(520px, 100vw);
  max-width: 100vw;
  max-height: 92dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: auto auto 0;
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  background: var(--bg-card);
  color: var(--text);
}
dialog::backdrop { background: rgba(8, 3, 14, 0.7); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
dialog[open] { animation: sheet 0.22s ease-out; }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.dialog-actions .spacer { flex: 1; }
@media (min-width: 560px) {
  dialog { margin: auto; border-radius: 24px; border-bottom: 1px solid var(--line); }
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 6px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 50;
  background: var(--text); color: var(--bg); font-weight: 600;
  padding: 11px 18px; border-radius: 14px; max-width: calc(100vw - 32px); width: max-content;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--danger); color: #2b0606; }

.footer { text-align: center; color: var(--muted); font-size: 0.85rem; margin-top: 20px; }
.footer.tech { font-size: 0.7rem; opacity: 0.6; margin-top: 4px; }
