/* =========================================================================
   Noten-Fritze – Styles
   Tablet-first, optimiert für iPad im Querformat. Große Touch-Ziele,
   ruhige Farben, klare Kontraste.
   ========================================================================= */

:root {
  /* Farben */
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef1f0;
  --line: #dce2e0;
  --text: #1f2a27;
  --text-muted: #6b7a75;
  --accent: #2f6f5e;
  --accent-dark: #245546;
  --accent-soft: #e3efeb;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --warn: #b9770e;
  --ok: #2e7d32;

  /* Spaltengruppen der Notenübersicht (Zellen / Kopfzeile / Sammelspalte) */
  --grp-schriftlich: #eef3fa;
  --grp-schriftlich-kopf: #e3ecf7;
  --grp-schriftlich-stark: #d9e6f5;
  --grp-sonstige: #fdf5e9;
  --grp-sonstige-kopf: #f9ecd8;
  --grp-sonstige-stark: #f5e5c6;
  --grp-zeugnis: #eaf3ef;
  --grp-zeugnis-kopf: #ddece5;
  --grp-zeugnis-stark: #d2e6dc;

  /* Maße */
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 52px;              /* Mindest-Touch-Ziel */
  --gap: 16px;
  --shadow: 0 2px 10px rgba(31, 42, 39, 0.08);
  --shadow-lg: 0 10px 40px rgba(31, 42, 39, 0.20);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  min-height: 64px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; }
.topbar .sub { color: var(--text-muted); font-size: 14px; }
.topbar .grow { flex: 1; }
.topbar .title-wrap { display: flex; flex-direction: column; min-width: 0; }
.topbar .title-wrap .main { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Content ---------- */
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--gap) calc(var(--gap) + var(--safe-right)) calc(var(--gap) + var(--safe-bottom)) calc(var(--gap) + var(--safe-left));
}
.container { max-width: 1180px; margin: 0 auto; }
.container.container-wide { max-width: 1560px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: transform .04s ease, background .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-dark); }
.btn.danger { background: var(--danger-soft); border-color: #f0c8c2; color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn.icon { min-width: var(--tap); padding: 0 12px; font-size: 20px; }
.btn:disabled { opacity: .45; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
a.btn { text-decoration: none; color: inherit; } /* Link im Knopf-Stil (z. B. Infoseite) */

.iconbtn {
  width: var(--tap); height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); font-size: 22px; cursor: pointer;
}
.iconbtn:active { transform: scale(0.95); }
.iconbtn.plain { border-color: transparent; background: transparent; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: var(--gap); }
.card h2 { margin: 0 0 4px; font-size: 18px; }
.card .muted { color: var(--text-muted); font-size: 14px; }

.grid { display: grid; gap: var(--gap); }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Klassenkarte */
.class-card { cursor: pointer; position: relative; display: flex; flex-direction: column; gap: 8px; }
.class-card .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.class-card .name { font-size: 20px; font-weight: 700; }
.class-card .foot { display: flex; justify-content: space-between; align-items: center; color: var(--text-muted); font-size: 13px; }
.class-card .stale-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
/* Löschen-Button oben rechts auf der Karte (Delegation greift ihn vor dem
   Karten-Klick über closest). */
.class-card .card-del { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; font-size: 18px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted);
  font-size: 13px; font-weight: 600;
}
.chip.accent { background: var(--accent-soft); color: var(--accent-dark); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: var(--gap); }
.tab {
  min-height: 46px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; white-space: nowrap; cursor: pointer;
}
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); }
/* Abgeschlossenes Quartal im Mitarbeit-Tab: nur noch zum Nachschauen.
   Bewusst ohne pointer-events: none, damit die Herleitung antippbar bleibt. */
