/* HWGLU Stundenplan – OLED-Dark */
:root {
  --bg: #000;
  --card: #0c0e13;
  --card-2: #12151c;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --txt: #f2f4f8;
  --txt-2: #98a1b0;
  --txt-3: #5c6472;
  --accent: #5e86ff;
  --accent-2: #00c8ff;
  --danger: #ff5c7a;
  --c-weekly: #4f8cff;
  --c-single: #ff9f43;
  --c-biweekly: #b47cff;
  --c-block: #ffd166;
  --c-other: #29c07a;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --app-fill-b: 0px; /* Full-Bleed-Korrektur unten, siehe Kommentar weiter unten */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* --app-fill-b: WebKit-Bug im iOS-Home-Screen-Modus (Standalone). Dort endet
   der Layout-Viewport – und damit 100vh/100dvh sowie fixed inset:0 – bereits
   safe-area-inset-bottom (iPhone 15 Pro: 34px) VOR der physischen Unterkante.
   Der Streifen bis zum Bildschirmrand bleibt schwarz bzw. native unbelegt
   (Inhalt/Sheets koennen dort nicht hinmalen). Alle Vollflaechen-Layer werden
   deshalb um genau diese Hoehe nach unten erweitert (bottom: -1 * --app-fill-b
   bzw. height + var(--app-fill-b)). Im Safari-Browser und auf Geraeten ohne
   den Bug steht 0px drin (keine Aenderung); der genaue Wert wird zusaetzlich
   in app.js (syncAppFill) live gemessen und gesetzt. */
@media (display-mode: standalone) {
  :root { --app-fill-b: env(safe-area-inset-bottom, 0px); }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: #000; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--txt);
  height: 100vh;
  height: calc(100dvh + var(--app-fill-b));
  overflow: hidden; /* das Dokument selbst scrollt nicht – nur #schedule */
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; touch-action: manipulation; }
a { color: var(--accent-2); text-decoration: none; }

.bg-glow {
  position: fixed; top: 0; left: 0; right: 0; bottom: calc(-1 * var(--app-fill-b));
  z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 34% at 85% -6%, rgba(0, 200, 255, 0.16), transparent 70%),
    radial-gradient(52% 30% at 8% -4%, rgba(94, 134, 255, 0.18), transparent 72%);
}

/* ---------- Topbar ---------- */
/* Fix statt sticky: die Topbar ist kein Teil des Scroll-Flows – sie kann sich
   auch bei Rubber-Band/Momentum nicht mitbewegen (siehe .schedule) */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  /* Deckend schwarz statt Glas – bewusst ohne backdrop-filter/Blur. */
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; }
.brand {
  order: 1;
  font-size: 11px; font-weight: 700; letter-spacing: 0.18em; color: var(--txt-3);
  text-transform: uppercase;
}
.week-title {
  order: 3;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  flex: 1 0 100%; margin: 10px 0 0; text-align: center; min-width: 0;
  font-size: clamp(18px, 6.4vw, 26px); font-weight: 800; letter-spacing: -0.02em;
}
.week-title span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-title .chev { flex: 0 0 13px; width: 13px; height: 13px; color: var(--txt-3); }
.actions { order: 2; display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* Ab iPad/Desktop: KW-Titel in die obere Zeile mit den Buttons */
@media (min-width: 768px) {
  .topbar-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas: "brand title actions";
    gap: 0 12px;
  }
  .brand { grid-area: brand; justify-self: start; }
  .week-title { grid-area: title; justify-self: center; margin: 0; }
  .actions { grid-area: actions; justify-self: end; margin-left: 0; }
}
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--card-2); border: 1px solid var(--line);
  transition: transform 0.12s ease, background 0.2s ease;
}
.icon-btn:active { transform: scale(0.92); background: #1a1f29; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pill-btn {
  height: 38px; padding: 0 14px; border-radius: 12px; font-size: 14px; font-weight: 700;
  background: linear-gradient(135deg, rgba(94, 134, 255, 0.22), rgba(0, 200, 255, 0.16));
  border: 1px solid rgba(94, 134, 255, 0.35);
}
.pill-btn:active { transform: scale(0.95); }

/* ---------- Wochenstrip ---------- */
.weekbar { display: flex; align-items: center; gap: 6px; margin-top: 10px; /* gleicher Abstand wie zwischen Button-Zeile und KW-Titel */ }
.nav-btn {
  flex: 0 0 34px; height: 52px; border-radius: 12px; font-size: 24px; line-height: 1;
  color: var(--txt-2); background: var(--card); border: 1px solid var(--line);
}
.nav-btn:active { transform: scale(0.93); }
.day-strip {
  flex: 1; display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.day-strip::-webkit-scrollbar { display: none; }
.day-chip {
  flex: 1 0 44px; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 7px 4px 6px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--line);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}
