/* sitzplan.jetzt – schlichtes, helles Design für Handy, Tablet und Computer (CI: docs/ci.md) */

/* Schriften selbst gehostet (OFL, keine fremden Server): Figtree für Überschriften/Buttons, Atkinson Hyperlegible für Text */
@font-face {
  font-family: "Figtree";
  src: url("./fonts/figtree-var.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("./fonts/atkinson-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("./fonts/atkinson-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #FAF7F0;          /* Papier */
  --surface: #ffffff;
  --text: #1E2A32;        /* Schiefer */
  --muted: #55646D;       /* Grau */
  --line: #DCE3E7;
  --primary: #1F5E7A;     /* Tinte */
  --primary-dark: #163F52;
  --primary-light: #E6F0F4;
  --accent: #F2C14E;      /* Kreide */
  --accent-light: #FBEFD0;
  --danger: #B5462F;
  --font-text: "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Figtree", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --red: #e5534b;
  --yellow: #f2c94c;
  --green: #43a26b;
  --green-text: #2B7A4E; /* Grün für Text: 4,9:1 auf Papier (AA) */
  --placeholder: #626F7A; /* Platzhalter/leichte Icons: ≥ 4,5:1 */
  --empty: #eef1f4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 2px 8px rgba(16, 24, 32, .06);
  /* Tischgröße – wird auch von app.js für Platzierung/Drag gelesen */
  --desk-w: 132px;
  --desk-h: 134px;
  /* Sichere Ränder (Notch, Home-Indicator, Querformat) */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  font-family: var(--font-text);
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }

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

body {
  /* Kein Markieren / kein Long-Press-Menü – außer in Eingabefeldern */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  font: inherit;
  font-size: 16px; /* verhindert Auto-Zoom auf iOS */
}

button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
h1, h2, .title, .btn { font-family: var(--font-head); }

/* Safe-Area: Kopfzeile, Fußzeile und Inhalt rücken selbst ein (Hintergründe reichen bis an den Rand) */
#app {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Kopfzeile ---------- */
.bar {
  display: flex;
  flex-wrap: wrap; /* reicht der Platz nicht, rutschen die Aktionen in eine zweite Zeile */
  align-items: center;
  gap: 8px 12px;
  padding: calc(10px + var(--sat)) calc(16px + var(--sar)) 10px calc(16px + var(--sal));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.title {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  flex: 1 1 7em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.title-btn {
  background: none;
  border: 0;
  text-align: left;
  padding: 8px 6px;
  border-radius: 8px;
  min-height: 44px;
}
.title-btn:hover { background: var(--bg); }
.title-btn::after { content: " ✎"; color: var(--muted); font-size: 16px; font-weight: 400; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; flex: 0 1 auto; min-width: 0; margin-left: auto; }

/* ---------- Buttons ---------- */
.btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  min-width: 44px; /* Tippfläche mind. 44 × 44 */
}
.btn:hover { background: #f7f9fa; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.small { min-height: 44px; padding: 0 12px; font-size: 15px; }

/* ---------- Klassenliste ---------- */
.list-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 20px calc(16px + var(--sar)) 20px calc(16px + var(--sal));
}
.list-main:last-child { padding-bottom: calc(20px + var(--sab)); } /* ohne Fußzeile (Admin) */
.class-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 16px;
}
.class-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.class-card:hover { border-color: #c5ced6; }
.class-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.class-card-name { font-size: 20px; font-weight: 650; overflow-wrap: anywhere; }
.class-card-meta { color: var(--muted); font-size: 15px; }
.class-card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.empty { color: var(--muted); text-align: center; margin-top: 15vh; font-size: 18px; }
.privacy {
  flex: none;
  padding: 8px calc(16px + var(--sar)) calc(8px + var(--sab)) calc(16px + var(--sal));
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* ---------- Sitzplan / Raum ---------- */
.room {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px calc(8px + var(--sar)) 0 calc(8px + var(--sal));
  gap: 6px;
}
/* Raumansicht: Ausschnitt scrollt; Pinch/Pan/Strg+Rad setzt app.js um, deshalb touch-action nur hier none */
.plan-canvas {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: none;
  background: var(--bg); /* wie .floor: Rest über/neben der Leinwand wirkt nicht wie eine leere Leiste */
  border-radius: var(--radius);
}
.plan-stage { position: relative; overflow: hidden; }
/* Logische Leinwand (feste Größe, per scale() gezoomt) */
.floor {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  background: var(--bg);
  border-radius: var(--radius);
}
.desk-area { position: absolute; }
.row-heads { position: absolute; left: 0; width: 32px; }
.row-heads .row-head {
  position: absolute;
  left: 4px;
  width: 28px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  writing-mode: vertical-rl;
  transform: rotate(180deg); /* von unten nach oben lesen */
}
.row-heads .row-head[aria-expanded="false"] { background: var(--empty); color: var(--text); }

/* Unten: Tafel/Pult-Leiste und Daumenleiste */
.plan-foot { flex: none; display: flex; flex-direction: column; gap: 6px; padding-bottom: calc(8px + var(--sab)); }
.board {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  min-height: 44px;
  background: #dfe5ea;
  border-radius: 8px;
}
.board-label {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 14px;
  letter-spacing: .04em;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board .btn { background: transparent; border-color: transparent; flex-shrink: 0; }
.board .btn:hover { background: rgba(255, 255, 255, .6); }
.thumbbar { display: flex; align-items: center; gap: 6px; min-width: 0; }
.thumbbar .btn { padding: 0 12px; }
.thumbbar .btn.primary { margin-left: auto; }
.thumbbar .btn.icon { padding: 0 10px; }
.floor-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 18px;
  pointer-events: none;
  text-align: center;
  padding: 16px;
}

/* ---------- Schülertisch ---------- */
.desk {
  position: absolute;
  width: var(--desk-w);
  height: var(--desk-h);
  padding: 18px 8px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: grab;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.desk.dragging {
  z-index: 10;
  cursor: grabbing;
  box-shadow: 0 6px 20px rgba(16, 24, 32, .18);
  transform: scale(1.03);
  user-select: none;
  -webkit-user-select: none;
}
/* Griff-Andeutung oben */
.desk::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 32px;
  height: 4px;
  margin-left: -16px;
  border-radius: 2px;
  background: #cfd6dc;
}
.desk-remove {
  position: absolute;
  top: 0;
  right: 0;
  width: 32px;
  height: 24px;
  border: 0;
  background: none;
  color: var(--placeholder);
  font-size: 13px;
  line-height: 1;
  padding: 0;
  border-radius: 0 var(--radius) 0 8px;
  touch-action: none;
}
.desk-remove::after { content: ""; position: absolute; inset: -10px -6px -10px -6px; } /* Tippfläche 44 × 44 */
.desk-remove:hover { color: var(--danger); background: #fbeceb; }
.desk-name {
  text-overflow: ellipsis; /* abgeschnittene Namen mit „…“ statt hart gekappt */
  width: 100%;
  height: 32px;
  flex: none;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--empty);
  padding: 0 8px;
  text-align: center;
  font-weight: 600;
  color: var(--text);
  touch-action: none; /* Ziehen auch vom Namensfeld aus */
  cursor: text;
}
.desk-name::placeholder { color: var(--placeholder); font-weight: 400; }
.desk-name:focus { outline: none; border-color: var(--primary); background: #fff; }
.squares {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 6px;
  flex: 1;
}
.square {
  border: 1px solid #d3dae0;
  border-radius: 6px;
  background: var(--empty);
  padding: 0;
  touch-action: none; /* Ziehen auch vom Quadrat aus */
}
.square[data-color="red"], .swatch[data-color="red"] { background: var(--red); border-color: var(--red); }
.square[data-color="yellow"], .swatch[data-color="yellow"] { background: var(--yellow); border-color: var(--yellow); }
.square[data-color="green"], .swatch[data-color="green"] { background: var(--green); border-color: var(--green); }
.square.active { outline: 3px solid var(--primary); outline-offset: 1px; }

/* Kompaktmodus (herausgezoomt): Name nur lesen, eine Zeile mit „…“; Tipp öffnet den Editor */
.floor.compact .desk-name { pointer-events: none; font-size: 20px; background: transparent; text-overflow: ellipsis; }
.floor.compact .desk-remove { display: none; }
/* Eingeklappte Reihe: kompakter Streifen nur mit Namen, nicht ziehbar */
.desk.collapsed {
  height: 48px;
  margin-top: calc((var(--desk-h) - 48px) / 2);
  padding: 7px 8px;
  cursor: pointer;
  background: var(--empty);
  box-shadow: none;
}
.desk.collapsed::before, .desk.collapsed .squares, .desk.collapsed .desk-remove { display: none; }
.desk.collapsed .desk-name { pointer-events: none; background: transparent; text-overflow: ellipsis; }

/* Snap: Ziel-Zelle beim Ziehen (belegt = Tausch) */
.snap-target {
  position: absolute;
  width: var(--desk-w);
  height: var(--desk-h);
  border: 3px dashed var(--primary);
  border-radius: var(--radius);
  background: rgba(47, 111, 143, .08);
  pointer-events: none;
}
.snap-target[hidden] { display: none; }
.snap-target[data-swap="1"] { border-color: #b07400; background: rgba(242, 201, 76, .18); }

/* Tauschen: Hinweisleiste, aktiver Schalter, ausgewählter Tisch */
.swap-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 12px;
  min-height: 48px;
  border-radius: 10px;
  background: #24323d;
  color: #fff;
  font-size: 15px;
}
.swap-hint { flex: 1; min-width: 0; }
.swap-bar .btn { flex: none; background: #fff; border-color: #fff; color: var(--text); font-weight: 600; }
.btn.swap-btn { min-width: 44px; }
.btn.swap-btn.on { background: #24323d; border-color: #24323d; color: #fff; }
.room.swapping .desk, .room.swapping .rdesk { cursor: pointer; }
.room.swapping .desk-name { pointer-events: none; cursor: pointer; }
[data-swap-selected="1"] { outline: 4px solid #b07400; outline-offset: 2px; background: #fff7e0; }

/* ---------- Reihenansicht (Standard auf dem Handy) ---------- */
.plan-rows {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.room[data-pult="unten"] .plan-rows > :first-child { margin-top: auto; } /* wenige Reihen: unten an der Tafel */
.rows-empty { color: var(--muted); text-align: center; font-size: 17px; padding: 16px; }
.row-block {
  flex: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 3px 3px;
}
.row-block .row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  font-size: 15px;
  font-weight: 650;
  text-align: left;
}
.row-meta { color: var(--muted); font-size: 14px; font-weight: 400; white-space: nowrap; }
.row-strip {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: var(--empty);
  font-size: 15px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-desks {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 180px));
  gap: 3px;
}
.rdesk {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
}
.rdesk-name {
  padding: 0 3px;
  font-size: 15px;
  font-weight: 600;
  line-height: 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rdesk-name.empty { color: var(--placeholder); font-weight: 400; }
.rdesk .squares { flex: none; grid-template-columns: repeat(3, minmax(28px, 1fr)); grid-template-rows: repeat(2, 32px); gap: 2px; }
.rdesk .square { touch-action: manipulation; } /* Liste bleibt per Finger scrollbar */

/* ---------- Tisch-Editor ---------- */
.sheet-label { display: block; font-weight: 500; font-size: 15px; }
.field.sheet-name { height: 52px; font-size: 20px; font-weight: 600; }
.sheet-squares { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 56px); gap: 10px; margin: 0 0 16px; }
.sheet-squares .square { touch-action: manipulation; border-radius: 10px; }
.sheet-actions .btn.danger { margin-right: auto; }

/* ---------- Popover ---------- */
.popover {
  position: fixed;
  z-index: 150; /* auch über dem Tisch-Editor */
  display: flex;
  gap: 8px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(16, 24, 32, .2);
}
.popover[hidden] { display: none; }
.swatch {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--empty);
  padding: 0;
}
.swatch.clear { color: var(--muted); font-size: 18px; }

/* ---------- Dialog ---------- */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(20, 30, 40, .35);
  display: grid;
  place-items: center;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
}
.dialog-backdrop[hidden] { display: none; }
.dialog-box {
  width: min(440px, 100%);
  max-height: calc(100vh - 32px - var(--sat) - var(--sab));
  max-height: calc(100dvh - 32px - var(--sat) - var(--sab));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(16, 24, 32, .25);
}
.dialog-box h2 { margin: 0 0 8px; font-size: 20px; touch-action: none; }
.dialog-box p { margin: 0 0 12px; color: var(--muted); line-height: 1.4; }
.dialog-box .hint { font-size: 14px; margin: 4px 0 0; }
.dialog-box .form-error { color: var(--danger); margin: 8px 0 0; }
.sheet-grab { display: none; }
.field {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin: 4px 0 12px;
}
.field:focus { outline: 2px solid var(--primary); border-color: transparent; }
.layout { border: 0; padding: 0; margin: 0 0 12px; }
.layout legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.radio { display: flex; align-items: center; gap: 8px; min-height: 44px; flex-wrap: wrap; }
.radio input[type="radio"] { width: 22px; height: 22px; margin: 0; }
.radio input[type="number"] {
  width: 64px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
}
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(112px + var(--sab)); /* über Tafel- und Daumenleiste */
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px - var(--sal) - var(--sar));
  text-align: center;
  z-index: 200;
  background: #24323d;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 15px;
  box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }
.toast.has-action:not([hidden]) { display: flex; align-items: center; gap: 12px; padding: 4px 6px 4px 18px; }
.toast-btn {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9fd3ec;
  font-weight: 650;
  font-size: 15px;
  text-decoration: underline;
}

/* ---------- Fußzeile: Links ---------- */
.privacy { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; }
.privacy a { color: var(--muted); display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 9px; } /* gleichmäßige Abstände, Tippfläche ≥ 44 × 44 */
.privacy > span:not(.footer-links) { flex: 1 1 100%; } /* Hinweis und Links sauber untereinander, beide zentriert */

/* ---------- Berechtigung: Banner (nicht modal) ---------- */
.ent-banner {
  flex: none;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px;
  padding: 6px calc(12px + var(--sar)) 6px calc(12px + var(--sal));
  background: var(--primary-light); color: var(--primary-dark); font-size: 15px; text-align: center;
  border-bottom: 1px solid var(--line);
}
.ent-banner[data-state="expired"], .ent-banner[data-state="past_due"] { background: var(--accent-light); color: var(--text); }
.ent-banner .link { min-height: 44px; display: inline-flex; align-items: center; padding: 0 6px; }
.ent-banner .btn.small { min-height: 40px; }
.readonly .desk-name { cursor: default; }

/* ---------- Konto ---------- */
.konto { display: grid; gap: 14px; align-content: start; max-width: 720px; margin: 0 auto; width: 100%; }
.konto-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.konto-card h2 { font-size: 18px; margin: 0 0 8px; }
.konto-card p { margin: 0 0 10px; line-height: 1.45; }
.konto-email { font-weight: 700; overflow-wrap: anywhere; }
.konto-status { color: var(--primary-dark); }
.konto-status[data-state="expired"], .konto-status[data-state="past_due"] { color: var(--danger); font-weight: 700; }
.konto-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 8px; }
.konto-row .field { flex: 1 1 220px; min-width: 0; margin: 0; }
.konto-row .form-error { flex: 1 1 100%; color: var(--danger); margin: 0; }
.konto-row .form-error[hidden] { display: none; }

/* ---------- Schlüssel ---------- */
.rk-value {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 20px; font-weight: 700; letter-spacing: .04em;
  color: var(--text) !important; background: var(--accent-light); border: 2px dashed var(--accent); border-radius: var(--radius);
  padding: 14px; text-align: center; overflow-wrap: anywhere; -webkit-user-select: all; user-select: all;
}
.rk-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.rk-field { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; text-transform: uppercase; }
.danger-zone { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.danger-zone summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--primary); font-weight: 600; }
.local-hint { margin: 10px 0 0 !important; text-align: center; }
.local-hint .link { font-size: 15px; text-align: center; }
@media print {
  body { overflow: visible; background: #fff; }
  .bar, .privacy, .rk-actions, .rk-card .check, .rk-card .btn, .toast { display: none !important; }
  .rk-card { box-shadow: none; border: 0; }
}

/* ---------- Konto, Sync-Status ---------- */
a.btn { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.account { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.sync { flex: none; font-size: 14px; color: var(--muted); white-space: nowrap; }
.sync[data-status="ok"] { color: var(--green-text); }
.sync[data-status="error"] { color: var(--danger); }
.link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary);
  font-size: 15px;
  text-decoration: underline;
  text-align: left;
  cursor: pointer;
}
.menu-items { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.menu-items .btn { width: 100%; text-align: left; }

/* ---------- Anmeldung / Antrag ---------- */
.auth-main { display: flex; justify-content: center; align-items: flex-start; }
.auth-card { width: min(460px, 100%); margin-top: 4vh; }
.intro { font-size: 17px; line-height: 1.45; margin: 0 0 16px; }
.auth-form {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
}
.auth-form h2 { margin: 0 0 12px; font-size: 20px; }
.auth-form label { display: block; font-weight: 500; font-size: 15px; }
.auth-form .hint, .auth-form p { color: var(--muted); line-height: 1.4; margin: 0 0 12px; }
.field.textarea { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; font: inherit; font-size: 16px; }
.auth-form label.check { display: flex; gap: 10px; align-items: center; min-height: 44px; font-weight: 400; margin: 4px 0 12px; line-height: 1.4; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; }
.form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-form .form-error { color: var(--danger); margin: 0 0 12px; }
.auth-form .forgot-row { margin: -6px 0 8px; text-align: right; }
.forgot-link { font-weight: 600; text-decoration: none; padding: 6px 0; }
.forgot-link:hover, .forgot-link:focus-visible { text-decoration: underline; }
.pw-checks { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 4px; font-size: 15px; color: var(--muted); }
.pw-checks li::before { content: '○'; display: inline-block; width: 1.4em; }
.pw-checks li[data-ok="true"] { color: var(--green-text); }
.pw-checks li[data-ok="true"]::before { content: '✓'; font-weight: 700; }
.auth-alt { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 4px 0; }
.auth-form .login-hint { margin: 14px 0 0; font-size: 14px; }
.done-card h2 { color: #22673f; }
.done-card .steps { margin: 4px 0 16px; padding-left: 1.4em; display: grid; gap: 8px; line-height: 1.4; }
.done-card .done-back { margin: 8px 0 0; text-align: center; }
.done-card .link { font-size: inherit; }
.auth-form .pw-for strong { color: var(--text); overflow-wrap: anywhere; }
.newlink { margin-top: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
/* Nur für Screenreader/Passwortmanager (nicht display:none, sonst ignorieren Manager das Feld) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
.safe-probe {
  position: fixed; visibility: hidden; pointer-events: none; top: 0; left: 0; width: 0; height: 0;
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
}
/* Startseite: „Sofort loslegen“ + Anmeldung, ab 820px nebeneinander */
.auth-card.welcome { width: min(960px, 100%); }
.welcome-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; align-items: start; }
.login-col { min-width: 0; }
.start-card h2 { margin: 0 0 8px; }
.btn.big { display: block; width: 100%; min-height: 52px; font-size: 17px; font-weight: 600; white-space: normal; }
a.btn.big { display: flex; justify-content: center; text-align: center; }
.or-divider { display: flex; align-items: center; gap: 12px; margin: 20px 4px; color: var(--muted); font-size: 15px; }
.or-divider::before, .or-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
@media (min-width: 820px) {
  .welcome-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
  .welcome-grid .or-divider { margin-top: 0; }
}
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; } /* Honeypot */

/* ---------- Admin ---------- */
.admin h2 { font-size: 18px; margin: 8px 0 12px; }
.admin .class-grid { margin-bottom: 24px; }
.request-card { cursor: default; }
.note { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.muted { color: var(--muted); }
.badge { font-size: 12px; background: var(--empty); border-radius: 6px; padding: 2px 6px; color: var(--muted); }
.admin-card { gap: 6px; }
.admin-card .class-card-name { font-size: 18px; }
.admin-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.class-card-meta, .mail-line { overflow-wrap: anywhere; }
.mail-line { font-size: 14px; color: var(--green-text); }
.mail-line[data-ok="false"] { color: var(--danger); }
.mail-line.muted { color: var(--muted); }
.chip { font-size: 13px; font-weight: 600; border-radius: 999px; padding: 3px 10px; background: var(--empty); color: var(--muted); }
.chip[data-state="pending"] { background: #fff1cc; color: #7a5300; }
.chip[data-state="nopw"] { background: var(--primary-light); color: var(--primary-dark); }
.chip[data-state="active"] { background: #def3e6; color: #22673f; }
.chip[data-state="rejected"] { background: #fbeceb; color: var(--danger); }
.mail-status { margin: 0 0 12px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.mail-status[data-ok="false"] { color: var(--danger); font-weight: 600; }
.link-box {
  border: 2px solid var(--primary); background: var(--primary-light); border-radius: var(--radius);
  padding: 12px 14px; margin: 0 0 20px; display: grid; gap: 10px;
}
.link-box[data-mail="failed"] { border-color: var(--danger); background: #fdf1f0; }
.link-box p { margin: 0; line-height: 1.4; overflow-wrap: anywhere; }
.link-box .link-warn { color: var(--danger); }
.link-box .muted { font-size: 14px; }
.link-row { display: flex; gap: 8px; flex-wrap: wrap; }
.link-field {
  width: 100%; min-width: 0; min-height: 44px; padding: 0 10px; font: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  -webkit-user-select: text; user-select: text;
}

/* ---------- Datenschutz (statische Seite) ---------- */
body.doc-page { overflow: auto; -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.doc-page main {
  max-width: 760px; margin: 0 auto; line-height: 1.55; overflow-wrap: anywhere;
  padding: calc(24px + var(--sat)) calc(16px + var(--sar)) calc(48px + var(--sab)) calc(16px + var(--sal));
}
.doc-page h1 { font-size: 26px; margin: 0 0 8px; }
.doc-page h2 { font-size: 19px; margin: 28px 0 8px; }
.doc-page a { color: var(--primary); }
.doc-page .back { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 8px; }
.todo {
  border: 2px dashed #d08a00;
  background: #fff7e0;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 12px 0;
}
.todo::before { content: "TODO: "; font-weight: 700; color: #8a5a00; }

/* ---------- Zoom-Leiste (Sitzplan) ---------- */
.zoom { display: flex; align-items: center; gap: 4px; }
.btn.icon { min-width: 44px; padding: 0 10px; font-size: 20px; line-height: 1; }
.btn.icon { flex-shrink: 0; }
.btn.icon .lbl { font-size: 16px; } /* Beschriftung wie bei den anderen Buttons, nur das Symbol größer */
.zoom-pct { min-width: 3.4em; text-align: center; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.only-narrow { display: none; }

/* Schmale Bildschirme: Beschriftungen kompakter */
@media (max-width: 760px) {
  .bar { flex-wrap: wrap; }
  .bar > * { min-width: 0; max-width: 100%; }
  .bar > .btn { flex: none; }
  .title { flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .actions { flex-wrap: wrap; flex: 1 1 100%; min-width: 0; }
  .actions .btn { flex: 1 1 auto; white-space: normal; min-height: 44px; min-width: 0; }
  .actions .btn.primary { order: -1; }
  /* Sitzplan: Kopfzeile bleibt einzeilig (‹ · Titel · Status · ⋯), Werkzeuge liegen unten in der Daumenleiste */
  .plan-bar { flex-wrap: nowrap; }
  .plan-bar .actions { flex: none; margin-left: 0; }
  .plan-bar .actions .btn { flex: none; }
  .btn { padding: 0 12px; font-size: 15px; }
  .btn.big { font-size: 17px; }
}
/* Handy (hoch) und Handy quer (wenig Höhe): Nebenaktionen ins „⋯“-Menü, Kopfzeile kompakt */
@media (max-width: 600px), (max-height: 500px) {
  .only-wide { display: none; }
  .only-narrow { display: inline-block; }
  .bar { gap: 8px; padding-top: calc(6px + var(--sat)); padding-bottom: 6px; }
  .title { font-size: 18px; }
  .title-btn::after { font-size: 14px; }
  .btn.account { max-width: 150px; }
  .actions { gap: 6px; }
  .room { padding-top: 8px; gap: 8px; }
  .board { padding: 3px 0; font-size: 12px; }
  .auth-card { margin-top: 0; }
  .empty { margin-top: 8vh; }
}
@media (max-width: 600px), (max-height: 500px) {
  .lbl, .zoom-pct { display: none; }
  .btn.back { min-width: 44px; padding: 0 10px; font-size: 20px; }
  .plan-bar .sync { font-size: 13px; }
  /* Dialoge als Bottom-Sheets: unten, volle Breite, Safe-Area unten, Griff zum Wegwischen */
  .dialog-backdrop { place-items: end center; padding: calc(16px + var(--sat)) 0 0; }
  .dialog-box {
    width: min(560px, 100%);
    max-height: calc(100vh - 16px - var(--sat));
    max-height: calc(100dvh - 16px - var(--sat));
    border-radius: 18px 18px 0 0;
    padding: 0 calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  }
  .sheet-grab { display: block; position: relative; height: 24px; margin: 0 -16px 2px; touch-action: none; }
  .sheet-grab::after {
    content: ""; position: absolute; left: 50%; top: 10px; width: 40px; height: 5px; margin-left: -20px;
    border-radius: 3px; background: #cfd6dc;
  }
  .dialog-actions .btn { flex: 1 1 auto; min-height: 48px; }
}
/* Handy quer (wenig Höhe): Tafel und Daumenleiste in einer Zeile */
@media (max-height: 500px) {
  .plan-foot { flex-direction: row; align-items: center; }
  .board { flex: 1 1 auto; min-width: 0; }
  .thumbbar { flex: none; }
}
