/* ============================================================
   Bibliothek: styles
   Paper-and-ink aesthetic. Light theme by default, dark theme via
   prefers-color-scheme or the manual toggle (html[data-theme]).
   ============================================================ */

/* ---------- Tokens ---------- */

:root {
  --paper: #f7f2e9;
  --paper-2: #efe8db;
  --paper-3: #e4dbca;
  --ink: #1f1b17;
  --ink-2: #5e564c;
  --ink-3: #857c70;
  --rule: #dcd3c3;
  --accent: #7a1f2b;
  --accent-soft: rgba(122, 31, 43, 0.09);
  --on-accent: #fff9f2;
  --backdrop: rgba(30, 22, 14, 0.45);
  --shadow: 0 1px 2px rgba(50, 35, 20, 0.07), 0 6px 18px rgba(50, 35, 20, 0.07);
  --serif: 'Source Serif 4', Georgia, 'Times New Roman', Times, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 6px;
  --max: 1560px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1917;
    --paper-2: #24211e;
    --paper-3: #2f2b26;
    --ink: #ebe3d5;
    --ink-2: #b5aa9b;
    --ink-3: #8b8073;
    --rule: #3a352f;
    --accent: #d47a84;
    --accent-soft: rgba(212, 122, 132, 0.14);
    --on-accent: #1b1917;
    --backdrop: rgba(0, 0, 0, 0.6);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --paper: #1b1917;
  --paper-2: #24211e;
  --paper-3: #2f2b26;
  --ink: #ebe3d5;
  --ink-2: #b5aa9b;
  --ink-3: #8b8073;
  --rule: #3a352f;
  --accent: #d47a84;
  --accent-soft: rgba(212, 122, 132, 0.14);
  --on-accent: #1b1917;
  --backdrop: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  overflow-x: hidden;
}

body.no-scroll { overflow: hidden; }
body.is-screensaver .topbar,
body.is-screensaver .view,
body.is-screensaver .site-footer { display: none; }

[hidden] { display: none !important; }

img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
p { margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

.noscript { padding: 40px; text-align: center; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.brand {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.01em;
}

.nav { display: flex; gap: 2px; }
.nav a {
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--ink-2);
}
.nav a:hover { color: var(--ink); background: var(--paper-2); }
.nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

.search { flex: 1 1 160px; max-width: 380px; margin-left: auto; }
.search input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.search input::placeholder { color: var(--ink-3); }

.icon-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-2);
  flex: 0 0 auto;
}
.icon-btn:hover { color: var(--ink); background: var(--paper-2); }
.icon-btn svg { width: 20px; height: 20px; }
/* Language toggle: text instead of an icon ("DE" / "EN"). */
.lang-btn { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; }

/* Phones: three rows (brand + toggles / nav / full-width search). The bar scrolls away
   instead of sticking, so it does not eat a fifth of the screen. */
@media (max-width: 720px) {
  .topbar { position: static; }
  .topbar-inner { padding: 8px 14px 10px; gap: 4px 6px; }
  .brand { font-size: 20px; margin-right: auto; }
  .topbar .icon-btn { order: 1; }
  .topbar .lang-btn { width: 34px; }
  .nav {
    order: 2;
    flex-basis: calc(100% + 10px);
    margin: 0 -5px;
    overflow-x: auto;              /* fallback for very narrow screens */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 6px 5px; font-size: 15px; }
  .search { order: 3; flex-basis: 100%; max-width: none; margin: 2px 0 0; min-width: 0; }
}
@media (max-width: 480px) {
  .nav { justify-content: space-between; }   /* phones: the five items fill the row */
}
@media (max-width: 389px) {
  .nav a { font-size: 14px; padding: 6px 4px; }
}
@media (max-width: 339px) {
  .nav a { font-size: 13px; padding: 6px 3px; }
}

/* ---------- Main ---------- */

.view {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 20px 20px 48px;
}

@media (max-width: 720px) {
  .view { padding: 14px 14px 36px; }
}