.day-chip:active { transform: scale(0.94); }
.day-chip .dc-day { font-size: 11px; font-weight: 700; color: var(--txt-3); letter-spacing: 0.04em; }
.day-chip .dc-num { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; }
.day-chip .dc-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent-2); opacity: 0.85; }
.day-chip .dc-dot.empty { background: var(--txt-3); opacity: 0.35; }
.day-chip.today { background: linear-gradient(160deg, rgba(94, 134, 255, 0.3), rgba(0, 200, 255, 0.14)); border-color: rgba(94, 134, 255, 0.5); }
.day-chip.today .dc-day { color: var(--accent-2); }
.day-chip.active { border-color: var(--line-2); background: var(--card-2); }

.status-bar {
  margin-top: 10px; padding: 7px 12px; border-radius: 12px; font-size: 12.5px; color: var(--txt-2);
  background: rgba(255, 159, 67, 0.12); border: 1px solid rgba(255, 159, 67, 0.3);
}
.status-bar.info { background: rgba(94, 134, 255, 0.1); border-color: rgba(94, 134, 255, 0.3); }

/* ---------- Stundenplan ---------- */
/* Eigener Scroll-Container UNTER der fixen Topbar. Rubber-Band und Momentum
   bewegen ausschliesslich dessen Inhalt – die Topbar bleibt selbst bei
   schnellen Flicks stehen, ganz ohne JS-Gegensteuern (die waeren die Ursache
   fuer Ruckler). Padding-top = Topbarhoehe + 18px haelt das alte Layout:
   Inhalt beginnt unter der Leiste und laeuft beim Scrollen darunter durch. */
.schedule {
  /* inset:0 wuerde im iOS-Standalone-Modus unten bereits
     safe-area-inset-bottom vor der Unterkante enden – bottom bewusst
     ueber --app-fill-b nach unten erweitert */
  position: fixed; top: 0; left: 0; right: 0; bottom: calc(-1 * var(--app-fill-b));
  z-index: 1;
  overflow-y: auto;
  overscroll-behavior-y: contain; /* kein Scroll-Chaining an das Dokument – der lokale Bounce am Rand bleibt */
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--scroll-offset, 131px) + 8px) 16px calc(28px + max(var(--safe-b), var(--app-fill-b)));
}
/* --scroll-offset wird in app.js gemaess echter Topbar-Hoehe gesetzt
   (variiert je Geraet: safe-area-inset, Zeilenumbruch, Statusleiste) */
.day-section { margin-bottom: 26px; scroll-margin-top: var(--scroll-offset, 131px); }
/* Am Seitenende KEINE Scroll-Reserve mehr: der fruehere Zuschlag
   26px + var(--scroll-offset) erzeugte den grossen schwarzen Balken unter dem
   letzten Wochentag. Die letzte Tagessktion endet jetzt direkt am Listenende –
   den Abschluss-Abstand liefert das Padding von .schedule. Der Sprung zum
   letzten Tag klemmt in scrollToSection/targetY() bereits auf max-Scroll und
   landet damit sauber am Listenende (der Tag kann dann nur nicht mehr ganz
   unter die Topbar wegspringen – bewusst in Kauf genommen). */
.day-section:last-child { margin-bottom: 0; }
.day-head { display: flex; align-items: baseline; gap: 10px; margin: 0 2px 10px; }
.day-head .dh-name { font-size: 13px; font-weight: 800; letter-spacing: 0.14em; color: var(--txt-2); }
.day-head .dh-date { font-size: 13px; color: var(--txt-3); }
.day-head .dh-today {
  margin-left: auto; font-size: 10.5px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: #06121c; background: linear-gradient(135deg, var(--accent-2), var(--accent));
  padding: 3px 9px; border-radius: 99px;
}

