:root {
  --grund: #f7f6f3;
  --flaeche: #ffffff;
  --rand: #dcd8d0;
  --schrift: #23201c;
  --gedaempft: #6d675e;
  --akzent: #7a4b2a;
  --akzent-hell: #f0e3d8;
  --treffer: #ffe9a8;
  --schatten: 0 1px 3px rgba(0, 0, 0, .08);
  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #16150f;
    --flaeche: #1f1d18;
    --rand: #38352d;
    --schrift: #e8e4dc;
    --gedaempft: #a09a8f;
    --akzent: #d2a077;
    --akzent-hell: #33291f;
    --treffer: #6b5311;
    --schatten: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

/* Muss !important sein: eigene display-Regeln auf Klassen sind spezifischer
   als das [hidden] des Browsers und würden es sonst aushebeln. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--grund);
  color: var(--schrift);
  font: 16px/1.55 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }

.kopfleiste {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: stretch; gap: 1.5rem;
  padding: 0 1.2rem;
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
}
.marke {
  display: flex; align-items: center;
  font-weight: 600; font-size: 1.05rem; color: var(--schrift);
  white-space: nowrap;
}
.marke:hover { text-decoration: none; color: var(--akzent); }

.bereiche { display: flex; gap: .3rem; }
.bereiche a {
  display: flex; align-items: center;
  padding: .85rem .95rem;
  color: var(--gedaempft); font-size: .95rem;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.bereiche a:hover { color: var(--schrift); text-decoration: none; }
.bereiche a.aktiv {
  color: var(--akzent); font-weight: 600;
  border-bottom-color: var(--akzent);
}

.werkzeugleiste {
  position: sticky; top: 3.05rem; z-index: 20;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .55rem 1.2rem;
  background: var(--grund);
  border-bottom: 1px solid var(--rand);
}

.suchform { display: flex; gap: .4rem; align-items: center; flex: 1; min-width: 260px; }
.suchform input[type=search] {
  flex: 1; min-width: 8rem;
  padding: .45rem .7rem;
  border: 1px solid var(--rand); border-radius: var(--radius);
  background: var(--grund); color: var(--schrift); font: inherit; font-size: .95rem;
}
.suchform select, .knopf, button, input[type=number] {
  padding: .45rem .6rem;
  border: 1px solid var(--rand); border-radius: var(--radius);
  background: var(--grund); color: var(--schrift);
  font: inherit; font-size: .9rem; cursor: pointer;
}
.knopf:hover, button:hover:not(:disabled) { background: var(--akzent-hell); text-decoration: none; }
button:disabled, .knopf[aria-disabled="true"] { opacity: .35; cursor: default; }
.knopf-haupt { background: var(--akzent); border-color: var(--akzent); color: var(--flaeche); }
.knopf-haupt:hover { opacity: .9; background: var(--akzent); color: var(--flaeche); }

/* Bildqualitätsschalter: Laufvogel — Schieberegler — HQ.
   Ein Link, kein Formular: funktioniert ohne JavaScript. */
.qualitaet {
  display: flex; align-items: center; gap: .5rem; flex: none;
  padding: .35rem .6rem;
  border: 1px solid var(--rand); border-radius: 999px;
  background: var(--grund); color: var(--gedaempft);
  user-select: none;
}
.qualitaet:hover { text-decoration: none; border-color: var(--akzent); }
.qualitaet:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

.q-vogel { width: 26px; height: 17px; flex: none; color: var(--akzent); }
.q-auge { fill: var(--grund); }
/* Bei voller Auflösung tritt der Vogel zurück — dann zählt Qualität, nicht Tempo. */
.qualitaet.ist-hq .q-vogel { color: var(--gedaempft); opacity: .45; }
.qualitaet.ist-hq .q-tempo { opacity: 0; }
.q-vogel, .q-tempo { transition: opacity .18s ease, color .18s ease; }

.q-schiene {
  position: relative; flex: none;
  width: 34px; height: 18px; border-radius: 999px;
  background: var(--rand);
  transition: background .18s ease;
}
.q-knopf {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--flaeche);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  transition: left .18s ease;
}
.qualitaet.ist-hq .q-schiene { background: var(--akzent); }
.qualitaet.ist-hq .q-knopf { left: 18px; }

.q-hq {
  font-size: .78rem; font-weight: 700; letter-spacing: .06em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  transition: color .18s ease;
}
.qualitaet.ist-hq .q-hq { color: var(--akzent); }

@media (prefers-reduced-motion: reduce) {
  .q-knopf, .q-schiene, .q-vogel, .q-tempo, .q-hq { transition: none; }
}

