:root {
  --bg: #f4f1ea; --karte: #ffffff; --text: #1f1d1a; --grau: #6b665e; --linie: #e3ded3;
  --akzent: #2f6f8f; --akzent-dunkel: #245a75; --akzent-hell: #e4eef3; --gruen: #2f7d4f; --rot: #b13a2d; --gelb: #b7791f;
  --seite: #fffdf8; --schatten: 0 6px 22px rgba(31, 29, 26, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 17px/1.5 "Segoe UI", system-ui, sans-serif; }
a { color: var(--akzent); }
.seite { max-width: 760px; margin: 0 auto; padding: 24px 16px 60px; }
.kopf h1 { margin: 0 0 4px; font-size: 32px; letter-spacing: 0.5px; }
.kopf h1 a { color: inherit; text-decoration: none; }
.unter { margin: 0 0 18px; color: var(--grau); }
.pille { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--linie); font-size: 13px; margin-left: 6px; white-space: nowrap; }
.karte { background: var(--karte); border: 1px solid var(--linie); border-radius: 16px; padding: 20px; margin-bottom: 18px; }
.karte h2 { margin: 0 0 12px; font-size: 20px; }
.feld { margin-bottom: 14px; }
.feld label { display: block; font-weight: 600; margin-bottom: 6px; }
.reihe { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .reihe { grid-template-columns: 1fr; } }
textarea, input[type=text], input[type=number], select, input[type=file] { width: 100%; padding: 10px 12px; border: 1px solid var(--linie); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; }
textarea { resize: vertical; }
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
.hinweis { color: var(--grau); font-size: 14px; margin: 6px 0 0; }
.fehler { color: var(--rot); }
.erfolg { color: var(--gruen); }
.versteckt { display: none !important; }
.primaer { background: var(--akzent); color: #fff; border: none; border-radius: 12px; padding: 12px 20px; font-size: 17px; font-weight: 600; cursor: pointer; }
.primaer:hover { background: var(--akzent-dunkel); }
.primaer:disabled { opacity: 0.6; cursor: wait; }
.knopf { display: inline-block; text-decoration: none; border: 1px solid var(--linie); border-radius: 12px; padding: 10px 16px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.knopf:hover { background: var(--akzent-hell); }
.knopf.primaer { border: none; color: #fff; background: var(--akzent); }
.knopf.primaer:hover { background: var(--akzent-dunkel); }
.knopf.klein, .primaer.klein { padding: 6px 10px; font-size: 14px; border-radius: 9px; }
.knopf.gefahr { color: var(--rot); border-color: var(--rot); }
.knoepfe { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.haken { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
.haken input { width: 18px; height: 18px; accent-color: var(--akzent); }
.haken.aus { opacity: 0.45; cursor: not-allowed; }

/* Startseite: das eine große Eingabefeld */
.eingabe-rahmen { border: 1px solid var(--linie); border-radius: 14px; background: var(--bg); padding: 0; }
.eingabe-rahmen textarea { border: none; background: transparent; padding: 14px 16px 6px; min-height: 180px; font-size: 18px; }
.eingabe-rahmen textarea:focus-visible { outline: none; }
.eingabe-fuss { display: flex; justify-content: flex-end; padding: 4px 14px 10px; }
.start { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.optionen-schalter { background: none; border: none; color: var(--grau); font: inherit; font-size: 15px; cursor: pointer; padding: 6px 0; }
.optionen-schalter:hover { color: var(--text); }
.schaetzung { color: var(--grau); font-size: 14px; margin-top: 8px; }
.optionen { border-top: 1px solid var(--linie); margin-top: 14px; padding-top: 14px; }
.optionen h3 { margin: 10px 0 8px; font-size: 15px; color: var(--grau); text-transform: uppercase; letter-spacing: 0.5px; }

/* Fortschritt */
.balken { height: 14px; background: var(--linie); border-radius: 999px; overflow: hidden; }
.balken-innen { height: 100%; width: 0; background: var(--akzent); transition: width 0.6s; }
.meldung { margin: 10px 0 0; font-weight: 600; }
.protokoll { margin: 8px 0 0; padding: 0; list-style: none; color: var(--grau); font-size: 13px; max-height: 120px; overflow: auto; }

/* Liste der Bücher */
.liste { list-style: none; padding: 0; margin: 0; }
.liste li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--linie); }
.liste li:first-child { border-top: none; }
.liste img, .liste .l-bild { width: 54px; height: 72px; object-fit: cover; border-radius: 6px; background: var(--linie); flex: none; }
.liste .l-text { flex: 1; min-width: 0; }
.liste .l-titel { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.liste .l-klein { color: var(--grau); font-size: 14px; }
.zustand-fertig { color: var(--gruen); }
.zustand-fehler, .zustand-abgebrochen { color: var(--rot); }
.zustand-laeuft, .zustand-wartet, .zustand-pausiert, .zustand-wartet_auf_freigabe { color: var(--gelb); }

/* Referenzen / Vorschau */
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.raster figure { margin: 0; }
.raster img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; background: var(--linie); border: 1px solid var(--linie); }
.raster figcaption { font-size: 13px; color: var(--grau); margin-top: 4px; }
.raster .quadrat img { aspect-ratio: 1; }
.kapitelliste { margin: 0; padding-left: 20px; }
.kapitelliste li { margin-bottom: 6px; }
.kapitelliste input { width: 100%; }
.kapitelliste .hinweis { display: inline; margin: 0 0 0 6px; }

/* Laufende Aufgaben (Blatt oder Bild wird gerade gezeichnet) */
.laeuft-text { color: var(--gelb); }
.raster figure.laeuft img { opacity: 0.55; }

/* ===== Arbeitsansicht (Editor) ===== */
body.editor { overflow: hidden; height: 100vh; display: flex; flex-direction: column; }
.leiste { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--linie); background: var(--karte); flex-wrap: wrap; }
.leiste .titel { font-weight: 700; font-size: 18px; min-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 220px; }
.leiste .titel input { font: inherit; font-weight: 700; border: 1px solid transparent; background: transparent; color: var(--text); border-radius: 8px; padding: 4px 8px; width: 100%; }
.leiste .titel input:hover, .leiste .titel input:focus { border-color: var(--linie); background: var(--bg); }
.leiste select { width: auto; max-width: 150px; padding: 6px 10px; border-radius: 9px; font-size: 14px; }
.menue { position: relative; }
.menue-inhalt { position: absolute; right: 0; top: calc(100% + 6px); background: var(--karte); border: 1px solid var(--linie); border-radius: 12px; box-shadow: var(--schatten); padding: 8px; min-width: 260px; z-index: 30; display: none; }
.menue.offen .menue-inhalt { display: block; }
.menue-inhalt a, .menue-inhalt button { display: block; width: 100%; text-align: left; padding: 9px 10px; border: none; background: none; color: var(--text); font: inherit; font-size: 15px; border-radius: 8px; cursor: pointer; text-decoration: none; }
.menue-inhalt a:hover, .menue-inhalt button:hover { background: var(--akzent-hell); }
.menue-inhalt .hinweis { padding: 4px 10px 8px; }
.menue-inhalt .feld { padding: 6px 10px 0; margin-bottom: 4px; }
.menue-inhalt .feld label { font-size: 13px; margin-bottom: 4px; }
.menue-inhalt select { width: 100%; max-width: none; font-size: 14px; padding: 6px 8px; }
.arbeitsflaeche { flex: 1; display: flex; min-height: 0; }
.seitenband { flex: 1; overflow-x: auto; overflow-y: hidden; display: flex; align-items: flex-start; gap: 28px; padding: 22px 32px; scroll-snap-type: x proximity; }
.seite-huelle { flex: none; scroll-snap-align: center; position: relative; }
.seite-huelle .seitenlabel { text-align: center; color: var(--grau); font-size: 13px; margin-bottom: 6px; }
.buchseite { position: relative; background: var(--seite); box-shadow: var(--schatten); overflow: hidden; color: #111; }
.buchseite.aktiv { outline: 2px solid var(--akzent); }
.buchseite .zeile { position: absolute; white-space: nowrap; overflow: visible; }
.buchseite .zeile.blocksatz { white-space: nowrap; text-align: justify; text-align-last: justify; }
.buchseite .block-text { position: absolute; cursor: text; border-radius: 3px; }
.buchseite .block-text:hover { background: rgba(47, 111, 143, 0.08); }
.buchseite .block-text.markiert { background: rgba(47, 111, 143, 0.14); }
.buchseite .bild { position: absolute; cursor: pointer; border-radius: 2px; }
.buchseite .bild img { width: 100%; height: 100%; object-fit: fill; display: block; border-radius: 2px; }
.buchseite .bild.platzhalter { background: #ece9e1; display: flex; align-items: center; justify-content: center; color: #777; font-size: 11px; text-align: center; padding: 4px; }
.buchseite .bild.platzhalter.fehlgeschlagen { color: var(--rot); }
.seitenleiste .platzhalter-leiste { aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; color: var(--grau); font-size: 14px; }
.buchseite .bild.markiert { outline: 3px solid var(--akzent); }
.buchseite .bild .laeuft { position: absolute; inset: 0; background: rgba(255,255,255,0.7); display: flex; align-items: center; justify-content: center; font-size: 12px; color: #333; }
.buchseite .seitenzahl { position: absolute; text-align: center; }
.buchseite .inhalt-eintrag { position: absolute; display: flex; justify-content: space-between; white-space: nowrap; }
.buchseite textarea.inline-editor { position: absolute; font: inherit; border: 1px solid var(--akzent); border-radius: 4px; padding: 2px 3px; background: #fff; color: #111; resize: none; z-index: 5; box-shadow: var(--schatten); }
.plus { position: absolute; left: 50%; transform: translateX(-50%); width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--linie); background: var(--karte); color: var(--akzent); font-size: 18px; line-height: 22px; text-align: center; cursor: pointer; opacity: 0.55; z-index: 4; }
.plus:hover { opacity: 1; background: var(--akzent); color: #fff; }
.plus.zwischen-seiten { position: static; transform: none; margin-top: 60px; flex: none; align-self: flex-start; }
.block-werkzeug { position: absolute; right: 2px; top: -14px; display: none; gap: 2px; z-index: 6; }
.block-text:hover .block-werkzeug, .block-text.markiert .block-werkzeug, .bild.markiert .block-werkzeug { display: flex; }
.block-werkzeug button { width: 24px; height: 22px; border: 1px solid var(--linie); background: var(--karte); color: var(--text); border-radius: 6px; font-size: 12px; cursor: pointer; padding: 0; }
.block-werkzeug button:hover { background: var(--akzent-hell); }
.seitenleiste { width: 340px; flex: none; border-left: 1px solid var(--linie); background: var(--karte); overflow-y: auto; padding: 16px; display: none; }
.seitenleiste.offen { display: block; }
.seitenleiste h3 { margin: 0 0 10px; font-size: 17px; }
.seitenleiste .vorschau { width: 100%; border-radius: 10px; border: 1px solid var(--linie); background: var(--linie); }
.seitenleiste .versionen { display: flex; gap: 6px; flex-wrap: wrap; }
.seitenleiste .versionen img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; }
.seitenleiste .versionen img.aktiv { border-color: var(--akzent); }
.seitenleiste .schliessen { float: right; }
.befunde { margin: 0; padding-left: 18px; }
.befunde li { margin-bottom: 6px; font-size: 14px; }
.befunde .fehler { font-weight: 600; }
.statuszeile { padding: 6px 16px; border-top: 1px solid var(--linie); background: var(--karte); color: var(--grau); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; }
.dialog-hintergrund { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.dialog-hintergrund.offen { display: flex; }
.dialog { background: var(--karte); border-radius: 16px; padding: 20px; max-width: 520px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: var(--schatten); }
.dialog h3 { margin: 0 0 12px; }
.dragging { opacity: 0.4; }
.ziel-oben { box-shadow: 0 -3px 0 var(--akzent) inset; }
.verlaufsliste { list-style: none; padding: 0; margin: 0; max-height: 50vh; overflow: auto; }
.verlaufsliste li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--linie); font-size: 14px; }
@media (max-width: 760px) {
  .seitenleiste { position: fixed; right: 0; top: 0; bottom: 0; width: min(92vw, 360px); z-index: 40; box-shadow: var(--schatten); }
  .seitenband { padding: 14px; gap: 16px; }
}
