/* Geist kommt vom eigenen Server statt von Google Fonts (Datenschutz). Variable Schrift: eine Datei
   pro Zeichensatz für alle Stärken. Quelle: @fontsource-variable/geist 5.3.0, Lizenz fonts/OFL.txt. */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/geist-latin-ext-wght-normal.woff2") format("woff2-variations"), url("../fonts/geist-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/geist-latin-wght-normal.woff2") format("woff2-variations"), url("../fonts/geist-latin-wght-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --wall: #efeeeb;
  --wall-2: #e6e4df;
  --surface: #ffffff;
  --surface-2: #f6f5f2;
  --ink: #141414;
  --ink-2: #3a3936;
  --dim: #5e5c58;
  --line: #dcdad5;
  --line-soft: #ebe9e5;
  --steel: #1b1b1b;
  --red: #d23a24;
  --red-hover: #bb2f1b;
  --red-soft: rgba(210, 58, 36, 0.1);
  --focus: 0 0 0 3px rgba(210, 58, 36, 0.28);
  --on-red: #ffffff;
  --on-ink: #ffffff;
  --line-strong: #c4c1bb;
  --tint: rgba(20, 20, 20, 0.055);
  --wall-glow: #f8f7f5;
  --topbar-bg: rgba(239, 238, 235, 0.86);
  --glass: rgba(255, 255, 255, 0.82);
  --skeleton: #dedbd5;
  --shimmer: rgba(255, 255, 255, 0.55);
  --spin-track: rgba(20, 20, 20, 0.1);
  --spin-head: rgba(20, 20, 20, 0.5);
  --scroll-thumb: #cfccc6;
  --selection: rgba(210, 58, 36, 0.2);
  --star-empty: #d4d1cb;
  --danger: #b42318;
  --danger-soft: rgba(180, 35, 24, 0.08);
  --danger-line: rgba(180, 35, 24, 0.35);

  /* Regalbrett: Oberseite, Kante, Vorderseite, Struktur, Wandschatten */
  --shelf-hi: rgba(255, 255, 255, 0.22);
  --shelf-top: #4a4a4c;
  --shelf-top-2: #343436;
  --shelf-edge: #0c0c0d;
  --shelf-front: #29292b;
  --shelf-front-2: #141415;
  --shelf-texture: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0 1px, transparent 1px 3px);
  --shelf-shadow: rgba(20, 20, 20, 0.32);

  --r-control: 12px;
  --r-card: 18px;
  --r-pill: 999px;

  --shadow-pop: 0 18px 40px -16px rgba(20, 20, 20, 0.28), 0 2px 6px rgba(20, 20, 20, 0.06);
  --shadow-card: 0 30px 70px -28px rgba(20, 20, 20, 0.4);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --ledge-h: 210px;
  --spine-scale: 1;
}

/* ---------- Designs: jedes überschreibt nur Farben und Regalmaterial ---------- */
html[data-theme="dark"] {
  color-scheme: dark;
  --danger: #ff8f80;
  --danger-soft: rgba(255, 143, 128, 0.12);
  --danger-line: rgba(255, 143, 128, 0.4);
  --wall: #121214;
  --wall-2: #1b1b1f;
  --surface: #1c1c20;
  --surface-2: #242429;
  --ink: #f1efea;
  --ink-2: #cfccc5;
  --dim: #a29f97;
  --line: #303036;
  --line-soft: #26262b;
  --line-strong: #4a4a52;
  --red: #d23a24;
  --red-hover: #e24a33;
  --red-soft: rgba(226, 74, 51, 0.16);
  --focus: 0 0 0 3px rgba(226, 74, 51, 0.4);
  --on-ink: #121214;
  --tint: rgba(255, 255, 255, 0.07);
  --wall-glow: #1b1b20;
  --topbar-bg: rgba(18, 18, 20, 0.84);
  --glass: rgba(28, 28, 32, 0.78);
  --skeleton: #2a2a30;
  --shimmer: rgba(255, 255, 255, 0.07);
  --spin-track: rgba(255, 255, 255, 0.12);
  --spin-head: rgba(255, 255, 255, 0.65);
  --scroll-thumb: #3a3a41;
  --selection: rgba(226, 74, 51, 0.38);
  --star-empty: #45454c;
  --shelf-hi: rgba(255, 255, 255, 0.55);
  --shelf-top: #c3c6cc;
  --shelf-top-2: #9fa3ab;
  --shelf-edge: #4f535a;
  --shelf-front: #8b8f97;
  --shelf-front-2: #676b73;
  --shelf-texture: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 4px);
  --shelf-shadow: rgba(0, 0, 0, 0.6);
}
html[data-theme="oak"] {
  --wall: #ece6dc;
  --wall-2: #e2dacd;
  --surface: #fffdf9;
  --surface-2: #f6f1e9;
  --ink: #231c15;
  --ink-2: #4a3f33;
  --dim: #6b5f50;
  --line: #d9cfbf;
  --line-soft: #e9e1d4;
  --line-strong: #c3b6a2;
  --red: #2f6b55;
  --red-hover: #245644;
  --red-soft: rgba(47, 107, 85, 0.12);
  --focus: 0 0 0 3px rgba(47, 107, 85, 0.3);
  --on-ink: #fffdf9;
  --tint: rgba(35, 28, 21, 0.06);
  --wall-glow: #f5f0e8;
  --topbar-bg: rgba(236, 230, 220, 0.86);
  --glass: rgba(255, 253, 249, 0.82);
  --skeleton: #ddd3c4;
  --spin-track: rgba(35, 28, 21, 0.12);
  --spin-head: rgba(35, 28, 21, 0.55);
  --scroll-thumb: #cbbfac;
  --selection: rgba(47, 107, 85, 0.22);
  --star-empty: #d6cbb9;
  --shelf-hi: rgba(255, 240, 215, 0.6);
  --shelf-top: #dcbb91;
  --shelf-top-2: #c79f70;
  --shelf-edge: #7e5631;
  --shelf-front: #b98b5b;
  --shelf-front-2: #94673c;
  --shelf-texture: repeating-linear-gradient(0deg, rgba(90, 55, 25, 0.14) 0 1px, transparent 1px 4px, rgba(255, 235, 200, 0.08) 4px 5px, transparent 5px 9px);
  --shelf-shadow: rgba(70, 45, 20, 0.35);
}
html[data-theme="midnight"] {
  color-scheme: dark;
  --danger: #ff8f80;
  --danger-soft: rgba(255, 143, 128, 0.12);
  --danger-line: rgba(255, 143, 128, 0.4);
  --wall: #0e1726;
  --wall-2: #142036;
  --surface: #15213a;
  --surface-2: #1b2a47;
  --ink: #eef2f8;
  --ink-2: #c6cedb;
  --dim: #95a1b6;
  --line: #24334f;
  --line-soft: #1d2a44;
  --line-strong: #35486c;
  --red: #e2b65a;
  --red-hover: #eec46d;
  --red-soft: rgba(226, 182, 90, 0.16);
  --focus: 0 0 0 3px rgba(226, 182, 90, 0.38);
  --on-red: #1b1406;
  --on-ink: #0e1726;
  --tint: rgba(255, 255, 255, 0.07);
  --wall-glow: #16233b;
  --topbar-bg: rgba(14, 23, 38, 0.84);
  --glass: rgba(21, 33, 58, 0.78);
  --skeleton: #1f2d4a;
  --shimmer: rgba(255, 255, 255, 0.07);
  --spin-track: rgba(255, 255, 255, 0.12);
  --spin-head: rgba(255, 255, 255, 0.65);
  --scroll-thumb: #2c3c5c;
  --selection: rgba(226, 182, 90, 0.35);
  --star-empty: #35486c;
  --shelf-hi: rgba(255, 238, 200, 0.7);
  --shelf-top: #e8cd94;
  --shelf-top-2: #cfa962;
  --shelf-edge: #6e5426;
  --shelf-front: #b8914f;
  --shelf-front-2: #8d6c35;
  --shelf-texture: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 3px);
  --shelf-shadow: rgba(0, 0, 0, 0.6);
}
html[data-theme="sage"] {
  --wall: #e3e9e2;
  --wall-2: #d7dfd5;
  --surface: #fbfcfa;
  --surface-2: #f1f4ef;
  --ink: #18211b;
  --ink-2: #3a463d;
  --dim: #56635a;
  --line: #cdd6cb;
  --line-soft: #e1e7df;
  --line-strong: #b4c0b1;
  --red: #1d6b66;
  --red-hover: #155753;
  --red-soft: rgba(29, 107, 102, 0.12);
  --focus: 0 0 0 3px rgba(29, 107, 102, 0.3);
  --on-ink: #fbfcfa;
  --tint: rgba(24, 33, 27, 0.055);
  --wall-glow: #edf1ec;
  --topbar-bg: rgba(227, 233, 226, 0.86);
  --glass: rgba(251, 252, 250, 0.82);
  --skeleton: #d3dbd1;
  --spin-track: rgba(24, 33, 27, 0.12);
  --spin-head: rgba(24, 33, 27, 0.55);
  --scroll-thumb: #b9c4b6;
  --selection: rgba(29, 107, 102, 0.2);
  --star-empty: #c9d2c6;
  --shelf-hi: #ffffff;
  --shelf-top: #ffffff;
  --shelf-top-2: #f1f3ee;
  --shelf-edge: #c3cbc0;
  --shelf-front: #f8f9f6;
  --shelf-front-2: #e3e7e0;
  --shelf-texture: linear-gradient(transparent, transparent);
  --shelf-shadow: rgba(40, 60, 45, 0.28);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
html {
  scrollbar-color: var(--scroll-thumb) var(--wall);
  /* Kein Doppeltipp-Zoom auf dem Handy (Pinch-Zoom: Viewport-Tag und theme.js) */
  touch-action: manipulation;
}
body {
  min-height: 100vh;
  overflow-x: clip;
  background:
    radial-gradient(ellipse 80% 420px at 50% 0%, var(--wall-glow) 0%, transparent 100%),
    var(--wall);
  color: var(--ink);
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--red);
}
::selection {
  background: var(--selection);
  color: var(--ink);
}
::-webkit-scrollbar {
  width: 12px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 3px solid var(--wall);
  border-radius: var(--r-pill);
}
:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}
button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
.hidden {
  display: none !important;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: var(--r-control);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s var(--ease-out);
}
.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}
.btn:active:not(:disabled) {
  transform: scale(0.97);
}
.btn-primary {
  background: var(--red);
  color: var(--on-red);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 4px 10px -4px rgba(20, 20, 20, 0.35);
}
.btn-primary:hover:not(:disabled) {
  background: var(--red-hover);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.btn-secondary:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover {
  background: var(--tint);
  color: var(--ink);
}
.btn-danger:hover {
  background: var(--red-soft);
  color: var(--red-hover);
}
/* Endgültige Aktionen nutzen in jedem Design dasselbe Warnrot, nicht die Akzentfarbe. */
.btn-danger-outline {
  background: var(--surface);
  border-color: var(--danger-line);
  color: var(--danger);
}
.btn-danger-outline:hover:not(:disabled) {
  background: var(--danger-soft);
}
.btn-danger-solid {
  background: #b42318;
  color: #fff;
}
.btn-danger-solid:hover:not(:disabled) {
  filter: brightness(0.92);
}
.btn-danger-outline:disabled,
.btn-danger-solid:disabled,
.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--r-control);
  border: none;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  padding: 0;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}
.icon-btn:hover {
  background: var(--tint);
  color: var(--ink);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}
.icon-btn.sm {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}
.icon-btn.sm svg {
  width: 16px;
  height: 16px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 0 28px;
  background: var(--topbar-bg);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
/* Offene Menüs der Kopfleiste liegen über der Buch-Schublade (z-index 47), sonst verschwinden sie darunter. */
.topbar:has(.profile-panel:not(.hidden), .notif-menu:not(.hidden), .user-search-results:not(.hidden)) {
  z-index: 48;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.03em;
  padding: 6px 4px;
  border-radius: 8px;
}
.brand-mark {
  display: block;
  width: 28px;
  height: 24px;
}
/* Auf dunklen Designs die Negativ-Variante mit hellen Buchrücken zeigen. */
.brand-mark-negativ,
html[data-theme="dark"] .brand-mark:not(.brand-mark-negativ),
html[data-theme="midnight"] .brand-mark:not(.brand-mark-negativ) {
  display: none;
}
html[data-theme="dark"] .brand-mark-negativ,
html[data-theme="midnight"] .brand-mark-negativ {
  display: block;
}
.auth-bar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Zurück zum eigenen Regal, von überall. Im eigenen Regal leicht markiert; ein Tippen springt dann nach oben. */
.home-btn svg {
  width: 18px;
  height: 18px;
}
.home-btn[aria-current="page"] {
  background: var(--tint);
  border-color: transparent;
}

/* ---------- search ---------- */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box > svg {
  position: absolute;
  left: 13px;
  width: 16px;
  height: 16px;
  color: var(--dim);
  pointer-events: none;
}
.search-box input,
.search-box input[type="text"] {
  width: 100%;
  height: 40px;
  min-height: 0;
  padding: 0 36px 0 38px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.search-box input::placeholder {
  color: var(--dim);
}
.search-box input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: var(--focus);
}
.user-search-box {
  width: 220px;
}
.clear-btn {
  position: absolute;
  right: 6px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--dim);
  cursor: pointer;
  padding: 0;
}
.clear-btn svg {
  width: 14px;
  height: 14px;
}
.clear-btn.show {
  display: inline-flex;
}
.clear-btn:hover {
  background: var(--tint);
  color: var(--ink);
}

.user-search-box-wrap {
  position: relative;
}

