/* Estante: papel frio, tinta cobalto, lombadas como gráfico. */
:root {
  --paper: #eff1ec;
  --surface: #ffffff;
  --surface-2: #f6f7f3;
  --ink: #1c262b;
  --muted: #5d6970;
  --line: #d8dcd4;
  --accent: #3346c8;
  --accent-ink: #ffffff;
  --accent-soft: #e3e7fb;
  --done: #2c7656;
  --done-soft: #dcefe4;
  --want: #6a6f86;
  --want-soft: #e8e9f0;
  --dropped: #a2553f;
  --dropped-soft: #f5e3dc;
  --shelf: #8a7a66;
  --star: #c98a12;
  --shadow: 0 1px 0 rgba(28, 38, 43, .04), 0 8px 24px -16px rgba(28, 38, 43, .35);
  --spine-l: 42%;
  --spine-s: 38%;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12171a;
    --surface: #1a2125;
    --surface-2: #20282d;
    --ink: #e5e9e3;
    --muted: #96a2a8;
    --line: #2c353b;
    --accent: #8d9cff;
    --accent-ink: #10142e;
    --accent-soft: #252c55;
    --done: #74c79f;
    --done-soft: #1d3a2d;
    --want: #a9adc4;
    --want-soft: #282b38;
    --dropped: #e09479;
    --dropped-soft: #3d2620;
    --shelf: #5c5246;
    --star: #e8b23f;
    --shadow: 0 1px 0 rgba(0, 0, 0, .2), 0 10px 28px -18px rgba(0, 0, 0, .8);
    --spine-l: 36%;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 15px/1.5 var(--sans); font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
[x-cloak] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* --- top ---------------------------------------------------------------- */
.top { border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 88%, transparent);
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px); }
.top-row { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.top-actions { display: flex; gap: 6px; align-items: center; }
.top-actions form { margin: 0; }
.brand { font: 600 26px/1 var(--serif); letter-spacing: -.02em; color: var(--ink); text-decoration: none;
  font-variation-settings: "opsz" 72; }

/* --- buttons ------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; font-size: 14px;
  white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--dropped); padding-left: 4px; }
.btn.wide { width: 100%; justify-content: center; }
.btn svg { width: 16px; height: 16px; stroke-width: 2.2; }
.icon-btn { border: 0; background: none; padding: 6px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.link-btn { border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--dropped); }

/* --- stats --------------------------------------------------------------- */
.stats-section { padding: 28px 0 8px; }
.year-title { font: 400 clamp(30px, 6vw, 46px)/1.05 var(--serif); letter-spacing: -.02em; margin: 0 0 22px;
  font-variation-settings: "opsz" 72; }
.year-select { font: italic 500 1em/1 var(--serif); border: 0; background: transparent; color: var(--accent);
  padding: 0 .1em; cursor: pointer; appearance: none; -webkit-appearance: none;
  border-bottom: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-radius: 0; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--ink); }
.stat { padding: 14px 16px 16px 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat + .stat { padding-left: 16px; border-left: 1px solid var(--line); }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font: 500 34px/1.1 var(--serif); letter-spacing: -.01em; font-variant-numeric: lining-nums tabular-nums; }
.stat-value.serif-name { font-size: 22px; line-height: 1.2; padding: 6px 0 3px; overflow-wrap: anywhere; }
.stat-note { font-size: 12.5px; color: var(--muted); }

/* --- shelf chart --------------------------------------------------------- */
.shelf { margin: 22px 0 0; overflow-x: auto; scrollbar-width: thin; }
.shelf-inner { display: grid; grid-template-columns: repeat(12, minmax(48px, 1fr)); min-width: 600px; }
.shelf-month { display: flex; flex-direction: column; }
.spines { height: 120px; display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 0 3px;
  border-bottom: 5px solid var(--shelf); }
.shelf-month:not(.has-books) .spines { background: linear-gradient(to top, color-mix(in srgb, var(--line) 50%, transparent) 0 1px, transparent 1px); }
.spine { flex: 0 1 auto; min-width: 5px; border: 0; padding: 0; cursor: pointer; position: relative; overflow: hidden;
  border-radius: 2px 2px 0 0;
  background:
    linear-gradient(to bottom, transparent 10%, rgba(255,255,255,.22) 10% 12%, transparent 12% 86%, rgba(255,255,255,.22) 86% 88%, transparent 88%),
    linear-gradient(to right, rgba(0,0,0,.18), transparent 30%, rgba(255,255,255,.08) 55%, rgba(0,0,0,.2)),
    hsl(var(--h) var(--spine-s) var(--spine-l));
  transform-origin: bottom center; transition: transform .2s ease; }