.count { color: var(--ink-2); font-size: 14px; margin: 0 0 16px; }
/* One-line intro above a view's filters (Zitate). */
.view-intro { color: var(--ink-3); font-size: 13px; margin: 0 0 14px; }

.empty {
  color: var(--ink-2);
  font-style: italic;
  font-family: var(--serif);
  font-size: 17px;
  text-align: center;
  padding: 48px 0;
}

/* ---------- Filters ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.seg-group {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-2);
  overflow: hidden;
}
.seg {
  border: 0;
  background: none;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--ink-2);
  line-height: 1.2;
  font-size: 14px;
  white-space: nowrap;
}
.seg + .seg { border-left: 1px solid var(--rule); }
.seg:hover { color: var(--ink); }
.seg[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg:focus-visible { outline-offset: -2px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--rule);
  background: var(--paper-2);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--ink-2);
  line-height: 1.2;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.chip-n { font-size: 12px; opacity: 0.75; }
.chip-sm { font-size: 12px; padding: 2px 9px; }

.fselect {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 14px;
}
.fselect select {
  font: inherit;
  padding: 5px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--ink);
  max-width: 180px;
}

.reset {
  color: var(--accent);
  font-size: 14px;
  margin-left: auto;
}
.filters-end {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.filters-end .reset { margin-left: 0; }
.chip svg { width: 15px; height: 15px; }
.chip[disabled] { opacity: 0.45; cursor: default; }

/* Dropdown (details-based) */
.dd { position: relative; }
.dd > summary { list-style: none; }
.dd > summary::-webkit-details-marker { display: none; }
.dd > summary::after {
  content: '';
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  margin-left: 2px;
}
.dd[open] > summary { border-color: var(--ink-3); color: var(--ink); }
.dd-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 260px;
  max-width: min(520px, calc(100vw - 28px));
  max-height: 60vh;
  overflow: auto;
}
.dd-empty { color: var(--ink-3); font-size: 13px; padding: 4px; }

