:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #4A90D9;
  --text: #e0e0e0;
  --text-muted: #888;
  --success: #2ecc71;
  --warning: #f39c12;
  --danger: #e74c3c;
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  max-width: 680px;
  margin: 0 auto;
  /* Safe-Area: Home-Indicator unten (iPhone) + Notch-Seiten im Querformat */
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 100;
  border-bottom: 1px solid var(--surface2);
  overflow-x: auto;
  scrollbar-width: none; /* Firefox */
  /* Safe-Area oben: schiebt die Buttons unter die iOS-Statusleiste
     (Uhrzeit/WLAN/Akku); der Hintergrund fuellt den Bereich dahinter. */
  padding-top: env(safe-area-inset-top, 0px);
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 0 0 auto;
  padding: 14px 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color .2s, border-color .2s;
  white-space: nowrap;
  /* iOS: kein blauer Tap-Highlight, kein versehentliches Text-Markieren */
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Wrapper haelt den Scroll-Hinweis (Verlauf am rechten Rand) an Ort und Stelle */
.tabs-wrap {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
}
/* Verlauf rechts = sichtbarer Hinweis, dass noch Reiter folgen.
   Verschwindet automatisch, sobald ganz nach rechts gescrollt wurde. */
.tabs-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 1px;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to right, transparent, var(--surface));
  opacity: 1;
  transition: opacity .2s;
}
.tabs-wrap.scrolled-end::after { opacity: 0; }
.tabs-wrap .tabs { position: static; }

/* Schmale Phones: kompaktere Tabs, damit moeglichst viele sichtbar sind */
@media (max-width: 430px) {
  .tab-btn { padding: 12px 6px; font-size: 12px; }
}
@media (max-width: 360px) {
  .tab-btn { padding: 11px 5px; font-size: 11px; }
}

/* ── Token-Eingabe (ersetzt prompt(), das im iOS-PWA blockiert wird) ── */
.token-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px
           calc(20px + env(safe-area-inset-bottom, 0px));
}
.token-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
}
.token-title { font-size: 17px; font-weight: 600; margin-bottom: 10px; }
.token-text { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 14px; }
.token-input {
  width: 100%;
  padding: 13px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface2);
  background: var(--bg);
  color: var(--text);
  /* 16px verhindert den Auto-Zoom von iOS-Safari beim Fokussieren */
  font-size: 16px;
  font-family: ui-monospace, monospace;
}
.token-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.token-show {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
  margin: 10px 0 14px;
  cursor: pointer;
}
.token-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.token-btn:active { opacity: .8; }