/* Design-Auswahl in den Einstellungen: Farbmuster statt Liste */
.setting-row.setting-theme {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}
.theme-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 7px 8px;
  border: none;
  border-radius: 10px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.theme-item:hover {
  background: var(--surface-2);
}
.theme-item[aria-checked="true"] {
  background: var(--tint);
}
.theme-swatch {
  position: relative;
  display: block;
  width: 44px;
  height: 32px;
  overflow: hidden;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.25);
}
.theme-swatch i {
  position: absolute;
  left: 15px;
  bottom: 7px;
  width: 6px;
  height: 15px;
  border-radius: 1px;
}
.theme-swatch b {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 4px;
  height: 3px;
  border-radius: 1px;
}
.theme-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.theme-name {
  font-size: 14px;
  font-weight: 600;
}
.theme-item[aria-checked="true"] .theme-name::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--red);
  vertical-align: 1px;
}
.theme-note {
  color: var(--dim);
  font-size: 12px;
}
/* Mitteilungen (Glocke in der Kopfleiste) */
.notif-picker {
  position: relative;
}
.notif-picker > .icon-btn {
  position: relative;
}
.notif-badge {
  position: absolute;
  top: 5px;
  right: 4px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--red);
  box-shadow: 0 0 0 2px var(--wall);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.notif-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: 360px;
  max-height: min(560px, calc(100vh - 90px));
  max-height: min(560px, calc(100dvh - 90px));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  animation: pop-in 0.2s var(--ease-out);
  transform-origin: top right;
}
.notif-section + .notif-section {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--line-soft);
}
.notif-head {
  margin: 0;
  padding: 8px 10px 6px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.notif-head span {
  margin-left: 4px;
  font-variant-numeric: tabular-nums;
}
.notif-list,
.follow-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.notif-empty {
  margin: 0;
  padding: 4px 10px 10px;
  color: var(--dim);
  font-size: 13.5px;
  line-height: 1.4;
}
.notif-item {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 9px 10px 9px 12px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  text-align: left;
  font-size: 13.5px;
  line-height: 1.35;
  cursor: pointer;
}
.notif-item:hover {
  background: var(--surface-2);
}
.notif-item.is-new {
  background: var(--tint);
}
.notif-item.is-new::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 21px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
}
.notif-item b {
  font-weight: 650;
}
.notif-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.notif-text small {
  color: var(--dim);
  font-size: 12px;
}
.notif-stars {
  display: flex;
  gap: 1px;
}
.notif-stars svg {
  width: 12px;
  height: 12px;
}
.notif-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--wall-2);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
}
.notif-cover {
  width: 34px;
  aspect-ratio: 0.66;
  border-radius: 1px 3px 3px 1px;
  object-fit: cover;
  background: var(--wall-2);
  box-shadow: 0 2px 6px -2px rgba(20, 20, 20, 0.35);
}
.follow-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.follow-go {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 7px 10px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.follow-go:hover {
  background: var(--surface-2);
}
.follow-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 14px;
}
.follow-names b {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.follow-names small {
  color: var(--dim);
  font-size: 12.5px;
}
.follow-bell[aria-pressed="false"],
.follow-notify[aria-pressed="false"] {
  color: var(--dim);
}
.follow-bell {
  margin-right: 4px;
}

.user-search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  z-index: 40;
  animation: pop-in 0.2s var(--ease-out);
  transform-origin: top right;
}
.user-search-empty {
  margin: 0;
  padding: 10px 12px;
  color: var(--dim);
  font-size: 14px;
}
.user-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 10px;
  background: none;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.user-search-item:hover {
  background: var(--surface-2);
}
.user-search-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.user-search-names b {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-search-names small {
  color: var(--dim);
  font-size: 12.5px;
}
.user-search-item img,
.user-search-avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--wall-2);
  flex: none;
}

/* ---------- auth chrome ---------- */
.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 16px 0 14px;
  border-radius: var(--r-control);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}
.google-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}
.login-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -16px 0 32px;
  padding: 8px 8px 8px 16px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(20, 20, 20, 0.04);
  animation: hint-in 0.5s var(--ease-out) both;
}
.login-hint p {
  flex: 1;
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
}
.login-hint .btn {
  height: 34px;
  padding: 0 14px;
}
.lh-short {
  display: none;
}
.dev-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -16px 0 32px;
  padding: 8px 8px 8px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: var(--surface-2);
}
.dev-banner p {
  flex: 1;
  margin: 0;
  color: var(--ink-2);
  font-size: 14px;
}
.dev-banner strong {
  color: var(--ink);
  font-weight: 700;
}
.dev-banner .btn {
  height: 34px;
  padding: 0 14px;
}

.user-chip {
  position: relative;
}
.user-chip-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 4px 14px 4px 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.user-chip-trigger:hover {
  border-color: var(--line-strong);
}
.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--wall-2);
}
.chip-name {
  font-size: 14px;
  font-weight: 600;
}
.profile-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  padding: 20px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-pop);
  text-align: center;
  z-index: 35;
  animation: pop-in 0.22s var(--ease-out);
  transform-origin: top right;
}
.profile-avatar-large {
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--wall-2);
}
.profile-display-name {
  margin: 0;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.profile-username {
  margin: 2px 0 4px;
  color: var(--dim);
  font-size: 14px;
}
.profile-meta {
  margin: 0 0 14px;
  color: var(--dim);
  font-size: 13px;
}
.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.profile-actions .btn {
  width: 100%;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.97);
  }
}
@keyframes hint-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ---------- page head ---------- */
.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 40px 28px 96px;
}
.shelf-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  text-wrap: balance;
}
.shelf-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 0;
  color: var(--dim);
  font-weight: 500;
}
.viewing-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--dim);
}
.viewing-badge svg {
  width: 13px;
  height: 13px;
  margin-top: -1px;
}
.link-btn {
  padding: 0;
  border: none;
  background: none;
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.shelf-head-side {
  display: flex;
  align-items: flex-end;
  gap: 28px;
}
.shelf-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.shelf-head-actions .follow-notify {
  border: 1px solid var(--line);
  background: var(--surface);
}
.stats {
  display: flex;
  gap: 28px;
  margin: 0;
}
.stats div {
  display: flex;
  flex-direction: column-reverse;
}
.stats dt {
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
}
.stats dd {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* ---------- toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 0 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.shelf-search {
  width: 260px;
}
.filter-bar {
  display: flex;
  gap: 6px;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar {
  display: none;
}
.filter-bar.fade-end {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent);
}
.toolbar-end {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.header-actions {
  display: flex;
  gap: 8px;
}

.filter-pill,
.cat-toggle {
  height: 32px;
  padding: 0 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}
/* Nur mit echter Maus: auf dem iPhone bleibt :hover nach dem Antippen hängen und färbte die Schrift
   eines gerade gewählten Chips dunkel auf dunklem Grund. */
@media (hover: hover) {
  .filter-pill:not(.active):hover,
  .cat-toggle:not(.active):not(:disabled):hover {
    border-color: var(--line-strong);
    color: var(--ink);
  }
}
.filter-pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
}
/* Zugeordnete Kategorie: in der Akzentfarbe getönt und mit Haken, statt schwarz wie die Filter. */
.cat-toggle.active {
  background: color-mix(in srgb, var(--red) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--red) 55%, transparent);
  color: var(--ink);
}
.cat-toggle.active::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 8px;
  margin: 0 8px 3px 1px;
  border: solid var(--red);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  vertical-align: middle;
}
/* „+ Neue Kategorie“ wird zum Eingabefeld in Chipform. */
.cat-new-form {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 3px 0 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--red);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--red-soft);
}
.cat-new-form input[type="text"] {
  width: 140px;
  min-height: 0;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: 16px; /* darunter zoomt iOS beim Tippen ins Feld */
  font-weight: 600;
}
.cat-new-form input[type="text"]:focus {
  outline: none;
  box-shadow: none;
}
.cat-new-form button {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  cursor: pointer;
}
.cat-new-form button svg {
  width: 13px;
  height: 13px;
}
.cat-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.cat-toggle-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cat-toggle-empty {
  margin: 0;
  color: var(--dim);
  font-size: 14px;
}

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-control);
  background: var(--wall-2);
  border: 1px solid var(--line);
}
.seg button {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(20, 20, 20, 0.12);
}
/* Symbole nur auf dem Handy, dort ersetzen sie die Beschriftung. */
.seg svg,
#openCatBtn svg {
  display: none;
}

/* ---------- series ---------- */
/* Festes Raster: jede Reihe hat eine gleich breite Zelle, damit ein frontal gedrehtes Buch
   (breiter als sein Rücken) nie die Anordnung der übrigen Reihen verschiebt. */
#shelves {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr));
  align-items: start;
  gap: 60px 64px;
  padding-top: 22px;
}
#shelves.grid-mode {
  grid-template-columns: minmax(0, 1fr);
}
.series {
  min-width: 0;
  scroll-margin-top: 90px;
}
#shelves .empty-state {
  grid-column: 1 / -1;
}
.series-head {
  margin-bottom: 14px;
}
.series-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.series-head .cat-tags {
  margin-top: 8px;
  width: 0;
  min-width: 100%;
}
.series-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
/* Autor, Bandzahl und Zahnrad brechen nur gemeinsam um, nie das Zahnrad allein. */
.series-sub {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.series-meta {
  color: var(--dim);
  font-size: 14px;
  font-weight: 500;
}
.cat-tags {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.cat-tag {
  height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: var(--r-pill);
  background: var(--tint);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}
.series-edit {
  margin-left: -4px;
  color: var(--dim);
}
/* Private Reihen und Bücher: nur der Besitzer bekommt sie überhaupt geladen und sieht dieses Schloss. */
.private-tag {
  height: 22px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 7px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
}
.private-tag svg {
  width: 12px;
  height: 12px;
}
.private-badge {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 3;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-2);
  box-shadow: 0 1px 3px rgba(20, 20, 20, 0.35);
  transform: translateX(-50%);
  pointer-events: none;
}
.private-badge svg {
  width: 11px;
  height: 11px;
}
.rating-row .seg {
  justify-self: start;
}
.tile .private-badge {
  left: auto;
  right: 6px;
  bottom: auto;
  top: 6px;
  transform: none;
}

/* ---------- Vitrine ---------- */
/* Erste Reihe über die ganze Breite, offen wie ein Titelbild: Überschrift mittig, größere Cover auf
   einem eigenen kurzen Brett, jedes Cover leuchtet in seiner eigenen Farbe (--c) auf die Wand.
   Darunter je ein Schildchen mit Titel und Sternen. */
.vitrine {
  --ledge-h: 250px;
  --plaque-gap: 62px;
  --glow: 0.5;
  --spot: rgba(255, 255, 255, 0.6);
  grid-column: 1 / -1;
  min-width: 0;
  padding-bottom: 34px;
  /* Der Schein darf über die Reihe hinaus leuchten, aber die Seite nie seitlich verbreitern. */
  overflow-x: clip;
  border-bottom: 1px solid var(--line-soft);
  /* Galerielicht auf der Wand hinter der Reihe. */
  background: radial-gradient(ellipse 46% 58% at 50% 48%, var(--spot), transparent 72%);
}
html[data-theme="dark"] .vitrine,
html[data-theme="midnight"] .vitrine {
  --glow: 0.75;
  --spot: rgba(255, 255, 255, 0.06);
}
.vitrine-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 4px;
}
.vitrine-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.vitrine-eyebrow svg {
  width: 13px;
  height: 13px;
}
.vitrine-head .series-line {
  justify-content: center;
}
.vitrine-head .series-title {
  font-size: 26px;
  letter-spacing: -0.035em;
}
/* Das Brett ist nur so breit wie die Bücher darauf. */
.vitrine .ledge-wrap {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}
.vitrine .ledge {
  gap: 30px;
  padding: 56px 72px var(--plaque-gap);
  /* Höchstens drei Bücher, die Größe ist so gewählt, dass sie immer passen: kein Scrollen, also
     auch kein Verschieben mit dem Finger und kein abgeschnittener Schein. */
  overflow: visible;
}
@media (max-width: 1100px) {
  .vitrine {
    --ledge-h: 214px;
  }
  .vitrine .ledge {
    gap: 24px;
    padding-left: 44px;
    padding-right: 44px;
  }
}
.vitrine .ledge-wrap::after {
  bottom: calc(var(--plaque-gap) - 19px);
}
.vitrine .ledge-wrap::before {
  bottom: calc(var(--plaque-gap) - 43px);
}
/* Gleich hoch statt der zufälligen Höhen im Regal, sonst wirkt die Reihe unruhig. */
.vitrine .book {
  --hpx: var(--ledge-h);
}
.vitrine .book::after {
  left: 6%;
  right: 6%;
  height: 8px;
  bottom: -3px;
  background: rgba(0, 0, 0, 0.45);
  filter: blur(4px);
}
/* Farbiger Schein hinter dem Cover. */
.vitrine-light {
  position: absolute;
  inset: 6% -8% 14%;
  z-index: -1;
  border-radius: 50%;
  background: rgb(var(--c, 120, 120, 120));
  opacity: var(--glow);
  filter: blur(30px);
  pointer-events: none;
}
.vitrine .book.open:hover .book-3d {
  transform: translateY(-6px) translateX(calc((var(--cw) - var(--wpx)) / 2)) translateZ(calc((var(--cw) - var(--wpx)) / 2)) rotateY(-90deg);
}
.vitrine .book .face.front {
  box-shadow:
    inset 4px 0 0 rgba(255, 255, 255, 0.16),
    inset 8px 0 8px -4px rgba(0, 0, 0, 0.35);
}
.vitrine .book.selected .face.front {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}
/* Schildchen unter dem Brett. */
.vitrine-plaque {
  position: absolute;
  top: calc(100% + 24px);
  left: 50%;
  width: calc(100% + 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transform: translateX(-50%);
  color: var(--ink-2);
  text-align: center;
  pointer-events: none;
}
.vitrine-plaque b {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.005em;
}
.vitrine-plaque .tile-stars {
  justify-content: center;
}
.vitrine-plaque .tile-stars svg {
  width: 10px;
  height: 10px;
}
.vitrine-ctl {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
}
.vitrine-ctl .btn {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
  gap: 6px;
}
.vitrine-ctl .btn svg {
  width: 13px;
  height: 13px;
  color: var(--red);
}
.vitrine-pos {
  margin-right: 2px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.vitrine-move {
  font-size: 20px;
  line-height: 1;
}
.vitrine-move:disabled {
  opacity: 0.35;
  cursor: default;
}
.vitrine-full {
  color: var(--dim);
  font-size: 13px;
}
#shelfShowcaseRow {
  border-bottom: none;
}
/* Bände einer Reihe für die Vitrine wählen: kleine Cover, gewählte mit Haken und Rahmen. */
.vitrine-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 14px 12px;
  margin: 2px 0 8px;
}
.vitrine-pick-item {
  gap: 2px;
  align-items: center;
  text-align: center;
}
.vitrine-pick-item .tile-cover {
  width: 100%;
  margin-bottom: 4px;
  transition:
    transform 0.35s var(--ease-out),
    opacity 0.2s ease,
    box-shadow 0.35s var(--ease-out);
}
.vitrine-pick-item .gen-cover b {
  font-size: 10px;
}
.vitrine-pick-item .gen-cover small {
  display: none;
}
.vitrine-pick-item:not(.open) .tile-cover {
  opacity: 0.55;
}
.vitrine-pick-item.is-muted .tile-cover {
  opacity: 0.3;
}
.vitrine-pick-item:not(.open):hover .tile-cover {
  opacity: 0.85;
}
.vitrine-pick-item.open .tile-meta {
  color: var(--ink);
  font-weight: 600;
}
.vitrine-check {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}
.vitrine-check svg {
  width: 13px;
  height: 13px;
}