.spine:hover, .spine:focus-visible { transform: translateY(-6px); }
.spine span { position: absolute; inset: 14% 0; writing-mode: vertical-rl; transform: rotate(180deg);
  font: 500 9px/1 var(--serif); color: rgba(255,255,255,.85); white-space: nowrap; overflow: hidden; text-overflow: clip;
  display: flex; align-items: center; }
.shelf-label { display: flex; justify-content: center; gap: 6px; font-size: 12px; color: var(--muted); padding-top: 6px; }
.shelf-label b { color: var(--ink); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) {
  .spine { animation: rise .5s cubic-bezier(.2,.8,.2,1) backwards; }
  .shelf-month:nth-child(n) .spine { animation-delay: calc(var(--h) * 1ms); }
}
@keyframes rise { from { transform: scaleY(0); } }

/* --- section titles ------------------------------------------------------ */
.section-title { font: 500 22px/1.2 var(--serif); margin: 36px 0 14px; letter-spacing: -.01em; }

/* --- reading now --------------------------------------------------------- */
.reading-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.reading-card { display: flex; gap: 16px; padding: 16px; background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow); border: 1px solid var(--line); }
.reading-cover { border: 0; padding: 0; background: none; cursor: pointer; flex: none; }
.reading-cover .cover { width: 84px; }
.reading-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.reading-title { font: 500 20px/1.2 var(--serif); margin: 0; }
.reading-numbers { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.reading-numbers strong { font: 600 18px/1 var(--serif); color: var(--accent); }
.reading-body .muted.small { margin: 2px 0 10px; }
.page-form { display: flex; gap: 8px; margin-top: auto; }
.page-form input { width: 100%; max-width: 120px; height: 38px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); font-variant-numeric: tabular-nums; }

.progress { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 10px 0 2px;
  box-shadow: inset 0 0 0 1px var(--line); }
.progress.big { height: 8px; margin-top: 14px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .4s ease; }