main { max-width: 62rem; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; }
main.breit { max-width: 78rem; }
h1 { font-size: 1.5rem; margin: 0 0 .3rem; font-weight: 600; }
h2 { font-size: 1.1rem; margin: 2rem 0 .6rem; font-weight: 600; }
.leise { color: var(--gedaempft); font-size: .9rem; }

/* Bücherübersicht */
.regal { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-top: 1.5rem; }
.buch-karte { display: block; color: inherit; }
.buch-karte:hover { text-decoration: none; }
.buch-karte img {
  width: 100%; aspect-ratio: 1418 / 2006; object-fit: cover;
  border: 1px solid var(--rand); border-radius: var(--radius);
  background: var(--flaeche); box-shadow: var(--schatten);
  transition: transform .12s ease;
}
.buch-karte:hover img { transform: translateY(-3px); }
.buch-karte .titel { margin-top: .55rem; font-weight: 600; font-size: .95rem; line-height: 1.3; }

/* Inhaltsverzeichnis */
.toc { list-style: none; padding: 0; margin: 1rem 0; }
.toc li { padding: .3rem 0; border-bottom: 1px solid var(--rand); display: flex; gap: 1rem; }
.toc li .titel { flex: 1; }
/* Die gelieferten Verzeichnisse reichen bis Ebene 6 — jede Stufe muss
   erkennbar sein, sonst wirkt die Gliederung flach. */
.toc .ebene-1 { font-weight: 600; margin-top: 1.2rem; border-bottom-width: 2px; }
.toc .ebene-2 { padding-left: 1.2rem; }
.toc .ebene-3 { padding-left: 2.4rem; font-size: .95rem; }
.toc .ebene-4 { padding-left: 3.6rem; font-size: .93rem; }
.toc .ebene-5 { padding-left: 4.8rem; font-size: .9rem;  color: var(--gedaempft); }
.toc .ebene-6 { padding-left: 6rem;   font-size: .88rem; color: var(--gedaempft); }
.toc .ohne-ziel { color: var(--gedaempft); }
.kasten {
  background: var(--flaeche); border: 1px solid var(--rand);
  border-left: 3px solid var(--akzent);
  border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1.2rem 0;
}

/* Leseansicht */
.lese-kopf {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.lese-kopf .wo { font-weight: 600; }
.lese-kopf .wo small { display: block; font-weight: 400; color: var(--gedaempft); font-size: .85rem; }
.werkzeuge { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.werkzeuge form { display: flex; gap: .3rem; align-items: center; }
.werkzeuge input[type=number] { width: 5.5rem; cursor: text; }

.blatt { text-align: center; }
.blatt img {
  max-width: 100%; height: auto;
  border: 1px solid var(--rand); border-radius: var(--radius);
  box-shadow: var(--schatten); background: var(--flaeche);
}
.volltext {
  white-space: pre-wrap; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .87rem; line-height: 1.6;
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 1.2rem; overflow-x: auto;
}
kbd {
  font: inherit; margin: 0 .1em; font-size: .82em;
  padding: .1em .4em; border: 1px solid var(--rand); border-bottom-width: 2px;
  border-radius: 4px; background: var(--flaeche);
}

.blaettern { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 1.2rem 0; }

.trefferleiste {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  background: var(--akzent-hell); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: .5rem .9rem; margin-bottom: 1rem;
  font-size: .9rem;
}

/* Trefferliste */
.filter { display: flex; gap: .9rem; flex-wrap: wrap; margin: 1rem 0 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--rand); }
.filter label { display: flex; gap: .35rem; align-items: center; font-size: .88rem; cursor: pointer; }
.filter label.leer { opacity: .45; }
.filter input { cursor: pointer; }

.trefferliste { list-style: none; padding: 0; margin: 0; }
.treffer {
  display: flex; gap: 1rem; padding: .9rem 0; border-bottom: 1px solid var(--rand);
}
.treffer img {
  width: 74px; flex: none; border: 1px solid var(--rand);
  border-radius: 3px; background: var(--flaeche); align-self: flex-start;
}
.treffer .inhalt { flex: 1; min-width: 0; }
.treffer .quelle { font-size: .82rem; color: var(--gedaempft); margin-bottom: .25rem; }
.treffer .auszug { font-size: .93rem; }
.treffer mark { background: var(--treffer); color: inherit; padding: 0 .1em; border-radius: 2px; }
.treffer .nummer { color: var(--gedaempft); font-size: .8rem; font-variant-numeric: tabular-nums; }

.seitenwahl { display: flex; gap: .5rem; align-items: center; justify-content: center; margin: 1.5rem 0; }

@media (max-width: 560px) {
  .kopf { gap: .5rem; }
  .qualitaet { gap: .35rem; padding: .3rem .5rem; }
  .q-vogel { width: 22px; height: 15px; }
  .treffer img { width: 52px; }
  main { padding: 1rem .8rem 3rem; }
}
