:root {
  --grund: #f7f6f2;
  --flaeche: #ffffff;
  --text: #1d2126;
  --leise: #6a7076;
  --linie: #e5e3db;
  --beruehrt: #eeede7;
  --schloss: #378add;
  --baustelle: #ba7517;
  --kreuz: #e24b4a;
  --gruen: #2f9e62;
  --rot: #d9534f;
  --knopf: #1d2126;
  --knopf-text: #ffffff;
  --schatten: 0 10px 40px rgba(20, 24, 30, .16);
  --rund: 14px;
  --alter: 56px;
}
:root[data-thema="dunkel"] {
  --grund: #13161b;
  --flaeche: #1b1f26;
  --text: #eceae4;
  --leise: #9097a0;
  --linie: #2a2f38;
  --beruehrt: #20252d;
  --schloss: #6aaef0;
  --baustelle: #e0a040;
  --kreuz: #f07272;
  --gruen: #3fb877;
  --rot: #e0625e;
  --knopf: #eceae4;
  --knopf-text: #13161b;
  --schatten: 0 10px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }

.sy { width: 20px; height: 20px; flex: none; display: block; }
.sy-schloss { color: var(--schloss); }
.sy-baustelle { color: var(--baustelle); }
.sy-liste-x { color: var(--leise); }
.sy-liste-x .x { stroke: var(--kreuz); }

/* ---------- Gestell ---------- */
.gestell { display: flex; min-height: 100%; max-width: 1080px; margin: 0 auto; }
#links {
  flex: 1 1 auto; min-width: 0;
  padding: calc(env(safe-area-inset-top) + 28px) 20px calc(env(safe-area-inset-bottom) + 28px);
}
#rechts { display: none; }
body.einzel #links { display: none; }
body.einzel #rechts {
  display: block; flex: 1 1 auto; min-width: 0;
  padding: calc(env(safe-area-inset-top) + 20px) 20px calc(env(safe-area-inset-bottom) + 28px);
}
@media (min-width: 860px) {
  #links { flex: 0 0 440px; padding: 56px 28px; }
  body.einzel #links { display: block; }
  #rechts, body.einzel #rechts { display: block; flex: 1 1 auto; padding: 56px 40px; }
  .nur-schmal { display: none !important; }
}

/* ---------- Übersicht ---------- */
.kopf { display: flex; align-items: flex-end; padding: 0 12px 18px; }
.kopf .zahl { font-size: 34px; font-weight: 650; line-height: 1; letter-spacing: -.02em; }
.kopf .wort { margin-left: 10px; color: var(--leise); padding-bottom: 3px; }
.kopf .luft { flex: 1; }
.sortierung {
  width: var(--alter); display: flex; justify-content: flex-end; color: var(--leise);
  cursor: pointer; padding: 6px 0; margin: -6px 0; user-select: none;
}
.sortierung .sy { width: 18px; height: 18px; }

