/* Das große Nölle-Wimmelbuch – warmes Papier, braune Tinte, wenige kräftige Farben. */
:root {
  color-scheme: light;
  --papier: #f6efe2; --papier2: #fffaf0; --flaeche: #fffdf8; --linie: #e3d6bf; --linie2: #cdbb9c;
  --tinte: #3d2b1f; --sub: #7a6553; --leise: #a8957f;
  --akzent: #c8553d; --akzent-tx: #fff; --akzent2: #2f7d6d; --gelb: #e9b949; --gelb-bg: #fbf0cf;
  --gefahr: #b4232a; --gefahr-bg: #fbe3df; --ok: #2f7d6d; --ok-bg: #dff0ea;
  --schatten: 0 1px 2px rgba(61, 43, 31, .08), 0 6px 18px rgba(61, 43, 31, .08);
  --r: 14px;
  --titel: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--papier); color: var(--tinte); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; min-height: 100vh; min-height: 100dvh; }
img { max-width: 100%; }
a { color: var(--akzent2); }
h1, h2, h3 { font-family: var(--titel); line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
.laedt { padding: 40px 16px; text-align: center; color: var(--sub); }
.hinweis { font-size: .86rem; color: var(--sub); margin: .3em 0 .8em; }
.leer { color: var(--leise); font-style: italic; }

/* Knöpfe + Felder */
button, .knopf {
  font: inherit; font-weight: 650; border: 1px solid var(--linie2); background: var(--flaeche); color: var(--tinte);
  border-radius: 999px; padding: 9px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; touch-action: manipulation; transition: background .15s, transform .1s;
}
button:hover { background: var(--papier2); }
button:active { transform: scale(.97); }
button:disabled { opacity: .55; cursor: default; transform: none; }
button.haupt { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-tx); }
button.haupt:hover { background: #b44a34; }
button.gruen { background: var(--akzent2); border-color: var(--akzent2); color: #fff; }
button.gefahr { color: var(--gefahr); border-color: #e6b3ad; }
button.gefahr.scharf { background: var(--gefahr); color: #fff; border-color: var(--gefahr); }
button.leise { border-color: transparent; background: transparent; color: var(--sub); }
button.klein, .knopf.klein { min-height: 32px; padding: 4px 11px; font-size: .86rem; }
button.rund { width: 40px; padding: 0; justify-content: center; }
label { display: block; font-size: .8rem; font-weight: 700; color: var(--sub); margin: 0 0 12px; }
input[type=text], input[type=password], textarea, select {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; color: var(--tinte);
  background: var(--papier2); border: 1px solid var(--linie2); border-radius: 10px; padding: 10px 12px; outline: none;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.4; }
input:focus, textarea:focus, select:focus { border-color: var(--akzent2); box-shadow: 0 0 0 3px rgba(47, 125, 109, .15); }
.reihe { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.reihe.zwischen { justify-content: space-between; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--papier); border: 1px solid var(--linie); color: var(--sub); white-space: nowrap; }
.chip.entwurf { background: var(--gelb-bg); border-color: #ecd48e; color: #7a5a06; }
.chip.laeuft { background: var(--ok-bg); border-color: #b5dacd; color: var(--ok); }
.chip.fehler { background: var(--gefahr-bg); border-color: #e6b3ad; color: var(--gefahr); }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r); box-shadow: var(--schatten); padding: 16px; }
.banner { border-radius: 12px; padding: 10px 14px; margin: 0 0 14px; font-size: .92rem; }
.banner.warn { background: var(--gelb-bg); border: 1px solid #ecd48e; }
.banner.fehler { background: var(--gefahr-bg); border: 1px solid #e6b3ad; }
.dreh { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: dreh .8s linear infinite; vertical-align: -2px; }
@keyframes dreh { to { transform: rotate(360deg); } }

/* Kopf */
#kopf { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; background: rgba(246, 239, 226, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--linie); }
.marke { display: flex; align-items: center; gap: 10px; color: var(--tinte); text-decoration: none; font-family: var(--titel); font-weight: 700; font-size: 1.15rem; }
.marke small { display: block; font-size: .7rem; color: var(--sub); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; line-height: 1; }
#kopf nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
#kopf nav a { padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--sub); font-weight: 650; font-size: .92rem; }
#kopf nav a.aktiv { background: var(--tinte); color: var(--papier); }
main { max-width: 1400px; margin: 0 auto; padding: 18px 16px 60px; }

/* Startseite (öffentlich) */
.start { min-height: calc(100dvh - 40px); display: grid; place-items: center; }
.start-inhalt { max-width: 860px; width: 100%; display: grid; gap: 28px; grid-template-columns: 1.2fr 1fr; align-items: center; }
.start-titel small { font-family: var(--titel); font-size: 1.1rem; color: var(--sub); display: block; }
.start-titel h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); margin: 0 0 .3em; }
.start-titel p { color: var(--sub); font-size: 1.05rem; max-width: 30em; }
.start-bild { width: 100%; max-width: 360px; }
@media (max-width: 720px) { .start-inhalt { grid-template-columns: 1fr; gap: 10px; } .start-bild { max-width: 110px; order: -1; } }
.fehlertext { display: none; background: var(--gefahr-bg); color: var(--gefahr); border-radius: 10px; padding: 8px 12px; font-weight: 650; font-size: .9rem; margin-bottom: 12px; }
.fehlertext.zeigen { display: block; }

/* Seitenübersicht */
.uebersicht-kopf { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.seiten { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.seitenkarte { position: relative; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--r); box-shadow: var(--schatten);
  overflow: hidden; cursor: pointer; transition: transform .15s, box-shadow .15s; user-select: none; -webkit-user-select: none; }
.seitenkarte:hover { transform: translateY(-2px); }
.seitenkarte.zieht { opacity: .4; }
.seitenkarte .vorschau { aspect-ratio: 3 / 2; background: var(--papier2) center / cover no-repeat; display: grid; place-items: center; color: var(--leise);
  border-bottom: 1px solid var(--linie); position: relative; }
.seitenkarte .vorschau img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-touch-callout: none; pointer-events: none; }
.seitenkarte .vorschau .falz { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: rgba(61, 43, 31, .14); }
.seitenkarte .nr { position: absolute; top: 8px; left: 8px; background: var(--tinte); color: var(--papier); border-radius: 999px; font-weight: 800;
  font-size: .78rem; padding: 2px 9px; z-index: 1; }
.seitenkarte .griff { position: absolute; top: 4px; right: 4px; z-index: 2; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(255, 253, 248, .9); color: var(--sub); cursor: grab; touch-action: none; font-size: 1.1rem; border: 1px solid var(--linie); }
.seitenkarte .info { padding: 10px 12px 12px; }
.seitenkarte h3 { margin: 0 0 6px; }
.seitenkarte .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.platzhalter-seite { font-family: var(--titel); font-size: 2.4rem; opacity: .5; }
.zieh-geist { position: fixed; z-index: 100; pointer-events: none; opacity: .92; transform: rotate(2deg); box-shadow: 0 16px 40px rgba(0, 0, 0, .25); }

/* Editor */
.editor-kopf { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.editor-kopf h1 { margin: 0; flex: 1 1 200px; cursor: text; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .editor { grid-template-columns: 1fr; } }
.editor > * { min-width: 0; }
.buehne-karte { padding: 12px; }
.werkzeuge { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.werkzeuge .gruppe { display: inline-flex; border: 1px solid var(--linie2); border-radius: 999px; overflow: hidden; }
.werkzeuge .gruppe button { border: 0; border-radius: 0; min-height: 38px; }
.werkzeuge .gruppe button.an { background: var(--tinte); color: var(--papier); }
.werkzeuge input[type=range] { width: 90px; }
.buehne { position: relative; background: var(--papier2); border-radius: 10px; overflow: hidden; border: 1px solid var(--linie); min-height: 200px;
  display: grid; place-items: center; }
.buehne img.seite { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.buehne canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.buehne canvas.zeichnen { touch-action: none; cursor: crosshair; }
.buehne .falz { position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1px dashed rgba(61, 43, 31, .25); pointer-events: none; }
.buehne .ueberlagerung { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(246, 239, 226, .78); text-align: center; padding: 20px;
  font-weight: 650; }
.leere-buehne { padding: 50px 20px; text-align: center; color: var(--sub); }
.versionen { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 4px; scroll-snap-type: x proximity; }
.version { flex: 0 0 auto; width: 118px; scroll-snap-align: start; border: 2px solid transparent; border-radius: 10px; background: var(--papier2); padding: 4px;
  cursor: pointer; text-align: left; font-size: .74rem; color: var(--sub); display: block; min-height: 0; font-weight: 500; line-height: 1.3; }
.version.gewaehlt { border-color: var(--akzent2); }
.version .bildchen { aspect-ratio: 3 / 2; border-radius: 6px; background: var(--linie) center / cover; display: grid; place-items: center; overflow: hidden; }
.version .bildchen img { width: 100%; height: 100%; object-fit: cover; display: block; }
.version b { color: var(--tinte); }
.version .aktuell { color: var(--akzent); font-weight: 800; }
.versionsinfo { margin-top: 10px; font-size: .9rem; }
.versionsinfo dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 8px 0; }
.versionsinfo dt { font-weight: 700; color: var(--sub); }
.versionsinfo dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.seitenleiste { display: grid; gap: 14px; }
.seitenleiste .karte h2 { margin-bottom: 8px; }
details.karte > summary { cursor: pointer; font-family: var(--titel); font-weight: 700; font-size: 1.1rem; list-style: none; }
details.karte > summary::-webkit-details-marker { display: none; }
details.karte > summary::after { content: "▾"; float: right; color: var(--leise); }
details.karte:not([open]) > summary::after { content: "▸"; }
details.karte[open] > summary { margin-bottom: 10px; }
.markliste { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 8px; }
.markliste li { display: grid; grid-template-columns: 28px 1fr 36px; gap: 8px; align-items: start; border-radius: 10px; padding: 6px; border: 1px solid var(--linie); }
.markliste li.gewaehlt { border-color: var(--akzent); background: #fdf2ee; }
.markliste .num { width: 26px; height: 26px; border-radius: 50%; background: var(--akzent); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: .82rem; }
.markliste textarea { min-height: 44px; margin: 0; padding: 7px 9px; font-size: 15px; }
.schalter { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 600; color: var(--tinte); margin: 8px 0; }
.schalter input { width: 20px; height: 20px; accent-color: var(--akzent2); }
.refwahl { display: grid; gap: 10px; max-height: 360px; overflow: auto; padding-right: 4px; }
.refwahl .gruppe-titel { font-size: .78rem; font-weight: 800; color: var(--sub); text-transform: uppercase; letter-spacing: .05em; display: flex; justify-content: space-between; align-items: center; }
.refwahl .liste { display: flex; flex-wrap: wrap; gap: 6px; }
.refknopf { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; border: 1px solid var(--linie2); background: var(--flaeche);
  cursor: pointer; font-size: .86rem; font-weight: 600; min-height: 36px; }
.refknopf.an { background: var(--ok-bg); border-color: var(--akzent2); color: var(--ok); }
.refknopf .av, .av { width: 28px; height: 28px; border-radius: 50%; background: var(--linie) center / cover; display: inline-grid; place-items: center; font-size: .9rem; flex: 0 0 auto; overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.fotoliste { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.foto { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--linie); background: var(--papier2); }
.foto img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.foto.aus img { opacity: .35; filter: grayscale(1); }
.foto .leiste { display: flex; justify-content: space-between; padding: 2px; }
.foto .leiste button { min-height: 30px; width: 30px; padding: 0; justify-content: center; font-size: .85rem; }
.foto .notiz { font-size: .72rem; padding: 0 6px 6px; color: var(--sub); overflow-wrap: anywhere; }
.foto .haupt-mark { position: absolute; top: 4px; left: 4px; background: var(--gelb); color: var(--tinte); border-radius: 999px; font-size: .68rem; font-weight: 800; padding: 1px 7px; }
.datei-knopf { position: relative; overflow: hidden; }
.datei-knopf input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }

/* Vergleich */
.dialog-hg { position: fixed; inset: 0; background: rgba(40, 28, 20, .55); z-index: 50; display: grid; place-items: center; padding: 12px; }
.dialog { background: var(--flaeche); border-radius: 16px; width: min(1200px, 100%); max-height: 96dvh; overflow: auto; padding: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.dialog.schmal { width: min(560px, 100%); }
.vergleich { position: relative; overflow: hidden; border-radius: 10px; background: var(--papier2); touch-action: none; user-select: none; }
.vergleich img { display: block; width: 100%; height: auto; pointer-events: none; }
.vergleich .oben { position: absolute; inset: 0; overflow: hidden; }
.vergleich .oben img { width: 100%; height: 100%; object-fit: fill; }
.vergleich .strich { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; box-shadow: 0 0 6px rgba(0, 0, 0, .5); transform: translateX(-1px); pointer-events: none; }
.vergleich .strich::after { content: "◀ ▶"; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: #fff; border-radius: 999px;
  padding: 4px 8px; font-size: .7rem; white-space: nowrap; color: var(--tinte); }
.vergleich .etikett { position: absolute; top: 8px; background: rgba(61, 43, 31, .8); color: #fff; font-size: .75rem; font-weight: 700; border-radius: 999px; padding: 2px 10px; }

/* Bibliothek */
.familien { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 26px; }
.familie h2 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.familie .beschreibung { color: var(--sub); font-size: .9rem; margin: -2px 0 10px; }
.baum { display: grid; gap: 10px; }
.baum .rolle { display: grid; grid-template-columns: 110px 1fr; gap: 8px; align-items: start; }
.baum .rolle > span { font-size: .78rem; font-weight: 800; color: var(--sub); text-transform: uppercase; letter-spacing: .05em; padding-top: 7px; }
.baum .rolle > span::after { content: " →"; color: var(--leise); }
.mitglieder { display: flex; flex-wrap: wrap; gap: 6px; }
.mitglied { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px 3px 3px; border-radius: 999px; background: var(--papier2); border: 1px solid var(--linie);
  cursor: pointer; font-weight: 600; font-size: .9rem; min-height: 36px; }
.mitglied:hover { border-color: var(--linie2); }
.einzel { display: flex; flex-wrap: wrap; gap: 8px; }
.segment { display: inline-flex; border: 1px solid var(--linie2); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.segment button { border: 0; border-radius: 0; min-height: 38px; font-weight: 600; }
.segment button.an { background: var(--tinte); color: var(--papier); }
.mitgliedschaft { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--linie); }
.mitgliedschaft select { margin: 0; width: auto; padding: 6px 8px; }

#toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 30px); opacity: 0; transition: .25s; z-index: 200; background: var(--tinte); color: var(--papier);
  padding: 10px 18px; border-radius: 999px; font-weight: 650; max-width: calc(100% - 32px); text-align: center; pointer-events: none; }
#toast.zeigen { opacity: 1; transform: translate(-50%, 0); }
#toast.fehler { background: var(--gefahr); color: #fff; }
@media (max-width: 600px) {
  main { padding: 12px 12px 60px; }
  #kopf { padding: 8px 12px; }
  #kopf nav a { padding: 6px 9px; font-size: .85rem; }
  #kopf nav .lang { display: none; }
  #abmelden { min-height: 32px; padding: 4px 8px; font-size: .85rem; }
  .baum .rolle { grid-template-columns: 1fr; }
  .baum .rolle > span { padding-top: 0; }
  .werkzeuge .gruppe button { padding: 6px 10px; font-size: .88rem; }
  .seiten { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}
