:root {
  --tinte: #14202b; --grau: #5b6b79; --linie: #d5dde4; --flaeche: #f3f6f8;
  --akzent: #1f5f8b; --rot: #c62828; --orange: #e67700; --gruen: #2e7d32; --gelb: #f2c94c;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--tinte);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
a { color: var(--akzent); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--gelb); outline-offset: 2px;
}

/* Einfache Seiten (Anmeldung, Fehler) */
body.seite { background: var(--flaeche); }
.schmal { max-width: 36rem; margin: 3rem auto; padding: 0 1rem; }
.lead { font-size: 1.1rem; }
.knopf {
  display: inline-block; padding: .55rem 1rem; border-radius: .45rem; border: 1px solid var(--akzent);
  background: var(--akzent); color: #fff; font: inherit; text-decoration: none; cursor: pointer;
}
.knopf.zweit { background: #fff; color: var(--akzent); }
.knopf:disabled { opacity: .6; cursor: wait; }

/* App */
body.app { display: flex; flex-direction: column; background: var(--flaeche); }
.kopf { display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; background: var(--tinte); color: #fff; }
.kopf h1 { font-size: 1.1rem; margin: 0; font-weight: 650; white-space: nowrap; }
.kopf .wer { margin-left: auto; color: #b9cad8; font-size: .9rem; white-space: nowrap; }
.kopf .abmelden { color: #cfe0ee; font-size: .9rem; white-space: nowrap; }
.rahmen { flex: 1; display: flex; min-height: 0; }
.geschosse {
  width: 11.5rem; flex: none; overflow-y: auto; padding: .5rem .75rem 1rem;
  background: #fff; border-right: 1px solid var(--linie);
}
.gebaeude h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--grau); margin: .9rem 0 .35rem; }
.gebaeude .knoepfe { display: flex; flex-wrap: wrap; gap: .45rem; }
.geschoss {
  position: relative; min-width: 3.3rem; padding: .45rem .55rem; border: 1px solid var(--linie); border-radius: .45rem;
  background: #fff; color: var(--tinte); font: inherit; cursor: pointer;
}
.geschoss:hover { border-color: var(--akzent); }
.geschoss[aria-pressed="true"] { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.plan { flex: 1; min-width: 0; min-height: 0; }
.plan.leaflet-container { background: #fff; }
#status {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); max-width: 90vw; padding: .6rem 1rem;
  border-radius: .5rem; background: var(--tinte); color: #fff; box-shadow: 0 4px 16px rgb(0 0 0 / .2); z-index: 1100;
}
#status:empty { display: none; }

@media (max-width: 720px) {
  .kopf { gap: .4rem .6rem; padding: .45rem .6rem; flex-wrap: wrap; }
  .kopf .wer { display: none; }
  .kopf .abmelden { margin-left: auto; }
  .rahmen { flex-direction: column; }
  .geschosse {
    width: auto; display: flex; gap: 1rem; overflow-x: auto; overflow-y: hidden; padding: .4rem .6rem .6rem;
    border-right: 0; border-bottom: 1px solid var(--linie);
  }
  .gebaeude { flex: none; }
  .gebaeude h2 { margin: 0 0 .25rem; }
  .gebaeude .knoepfe { flex-wrap: nowrap; }
}

/* Suche */
.suche { position: relative; flex: 0 1 18rem; min-width: 8rem; }
.suche input {
  width: 100%; padding: .4rem .6rem; border-radius: .4rem; border: 1px solid #4b6072;
  background: #233445; color: #fff; font: inherit;
}
.suche input::placeholder { color: #9fb3c4; }
.treffer {
  position: absolute; top: calc(100% + .25rem); left: 0; right: 0; margin: 0; padding: .25rem; list-style: none;
  background: #fff; border-radius: .45rem; box-shadow: 0 8px 24px rgb(0 0 0 / .2); z-index: 1200;
}
.treffer button {
  display: flex; gap: .6rem; width: 100%; padding: .45rem .6rem; border: 0; border-radius: .3rem;
  background: none; color: var(--tinte); font: inherit; text-align: left; cursor: pointer;
}
.treffer button:hover, .treffer button:focus-visible { background: var(--flaeche); }
.treffer .name { color: var(--grau); }

/* Raumflächen im Plan */
/* Leicht blau hinterlegt und umrandet, damit erkennbar ist, dass sich Räume anklicken lassen. */
.leaflet-container path.raum { stroke: var(--akzent); stroke-opacity: .45; stroke-width: 1.5; fill: var(--akzent); fill-opacity: .07; cursor: pointer; }
.leaflet-container path.raum:hover { stroke-opacity: .9; fill-opacity: .2; }
.leaflet-container path.raum.rot { stroke: var(--rot); stroke-opacity: 1; fill: var(--rot); fill-opacity: .42; }
.leaflet-container path.raum.orange { stroke: var(--orange); stroke-opacity: 1; fill: var(--orange); fill-opacity: .42; }
/* Belegung: belegte Räume ohne Farbe schraffiert (Muster #schraffur in index.php), freie mit grünem Rand.
   Rot und Orange behalten ihre Füllung; der grüne Rand zeigt auch dort, dass der Raum gerade frei ist. */
.leaflet-container path.raum.belegt:not(.rot):not(.orange) { fill: url(#schraffur); fill-opacity: 1; }
.leaflet-container path.raum.frei { stroke: var(--gruen); stroke-opacity: 1; stroke-width: 4; }
.leaflet-container path.raum.gewaehlt { stroke: var(--akzent); stroke-opacity: 1; stroke-width: 4; }

/* Hinweis im Plan, solange kein Raum gewählt ist; Klicks gehen durch. */
.planhinweis {
  margin: .6rem .6rem 0 0; padding: .35rem .7rem; border: 1px solid var(--linie); border-radius: .5rem;
  background: rgb(255 255 255 / .94); color: var(--tinte); font-size: .9rem; box-shadow: 0 2px 8px rgb(0 0 0 / .12);
  pointer-events: none;
}
.planhinweis[hidden] { display: none; }

/* Raumkarte */
.raumkarte { width: 24rem; flex: none; overflow-y: auto; padding: 1rem 1.1rem 2rem; background: #fff; border-left: 1px solid var(--linie); }
.raumkarte[hidden] { display: none; }
.karte-kopf { display: flex; align-items: flex-start; gap: .5rem; }
.karte-kopf h2 { display: flex; flex-direction: column; margin: 0; font-size: 1.6rem; line-height: 1.2; }
.karte-kopf .name { font-size: 1rem; font-weight: 400; color: var(--grau); }
.schliessen { margin-left: auto; padding: .1rem .45rem; border: 0; background: none; color: var(--grau); font-size: 1.7rem; line-height: 1; cursor: pointer; }

@media (max-width: 720px) {
  .suche { flex: 1 1 100%; order: 1; }
  .raumkarte {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto; max-height: 62vh; border-left: 0;
    border-top: 1px solid var(--linie); border-radius: 1rem 1rem 0 0; box-shadow: 0 -6px 24px rgb(0 0 0 / .18); z-index: 1050;
  }
}

/* Zahl roter Räume am Geschossknopf */
.geschoss .zahl {
  position: absolute; top: -.5rem; right: -.5rem; min-width: 1.35rem; padding: 0 .3rem; border-radius: 1rem;
  background: var(--rot); color: #fff; font-size: .75rem; font-weight: 700; line-height: 1.35rem; text-align: center;
}

/* Probleme in der Raumkarte */
.probleme { display: grid; gap: .8rem; margin-top: 1rem; }
.problem { padding: .7rem .8rem; border: 1px solid var(--linie); border-left: 5px solid var(--rot); border-radius: .5rem; }
.problem.orange { border-left-color: var(--orange); }
.problem h3 { margin: .4rem 0 .2rem; font-size: 1.05rem; }
.problem p { margin: .25rem 0; }
.problem .beschreibung { white-space: pre-line; }
.problem .kommentarzahl { font-size: .85rem; color: var(--grau); }
.problem .kommentare { list-style: none; margin: .3rem 0; padding: 0; display: grid; gap: .4rem; }
.problem .kommentare li { padding: .3rem .6rem; border-left: 3px solid var(--linie); background: var(--flaeche); border-radius: 0 .3rem .3rem 0; }
.problem .kommentar-kopf { font-size: .8rem; color: var(--grau); }
.problem .kommentar-text { margin: .1rem 0 0; white-space: pre-line; }
.problem .kommentar-text.leer { color: var(--grau); }
.problem .notiz { font-style: italic; }
.problem .spur { font-size: .8rem; color: var(--grau); }
.problem .bearbeiten { margin-top: .45rem; padding: .3rem .75rem; font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.chip { padding: .1rem .55rem; border: 1px solid var(--linie); border-radius: 1rem; background: var(--flaeche); font-size: .8rem; }
.chip.rot { background: var(--rot); border-color: var(--rot); color: #fff; }
.chip.orange { background: var(--orange); border-color: var(--orange); color: #fff; }
.alter { margin-left: auto; font-size: .8rem; color: var(--grau); }
.leer { color: var(--grau); }
.hinweis { color: var(--grau); font-style: italic; margin: .25rem 0 .5rem; }
.karte-fuss { margin-top: 1.2rem; }

/* Dialoge */
dialog {
  width: min(34rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 1.2rem 1.3rem;
  border: 0; border-radius: .7rem; box-shadow: 0 12px 40px rgb(0 0 0 / .3); color: var(--tinte);
}
dialog::backdrop { background: rgb(20 32 43 / .45); }
dialog h2 { margin: 0 0 .2rem; font-size: 1.25rem; }
.unterzeile { margin: 0; color: var(--grau); }
.formular label { display: block; margin-top: .8rem; font-size: .9rem; font-weight: 600; }
.formular input, .formular select, .formular textarea {
  width: 100%; margin-top: .25rem; padding: .45rem .55rem; border: 1px solid #b8c4ce; border-radius: .4rem; font: inherit;
}
.formular [aria-invalid="true"] { border-color: var(--rot); }
.feldfehler, .meldung { margin: .25rem 0 0; color: var(--rot); font-size: .9rem; }
.meldung:empty { display: none; }
.dialog-knoepfe { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }

/* Listenknopf im Kopf */
.liste-knopf {
  display: flex; align-items: center; gap: .4rem; padding: .35rem .7rem; border: 1px solid #4b6072; border-radius: .4rem;
  background: #233445; color: #fff; font: inherit; font-size: .9rem; white-space: nowrap; cursor: pointer;
}
.liste-knopf .zahl {
  min-width: 1.35rem; padding: 0 .3rem; border-radius: 1rem; background: var(--rot);
  font-size: .75rem; font-weight: 700; line-height: 1.35rem; text-align: center;
}

/* Weitere Orte */
.ort {
  padding: .45rem .6rem; border: 1px solid var(--linie); border-left: 5px solid var(--linie); border-radius: .45rem;
  background: #fff; color: var(--tinte); font: inherit; cursor: pointer;
}
.ort.rot { border-left-color: var(--rot); }
.ort.orange { border-left-color: var(--orange); }

/* Liste */
dialog.liste { width: min(60rem, calc(100vw - 2rem)); }
.liste-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .8rem; }
.liste-kopf h2 { margin: 0; }
.liste-kopf select { padding: .35rem .5rem; border: 1px solid #b8c4ce; border-radius: .4rem; font: inherit; }
.tabelle { overflow-x: auto; }
.liste table { width: 100%; border-collapse: collapse; }
.liste th, .liste td { padding: .45rem .5rem; border-bottom: 1px solid var(--linie); text-align: left; vertical-align: top; }
.liste th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--grau); }
.raum-link { padding: 0; border: 0; background: none; color: var(--akzent); font: inherit; font-weight: 650; text-decoration: underline; cursor: pointer; }
.alter-spalte { white-space: nowrap; color: var(--grau); }

@media (max-width: 720px) {
  .liste-knopf { padding: .3rem .5rem; font-size: 0; gap: 0; }
  .liste-knopf .zahl { font-size: .75rem; }
  .liste-knopf::before { content: "Liste"; font-size: .85rem; margin-right: .3rem; }
}

/* Muster für belegte Räume; display: none würde das Muster mit abschalten. */
.muster { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Gelbe Hinweise und Band „Schulweit“ über dem Plan */
.hinweise {
  margin: 0; padding: .4rem 1rem; list-style: none; background: #fff4cc; border-bottom: 1px solid var(--gelb);
  color: var(--tinte); font-size: .9rem;
}
.schulweit {
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; padding: .4rem 1rem;
  background: #fff; border-bottom: 1px solid var(--linie);
}
.schulweit h2 { margin: 0; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--grau); }
.schulweit ul { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin: 0; padding: 0; list-style: none; }
.schulweit li { display: flex; align-items: center; gap: .45rem; padding-left: .5rem; border-left: 4px solid var(--rot); }
.schulweit li.orange { border-left-color: var(--orange); }
.schulweit .loesen {
  padding: .1rem .45rem; border: 1px solid var(--linie); border-radius: .35rem; background: #fff;
  color: var(--akzent); font: inherit; font-size: .8rem; cursor: pointer;
}

/* Stand der Abrufe unten rechts im Plan; Klicks gehen durch. */
.abrufstand {
  margin: 0 .6rem .6rem 0; padding: .2rem .55rem; border-radius: .4rem; background: rgb(255 255 255 / .9);
  color: var(--grau); font-size: .8rem; pointer-events: none;
}
.abrufstand:empty { display: none; }

/* Belegung in der Raumkarte */
.belegung { margin-top: .9rem; }
.belegung-jetzt { margin: 0 0 .4rem; font-weight: 650; }
.belegung-jetzt.frei { color: var(--gruen); }
.zeitleiste {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(6.4rem, 1fr)); gap: .3rem;
  margin: 0; padding: 0; list-style: none;
}
.fenster { padding: .15rem .35rem; border-radius: .3rem; font-size: .8rem; text-align: center; font-variant-numeric: tabular-nums; }
.fenster.belegt { background: #dbe7f0; border: 1px solid #b6cbdb; }
.fenster.entfaellt { border: 1px dashed var(--grau); color: var(--grau); text-decoration: line-through; }

/* iServ-Meldungen in Raumkarte und Dialogen */
.chip.iserv-chip { background: #fff; border-color: var(--akzent); color: var(--akzent); font-weight: 650; }
.iserv-knoepfe { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .45rem; }
.iserv-knoepfe .knopf { padding: .3rem .75rem; font-size: .9rem; }

/* Liste mit iServ-Meldungen */
.liste tr.iserv .quelle { color: var(--akzent); font-weight: 650; }
.nur-frei { display: flex; align-items: center; gap: .35rem; font-size: .9rem; white-space: nowrap; }
.ohne-raum { color: var(--grau); font-style: italic; }

.nur-vorlesen { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 720px) {
  .liste-kopf h2 { order: 0; }
  .liste-kopf .schliessen { order: 1; }
  .liste-kopf select, .liste-kopf .nur-frei { order: 2; }
}

/* Knöpfe für Bearbeiter im Kopf */
.kopf-knopf {
  display: flex; align-items: center; gap: .4rem; padding: .35rem .7rem; border: 1px solid #4b6072; border-radius: .4rem;
  background: #233445; color: #fff; font: inherit; font-size: .9rem; white-space: nowrap; cursor: pointer;
}
.kopf-knopf .zahl {
  min-width: 1.35rem; padding: 0 .3rem; border-radius: 1rem; background: var(--orange);
  font-size: .75rem; font-weight: 700; line-height: 1.35rem; text-align: center;
}

/* Einstellungen */
.schalter { padding: .7rem 0; border-bottom: 1px solid var(--linie); }
.schalter label { display: flex; align-items: center; gap: .55rem; font-weight: 650; cursor: pointer; }
.schalter input { width: 1.2rem; height: 1.2rem; margin: 0; }
.schalter .erklaerung { margin: .3rem 0 0 1.75rem; }
.schalter .spur { margin: .2rem 0 0 1.75rem; font-size: .8rem; color: var(--grau); }

/* Ohne Raum */
dialog.ohneraum { width: min(44rem, calc(100vw - 2rem)); }
.ohneraum-liste { display: grid; gap: .8rem; margin-top: .8rem; }
.zuordnen { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .45rem; margin-top: .5rem; }
.raumsuche { position: relative; flex: 1 1 10rem; }
.raumfeld { width: 100%; padding: .45rem .55rem; border: 1px solid #b8c4ce; border-radius: .4rem; font: inherit; }

/* Im Dialog stehen die Treffer im Fluss: Ein schwebendes Feld würde am Dialogrand abgeschnitten. */
.raumsuche .treffer { position: static; margin-top: .25rem; border: 1px solid var(--linie); box-shadow: none; }

@media (max-width: 720px) {
  .kopf-knopf { padding: .3rem .5rem; font-size: .85rem; }
}

/* Langer Titel schiebt das Schließen-Kreuz sonst auf eine eigene Zeile */
dialog.ohneraum .liste-kopf { flex-wrap: nowrap; justify-content: space-between; }

/* Kiosk-Anzeige (public/kiosk.php) für 1920×1080, gelesen aus 2 bis 4 m: alle Größen in px, Raum und Titel 36 px, Nebeninformationen 26 px.
   Die Höhe einer Karte (höchstens 185 px) und der Abstand (10 px) stehen auch in assets/kiosk.js (KARTE_PX). */
body.kiosk { display: flex; flex-direction: column; background: var(--flaeche); overflow: hidden; font-size: 22px; line-height: 1.2; cursor: none; }
#kiosk { display: flex; flex-direction: column; height: 100%; }
.kiosk .kopf { gap: 40px; padding: 10px 28px; }
.kiosk .kopf h1 { font-size: 36px; }
.kiosk .geschoss-name { font-size: 36px; color: #fff; }
.kiosk .uhr { font-size: 36px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kiosk .kopf-status { margin-left: auto; color: #b9cad8; font-size: 26px; }
.kiosk-rahmen { flex: 1; display: flex; min-height: 0; }
.kiosk-links { flex: 0 0 62%; display: flex; flex-direction: column; min-width: 0; border-right: 1px solid var(--linie); }
.kiosk-karte { flex: 1; min-height: 0; background: #fff; }
.kiosk-karte.leaflet-container { background: #fff; cursor: default; }
.kiosk .legende { display: flex; gap: 40px; margin: 0; padding: 10px 28px; list-style: none; background: #fff; border-top: 1px solid var(--linie); font-size: 26px; }
.kiosk .legende li { display: flex; align-items: center; gap: 10px; }
.kiosk .legende .punkt { width: 36px; height: 24px; border-radius: 4px; border: 4px solid transparent; }
.kiosk .legende .punkt.rot { background: var(--rot); opacity: .75; }
.kiosk .legende .punkt.orange { background: var(--orange); opacity: .75; }
.kiosk .legende .punkt.frei { border-color: var(--gruen); background: #fff; }
.kiosk .legende .punkt.belegt { background: repeating-linear-gradient(45deg, #b6cbdb 0 3px, #f3f6f8 3px 7px); border-color: #b6cbdb; }
.kiosk-rechts { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 0 20px 8px; }
.kiosk-rechts h2 { margin: 12px 0 8px; font-size: 30px; }
.kiosk .hinweise { margin: 10px 0 0; padding: 8px 14px; border: 1px solid var(--gelb); border-radius: 6px; font-size: 26px; }
.kiosk-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; overflow: hidden; }
.kiosk .eintrag { flex: none; max-height: 185px; padding: 10px 16px; border: 1px solid var(--linie); border-left: 10px solid var(--rot); border-radius: 8px; background: #fff; overflow: hidden; }
.kiosk .eintrag.orange { border-left-color: var(--orange); }
.kiosk .eintrag-oben { display: flex; align-items: center; gap: 10px; }
.kiosk .eintrag-raum { font-size: 36px; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kiosk .chip { font-size: 26px; padding: 1px 14px; white-space: nowrap; }
.kiosk .eintrag-titel {
  font-size: 36px; line-height: 1.15; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.kiosk .eintrag-unten { display: flex; gap: 24px; font-size: 26px; color: var(--grau); }
.kiosk-leer { padding: 16px; color: var(--grau); font-size: 36px; }
.kiosk-seiten { margin: 4px 0 0; text-align: right; color: var(--grau); font-size: 26px; }
.kiosk-meldung {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 2000;
  background: var(--tinte); color: #fff; font-size: 64px; font-weight: 650;
}
.kiosk-meldung p { margin: 0; }
.kiosk-meldung .klein { font-size: 30px; font-weight: 400; color: #b9cad8; }
.leaflet-container path.raum.anzeige { cursor: default; }
/* Raumnummer an roten und orangen Räumen im Plan */
.leaflet-tooltip.raumetikett {
  padding: 1px 8px; border: 3px solid var(--rot); border-radius: 6px; background: #fff; color: var(--tinte);
  font: 700 24px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif; box-shadow: none;
}
.leaflet-tooltip.raumetikett.orange { border-color: var(--orange); }
.leaflet-tooltip.raumetikett::before { display: none; }
