/* Materialatlas NT · Werkbank-Stil: Tinte auf Papier, gelbes Ortsschild, große Daumenziele. */
:root {
  --ink: #111827; --paper: #f6f5f1; --card: #ffffff; --line: #c9c5bb; --muted: #374151;
  --accent: #1d4ed8; --accent-ink: #ffffff; --ort: #ffd23f; --ort-ink: #111827;
  --ok: #0f6b36; --ok-bg: #e6f4ea; --err: #a61b1b; --err-bg: #fdecec; --warn: #8a3a0a; --warn-bg: #fff1e3;
  --off: #1f2937; --bio: #166534; --ch: #9a3412; --ph: #1e40af; --offen: #4b5563;
  --r: 14px; --tap: 56px; --pad: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  font-size: 18px; line-height: 1.4; color: var(--ink); background: var(--paper);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
body.mit-aktion { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.laden { padding: 24px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
.klein { font-size: .86rem; } .gedimmt { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Kopfzeile mit Verbindungsstatus */
#kopf { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #fff; display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top)); }
#kopf .marke { font-weight: 800; letter-spacing: .02em; flex: 1; font-size: 1rem; }
.pille { border: 0; border-radius: 999px; padding: 8px 14px; min-height: 44px; font-weight: 700; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px; }
.pille::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; }
.pille.ok { background: #d9f2e1; color: #0b4d27; }
.pille.lesen { background: #e5e7eb; color: #111827; }
.pille.offline { background: #fde68a; color: #111827; }
.pille.offline::before { border-radius: 2px; }
.pille.fehler { background: #fecaca; color: #7f1d1d; }

/* Ortsschild: bleibt sichtbar, bis man wechselt */
#ort { position: sticky; top: calc(60px + env(safe-area-inset-top)); z-index: 25; }
.ortsschild { background: var(--ort); color: var(--ort-ink); border-bottom: 3px solid var(--ink); padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.ortsschild .bereich { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.ortsschild .name { font-size: 1.3rem; font-weight: 900; line-height: 1.1; }
.ortsschild .ebene { font-size: 1.05rem; font-weight: 700; }
.ortsschild .knoepfe { grid-row: 1 / span 3; grid-column: 2; display: flex; flex-direction: column; gap: 6px; }
.ortsschild .knoepfe button { width: 56px; height: 44px; border: 2px solid var(--ink); background: #fff; border-radius: 10px; font-size: 1.1rem; font-weight: 900; }
.ortsschild .knoepfe button:disabled { opacity: .35; }
.ortsschild .zeit { font-size: .8rem; font-weight: 600; }

/* Meldungen: was passiert ist · was erhalten blieb · was jetzt */
#meldung:empty { display: none; }
.kasten { margin: 12px; border-radius: var(--r); padding: 14px; border: 2px solid; }
.kasten h2 { font-size: 1.05rem; }
.kasten p { margin: 4px 0; }
.kasten.konflikt { background: var(--err-bg); border-color: var(--err); color: #4c0d0d; }
.kasten.offline { background: var(--warn-bg); border-color: var(--warn); color: #3d1a04; }
.kasten.ok { background: var(--ok-bg); border-color: var(--ok); color: #05301a; }
.kasten.info { background: #eef2ff; border-color: var(--accent); }
.kasten .reihe { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

main { padding: 12px; max-width: 720px; margin: 0 auto; }
.karte { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: var(--pad); margin-bottom: 12px; }
.schritte { display: flex; gap: 4px; margin: 0 0 12px; padding: 0; list-style: none; font-size: .8rem; font-weight: 700; }
.schritte li { flex: 1; text-align: center; padding: 6px 2px; border-bottom: 4px solid var(--line); color: var(--muted); }
.schritte li.an { border-color: var(--ink); color: var(--ink); }
.schritte li.fertig { border-color: var(--ok); color: var(--ok); }

/* Knöpfe */
.knopf { min-height: var(--tap); border-radius: 12px; border: 2px solid var(--ink); background: #fff; padding: 10px 16px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.knopf.haupt { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.knopf.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.knopf.gefahr { background: #fff; border-color: var(--err); color: var(--err); }
.knopf.breit { width: 100%; }
.knopf:disabled { opacity: .45; cursor: not-allowed; }
.knopf.klein { min-height: 48px; padding: 6px 12px; font-size: .95rem; }

/* Fachwahl */
.faecher { display: grid; gap: 12px; }
.fach { min-height: 92px; border-radius: var(--r); border: 3px solid; background: #fff; text-align: left; padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; align-items: center; }
.fach strong { font-size: 1.35rem; }
.fach span { font-size: .9rem; color: var(--muted); }
.fach.Biologie { border-color: var(--bio); } .fach.Chemie { border-color: var(--ch); } .fach.Physik { border-color: var(--ph); }
.fach .zahl { font-size: 1.5rem; font-weight: 900; grid-row: 1 / span 2; grid-column: 2; }

/* Schrankwahl */
.bereich-titel { margin: 16px 0 8px; font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.schrank-raster { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.schrank { min-height: 96px; border-radius: var(--r); border: 2px solid var(--ink); background: #fff; padding: 10px 12px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.schrank .n { font-weight: 900; font-size: 1.1rem; }
.schrank .s { font-size: .85rem; font-weight: 700; }
.schrank.frei .s { color: var(--ok); }
.schrank.meins { background: var(--ort); }
.schrank.belegt { background: repeating-linear-gradient(135deg, #f3f4f6 0 10px, #e5e7eb 10px 20px); border-style: dashed; color: #1f2937; }
.schrank.belegt .s { color: #7f1d1d; }

/* Ebenenwahl: von oben nach unten gezeichnet, von unten gezählt */
.korpus { border: 4px solid var(--ink); border-radius: 10px; background: #fff; padding: 6px; display: flex; flex-direction: column; gap: 6px; }
.ebene { min-height: 64px; border: 2px solid var(--ink); border-radius: 8px; background: #fafaf9; display: grid; grid-template-columns: 52px 1fr auto; align-items: center; padding: 0 12px; text-align: left; gap: 8px; }
.ebene .nr { font-size: 1.5rem; font-weight: 900; }
.ebene .typ { font-weight: 700; }
.ebene .fz { font-size: .85rem; color: var(--muted); }
.ebene.auszug { background: #eef2ff; }
.ebene.auszug .typ::after { content: ""; display: inline-block; width: 26px; height: 6px; border-radius: 3px; background: var(--ink); margin-left: 8px; vertical-align: middle; }
.ebene.brett .typ::after { content: ""; display: inline-block; width: 34px; height: 3px; background: var(--ink); margin-left: 8px; vertical-align: middle; }
.ebene.gewaehlt { background: var(--ort); outline: 3px solid var(--ink); }

/* Materialliste */
.suche { position: sticky; top: calc(160px + env(safe-area-inset-top)); z-index: 20; background: var(--paper); padding: 8px 0; }
.suche input[type=search] { width: 100%; min-height: var(--tap); border: 2px solid var(--ink); border-radius: 12px; padding: 0 14px; background: #fff; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none; }
.chip { flex: none; min-height: 44px; border-radius: 999px; border: 2px solid var(--ink); background: #fff; padding: 6px 14px; font-weight: 700; font-size: .9rem; }
.chip[aria-pressed=true] { background: var(--ink); color: #fff; }
.filterzeile { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.filterzeile select { min-height: 44px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; padding: 0 8px; max-width: 100%; }
.treffer { font-size: .9rem; color: var(--muted); margin: 6px 0; }
.liste { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.zeile { display: grid; grid-template-columns: 1fr 56px; background: #fff; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; }
.zeile.markiert { border-color: var(--ink); background: #fffbe6; box-shadow: inset 6px 0 0 var(--ink); }
.zeile .wahl { border: 0; background: transparent; text-align: left; padding: 10px 12px; display: grid; grid-template-columns: 34px 1fr; gap: 10px; min-height: 64px; }
.zeile .box { width: 30px; height: 30px; border: 3px solid var(--ink); border-radius: 7px; display: grid; place-items: center; font-weight: 900; background: #fff; margin-top: 2px; }
.zeile.markiert .box { background: var(--ink); color: #fff; }
.zeile .titel { font-weight: 800; }
.zeile .wort { font-size: .85rem; color: var(--muted); margin-top: 2px; }
.zeile .info { border: 0; border-left: 2px solid var(--line); background: #f3f4f6; font-weight: 900; font-size: 1.2rem; }
.marken { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.marke { font-size: .75rem; font-weight: 800; border-radius: 6px; padding: 2px 6px; border: 1.5px solid currentColor; }
.marke.Biologie { color: var(--bio); } .marke.Chemie { color: var(--ch); } .marke.Physik { color: var(--ph); }
.marke.offen { color: var(--offen); border-style: dashed; } .marke.warn { color: var(--warn); } .marke.ort { color: var(--ink); background: var(--ort); border-color: var(--ink); }
.marke.jg { color: var(--ink); }

/* Aktionsleiste im Daumenbereich */
#aktion { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 35; padding: 8px 12px; }
#aktion:empty { display: none; }
#aktion .leiste { max-width: 720px; margin: 0 auto; display: flex; gap: 8px; background: var(--ink); border-radius: 16px; padding: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
#aktion .leiste .knopf { flex: 1; }
#aktion .leiste .knopf.neben { flex: none; background: transparent; color: #fff; border-color: #6b7280; }
#reiter { position: fixed; left: 0; right: 0; bottom: 0; z-index: 36; background: #fff; border-top: 2px solid var(--ink); display: grid; grid-template-columns: repeat(3, 1fr); padding-bottom: env(safe-area-inset-bottom); }
#reiter a { min-height: 64px; display: grid; place-items: center; text-decoration: none; color: var(--ink); font-weight: 800; font-size: .95rem; border-top: 5px solid transparent; }
#reiter a[aria-current=page] { border-top-color: var(--ink); background: var(--ort); }

/* Blatt (Dialog von unten) */
#blatt { position: fixed; inset: 0; z-index: 50; background: rgba(17,24,39,.55); display: flex; align-items: flex-end; }
#blatt[hidden] { display: none; }
#blatt .innen { background: var(--paper); width: 100%; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
#blatt .griff { width: 48px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
#blatt .fuss { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); background: var(--paper); padding: 12px 0 4px; display: flex; flex-direction: column; gap: 8px; }
dl.daten { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 8px 0; font-size: .92rem; }
dl.daten dt { font-weight: 800; } dl.daten dd { margin: 0; }
.wortlaut { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .88rem; background: #fff; border: 2px solid var(--ink); border-radius: 10px; padding: 10px; white-space: pre-wrap; word-break: break-word; }
.bezug { border-left: 5px solid var(--line); padding: 6px 10px; margin: 8px 0; background: #fff; border-radius: 0 10px 10px 0; }
.bezug .code { font-family: ui-monospace, Menlo, monospace; font-weight: 900; }

/* Einrichtung */
.raum-summe { font-weight: 800; }
.schrankzeile { background: #fff; border: 2px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.schrankzeile.neu { border-color: var(--accent); border-style: dashed; }
.schrankzeile.weg { opacity: .6; text-decoration: line-through; }
.schrankzeile.geaendert { border-color: var(--ink); }
.schrankzeile.gesperrt { background: repeating-linear-gradient(135deg, #f9fafb 0 10px, #eef0f3 10px 20px); }
.schrankzeile .kopfz { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; }
.schrankzeile .kopfz button.auf { border: 0; background: transparent; text-align: left; min-height: 52px; padding: 0; }
.schrankzeile .details { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.ebenenschalter { display: grid; grid-template-columns: 1fr; gap: 6px; }
.ebenenschalter .ez { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
.umschalter { display: inline-grid; grid-template-columns: 1fr 1fr; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; }
.umschalter button { min-height: 48px; min-width: 86px; border: 0; background: #fff; font-weight: 800; }
.umschalter button[aria-pressed=true] { background: var(--ink); color: #fff; }
.reihe { display: flex; gap: 8px; flex-wrap: wrap; }
.etikett { font-size: .78rem; font-weight: 800; border-radius: 6px; padding: 2px 6px; background: #e5e7eb; }
.etikett.neu { background: #dbeafe; color: #1e3a8a; } .etikett.geaendert { background: var(--ort); } .etikett.weg { background: #fee2e2; color: #7f1d1d; } .etikett.konflikt { background: var(--err); color: #fff; }
input.text { width: 100%; min-height: var(--tap); border: 2px solid var(--ink); border-radius: 12px; padding: 0 14px; background: #fff; }
.feld { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; font-weight: 700; }
.fehlertext { color: var(--err); font-weight: 700; font-size: .9rem; }
#hinweis { position: fixed; left: 12px; right: 12px; bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 60; display: flex; justify-content: center; pointer-events: none; }
#hinweis .toast { background: var(--ok); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 800; max-width: 600px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
@media (min-width: 560px) { .schrank-raster { grid-template-columns: repeat(3, 1fr); } }
