/* publishm8te – Oberfläche.
 *
 * Mobile-First: Die Handy-Fassung ist die Grundregel, ab 900 px kommt die
 * Seitennavigation dazu. Keine externen Schriften, kein CDN – die
 * Content-Security-Policy lässt nur eigene Quellen zu. Das Manuskript steht in
 * einer Serifenschrift des Systems, die Oberfläche in der Systemschrift.
 *
 * Farben: Papier statt Bildschirmweiß, Petrol #006669 als Marke, ein Hauch
 * Lime als Akzent für Erreichtes. Beide Farbschemata sind ausgearbeitet. */

:root {
  --grund: #f6f4ef;
  --flaeche: #fffdf9;
  --flaeche-2: #efece5;
  --tinte: #1f2422;
  --gedaempft: #64706c;
  --leise: #8a948f;
  --linie: #ddd8cd;
  --linie-fein: #e9e5db;
  --marke: #006669;
  --marke-dunkel: #004f52;
  --marke-auf: #f6f4ef;
  --marke-bg: #dcebe9;
  --akzent: #bbd135;
  --akzent-dunkel: #6f8410;
  --gut: #2f6b3f;
  --gut-bg: #dfeddf;
  --warn: #8a5a12;
  --warn-bg: #f4e9d4;
  --bad: #9b2f28;
  --bad-bg: #f4dfdc;
  --schatten: 0 1px 2px rgba(31, 36, 34, .06), 0 8px 24px -14px rgba(31, 36, 34, .25);
  --schrift: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serife: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, "Times New Roman", serif;
  --fest: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 8px;
  --radius-gross: 14px;
  --tipp: 44px;
  --sicher-unten: env(safe-area-inset-bottom, 0px);
  --kopf-hoehe: 52px;
  --tab-hoehe: 60px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --grund: #161a1c; --flaeche: #1e2325; --flaeche-2: #262c2e; --tinte: #e6e8e4; --gedaempft: #9aa5a0; --leise: #6f7a76;
    --linie: #333b3d; --linie-fein: #2a3133; --marke: #4fb2b0; --marke-dunkel: #6ec5c3; --marke-auf: #0f1a1b; --marke-bg: #1c3536;
    --akzent: #c7d95a; --akzent-dunkel: #c7d95a; --gut: #6fbf87; --gut-bg: #1b2f22; --warn: #d9a852; --warn-bg: #33270f; --bad: #e08a82; --bad-bg: #3a1c19;
    --schatten: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -14px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --grund: #161a1c; --flaeche: #1e2325; --flaeche-2: #262c2e; --tinte: #e6e8e4; --gedaempft: #9aa5a0; --leise: #6f7a76;
  --linie: #333b3d; --linie-fein: #2a3133; --marke: #4fb2b0; --marke-dunkel: #6ec5c3; --marke-auf: #0f1a1b; --marke-bg: #1c3536;
  --akzent: #c7d95a; --akzent-dunkel: #c7d95a; --gut: #6fbf87; --gut-bg: #1b2f22; --warn: #d9a852; --warn-bg: #33270f; --bad: #e08a82; --bad-bg: #3a1c19;
  --schatten: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px -14px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--grund); color: var(--tinte); font-family: var(--schrift);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tab-hoehe) + var(--sicher-unten));
  overflow-x: hidden;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; text-wrap: balance; line-height: 1.25; }