/* Book combobox */
.combo { position: relative; display: inline-flex; align-items: center; }
.combo-input {
  font: inherit;
  font-size: 14px;
  padding: 5px 30px 5px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-2);
  color: var(--ink);
  width: 240px;
  max-width: calc(100vw - 60px);
}
.combo-input[data-selected]:not([data-selected=""]) { border-color: var(--accent); }
.combo-clear {
  position: absolute;
  right: 4px;
  width: 24px; height: 24px;
  border: 0;
  border-radius: 999px;
  background: none;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1;
}
.combo-clear:hover { background: var(--paper-3); color: var(--ink); }
.combo-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 30;
  list-style: none;
  margin: 0;
  padding: 6px;
  min-width: 300px;
  max-width: min(460px, calc(100vw - 28px));
  max-height: 50vh;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.combo-list li {
  padding: 6px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.combo-list li i { font-family: var(--serif); }
.combo-list li small { color: var(--ink-3); white-space: nowrap; }
.combo-list li:hover, .combo-list li[aria-selected="true"] { background: var(--paper-2); }

/* ---------- Regal: grid + cards ---------- */

.grid {
  display: grid;
  gap: 24px 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 640px)  { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px)  { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (min-width: 1440px) { .grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.card {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
  min-width: 0;
}
.card:focus-visible { outline-offset: 4px; }

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 4px;
  overflow: hidden;
  background: var(--paper-3);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.card:hover .cover { transform: translateY(-3px); }
.cover img { width: 100%; height: 100%; object-fit: cover; }

/* Placeholder spine for books without cover */
.spine {
  position: absolute;
  inset: 0;
  background: var(--spine, #4a5d4b);
  color: var(--spine-ink, #f4efe6);
  padding: 16% 12%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
}
.spine::before {
  content: '';
  position: absolute;
  inset: 7%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  pointer-events: none;
}
.spine-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(13px, 0.9vw + 7px, 17px);
  line-height: 1.2;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.spine-author {
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.85;
  overflow-wrap: anywhere;
}

.card-body { padding-top: 9px; }
.card-title {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-author { margin-top: 2px; color: var(--ink-2); font-size: 13px; }
.card-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-3);
}

.badge {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-q {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.badge-q svg { width: 11px; height: 11px; }
.badge-muted { border-style: dashed; color: var(--ink-3); }

/* Rating stars: five slots, filled up to the rating */
.stars {
  display: inline-flex;
  gap: 1px;
  font-size: 14px;
  line-height: 1;
  vertical-align: -1px;
  white-space: nowrap;
}
.star { font-style: normal; color: var(--ink-3); opacity: 0.35; }
.star.is-on { color: var(--accent); opacity: 1; }
.stars-sm { font-size: 12px; }
.stars-lg { font-size: 17px; }

/* Card line with rating and reading status */
.card-state {
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
}
.st { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; line-height: 1; white-space: nowrap; }
.st-done { color: var(--accent); }
.st-done svg { width: 13px; height: 13px; }
.st-now { color: var(--ink-2); }
.st-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.st-unread, .st-wish { text-transform: uppercase; letter-spacing: 0.06em; font-size: 10px; }

/* Books not on the shelf (audiobook, borrowed, lost, wishlist) */
.card.is-unowned .cover {
  opacity: 0.8;
  box-shadow: none;
  outline: 1.5px dashed var(--ink-3);
  outline-offset: -1.5px;
}
.card.is-unowned .card-title { color: var(--ink-2); }

/* Phones: one column, horizontal cards */
@media (max-width: 479px) {
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .card {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }
  .card-body { padding-top: 2px; }
  .card-title { font-size: 17px; }
  .card-author { font-size: 14px; }
  .card .spine { padding: 12% 8%; justify-content: center; }
  .card .spine-title { font-size: 12px; }
  .card .spine-author { display: none; }
}

/* ---------- Zitate ---------- */

.quotes { columns: 1; column-gap: 20px; }
@media (min-width: 680px)  { .quotes { columns: 2; } }
@media (min-width: 1100px) { .quotes { columns: 3; } }
@media (min-width: 1500px) { .quotes { columns: 4; } }

.quote {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  margin: 0 0 20px;
  padding: 22px 24px 16px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
}
.quote-text {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.45;
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}
.quote-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  font-size: 13px;
  color: var(--ink-2);
}
.quote-attr { text-decoration: none; }
.quote-attr:hover { color: var(--accent); }
.quote-attr cite { font-style: italic; }

.tag {
  font-size: 11px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Themen ---------- */

.tiles {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.tile {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper-2);
  overflow: hidden;
}
.tile-main {
  flex: 1;
  text-decoration: none;
  padding: 22px 20px 14px;
}
.tile-main:hover { background: var(--paper-3); }
.tile-label {
  display: block;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
}
.tile-desc { display: block; margin-top: 4px; color: var(--ink-2); font-size: 13px; font-family: var(--serif); font-style: italic; }
.tile-n { display: block; margin-top: 8px; color: var(--ink-3); font-size: 13px; }
.tile-books {
  padding: 9px 20px 11px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  border-top: 1px solid var(--rule);
}
.tile-books:hover { background: var(--paper-3); }
.tile.is-selected { border-color: var(--accent); }

.theme-books { margin-top: 32px; }
.theme-books h2 {
  font-size: 22px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 12px;
}
.book-list { list-style: none; margin: 0; padding: 0; }
.book-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 15px;
}
.book-list a { text-decoration: none; }
.book-list a:hover { color: var(--accent); }
.book-list a i { font-family: var(--serif); }
.book-list small { color: var(--ink-3); white-space: nowrap; }

/* ---------- Book detail overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  justify-content: flex-end;
}
.overlay-backdrop { position: absolute; inset: 0; background: var(--backdrop); }
.panel {
  position: relative;
  width: min(780px, 100%);
  height: 100%;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  animation: panel-in 0.22s ease;
}
@keyframes panel-in {
  from { transform: translateX(24px); opacity: 0; }
}
.panel:focus { outline: none; }

.panel-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
}
.panel-pos { color: var(--ink-3); font-size: 13px; margin: 0 auto 0 4px; }
.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 26px 30px 48px;
  overscroll-behavior: contain;
}

.book-head {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 26px;
  margin-bottom: 26px;
}
.book-head .cover { width: 160px; }
.book-title { font-size: 28px; }
.book-subtitle { font-family: var(--serif); font-size: 17px; color: var(--ink-2); margin-top: 4px; }
.book-author { font-size: 16px; margin-top: 10px; }
.book-year { color: var(--ink-2); }
.book-badges { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 4px; }
.book-themes { margin-bottom: 8px; }

.facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 18px;
  font-size: 14px;
  margin: 0 0 22px;
}
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; min-width: 0; }
.files {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: none;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
}
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.btn:hover { background: var(--accent); color: var(--on-accent); }
.btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.section { margin-top: 30px; }
.section h2 {
  font-size: 20px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.section h2 small {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 13px;
  color: var(--ink-3);
}
.section h3 {
  font-family: var(--sans);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin: 20px 0 10px;
}
.q {
  margin: 0 0 18px;
  padding-left: 16px;
  border-left: 2px solid var(--accent);
}
.q-text {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.q-meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 12px;
  color: var(--ink-3);
}
.notes { white-space: pre-line; }
.fact-rating { display: flex; align-items: center; gap: 8px; }
.book-themes { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Free-form tags: muted, not clickable (theme chips are the linked ones) */
.chip-tag {
  cursor: default;
  background: none;
  border-style: dashed;
  color: var(--ink-3);
  font-size: 12px;
  padding: 3px 9px;
}
.chip-tag:hover { color: var(--ink-3); border-color: var(--rule); }

/* Rendered notes (light Markdown) */
.md { font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.md > * + * { margin-top: 10px; }
.md h3 {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  margin: 22px 0 8px;
}
.md h4 {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin: 18px 0 6px;
}
.md > h3:first-child, .md > h4:first-child { margin-top: 0; }
.md ul, .md ol { padding-left: 22px; }
.md li + li { margin-top: 4px; }
.md blockquote {
  margin: 10px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--rule);
  color: var(--ink-2);
  font-family: var(--serif);
  font-size: 16px;
}
.md hr { border: 0; border-top: 1px solid var(--rule); margin: 16px 0; }
.md a { color: var(--accent); word-break: break-all; }
.md code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--paper-2);
  padding: 1px 4px;
  border-radius: 3px;
}

@media (max-width: 560px) {
  .panel-body { padding: 18px 16px 40px; }
  .book-head { grid-template-columns: 104px minmax(0, 1fr); gap: 16px; }
  .book-head .cover { width: 104px; }
  .book-title { font-size: 23px; }
}

/* ---------- Screensaver ---------- */

.ss {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}
.ss.is-idle { cursor: none; }

.ss-stage { position: absolute; inset: 0; }
.ss-slide {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8vh 8vw 18vh;
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}
.ss-slide.is-active { opacity: 1; }

.ss-quote {
  font-family: var(--serif);
  font-size: clamp(22px, 2.4vw + 14px, 54px);
  line-height: 1.35;
  margin: auto 0 0;
  max-width: 26em;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.ss-quote.len-m { font-size: clamp(19px, 1.8vw + 12px, 40px); max-width: 30em; }
.ss-quote.len-l { font-size: clamp(16px, 1.2vw + 10px, 30px); max-width: 34em; }
.ss-quote.len-xl { font-size: clamp(14px, 0.9vw + 8px, 24px); max-width: 40em; line-height: 1.4; }

.ss-attr {
  margin: 4vh 0 auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--ink-2);
  font-size: clamp(12px, 0.45vw + 10px, 16px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.ss-attr .ss-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15em;
  letter-spacing: 0.02em;
  text-transform: none;
}

.ss-pie {
  position: absolute;
  right: 28px;
  bottom: 28px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) var(--p, 0deg), transparent 0);
  box-shadow: 0 0 0 1px var(--ink-3);
  opacity: 0.55;
  transition: opacity 0.4s;
}
.screensaver.is-paused .ss-pie { opacity: 0.25; }
@media (max-width: 600px) { .ss-pie { right: 16px; bottom: 16px; width: 12px; height: 12px; } }

.ss-controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 18px 18px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 65%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.ss.is-idle .ss-controls { opacity: 0; transform: translateY(10px); pointer-events: none; }
.ss-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ss-count { font-size: 13px; color: var(--ink-3); min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.ss-scope { font-size: 13px; color: var(--ink-2); }
.ss-scope a { color: var(--accent); }
.ss .icon-btn { border-color: var(--rule); background: var(--paper-2); }
.ss .icon-btn:hover { background: var(--paper-3); color: var(--ink); }
.ss .dd-menu { top: auto; bottom: calc(100% + 6px); }
.ss-empty {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(18px, 1.4vw + 10px, 28px);
  color: var(--ink-2);
}

/* ---------- Statistik ---------- */

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat-tile {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 16px 18px;
  min-width: 0;
}
.stat-n {
  display: block;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-l { display: block; margin-top: 4px; color: var(--ink-2); font-size: 13px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}
.stat-card {
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 18px 20px 20px;
  min-width: 0;
}
.stat-wide { grid-column: 1 / -1; }
.stat-card h2, .stat-timeline h2 {
  font-size: 20px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.stat-card h2 small, .stat-timeline h2 small, .stat-timeline h3 small {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 13px;
  color: var(--ink-3);
}
.stat-note { color: var(--ink-3); font-size: 13px; margin-top: 10px; }
.muted { color: var(--ink-3); }

/* Bar chart rows: label | track | value (text carries the numbers, the bar is decoration) */
.bars { --label: 140px; list-style: none; margin: 0; padding: 0; font-size: 14px; }
.bars-years { --label: 44px; }
.bars-rating { --label: 70px; }
.bar-row {
  display: grid;
  grid-template-columns: var(--label) minmax(0, 1fr) max-content;
  gap: 12px;
  align-items: center;
  padding: 4px 0;
}
.bar-label {
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.bar-label a { text-decoration: none; }
.bar-label a:hover { color: var(--accent); text-decoration: underline; }
.bar-track {
  display: block;
  height: 10px;
  background: var(--paper-3);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  min-width: 2px;
  background: var(--accent);
  border-radius: 0 4px 4px 0;
}
.bar-value { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-value small { color: var(--ink-3); font-size: 12px; }
@media (max-width: 479px) {
  .bars { --label: 96px; }
  .bar-row { gap: 8px; }
  .bar-value small { display: none; }
}

.stat-card .book-list li { font-size: 14px; padding: 6px 0; }
.book-list li a { min-width: 0; }
.book-list.cols li { break-inside: avoid; }
@media (min-width: 720px)  { .book-list.cols { columns: 2; column-gap: 32px; } }
@media (min-width: 1180px) { .book-list.cols { columns: 3; } }

.stat-timeline { margin-top: 32px; }
.stat-timeline h3 {
  font-size: 22px;
  margin: 24px 0 6px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.tl-date {
  display: inline-block;
  min-width: 62px;
  color: var(--ink-3);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--rule);
  color: var(--ink-3);
  font-size: 13px;
  text-align: center;
  padding: 18px 20px 28px;
}
.site-footer p + p { margin-top: 4px; }

/* Phones: two theme tiles per row, the odd last stat tile spans the row */
@media (max-width: 520px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile-main { padding: 16px 14px 12px; }
  .tile-label { font-size: 19px; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
  .tile-desc { font-size: 12px; }
  .tile-books { padding: 8px 14px 10px; }
  .stat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.private-note { margin-top: 10px; color: var(--accent); font-weight: 600; }
.credits { margin-top: 18px; color: var(--ink-2); }
.credits a { color: inherit; text-underline-offset: 2px; }
.credits a:hover { color: var(--accent); }
.heart { color: var(--ink); }

/* ---------- Motion ---------- */

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