.strang { list-style: none; margin: 0; padding: 0; }
.strang .abstand { height: 14px; }
.zeile { position: relative; border-radius: var(--rund); overflow: hidden; touch-action: pan-y; }
.zeile .unter { position: absolute; inset: 0; display: flex; align-items: center; color: #fff; }
.zeile .unter.gruen { background: var(--gruen); justify-content: flex-start; padding-left: 22px; }
.zeile .unter.rot { background: var(--rot); justify-content: flex-end; padding-right: 22px; }
.zeile .unter .sy { width: 22px; height: 22px; color: #fff; }
.zeile .unter { opacity: 0; }
.zeile.zieht-rechts .unter.gruen, .zeile.zieht-links .unter.rot { opacity: 1; }
.zeile .inhalt {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 13px 12px; min-height: 52px; background: var(--grund); cursor: pointer;
  border-radius: var(--rund);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.zeile.gleitet .inhalt { transition: transform .18s ease; }
.zeile.gewaehlt .inhalt, .zeile .inhalt:active { background: var(--beruehrt); }
@media (hover: hover) { .zeile .inhalt:hover { background: var(--beruehrt); } }
.zeile .titel { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.zeile .pin { color: var(--leise); }
.zeile .pin .sy { width: 14px; height: 14px; }
.zeile .alter {
  flex: none; width: var(--alter); text-align: right; color: var(--leise);
  font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.zeile .alter.breit { width: auto; min-width: var(--alter); }
.zeile .punkt { width: 7px; height: 7px; border-radius: 50%; background: var(--schloss); flex: none; }
.zeile.weg { transition: height .2s ease, opacity .2s ease; opacity: 0; }

.leer { color: var(--leise); padding: 20px 12px; }
.leer a { color: inherit; }

.fuss { display: flex; align-items: center; gap: 6px; padding: 22px 4px 0; color: var(--leise); }
.fuss .luft { flex: 1; }
.fuss .ding {
  display: flex; align-items: center; gap: 6px; padding: 8px; border-radius: 10px; cursor: pointer;
  user-select: none; font-size: 14px; font-variant-numeric: tabular-nums;
}
.fuss .ding:active { background: var(--beruehrt); }
@media (hover: hover) { .fuss .ding:hover { background: var(--beruehrt); color: var(--text); } }

/* ---------- Einzelansicht ---------- */
.zurueck {
  display: inline-flex; align-items: center; gap: 2px; color: var(--leise); cursor: pointer;
  margin: 0 0 22px -6px; padding: 6px 8px 6px 0; user-select: none;
}
.einzel-kopf { display: flex; align-items: flex-start; gap: 12px; }
.einzel-kopf h1 { flex: 1; font-size: 26px; line-height: 1.2; font-weight: 650; letter-spacing: -.01em; }
.einzel-kopf .nadel { color: var(--leise); cursor: pointer; padding: 6px; margin: -2px -6px 0 0; border-radius: 10px; }
.einzel-kopf .nadel.an { color: var(--text); }
.einzel-kopf .nadel.an .sy { fill: currentColor; }
.unterzeile { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--leise); margin-top: 10px; font-size: 15px; }
.unterzeile .sy { width: 18px; height: 18px; }
.abschnitt { margin-top: 30px; }
.abschnitt h2 { font-size: 13px; font-weight: 600; color: var(--leise); margin-bottom: 8px; }
.abschnitt p { font-size: 17px; }
.punkte { list-style: none; margin: 0; padding: 0; }
.punkte li { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.punkte li + li { border-top: 1px solid var(--linie); }
.punkte .was { flex: 1; min-width: 0; }
.punkte .erledigt { color: var(--leise); font-size: 14px; white-space: nowrap; }
.klein {
  flex: none; font: inherit; font-size: 14px; color: var(--text); background: var(--beruehrt);
  border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap;
}
.befehl {
  margin-top: 26px; padding: 16px; background: var(--flaeche); border-radius: var(--rund);
  font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
.begruendung { margin-top: 14px; font-size: 17px; }
.ausgabe { margin-top: 14px; max-height: 50vh; overflow: auto; color: var(--leise); }
.lage { margin-top: 18px; color: var(--leise); }

.knoepfe { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 34px; }
.knopf {
  font: inherit; font-weight: 550; text-align: center; text-decoration: none; cursor: pointer;
  border: 0; border-radius: 12px; padding: 12px 18px; background: var(--beruehrt); color: var(--text);
}
.knopf.haupt { background: var(--knopf); color: var(--knopf-text); }
.knopf.leise { background: transparent; color: var(--leise); }
.knopf:disabled { opacity: .5; cursor: default; }
@media (max-width: 859px) {
  .knoepfe { flex-direction: column; }
  .knopf { width: 100%; padding: 14px 18px; }
}

/* ---------- Suche im Archiv ---------- */
.suche { display: flex; align-items: center; gap: 10px; background: var(--flaeche); border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; color: var(--leise); }
.suche input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }
.suche .weg { cursor: pointer; display: flex; }
.titelzeile { font-size: 26px; font-weight: 650; padding: 0 12px 16px; }

/* ---------- Schicht: Menü, Legende, Vorschau ---------- */
#schicht:empty { display: none; }
#schicht { position: fixed; inset: 0; z-index: 20; }
#schicht .grund { position: absolute; inset: 0; }
#schicht .grund.dunkel { background: rgba(10, 12, 16, .35); }
.menue {
  position: absolute; min-width: 170px; background: var(--flaeche); border-radius: 12px;
  box-shadow: var(--schatten); padding: 6px;
}
.menue div { padding: 11px 14px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.menue div:active { background: var(--beruehrt); }
@media (hover: hover) { .menue div:hover { background: var(--beruehrt); } }
.blatt {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 460px); background: var(--flaeche); box-shadow: var(--schatten);
  border-radius: 20px 20px 0 0; padding: 24px 22px calc(env(safe-area-inset-bottom) + 22px);
}
@media (min-width: 860px) { .blatt { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: 20px; } }
.blatt h2 { font-size: 18px; margin-bottom: 16px; }
.blatt .feld { display: block; margin-bottom: 14px; }
.blatt .feld span { display: block; font-size: 13px; color: var(--leise); margin-bottom: 6px; }
.blatt input, .blatt textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--grund);
  border: 1px solid var(--linie); border-radius: 10px; padding: 10px 12px; outline: 0; resize: vertical;
}
.blatt .knoepfe { margin-top: 20px; }
.legende { list-style: none; margin: 0; padding: 0; }
.legende li { display: flex; align-items: center; gap: 14px; padding: 9px 0; }
.blatt .weiteres { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--linie); color: var(--leise); cursor: pointer; }

/* ---------- Hinweis mit „Rückgängig“ ---------- */
#hinweis {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 22px); transform: translateX(-50%);
  z-index: 30; display: flex; gap: 16px; align-items: center; padding: 12px 18px; border-radius: 999px;
  background: var(--knopf); color: var(--knopf-text); box-shadow: var(--schatten); font-size: 15px;
  white-space: nowrap; max-width: calc(100vw - 32px);
}
#hinweis:empty { display: none; }
#hinweis .tun { font-weight: 650; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Einrichtung ---------- */
.block { margin-top: 30px; }
.block h2 { font-size: 17px; font-weight: 650; margin-bottom: 6px; }
.block p { color: var(--leise); margin-bottom: 12px; }
.block .lage { margin: 0 0 12px; color: var(--text); }
.block code, .code {
  display: block; background: var(--flaeche); border-radius: 10px; padding: 12px 14px; margin: 10px 0;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all;
  user-select: all;
}
.schluesselliste { list-style: none; padding: 0; margin: 0 0 12px; }
.schluesselliste li { display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--linie); }
.schluesselliste .kennung { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--leise); }
.schluesselliste .luft { flex: 1; }
.gut { color: var(--gruen); }
.offen { color: var(--baustelle); }
.fehler { color: var(--rot); }

/* ---------- Anmeldeseite ---------- */
.tor { display: flex; align-items: center; justify-content: center; min-height: 100%; }
.tor-mitte { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 24px; text-align: center; }
.tor-mitte img { border-radius: 18px; }
.tor-mitte h1 { font-size: 28px; font-weight: 650; }
.tor-mitte .knopf { width: auto; margin-top: 8px; }