/* ---------- ledge & books ---------- */
.ledge-wrap {
  position: relative;
}
/* Schwebendes Wandbrett: sichtbare Oberseite (auf der die Bücher stehen), dunkle Kante,
   strukturierte Vorderseite, helle Schnittkanten links/rechts und ein weicher Schatten an der Wand. */
.ledge-wrap::after {
  content: "";
  position: absolute;
  left: -6px;
  right: -6px;
  bottom: -16px;
  height: 22px;
  z-index: 0;
  border-radius: 3px;
  background:
    linear-gradient(90deg, var(--shelf-hi) 0, transparent 2px, transparent calc(100% - 2px), var(--shelf-hi) 100%),
    linear-gradient(180deg, var(--shelf-hi) 0, var(--shelf-top) 1px, var(--shelf-top-2) 6px, var(--shelf-edge) 6px, var(--shelf-edge) 7px, transparent 7px),
    var(--shelf-texture),
    linear-gradient(180deg, var(--shelf-front) 7px, var(--shelf-front-2) 100%);
  box-shadow:
    0 2px 3px -1px var(--shelf-shadow),
    0 16px 22px -12px var(--shelf-shadow);
}
.ledge-wrap::before {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: -40px;
  height: 26px;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 0%, var(--shelf-shadow), transparent 70%);
  opacity: 0.7;
  filter: blur(6px);
  pointer-events: none;
}
.ledge {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: safe center;
  gap: 2px;
  min-height: calc(var(--ledge-h) + 25px);
  padding: 22px 18px 3px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ledge::-webkit-scrollbar {
  display: none;
}

.book {
  --s: var(--spine-scale);
  --wpx: calc(var(--w, 34) * 1px * var(--s));
  --hpx: calc(var(--ledge-h) * var(--hf, 1));
  --cw: calc(var(--hpx) * var(--ratio, 0.66));
  position: relative;
  flex: none;
  width: var(--wpx);
  height: var(--hpx);
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  perspective: 1400px;
  transition: width 0.6s var(--ease-out);
}
.book.open {
  width: var(--cw);
  z-index: 2;
}
.book-3d {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: calc(var(--wpx) / 2) 50% calc(var(--cw) / -2);
  transition: transform 0.7s var(--ease-out);
}
.book.open .book-3d {
  transform: translateX(calc((var(--cw) - var(--wpx)) / 2)) translateZ(calc((var(--cw) - var(--wpx)) / 2)) rotateY(-90deg);
}
.book:not(.open):hover .book-3d {
  transform: translateY(-6px);
}
.book::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 5px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.38);
  filter: blur(2px);
  z-index: -1;
  pointer-events: none;
}
.face {
  position: absolute;
  top: 0;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
/* Gebundener Rücken: gewölbt (Licht von links, Schatten in beiden Falzen) und mit je einer
   Zierlinie in der Schriftfarbe oben und unten, wie bei einem Hardcover. */
.face.spine {
  --rule: rgba(var(--l, 250, 250, 250), 0.42);
  left: 0;
  width: var(--wpx);
  border-radius: 2px 2px 1px 1px;
  background:
    linear-gradient(180deg,
      transparent 7px, var(--rule) 7px, var(--rule) 8px, transparent 8px,
      transparent calc(100% - 9px), var(--rule) calc(100% - 9px), var(--rule) calc(100% - 8px), transparent calc(100% - 8px)),
    linear-gradient(90deg,
      rgba(0, 0, 0, 0.32) 0,
      rgba(0, 0, 0, 0.06) 9%,
      rgba(255, 255, 255, 0.14) 27%,
      rgba(255, 255, 255, 0.03) 50%,
      rgba(0, 0, 0, 0.06) 78%,
      rgba(0, 0, 0, 0.36) 100%),
    rgb(var(--g, 70, 70, 70));
  color: rgb(var(--l, 250, 250, 250));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 15px 0 17px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}
.spine-emblem {
  display: none;
  flex: none;
  width: calc(var(--wpx) - 10px);
  aspect-ratio: 1;
  border-radius: 1.5px;
  background: var(--emblem, none) var(--ex, 50%) var(--ey, 36%) / var(--es, 300%) auto;
  box-shadow: 0 0 0 1px var(--rule);
}
.book.has-emblem .spine-emblem {
  display: block;
}
.spine-title {
  flex: 1;
  min-height: 0;
  max-width: calc(100% - 8px);
  writing-mode: vertical-rl;
  text-align: center;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: 0.03em;
  overflow: hidden;
}
.ink-light .spine-title {
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}
.spine-no {
  flex: none;
  align-self: stretch;
  margin: 0 6px;
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.spine-no:not(:empty) {
  padding-top: 6px;
  border-top: 1px solid var(--rule);
}

.face.front {
  left: var(--wpx);
  width: var(--cw);
  transform-origin: left center;
  transform: rotateY(90deg);
  border-radius: 1px 4px 4px 1px;
  background: rgb(var(--c, 70, 70, 70));
  box-shadow: inset 4px 0 0 rgba(255, 255, 255, 0.16), inset 8px 0 8px -4px rgba(0, 0, 0, 0.35);
}
.book.has-cover .face.front,
.tile.has-cover .tile-cover {
  background: var(--cover) center / cover, rgb(var(--c, 70, 70, 70));
}
.detail-cover.has-cover {
  background:
    var(--cover) center / cover,
    var(--cover-sm, none) center / cover,
    rgb(var(--c, 70, 70, 70));
}
.book.open .face.front {
  box-shadow:
    inset 4px 0 0 rgba(255, 255, 255, 0.16),
    inset 8px 0 8px -4px rgba(0, 0, 0, 0.35),
    18px 22px 30px -14px rgba(20, 20, 20, 0.55);
}
.book.open .face.spine {
  box-shadow: none;
}

.gen-cover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 10px 12px 13px;
  container-type: inline-size;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.12), transparent 50%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.35), transparent 60%);
  text-align: left;
}
.has-cover .gen-cover {
  display: none;
}
/* Schmale Kacheln auf dem Handy: Schrift mit der Coverbreite verkleinern, damit lange Wörter ganz bleiben. */
.gen-cover b {
  font-size: min(15px, 14.5cqi);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
  hyphens: auto;
}
.gen-cover small {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.8;
}
.gen-cover {
  color: rgb(var(--l, 250, 250, 250));
}

/* ---------- Ladezustand, solange das Cover gesucht wird ---------- */
.book.is-loading .face,
.tile.is-loading .tile-cover,
.detail-cover.is-loading {
  background: var(--skeleton) !important;
  color: var(--dim) !important;
}
.is-loading .spine-emblem,
.is-loading .gen-cover {
  visibility: hidden;
}
.book.is-loading .face::after,
.tile.is-loading .tile-cover::after,
.detail-cover.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, var(--shimmer) 50%, transparent 70%);
  background-size: 250% 100%;
  animation: shimmer 1.5s linear infinite;
  pointer-events: none;
}
.book.is-loading .face.front::before,
.tile.is-loading .tile-cover::before,
.detail-cover.is-loading::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 2px solid var(--spin-track);
  border-top-color: var(--spin-head);
  animation: spin 0.8s linear infinite;
}
@keyframes shimmer {
  from {
    background-position: 150% 0;
  }
  to {
    background-position: -100% 0;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- cover grid ---------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 26px 22px;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}
.tile-cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 3px 6px 6px 3px;
  overflow: hidden;
  background: rgb(var(--c, 70, 70, 70));
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, 0.16),
    inset 7px 0 7px -4px rgba(0, 0, 0, 0.3),
    0 12px 20px -12px rgba(20, 20, 20, 0.5);
  margin-bottom: 8px;
  transition:
    transform 0.35s var(--ease-out),
    box-shadow 0.35s var(--ease-out);
}
.tile:hover .tile-cover {
  transform: translateY(-4px);
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, 0.16),
    inset 7px 0 7px -4px rgba(0, 0, 0, 0.3),
    0 20px 26px -12px rgba(20, 20, 20, 0.55);
}
.tile.open .tile-cover {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}
.tile-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
.tile-meta {
  color: var(--dim);
  font-size: 13px;
}
.tile-stars {
  display: flex;
  gap: 1px;
}
.tile-stars svg {
  width: 11px;
  height: 11px;
}

/* ---------- side drawers ---------- */
.toc-overlay,
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 20, 0);
  pointer-events: none;
  transition: background 0.3s ease;
}
.toc-overlay {
  z-index: 44;
}
.drawer-overlay {
  z-index: 46;
}
.toc-overlay.open,
.drawer-overlay.open {
  background: rgba(20, 20, 20, 0.28);
  pointer-events: auto;
}
.toc-panel,
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  background: var(--surface);
  visibility: hidden;
  transition:
    transform 0.45s var(--ease-out),
    visibility 0s linear 0.45s;
}
.toc-panel.open,
.drawer.open {
  transform: none;
  visibility: visible;
  transition: transform 0.45s var(--ease-out);
}
.toc-panel {
  left: 0;
  width: 290px;
  max-width: 84vw;
  z-index: 45;
  display: flex;
  flex-direction: column;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  transform: translateX(-102%);
  box-shadow: 20px 0 50px -20px rgba(20, 20, 20, 0.3);
}
.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 10px 12px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}
.toc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.toc-item em {
  font-style: normal;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.toc-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.toc-item.active {
  background: var(--wall);
  color: var(--ink);
  font-weight: 700;
}
.toc-item:focus-visible {
  outline-offset: -2px;
}
.toc-list {
  flex: 1;
  min-height: 0;
}
.toc-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.toc-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: none;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
}
.toc-action:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.toc-action svg {
  flex: none;
  width: 20px;
  height: 20px;
}
.toc-action span {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.toc-action b {
  font-size: 14px;
  font-weight: 600;
}
.toc-action small {
  color: var(--dim);
  font-size: 12px;
}
#installBtn svg {
  color: var(--red);
}

/* Einstellungen */
.settings-modal {
  max-width: 520px;
}
.settings-group {
  margin-top: 22px;
}
.settings-group h3 {
  margin: 0 0 4px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.setting-row > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.setting-row b {
  font-size: 15px;
  font-weight: 600;
}
.setting-row small {
  color: var(--dim);
  font-size: 13px;
}
.setting-row select {
  width: auto;
  min-width: 170px;
  flex: none;
}
.setting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0 2px;
}
.install-steps {
  margin: 14px 0 0;
  padding-left: 20px;
  line-height: 1.6;
}
html select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  cursor: pointer;
}

.drawer {
  right: 0;
  width: 420px;
  max-width: 100vw;
  z-index: 47;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(102%);
  box-shadow: -20px 0 60px -20px rgba(20, 20, 20, 0.35);
}

.detail-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 280px;
  padding-top: 40px;
  background:
    radial-gradient(ellipse 70% 80% at 50% 100%, rgba(var(--c, 120, 120, 120), 0.32), transparent 75%),
    linear-gradient(180deg, rgba(var(--c, 120, 120, 120), 0.14), rgba(var(--c, 120, 120, 120), 0.04));
}
.detail-hero-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
}
.detail-hero-actions .icon-btn {
  background: var(--glass);
}
.detail-hero-actions .icon-btn:hover {
  background: var(--surface);
}
.detail-cover {
  position: relative;
  width: 150px;
  aspect-ratio: var(--ratio, 0.66);
  transform: translateY(30px);
  border-radius: 2px 6px 6px 2px;
  overflow: hidden;
  background: rgb(var(--c, 70, 70, 70));
  box-shadow:
    inset 4px 0 0 rgba(255, 255, 255, 0.18),
    inset 9px 0 9px -5px rgba(0, 0, 0, 0.35),
    20px 26px 40px -16px rgba(20, 20, 20, 0.55);
  animation: cover-in 0.6s var(--ease-out) both;
}
.detail-cover .gen-cover b {
  font-size: min(18px, 16cqi);
}
.detail-cover.has-cover:not(.is-loading) {
  cursor: zoom-in;
}
.detail-cover:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 4px;
}
.fill-missing {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 14px 0 0;
  padding: 10px 10px 10px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-control);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
}
.fill-missing .btn {
  height: 34px;
  padding: 0 14px;
}
.fill-missing + .field {
  margin-top: 12px;
}

