:root {
  --grund: #f6f4ef; --karte: #fff; --text: #1f1d1a; --leise: #6b665e; --linie: #e2ddd3;
  --akzent: #2f6f5e; --akzent-text: #fff; --fehler: #b3261e; --orange: #f08c00; --ok: #2b8a3e;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--grund); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1, h2 { margin: 0 0 .6rem; line-height: 1.2; }
h2 { font-size: 1.1rem; }
small { font-weight: normal; }
.leise { color: var(--leise); }
.fehler { color: var(--fehler); }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: .6rem .7rem; border: 1px solid var(--linie);
  border-radius: 8px; background: #fff; min-height: 44px; }
textarea { resize: vertical; }
button, .knopf-datei { padding: .6rem 1rem; border: 1px solid var(--linie); border-radius: 8px;
  background: #fff; cursor: pointer; min-height: 44px; white-space: nowrap; }
button:hover { border-color: #bdb5a6; }
button:disabled { opacity: .5; cursor: default; }
button.primaer { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
button.still { background: transparent; border-color: transparent; color: var(--leise); }
.knopf-datei { display: inline-block; }
.knopf-datei input { display: none; }

.kopf { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; display: flex; gap: .5rem;
  align-items: center; padding: .5rem max(1rem, env(safe-area-inset-left)); background: #fffdf8;
  border-bottom: 1px solid var(--linie); flex-wrap: wrap; }
.marke { font-weight: 700; margin-right: auto; }
.reiter { display: flex; gap: .25rem; order: 3; width: 100%; overflow-x: auto; }
.reiter button { flex: 1; border: 0; background: transparent; border-bottom: 3px solid transparent; border-radius: 0; }
.reiter button.aktiv { border-bottom-color: var(--akzent); font-weight: 600; }
@media (min-width: 760px) { .reiter { order: 0; width: auto; } .reiter button { flex: none; } }

main { max-width: 1400px; margin: 0 auto; padding: 1rem; }
.karte { background: var(--karte); border: 1px solid var(--linie); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.zeile { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.zeile > input, .zeile > select { flex: 1 1 220px; }
.stapel { display: grid; gap: .6rem; }
.feld { display: block; margin: .6rem 0; font-weight: 600; }
.feld .zeile { margin-top: .3rem; font-weight: normal; }
.schalter { display: flex; gap: .6rem; align-items: center; margin: .6rem 0; cursor: pointer; }
.schalter input { width: 22px; height: 22px; min-height: 0; flex: none; }
.knoepfe { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.knoepfe.rechts { justify-content: flex-end; }
.banner { background: #fff4e0; border: 1px solid #f3c77a; border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; }
.statistik { display: flex; gap: .4rem; flex-wrap: wrap; margin: .4rem 0; }
.statistik span { background: var(--grund); border-radius: 99px; padding: .15rem .6rem; font-size: .85rem; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-karte { width: min(380px, 100%); display: grid; gap: .8rem; }

.themen { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); margin-top: 1rem; }
.thema { border: 1px solid var(--linie); border-radius: 10px; padding: .8rem; display: grid; gap: .5rem; align-content: space-between; }
.thema b { display: block; }

.galerie { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.seite { background: var(--karte); border: 2px solid var(--linie); border-radius: 12px; padding: .6rem; display: grid; gap: .45rem; align-content: start; }
.seite.auffaellig { border-color: var(--orange); box-shadow: 0 0 0 2px var(--orange); }
.seite.fehler { border-color: var(--fehler); }
.seite .vorschau { aspect-ratio: 1; background: #faf9f6; border-radius: 8px; display: grid; place-items: center;
  overflow: hidden; border: 1px solid var(--linie); }
.seite .vorschau img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.seite .kopfzeile { display: flex; justify-content: space-between; gap: .4rem; align-items: baseline; }
.seite .titel { font-weight: 600; }
.seite textarea { font-size: .88rem; min-height: 7.5em; }
.seite .hinweis { font-size: .82rem; }
.marke-status { font-size: .78rem; border-radius: 99px; padding: .1rem .55rem; background: var(--grund); white-space: nowrap; }
.marke-status.fertig { background: #e6f4ea; color: var(--ok); }
.marke-status.wartet, .marke-status.laeuft { background: #e7eefc; color: #1d4ed8; }
.marke-status.fehler { background: #fde8e7; color: var(--fehler); }
.marke-status.auffaellig { background: #fff0db; color: #a35a00; }

.vorlagen { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem; margin-bottom: .8rem; }
.vorlage { position: relative; border: 1px solid var(--linie); border-radius: 8px; overflow: hidden; aspect-ratio: 1; background: #fff; }
.vorlage img { width: 100%; height: 100%; object-fit: contain; }
.vorlage button { position: absolute; top: 4px; right: 4px; min-height: 0; padding: .1rem .5rem; background: #fffc; }

dialog { border: 0; border-radius: 12px; padding: 1rem; max-width: min(520px, calc(100vw - 2rem)); }
dialog::backdrop { background: #0008; }
.bildfenster { max-width: min(96vw, 1100px); width: 100%; position: relative; }
.bildfenster img { width: 100%; height: auto; max-height: 80vh; object-fit: contain; display: block; }
.schliessen { position: absolute; top: .3rem; right: .3rem; min-height: 0; font-size: 1.4rem; line-height: 1; padding: .2rem .6rem; }

.laden { position: fixed; inset: 0; background: #0006; display: grid; place-items: center; z-index: 20; padding: 1rem; }
.laden .karte { text-align: center; max-width: 360px; }
.kreisel { width: 36px; height: 36px; border: 4px solid var(--linie); border-top-color: var(--akzent);
  border-radius: 50%; margin: 0 auto .6rem; animation: drehen 1s linear infinite; }
.seite .kreisel { width: 28px; height: 28px; margin: 0; }
@keyframes drehen { to { transform: rotate(360deg); } }
.meldung { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  background: #1f1d1a; color: #fff; padding: .7rem 1rem; border-radius: 10px; z-index: 30; max-width: calc(100vw - 2rem); }
.meldung.fehler { background: var(--fehler); color: #fff; }

.zahlen { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.zahlen label { font-weight: 600; font-size: .9rem; }
.promptfeld textarea { font: 14px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; min-height: 9em; }
.promptfeld .zweck { margin: .1rem 0 .5rem; }
.promptfeld .platzhalter code { background: var(--grund); border-radius: 4px; padding: 0 .3rem; }
.promptfeld.geaendert { border-color: var(--akzent); }
.promptfeld .feldkopf { display: flex; justify-content: space-between; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.speicherleiste { position: sticky; bottom: calc(.5rem + env(safe-area-inset-bottom, 0px)); z-index: 4; display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; box-shadow: 0 4px 18px #0002; }
.prompttext { white-space: pre-wrap; word-break: break-word; background: var(--grund); border-radius: 8px; padding: .8rem; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 50vh; overflow: auto; }
.versionen { display: grid; gap: .4rem; }
.version { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; border-bottom: 1px solid var(--linie); padding: .4rem 0; }
.version .info { flex: 1 1 240px; }
.textfenster { max-width: min(900px, calc(100vw - 2rem)); width: 100%; position: relative; }
.seite .promptlink { font-size: .8rem; background: none; border: 0; padding: 0; min-height: 0; color: var(--akzent); text-decoration: underline; justify-self: start; }
#d-frage-text { white-space: pre-wrap; }
.textfenster h3 { font-size: .95rem; margin: 1rem 0 .3rem; }

/* ---------- Themen-Bibliothek ---------- */
.unterreiter { display: inline-flex; gap: .25rem; background: #ece8df; border-radius: 10px; padding: .25rem; margin-bottom: 1rem; max-width: 100%; overflow-x: auto; }
.unterreiter button { border: 0; background: transparent; border-radius: 8px; min-height: 38px; }
.unterreiter button.aktiv { background: #fff; box-shadow: 0 1px 3px #0001; font-weight: 600; }
.zahl { display: inline-block; min-width: 1.6em; padding: 0 .4em; border-radius: 99px; background: var(--grund); font-size: .8rem; font-weight: 600; text-align: center; }
.bib { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 860px) { .bib { grid-template-columns: 230px 1fr; align-items: start; } .bib-leiste { position: sticky; top: calc(4rem + env(safe-area-inset-top, 0px)); } }
.bib-leiste { background: var(--karte); border: 1px solid var(--linie); border-radius: 12px; padding: .5rem; min-width: 0; }
.bib-filter, .bib-ordner { display: grid; gap: 2px; }
.bib-eintrag { display: flex; align-items: center; gap: .4rem; width: 100%; border: 0; background: transparent; text-align: left; border-radius: 8px; padding: .45rem .6rem; min-height: 40px; cursor: pointer; }
.bib-eintrag:hover { background: var(--grund); }
.bib-eintrag.aktiv { background: #e6f0ec; color: var(--akzent); font-weight: 600; }
.bib-eintrag .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bib-eintrag .zahl { background: transparent; color: var(--leise); }
.bib-eintrag.ziel { outline: 2px dashed var(--akzent); background: #e6f0ec; }
.bib-eintrag .menue { border: 0; background: transparent; min-height: 0; padding: .1rem .4rem; color: var(--leise); }
.bib-ordner .bib-eintrag[draggable="true"] { cursor: grab; }
.bib-ordner .bib-eintrag.zieht { opacity: .4; }
.bib-ordnerkopf { display: flex; justify-content: space-between; align-items: center; margin: .6rem .6rem .2rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--leise); }
button.klein { min-height: 0; padding: .2rem .5rem; font-size: .85rem; }
@media (max-width: 859px) {
  .bib-filter, .bib-ordner { display: flex; overflow-x: auto; gap: .3rem; padding-bottom: .2rem; }
  .bib-eintrag { width: auto; flex: none; border: 1px solid var(--linie); border-radius: 99px; min-height: 38px; }
  .bib-ordnerkopf { margin: .5rem .2rem .3rem; }
}
.bib-haupt { min-width: 0; }
.bib-werkzeug { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.bib-werkzeug input { flex: 1 1 240px; }
.bib-werkzeug select { flex: 0 1 200px; }
.bib-info { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; flex-wrap: wrap; }
.bib-sammel { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; background: #e6f0ec; border: 1px solid #b9d6cb; border-radius: 10px; padding: .5rem .7rem; margin-bottom: .6rem; position: sticky; top: calc(3.6rem + env(safe-area-inset-top, 0px)); z-index: 3; }
.bib-sammel select { width: auto; flex: 0 1 220px; }
.bib-karten { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.bib-karte { background: var(--karte); border: 1px solid var(--linie); border-radius: 12px; padding: .8rem; display: grid; gap: .45rem; align-content: start; }
.bib-karte.gewaehlt { border-color: var(--akzent); box-shadow: 0 0 0 1px var(--akzent); }
.bib-karte[draggable="true"] { cursor: grab; }
.bib-karte.zieht { opacity: .4; }
.bib-karte .kopf2 { display: flex; gap: .5rem; align-items: flex-start; }
.bib-karte .kopf2 input[type=checkbox] { width: 20px; height: 20px; min-height: 0; margin: .15rem 0 0; flex: none; }
.bib-karte .titel { flex: 1; font-weight: 600; line-height: 1.3; }
.stern { border: 0; background: transparent; min-height: 0; padding: 0 .2rem; font-size: 1.35rem; line-height: 1; color: #c4bdaf; }
.stern.an { color: #e0a100; }
.bib-karte .meta { font-size: .8rem; color: var(--leise); display: flex; gap: .3rem .7rem; flex-wrap: wrap; }
.bib-karte .notiz { font-size: .88rem; background: #fbf8f1; border-left: 3px solid #e6dcc6; padding: .3rem .5rem; border-radius: 4px; white-space: pre-wrap; }
.verwendet { font-size: .82rem; color: var(--ok); }
.verwendet a { color: var(--ok); }
.bib-karte .aktionen { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: .2rem; }
.bib-karte .aktionen select { width: auto; flex: 1 1 130px; min-height: 40px; padding: .4rem; }
.bib-karte .aktionen button { min-height: 40px; padding: .4rem .7rem; }
.bib-leer { text-align: center; color: var(--leise); padding: 2rem 1rem; border: 1px dashed var(--linie); border-radius: 12px; }
.ordner-menue { display: grid; gap: .4rem; min-width: 220px; }

/* Korrekturen Leiste/Handy */
.bib-eintrag .name { min-width: 0; }
.bib-eintrag .zahl, .bib-eintrag .menue { flex: none; }
.nebenaktionen { display: flex; gap: .2rem; flex-wrap: wrap; margin-top: -.2rem; }
.nebenaktionen button { color: var(--leise); }
.bib-karte .aktionen .primaer { flex: none; }
.bib-karte.hervor { animation: hervor 2.4s ease-out; }
@keyframes hervor { 0%, 40% { box-shadow: 0 0 0 3px var(--orange); } 100% { box-shadow: none; } }
@media (max-width: 520px) {
  .reiter button { padding-left: .55rem; padding-right: .55rem; }
  .bib-karte { padding: .65rem; gap: .35rem; }
  .bib-karten { grid-template-columns: 1fr; }
}
/* Projekt-Übersicht */
.pu-karten { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.bib-karte { min-width: 0; }
.pu-karte { padding: 0; overflow: hidden; display: flex; flex-direction: column; gap: 0; }
.pu-karte .bildflaeche { position: relative; display: block; width: 100%; aspect-ratio: 16 / 10; overflow: hidden; background: #faf9f6; border-bottom: 1px solid var(--linie); cursor: pointer; flex: none; }
.pu-karte .bildflaeche img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center 35%; }
.pu-karte .bildflaeche > span.leise { position: absolute; inset: 0; display: grid; place-items: center; font-size: .9rem; }
.pu-karte .inhalt { min-width: 0; }
.pu-karte .meta span { min-width: 0; overflow-wrap: anywhere; }
.pu-karte .bildflaeche .auswahl { position: absolute; top: .5rem; left: .5rem; width: 22px; height: 22px; min-height: 0; margin: 0; }
.pu-karte .bildflaeche .stern { position: absolute; top: .3rem; right: .4rem; background: #fffc; border-radius: 99px; padding: .1rem .35rem; }
.pu-karte .inhalt { padding: .7rem .8rem .8rem; display: grid; gap: .4rem; }
.pu-karte .titelzeile { display: flex; gap: .5rem; align-items: flex-start; justify-content: space-between; }
.pu-karte .titel { font-weight: 600; line-height: 1.3; }
.etikett { font-size: .75rem; border-radius: 99px; padding: .12rem .55rem; white-space: nowrap; font-weight: 600; }
.etikett.in_arbeit { background: #e7eefc; color: #1d4ed8; }
.etikett.fertig { background: #e6f4ea; color: var(--ok); }
.etikett.hochgeladen { background: #fff0db; color: #a35a00; }
.etikett.veroeffentlicht { background: #f1e8fb; color: #6b2fb3; }
.etikett.pdf { background: #ecebe7; color: #4b4740; font-weight: 500; }
.fortschritt { height: 6px; border-radius: 99px; background: #ece8df; overflow: hidden; }
.fortschritt span { display: block; height: 100%; background: var(--akzent); }
.pu-karte .zahlen-zeile { font-size: .82rem; color: var(--leise); display: flex; gap: .3rem .8rem; flex-wrap: wrap; }
.pu-karte .zahlen-zeile .warn { color: #a35a00; }
.pu-karte .aktionen select { flex: 1 1 120px; }
.bib-filter, .bib-ordner { grid-template-columns: minmax(0, 1fr); }
.pu-karte a { color: var(--akzent); }
.klein-text { font-size: .85rem; margin: .6rem 0 0; }

/* Stilvorlagen pro Projekt */
.pv-zeile { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .3rem; font-weight: normal; }
.pv-vorschau { display: flex; gap: .3rem; flex-wrap: wrap; }
.pv-vorschau img { width: 46px; height: 46px; object-fit: cover; border: 1px solid var(--linie); border-radius: 6px; background: #fff; }
.pv-modus { display: grid; gap: .4rem; margin: .4rem 0 .8rem; }
.pv-modus label { display: flex; gap: .5rem; align-items: center; cursor: pointer; }
.pv-modus input { width: 20px; height: 20px; min-height: 0; flex: none; }
.pv-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; margin: .4rem 0 .8rem; }
.pv-raster.aus { opacity: .45; pointer-events: none; }
.pv-kachel { position: relative; border: 2px solid var(--linie); border-radius: 8px; overflow: hidden; aspect-ratio: 1; background: #fff; cursor: pointer; display: block; }
.pv-kachel.an { border-color: var(--akzent); box-shadow: 0 0 0 1px var(--akzent); }
.pv-kachel img { width: 100%; height: 100%; object-fit: contain; }
.pv-kachel input { position: absolute; top: 5px; left: 5px; width: 20px; height: 20px; min-height: 0; margin: 0; }
.pv-kachel .weg { position: absolute; top: 3px; right: 3px; min-height: 0; padding: .05rem .45rem; background: #fffd; }
.pv-kachel .art { position: absolute; bottom: 0; left: 0; right: 0; font-size: .7rem; background: #fffd; text-align: center; padding: 1px; }
.linkzeile { display: flex; gap: .9rem; flex-wrap: wrap; }
.sammlung { border: 1px solid var(--linie); border-radius: 10px; padding: .7rem; }
.sammlung .kopf3 { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.sammlung .vorlagen { margin: .5rem 0; }
.pv-modus select { width: auto; min-height: 36px; padding: .2rem .5rem; }
