:root {
  --bg: #f6f1e9;
  --surface: #fffbf5;
  --ink: #221d17;
  --muted: #6f655a;
  --line: #e6dccd;
  --accent: #b4532a;
  --accent-soft: #f3ddd0;
  --star: #d39b1f;
  --shadow: 0 1px 2px rgb(60 40 20 / .06), 0 4px 14px rgb(60 40 20 / .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --surface: #211d18;
    --ink: #f1e9dd;
    --muted: #a69a8b;
    --line: #342e27;
    --accent: #e3804f;
    --accent-soft: #3a261b;
    --star: #e8b84a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
main, .top { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: calc(20px + env(safe-area-inset-top)); padding-bottom: 8px; }
h1 { font: 700 30px/1.1 ui-serif, Georgia, "Times New Roman", serif; margin: 0; letter-spacing: -.01em; }
.sub { margin: 4px 0 0; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }

.controls { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 0; }
input[type=search] {
  width: 100%; font: inherit; padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
input[type=search]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip small { opacity: .75; margin-left: 4px; }

.list { display: flex; flex-direction: column; gap: 10px; padding: 8px 0 24px; }
.group-title { font: 600 13px/1 ui-sans-serif, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 2px 2px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px;
}
.book { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: start; }
.cover {
  width: 56px; height: 84px; border-radius: 6px; overflow: hidden; position: relative;
  display: grid; place-items: center; color: #fff; font: 700 18px/1 ui-serif, Georgia, serif;
  box-shadow: inset -3px 0 0 rgb(0 0 0 / .15);
}
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.title { font-weight: 650; margin: 0; line-height: 1.25; }
.author { color: var(--muted); font-size: 14px; margin: 2px 0 6px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.pill { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 8px; font-weight: 600; }
.stars { color: var(--star); letter-spacing: 1px; }
.why { margin: 6px 0 0; font-size: 14.5px; }
.based { margin-top: 6px; font-size: 13px; color: var(--muted); }
.notes { margin: 6px 0 0; font-size: 14px; font-style: italic; }
.progress { height: 6px; border-radius: 3px; background: var(--line); margin-top: 8px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 32px 8px; }
.intro { color: var(--muted); margin: 12px 0 0; }
.muted { color: var(--muted); font-size: 14px; }

.prose { margin-top: 12px; }
.prose h2 { margin: 0 0 8px; font: 700 20px/1.2 ui-serif, Georgia, serif; }
.prose li { margin: 4px 0; }
code { font-size: .9em; background: var(--accent-soft); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.btn {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  padding: 10px 16px; border-radius: 999px; font-weight: 600;
}

.tabs {
  position: fixed; inset: auto 0 0 0; z-index: 5; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; max-width: 200px; background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; cursor: pointer;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-selected=true] { color: var(--accent); font-weight: 600; }
.listen { display: flex; gap: 8px; margin-top: 10px; }
.listen a {
  font-size: 13px; font-weight: 600; text-decoration: none; color: var(--accent);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; background: var(--bg);
}
.avail { margin: 8px 0 0; font-size: 13px; font-weight: 600; }
.avail.ok { color: #2f7a46; }
.avail.buy { color: var(--muted); }
@media (prefers-color-scheme: dark) { .avail.ok { color: #7fcf95; } }