/* Cover groß: dunkle Fläche, ein Klick irgendwo schließt. */
.modal-overlay.cover-zoom {
  z-index: 60;
  align-items: center;
  padding: 24px;
  background: rgba(12, 12, 12, 0.82);
  cursor: zoom-out;
}
.cover-zoom:focus {
  outline: none;
}
.cover-zoom img {
  display: block;
  width: auto;
  height: min(86vh, 900px);
  height: min(86dvh, 900px);
  max-width: 100%;
  object-fit: contain;
  border-radius: 3px 8px 8px 3px;
  background: var(--cover-sm, none) center / cover;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.7);
  animation: modal-in 0.38s var(--ease-out);
}
@keyframes cover-in {
  from {
    opacity: 0;
    transform: translateY(46px) rotate(-2deg);
  }
}
.detail-body {
  padding: 52px 28px 32px;
}
.detail-title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.12;
  text-wrap: balance;
}
.detail-meta {
  margin: 6px 0 0;
  color: var(--dim);
  font-weight: 500;
}
.detail-edit-fields .field:first-child {
  margin-top: 0;
}
.detail-edit-fields .field + .field {
  margin-top: 12px;
}
.detail-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}
.detail-rows {
  margin-top: 22px;
  border-top: 1px solid var(--line-soft);
}
.rating-row,
.detail-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.detail-row {
  align-items: baseline;
}
.row-label {
  color: var(--dim);
  font-size: 13px;
  font-weight: 600;
}
.row-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.detail-row input {
  min-width: 0;
  width: 100%;
  min-height: 42px;
}
/* iOS Safari gibt Datumsfeldern eine feste Mindestbreite und zentrierten Text; beides angleichen. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  max-width: 100%;
  text-align: left;
}
input[type="date"]::-webkit-date-and-time-value {
  min-height: 1.5em; /* leeres Feld fällt in iOS sonst auf eine andere Höhe */
  text-align: left;
  margin: 0;
}
/* Zeilen mit Eingabefeld mittig ausrichten: ein leeres Datumsfeld hat keine Grundlinie,
   das Label rutschte sonst an die Unterkante. */
.detail-row:has(input) {
  align-items: center;
}
.date-field {
  position: relative;
  display: block;
  min-width: 0;
}
.date-placeholder {
  display: none;
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dim);
  font-size: 15px;
  pointer-events: none;
}
/* Nur iOS zeigt ein leeres Datumsfeld ganz leer; Desktop-Browser haben ihren eigenen Platzhalter. */
@supports (-webkit-touch-callout: none) {
  .date-field.is-empty .date-placeholder {
    display: block;
  }
}
.detail-block {
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}
.detail-block .row-label {
  display: block;
  margin-bottom: 8px;
}
.detail-text {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.55;
  max-width: 62ch;
}
.detail-note {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  white-space: pre-wrap;
  line-height: 1.5;
}
.detail-block small {
  display: block;
  margin-top: 8px;
  color: var(--dim);
  font-size: 13px;
}
.stars {
  display: flex;
  gap: 2px;
}
.star-btn {
  display: inline-flex;
  padding: 3px;
  border: none;
  border-radius: 6px;
  background: none;
  cursor: pointer;
}
.stars svg {
  width: 22px;
  height: 22px;
  transition: transform 0.2s var(--ease-out);
}
.star-btn:hover svg {
  transform: scale(1.15);
}
.star-btn:active svg {
  transform: scale(0.9);
}
.detail-actions {
  display: flex;
  margin-top: 22px;
}

/* ---------- forms ---------- */
.field {
  display: block;
  margin-top: 16px;
}
.req {
  color: var(--red);
  text-decoration: none;
  border: none;
}
.field > span,
.field > label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

/* Buchvorschläge im Hinzufügen-Dialog */
.suggest-field {
  position: relative;
}
.suggest-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  max-height: 336px;
  overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  animation: pop-in 0.18s var(--ease-out);
  transform-origin: top center;
}
.suggest-item {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 10px;
  background: none;
  text-align: left;
  cursor: pointer;
}
.suggest-item:hover,
.suggest-item.is-active {
  background: var(--surface-2);
}
.suggest-thumb {
  display: block;
  width: 36px;
  height: 54px;
  overflow: hidden;
  border-radius: 2px 4px 4px 2px;
  background: var(--wall-2);
  box-shadow: 0 2px 6px -2px rgba(20, 20, 20, 0.35);
}
.suggest-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.suggest-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.suggest-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}
.suggest-meta {
  color: var(--dim);
  font-size: 12px;
}
.suggest-empty {
  margin: 0;
  padding: 10px;
  color: var(--dim);
  font-size: 13px;
}

/* Reihen-Auswahl: Freitextfeld mit Pfeil, darunter die vorhandenen Reihen */
.combo {
  position: relative;
}
.combo input[type="text"] {
  padding-right: 38px;
}
.combo-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  width: 38px;
  padding: 0;
  border: none;
  border-radius: 0 var(--r-control) var(--r-control) 0;
  background: none;
  color: var(--dim);
  cursor: pointer;
}
.combo-toggle:hover {
  color: var(--ink);
}
.combo-toggle svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s var(--ease-out);
}
.combo:has([aria-expanded="true"]) .combo-toggle svg {
  transform: rotate(180deg);
}
.combo-list {
  max-height: 264px;
}
.combo-item {
  grid-template-columns: 22px 1fr;
  gap: 10px;
}
.combo-item .suggest-title,
.combo-item .suggest-meta {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Cover-Auswahl */
.cp-strip {
  display: flex;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 4px 10px;
  margin: 0 -4px;
  scrollbar-width: thin;
}
.cp-opt {
  flex: none;
  width: 64px;
  height: 96px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 3px 6px 6px 3px;
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 0.2s var(--ease-out);
}
.cp-opt:hover {
  transform: translateY(-2px);
}
.cp-opt img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cp-opt.is-selected {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}
.cp-text {
  padding: 6px;
  border-style: dashed;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  hyphens: manual;
}
.cp-loading {
  align-self: center;
  padding: 0 6px;
  color: var(--dim);
  font-size: 13px;
  white-space: nowrap;
}
.cp-url {
  display: flex;
  gap: 8px;
}
.cp-url input {
  flex: 1;
  min-width: 0;
}
.detail-block > label {
  display: block;
}
.summary-search {
  margin-top: 8px;
  font-size: 14px;
}
.summary-search:disabled {
  color: var(--dim);
  cursor: progress;
}
.field small {
  display: block;
  margin-top: 6px;
  color: var(--dim);
  font-size: 13px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 12px;
}
input[type="text"],
input[type="url"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
textarea {
  resize: vertical;
  line-height: 1.5;
}
input::placeholder,
textarea::placeholder {
  color: var(--dim);
}
input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: var(--focus);
}

/* ---------- modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 20, 20, 0.36);
  animation: fade-in 0.2s ease;
}
.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px;
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow-card);
  animation: modal-in 0.38s var(--ease-out);
}
.modal h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
  text-wrap: balance;
}
.modal-lede {
  margin: 6px 0 0;
  color: var(--dim);
  font-size: 14px;
}
.modal-setting {
  margin-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.modal-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 26px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Neues-Buch-Dialog: Kopf mit Suche, scrollender Inhalt, feste Fußleiste */
.modal.modal-add {
  display: flex;
  flex-direction: column;
  max-width: 600px;
  padding: 0;
  overflow: hidden;
}
.modal-add form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.modal-add-head {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-add-head .modal-title-row {
  align-items: center;
  margin-bottom: 14px;
}
.modal-add-head .icon-btn {
  margin: -6px -10px -6px 0;
}
.add-search .search-box input {
  height: 48px;
  padding-left: 42px;
  font-size: 16px;
}
.add-search .search-box > svg {
  left: 15px;
  width: 18px;
  height: 18px;
}
.add-search small {
  display: block;
  margin-top: 8px;
  color: var(--dim);
  font-size: 13px;
}
.modal-add-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 28px 26px;
}
.modal-actions.modal-add-foot {
  margin: 0;
  padding: 14px 28px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}

/* Supporter: Unterstützen-Fenster und Kauf-Fenster */
/* Kleines Stern-Abzeichen in der Ecke: Scannen ist ein Supporter-Extra. */
#openScanBtn.is-locked {
  position: relative;
}
#openScanBtn.is-locked::after {
  content: "★";
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  color: var(--on-red);
  font-size: 10px;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--wall);
}
.support-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--p-badge-bg);
  color: var(--p-badge-fg);
}
.support-badge svg {
  width: 13px;
  height: 13px;
}
.modal.support-modal {
  max-width: 440px;
  padding: 0;
}
.support-hero {
  position: relative;
  padding: 26px 24px 22px;
  text-align: center;
  box-shadow: none;
}
.support-close {
  position: absolute;
  top: 12px;
  right: 12px;
  color: var(--p-dim);
}
.support-close:hover {
  background: color-mix(in srgb, var(--p-fg) 10%, transparent);
  color: var(--p-fg);
}
.support-hero h2 {
  margin-top: 14px;
  font-size: 26px;
}
.support-lede {
  max-width: 34ch;
  margin: 8px auto 0;
  color: var(--p-dim);
  font-size: 14.5px;
  line-height: 1.5;
  text-wrap: pretty;
}
.support-body {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 18px 20px 16px;
}
.support-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}
.support-features li {
  display: flex;
  flex-direction: column;
  padding: 6px 6px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}
/* Die Funktion, über die man gekommen ist */
.support-features li.is-focus {
  border-color: var(--red);
  box-shadow: 0 0 0 1px var(--red);
}
.support-features b {
  margin: 10px 6px 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.support-features small {
  margin: 3px 6px 0;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.4;
}
.sf-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 118px;
  border-radius: 11px;
  background: var(--surface-2);
  overflow: hidden;
}
html[data-theme="dark"] .sf-visual,
html[data-theme="midnight"] .sf-visual {
  background: var(--wall-2);
}
/* Regal scannen im Kleinen: ein Buch im Sucher, es wird erkannt, dann gleitet das Ergebnis mit
   „Hinzufügen“ herein und der Knopf wird angetippt. Alles im selben 6-s-Takt. */
.sf-scan {
  --sf-t: 6s;
}
/* Hochkant wie ein echtes Handy, mit Auslöser unten in der Mitte. */
.sf-phone {
  position: relative;
  width: 64px;
  height: 108px;
  padding: 4px 4px 22px;
  border-radius: 14px;
  background: var(--ink);
  box-shadow: 0 10px 20px -10px rgba(20, 20, 20, 0.6);
  animation: sf-phone var(--sf-t) var(--ease-out) infinite;
}
.sf-phone::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  border-radius: 50%;
  background: var(--on-ink);
  box-shadow: 0 0 0 1.5px var(--ink), 0 0 0 2.5px var(--on-ink);
  animation: sf-shutter var(--sf-t) infinite;
}
.sf-spines {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  border-radius: 10px;
  background: var(--wall);
  overflow: hidden;
}
/* Blitz beim Auslösen */
.sf-spines::after {
  content: "";
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  animation: sf-flash var(--sf-t) infinite;
  pointer-events: none;
}
.sf-spines .thumb {
  width: 34px;
  height: 51px;
  border-radius: 1px 3px 3px 1px;
  outline: 2px solid transparent;
  outline-offset: 2px;
  animation: sf-mark var(--sf-t) infinite;
}
.sf-chip {
  position: absolute;
  left: 50%;
  bottom: 34px;
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--on-ink);
  font-size: 11px;
  font-weight: 650;
  box-shadow: 0 6px 14px -6px rgba(20, 20, 20, 0.5);
  opacity: 0;
  animation: sf-chip var(--sf-t) var(--ease-out) infinite;
}
.sf-chip::before {
  content: "✓ ";
  color: var(--red);
  font-weight: 800;
}
.sf-result {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  animation: sf-result var(--sf-t) var(--ease-out) infinite;
}
.sf-result-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.sf-result-row .thumb {
  width: 20px;
  height: 30px;
  border-radius: 1px 2px 2px 1px;
}
.sf-result-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}
.sf-result-row b,
.sf-result-row small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sf-result-row b {
  font-size: 11.5px;
  font-weight: 650;
}
.sf-result-row small {
  color: var(--dim);
  font-size: 10px;
}
.sf-tick {
  position: relative;
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--red);
}
.sf-tick::after {
  content: "";
  position: absolute;
  left: 4.5px;
  top: 2px;
  width: 3.5px;
  height: 7px;
  border: solid var(--on-red);
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(45deg);
}
.sf-add {
  display: grid;
  place-items: center;
  height: 24px;
  border-radius: 7px;
  background: var(--red);
  color: var(--on-red);
  font-size: 11px;
  font-weight: 650;
  animation: sf-press var(--sf-t) infinite;
}
/* 0–14 %: Buch im Sucher · 15 %: Auslöser und Blitz · 20–42 %: erkannt · 42–58 %: Wechsel zum Ergebnis ·
   72 %: Tipp auf „Hinzufügen“ · 92–100 %: zurück */
