:root {
  --bg: #1c1c17;
  --bg-leiste: #201f19;
  --karte: #26251e;
  --karte-rand: #38372d;
  --rand: #3a3930;
  --text: #ece7d9;
  --text-schwach: #9a9586;
  --akzent: #c3af78;
  --akzent-dunkel: #8f7d4e;
  --akzent-glas: rgba(195, 175, 120, 0.12);
  --papier: #f1ece0;
  --fehler-bg: #4a2f24;
  --fehler-text: #f0c9a8;
  --schnittkante: #d1594a;
  --gruen-leer: #4f6b52;
}

* { box-sizing: border-box; }

/* Das hidden-Attribut muss IMMER wirken, auch wenn eine eigene Regel sonst
   display:flex/grid auf dasselbe Element setzt (sonst bleiben versteckte
   Elemente wie das Zuschneiden-Modal oder "Bild hierher hochladen" sichtbar –
   schon zweimal als echter Fehler aufgetreten, siehe PLAN.md). */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1, h2 { margin: 0; }

.kopfzeile {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--bg-leiste);
  border-bottom: 1px solid var(--rand);
}

.kopfzeile-titel {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kopfzeile h1 { font-size: 1.3rem; }
.kopfzeile-untertitel {
  margin: 0;
  color: var(--text-schwach);
  font-size: 0.85rem;
}
.kopfzeile-drucken { margin-left: auto; }

.btn {
  background: #3a3930;
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn:hover:not(:disabled) { background: #46453a; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-akzent {
  background: var(--akzent);
  color: #211f17;
  border-color: var(--akzent-dunkel);
  font-weight: 600;
}
.btn-akzent:hover:not(:disabled) { background: #d3c08c; }

.btn-klein {
  background: #3a3930;
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: 5px;
  padding: 4px 9px;
  font-size: 0.8rem;
  cursor: pointer;
}
.btn-klein:hover:not(:disabled) { background: #46453a; }
.btn-klein:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-breit { width: 100%; }
.btn-mit-abstand { margin-top: 14px; }

.button-reihe {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}
.button-reihe .btn { flex: 1; }

.meldung {
  margin: 0;
  padding: 10px 24px;
  background: var(--fehler-bg);
  color: var(--fehler-text);
  font-size: 0.9rem;
}

.hauptbereich {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  padding: 20px 24px;
  align-items: start;
}

.karte {
  background: var(--karte);
  border: 1px solid var(--karte-rand);
  border-radius: 10px;
  padding: 16px;
}

.karte-hervorgehoben {
  border-color: var(--akzent-dunkel);
  box-shadow: 0 0 0 1px var(--akzent-glas);
}

.seitenleiste {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.seitenleiste h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-schwach);
  margin-bottom: 12px;
}

.schritt-nr {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--akzent);
  color: #211f17;
  font-size: 0.7rem;
  font-weight: 700;
}

.hinweis-inline {
  text-transform: none;
  letter-spacing: normal;
  font-weight: normal;
  color: var(--text-schwach);
  font-size: 0.75rem;
  margin-left: auto;
}

.seitenleiste label, .vorschau-bereich label {
  display: block;
  font-size: 0.85rem;
  margin: 12px 0 8px;
  color: var(--text-schwach);
}

select {
  width: 100%;
  background: var(--bg-leiste);
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.9rem;
}

.eingabe-zeile {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.eingabe-mit-einheit {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-leiste);
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 8px;
}

.eingabe-mit-einheit input {
  background: transparent;
  border: none;
  color: var(--text);
  width: 100%;
  font-size: 0.95rem;
  min-width: 0;
}
.eingabe-mit-einheit input:focus { outline: none; }
.eingabe-mit-einheit span { color: var(--text-schwach); font-size: 0.8rem; white-space: nowrap; }

.hinweis {
  font-size: 0.8rem;
  color: var(--text-schwach);
  margin: 6px 0 0;
}

.button-gruppe {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.button-gruppe button {
  background: var(--bg-leiste);
  color: var(--text);
  border: 1px solid var(--rand);
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}
.button-gruppe button.aktiv {
  background: var(--akzent);
  color: #211f17;
  border-color: var(--akzent-dunkel);
  font-weight: 600;
}

.checkbox-zeile {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text);
  cursor: pointer;
  margin-top: 10px;
}
.checkbox-zeile input { margin-top: 3px; flex-shrink: 0; }

.bilder-liste {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.bild-eintrag {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-leiste);
  border: 1px solid var(--rand);
  border-radius: 6px;
  padding: 6px;
}

.bild-eintrag.aktiv {
  border-color: var(--akzent);
  background: var(--akzent-glas);
}

.bild-eintrag-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  padding: 4px;
}

.bild-nr {
  background: var(--rand);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.bild-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.statistik {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 10px;
  margin: 0;
  font-size: 0.88rem;
}
.statistik dt { color: var(--text-schwach); }
.statistik dd { margin: 0; font-weight: 600; text-align: right; }

.vorschau-bereich { min-width: 0; }

.vorschau-kopf {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.blaetter-navigation { display: flex; gap: 8px; }

.schnitt-hinweis {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.legende-punkt {
  display: inline-block;
  width: 18px;
  height: 2px;
  border-top: 2px dashed var(--schnittkante);
}

/* Einzelseiten-Vorschau: ein A6-Feld auf einmal, wie beim Durchblättern des
   fertigen Hefts (siehe PLAN.md, "Seite für Seite durchblättern"). */
.seiten-karte {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  background: var(--papier);
  border: 1px solid var(--akzent-dunkel);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

.seiten-karte.umschlag {
  background: repeating-linear-gradient(135deg, #201f19, #201f19 10px, #26251e 10px, #26251e 20px);
  border-color: var(--rand);
  cursor: default;
}

/* Spiegel-Vorschau für die Rückseite, falls der Drucker seitenverkehrt ausgibt */
.seiten-karte.gespiegelt { transform: scaleX(-1); }
.seiten-karte.gespiegelt .feld-bild-huelle,
.seiten-karte.gespiegelt .seiten-platzhalter,
.seiten-karte.gespiegelt .feld-chip { transform: scaleX(-1); }

.feld-chip {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  display: inline-block;
  background: #26251e;
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 600;
}

.seiten-platzhalter {
  color: var(--text-schwach);
  font-size: 0.95rem;
  text-align: center;
  font-style: italic;
  line-height: 1.5;
}

#feld-leer-ansicht {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.seiten-karte:has(#feld-leer-ansicht:not([hidden])) { cursor: pointer; }

.feld-bild-huelle {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Nur noch für die Druckansicht gebraucht: eine Zelle im echten A4-Layout. */
.a6-feld {
  background: var(--papier);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ausschnitt-rahmen {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  overflow: hidden;
}

.ausschnitt-rahmen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.feld-chip {
  display: inline-block;
  background: var(--akzent);
  color: #211f17;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 12px;
}

.feld-dateiname {
  font-size: 0.85rem;
  color: var(--text);
  overflow-wrap: break-word;
  margin: 0;
}

/* Druckansicht: unsichtbar am Bildschirm, einzige sichtbare Sache beim Drucken */
.druck-bereich { display: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.modal-inhalt {
  background: var(--bg-leiste);
  border: 1px solid var(--rand);
  border-radius: 8px;
  padding: 20px;
  width: 380px;
}

.zuschnitt-aussenrahmen {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.zuschnitt-rahmen {
  width: 100%;
  max-height: 320px;
  aspect-ratio: 105 / 148;
  overflow: hidden;
  background: #000;
  cursor: grab;
}

.zuschnitt-rahmen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

#zuschnitt-skalierung { width: 100%; }

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

@media print {
  #app, #meldung, .modal { display: none !important; }

  .druck-bereich { display: block; }

  .druck-seite {
    display: grid;
    page-break-after: always;
  }

  .druck-seite.gespiegelt { transform: scaleX(-1); }
  .druck-seite.gespiegelt .feld-bild-huelle { transform: scaleX(-1); }
}

@media (max-width: 1100px) {
  .hauptbereich { grid-template-columns: 1fr; }
}
