:root {
  --bg: #f4f1ea;
  --paper: #fffdf8;
  --ink: #2a2723;
  --muted: #8a8377;
  --accent: #6b4f2a;
  --border: #e2dccf;
}

* { box-sizing: border-box; }

/* Muss display:flex etc. schlagen, sonst wird das hidden-Attribut ignoriert. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.6;
}

/* ── Kopfzeile ─────────────────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  font-family: system-ui, sans-serif;
  font-size: .9rem;
}
#topbar .spacer { flex: 1; }
#userLabel { color: var(--muted); font-size: .82rem; }

/* ── Views ─────────────────────────────────────────────────────────────── */
.view { max-width: 46rem; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  margin-top: 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.card h1 { margin: 0; font-size: 1.5rem; }
label { display: flex; flex-direction: column; gap: .3rem; font-family: system-ui, sans-serif; font-size: .85rem; color: var(--muted); }
input {
  font: inherit;
  font-family: system-ui, sans-serif;
  padding: .6rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
button {
  font-family: system-ui, sans-serif;
  font-size: .9rem;
  padding: .6rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:disabled { opacity: .6; cursor: default; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
.muted { color: var(--muted); }
.error { color: #a33; font-family: system-ui, sans-serif; font-size: .85rem; margin: 0; }

/* ── Bibliothek ────────────────────────────────────────────────────────── */
.book-list { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); }
.book-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.book-card:hover { border-color: var(--accent); }
.book-card .title { font-size: 1.1rem; }
.book-card .meta { font-family: system-ui, sans-serif; font-size: .8rem; color: var(--muted); }

/* ── Reader ────────────────────────────────────────────────────────────── */
#readerNav {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1.5rem;
  font-family: system-ui, sans-serif;
}
#chapterSelect { flex: 1; font: inherit; font-family: system-ui, sans-serif; padding: .4rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; }

.chapter {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2.5rem clamp(1rem, 5vw, 3rem);
  /* Kopier-/Auswahl-Hürde (kein Vollschutz, Plan 3.3) */
  user-select: none;
  -webkit-user-select: none;
}
.chapter h1, .chapter h2, .chapter h3, .chapter h4 { line-height: 1.25; }
.chapter p { margin: 0 0 1rem; text-align: justify; hyphens: auto; }
.chapter blockquote { margin: 1.2rem 0; padding-left: 1rem; border-left: 3px solid var(--border); color: #55503f; font-style: italic; }
.chapter figure { margin: 1.5rem 0; text-align: center; }
.chapter img { max-width: 100%; height: auto; border-radius: 4px; -webkit-user-drag: none; user-drag: none; pointer-events: none; }
.chapter figcaption { font-family: system-ui, sans-serif; font-size: .8rem; color: var(--muted); margin-top: .4rem; }
.chapter hr { border: none; border-top: 1px solid var(--border); margin: 2rem auto; width: 40%; }

/* ── Sichtbares Wasserzeichen-Overlay (Plan 3.4) ───────────────────────── */
.watermark {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background-repeat: repeat;
  opacity: .5;
}