@keyframes sf-shutter {
  0%, 12%, 18%, 100% {
    transform: none;
  }
  15% {
    transform: scale(0.75);
  }
}
@keyframes sf-flash {
  0%, 15% {
    opacity: 0;
  }
  16.5% {
    opacity: 0.85;
  }
  21%, 100% {
    opacity: 0;
  }
}
@keyframes sf-phone {
  0%, 42% {
    opacity: 1;
    transform: none;
  }
  56%, 92% {
    opacity: 0;
    transform: translateX(-30px) scale(0.86);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}
@keyframes sf-mark {
  0%, 18% {
    outline-color: transparent;
  }
  22%, 50% {
    outline-color: var(--red);
  }
  56%, 100% {
    outline-color: transparent;
  }
}
@keyframes sf-chip {
  0%, 22% {
    opacity: 0;
    transform: translate(-50%, 6px) scale(0.9);
  }
  28%, 42% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  50%, 100% {
    opacity: 0;
    transform: translate(-50%, 0);
  }
}
@keyframes sf-result {
  0%, 44% {
    opacity: 0;
    transform: translate(30px, -50%) scale(0.92);
  }
  58%, 88% {
    opacity: 1;
    transform: translate(0, -50%);
  }
  96%, 100% {
    opacity: 0;
    transform: translate(0, -50%) scale(0.96);
  }
}
@keyframes sf-press {
  0%, 70%, 78%, 100% {
    transform: none;
    filter: none;
  }
  74% {
    transform: scale(0.93);
    filter: brightness(0.9);
  }
}
@media (prefers-reduced-motion: reduce) {
  .sf-phone,
  .sf-chip {
    display: none;
  }
  .sf-result {
    opacity: 1;
    transform: translateY(-50%);
    animation: none;
  }
  .sf-add {
    animation: none;
  }
}

/* Supporter-Knopf: im Eiche-Design in der Holzfarbe des Supporter-Tags; sonst in der Akzentfarbe. */
html[data-theme="oak"] .btn-support {
  background: var(--shelf-top);
  color: var(--ink);
}
html[data-theme="oak"] .btn-support:hover:not(:disabled) {
  background: var(--shelf-top-2);
}
/* Drei Lieblinge frontal auf einem Brett, jeder mit Schein in seiner Farbe */
.sf-shelf {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 10px;
  margin-top: 6px;
}
.sf-shelf::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -5px;
  height: 5px;
  border-radius: 1px;
  background: var(--shelf-front, var(--steel));
  box-shadow: 0 6px 10px -4px rgba(20, 20, 20, 0.4);
}
.sf-shelf .thumb {
  display: block;
  width: 40px;
  height: 60px;
  border-radius: 2px 4px 4px 2px;
  box-shadow:
    inset 2px 0 0 rgba(255, 255, 255, 0.16),
    0 10px 20px -6px rgba(var(--c, 120, 120, 120), 0.75);
}
.sf-shelf .thumb:nth-child(2) {
  width: 48px;
  height: 72px;
}
@media (max-width: 380px) {
  .sf-shelf {
    gap: 5px;
    padding: 0 6px;
  }
}
.support-cta {
  gap: 8px;
  width: 100%;
}
.support-cta svg {
  width: 18px;
  height: 18px;
  transition: transform 0.25s var(--ease-out);
}
.support-cta:hover svg {
  transform: translateX(3px);
}
.support-later {
  align-self: center;
  margin-top: 12px;
  color: var(--dim);
  font-size: 14px;
  text-decoration: none;
}
.support-later:hover {
  color: var(--ink);
}
.support-free {
  margin: 8px 0 0;
  color: var(--dim);
  font-size: 12.5px;
  text-align: center;
}
.modal.support-modal:focus {
  outline: none;
}
/* Kauf-Fenster: schlanker Kopf mit Zurück-Pfeil, darunter die Plan-Karte im Supporter-Look */
.buy-head {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  padding: 12px 12px 0;
}
.buy-head h2 {
  grid-column: 2;
  font-size: 18px;
  text-align: center;
}
.buy-head #buyCloseBtn {
  grid-column: 3;
}
.buy-plan {
  padding: 20px 20px 18px;
  border-radius: 18px;
}
.buy-plan-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.buy-plan-note {
  color: var(--p-dim);
  font-size: 12.5px;
}
.buy-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 16px 0 0;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
}
.buy-price small {
  color: var(--p-dim);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}
.buy-includes {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 16px 0 0;
  padding: 16px 0 0;
  border-top: 1px solid color-mix(in srgb, var(--p-fg) 14%, transparent);
  list-style: none;
  font-size: 14px;
  line-height: 1.4;
}
.buy-includes li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.buy-includes li::before {
  content: "";
  flex: none;
  width: 5px;
  height: 10px;
  margin: 2px 5px 0 4px;
  border: solid var(--p-badge-bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.buy-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 16px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--tint);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.4;
}
.buy-note svg {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--dim);
}
#buyConfirmBtn:disabled {
  opacity: 0.6;
}
.buy-legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin: 14px 0 0;
  font-size: 12.5px;
}
.buy-legal a {
  color: var(--dim);
  text-underline-offset: 3px;
}
/* Vitrine ohne Premium: der Knopf führt zum Unterstützen-Fenster */
.vitrine-locked svg {
  width: 14px;
  height: 14px;
  color: var(--red);
}

/* Wechsel zwischen Unterstützen- und Kauf-Fenster: Hintergrund bleibt, der Inhalt gleitet seitlich. */
.modal-overlay.is-step,
.modal-overlay.is-step-back {
  animation: none;
}
.is-step .modal {
  animation: step-in 0.34s var(--ease-out);
}
.is-step-back .modal {
  animation: step-back 0.34s var(--ease-out);
}
@keyframes step-in {
  from {
    opacity: 0;
    transform: translateX(28px);
  }
}
@keyframes step-back {
  from {
    opacity: 0;
    transform: translateX(-28px);
  }
}

/* Regal scannen: Prüfliste der erkannten Bücher */
.modal-scan .modal-add-head .modal-title-row {
  margin-bottom: 0;
}
.modal-scan .scan-again {
  margin-right: auto;
}
.modal-scan .modal-lede:empty {
  display: none;
}
/* Kein Buch erkannt: groß und mittig zwischen Kopf und Fuß des Fensters */
.scan-empty {
  margin: 0;
  padding: 26px 8px 4px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  text-align: center;
  text-wrap: balance;
}
/* Während das Foto gelesen wird, geht das Fenster nur über „Abbrechen“ zu */
.is-busy #closeScanBtn {
  visibility: hidden;
}
.scan-loading {
  width: 28px;
  height: 28px;
  margin: 48px auto;
  border-radius: 50%;
  border: 3px solid var(--spin-track);
  border-top-color: var(--spin-head);
  animation: spin 0.8s linear infinite;
}
/* Ergebnis-Kopf: Anzahl groß wie die Zahlen im Regal-Kopf, daneben die Aufteilung */
.scan-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--r-card);
  background: var(--surface-2);
}
.scan-summary > b {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.scan-summary > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.scan-summary strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.scan-summary small {
  color: var(--dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.scan-section {
  margin-top: 20px;
}
.scan-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.scan-section-head h3 {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}
.scan-section-head h3 span {
  margin-left: 4px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.scan-section-head .link-btn {
  color: var(--ink-2);
  font-size: 13px;
}
.scan-section-hint {
  margin: 0 0 6px;
  color: var(--dim);
  font-size: 13px;
}
.scan-owned > summary {
  cursor: pointer;
  list-style: none;
}
.scan-owned > summary::-webkit-details-marker {
  display: none;
}
.scan-owned > summary h3::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-right: 2px solid var(--dim);
  border-bottom: 2px solid var(--dim);
  transform: translateY(-3px) rotate(45deg);
  transition: transform 0.15s ease;
}
.scan-owned[open] > summary h3::after {
  transform: translateY(0) rotate(-135deg);
}
.scan-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}
.scan-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.scan-row:last-child {
  border-bottom: none;
}
.scan-pick {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  cursor: pointer;
}
/* Runder Haken in der Akzentfarbe statt der Standard-Checkbox */
.scan-check {
  flex: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface) center / 14px no-repeat;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.scan-check:checked {
  border-color: var(--red);
  background-color: var(--red);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='5 12.5 10 17 19 7'/%3E%3C/svg%3E");
}
.scan-check:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.scan-cover {
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 54px;
  overflow: hidden;
  border-radius: 1px 3px 3px 1px;
  background: var(--surface-2);
  box-shadow: 0 8px 12px -8px rgba(20, 20, 20, 0.45), inset 2px 0 0 rgba(20, 20, 20, 0.06);
}
.scan-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: fade-in 0.25s ease;
}
.scan-cover > span {
  color: var(--dim);
  font-size: 16px;
  font-weight: 800;
}
.scan-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.scan-text b,
.scan-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scan-text b {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.scan-text small {
  color: var(--dim);
  font-size: 13px;
}
.scan-row:not(.is-on) .scan-cover,
.scan-row:not(.is-on) .scan-text {
  opacity: 0.5;
  transition: opacity 0.15s ease;
}
.scan-edit[aria-expanded="true"] {
  background: var(--tint);
  color: var(--ink);
}
.scan-editor {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 4px 36px;
}
.scan-editor .field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.scan-editor input {
  min-height: 38px;
  font-size: 14px;
}
/* Eigene Bild-URL gibt es im Neues-Buch-Dialog; hier bleibt es bei den gefundenen Covern. */
.scan-editor .cp-url {
  display: none;
}
@media (max-width: 640px) {
  .scan-editor {
    padding-left: 0;
  }
  .scan-editor .field-row {
    grid-template-columns: 1fr;
  }
  /* Drei Knöpfe passen nicht nebeneinander: Speichern volle Breite, die anderen darunter. */
  .modal-scan .modal-add-foot {
    flex-wrap: wrap;
  }
  .modal-scan #saveScanBtn {
    flex: 1 0 100%;
    order: -1;
  }
  .modal-scan .modal-add-foot .btn-ghost {
    flex: 1 1 0;
    margin: 0;
  }
}

.add-book-card {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
}
.add-preview {
  position: relative;
  align-self: start;
  aspect-ratio: 2 / 3;
  margin-top: 2px;
  overflow: hidden;
  border-radius: 2px 5px 5px 2px;
  background: var(--wall-2);
  box-shadow: 0 12px 20px -12px rgba(20, 20, 20, 0.55);
}
.add-preview::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 9px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.1) 55%, transparent);
  pointer-events: none;
}
.add-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: fade-in 0.25s ease;
}
.add-preview-blank {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  height: 100%;
  padding: 12px 10px 12px 15px;
}
.add-preview-blank b {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.add-preview-blank small {
  color: var(--dim);
  font-size: 11px;
  line-height: 1.2;
}
.add-preview.is-empty .add-preview-blank b {
  color: var(--dim);
  font-weight: 600;
}
.add-book-fields > .field:first-child {
  margin-top: 0;
}
.add-book-fields .field-row {
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 12px;
}
/* Die Reihenliste läuft unter dem Seitenfeld weiter, damit lange Namen Platz haben. */
.add-book-fields .combo-list {
  right: -108px;
}
.field-hint {
  display: block;
  margin-top: 8px;
  color: var(--dim);
  font-size: 13px;
}
.more-genres {
  margin-top: 10px;
}
.more-genres summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  margin-left: -10px;
  border-radius: var(--r-control);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.more-genres summary::-webkit-details-marker {
  display: none;
}
.more-genres summary::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}
.more-genres[open] summary::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}
.more-genres summary:hover {
  background: var(--tint);
}
.more-genres .cat-toggle-list {
  margin-top: 8px;
}
.cat-toggle.cat-new {
  border-style: dashed;
  background: transparent;
  color: var(--dim);
}
.cat-toggle.cat-new:hover:not(:disabled) {
  color: var(--ink);
}
.suggest-genres {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}
.suggest-genres span {
  height: 20px;
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--tint);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}
@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}

.cat-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 18px;
}
.field .cat-chip-list {
  margin-top: 0;
}
.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  padding: 0 4px 0 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  font-size: 13px;
  font-weight: 600;
}
.cat-chip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--dim);
  cursor: pointer;
  padding: 0;
}
.cat-chip button svg {
  width: 12px;
  height: 12px;
}
.cat-chip button:hover {
  background: var(--red-soft);
  color: var(--red-hover);
}
.cat-empty {
  margin: 0;
  color: var(--dim);
  font-size: 14px;
}
.add-cat-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}
.field .add-cat-row {
  margin-top: 0;
}
.add-cat-row input {
  flex: 1;
}