/* ── Header ── */
.day-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.day-nav-btn {
  background: var(--surface2);
  border: none;
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.day-nav-btn:hover { background: var(--accent); }
.day-title { font-size: 17px; font-weight: 600; text-align: center; }
.day-sub { font-size: 12px; color: var(--text-muted); text-align: center; }

.today-btn {
  display: block;
  margin: 0 auto 12px;
  background: none;
  border: 1px solid var(--surface2);
  color: var(--text-muted);
  padding: 4px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
}
.today-btn:hover { background: var(--surface2); color: var(--text); }

/* ── Kapazitaet-Bar ── */
.kap-bar-wrap { padding: 0 16px 12px; }
.kap-bar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.kap-bar-label { font-size: 12px; color: var(--text-muted); }
.kap-bar-bg {
  background: var(--surface2);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.kap-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width .4s;
}

/* ── Sektions-Ueberschrift ── */
.section-title {
  padding: 8px 16px 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
  gap: 8px;
}
.section-title-row .section-title { padding: 0; }

/* ── Lernblock-Karte ── */
.block-card {
  margin: 6px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-left: 4px solid var(--accent);
  transition: opacity .2s;
}
.block-card.erledigt { opacity: .45; }
.block-card.erledigt .block-title { text-decoration: line-through; }

.block-check {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
  transition: background .15s, border-color .15s;
  color: white;
}
.block-check.checked {
  background: var(--success);
  border-color: var(--success);
}

.block-body { flex: 1; min-width: 0; }
.block-fach {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 3px;
}
.block-title { font-size: 15px; font-weight: 500; word-break: break-word; }
.block-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.block-actions { display: flex; gap: 4px; flex-shrink: 0; }
.action-btn {
  background: var(--surface2);
  border: none;
  color: var(--text);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s;
}
.action-btn:hover { background: var(--accent); }
.action-btn.danger { color: var(--text-muted); }
.action-btn.danger:hover { background: var(--danger); color: white; }
.action-btn.primary { background: var(--accent); color: white; font-weight: 600; }
.action-btn.primary:hover { opacity: .85; }
.action-btn.small { padding: 4px 8px; font-size: 12px; }

/* ── Wiederholungs-Karte ── */
.wdh-card {
  margin: 6px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  border-left: 4px solid var(--warning);
}
.wdh-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.wdh-icon { font-size: 18px; }
.wdh-title { font-size: 15px; font-weight: 500; }
.wdh-fach { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--warning); }
.wdh-ratings { display: flex; gap: 8px; flex-wrap: wrap; }
.rating-btn {
  flex: 1;
  min-width: 70px;
  padding: 10px 4px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: white;
  transition: opacity .15s;
}
.rating-btn:hover { opacity: .85; }
.rating-btn[data-r="wieder"] { background: #c0392b; }
.rating-btn[data-r="schwer"] { background: #e67e22; }
.rating-btn[data-r="gut"] { background: #27ae60; }
.rating-btn[data-r="einfach"] { background: #2980b9; }

/* ── PDF-Link ── */
.block-body.has-pdf {
  cursor: pointer;
}
.block-sources {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.source-badge:hover {
  opacity: .85;
  transform: scale(1.04);
}
.pdf-badge {
  background: #e8f0fe;
  color: #1a73e8;
}
.thea-badge {
  background: #fce8f3;
  color: #c2185b;
}
.podcast-badge {
  background: #e8f5e9;
  color: #2e7d32;
}
.skript-badge {
  background: #fff4e6;
  color: #b95000;
  text-decoration: none;
}
/* Podcast-Button in TG-Row: gedimmt wenn kein Podcast, farbig wenn vorhanden */
.tg-podcast {
  opacity: 0.35;
  filter: grayscale(0.7);
}
.tg-podcast.has-podcast {
  opacity: 1;
  filter: none;
}

/* ── Recall- & Endspurt-Bloecke ── */
.block-card.block-recall {
  background: linear-gradient(to right, rgba(255, 152, 0, 0.08), transparent 80%);
}
.block-card.block-endspurt {
  background: linear-gradient(to right, rgba(229, 57, 53, 0.10), transparent 80%);
}
.recall-banner {
  display: inline-block;
  margin: 4px 0;
  padding: 4px 8px;
  background: #fff3e0;
  color: #e65100;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #ffcc80;
}
.pdf-info {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  background: #eceff1;
  color: #455a64;
  border-radius: 4px;
  margin-left: 4px;
}
.kr-badge {
  display: inline-block;
  font-size: 11px;
  margin-left: 4px;
  letter-spacing: -1px;
}
.kr-badge.kr-3 { color: #e65100; font-weight: 700; }
.kr-badge.kr-2 { color: #f9a825; }

/* ── NLP-Cluster Badge & Modal ── */
.cluster-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  background: #ede7f6;
  color: #4527a0;
  border: 1.5px solid #d1c4e9;
  cursor: pointer;
  transition: all .15s;
}
.cluster-badge:hover {
  background: #d1c4e9;
  transform: scale(1.04);
}
.cluster-modal {
  max-width: 600px;
}
.cluster-bigLabel {
  font-size: 14px;
  color: #4527a0;
  background: #ede7f6;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 600;
}
.cluster-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--bg-card);
  border-left: 4px solid #4A90D9;
  border-radius: 6px;
  font-size: 13px;
}
.cluster-fach {
  font-weight: 700;
  font-size: 10px;
  background: var(--surface);
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
}
.cluster-titel {
  flex: 1;
  font-weight: 500;
}
.cluster-sim {
  font-size: 11px;
  color: #6a1b9a;
  font-weight: 700;
  background: #f3e5f5;
  padding: 1px 6px;
  border-radius: 4px;
}
.cluster-otherlbl {
  font-size: 10px;
  color: var(--text-muted);
  padding: 1px 5px;
  background: var(--surface);
  border-radius: 4px;
}
.modal-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
  margin: 8px 0 16px;
}
.endspurt-banner {
  display: inline-block;
  margin: 4px 0;
  padding: 4px 8px;
  background: #ffebee;
  color: #b71c1c;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid #ef9a9a;
}

/* ── Media Tracking ── */
.media-track {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.media-toggle {
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: transparent;
  cursor: pointer;
  opacity: 0.45;
  transition: all .15s;
  line-height: 1.4;
}
.media-toggle.active {
  opacity: 1;
  border-color: var(--primary);
  background: #e8f0fe;
}
.media-hist {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
  white-space: nowrap;
}
.media-hist-wdh {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding: 6px 8px;
  background: var(--bg-card);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.media-used-today {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.media-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Active Recall ── */
.recall-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--warning);
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
}
.recall-questions {
  margin-bottom: 10px;
}
.recall-q {
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 10px;
  background: rgba(243,156,18,.1);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  border-left: 3px solid var(--warning);
}
.recall-q-item {
  margin-bottom: 8px;
}
.recall-q-item .recall-q { margin-bottom: 4px; }
.recall-star {
  float: right;
  color: var(--warning);
  font-size: 11px;
  letter-spacing: 1px;
}
.recall-toggle {
  font-size: 11px;
  padding: 3px 10px;
  background: transparent;
  border: 1px solid var(--warning);
  color: var(--warning);
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 4px;
}
.recall-toggle:hover { background: rgba(243,156,18,.15); }
.recall-a {
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 10px;
  background: rgba(46,125,50,.08);
  border-left: 3px solid #2e7d32;
  border-radius: var(--radius-sm);
  margin: 4px 0 6px;
  color: var(--text);
}
.recall-show-btn {
  width: 100%;
  margin-top: 4px;
}
.recall-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-style: italic;
}
.recall-tg-link {
  display: inline-block;
  font-size: 11px;
  color: var(--primary);
  text-decoration: none;
  margin-bottom: 8px;
  cursor: pointer;
}
.recall-tg-link:hover { text-decoration: underline; }

/* ── Leerer Zustand ── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }

/* ── Faecher-Tab ── */
.fach-card {
  margin: 8px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}
.fach-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  cursor: pointer;
}
.fach-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fach-name { flex: 1; font-weight: 600; }
.fach-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-muted);
}
.fach-badge.prio-hoch { background: #c0392b33; color: var(--danger); }
.fach-badge.prio-mittel { background: #e67e2233; color: var(--warning); }
.fach-badge.prio-niedrig { background: #27ae6033; color: var(--success); }
.fach-collapse { font-size: 12px; color: var(--text-muted); transition: transform .2s; }
.fach-card.expanded .fach-collapse { transform: rotate(180deg); }
.fach-tg-list {
  padding: 0 14px 14px;
  display: none;
  flex-direction: column;
  gap: 6px;
}
.fach-card.expanded .fach-tg-list { display: flex; }
.tg-row {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  gap: 8px;
}
.tg-title { flex: 1; font-size: 14px; word-break: break-word; }
.tg-prio { font-size: 11px; padding: 2px 8px; border-radius: 20px; flex-shrink: 0; }
.prio-hoch { background: #c0392b33; color: var(--danger); }
.prio-mittel { background: #e67e2233; color: var(--warning); }
.prio-niedrig { background: #27ae6033; color: var(--success); }

/* ── Sync-Tab ── */
.sync-section { padding: 16px; }
.trainer-grid { display: flex; flex-direction: column; gap: 8px; }
.trainer-card {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface); border-left: 4px solid var(--accent);
  text-decoration: none; color: var(--text);
  transition: transform .1s, box-shadow .1s;
}
.trainer-card:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,.1); }
.trainer-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: bold; font-size: 13px; flex-shrink: 0;
}
.trainer-body { flex: 1; min-width: 0; }
.trainer-title { font-size: 14px; font-weight: 600; }
.trainer-sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.sync-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  transition: opacity .2s;
}
.sync-btn:hover { opacity: .85; }
.sync-btn:disabled { opacity: .5; cursor: not-allowed; }
.sync-log {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  color: var(--text-muted);
  min-height: 60px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  transition: transform .3s;
  z-index: 999;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Dialog ── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Safe-Area, damit Dialoge nicht unter Statusleiste/Home-Indicator rutschen */
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px
           calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 200;
  animation: fadeIn .15s ease;
}

/* ── View Switcher (Liste vs Timeline) ── */
.view-switcher {
  display: flex;
  gap: 6px;
  align-items: center;
}
.view-btn {
  padding: 4px 10px;
  font-size: 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  transition: all .12s;
}
.view-btn:hover {
  border-color: var(--primary);
}
.view-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ── Timeline-View ── */
.timeline-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border-radius: 6px;
  flex-wrap: wrap;
}
.tl-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tl-leg {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.tl-leg.tl-lv     { background: #e3f2fd; color: #1565c0; }
.tl-leg.tl-arbeit { background: #fff3e0; color: #e65100; }
.tl-leg.tl-sport  { background: #e8f5e9; color: #2e7d32; }
.tl-leg.tl-pruefung { background: #ffebee; color: #c62828; }

.tl-grid {
  position: relative;
  display: grid;
  grid-template-columns: 50px 1fr 1fr;
  gap: 4px;
  background: var(--bg-card);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 12px;
}
.tl-hours {
  position: relative;
}
.tl-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px solid var(--border);
  height: 1px;
}
.tl-hour-label {
  position: absolute;
  left: 0;
  top: -7px;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0 4px;
  font-weight: 500;
}
.tl-col {
  position: relative;
  background: rgba(255,255,255,0.02);
  border-radius: 4px;
}
.tl-col-termine::before {
  content: "📅 Termine";
  position: absolute;
  top: -18px;
  left: 0;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}
.tl-col-bloecke::before {
  content: "📚 Lernblöcke";
  position: absolute;
  top: -18px;
  left: 0;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}
.tl-event, .tl-lernblock {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: 6px;
  padding: 4px 6px;
  overflow: hidden;
  font-size: 11px;
  border-left: 3px solid;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  cursor: pointer;
  transition: transform .1s;
}
.tl-event:hover, .tl-lernblock:hover {
  transform: scale(1.01);
}
.tl-event.tl-lv     { background: #e3f2fd; border-left-color: #1565c0; color: #0d47a1; }
.tl-event.tl-arbeit { background: #fff3e0; border-left-color: #e65100; color: #bf360c; }
.tl-event.tl-sport  { background: #e8f5e9; border-left-color: #2e7d32; color: #1b5e20; }
.tl-event.tl-pruefung { background: #ffebee; border-left-color: #c62828; color: #b71c1c; font-weight: 700; }
.tl-event.tl-urlaub { background: #f3e5f5; border-left-color: #6a1b9a; color: #4a148c; }
.tl-event.tl-privat { background: #eceff1; border-left-color: #455a64; color: #263238; }
.tl-event-time {
  font-size: 9px;
  opacity: 0.8;
  font-weight: 600;
}
.tl-event-title {
  font-weight: 600;
  line-height: 1.2;
  margin-top: 1px;
}
.tl-event-room {
  font-size: 9px;
  opacity: 0.7;
}
.tl-lernblock {
  background: #fff8e1;
  border-left-color: #f9a825;
  color: #6f5300;
}
.tl-lernblock.tl-recall { background: #fff3e0; border-left-color: #e65100; }
.tl-lernblock.tl-endspurt { background: #ffebee; border-left-color: #b71c1c; }
.tl-lernblock.erledigt { opacity: 0.5; text-decoration: line-through; }
.tl-block-head {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  opacity: 0.8;
  font-weight: 600;
}
.tl-block-time { color: var(--text); }
.tl-block-fach { font-weight: 700; }
.tl-block-title {
  font-weight: 600;
  line-height: 1.2;
  margin-top: 1px;
}
.tl-empty-col {
  padding: 12px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.tl-noTime-section {
  margin-top: 12px;
  padding: 10px;
  background: #fff3e0;
  border-radius: 6px;
  border: 1px solid #ffcc80;
}
.tl-noTime-title {
  font-size: 12px;
  font-weight: 700;
  color: #e65100;
  margin-bottom: 6px;
}
.tl-block-noTime {
  display: flex;
  gap: 6px;
  padding: 5px 8px;
  margin-bottom: 4px;
  background: var(--surface);
  border-left: 3px solid;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.tl-block-noTime:hover { background: var(--bg-card); }

.clickable-event {
  cursor: pointer;
  position: relative;
}
.clickable-event::after {
  content: "↻";
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 9px;
  opacity: 0.6;
}
.clickable-event:hover {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

/* ── Konflikt-Dialog ── */
.konflikt-modal { max-width: 600px; }
.konflikt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}
.konflikt-item {
  padding: 10px 12px;
  background: #fff3e0;
  border-left: 3px solid #ef6c00;
  border-radius: 6px;
}
.konflikt-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.konflikt-emoji { font-size: 16px; }
.konflikt-time {
  font-size: 11px;
  background: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}
.konflikt-detail {
  font-size: 11px;
  color: #6d4c00;
  margin-top: 4px;
}

/* ── Arbeit Alternativen ── */
.arbeit-modal { max-width: 500px; }
.arbeit-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0 12px;
}
@media (max-width: 540px) { .arbeit-actions { grid-template-columns: 1fr; } }
.arbeit-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: all .15s;
}
.arbeit-btn:hover { transform: translateY(-2px); }
.arb-icon { font-size: 24px; }
.arb-label { font-size: 14px; font-weight: 700; }
.arb-desc { font-size: 11px; color: var(--text-muted); line-height: 1.3; }
.arb-lernen:hover { border-color: #fb8c00; background: #fff3e0; }
.arb-erholung:hover { border-color: #2e7d32; background: #e8f5e9; }

/* ── Smart Fallback Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 300;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 540px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: 0 10px 50px rgba(0,0,0,.6);
}
.modal h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--text);
}
.modal h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px;
}
.modal-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 18px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.fallback-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fallback-item {
  background: var(--bg-card);
  border-left: 4px solid #4A90D9;
  border-radius: 8px;
  padding: 12px 14px;
  transition: opacity .25s ease, transform .25s ease;
}
.fallback-item.done {
  opacity: 0.55;
}
.fallback-head {
  margin-bottom: 8px;
}
.fallback-titel {
  font-weight: 600;
  font-size: 15px;
}
.fallback-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.fallback-frage {
  font-size: 13px;
  color: var(--text-muted);
  margin: 8px 0 10px;
  font-style: italic;
}
.fallback-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 600px) {
  .fallback-actions { grid-template-columns: 1fr 1fr 1fr; }
}
.fb-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: all .12s ease;
}
.fb-btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}
.fb-btn .fb-icon {
  font-size: 18px;
  font-weight: 700;
}
.fb-btn .fb-label {
  font-size: 13px;
  font-weight: 600;
}
.fb-btn .fb-desc {
  font-size: 11px;
  color: var(--text-muted);
}
.fb-vergessen:hover { border-color: #43a047; background: #e8f5e9; }
.fb-teilweise:hover { border-color: #fb8c00; background: #fff3e0; }
.fb-verschieben:hover { border-color: #e53935; background: #ffebee; }
.fb-done {
  padding: 10px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}
.sub-modal {
  max-width: 380px;
}
.sub-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sub-actions button {
  padding: 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}
.sub-actions .btn-primary {
  border-color: var(--primary);
}
.sub-actions .btn-secondary {
  color: var(--text-muted);
}
.sub-actions button:hover { background: var(--bg-card); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.dialog {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.dialog-title { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
.dialog-body label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin: 12px 0 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.dialog-body label:first-child { margin-top: 0; }
.dialog-body input[type="text"],
.dialog-body input[type="number"],
.dialog-body input[type="date"],
.dialog-body input[type="time"],
.dialog-body select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--surface2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.dialog-body input[type="color"] {
  width: 60px;
  height: 36px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dialog-body input:focus,
.dialog-body select:focus {
  outline: none;
  border-color: var(--accent);
}
.dialog-body input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
  vertical-align: middle;
}
.dialog-body .grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}
.dialog-actions .action-btn { padding: 10px 18px; font-size: 14px; }

/* ── Add-Buttons inline ── */
.tg-add {
  width: 100%;
  text-align: center;
  background: transparent;
  border: 1px dashed var(--surface2);
  color: var(--text-muted);
  padding: 8px;
  margin-top: 4px;
}
.tg-add:hover { background: var(--surface2); color: var(--text); }

/* ── Wochenansicht ── */
.week-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.woche-day-card {
  margin: 6px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: background .15s;
}
.woche-day-card:hover { background: #1c2a4a; }
.woche-day-card.heute { border: 1px solid var(--accent); }
.woche-day-card.frei { opacity: .6; }

.woche-day-inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
}
.woche-day-label {
  min-width: 38px;
  text-align: center;
  flex-shrink: 0;
}
.woche-day-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
}
.woche-day-num {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.woche-day-card.heute .woche-day-num { color: var(--accent); }
.woche-day-card.frei .woche-day-num { color: var(--text-muted); }

.woche-day-body { flex: 1; min-width: 0; padding-top: 2px; }

.woche-kap-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.woche-kap-bar-bg {
  flex: 1;
  background: var(--surface2);
  border-radius: 3px;
  height: 6px;
  overflow: hidden;
}
.woche-kap-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.woche-kap-text {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 42px;
  text-align: right;
}

.woche-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.woche-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 20px;
  white-space: nowrap;
}
.woche-badge.blocks-offen { background: #4A90D933; color: var(--accent); }
.woche-badge.blocks-done  { background: #2ecc7133; color: var(--success); }
.woche-badge.blocks-wdh   { background: #f39c1233; color: var(--warning); }
.woche-badge.pruefung     { background: #e74c3c33; color: var(--danger); }
.woche-badge.lv           { background: #9b59b633; color: #bb8fe8; }
.woche-badge.arbeit       { background: #7f8c8d33; color: #aab; }
.woche-badge.frei-badge   { background: var(--surface2); color: var(--text-muted); }

/* ── Monatsansicht ── */
.month-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.month-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 0 16px 12px;
  font-size: 11px;
  color: var(--text-muted);
  justify-content: center;
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-swatch {
  width: 12px; height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.legend-swatch.pruefung { background: #e74c3c; }
.legend-swatch.lernen   { background: #2ecc71; }
.legend-swatch.arbeit   { background: #f39c12; }
.legend-swatch.frei     { background: #f39c1255; }

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 8px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 4px;
  font-weight: 600;
  letter-spacing: .5px;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  padding: 0 8px 16px;
}

.month-cell {
  aspect-ratio: 1 / 1.1;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  transition: filter .15s, transform .1s;
  position: relative;
  overflow: hidden;
}
.month-cell:hover { filter: brightness(1.2); }
.month-cell:active { transform: scale(.96); }
.month-cell.outside { opacity: .25; cursor: default; }
.month-cell.outside:hover { filter: none; }
.month-cell.heute { outline: 2px solid var(--accent); outline-offset: -2px; }

.month-cell.frei     { background: #f39c1255; }
.month-cell.arbeit   { background: #f39c12dd; color: #1a1a2e; }
.month-cell.lernen   { background: #2ecc71dd; color: #1a1a2e; }
.month-cell.pruefung { background: #e74c3cdd; color: white; }

.month-cell-num {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 2px;
}
.month-cell-dots {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: auto;
}
.month-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
}
.month-dot.pruefung { background: #e74c3c; }
.month-dot.lernen   { background: #2ecc71; }
.month-dot.arbeit   { background: #f39c12; }
.month-cell.pruefung .month-dot.pruefung,
.month-cell.lernen .month-dot.lernen,
.month-cell.arbeit .month-dot.arbeit { background: rgba(255,255,255,.7); }

/* ── Teilgebiet-Erweiterungen ── */
.tg-row { flex-wrap: wrap; }
.tg-body { flex: 1; min-width: 0; }
.tg-notiz {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tg-stunden {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Statistik-Tab ── */
.stats-summary { padding: 12px 12px 0; }

.stats-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}
@media (max-width: 380px) {
  .stats-tiles { grid-template-columns: repeat(2, 1fr); }
}
.stats-tile {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
}
.stats-tile-val {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}
.stats-tile-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.stats-fach-card {
  margin: 6px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}
.stats-fach-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
}
.stats-fach-name {
  font-weight: 700;
  font-size: 14px;
  min-width: 52px;
}
.stats-fach-bar-wrap {
  flex: 1;
  background: var(--surface2);
  border-radius: 3px;
  height: 6px;
  overflow: hidden;
}
.stats-fach-bar {
  height: 100%;
  border-radius: 3px;
  transition: width .4s;
}
.stats-fach-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  min-width: 32px;
  text-align: right;
}
.stats-fach-meta {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 44px;
  text-align: right;
}
.stats-collapse { font-size: 12px; color: var(--text-muted); transition: transform .2s; }
.stats-fach-card.expanded .stats-collapse { transform: rotate(180deg); }

.stats-tg-list {
  display: none;
  flex-direction: column;
  padding: 0 14px 12px;
  gap: 6px;
}
.stats-fach-card.expanded .stats-tg-list { display: flex; }

.stats-tg-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.stats-tg-info { flex: 1; min-width: 0; }
.stats-tg-title { font-size: 13px; display: block; word-break: break-word; }
.stats-tg-meta { font-size: 11px; color: var(--text-muted); }
.stats-tg-bar-wrap {
  width: 60px;
  background: var(--bg);
  border-radius: 3px;
  height: 5px;
  overflow: hidden;
  flex-shrink: 0;
}
.stats-tg-bar { height: 100%; border-radius: 3px; }
.stats-tg-pct {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 30px;
  text-align: right;
  flex-shrink: 0;
}

/* ── Außerhalb-Planungszeitraum ── */
.woche-day-card.ausserhalb { opacity: .35; cursor: default; pointer-events: none; }
.month-cell.ausserhalb-plan {
  opacity: .45;
  background: var(--surface) !important;
  cursor: default;
}
.month-cell.ausserhalb-plan:hover { filter: none; }

/* ── Wiederholungen-Datumsgruppe (Statistik) ── */
.wdh-date-group { margin: 4px 12px; }
.wdh-date-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--warning);
  padding: 6px 2px 2px;
}

/* ── Responsive Touch ── */
@media (max-width: 400px) {
  .wdh-ratings { gap: 4px; }
  .rating-btn { min-width: 60px; font-size: 12px; }
  .block-card { gap: 8px; padding: 12px; }
  .action-btn { padding: 4px 8px; }
}

/* ── PDF-Upload ── */
.upload-intro { padding: 4px 2px 0; }
.upload-dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 32px 16px; margin: 4px 0 14px;
  border: 2px dashed var(--surface2); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.upload-dropzone:hover, .upload-dropzone.dragging {
  border-color: var(--accent); background: rgba(74,144,217,.08);
}
.upload-dz-icon { font-size: 34px; }
.upload-dz-text { font-size: 14px; font-weight: 600; }
.upload-dz-hint { font-size: 11px; color: var(--text-muted); }
.upload-progress {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  padding: 16px; font-size: 13px; color: var(--text-muted);
  background: var(--surface); border-radius: var(--radius); margin-bottom: 12px;
}
.upload-spinner {
  width: 18px; height: 18px; border: 2px solid var(--surface2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.upload-confirm {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
}
.uc-detected {
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 14px;
}
.uc-detected-title { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.uc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.uc-chip {
  font-size: 11px; padding: 3px 8px; border-radius: 20px;
  background: rgba(74,144,217,.15); color: var(--accent);
}
.uc-chip-ok  { background: #d1f0d5; color: #1c6a2b; }
.uc-chip-off { background: #eee; color: #666; }
.uc-chip-err { background: #fde0e0; color: #8a1e1e; }

/* ── Prüfungssimulation (Phase 5) ── */
.quiz-dialog { max-width: 560px; }
.quiz-dialog .dialog-title { display: flex; justify-content: space-between; align-items: center; }
.quiz-prog { font-size: 12px; color: var(--text-muted); font-weight: normal; }
.quiz-tg { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.3px; }
.quiz-frage { font-size: 15px; line-height: 1.5; padding: 14px; background: rgba(74,144,217,.08); border-left: 3px solid var(--accent); border-radius: 6px; margin-bottom: 12px; }
.quiz-hint { font-size: 12px; color: var(--text-muted); font-style: italic; margin-top: 10px; }
.quiz-actions { flex-wrap: wrap; gap: 6px; }
.quiz-score { font-size: 42px; font-weight: bold; text-align: center; color: var(--accent); margin: 10px 0 20px; }
.quiz-verteilung { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; text-align: center; margin-bottom: 12px; }
.quiz-verteilung > div { font-size: 20px; font-weight: bold; }
.quiz-badge { display: block; font-size: 11px; font-weight: normal; padding: 3px 8px; border-radius: 12px; margin-bottom: 4px; }
.quiz-badge.gut    { background: #d1f0d5; color: #1c6a2b; }
.quiz-badge.halb   { background: #fff4e0; color: #b95000; }
.quiz-badge.wieder { background: #fde0e0; color: #8a1e1e; }
.quiz-note { font-size: 13px; color: var(--text-muted); text-align: center; }
.fach-quiz { font-size: 14px; }
.uc-match { font-size: 11px; color: var(--text-muted); margin-top: 8px; }
.uc-label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); margin: 12px 0 4px; font-weight: 600;
}
.uc-row { display: flex; gap: 8px; }
.uc-input {
  width: 100%; padding: 9px 10px; font-size: 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--surface2); border-radius: var(--radius-sm);
}
.uc-input:focus { outline: none; border-color: var(--accent); }
.uc-grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 4px; }
.uc-actions { display: flex; gap: 8px; margin-top: 18px; }
.uc-actions .btn-primary { flex: 1; }
.upload-done {
  background: var(--surface); border-left: 3px solid var(--success);
  border-radius: var(--radius-sm); padding: 14px 16px; font-size: 14px; line-height: 1.6;
}
.upload-done .btn-secondary { margin-top: 8px; }