/* --- toolbar ------------------------------------------------------------- */
.library { padding-bottom: 64px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 40px 0 18px;
  padding-top: 18px; border-top: 1px solid var(--ink); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px;
  max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 500; color: var(--muted);
  cursor: pointer; white-space: nowrap; transition: background .15s, color .15s; }
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg-full { display: flex; width: 100%; }
.seg-full label { flex: 1; text-align: center; }
.search { flex: 1 1 220px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.search:focus-within { border-color: var(--accent); }
.search input { border: 0; background: none; outline: none; flex: 1; min-width: 0; color: var(--ink); }

/* --- item grid ----------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.card { display: flex; gap: 14px; padding: 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); cursor: pointer; transition: border-color .15s; min-width: 0; }
.card:hover { border-color: var(--muted); }
.card.status-dropped { opacity: .72; }
.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.pill, .tag { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; line-height: 1.5; }
.pill-reading { background: var(--accent-soft); color: var(--accent); }
.pill-done { background: var(--done-soft); color: var(--done); }
.pill-want { background: var(--want-soft); color: var(--want); }
.pill-dropped { background: var(--dropped-soft); color: var(--dropped); }
.tag { border: 1px solid var(--line); color: var(--muted); font-weight: 500; }
.card-title { font: 500 18px/1.22 var(--serif); margin: 0; letter-spacing: -.005em; overflow-wrap: anywhere; }
.card-creator { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); }
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 0; font-size: 12.5px; }
.card-meta div { display: flex; flex-direction: column; }
.card-meta dt { color: var(--muted); font-size: 11px; }
.card-meta dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }
.card-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 8px; min-height: 26px; }
.stars { color: var(--line); letter-spacing: 1px; font-size: 14px; }
.stars .on { color: var(--star); font-style: normal; }
.stars i { font-style: normal; }
.notes-count { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; color: var(--muted); margin-left: auto; }
.notes-count svg { width: 14px; height: 14px; }
.empty { grid-column: 1 / -1; text-align: center; padding: 48px 16px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r-lg); }

/* --- covers -------------------------------------------------------------- */
.cover { width: 72px; aspect-ratio: 2 / 3; border-radius: 3px 6px 6px 3px; object-fit: cover; flex: none; display: block;
  box-shadow: 0 1px 2px rgba(0,0,0,.2), 0 6px 14px -8px rgba(0,0,0,.5); background: var(--surface-2); }
.cover-gen { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  padding: 10px 7px 7px 12px; color: hsl(var(--h) 60% 94%);
  background:
    linear-gradient(to right, rgba(0,0,0,.28) 0 4px, rgba(255,255,255,.14) 4px 5px, transparent 5px),
    radial-gradient(120% 80% at 100% 0%, hsl(calc(var(--h) + 30) 45% 55% / .55), transparent 60%),
    hsl(var(--h) 34% 34%); }
.cover-gen.kind-movie, .cover-gen.kind-series { border-radius: 4px; padding-left: 8px;
  background: radial-gradient(120% 80% at 0% 100%, hsl(calc(var(--h) + 40) 50% 50% / .5), transparent 60%), hsl(var(--h) 25% 22%); }
.cover-initials { font: italic 500 22px/1 var(--serif); letter-spacing: -.02em; }
.cover-author { font-size: 8px; line-height: 1.2; opacity: .8; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* --- modal --------------------------------------------------------------- */
.modal { border: 0; padding: 0; background: transparent; max-width: 620px; width: calc(100% - 24px); max-height: calc(100dvh - 24px); color: var(--ink); }
.modal::backdrop { background: rgba(14, 20, 24, .5); backdrop-filter: blur(2px); }
.modal-card { background: var(--surface); border-radius: var(--r-lg); padding: 20px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); }
@media (prefers-reduced-motion: no-preference) {
  .modal[open] .modal-card { animation: pop .18s ease-out; }
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { font: 500 24px/1.15 var(--serif); margin: 0; letter-spacing: -.01em; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.item-form { display: flex; flex-direction: column; gap: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.field input, .field select, .field textarea, .note-form textarea, .note-form input {
  width: 100%; padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2);
  min-height: 40px; }
.field textarea, .note-form textarea { resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .note-form textarea:focus, .note-form input:focus {
  outline: none; border-color: var(--accent); background: var(--surface); }
.star-input { display: flex; gap: 2px; }
.star-input button { border: 0; background: none; font-size: 26px; line-height: 1; padding: 2px; cursor: pointer; color: var(--line); }
.star-input button.on { color: var(--star); }
.modal-foot { display: flex; align-items: center; gap: 6px; padding-top: 6px; }
.spacer { flex: 1; }
.errorlist { list-style: none; padding: 0; margin: 2px 0 0; color: var(--dropped); font-size: 12.5px; }
.error { color: var(--dropped); font-size: 13.5px; }

/* --- notes --------------------------------------------------------------- */
.notes { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.notes-title { font: 500 19px/1.2 var(--serif); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.notes-title .count { font: 600 12px/1 var(--sans); background: var(--surface-2); border: 1px solid var(--line); padding: 3px 7px; border-radius: 99px; color: var(--muted); }
.note-form { display: flex; flex-direction: column; gap: 8px; }
.note-form-row { display: flex; gap: 8px; }
.note-form-row input { width: 90px; flex: none; }
.note-form-row .btn { margin-left: auto; }
.note-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; }
.note { padding: 10px 0 10px 14px; border-left: 3px solid var(--accent-soft); }
.note blockquote { margin: 0; font: 400 16px/1.55 var(--serif); }
.note-meta { display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
.note-meta .link-btn { margin-left: auto; }
.note-empty { color: var(--muted); font-size: 13.5px; }

/* --- login --------------------------------------------------------------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login-box .brand { font-size: 44px; margin: 0; }
.login-box p { margin: 0 0 8px; }

/* --- responsive ---------------------------------------------------------- */
@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat, .stat + .stat { padding: 12px 12px 12px 0; border-left: 0; border-bottom: 1px solid var(--line); }
  .stat:nth-child(2n) { padding-left: 12px; border-left: 1px solid var(--line); }
  .stat-author { grid-column: 1 / -1; padding-left: 0 !important; border-left: 0 !important; }
}
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .grid, .reading-list { grid-template-columns: 1fr; }
  .stat-value { font-size: 28px; }
  .toolbar .seg { width: 100%; }
  .toolbar .seg label { flex: 1; text-align: center; }
  .modal { width: 100%; max-width: none; max-height: 100dvh; margin: auto 0 0; }
  .modal-card { border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 18px 16px 24px; }
  .btn.primary svg + * { display: inline; }
}