/* ---------- empty states ---------- */
.empty-state {
  padding: 56px 20px 0;
  text-align: center;
}
.empty-state p {
  margin: 0 auto;
  max-width: 36ch;
  color: var(--dim);
  font-size: 16px;
}
.empty-state::after {
  content: "";
  display: block;
  max-width: 460px;
  height: 22px;
  margin: 44px auto 0;
  border-radius: 3px;
  background:
    linear-gradient(180deg, var(--shelf-hi) 0, var(--shelf-top) 1px, var(--shelf-top-2) 6px, var(--shelf-edge) 6px, var(--shelf-edge) 7px, transparent 7px),
    var(--shelf-texture),
    linear-gradient(180deg, var(--shelf-front) 7px, var(--shelf-front-2) 100%);
  box-shadow: 0 16px 22px -12px var(--shelf-shadow);
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: var(--r-control);
  background: var(--ink);
  color: var(--on-ink);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translate(-50%, 10px);
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    transform 0.4s var(--ease-out);
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Einführung ---------- */
/* Über Dialogen und Cover-Zoom, unter dem Toast. Die Ebene fängt alle Klicks ab, damit die Tour nicht versehentlich verlassen wird. */
.tour {
  position: fixed;
  inset: 0;
  z-index: 70;
  /* Wird nur ausgelesen: Abstand des Kärtchens zu Notch und Home-Balken */
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  animation: fade-in 0.2s ease;
}
.tour-spot {
  position: fixed;
  border-radius: var(--r-control);
  box-shadow: 0 0 0 2px var(--red), 0 0 0 9999px rgba(20, 20, 20, 0.5);
  pointer-events: none;
  transition:
    left 0.4s var(--ease-out),
    top 0.4s var(--ease-out),
    width 0.4s var(--ease-out),
    height 0.4s var(--ease-out);
}
.tour.is-center .tour-spot {
  box-shadow: 0 0 0 9999px rgba(20, 20, 20, 0.5);
}
.tour-card {
  position: fixed;
  width: min(360px, calc(100vw - 32px));
  padding: 20px 20px 16px;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  transition:
    left 0.4s var(--ease-out),
    top 0.4s var(--ease-out);
}
.tour-card h2 {
  margin: 12px 0 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  text-wrap: balance;
}
.tour-text {
  margin: 6px 0 0;
  color: var(--dim);
  font-size: 14px;
  line-height: 1.45;
  text-wrap: pretty;
}
.tour-dots {
  display: flex;
  gap: 5px;
}
.tour-dots i {
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--line-strong);
  transition:
    width 0.3s var(--ease-out),
    background-color 0.3s ease;
}
.tour-dots i.on {
  width: 18px;
  background: var(--red);
}
.tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 18px;
}
.tour-actions > .btn-ghost {
  margin-left: -10px;
}
.tour-nav {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ---------- responsive ---------- */
/* ---------- Startseite ---------- */
body[data-route="home"] #tocMenuBtn,
body[data-route="browse"] #tocMenuBtn,
body[data-route="admin"] #tocMenuBtn {
  display: none !important;
}
.home {
  padding-top: 64px;
}
.hero-copy {
  max-width: 720px;
}
/* Breite Screens: Überschrift links, Text und Knöpfe rechts, damit das Regal ohne Scrollen zu sehen ist. */
@media (min-width: 1024px) {
  .page.home {
    padding-top: 48px;
  }
  .home .hero-copy {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    column-gap: 56px;
    align-items: end;
    max-width: none;
  }
  .home .hero-title {
    grid-row: 1 / span 3;
    font-size: clamp(56px, 5.6vw, 80px);
  }
  .home .hero-lede {
    margin-top: 0;
  }
  .home .hero-scene {
    margin-top: 28px;
  }
}
.hero-title {
  max-width: 13ch;
  font-size: clamp(40px, 6.6vw, 86px);
  line-height: 0.98;
  letter-spacing: -0.05em;
}
.hero-title span {
  display: block;
  color: var(--red);
}
.hero-lede {
  max-width: 46ch;
  margin: 24px 0 0;
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1.55;
  text-wrap: pretty;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}
.btn-lg {
  height: 52px;
  padding: 0 24px;
  border-radius: 14px;
  font-size: 16px;
}
a.btn {
  text-decoration: none;
}
.hero-note {
  margin: 14px 0 0;
  color: var(--dim);
  font-size: 13px;
}

/* Schaufenster an der Wand: je Reihe ein Cover, alle gleich hoch, mit ruhigem Abstand. */
.hero-scene {
  --display-h: min(268px, 18.5vw);
  position: relative;
  margin: 64px -28px 0;
  padding-top: 30px;
}
.hero-scene::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -40px;
  width: min(900px, 90%);
  height: 420px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse 50% 50% at 50% 50%, var(--wall-glow), transparent 70%);
  pointer-events: none;
}
.hero-shelf .ledge-wrap,
.demo-turn .ledge-wrap {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}
.demo-turn .ledge {
  justify-content: center;
  overflow: hidden;
  min-height: 0;
  pointer-events: none;
}
.display-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(18px, 3vw, 40px);
  padding: 0 clamp(28px, 4vw, 56px) 3px;
}
.display-slot {
  position: relative;
  flex: none;
  height: var(--display-h);
  aspect-ratio: 0.66;
}
/* Kontaktschatten, wo das Buch auf dem Brett steht */
.display-slot::after {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: -2px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  filter: blur(3px);
  z-index: -1;
}
.display-cover {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 2px 5px 5px 2px;
  background: rgb(var(--c, 120, 120, 120));
  box-shadow:
    inset 4px 0 0 rgba(255, 255, 255, 0.16),
    inset 9px 0 9px -5px rgba(0, 0, 0, 0.3),
    16px 20px 30px -16px rgba(20, 20, 20, 0.5);
  opacity: 0;
  transition: opacity 1.2s ease;
}
.display-cover.is-front {
  opacity: 1;
}
.display-cover.has-cover {
  background: var(--cover) center / cover, rgb(var(--c, 120, 120, 120));
}
.display-cover .gen-cover b {
  font-size: min(18px, 16cqi);
}
.hero-caption {
  position: relative;
  margin-top: 40px;
  color: var(--dim);
  font-size: 13px;
  text-align: center;
}
.hero-caption a {
  color: var(--ink);
  font-weight: 600;
  text-underline-offset: 3px;
}

.section-title {
  margin: 0;
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.1;
  text-wrap: balance;
}
.steps {
  margin-top: 128px;
}
.step-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 18px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}
.step {
  padding: 14px 14px 22px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
}
.step h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 6px 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.step-no {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
}
.step p {
  margin: 8px 6px 0;
  color: var(--dim);
  font-size: 15px;
  line-height: 1.5;
}
.step-demo {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 184px;
  padding: 18px;
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
}
.demo-input {
  display: flex;
  align-items: center;
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--red);
  border-radius: 10px;
  box-shadow: var(--focus);
  font-size: 14px;
  font-weight: 500;
}
.demo-caret {
  width: 1.5px;
  height: 17px;
  margin-left: 1px;
  background: var(--ink);
  animation: caret 1.1s steps(1) infinite;
}
@keyframes caret {
  50% {
    opacity: 0;
  }
}
.demo-suggest {
  margin-top: 6px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
}
.demo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px;
  border-radius: 7px;
}
.demo-row:first-child {
  background: var(--tint);
}
.demo-row > span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.demo-row b {
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.demo-row small {
  color: var(--dim);
  font-size: 11.5px;
}
.thumb {
  flex: none;
  width: 22px;
  height: 33px;
  border-radius: 2px;
  background: rgb(var(--c, 120, 120, 120));
}
.thumb.has-cover {
  background: var(--cover) center / cover, rgb(var(--c, 120, 120, 120));
}
.demo-turn {
  --ledge-h: 124px;
  --spine-scale: 0.72;
  justify-content: flex-end;
  padding-bottom: 30px;
}
.demo-turn .ledge {
  padding: 0 22px 3px;
}
.demo-share {
  align-items: center;
  gap: 12px;
}
.demo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: 13px;
  white-space: nowrap;
}
.demo-link > span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.demo-link svg {
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--red);
}
.demo-host {
  color: var(--dim);
}
.demo-copied {
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--on-ink);
  font-size: 12px;
  font-weight: 600;
  animation: copied 3.4s var(--ease-out) infinite;
}
@keyframes copied {
  0%, 18% {
    opacity: 0;
    transform: translateY(6px);
  }
  28%, 78% {
    opacity: 1;
    transform: none;
  }
  90%, 100% {
    opacity: 0;
  }
}

/* Supporter-Extras: Scannen und Vitrine, ohne Preis */
/* Hebt sich als eigenes Panel ab: in hellen Designs dunkel, in dunklen eine Stufe heller, mit Schein in der Akzentfarbe. */
.supporter-panel {
  --p-bg: var(--ink);
  --p-fg: var(--on-ink);
  --p-dim: color-mix(in srgb, var(--on-ink) 66%, transparent);
  --p-card: var(--surface);
  --p-glow-a: color-mix(in srgb, var(--red) 34%, transparent);
  --p-glow-b: color-mix(in srgb, var(--red) 14%, transparent);
  --p-badge-bg: var(--red);
  --p-badge-fg: var(--on-red);
  background:
    radial-gradient(ellipse 55% 70% at 100% 0%, var(--p-glow-a), transparent 70%),
    radial-gradient(ellipse 40% 60% at 0% 100%, var(--p-glow-b), transparent 70%),
    var(--p-bg);
  color: var(--p-fg);
  box-shadow: 0 30px 60px -30px rgba(20, 20, 20, 0.45);
}
.perks {
  margin-top: 128px;
  padding: 48px 44px 40px;
  border-radius: 28px;
}
/* Eiche: dunkles Nussholz mit warmem Bernstein-Schein, wie eine Holzvitrine. */
html[data-theme="oak"] .supporter-panel {
  --p-bg: #34251a;
  --p-dim: rgba(255, 245, 230, 0.72);
  --p-glow-a: rgba(226, 172, 98, 0.34);
  --p-glow-b: rgba(226, 172, 98, 0.14);
  --p-badge-bg: var(--shelf-top);
  --p-badge-fg: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 235, 200, 0.12),
    0 30px 60px -30px rgba(70, 45, 20, 0.55);
}
html[data-theme="dark"] .supporter-panel,
html[data-theme="midnight"] .supporter-panel {
  --p-bg: var(--wall-2);
  --p-fg: var(--ink);
  --p-dim: var(--dim);
  --p-card: var(--surface-2);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 35%, transparent);
}
html[data-theme="dark"] .perks .step-demo,
html[data-theme="midnight"] .perks .step-demo {
  background-color: var(--surface);
}
.perks-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 14px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--p-badge-bg);
  color: var(--p-badge-fg);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.perks-eyebrow svg {
  width: 13px;
  height: 13px;
}
.perks-lede {
  max-width: 56ch;
  margin: 12px 0 0;
  color: var(--p-dim);
  font-size: 16px;
  line-height: 1.55;
  text-wrap: pretty;
}
.perk-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 18px;
  margin: 28px 0 0;
  padding: 0;
  list-style: none;
}
.perk {
  padding: 14px 14px 22px;
  background: var(--p-card);
  color: var(--ink);
  border-radius: var(--r-card);
}
.perk .step-demo {
  height: 220px;
}
.perk-kind {
  display: inline-block;
  margin: 18px 6px 0;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--red-soft);
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
}
.perk h3 {
  margin: 10px 6px 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.perk p {
  margin: 8px 6px 0;
  color: var(--dim);
  font-size: 15px;
  line-height: 1.5;
}
.perks-cta {
  display: flex;
  justify-content: flex-end;
  margin-top: 28px;
}

/* Scannen: das Handy fotografiert das Regal, die Buchrücken werden nacheinander markiert, daneben
   füllt sich die Trefferliste, am Ende ein Tipp auf „Ins Regal stellen“. Alles läuft im selben 6-s-Takt. */
.demo-scan {
  --ledge-h: 92px;
  --spine-scale: 0.5;
  --scan-t: 6s;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px;
}
.scan-phone {
  position: relative;
  flex: none;
  width: 112px;
  height: 188px;
  padding: 6px 6px 30px;
  border-radius: 20px;
  background: var(--ink);
  box-shadow: 0 16px 30px -16px rgba(20, 20, 20, 0.6);
}
.scan-shot {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  padding-bottom: 22px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--wall);
}
.demo-scan .ledge {
  justify-content: center;
  overflow: visible;
  gap: 5px;
  min-height: 0;
  padding: 0 6px 3px;
  pointer-events: none;
}
/* Das Brett geht über den ganzen Bildschirm, wie auf einem echten Foto. */
.demo-scan .ledge-wrap {
  width: 100%;
}
.demo-scan .ledge-wrap::after {
  left: -8px;
  right: -8px;
}
/* Rahmen um jeden erkannten Buchrücken, einer nach dem anderen. */
.demo-scan .book .face.spine {
  outline: 1.5px solid transparent;
  outline-offset: 1.5px;
  animation: scan-mark var(--scan-t) infinite;
}
.demo-scan .book:nth-child(2) .face.spine { animation-delay: 0.35s; }
.demo-scan .book:nth-child(3) .face.spine { animation-delay: 0.7s; }
.demo-scan .book:nth-child(4) .face.spine { animation-delay: 1.05s; }
@keyframes scan-mark {
  0%, 12% {
    outline-color: transparent;
  }
  16%, 82% {
    outline-color: var(--red);
  }
  90%, 100% {
    outline-color: transparent;
  }
}
.scan-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  animation: scan-flash var(--scan-t) infinite;
  pointer-events: none;
}
@keyframes scan-flash {
  0%, 5% {
    opacity: 0;
  }
  7% {
    opacity: 0.85;
  }
  13%, 100% {
    opacity: 0;
  }
}
.scan-shutter {
  position: absolute;
  bottom: 7px;
  left: 50%;
  width: 18px;
  height: 18px;
  margin-left: -9px;
  border-radius: 50%;
  background: var(--on-ink);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 3.5px var(--on-ink);
  animation: scan-press var(--scan-t) infinite;
}
@keyframes scan-press {
  0%, 3%, 9%, 100% {
    transform: none;
  }
  6% {
    transform: scale(0.8);
  }
}
.scan-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(210px, 100%);
  min-width: 0;
}
.scan-hits {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
}
.scan-hits li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 5px;
  border-radius: 7px;
  opacity: 0;
  animation: scan-hit var(--scan-t) infinite;
}
.scan-hits li:nth-child(2) { animation-delay: 0.35s; }
.scan-hits li:nth-child(3) { animation-delay: 0.7s; }
.scan-hits li:nth-child(4) { animation-delay: 1.05s; }
@keyframes scan-hit {
  0%, 14% {
    opacity: 0;
    transform: translateX(-8px);
  }
  20%, 86% {
    opacity: 1;
    transform: none;
  }
  94%, 100% {
    opacity: 0;
  }
}
.scan-hits .thumb {
  width: 18px;
  height: 27px;
}
.scan-hit-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}
.scan-hits b,
.scan-hits small {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.scan-hits b {
  font-size: 12px;
  font-weight: 600;
}
.scan-hits small {
  color: var(--dim);
  font-size: 10.5px;
}
.scan-tick {
  position: relative;
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 5px;
  background: var(--red);
}
.scan-tick::after {
  content: "";
  position: absolute;
  left: 5.5px;
  top: 2.5px;
  width: 4px;
  height: 8px;
  border: solid var(--on-red);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.scan-go {
  display: grid;
  place-items: center;
  height: 30px;
  border-radius: 9px;
  background: var(--red);
  color: var(--on-red);
  font-size: 12px;
  font-weight: 650;
  opacity: 0;
  animation: scan-go var(--scan-t) infinite;
}
@keyframes scan-go {
  0%, 40% {
    opacity: 0;
    transform: translateY(6px);
  }
  46%, 62% {
    opacity: 1;
    transform: none;
  }
  65% {
    transform: scale(0.94);
  }
  68%, 86% {
    opacity: 1;
    transform: none;
  }
  94%, 100% {
    opacity: 0;
  }
}

/* Vitrine: drei Cover frontal, jedes mit farbigem Schein, auf einem dunklen Brett. */
.demo-vitrine {
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 34px;
  background: radial-gradient(ellipse 60% 70% at 50% 45%, var(--wall-glow), transparent 75%), var(--surface-2);
}
.demo-vitrine .ledge-wrap {
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}
.demo-vitrine-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  gap: 22px;
  padding: 0 26px 3px;
}
.demo-vitrine-item {
  position: relative;
  display: block;
}
.demo-vitrine-item .thumb {
  position: relative;
  display: block;
  width: 84px;
  height: 126px;
  border-radius: 2px 4px 4px 2px;
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, 0.16),
    inset 7px 0 7px -4px rgba(0, 0, 0, 0.3),
    10px 14px 22px -12px rgba(20, 20, 20, 0.55);
}
.demo-vitrine-item:nth-child(2) .thumb {
  width: 96px;
  height: 144px;
}
.demo-vitrine-glow {
  position: absolute;
  inset: 8% -10% 12%;
  border-radius: 50%;
  background: rgb(var(--c, 120, 120, 120));
  opacity: 0.5;
  filter: blur(22px);
}
html[data-theme="dark"] .demo-vitrine-glow,
html[data-theme="midnight"] .demo-vitrine-glow {
  opacity: 0.75;
}
@media (prefers-reduced-motion: reduce) {
  .demo-scan *,
  .demo-scan .book .face.spine {
    animation: none !important;
  }
  .scan-hits li,
  .scan-go {
    opacity: 1;
  }
}