.event-card {
  position: relative; display: flex; gap: 14px; width: 100%; text-align: left;
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-left: 3px solid var(--c-other);
  border-radius: var(--radius); padding: 14px 14px 14px 12px; margin-bottom: 10px;
  transition: transform 0.12s ease, border-color 0.2s ease;
}
.event-card:active { transform: scale(0.98); border-color: var(--line-2); }
.event-card.k-weekly { border-left-color: var(--c-weekly); }
.event-card.k-single { border-left-color: var(--c-single); }
.event-card.k-biweekly { border-left-color: var(--c-biweekly); }
.event-card.k-block { border-left-color: var(--c-block); }
/* Laufende Vorlesung: die Karte selbst ist der "jetzt"-Marker (keine jetzt-Linie) */
.event-card.is-live {
  border-color: rgba(255, 92, 122, 0.5);
  border-left-color: var(--danger);
  background: linear-gradient(180deg, rgba(255, 92, 122, 0.16), rgba(255, 92, 122, 0.05)), var(--card-2);
  box-shadow: 0 0 0 1px rgba(255, 92, 122, 0.25), 0 8px 26px rgba(255, 92, 122, 0.1);
}
.event-card.is-live .ec-time .t1 { color: var(--danger); }

.ec-time { flex: 0 0 52px; padding-top: 1px; }
.ec-time .t1 { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.ec-time .t2 { font-size: 12.5px; color: var(--txt-3); font-variant-numeric: tabular-nums; }
.ec-main { flex: 1; min-width: 0; }
.ec-title {
  font-size: 15.5px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ec-sub { margin-top: 5px; font-size: 12.5px; color: var(--txt-2); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.ec-sub span { display: inline-flex; align-items: center; gap: 5px; }
.ec-sub svg { width: 12px; height: 12px; color: var(--txt-3); flex: none; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.badge {
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3.5px 8px; border-radius: 8px; color: var(--txt-2);
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
}
.badge.type { color: var(--accent-2); border-color: rgba(0, 200, 255, 0.25); background: rgba(0, 200, 255, 0.08); }
.badge.kind-single { color: var(--c-single); border-color: rgba(255, 159, 67, 0.3); background: rgba(255, 159, 67, 0.08); }
.badge.kind-biweekly { color: var(--c-biweekly); border-color: rgba(180, 124, 255, 0.3); background: rgba(180, 124, 255, 0.08); }
.badge.kind-block { color: var(--c-block); border-color: rgba(255, 209, 102, 0.3); background: rgba(255, 209, 102, 0.08); }
.badge.live {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--danger); border-color: rgba(255, 92, 122, 0.4); background: rgba(255, 92, 122, 0.12);
}
.badge.live .lv-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--danger);
  box-shadow: 0 0 8px var(--danger); animation: livePulse 1.4s ease-in-out infinite;
}
@keyframes livePulse { 50% { opacity: 0.3; transform: scale(0.75); } }
@media (prefers-reduced-motion: reduce) {
  .badge.live .lv-dot { animation: none; }
}

.ec-progress {
  height: 3px; margin-top: 10px; border-radius: 99px;
  background: rgba(255, 255, 255, 0.08); overflow: hidden;
}
.ec-progress i {
  display: block; height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--danger), rgba(255, 92, 122, 0.45));
}

/* Jetzt-Linie: nur wenn gerade keine Vorlesung laeuft (vor allen Terminen,
   Pause zwischen zwei Terminen, nach allen). Waehrend einer laufenden
   Vorlesung markiert die is-live-Karte "jetzt". */
.now-line { display: flex; align-items: center; gap: 8px; margin: 2px 2px 12px; }
.now-line .nl-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 10px var(--danger); }
.now-line .nl-bar { flex: 1; height: 1.5px; background: linear-gradient(90deg, var(--danger), rgba(255, 92, 122, 0.05)); }
.now-line .nl-txt { font-size: 11px; font-weight: 800; color: var(--danger); font-variant-numeric: tabular-nums; }

.empty-day { font-size: 13px; color: var(--txt-3); padding: 4px 2px 0; }
.empty-week {
  text-align: center; padding: 48px 24px; border: 1px dashed var(--line-2); border-radius: 22px;
  color: var(--txt-2); font-size: 15px; line-height: 1.5;
}
.empty-week .big { font-size: 40px; display: block; margin-bottom: 10px; }

