/* Bücherregal — gemeinsames Stylesheet.
   Farbwelt: Buchleinen. Katalogdaten in Schreibmaschinenschrift, weil sie
   aus dem Bibliothekskatalog stammen und sich vom Fließtext abheben sollen. */

:root {
  color-scheme: light dark;

  --paper: #E7E4DB;
  --card: #FFFFFF;
  --ink: #22201C;
  --ink-soft: #6B665C;
  --line: #CFCABD;
  --header-bg: #22201C;
  --header-text: #E7E4DB;
  --counts: #B9B3A6;
  --btn-bg: #22201C;
  --btn-text: #FFFFFF;
  --on-pick: #FFFFFF;
  --error-bg: #F6EAE7;

  --cloth-red: #8C3A2E;
  --cloth-green: #3A5A45;
  --cloth-ochre: #B57726;
  --cloth-slate: #8A8578;

  --sans: 'Archivo', system-ui, sans-serif;
  --mono: 'Courier Prime', ui-monospace, monospace;
}

/* Dunkel: einmal für die Systemeinstellung, einmal für die feste Wahl.
   'hell' schließt die Systemvariante aus, sonst könnte die Einstellung
   nicht gegen ein dunkles Betriebssystem gewinnen. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="hell"]) {
    --paper: #1B1A17;
    --card: #24231F;
    --ink: #E7E4DB;
    --ink-soft: #9A9488;
    --line: #3B3932;
    --header-bg: #100F0D;
    --header-text: #E7E4DB;
    --counts: #8A8578;
    --btn-bg: #E7E4DB;
    --btn-text: #1B1A17;
    --on-pick: #14130F;
    --error-bg: #33211D;
    --cloth-red: #D18374;
    --cloth-green: #7FA98C;
    --cloth-ochre: #D9A44C;
    --cloth-slate: #8A8578;
  }
}
:root[data-theme="dunkel"] {
  --paper: #1B1A17;
  --card: #24231F;
  --ink: #E7E4DB;
  --ink-soft: #9A9488;
  --line: #3B3932;
  --header-bg: #100F0D;
  --header-text: #E7E4DB;
  --counts: #8A8578;
  --btn-bg: #E7E4DB;
  --btn-text: #1B1A17;
  --on-pick: #14130F;
  --error-bg: #33211D;
  --cloth-red: #D18374;
  --cloth-green: #7FA98C;
  --cloth-ochre: #D9A44C;
  --cloth-slate: #8A8578;
}

* { box-sizing: border-box; }

body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); font-size: 15px; line-height: 1.5;
  padding-bottom: 40px;
}
body.centered {
  min-height: 100dvh; display: flex; align-items: center;
  justify-content: center; padding: 24px;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 0 14px; }

/* ------------------------------------------------------------- Kopf */

header { background: var(--header-bg); color: var(--header-text); padding: 18px 0 0; }
.bar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.brand {
  font-size: 21px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--header-text); text-decoration: none;
}
.counts {
  font-family: var(--mono); font-size: 12px; color: var(--counts);
  margin-top: 7px; letter-spacing: 0.02em; min-height: 18px;
}
nav { display: flex; gap: 18px; margin-top: 14px; }
nav a {
  padding: 8px 0 10px; font-size: 14px; font-weight: 500;
  color: var(--counts); text-decoration: none;
  border-bottom: 2px solid transparent;
}
nav a[aria-current="page"] { color: var(--header-text); border-bottom-color: var(--cloth-ochre); }
nav a:focus-visible { outline: 2px solid var(--cloth-ochre); outline-offset: 2px; }

.linkish {
  font-family: var(--sans); font-size: 13px; color: var(--header-text);
  background: none; border: none; padding: 4px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

main { margin-top: 14px; }

/* --------------------------------------------------------- Formulare */

input[type=search], input[type=password], input[type=text], input[type=number], select, textarea {
  width: 100%; padding: 11px 12px; font-size: 16px; font-family: var(--sans);
  color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 0;
}
textarea { background: var(--paper); min-height: 74px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--cloth-red); outline-offset: 1px;
}
label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 7px; }
.field { margin-bottom: 12px; }

.btn {
  padding: 12px 20px; font-family: var(--sans); font-size: 15px; font-weight: 600;
  color: var(--btn-text); background: var(--btn-bg);
  border: none; border-radius: 0; cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--cloth-red); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.wide { width: 100%; }
.btn.quiet {
  color: var(--ink); background: var(--card); border: 1px solid var(--line);
  font-weight: 500;
}
.btn.quiet:hover:not(:disabled) { background: var(--paper); color: var(--ink); }
.textlink {
  padding: 11px 6px; font-family: var(--sans); font-size: 13px;
  color: var(--cloth-red); background: none; border: none; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

.controls { display: grid; gap: 9px; margin-bottom: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  flex: 1 1 0; min-width: 74px; padding: 9px 6px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 0; cursor: pointer;
}
.chip[aria-pressed=true] { background: var(--btn-bg); color: var(--btn-text); border-color: var(--btn-bg); }

/* ------------------------------------------------------------ Bücher */

.book {
  display: flex; gap: 11px; background: var(--card);
  border: 1px solid var(--line); border-left: 6px solid var(--spine, var(--cloth-slate));
  padding: 11px 12px; margin-bottom: 8px; cursor: pointer;
}
.cover {
  width: 44px; height: 66px; flex: none; object-fit: cover;
  background: var(--paper); border: 1px solid var(--line);
}
.cover.blank {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 18px; color: var(--line);
}
.cover.big { width: 62px; height: 93px; }
.meat { min-width: 0; flex: 1; }
.title { font-weight: 600; line-height: 1.3; }
.authors { color: var(--ink-soft); font-size: 14px; margin-top: 1px; }
.cat {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft);
  margin-top: 5px; letter-spacing: 0.02em; word-break: break-word;
}
.stars { color: var(--cloth-ochre); font-size: 13px; letter-spacing: 0.06em; }