/* ---------- Übersicht: Leserliste ---------- */
.reader-list {
  margin-top: 28px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  overflow: hidden;
}
.reader-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  color: inherit;
  text-decoration: none;
  transition: background 0.2s;
}
.reader-row + .reader-row {
  border-top: 1px solid var(--line-soft);
}
a.reader-row:hover {
  background: var(--surface-2);
}
a.reader-row:focus-visible {
  outline: none;
  box-shadow: inset var(--focus);
}
.reader-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--wall-2);
}
.reader-avatar-fallback {
  display: grid;
  place-items: center;
  background: var(--red);
  color: var(--on-red);
  font-size: 17px;
  font-weight: 700;
}
.reader-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.reader-text b {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.reader-text small {
  color: var(--dim);
  font-size: 13px;
}
.reader-series {
  overflow: hidden;
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.reader-series em {
  color: var(--dim);
  font-style: normal;
}
.reader-covers {
  display: flex;
  gap: 8px;
}
.reader-covers .thumb {
  width: 44px;
  height: 66px;
  border-radius: 2px 4px 4px 2px;
  box-shadow:
    inset 3px 0 0 rgba(255, 255, 255, 0.14),
    0 6px 12px -6px rgba(20, 20, 20, 0.45);
}
.thumb.is-loading {
  background: var(--skeleton);
}
.reader-go {
  color: var(--dim);
  font-size: 18px;
  transition: transform 0.3s var(--ease-out), color 0.2s;
}
a.reader-row:hover .reader-go {
  color: var(--ink);
  transform: translateX(3px);
}
.reader-row.is-empty .reader-avatar {
  opacity: 0.75;
}
.reader-row.is-skeleton .reader-avatar,
.reader-row.is-skeleton b,
.reader-row.is-skeleton small,
.reader-row.is-skeleton .thumb {
  display: block;
  background: var(--skeleton);
  box-shadow: none;
}
.reader-row.is-skeleton b {
  width: 150px;
  height: 14px;
  border-radius: 4px;
}
.reader-row.is-skeleton small {
  width: 110px;
  height: 11px;
  border-radius: 4px;
}
.browse-count {
  color: var(--ink-2);
  font-weight: 600;
}
.cards-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 24px 0;
  color: var(--dim);
}

.home-foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 96px;
  padding-top: 22px;
  border-top: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 13px;
}
.home-foot span:first-child {
  color: var(--ink-2);
  font-weight: 700;
}

/* Impressum und Datenschutz: Links im Fuß, und die beiden Seiten selbst */
.legal-links {
  display: flex;
  gap: 18px;
}
.legal-links a,
.scan-privacy a,
.legal a {
  color: inherit;
  text-underline-offset: 3px;
}
.site-legal {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 28px 40px;
  color: var(--dim);
  font-size: 13px;
}
/* Die Startseite zeigt die Links schon in ihrem eigenen Fuß. */
body:has(#homeView:not(.hidden)) .site-legal {
  display: none;
}
.scan-privacy {
  margin: 0;
  padding: 10px 28px 0;
  border-top: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 12.5px;
}
.modal-scan .modal-add-foot {
  border-top: none;
}
.legal {
  max-width: 720px;
  line-height: 1.6;
}
.legal h1 {
  margin: 0 0 12px;
  /* "Datenschutzerklärung" ist ein langes Wort: auf schmalen Handys kleiner setzen und trennen. */
  font-size: clamp(28px, 8vw, 44px);
  hyphens: auto;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
}
.legal h2 {
  scroll-margin-top: 80px; /* Sprungmarken (agb.html#widerruf) nicht unter der Kopfleiste */
  margin: 36px 0 8px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.025em;
}
.legal h3 {
  margin: 22px 0 6px;
  font-size: 16px;
  font-weight: 700;
}
.legal p,
.legal li {
  color: var(--ink-2);
  font-size: 15px;
}
.legal ul {
  padding-left: 20px;
}
.legal-lede {
  color: var(--dim);
  font-size: 17px;
}
.legal-foot {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  color: var(--dim);
}
/* Platzhalter, die vor dem Veröffentlichen ersetzt werden müssen, fallen sofort auf. */
.legal .todo {
  padding: 0 4px;
  border-radius: 4px;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 600;
}
@media (max-width: 640px) {
  .site-legal {
    padding: 0 16px 32px;
  }
  .scan-privacy {
    padding: 10px 16px 0;
  }
}

.browse-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px 24px;
  margin-bottom: 8px;
}
.browse-lede {
  margin: 12px 0 0;
  color: var(--dim);
  font-size: 16px;
}
.browse-search {
  width: 300px;
}

/* ---------- Kontomenü, Profil und Rückfragen ---------- */
.profile-links {
  display: flex;
  flex-direction: column;
  margin: 4px -8px 10px;
  padding: 6px 0;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}