/* Skeleton */
.skeleton { height: 92px; border-radius: var(--radius); margin-bottom: 10px;
  background: linear-gradient(100deg, var(--card) 30%, var(--card-2) 50%, var(--card) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border: 1px solid var(--line); }
@keyframes shimmer { to { background-position: -200% 0; } }
/* ---------- Sheets ---------- */
.backdrop {
  position: fixed; top: 0; left: 0; right: 0; bottom: calc(-1 * var(--app-fill-b));
  z-index: 40; background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: calc(-1 * var(--app-fill-b)); z-index: 50;
  background: linear-gradient(180deg, #14171e, #0a0c10);
  border-top: 1px solid var(--line-2);
  border-radius: 26px 26px 0 0;
  /* Die Sheet-Unterkante liegt via --app-fill-b in JEDEM Zustand auf der
     physikalischen Bildschirmkante (live gemessen in app.js/syncAppFill).
     Der Inhalt-Abstand unten muss aber den UEBERHANG mitfreiraeumen: mit
     nur 24px + safe-b rutscht der Button in den verdeckten Randbereich
     (Home-Indicator-Band, 34px) – auf dem iPhone 15 Pro meldet
     env(safe-area-inset-bottom) dort 0px und laeuft leer. max(safe-b,
     app-fill-b) legt den Button zustandsunabhaengig 24px ueber die
     nutzbare Unterkante – exakt die als "gut" bestaetigte Position. */
  padding: 10px 20px calc(24px + var(--safe-b)); /* Fallback ohne max() */
  padding-bottom: calc(24px + max(var(--safe-b), var(--app-fill-b)));
  max-height: 86vh; max-height: 86dvh; overflow-y: auto;
  overscroll-behavior-y: contain; /* wie .schedule: lokaler Bounce am Rand, kein Chaining zum Dokument */
  animation: slideUp 0.26s cubic-bezier(0.2, 0.9, 0.25, 1);
}
@keyframes slideUp { from { transform: translateY(60px); opacity: 0.4; } }
.sheet-handle { width: 40px; height: 4.5px; border-radius: 99px; background: var(--line-2); margin: 4px auto 16px; }
.sheet-body h2 { font-size: 21px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 10px; }
.hint { font-size: 13px; color: var(--txt-2); line-height: 1.5; margin-bottom: 14px; }
.hint.small { font-size: 11.5px; color: var(--txt-3); margin-top: 12px; }
.msg-warn {
  padding: 11px 13px; border-radius: 12px; color: #ffb3c1;
  background: rgba(255, 92, 122, 0.1); border: 1px solid rgba(255, 92, 122, 0.32);
}

.detail-title { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; margin-bottom: 12px; }
.detail-grid { display: grid; grid-template-columns: 92px 1fr; gap: 10px 12px; font-size: 14.5px; margin: 14px 0 6px; }
.detail-grid .k { color: var(--txt-3); font-size: 13px; padding-top: 1px; }
.detail-grid .v { color: var(--txt); }
.primary-btn {
  height: 46px; padding: 0 18px; border-radius: 14px; font-size: 15px; font-weight: 800; color: #05101c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.primary-btn:active { transform: scale(0.97); }
.ghost-btn {
  height: 46px; padding: 0 18px; border-radius: 14px; font-size: 14px; font-weight: 700; color: var(--txt-2);
  background: var(--card-2); border: 1px solid var(--line);
}
.ghost-btn:active { transform: scale(0.97); }
.btn-row { display: flex; gap: 10px; margin-top: 16px; }
.btn-row > * { flex: 1; }
.link-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 18px; }

.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12px; color: var(--txt-3); margin-bottom: 6px; letter-spacing: 0.02em; }
.field input {
  width: 100%; height: 46px; border-radius: 13px; padding: 0 14px; font-size: 16px; color: var(--txt);
  background: var(--card); border: 1px solid var(--line-2); outline: none;
}
.field input:focus { border-color: var(--accent); }

.week-list { display: flex; flex-direction: column; gap: 8px; }
.week-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 15px; border-radius: 14px; text-align: left;
  background: var(--card); border: 1px solid var(--line); font-size: 14.5px;
}
.week-item.current { border-color: rgba(94, 134, 255, 0.5); background: rgba(94, 134, 255, 0.1); }
.week-item .wi-range { color: var(--txt-3); font-size: 12.5px; }
.week-item .wi-tag { font-size: 10px; font-weight: 800; letter-spacing: 0.08em; color: var(--c-single); text-transform: uppercase; }

.toast {
  /* 30px + safe-b ueber der Fixed-Unterkante = 30px ueber der nutzbaren
     Unterkante. "- var(--app-fill-b)" (frueher hier) zog den Toast in den
     verdeckten Randbereich – untere Kante angeschnitten. */
  position: fixed; left: 50%; bottom: calc(30px + var(--safe-b)); transform: translateX(-50%);
  z-index: 60; max-width: 86vw; padding: 12px 18px; border-radius: 14px; font-size: 13.5px;
  background: #1b2029; border: 1px solid var(--line-2); color: var(--txt);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.6); animation: slideUp 0.22s ease;
}
