/* Aussehen der Prototyp-Zeichenfläche. Keine Logik, nur Darstellung. */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #e9ecef;
  color: #212529;
  /* Auswahl und Antipp-Menü auf dem iPad verhindern */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---- Werkzeugleiste ---- */
.leiste {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid #ced4da;
}

.gruppe { display: flex; gap: 6px; align-items: center; font-size: 15px; }

button {
  font: inherit;
  min-height: 44px;           /* Mindestgröße für Fingerbedienung */
  padding: 0 14px;
  border: 1px solid #adb5bd;
  border-radius: 8px;
  background: #f8f9fa;
  color: inherit;
  cursor: pointer;
}
button:disabled { opacity: 0.4; cursor: default; }
button.aktiv { background: #343a40; color: #fff; border-color: #343a40; }

button.farbe {
  width: 44px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px #adb5bd;
}
button.farbe.aktiv { box-shadow: 0 0 0 3px #343a40; }

input[type="range"] { width: 120px; }
input[type="checkbox"] { width: 20px; height: 20px; }

.rechts { margin-left: auto; display: flex; gap: 8px; align-items: center; }

[hidden] { display: none !important; }

/* Links, die wie Knöpfe aussehen */
a.knopf {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #adb5bd;
  border-radius: 8px;
  background: #f8f9fa;
  color: inherit;
  text-decoration: none;
}

/* Nur lesen (z. B. Schüler im Lehrerbereich): Werkzeuge ausblenden */
.nur-lesen #werkzeuge,
.nur-lesen [data-farbe],
.nur-lesen #dicke,
.nur-lesen #rueckgaengig,
.nur-lesen #wiederholen,
.nur-lesen #leeren,
.nur-lesen #finger,
.nur-lesen #einfuegen-gruppe { display: none; }
.nur-lesen label.gruppe { display: none; }

/* ---- Dialog "An Schüler verteilen" ---- */
dialog {
  width: min(92vw, 520px);
  max-height: 86vh;
  overflow: auto;
  padding: 18px;
  border: none;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35);
  -webkit-user-select: text;
  user-select: text;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
dialog .liste li { justify-content: space-between; }
dialog .zeile { margin-top: 12px; }
dialog label { display: flex; align-items: center; gap: 8px; font-size: 16px; }
dialog input[type="checkbox"] { width: 22px; height: 22px; margin: 0; }
.leise { color: #6c757d; font-size: 14px; }
.meldung.fehler { padding: 10px; color: #842029; background: #f8d7da; border-radius: 8px; }

/* ---- Verwaltungsseiten (Übersicht, Kurs) ---- */
body.verwaltung { -webkit-user-select: text; user-select: text; }
.kopfleiste {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid #ced4da;
}
.kopfleiste .logo { font-weight: 700; font-size: 18px; color: inherit; text-decoration: none; }
.kopfleiste .person { font-size: 15px; }
.inhalt { width: min(100%, 900px); margin: 0 auto; padding: 16px 14px 60px; }
.inhalt h1 { margin: 8px 0 12px; font-size: 26px; }
.inhalt h2 { margin: 28px 0 8px; font-size: 20px; }
.liste { list-style: none; margin: 0 0 10px; padding: 0; }
.liste li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid #dee2e6; }
.kurs-link { display: block; width: 100%; padding: 12px; background: #fff; border-radius: 8px; color: inherit; text-decoration: none; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.abschnitt { margin: 12px 0; padding: 12px 14px; background: #fff; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.abschnitt summary { cursor: pointer; font-weight: 600; font-size: 17px; min-height: 32px; }
.abschnitt small, .leise { color: #6c757d; font-weight: 400; }
button.klein { min-height: 32px; padding: 0 10px; font-size: 14px; }
.zeile { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.inhalt label { display: block; font-size: 15px; }
.inhalt input, .inhalt textarea {
  display: block; min-height: 44px; margin-top: 4px; padding: 6px 10px; font: inherit;
  border: 1px solid #adb5bd; border-radius: 8px; width: 100%;
}
.zeile label { flex: 1 1 200px; }
.inhalt textarea { margin-bottom: 10px; }
.tabelle { width: 100%; border-collapse: collapse; background: #fff; margin: 8px 0 16px; }
.tabelle th, .tabelle td { padding: 8px; border: 1px solid #dee2e6; text-align: left; font-size: 15px; }
.warnung { padding: 10px; background: #fff3cd; border-radius: 8px; }
.meldung.fehler { padding: 10px; color: #842029; background: #f8d7da; border-radius: 8px; }
/* Meldungen bleiben beim Scrollen oben im Bild sichtbar, damit man sie auch unten auf der Seite sieht */
#meldung:not(:empty) {
  position: sticky; top: 8px; z-index: 20;
  padding: 10px 14px; border-radius: 8px;
  color: #0f5132; background: #d1e7dd; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
#meldung.fehler:not(:empty) { color: #842029; background: #f8d7da; }
.inhalt select { display: block; min-height: 44px; margin-top: 4px; padding: 6px 10px; font: inherit; border: 1px solid #adb5bd; border-radius: 8px; width: 100%; background: #fff; }
code { font-size: 16px; }
.liste li code { color: #6c757d; }
.inhalt input[type="checkbox"] { display: inline-block; width: 22px; min-height: 0; height: 22px; margin: 0 8px 0 0; vertical-align: middle; }
.haken { display: block; margin: 8px 0 12px; }
.gefahr { padding: 12px 14px; border: 1px solid #f1aeb5; border-radius: 8px; background: #fff5f5; }
button.gefahr-knopf { background: #b02a37; border-color: #b02a37; color: #fff; }
td button.klein + button.klein { margin-left: 6px; }

/* Zugangsdaten drucken: nur die Tabelle zeigen */
@media print {
  .kopfleiste, #abschnitte, #mitglieder, #schueler-form, h1, h2, #drucken, .inhalt > p,
  #schueler-bereich > h3, #schueler-bereich > p { display: none !important; }
}

/* ---- Anmeldeseite ---- */
.anmeldung { display: flex; justify-content: center; padding: 40px 14px; }
.anmeldekasten {
  width: min(100%, 360px);
  padding: 24px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}
.anmeldekasten h1 { margin: 0 0 16px; font-size: 24px; }
.anmeldekasten label { display: block; margin-bottom: 14px; font-size: 15px; }
.anmeldekasten input {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  padding: 0 10px;
  font: inherit;
  border: 1px solid #adb5bd;
  border-radius: 8px;
  -webkit-user-select: text;
  user-select: text;      /* Eingabefelder müssen auswählbar bleiben */
}
.anmeldekasten button { width: 100%; background: #343a40; color: #fff; border-color: #343a40; }
.fehler { margin: 0 0 14px; padding: 10px; color: #842029; background: #f8d7da; border-radius: 8px; }

/* ---- Statuszeile ---- */
/* Die Statuszeile ist EINE Zeile mit fester Höhe: Ändert sich ein Text, darf nichts umbrechen und das Blatt
   darunter nicht springen. Zu lange Texte werden mit "…" gekürzt; Zähler und Diagnose-Knopf bleiben rechts
   immer sichtbar. */
.status {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  padding: 0 14px;
  height: 38px;
  overflow: hidden;
  white-space: nowrap;
  font-size: 13px;
  color: #495057;
}
.status > * { flex: 0 0 auto; }
.status > strong { flex: 0 1 auto; min-width: 0; max-width: 28%; overflow: hidden; text-overflow: ellipsis; }
.status > #live-anzeige { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.status > #eingabe-anzeige { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }   /* gibt zuerst Platz her */
.status > #speicher-anzeige { flex: 0 1 auto; min-width: 0; max-width: 40%; overflow: hidden; text-overflow: ellipsis; margin-left: auto; }   /* steht rechts */
.status > button { flex: none; }

/* ---- Die Seite ---- */
.buehne { padding: 10px 14px 40px; display: flex; justify-content: center; }

.seite {
  position: relative;
  width: min(100%, 900px);
  aspect-ratio: 1 / 1.4142;   /* DIN A4, passt zu SEITE_HOEHE in zeichenlogik.js */
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

.seite canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* Wichtig fürs Zeichnen: Der Browser darf Berührungen nicht als Scrollen oder Zoomen
     deuten, sonst bricht der Strich nach kurzer Zeit ab. */
  touch-action: none;
}