h2 { font-size: 1.35rem; } h3 { font-size: 1rem; } h4 { font-size: .95rem; }
p { margin: 0 0 .7rem; }
a { color: var(--marke); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
code { font-family: var(--fest); font-size: .85em; background: var(--flaeche-2); padding: .1em .35em; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--marke); outline-offset: 2px; }
.gedaempft { color: var(--gedaempft); } .klein { font-size: .82rem; } .leise { color: var(--leise); }
.gut { color: var(--gut); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.nowrap { white-space: nowrap; } .rechtsbuendig { margin-left: auto; }
.nur-breit { display: none !important; }
.zum-inhalt { position: absolute; left: -9999px; background: var(--marke); color: var(--marke-auf); padding: .6rem 1rem; z-index: 200; }
.zum-inhalt:focus { left: .5rem; top: .5rem; }

/* ---------------------------------------------------------------- Kopf */
.kopf {
  position: sticky; top: 0; z-index: 40; height: var(--kopf-hoehe);
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: color-mix(in srgb, var(--flaeche) 92%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--linie-fein);
}
.kopf::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--marke) 0%, var(--marke) 60%, var(--akzent) 100%); opacity: .9; }
.marke { font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; color: var(--tinte); text-decoration: none !important; flex: none; display: inline-flex; align-items: center; min-height: var(--tipp); }
.marke span { color: var(--marke); }
.marke.gross { font-size: 1.8rem; display: block; margin-bottom: 1rem; }
.projekt-titel { flex: 1; min-width: 0; font-size: .9rem; color: var(--gedaempft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-aktionen { display: flex; align-items: center; gap: 6px; flex: none; }
.benutzer { font-size: .82rem; color: var(--gedaempft); display: none; }
.abgemeldet .kopf-aktionen, .abgemeldet .sidenav, .abgemeldet .tabbar, .abgemeldet .projekt-titel { display: none; }
.abgemeldet { padding-bottom: 0; }
.nur-schreiben { display: none; }

/* ---------------------------------------------------------------- Knöpfe */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tipp); padding: 0 14px; border-radius: var(--radius);
  border: 1px solid var(--linie); background: var(--flaeche); color: var(--tinte);
  cursor: pointer; font-weight: 550; font-size: .9rem; white-space: nowrap; text-decoration: none !important;
  transition: background .15s, border-color .15s;
}
.knopf:hover:not(:disabled) { border-color: var(--marke); }
.knopf:active:not(:disabled) { transform: scale(.98); }
.knopf:disabled { opacity: .5; cursor: progress; }
.knopf.primaer { background: var(--marke); border-color: var(--marke); color: var(--marke-auf); }
.knopf.primaer:hover:not(:disabled) { background: var(--marke-dunkel); }
.knopf.leise { background: transparent; border-color: transparent; color: var(--gedaempft); }
.knopf.leise:hover:not(:disabled) { background: var(--flaeche-2); color: var(--tinte); }
.knopf.gefaehrlich { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--linie)); }
.knopf.klein { min-height: 34px; padding: 0 10px; font-size: .82rem; }
.knopf-icon {
  display: inline-grid; place-items: center; width: var(--tipp); height: var(--tipp); flex: none;
  border-radius: var(--radius); border: 1px solid transparent; background: transparent; color: var(--gedaempft); cursor: pointer;
}
.knopf-icon:hover { background: var(--flaeche-2); color: var(--tinte); }
.knopf-icon.klein { width: 42px; height: 42px; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.knopfreihe.rechts { justify-content: flex-end; margin-top: 1rem; }
.knopfreihe.umbruch .knopf { flex: 1 1 auto; }
.speicherleiste { position: sticky; bottom: calc(var(--tab-hoehe) + var(--sicher-unten) + 8px); background: var(--flaeche); padding: 10px 12px; border: 1px solid var(--linie); border-radius: var(--radius); box-shadow: var(--schatten); margin: 1rem 0; z-index: 5; }
.chip {
  flex: none; padding: 0 12px; min-height: 42px; border-radius: 999px; font-size: .84rem; font-weight: 550;
  border: 1px solid var(--linie); background: var(--flaeche); color: var(--gedaempft); cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--marke); border-color: var(--marke); color: var(--marke-auf); }