.profile-link {
  display: block;
  padding: 9px 10px;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.profile-link:hover {
  background: var(--tint);
}
.account-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
}
.account-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--wall-2);
}
.account-name {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.account-handle {
  margin: 2px 0 0;
  color: var(--dim);
  font-size: 14px;
}
.account-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 18px 0 0;
}
.account-facts div {
  display: flex;
  flex-direction: column-reverse;
  gap: 2px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
}
.account-facts dt {
  color: var(--dim);
  font-size: 12px;
}
.account-facts dd {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.account-banned {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  line-height: 1.45;
}
.account-form {
  padding: 4px 0 8px;
}
.account-form .field:first-child {
  margin-top: 8px;
}
.account-danger .field > span {
  color: var(--danger);
}

/* ---------- Verwaltung ---------- */
.admin-gate {
  display: flex;
  justify-content: center;
  padding: 32px 0;
}
.gate-card {
  width: 100%;
  max-width: 440px;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  text-align: center;
}
.gate-icon {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--red-soft);
  color: var(--red);
}
.gate-icon svg {
  width: 22px;
  height: 22px;
}
.gate-card h2 {
  margin: 14px 0 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.gate-card p {
  margin: 8px 0 0;
  color: var(--dim);
  line-height: 1.5;
}
.gate-actions {
  margin-top: 20px;
}
.mfa-qr {
  display: block;
  width: 180px;
  height: 180px;
  margin: 0 auto;
  padding: 10px;
  border-radius: 12px;
  background: #fff;
}
.gate-card .mfa-secret {
  margin-top: 12px;
  font-size: 13px;
}
.mfa-secret code {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.06em;
  word-break: break-all;
}
.mfa-form {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}
.mfa-form input {
  flex: 1;
  min-width: 0;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
  text-align: center;
}
.admin-stats {
  flex-wrap: wrap;
  row-gap: 14px;
  margin: 22px 0 0;
}
.admin-toolbar {
  margin-top: 24px;
}
.admin-users {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  overflow: hidden;
}
.admin-user + .admin-user {
  border-top: 1px solid var(--line-soft);
}
.admin-user-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.admin-user-head:hover,
.admin-user.open .admin-user-head {
  background: var(--surface-2);
}
.admin-user-head .reader-avatar {
  width: 38px;
  height: 38px;
}
.admin-user-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.admin-user-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.admin-user-name b {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-user-main small {
  overflow: hidden;
  color: var(--dim);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge {
  flex: none;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--red-soft);
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
}
.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge-premium {
  background: var(--tint);
  color: var(--ink);
}
.admin-user-meta {
  display: flex;
  gap: 18px;
  color: var(--dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.admin-chevron {
  width: 18px;
  height: 18px;
  color: var(--dim);
  transition: transform 0.25s var(--ease-out);
}
.admin-user.open .admin-chevron {
  transform: rotate(180deg);
}
.admin-user.is-banned .admin-user-name b {
  color: var(--dim);
}
.admin-user-body {
  padding: 4px 20px 20px 74px;
  background: var(--surface-2);
}
.admin-note {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 14px;
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-books {
  margin-top: 18px;
}
.admin-books h3 {
  margin: 0 0 6px;
  color: var(--dim);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.admin-books ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.admin-books li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--line-soft);
}
.admin-books li > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.admin-books li b {
  font-size: 14px;
  font-weight: 600;
}
.admin-books li small {
  color: var(--dim);
  font-size: 12.5px;
}
.admin-books .icon-btn svg {
  width: 16px;
  height: 16px;
}
.admin-books .icon-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.admin-muted {
  margin: 0;
  color: var(--dim);
  font-size: 14px;
}
.admin-log-title {
  margin-top: 48px;
  font-size: 22px;
}
.admin-log {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}
.admin-log li {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 14px;
}
.admin-log time {
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.admin-costs-lede {
  max-width: 640px;
  margin-top: 8px;
  line-height: 1.5;
}
.admin-cost-list {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
  overflow: hidden;
}
.admin-cost-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px 130px 130px 32px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 20px;
}
.admin-cost-row + .admin-cost-row {
  border-top: 1px solid var(--line-soft);
}
.admin-cost-row.is-auto {
  padding-top: 14px;
  padding-bottom: 14px;
  background: var(--surface-2);
}
.admin-cost-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  grid-column: 1 / 4;
  min-width: 0;
}
.admin-cost-main b {
  font-size: 15px;
}
.admin-cost-main small {
  color: var(--dim);
  font-size: 13px;
  line-height: 1.45;
}
.admin-cost-amount {
  display: flex;
  gap: 6px;
}
.admin-cost-amount input {
  min-width: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.admin-cost-amount select {
  width: 56px;
  flex: none;
  padding-inline: 8px;
}
.admin-cost-month {
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.admin-cost-row .icon-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}
.admin-cost-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.admin-cost-assume {
  margin-top: 18px;
}
.admin-sub {
  margin: 36px 0 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.limit-meters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.limit-meter {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
}
.limit-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}
.limit-head span {
  color: var(--dim);
  font-size: 12px;
  font-weight: 600;
}
.limit-value {
  margin: 8px 0 0;
  color: var(--dim);
  font-size: 13px;
}
.limit-value strong {
  margin-right: 2px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.limit-value .badge {
  margin-left: 4px;
  vertical-align: 3px;
}
.limit-track {
  height: 8px;
  margin-top: 10px;
  border-radius: var(--r-pill);
  background: var(--tint);
  overflow: hidden;
}
.limit-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}
.limit-meter.is-near .limit-track,
.limit-meter.is-over .limit-track {
  background: var(--danger-soft);
}
.limit-meter.is-near .limit-track span,
.limit-meter.is-over .limit-track span {
  background: var(--danger);
}
.limit-meter small {
  display: block;
  margin-top: 8px;
  color: var(--dim);
  font-size: 12.5px;
  line-height: 1.45;
}
.limit-hint {
  grid-column: 1 / -1;
  font-size: 13px;
}
.usage-chart {
  margin: 16px 0 0;
  padding: 16px 18px 12px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-card);
}
.usage-chart figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  font-size: 14px;
}
.usage-chart figcaption small {
  color: var(--dim);
  font-size: 12.5px;
}
.usage-plot {
  position: relative;
  margin-top: 10px;
}
.usage-svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}
.usage-svg:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}
.usage-grid {
  stroke: var(--line-soft);
  stroke-width: 1;
}
.usage-tick,
.usage-label {
  fill: var(--dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.usage-label {
  fill: var(--ink-2);
  font-weight: 600;
}
.usage-bar {
  fill: var(--dim);
  transition: opacity 0.15s ease;
}
.usage-bar.is-today {
  fill: var(--red);
}
.usage-svg:hover .usage-bar:not(.is-active),
.usage-svg:focus-visible .usage-bar:not(.is-active) {
  opacity: 0.55;
}
.usage-cross {
  stroke: var(--line-strong);
  stroke-width: 1;
}
.usage-tip {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  font-size: 12.5px;
  pointer-events: none;
  white-space: nowrap;
}
.usage-tip strong {
  font-size: 15px;
}
.usage-tip span {
  color: var(--dim);
}
.usage-table {
  margin-top: 8px;
}
.usage-table summary {
  width: fit-content;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.usage-table table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.usage-table th,
.usage-table td {
  padding: 5px 0;
  border-top: 1px solid var(--line-soft);
  text-align: right;
}
.usage-table th:first-child,
.usage-table td:first-child {
  text-align: left;
}
.usage-table th {
  color: var(--dim);
  font-weight: 600;
}
.admin-cost-assume summary {
  width: fit-content;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.admin-cost-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-items: end;
  column-gap: 14px;
}

@media (max-width: 900px) {
  .toolbar {
    gap: 10px;
  }
  .toolbar-end {
    display: contents;
  }
  .shelf-search {
    order: 0;
    flex: 1 1 60%;
    width: auto;
  }
  .header-actions {
    order: 1;
  }
  .toolbar .seg {
    order: 2;
  }
  .filter-bar {
    order: 3;
    flex: 1 1 0;
    margin-right: -28px;
    padding-right: 28px;
  }
}

@media (max-width: 640px) {
  :root {
    --ledge-h: 172px;
    --spine-scale: 0.86;
  }
  .topbar {
    padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    gap: 6px;
  }
  /* Unter 16px zoomt iOS beim Antippen hinein und die Seite bleibt danach seitlich verschiebbar. */
  input,
  select,
  textarea,
  .search-box input[type="text"] {
    font-size: 16px;
  }
  .brand-name {
    display: none;
  }
  .page {
    padding: 18px 16px 80px;
  }
  .filter-bar {
    margin-right: -16px;
    padding-right: 16px;
  }
  .shelf-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 14px;
  }
  .shelf-meta {
    margin-top: 8px;
  }
  /* Zwei feste Zeilen: Suche mit den Aktionen, darunter Ansicht und Filter. */
  .toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      "search search cat scan add"
      "view   chips  chips chips chips";
    gap: 12px 8px;
    align-items: center;
    padding: 8px 0 14px;
    margin-bottom: 6px;
  }
  .header-actions {
    display: contents;
  }
  .shelf-search {
    grid-area: search;
  }
  #openCatBtn {
    grid-area: cat;
  }
  #openScanBtn {
    grid-area: scan;
  }
  #openAddBtn {
    grid-area: add;
  }
  .toolbar .seg {
    grid-area: view;
  }
  .filter-bar {
    grid-area: chips;
  }
  .filter-bar .filter-pill {
    height: 36px;
  }
  #openCatBtn,
  #openScanBtn,
  #openAddBtn {
    width: 40px;
    padding: 0;
  }
  #openCatBtn span,
  #openScanBtn span,
  #openAddBtn span,
  .toolbar .seg span {
    display: none;
  }
  #openCatBtn svg,
  #openScanBtn svg {
    display: block;
    width: 18px;
    height: 18px;
  }
  #openAddBtn svg {
    width: 18px;
    height: 18px;
  }
  .toolbar .seg button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 28px;
    padding: 0;
    border-radius: 8px;
  }
  .toolbar .seg svg {
    display: block;
    width: 17px;
    height: 17px;
  }
  #shelves {
    padding-top: 10px;
  }
  .series-head {
    margin-bottom: 4px;
  }
  #shelves:not(.grid-mode) .series-head .cat-tags {
    display: none;
  }
  .shelf-head-side {
    width: 100%;
    justify-content: space-between;
    align-items: center;
  }
  .stats {
    gap: 22px;
  }
  .stats dd {
    font-size: 22px;
  }
  .ledge {
    margin: 0 -16px;
    padding: 14px 16px 3px;
    min-height: calc(var(--ledge-h) + 17px);
  }
  .ledge-wrap::after {
    left: -16px;
    right: -16px;
    border-radius: 0;
  }
  .vitrine {
    /* Drei Cover (Seitenverhältnis bis 0,7) plus Abstände passen in die Bildschirmbreite. */
    --ledge-h: min(184px, calc((100vw - 76px) / 2.1));
    --plaque-gap: 56px;
    padding-bottom: 26px;
  }
  .vitrine-plaque b {
    font-size: 12px;
  }
  .vitrine-head .series-title {
    font-size: 22px;
  }
  .vitrine .ledge {
    gap: 14px;
    margin: 0;
    padding: 30px 8px var(--plaque-gap);
  }
  .vitrine .ledge-wrap::after {
    left: -6px;
    right: -6px;
    border-radius: 3px;
  }
  .tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 20px 14px;
  }
  #shelves {
    gap: 44px;
  }

  .user-search-box {
    width: 40px;
    height: 40px;
    border-radius: var(--r-control);
    border: 1px solid var(--line);
    background: var(--surface);
    overflow: hidden;
    cursor: pointer;
    transition: width 0.3s var(--ease-out);
  }
  .user-search-box > svg {
    left: 11px;
  }
  .user-search-box input {
    opacity: 0;
    pointer-events: none;
    border: none;
    background: transparent;
    height: 100%;
  }
  .user-search-box input:focus {
    box-shadow: none;
  }
  .user-search-box.expanded {
    width: 170px;
    cursor: text;
  }
  .user-search-box.expanded input {
    opacity: 1;
    pointer-events: auto;
  }
  /* Platz für das aufgeklappte Suchfeld */
  .auth-bar:has(.user-search-box.expanded) .notif-picker {
    display: none;
  }
  .notif-menu {
    position: fixed;
    top: 64px;
    left: 10px;
    right: 10px;
    width: auto;
  }
  .shelf-head-side {
    flex-wrap: wrap;
    row-gap: 14px;
  }
  .shelf-head-actions {
    margin-left: auto;
  }
  .google-btn span,
  .home-btn span,
  .chip-name {
    display: none;
  }
  .home-btn {
    width: 40px;
    padding: 0;
  }
  .auth-bar:has(.user-search-box.expanded) .home-btn {
    display: none;
  }
  .google-btn {
    width: 40px;
    padding: 0;
    justify-content: center;
  }
  .user-chip-trigger {
    padding: 4px;
    width: 40px;
    justify-content: center;
  }
  .login-hint {
    margin: 0 0 16px;
    padding: 6px 6px 6px 14px;
  }
  .lh-long {
    display: none;
  }
  .dev-banner {
    margin: 0 0 16px;
    padding: 8px 6px 8px 14px;
  }
  .dev-banner p {
    font-size: 13px;
    line-height: 1.35;
  }
  .lh-short {
    display: inline;
  }
  .series {
    flex-basis: 100%;
  }
  .home {
    padding-top: 30px;
  }
  .hero-title {
    font-size: 40px;
  }
  .hero-lede {
    margin-top: 18px;
    font-size: 16.5px;
  }
  .hero-actions {
    margin-top: 26px;
  }
  .hero-actions .btn {
    flex: 1 1 100%;
  }
  .hero-note {
    text-align: center;
  }
  .hero-scene {
    --display-h: 146px;
    margin: 36px 0 0;
    padding-top: 10px;
  }
  .display-row {
    gap: 16px;
    padding: 0 18px 3px;
  }
  .hero-caption {
    margin-top: 34px;
  }
  .steps {
    margin-top: 80px;
  }
  .perks {
    margin-top: 80px;
    padding: 32px 14px 24px;
    border-radius: 22px;
  }
  .perks .section-title,
  .perks-eyebrow,
  .perks-lede,
  .perks-note {
    margin-left: 6px;
    margin-right: 6px;
  }
  .demo-vitrine-row {
    gap: 14px;
    padding: 0 16px 3px;
  }
  .demo-vitrine-item .thumb {
    width: 70px;
    height: 105px;
  }
  .demo-vitrine-item:nth-child(2) .thumb {
    width: 80px;
    height: 120px;
  }
  .browse-search {
    width: 100%;
  }
  /* Handy: Name oben, Cover-Reihe darunter über die ganze Breite */
  .reader-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "avatar text go" "covers covers covers";
    gap: 12px 14px;
    padding: 16px;
  }
  .reader-avatar {
    grid-area: avatar;
  }
  .reader-text {
    grid-area: text;
  }
  .reader-go {
    grid-area: go;
  }
  .reader-covers {
    grid-area: covers;
    overflow: hidden;
  }
  .reader-covers:empty {
    display: none;
  }
  .admin-user-head {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: 14px 16px;
  }
  .admin-user-meta {
    grid-column: 2 / -1;
    flex-wrap: wrap;
    gap: 4px 12px;
  }
  .admin-chevron {
    grid-row: 1;
    grid-column: 3;
  }
  .admin-user-body {
    padding: 4px 16px 18px;
  }
  .admin-log li {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .admin-cost-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 32px;
    padding: 12px 10px 12px 16px;
  }
  .admin-cost-row > input[data-k="name"] {
    grid-column: 1 / 3;
  }
  .admin-cost-row .icon-btn {
    grid-column: 3;
    grid-row: 1;
  }
  .admin-cost-month {
    grid-column: 1 / 3;
    text-align: left;
  }
  .admin-cost-main {
    grid-column: 1 / -1;
  }
  .account-facts div {
    padding: 10px 12px;
  }
  .reader-covers .thumb {
    flex: none;
  }
  .home-foot {
    margin-top: 64px;
  }

  .drawer {
    top: auto;
    left: 0;
    width: 100%;
    max-width: none;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: 22px 22px 0 0;
    transform: translateY(102%);
    box-shadow: 0 -20px 60px -20px rgba(20, 20, 20, 0.35);
  }
  .detail-hero {
    height: 230px;
    border-radius: 22px 22px 0 0;
  }
  .detail-cover {
    width: 124px;
  }
  .detail-body {
    padding: 48px 20px calc(24px + env(safe-area-inset-bottom));
  }
  .rating-row,
  .detail-row {
    grid-template-columns: 96px minmax(0, 1fr);
  }
  .detail-block textarea {
    min-height: 140px;
  }
  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  /* Knöpfe und Schalter bleiben rechts neben dem Text, nur Auswahllisten bekommen eine eigene Zeile. */
  .setting-row {
    flex-wrap: wrap;
    row-gap: 10px;
  }
  .setting-row > span {
    flex: 1 1 0;
  }
  .setting-row select {
    width: 100%;
  }
  .setting-row > .btn,
  .setting-row > .seg {
    flex: none;
  }
  .setting-row.setting-theme {
    flex-wrap: nowrap;
  }
  .setting-theme > span {
    flex: none;
  }
  .theme-grid {
    grid-template-columns: 1fr;
  }
  /* Kopfzeile mit dem Schließen-Knopf bleibt beim Scrollen langer Fenster stehen. */
  .settings-modal .modal-title-row,
  .account-modal .modal-title-row {
    position: sticky;
    top: -24px;
    z-index: 2;
    margin: -24px -20px 0;
    padding: 18px 20px 10px;
    background: var(--surface);
    box-shadow: 0 1px 0 var(--line-soft);
  }
  .setting-actions {
    display: grid;
    gap: 0;
    padding: 4px 0 0;
  }
  .setting-actions .btn {
    justify-content: space-between;
    width: 100%;
    height: 48px;
    padding: 0;
    border: none;
    border-bottom: 1px solid var(--line-soft);
    border-radius: 0;
    background: transparent;
    font-size: 15px;
  }
  .settings-group:last-child > :last-child {
    border-bottom: none;
  }
  .setting-actions .btn::after {
    content: "";
    width: 8px;
    height: 8px;
    margin-right: 4px;
    border-top: 2px solid var(--dim);
    border-right: 2px solid var(--dim);
    transform: rotate(45deg);
  }
  .modal {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px - env(safe-area-inset-bottom));
    padding: 24px 20px;
    border-radius: 20px;
  }
  .modal-overlay {
    align-items: flex-end;
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  }
  .modal.modal-add {
    padding: 0;
  }
  .modal-add-head {
    padding: 20px 20px 16px;
  }
  .modal-add-body {
    padding: 4px 20px 22px;
  }
  .modal-actions.modal-add-foot {
    padding: 12px 20px;
  }
  .add-book-card {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 14px;
  }
  .add-book-fields .field-row {
    grid-template-columns: minmax(0, 1fr) 78px;
    gap: 10px;
  }
  .add-book-fields .combo-list {
    right: -88px;
  }
  .toast {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

@media (min-width: 1024px) {
  /* Auf großen Screens steht die Schublade neben dem Regal statt davor: keine Abdunklung,
     der Inhalt rückt nach links, damit das gedrehte Buch sichtbar bleibt. */
  .drawer-overlay.open {
    background: transparent;
    pointer-events: none;
  }
  .drawer {
    top: 64px;
    box-shadow: -1px 0 0 var(--line), -30px 0 60px -40px rgba(20, 20, 20, 0.35);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}