.table-wrap.gesperrt { opacity: .55; filter: grayscale(1); }
/* Hinweisleiste über einer gesperrten Ansicht */
.hint-box {
  margin: 0 0 var(--gap); padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-muted); font-size: 15px;
}
.hint-box strong { color: var(--text); }
/* Startseite: nicht beendete Stunden, je Klasse eine Zeile */
.offen-zeile { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.offen-zeile + .offen-zeile { margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--surface-2); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-hover:active { background: var(--accent-soft); }
/* Sammelspalten der Notenübersicht: Trennlinie am Gruppenanfang.
   Die Flächenfarbe kommt aus den Gruppenklassen weiter unten. */
td.summe, th.summe { border-left: 2px solid var(--line); }

/* Spaltengruppen der Notenübersicht: schriftliche Leistungen, sonstige
   Leistungen und Zeugnis (Gesamt + Zeugnisnote). `summe-stark` markiert die
   Ergebnisspalte am Ende einer Gruppe und wird kräftiger getönt. */
th.grp-schriftlich { background: var(--grp-schriftlich-kopf); }
tbody td.grp-schriftlich { background: var(--grp-schriftlich); }
th.grp-schriftlich.summe-stark { background: var(--grp-schriftlich-stark); }
tbody td.grp-schriftlich.summe-stark { background: var(--grp-schriftlich-stark); }
th.grp-sonstige { background: var(--grp-sonstige-kopf); }
tbody td.grp-sonstige { background: var(--grp-sonstige); }
th.grp-sonstige.summe-stark { background: var(--grp-sonstige-stark); }
tbody td.grp-sonstige.summe-stark { background: var(--grp-sonstige-stark); }
th.grp-zeugnis { background: var(--grp-zeugnis-kopf); }
tbody td.grp-zeugnis { background: var(--grp-zeugnis); }
th.grp-zeugnis.summe-stark { background: var(--grp-zeugnis-stark); }
tbody td.grp-zeugnis.summe-stark { background: var(--grp-zeugnis-stark); }

/* Notenübersicht: Namensspalte beim Querscrollen stehen lassen.
   Der Hintergrund muss deckend sein, sonst scheinen die Notenspalten durch;
   die Kante als box-shadow, weil ein border-right mitscrollen würde. */
.noten-tab th:first-child, .noten-tab td:first-child {
  position: sticky; left: 0;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
}
.noten-tab thead th { z-index: 1; }
.noten-tab tbody td:first-child { z-index: 2; }
.noten-tab thead th:first-child { z-index: 3; background: var(--surface-2); }

/* Leerraum rechts neben der Tabelle (Breite kommt aus --rand, gesetzt beim
   Mount): erlaubt, weiter zu scrollen, bis auch die letzten Spalten direkt
   neben der Namensspalte stehen. */
.noten-wrap { display: flex; }
.noten-wrap > .noten-tab { flex: 0 0 auto; width: auto; min-width: 100%; }
.noten-wrap > .noten-rand { flex: 0 0 auto; width: var(--rand, 0px); }

/* Spalten per Ziehen am Kopf umsortieren. `touch-action: none` gibt alle Gesten
   ab dem Kopf komplett an das JS (iOS übernimmt sonst per pointercancel/Scroll);
   vertikales Scrollen bleibt über den Tabellenkörper möglich. */
/* Noteneingabe direkt in der Zelle (Excel-artig): die Zelle ist Tap-Ziel und
   wird beim Bearbeiten durch ein Eingabefeld ersetzt. Das Feld füllt die Zelle
   komplett, damit die Spaltenbreite beim Wechsel nicht springt. */
.noten-tab td.zelle { cursor: text; }
.noten-tab td.zelle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.noten-tab td.zelle.editiert { padding: 0; }
.noten-tab .zelle-input {
  width: 100%; min-width: 48px; box-sizing: border-box;
  /* Bewusst flacher als normale Formularfelder (kein var(--tap)): Das Feld
     sitzt in einer Tabellenzelle, die Zeilenhöhe soll beim Wechsel nicht
     springen. */
  min-height: 0; height: 34px; line-height: 34px;
  padding: 0 4px; margin: 0;
  border: 2px solid var(--accent); border-radius: 0;
  font: inherit; font-size: 15px; text-align: center; background: var(--surface);
}

/* Nummernpad an der Zelle: Noteneingabe per Fingertipp, ohne dass auf dem iPad
   die Bildschirmtastatur aufgeht (das Eingabefeld trägt inputmode="none").
   Liegt im body mit position:fixed, damit es nicht vom Tabellen-Scroll
   abgeschnitten wird; über der Tabelle, aber unter Modal (100) und Toast (200). */
.notenpad {
  position: fixed; z-index: 60; padding: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0, 0, 0, .2);
}
.notenpad .pad-grid { display: grid; grid-template-columns: repeat(3, 58px); gap: 6px; }
.notenpad.mss .pad-grid { grid-template-columns: repeat(4, 52px); }
.notenpad .pad-btn {
  min-height: var(--tap); padding: 0;
  font: inherit; font-size: 17px; font-weight: 600;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.notenpad .pad-btn:active { background: var(--accent-soft); border-color: var(--accent); }
.notenpad .pad-fuss { display: flex; gap: 6px; margin-top: 6px; }
.notenpad .pad-fuss .pad-btn { flex: 1; font-size: 15px; font-weight: 500; }
.notenpad .pad-btn.fertig { background: var(--accent); border-color: var(--accent); color: #fff; }

.noten-tab th.zieh { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.noten-tab.spalten-ziehen { user-select: none; -webkit-user-select: none; }
.noten-tab.spalten-ziehen th.zieh { cursor: grabbing; }
.noten-tab th.zieht { opacity: .45; }
.noten-tab .ziel-vor { box-shadow: inset 3px 0 0 var(--accent); }
.noten-tab .ziel-nach { box-shadow: inset -3px 0 0 var(--accent); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 14px; font-weight: 600; color: var(--text-muted); }
input, select, textarea {
  font: inherit; color: var(--text);
  min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 160px; }

/* Stundenzeiten (Einstellungen): Stunden und Pausen als Zeilen, zeitlich sortiert */
.sz-liste { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.sz-zeile {
  display: grid; grid-template-columns: minmax(110px, 1fr) auto auto auto 44px;
  align-items: center; gap: 8px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.sz-zeile.pause { background: var(--surface-2); }
.sz-zeile input[type="time"] { width: 110px; min-height: 44px; padding: 6px; text-align: center; }
.sz-zeile input.sz-name { min-height: 44px; min-width: 0; }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { flex: 1; min-height: var(--tap); border: none; background: var(--surface); font-weight: 600; cursor: pointer; }
.seg button.active { background: var(--accent); color: #fff; }

.hint { font-size: 13px; color: var(--text-muted); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20,28,26,.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; padding: 0;
}
.modal {
  background: var(--surface);
  width: 100%; max-width: 560px;
  border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg);
  max-height: 92vh; overflow-y: auto;
  padding: 22px calc(22px + var(--safe-right)) calc(22px + var(--safe-bottom)) calc(22px + var(--safe-left));
  animation: sheet-up .18s ease;
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal h2 { margin: 0 0 16px; }
.modal .actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
/* Breite nach Beschriftung: passen nicht alle Knöpfe in eine Zeile, brechen sie um */
.modal .actions .btn { flex: 1 1 auto; }
/* Rückgängig im Tracker: langes Drücken ohne Textauswahl/Kontextmenü (iOS) */
#undo-btn { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* Liste „Einträge dieser Stunde" */
.undo-liste { max-height: 55vh; overflow-y: auto; }
.undo-zeile { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.undo-zeile .nm { font-weight: 600; }
/* Sitzregeln: Liste mit ✕ je Regel, darunter „Neue Regel“ */
.regel-liste { max-height: 40vh; overflow-y: auto; }
.regel-zeile { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.regel-warn { font-size: 13px; color: #b45309; white-space: nowrap; }
.regel-neu { margin-top: 16px; }
.regel-neu h3 { margin: 0 0 8px; font-size: 16px; }
.regel-neu .form-row .field { flex: 1 1 200px; }
@media (min-width: 700px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 20px; }
}

/* ---------- Toast ---------- */
.toast-root { position: fixed; left: 0; right: 0; bottom: calc(20px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; }
.toast {
  background: #263832; color: #fff; padding: 12px 18px; border-radius: 12px;
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 14px;
  pointer-events: auto; font-weight: 600; max-width: 90vw;
}
.toast .undo { color: #9fe6cf; font-weight: 700; cursor: pointer; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
/* Link zur Infoseite unten auf der Startseite */
/* ---------- Stundenplan (Startseite) ---------- */
.home-tabs { margin: 0 0 0 12px; padding: 0; align-self: center; }
.sp-wochenkopf { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.sp-wochentitel { font-size: 17px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sp-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: var(--gap); align-items: start; }
@media (max-width: 900px) { .sp-layout { grid-template-columns: 1fr; } }
.sp-tabelle { table-layout: fixed; }
.sp-tabelle th, .sp-tabelle td { padding: 6px; white-space: normal; vertical-align: top; border-left: 1px solid var(--line); }
.sp-tabelle th { text-transform: none; letter-spacing: 0; }
.sp-tabelle thead th { font-size: 14px; color: var(--text); text-align: center; }
.sp-tabelle thead th:first-child, .sp-tabelle th.sp-zeit { width: 86px; border-left: none; }
.sp-tabelle th.heute, .sp-tabelle td.heute { background: var(--accent-soft); }
.sp-tabelle th.sp-zeit { position: static; background: var(--surface-2); font-size: 13px; color: var(--text); }
.sp-tabelle th.sp-zeit .muted { display: block; font-size: 12px; font-weight: 400; }
.sp-zelle { height: 58px; }
.sp-zelle[data-action] { cursor: pointer; }
.sp-zelle.jetzt { box-shadow: inset 0 0 0 3px var(--accent); }
.sp-tabelle.bearbeiten .sp-zelle:empty::after { content: "＋"; display: block; text-align: center; color: var(--line); font-size: 20px; padding-top: 10px; }
.sp-tabelle tr.pause .sp-zelle { height: 36px; background-image: repeating-linear-gradient(135deg, transparent 0 8px, rgba(0,0,0,.025) 8px 16px); }
.sp-tabelle tr.pause th.sp-zeit { font-weight: 400; }
.sp-eintrag {
  position: relative; border-radius: 8px; padding: 5px 7px; margin-bottom: 4px;
  background: var(--surface-2); font-size: 14px; line-height: 1.25; overflow: hidden;
}
.sp-eintrag:last-child { margin-bottom: 0; }
.sp-eintrag .nm { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.sp-eintrag .fach { display: block; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-eintrag.frei { background: transparent; border: 1px dashed var(--line); color: var(--text-muted); }
.sp-eintrag.frei .nm { font-weight: 600; }
.sp-ab { float: right; font-size: 11px; font-weight: 700; background: var(--text); color: #fff; border-radius: 6px; padding: 0 5px; margin-left: 4px; }
.sp-notiz h3 { margin: 0 0 8px; font-size: 16px; }
.sp-notiz textarea { width: 100%; min-height: 220px; }
.sp-modus { margin-bottom: 12px; }
.sp-slot { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.sp-slot h4 { margin: 4px 0 0; }
.sp-slot select, .sp-slot input { width: 100%; }
/* Kalender: tatsächlicher Tag (Ferien, Änderungen, Termine) */
.sp-ansicht { margin: 0; padding: 0; }
.sp-tabelle th.frei, .sp-tabelle td.frei { background: #eef3ea; }
.sp-frei-name { display: block; font-size: 12px; font-weight: 600; color: #4d6b45; }
.sp-tabelle tr.ganztags td { height: auto; }
.sp-eintrag.weg { opacity: .6; }
.sp-eintrag.weg .nm { text-decoration: line-through; }
.sp-eintrag.hergeschoben { box-shadow: inset 3px 0 0 var(--accent); }
.sp-vermerk { display: block; font-size: 12px; color: var(--text); opacity: .8; }
.sp-termin {
  border-radius: 8px; padding: 3px 7px; margin-top: 4px; font-size: 13px; font-weight: 600;
  line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid rgba(0, 0, 0, .08);
}
.sp-termin:first-child { margin-top: 0; }
[data-action="termin-bearbeiten"] { cursor: pointer; }
.sp-seite { display: flex; flex-direction: column; gap: var(--gap); }
.sp-naechste h3 { margin: 0 0 8px; font-size: 16px; }
.sp-naechster { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.sp-naechster:last-child { border-bottom: none; }
.menue { display: flex; flex-direction: column; gap: 8px; }
.menue h4 { margin: 8px 0 0; }
.menue hr { border: none; border-top: 1px solid var(--line); margin: 6px 0 0; }
.menue-knopf { width: 100%; justify-content: flex-start; }
/* Monatsansicht */
.mo-tabelle { table-layout: fixed; }
.mo-tabelle th { text-transform: none; letter-spacing: 0; text-align: center; font-size: 14px; color: var(--text); }
.mo-tabelle th.we { width: 9%; }
.mo-tag { height: 96px; vertical-align: top; padding: 6px; white-space: normal; border-left: 1px solid var(--line); cursor: pointer; }
.mo-tag.anders { opacity: .45; }
.mo-tag.we { background: var(--surface-2); }
.mo-tag.frei { background: #eef3ea; }
.mo-tag.heute { box-shadow: inset 0 0 0 3px var(--accent); }
.mo-nr { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.mo-frei { font-size: 12px; font-weight: 600; color: #4d6b45; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Langes Drücken auf eine Stunde: kein Text-Markieren / iOS-Menü */
.sp-tabelle .sp-zelle[data-datum] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.sp-thema { display: block; font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Stundenplanung (Fahrplan) */
.pl-kopfzeile { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pl-kopfzeile #pl-thema { flex: 1; min-width: 220px; font-size: 18px; font-weight: 600; }
.pl-summe { font-size: 14px; color: var(--text-muted); white-space: nowrap; }
.pl-summe.zuviel { color: var(--danger); font-weight: 700; }
.pl-ha { background: #fdf5e9; }
.pl-liste { display: flex; flex-direction: column; gap: 10px; margin: var(--gap) 0; }
.pl-baustein { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.pl-baustein.link { border-left: 4px solid var(--accent); }
.pl-baustein.zieht, .pl-trenner.zieht { opacity: .7; box-shadow: var(--shadow-lg); }
.pl-zeile { display: flex; align-items: center; gap: 8px; }
.pl-griff { font-size: 22px; line-height: 1; padding: 8px 6px; cursor: grab; color: var(--text-muted); touch-action: none; -webkit-user-select: none; user-select: none; }
.pl-phase { width: 170px; }
.pl-min { width: 80px; }
.pl-baustein textarea { width: 100%; min-height: 0; }
.pl-baustein.datei { border-left: 4px solid #b9770e; }
.pl-datei { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pl-datei-pin.aktiv { background: var(--accent-soft); border-color: var(--accent); }
.pl-entfernt { color: var(--text-muted); font-size: 13px; }
.pl-link { display: flex; gap: 8px; align-items: center; }
.pl-link input { flex: 1; }
.pl-trenner { display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text-muted); font-weight: 600; font-size: 14px; }
.pl-trenner.fest { padding-left: 14px; }
.pl-stundensumme { margin-left: auto; font-weight: 400; }
.pl-leer { text-align: center; }
.pl-klassenpunkt { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.pl-lesenliste { display: flex; flex-direction: column; gap: 10px; }
.pl-lesen { border-left: 3px solid var(--accent); padding-left: 10px; }
.pl-text { white-space: pre-wrap; }
/* Farbwahl im Klassen-Dialog */
.farbwahl { display: flex; flex-wrap: wrap; gap: 8px; }
.farbwahl .farbe { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .1); cursor: pointer; }
.farbwahl .farbe.aktiv { border: 3px solid var(--text); }
.home-info { text-align: center; margin: 32px 0 8px; font-size: 15px; }
.home-info a { color: var(--text-muted); }
.empty .big { font-size: 44px; margin-bottom: 8px; }

/* ---------- Noten-Übersicht ---------- */
.note-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 40px; padding: 0 8px; border-radius: 10px;
  font-weight: 700; font-variant-numeric: tabular-nums; color: #fff;
}
.note-badge.tappable { border: none; font-family: inherit; font-size: 17px; cursor: pointer; }
.grade-cell { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.grade-pill {
  min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px dashed var(--line);
  background: var(--surface-2); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.grade-pill.add { border-style: dashed; color: var(--accent); background: var(--accent-soft); }

/* ---------- Sitzplan / Tracker ---------- */
.plan-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: var(--gap); }
/* Auswahl des Sitzplans (Raum) im Reiter Sitzplan */
.sitzplan-tabs { margin-bottom: 0; padding-bottom: 0; max-width: 100%; }
/* Sitzplan-Raster: Die Kacheln teilen sich die Breite. Hat der Plan mehr Spalten
   als in den Einstellungen erlaubt („breit“), bleibt jede Kachel so breit wie
   bei --sichtbar Spalten und der Rahmen .seatgrid-scroll scrollt seitlich. */
.seatgrid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.seatgrid {
  --gap: 12px; --kachel-min: 0px;
  display: grid; gap: var(--gap);
  grid-template-columns: repeat(var(--cols, 6), minmax(var(--kachel-min), 1fr));
  align-items: stretch;
}
.seatgrid.breit { --kachel-min: calc((100% - (var(--sichtbar) - 1) * var(--gap)) / var(--sichtbar)); }
.seat {
  position: relative;
  min-height: 84px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px; cursor: pointer; text-align: center; user-select: none;
  transition: transform .05s ease;
}
.seat:active { transform: scale(0.96); }
.seat.empty { border-style: dashed; color: var(--text-muted); background: var(--surface-2); }
/* Stelle ohne Platz (Gang): hält die Rasterform, ist aber unsichtbar – beim
   „Raum gestalten“ als blasser Umriss, damit man sie wieder antippen kann */
.seat.keinplatz { visibility: hidden; }
.seatgrid.gestalten .seat.keinplatz {
  visibility: visible; border-style: dotted; background: transparent;
  color: var(--text-muted); font-size: 13px; opacity: .6;
}
.seatgrid.gestalten .seat:not(.keinplatz) { border-color: var(--accent); }
.gestalten-leiste { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); }
/* Tafel: flache Leiste unter der vordersten Reihe (vorne = unten) */
.seatgrid .tafel { grid-column: 1 / -1; display: flex; justify-content: center; }
.seatgrid .tafel span {
  width: 50%; min-width: 120px; height: 16px; border-radius: 4px;
  background: #2f4a3f; color: #e7efe9; font-size: 10px; line-height: 16px;
  text-align: center; letter-spacing: .2em; text-transform: uppercase;
}
.seat .nm { font-weight: 700; font-size: 16px; line-height: 1.15; }
.seat .sub { font-size: 12px; color: var(--text-muted); }
.seat .count {
  position: absolute; top: -8px; right: -8px;
  min-width: 26px; height: 26px; padding: 0 6px;
  background: var(--accent); color: #fff; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; box-shadow: var(--shadow);
}
.seat.heat { color: #14231f; }
/* Abwesende Schüler: ausgegraut, Ereignis-Buttons deaktiviert */
.seat.abwesend { opacity: .5; filter: grayscale(.8); }
.seat .abw-btn { position: absolute; top: 2px; right: 2px; min-height: 28px; padding: 0 6px; z-index: 1; }
.seat .abw-btn.aktiv { outline: 2px solid var(--accent); }
.typebtn[disabled] { opacity: .45; pointer-events: none; }
.seat .flash { position: absolute; inset: 0; border-radius: inherit; background: #fff; opacity: 0; }
.seat.pulse .flash { animation: flash .4s ease; }
@keyframes flash { from { opacity: .55; } to { opacity: 0; } }

/* Legende Heatmap */
.legend { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.legend .bar { width: 120px; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #2e7d32, #d4b106, #c62828); }
/* Pausetaste der Heatmap: klein wie die Legende, in der Pause farbig, damit sie nicht vergessen wird */
.legend .heatpause { min-height: 30px; padding: 0 12px; font-size: 13px; border-radius: 999px; margin: -6px 6px -6px 0; }
.heatpause.aktiv { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Tracker Ereignis-Auswahl */
.evtbar { display: flex; gap: 8px; flex-wrap: wrap; }
.evtbar .evt {
  min-height: var(--tap); padding: 0 16px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.evtbar .evt.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.evtbar .evt .dot { width: 12px; height: 12px; border-radius: 50%; }

/* Tracker: Kacheln mit Ereignis-Buttons direkt je Schüler/in */
.tracker-toolbar { align-items: flex-start; }
.tracker-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.tracker-legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.tracker-legend .dot { width: 12px; height: 12px; border-radius: 50%; }

.seatgrid.tracker-grid { width: 100%; }

.seat.tracker { min-height: 132px; justify-content: flex-start; align-items: stretch; gap: 8px; padding: 10px; cursor: default; }
.seat.tracker.empty { justify-content: center; align-items: center; }
.seat .seat-head { display: flex; align-items: baseline; gap: 8px; width: 100%; }
.seat .seat-head .nm {
  font-weight: 700; font-size: 15px; line-height: 1.15;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seat .seat-head .tcount-total {
  margin-left: auto; flex: none; font-weight: 800; font-size: 13px; color: #14231f;
  background: rgba(255, 255, 255, .78); border-radius: 999px; padding: 1px 8px;
}

.typebtns { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-top: auto; }
.typebtn {
  position: relative; min-height: 46px; border-radius: 10px;
  border: 2px solid var(--c); background: #fff; color: var(--c);
  font-weight: 800; font-size: 12px; cursor: pointer; line-height: 1.05;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 2px 4px;
}
.typebtn:active { transform: scale(0.92); }
.typebtn .tlabel { pointer-events: none; }
.typebtn .tcount {
  position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--c); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; line-height: 1; box-shadow: var(--shadow);
}
.typebtn .tcount:empty { display: none; }
.typebtn.pulse { animation: btnpulse .45s ease; }
@keyframes btnpulse { 0% { background: var(--c); color: #fff; } 100% { background: #fff; color: var(--c); } }
/* Vermerk „keine HA“ neben dem Namen (gilt für die laufende Stunde) */
.tag-ha {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--warn); color: #fff; font-size: 11px; font-weight: 800;
  vertical-align: middle;
}
/* Vermerk „Verweigerung“ neben dem Namen (Stunde zählt als Note 6) */
.tag-verweigerung {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: #4a148c; color: #fff; font-size: 11px; font-weight: 800;
  vertical-align: middle;
}

/* ---------- Tracker-Modi (Abwesend / Verweigerung / keine HA / Heatmap) ---------- */
/* Ein aktiver Modus färbt Topbar und Seite um, damit der Wechsel des
   Tippverhaltens sofort erkennbar ist. Die ganze Kachel wird zum Tap-Ziel. */
.modusbar { display: flex; gap: 8px; }
.modusbtn { min-height: 44px; padding: 0 14px; font-size: 15px; }
.modusbtn.aktiv {
  background: var(--modus-color, var(--accent));
  border-color: var(--modus-color, var(--accent));
  color: #fff;
}

.modus-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: var(--gap);
  border-radius: var(--radius);
  border: 2px solid var(--modus-color, var(--accent));
  background: var(--modus-soft, var(--accent-soft));
}
.modus-banner .modus-icon { font-size: 26px; }
.modus-banner .grow { flex: 1; min-width: 0; }
.modus-banner .hint { color: var(--text); opacity: .8; }

body.modus-abwesend { --modus-color: #c0392b; --modus-soft: #fbe9e7; }
body.modus-verweigerung { --modus-color: #4a148c; --modus-soft: #f3e5f5; }
body.modus-keineha  { --modus-color: #b9770e; --modus-soft: #fdf1de; }
body.modus-heat     { --modus-color: #1565c0; --modus-soft: #e3edfa; }
body.modus-abwesend, body.modus-verweigerung, body.modus-keineha, body.modus-heat { background: var(--modus-soft); }
body.modus-abwesend .content, body.modus-verweigerung .content, body.modus-keineha .content, body.modus-heat .content { background: var(--modus-soft); }
body.modus-abwesend .topbar, body.modus-verweigerung .topbar, body.modus-keineha .topbar, body.modus-heat .topbar {
  background: var(--modus-soft);
  border-bottom: 3px solid var(--modus-color);
}

.seat.tracker.modus { cursor: pointer; outline: 2px dashed var(--modus-color); outline-offset: -4px; }
/* Im Modus zählt der Tap auf die ganze Kachel – die Typ-Buttons reichen ihn durch */
.seat.tracker.modus .typebtn { opacity: .3; pointer-events: none; }

/* Kompakte Kacheln für große Sitzpläne: ab 7 sichtbaren Spalten „kompakt“, ab 9 „mini“,
   damit z. B. ein 4×9-Raster auf ein iPad-Querformat passt. */
.tracker-grid.kompakt { --gap: 8px; }
.tracker-grid.mini { --gap: 6px; }
.tracker-grid.kompakt .seat.tracker { min-height: 96px; padding: 8px; gap: 6px; }
.tracker-grid.mini .seat.tracker { min-height: 72px; padding: 6px; gap: 4px; }
.tracker-grid.kompakt .seat .seat-head .nm { font-size: 13px; }
.tracker-grid.mini .seat .seat-head .nm { font-size: 12px; }
.tracker-grid.kompakt .typebtns { gap: 4px; }
.tracker-grid.mini .typebtns { gap: 3px; }
.tracker-grid.kompakt .typebtn { min-height: 34px; font-size: 13px; line-height: 1; border-radius: 8px; }
.tracker-grid.mini .typebtn { min-height: 28px; font-size: 12px; line-height: 1; border-radius: 6px; }
.tracker-grid.kompakt .typebtn .tcount { min-width: 16px; height: 16px; font-size: 9px; padding: 0 4px; top: -6px; right: -6px; }
.tracker-grid.mini .typebtn .tcount { min-width: 14px; height: 14px; font-size: 9px; padding: 0 3px; top: -5px; right: -5px; }
/* In „mini“ entfällt der Σ-Badge, er kostet zu viel Platz */
.tracker-grid.mini .tcount-total { display: none; }

/* ---------- Besprechungsmodus ---------- */
.discussion { max-width: 680px; margin: 0 auto; }
.disc-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: var(--gap); }
.disc-nav .who { font-size: 24px; font-weight: 800; text-align: center; flex: 1; }
.big-grade { font-size: 64px; font-weight: 800; text-align: center; line-height: 1; margin: 10px 0; }
.disc-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 10px; }
.disc-picker .btn { justify-content: flex-start; }
/* Raumwahl im Tracker: ein Knopf je Sitzplan über die volle Breite, damit lange Namen passen */
.raum-picker { display: flex; flex-direction: column; gap: 10px; }
.raum-picker .btn { width: 100%; justify-content: flex-start; white-space: normal; text-align: left; }

/* Breakdown */
.breakdown .grp { margin-top: 14px; }
.breakdown .grp h3 { margin: 0 0 8px; font-size: 15px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.breakdown .line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.breakdown .line .r { font-variant-numeric: tabular-nums; font-weight: 700; }
.breakdown .total { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--line); font-size: 20px; font-weight: 800; }

/* Utility */
.muted { color: var(--text-muted); }
.right { text-align: right; }
.center { text-align: center; }
.spacer { height: 12px; }
.hstack { display: flex; align-items: center; gap: 10px; }
.hstack.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.danger-text { color: var(--danger); }
.pointer { cursor: pointer; }
.hidden { display: none !important; }

/* Drag & Sortier-Hilfe */
.dragging { opacity: .5; }
.drop-target { outline: 2px dashed var(--accent); }