.chips { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chips.umbruch { flex-wrap: wrap; overflow: visible; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: .72rem; font-weight: 650; letter-spacing: .02em; background: var(--marke-bg); color: var(--marke); white-space: nowrap; }
.badge.leise { background: var(--flaeche-2); color: var(--gedaempft); }
.badge.gut { background: var(--gut-bg); color: var(--gut); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.datenbank { background: var(--marke-bg); color: var(--marke); } .badge.umgebung { background: var(--warn-bg); color: var(--warn); } .badge.vorbelegung { background: var(--flaeche-2); color: var(--gedaempft); }

/* ---------------------------------------------------------------- Layout */
.huelle { display: block; }
.sidenav { display: none; }
.main { padding: 14px 14px 32px; max-width: 1180px; margin: 0 auto; width: 100%; min-width: 0; }
.main:focus { outline: none; }
.ansicht-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.ansicht-kopf p { margin: 4px 0 0; color: var(--gedaempft); font-size: .9rem; max-width: 64ch; }
.karte { background: var(--flaeche); border: 1px solid var(--linie-fein); border-radius: var(--radius-gross); padding: 16px; margin-bottom: 12px; box-shadow: var(--schatten); }
.karte > h3 { margin-bottom: 10px; }
.leer { text-align: center; padding: 36px 16px; color: var(--gedaempft); }
.leer p { max-width: 48ch; margin: 0 auto 12px; }
.laden { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--gedaempft); padding: 30px 0; font-size: .9rem; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--linie); border-top-color: var(--marke); animation: drehen .7s linear infinite; flex: none; }
@keyframes drehen { to { transform: rotate(360deg); } }
.wartet { display: inline-flex; align-items: center; gap: 8px; color: var(--gedaempft); }
.hinweis-box { background: var(--marke-bg); border: 1px solid color-mix(in srgb, var(--marke) 30%, transparent); border-radius: var(--radius); padding: 10px 12px; font-size: .9rem; }
.hinweis-box.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.kern { background: var(--flaeche-2); border-left: 3px solid var(--marke); padding: 8px 12px; border-radius: 0 var(--radius) var(--radius) 0; font-size: .92rem; }
.zeile { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--linie-fein); flex-wrap: wrap; }
.zeile:last-child { border-bottom: 0; }
.balken { height: 6px; border-radius: 999px; background: var(--flaeche-2); overflow: hidden; margin: 6px 0; }
.balken > span { display: block; height: 100%; background: var(--marke); border-radius: 999px; transition: width .3s; }
.balken.gut > span { background: var(--akzent-dunkel); } .balken.bad > span { background: var(--bad); }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { border-bottom: 1px solid var(--linie-fein); }
.liste li:last-child { border-bottom: 0; }
.liste.kompakt .listenknopf { padding: 8px 4px; }
.listenknopf { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left; padding: 10px 4px; background: none; border: 0; cursor: pointer; min-height: var(--tipp); border-radius: 6px; color: inherit; text-decoration: none !important; }
.listenknopf:hover { background: var(--flaeche-2); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; font-size: .9rem; }
.kv dt { color: var(--gedaempft); } .kv dd { margin: 0; }
.tabelle-rollt { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--linie-fein); vertical-align: top; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gedaempft); white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Formulare */
.feld { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; min-width: 0; }
.feld-name { font-size: .8rem; font-weight: 600; color: var(--gedaempft); }
.feld-hinweis { font-size: .78rem; color: var(--leise); line-height: 1.4; }
.pflicht { color: var(--warn); font-weight: 600; font-size: .72rem; }
input, select, textarea {
  width: 100%; min-height: var(--tipp); padding: 9px 11px; font: inherit; font-size: 16px; /* 16px: iOS zoomt sonst */
  border-radius: var(--radius); border: 1px solid var(--linie); background: var(--flaeche); color: var(--tinte);
}
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--marke); flex: none; margin: 0; }
textarea { resize: vertical; line-height: 1.5; min-height: 60px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--marke) 45%, transparent); outline-offset: 1px; border-color: var(--marke); }
input:disabled, select:disabled, textarea:disabled { opacity: .7; }
.formraster { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.kontroll { display: flex; align-items: flex-start; gap: 9px; min-height: var(--tipp); padding: 6px 0; font-size: .9rem; cursor: pointer; }
.kontroll input { margin-top: 2px; }
.kontroll .feld-hinweis { display: block; width: 100%; }
.feld-mit-zaehler { display: flex; flex-direction: column; gap: 4px; }
.zaehler { font-size: .75rem; color: var(--leise); align-self: flex-end; }
.zaehler.warn { color: var(--warn); } .zaehler.bad { color: var(--bad); font-weight: 600; }
.einstellung { padding: 12px 0; border-bottom: 1px solid var(--linie-fein); }
.einstellung:last-child { border-bottom: 0; }
.einstellung .feld { margin-bottom: 6px; }
.einstellung .feld-hinweis { color: var(--gedaempft); margin: 0 0 6px; }
.herkunft { font-size: .75rem; color: var(--leise); margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Projekte */
.projektliste { display: grid; grid-template-columns: 1fr; gap: 12px; }
.projektkarte { display: block; background: var(--flaeche); border: 1px solid var(--linie-fein); border-radius: var(--radius-gross); padding: 16px; color: inherit; text-decoration: none !important; box-shadow: var(--schatten); }
.projektkarte:hover { border-color: var(--marke); }
.projektkarte h3 { font-family: var(--serife); font-size: 1.25rem; margin: 8px 0 2px; }
.projektkarte-kopf { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Schreiben */
.schreiben { display: block; }
.binder { display: block; }
.binder-kopf { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.binder-titel { display: flex; flex-direction: column; min-width: 0; }
.binder-titel strong { font-family: var(--serife); font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.binder-suche { margin-bottom: 8px; }
.suchtreffer { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 6px; margin-bottom: 8px; max-height: 40vh; overflow-y: auto; }
.treffer { display: flex; flex-direction: column; gap: 2px; padding: 8px; border-radius: 6px; color: inherit; text-decoration: none !important; }
.treffer:hover { background: var(--flaeche-2); }
.treffer mark { background: var(--akzent); color: #1f2422; padding: 0 2px; border-radius: 2px; }
.baum, .baum ul { list-style: none; margin: 0; padding: 0; }
.baum ul { padding-left: 14px; border-left: 1px solid var(--linie-fein); margin-left: 9px; }
.baum-zeile { display: grid; grid-template-columns: 12px 1fr; align-items: center; gap: 8px; padding: 9px 8px; min-height: var(--tipp); border-radius: var(--radius); color: inherit; text-decoration: none !important; position: relative; }
.baum-zeile:hover { background: var(--flaeche-2); }
.baum-zeile.aktiv { background: var(--marke-bg); }
.baum-zeile.nicht-im-export .baum-titel { text-decoration: line-through; opacity: .6; }
.baum-punkt { width: 9px; height: 9px; border-radius: 50%; background: var(--linie); }
.status-entwurf .baum-punkt { background: var(--warn); } .status-ueberarbeitet .baum-punkt { background: var(--marke); } .status-fertig .baum-punkt { background: var(--akzent-dunkel); }
.baum-text { display: flex; flex-direction: column; min-width: 0; }
.baum-titel { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.baum-teil > .baum-zeile .baum-titel { text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; color: var(--gedaempft); }
.baum-meta { font-size: .75rem; color: var(--leise); }
.baum-balken { position: absolute; left: 28px; right: 8px; bottom: 3px; height: 2px; background: var(--linie-fein); border-radius: 2px; }
.baum-balken span { display: block; height: 100%; background: var(--marke); border-radius: 2px; }

.editor-spalte { min-width: 0; }
.editor { display: flex; flex-direction: column; min-height: calc(100dvh - var(--kopf-hoehe)); }
.editor-kopf { display: flex; align-items: center; gap: 4px; padding: 2px 0 6px; }
.editor-titel { border: 0; background: transparent; font-family: var(--serife); font-size: 1.25rem; font-weight: 650; padding: 6px 4px; min-height: 0; }
.editor-titel:focus { outline: none; border-bottom: 1px solid var(--marke); border-radius: 0; }
.editor-werkzeuge {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding: 4px; background: var(--flaeche); border: 1px solid var(--linie-fein); border-radius: var(--radius); margin-bottom: 8px;
}
.editor-werkzeuge::-webkit-scrollbar { display: none; }
.wz { flex: none; min-width: 42px; height: 42px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--gedaempft); font-weight: 650; font-size: .85rem; cursor: pointer; display: inline-grid; place-items: center; }
.wz:hover, .wz[aria-pressed="true"] { background: var(--flaeche-2); color: var(--tinte); }
.wz.fett { font-weight: 800; } .wz.kursiv { font-style: italic; font-family: var(--serife); }
.wz.ki { color: var(--marke); }
.wz-trenner { width: 1px; background: var(--linie); margin: 6px 4px; flex: none; }
.nur-handy { display: none; }
.editor-flaeche { flex: 1; }
.manuskript {
  display: block; width: 100%; min-height: 60vh; border: 0; background: transparent; padding: 8px 2px 40vh; resize: none;
  font-family: var(--serife); font-size: 1.12rem; line-height: 1.7; color: var(--tinte); field-sizing: content; overflow: hidden;
  max-width: 70ch; margin: 0 auto;
}
.manuskript:focus { outline: none; }
.manuskript-lesen { font-family: var(--serife); font-size: 1.12rem; line-height: 1.7; max-width: 70ch; margin: 0 auto; padding: 8px 2px 30vh; }
.manuskript-lesen h2, .manuskript-lesen h3, .manuskript-lesen h4 { font-family: var(--schrift); margin: 1.6em 0 .5em; }
.manuskript-lesen p { margin: 0 0 1em; }
.manuskript-lesen blockquote { margin: 1em 1.2em; padding-left: 1em; border-left: 3px solid var(--linie); color: var(--gedaempft); }
.manuskript-lesen .zitat { color: var(--marke); } .manuskript-lesen .zitat.fehlt { color: var(--bad); }
.manuskript-lesen .fussnoten { font-size: .85em; border-top: 1px solid var(--linie); margin-top: 2em; padding-top: .5em; color: var(--gedaempft); }
.manuskript-lesen .fussnoten ol { padding-left: 1.4em; } .manuskript-lesen .fn-nr { display: none; }
.manuskript-lesen mark.pruefen { background: var(--warn-bg); color: var(--warn); padding: 0 3px; border-radius: 3px; }
.manuskript-lesen table { margin: 1em 0; } .manuskript-lesen .abb { color: var(--leise); font-style: italic; }
.markdown p { margin: 0 0 .6em; } .markdown ul, .markdown ol { padding-left: 1.3em; }
.editor-fuss { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 2px; font-size: .78rem; color: var(--leise); flex-wrap: wrap; border-top: 1px solid var(--linie-fein); }
.speicherstatus { padding: 3px 9px; border-radius: 999px; background: var(--gut-bg); color: var(--gut); font-weight: 600; }
.speicherstatus.offen { background: var(--flaeche-2); color: var(--gedaempft); }
.speicherstatus.laeuft { background: var(--marke-bg); color: var(--marke); }
.speicherstatus.offline, .speicherstatus.fehler { background: var(--bad-bg); color: var(--bad); }
.kapitel-navi { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0 24px; }
.caret-spiegel { position: absolute; top: 0; left: -9999px; visibility: hidden; white-space: pre-wrap; word-wrap: break-word; }

.inspektor { display: none; }
.inspektor-kopf { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.inspektor .karte { padding: 12px; margin-bottom: 10px; }
.inspektor .formraster { grid-template-columns: 1fr 1fr; }
.fassungen .liste { margin-top: 8px; }

/* Handy: Editor offen → Gliederung und Tab-Leiste weichen dem Text. */
@media (max-width: 899px) {
  body.editor-offen .binder { display: none; }
  body.editor-offen .tabbar { display: none; }
  body.editor-offen { padding-bottom: 60px; }
  body.editor-offen .editor-werkzeuge {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; margin: 0; border-radius: 0; border: 0; border-top: 1px solid var(--linie);
    padding: 6px 6px calc(6px + var(--sicher-unten)); background: color-mix(in srgb, var(--flaeche) 96%, transparent); backdrop-filter: blur(10px);
  }
  body.editor-offen.tastatur-offen .editor-werkzeuge { padding-bottom: 6px; }
  body.editor-offen .nur-handy { display: inline-grid; }
  body.editor-offen .kapitel-navi { padding-bottom: 80px; }
  body.editor-offen .kopf { display: none; }
  body.editor-offen .editor-kopf { position: sticky; top: 0; z-index: 30; background: var(--grund); padding: 6px 0; }
  body.editor-offen .manuskript, body.editor-offen .manuskript-lesen { font-size: 1.05rem; padding-left: 6px; padding-right: 6px; }
}

/* Fokusmodus: nur der Text. */
body.fokus .kopf, body.fokus .sidenav, body.fokus .tabbar, body.fokus .binder, body.fokus .inspektor, body.fokus .editor-kopf, body.fokus .kapitel-navi { display: none !important; }
body.fokus .huelle { display: block; }
body.fokus .main { max-width: none; padding-top: 24px; }
body.fokus .editor-werkzeuge { opacity: .25; transition: opacity .2s; }
body.fokus .editor-werkzeuge:hover, body.fokus .editor-werkzeuge:focus-within { opacity: 1; }
body.fokus .manuskript { font-size: 1.2rem; line-height: 1.8; }

/* ---------------------------------------------------------------- Planen */
.gliederung-liste { list-style: none; margin: 0; padding: 0; }
.gl-knoten { background: var(--flaeche); border: 1px solid var(--linie-fein); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--schatten); }
.gl-knoten.ebene-1 { margin-left: 18px; } .gl-knoten.ebene-2 { margin-left: 36px; }
.gl-knoten.art-teil { border-left: 4px solid var(--marke); }
.gl-knoten.zieht { opacity: .4; } .gl-knoten.ziel { outline: 2px dashed var(--marke); outline-offset: 2px; }
.gl-zeile { display: flex; align-items: center; gap: 6px; }
.gl-griff { color: var(--leise); cursor: grab; display: inline-grid; place-items: center; width: 24px; }
.gl-titel { border: 0; background: transparent; font-family: var(--serife); font-size: 1.05rem; font-weight: 650; padding: 4px; min-height: 42px; flex: 1; }
.gl-masse { font-size: .78rem; color: var(--leise); white-space: nowrap; }
.gl-details { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.gl-details select, .gl-details input { width: auto; min-height: 42px; padding: 4px 8px; font-size: 14px; }
.gl-ziel { width: 6.5em !important; }
.gl-knoepfe { display: inline-flex; gap: 2px; margin-left: auto; }
.gl-karte { min-height: 44px; font-size: .9rem; margin-top: 6px; }
.gl-kern { font-size: .9rem; margin-top: 6px; font-style: italic; }
.korkbrett { display: grid; grid-template-columns: 1fr; gap: 12px; }
.karte-pin { display: block; background: var(--flaeche); border: 1px solid var(--linie-fein); border-top: 4px solid var(--linie); border-radius: var(--radius); padding: 12px 14px; color: inherit; text-decoration: none !important; box-shadow: var(--schatten); min-height: 140px; }
.karte-pin.status-entwurf { border-top-color: var(--warn); } .karte-pin.status-ueberarbeitet { border-top-color: var(--marke); } .karte-pin.status-fertig { border-top-color: var(--akzent-dunkel); }
.karte-pin h4 { font-family: var(--serife); font-size: 1.1rem; margin: 6px 0; }
.karte-pin p { font-size: .9rem; color: var(--gedaempft); }
.karte-kopf { display: flex; justify-content: space-between; align-items: center; }

/* ---------------------------------------------------------------- Recherche / Quellen */
.notizliste, .quellenliste { display: grid; grid-template-columns: 1fr; gap: 10px; }
.notiz, .quelle { background: var(--flaeche); border: 1px solid var(--linie-fein); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; box-shadow: var(--schatten); }
.notiz:hover, .quelle:hover { border-color: var(--marke); }
.notiz.erledigt { opacity: .6; } .notiz.angeheftet { border-left: 3px solid var(--akzent-dunkel); }
.notiz-kopf, .quelle-kopf { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.notiz h4 { margin: 2px 0 4px; }
.notiz-text { white-space: pre-wrap; font-size: .92rem; margin: 0; }
.kuerzel { cursor: copy; }

/* ---------------------------------------------------------------- KI */
.ki-ergebnis { margin-top: 12px; }
.ki-hinweis { background: var(--marke-bg); border-radius: var(--radius); padding: 8px 12px; font-size: .92rem; }
.vorher-nachher { display: grid; grid-template-columns: 1fr; gap: 12px; }
.vorschlagtext { white-space: pre-wrap; font-family: var(--serife); font-size: 1rem; line-height: 1.6; background: var(--flaeche-2); padding: 10px 12px; border-radius: var(--radius); max-height: 50vh; overflow-y: auto; }
.vorschlagtext.lang { max-height: 60vh; }
.diff { font-family: var(--serife); font-size: 1rem; line-height: 1.6; background: var(--flaeche-2); padding: 10px 12px; border-radius: var(--radius); max-height: 50vh; overflow-y: auto; white-space: pre-wrap; }
.diff-weg { background: var(--bad-bg); color: var(--bad); text-decoration: line-through; }
.diff-neu { background: var(--gut-bg); color: var(--gut); }
.prompt-einsicht { margin-top: 10px; font-size: .8rem; color: var(--gedaempft); }
.prompt-einsicht summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; }
.prompt { white-space: pre-wrap; font-family: var(--fest); font-size: .72rem; background: var(--flaeche-2); padding: 8px; border-radius: 6px; max-height: 30vh; overflow: auto; margin: 6px 0; }
.prompt.auftrag { border-left: 3px solid var(--marke); }
.befunde { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 10px; }
.befund { background: var(--flaeche); border: 1px solid var(--linie-fein); border-radius: var(--radius); padding: 10px 12px; }
.befund.gewicht-hoch { border-left: 3px solid var(--bad); } .befund.gewicht-mittel { border-left: 3px solid var(--warn); }
.befund-kopf { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.befund .stelle { margin: 6px 0; padding: 4px 10px; border-left: 3px solid var(--linie); font-family: var(--serife); cursor: pointer; }
.befund p { margin: 4px 0; font-size: .92rem; }
.gespraech { display: grid; gap: 10px; margin-bottom: 12px; max-height: 60vh; overflow-y: auto; }
.sprechblase { padding: 10px 14px; border-radius: 14px; max-width: 90%; font-size: .95rem; }
.sprechblase.ich { background: var(--marke-bg); align-self: flex-end; justify-self: end; }
.sprechblase.sie { background: var(--flaeche-2); justify-self: start; }
.belege { color: var(--gedaempft); }

/* ---------------------------------------------------------------- Fortschritt */
.kacheln { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.kachel { background: var(--flaeche); border: 1px solid var(--linie-fein); border-radius: var(--radius-gross); padding: 12px 14px; display: flex; flex-direction: column; box-shadow: var(--schatten); min-width: 0; }
.kachel.leit { grid-column: span 2; }
.kachel-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--leise); }
.kachel-wert { font-size: 1.6rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kachel.leit .kachel-wert { font-size: 2.2rem; }
.kachel-sub { font-size: .8rem; color: var(--gedaempft); }
.diagramm-wrap { width: 100%; overflow: hidden; }
.diagramm { width: 100%; height: auto; display: block; }
.balken-tag { fill: var(--marke); opacity: .85; } .balken-tag.erreicht { fill: var(--akzent-dunkel); }
.ziel-linie { stroke: var(--warn); stroke-dasharray: 4 4; }
.diagramm-text { font-size: 11px; fill: var(--leise); font-family: var(--schrift); }
.kapitelbalken { display: grid; gap: 8px; }
.kb.ebene-1 { margin-left: 16px; } .kb.ebene-2 { margin-left: 32px; }
.kb-zeile { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Export */
.formate { display: grid; grid-template-columns: 1fr; gap: 10px; }
.formatkarte { display: block; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 14px; color: inherit; text-decoration: none !important; }
.formatkarte:hover { border-color: var(--marke); }
.formatkarte .endung { display: inline-block; font-family: var(--fest); font-size: .72rem; background: var(--marke); color: var(--marke-auf); padding: 2px 8px; border-radius: 4px; text-transform: uppercase; }
.formatkarte h4 { margin: 6px 0 2px; }
.kapitelwahl .ebene-1 { margin-left: 16px; } .kapitelwahl .ebene-2 { margin-left: 32px; }
.kapitelwahl .kontroll { min-height: 36px; padding: 2px 0; }

/* ---------------------------------------------------------------- Mehr */
.mehr-liste { display: grid; gap: 4px; }
.mehr-eintrag { display: grid; grid-template-columns: 24px 1fr 16px; align-items: center; gap: 12px; padding: 12px; min-height: 56px; background: var(--flaeche); border: 1px solid var(--linie-fein); border-radius: var(--radius); color: inherit; text-decoration: none !important; }
.mehr-eintrag > span { display: flex; flex-direction: column; }
.mehr-eintrag svg { color: var(--marke); }

/* ---------------------------------------------------------------- Anmeldung */
.anmeldung { min-height: calc(100dvh - var(--kopf-hoehe) - 40px); display: grid; place-items: center; padding: 20px 0; }
.anmeldung-form { width: min(420px, 100%); background: var(--flaeche); border: 1px solid var(--linie-fein); border-radius: var(--radius-gross); padding: 28px 24px; box-shadow: var(--schatten); }
.anmeldung-form h2 { margin-bottom: 4px; }

/* ---------------------------------------------------------------- Tab-Leiste */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--flaeche) 96%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--linie); padding-bottom: var(--sicher-unten);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: var(--tab-hoehe); color: var(--leise); font-size: 10.5px; text-decoration: none !important; position: relative; }
.tabbar a.aktiv { color: var(--marke); }
.tabbar a.aktiv::before { content: ""; position: absolute; top: 0; left: 24%; right: 24%; height: 2px; background: var(--marke); border-radius: 0 0 2px 2px; }

/* ---------------------------------------------------------------- Sheet */
.sheet { position: fixed; inset: 0; z-index: 80; }
.sheet-hintergrund { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--flaeche); border-radius: 16px 16px 0 0; border-top: 1px solid var(--linie); box-shadow: var(--schatten);
  animation: hoch .22s cubic-bezier(.22, 1, .36, 1); padding-bottom: var(--sicher-unten);
}
@keyframes hoch { from { transform: translateY(100%); } }
.sheet-griff { display: block; width: 40px; height: 4px; border-radius: 999px; background: var(--linie); margin: 8px auto 0; flex: none; }
.sheet-kopf { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 18px; border-bottom: 1px solid var(--linie-fein); flex: none; touch-action: none; }
.sheet-kopf h2 { font-size: 1.05rem; }
.sheet-inhalt { padding: 14px 16px 24px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
body.sheet-offen { overflow: hidden; }

/* ---------------------------------------------------------------- Toasts */
.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tab-hoehe) + var(--sicher-unten) + 10px); z-index: 90; display: grid; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; cursor: pointer; background: var(--flaeche); border: 1px solid var(--linie); border-left: 3px solid var(--marke); border-radius: var(--radius); padding: 10px 12px; font-size: .88rem; box-shadow: var(--schatten); animation: einblenden .2s ease; }
.toast.bad { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); } .toast.gut { border-left-color: var(--gut); }
.toast.weg { opacity: 0; transition: opacity .2s; }
.toast-knopf { background: var(--marke); color: var(--marke-auf); border: 0; border-radius: 6px; padding: 6px 10px; font-weight: 600; cursor: pointer; }
@keyframes einblenden { from { opacity: 0; transform: translateY(6px); } }

/* ---------------------------------------------------------------- Tablet */
@media (min-width: 620px) {
  .formraster { grid-template-columns: 1fr 1fr; }
  .projektliste, .notizliste, .quellenliste, .formate { grid-template-columns: repeat(2, 1fr); }
  .korkbrett { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .vorher-nachher { grid-template-columns: 1fr 1fr; }
  .kacheln { grid-template-columns: repeat(4, 1fr); }
  .kachel.leit { grid-column: span 2; }
}

/* ---------------------------------------------------------------- Schreibtisch */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .knopf-icon.klein { width: 34px; height: 34px; }
  .wz { height: 36px; min-width: 38px; }
  .chip { min-height: 34px; }
  .gl-details select, .gl-details input, .gl-titel { min-height: 34px; }
  .tabbar { display: none; }
  .nur-breit { display: inline-flex !important; }
  .benutzer { display: inline; }
  .huelle { display: grid; grid-template-columns: 210px minmax(0, 1fr); align-items: start; }
  .sidenav { display: flex; flex-direction: column; gap: 1px; padding: 12px 10px; position: sticky; top: var(--kopf-hoehe); height: calc(100vh - var(--kopf-hoehe)); overflow-y: auto; border-right: 1px solid var(--linie-fein); }
  .sidenav a { display: flex; align-items: center; padding: 8px 12px; border-radius: var(--radius); color: var(--gedaempft); font-size: .9rem; font-weight: 500; text-decoration: none !important; }
  .sidenav a:hover { background: var(--flaeche-2); color: var(--tinte); }
  .sidenav a.aktiv { background: var(--marke-bg); color: var(--marke); font-weight: 600; }
  .navgruppe { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--leise); padding: 12px 12px 4px; }
  .main { padding: 22px 28px 40px; }
  .kopf { padding: 0 18px; }
  .speicherleiste { bottom: 8px; }
  .toasts { left: auto; right: 20px; bottom: 20px; width: 380px; }
  .sheet-griff { display: none; }
  .sheet-panel { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(640px, 92vw); max-height: 86vh; border-radius: var(--radius-gross); border: 1px solid var(--linie); animation: rein .18s ease; }
  .sheet-panel.breit { width: min(880px, 92vw); }
  @keyframes rein { from { opacity: 0; transform: translate(-50%, -46%); } }

  body[data-ansicht="schreiben"] .nur-schreiben { display: inline-grid; }
  body[data-ansicht="schreiben"] .main { max-width: none; padding: 0; }
  .schreiben.mit-editor { display: grid; grid-template-columns: 260px minmax(0, 1fr) 300px; min-height: calc(100vh - var(--kopf-hoehe)); }
  .schreiben:not(.mit-editor) { display: grid; grid-template-columns: 320px minmax(0, 1fr); }
  body.inspektor-zu .schreiben.mit-editor { grid-template-columns: 260px minmax(0, 1fr); }
  body.inspektor-zu .inspektor { display: none; }
  .binder { padding: 16px 12px; border-right: 1px solid var(--linie-fein); position: sticky; top: var(--kopf-hoehe); height: calc(100vh - var(--kopf-hoehe)); overflow-y: auto; }
  .editor-spalte { padding: 12px 28px 40px; }
  .editor { min-height: 0; }
  .inspektor { display: block; padding: 16px 14px; border-left: 1px solid var(--linie-fein); position: sticky; top: var(--kopf-hoehe); height: calc(100vh - var(--kopf-hoehe)); overflow-y: auto; }
  .editor-kopf .knopf-icon:first-child { display: none; }
  .kachel-wert { font-size: 1.9rem; }
}
@media (min-width: 1200px) {
  .schreiben.mit-editor { grid-template-columns: 280px minmax(0, 1fr) 340px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
  .kopf, .sidenav, .tabbar, .toasts, .editor-werkzeuge, .editor-fuss, .binder, .inspektor { display: none !important; }
}