.detail {
  display: none; padding: 2px 12px 14px; background: var(--card);
  border: 1px solid var(--line); border-top: none; margin: -8px 0 8px;
}
.detail.open { display: block; }
h3.sub, .detail h3 {
  font-size: 12px; font-family: var(--mono); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-soft); font-weight: 400;
  margin: 14px 0 7px;
}
.seg { display: flex; }
.seg button {
  flex: 1; padding: 10px 4px; font-family: var(--sans); font-size: 13px; font-weight: 500;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-right: none; cursor: pointer;
}
.seg button:last-child { border-right: 1px solid var(--line); }
.seg button[aria-pressed=true] { background: var(--pick); color: var(--on-pick); border-color: var(--pick); }
.rate { display: flex; gap: 3px; align-items: center; }
.rate button {
  padding: 5px 8px; font-size: 21px; line-height: 1; color: var(--line);
  background: none; border: none; cursor: pointer;
}
.rate button.on { color: var(--cloth-ochre); }
.rate .clear {
  font-size: 12px; font-family: var(--sans); color: var(--ink-soft);
  text-decoration: underline; text-underline-offset: 3px; margin-left: 4px;
}
.actions { display: flex; gap: 8px; margin-top: 13px; align-items: center; }
.actions .right { margin-left: auto; }
.note { font-size: 13px; color: var(--ink-soft); }

/* ------------------------------------------------------ Leihe, Verleih */

.tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.tag {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em;
  padding: 2px 6px; border: 1px solid var(--line); color: var(--ink-soft);
}
.tag.lib { border-color: var(--cloth-ochre); color: var(--cloth-ochre); }
.tag.due { border-color: var(--cloth-red); color: var(--cloth-red); font-weight: 700; }
.tag.out { border-color: var(--cloth-slate); color: var(--ink-soft); }
.tag.mine { border-color: var(--cloth-green); color: var(--cloth-green); font-weight: 700; }

.banner {
  display: block; width: 100%; text-align: left;
  padding: 11px 13px; margin-bottom: 12px; font-family: var(--sans); font-size: 14px;
  color: var(--cloth-red); background: var(--error-bg);
  border: none; border-left: 3px solid var(--cloth-red); cursor: pointer;
}
.banner:hover { text-decoration: underline; text-underline-offset: 3px; }

.leihe { display: none; }
.leihe.on { display: block; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------- Scan */

.stage {
  position: relative; background: #14130F; aspect-ratio: 4 / 3;
  border: 1px solid var(--line); overflow: hidden;
}
.stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.reticle {
  position: absolute; left: 12%; right: 12%; top: 34%; height: 32%;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.stage .hint {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 9px 12px; font-size: 13px;
  color: #E7E4DB; background: rgba(16, 15, 13, 0.72);
}
.review {
  background: var(--card); border: 1px solid var(--line);
  border-left: 6px solid var(--cloth-ochre); padding: 14px 13px; margin-top: 12px;
}
.warn {
  padding: 10px 12px; margin-top: 10px; font-size: 14px;
  color: var(--cloth-red); background: var(--error-bg);
  border-left: 3px solid var(--cloth-red);
}
.tally {
  font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
  margin-top: 12px; letter-spacing: 0.02em;
}

/* --------------------------------------------------- Einstellungen */

.panel {
  background: var(--card); border: 1px solid var(--line);
  padding: 18px 16px; margin-bottom: 12px;
}
.panel h2 { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.panel p.note { margin: 0 0 14px; }
.swatches { display: flex; gap: 10px; margin-top: 12px; }
.swatch { flex: 1; text-align: center; }
.swatch .chipbox { height: 44px; border: 1px solid var(--line); display: flex; }
.swatch .chipbox span { flex: 1; }
.swatch small { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }

/* ------------------------------------------------- Meldungen, Toast */

.card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-left: 6px solid var(--cloth-red);
  padding: 32px 26px;
}
.eyebrow {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-soft); margin: 0 0 6px;
}
h1 { font-size: 26px; font-weight: 600; margin: 0 0 22px; letter-spacing: -0.01em; }
.error {
  display: none; margin-top: 14px; padding: 10px 12px;
  font-size: 14px; color: var(--cloth-red);
  background: var(--error-bg); border-left: 3px solid var(--cloth-red);
}
.error.visible { display: block; }
.msg { padding: 30px 16px; text-align: center; color: var(--ink-soft); }
.msg strong { display: block; color: var(--ink); font-size: 17px; margin-bottom: 5px; }
.more {
  width: 100%; padding: 12px; margin-top: 6px; font-family: var(--sans);
  font-size: 14px; font-weight: 500; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); cursor: pointer;
}
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: var(--header-bg); color: var(--header-text); padding: 11px 18px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .18s;
  max-width: 88vw; z-index: 20;
}
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
