/* Incunabula — a warm, bookish, mostly-typographic UI. */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f2ede4;
  --ink: #1f1b16;
  --ink-2: #5a544c;
  --muted: #8a8378;
  --line: #e4ddd0;
  --accent: #8a3b2a;
  --accent-ink: #ffffff;
  --accent-soft: #f6e8e3;
  --star: #d9a21b;
  --danger: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 27, 22, 0.06), 0 4px 16px rgba(31, 27, 22, 0.04);
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f; --surface: #201c16; --surface-2: #2a251d; --ink: #f1ebe0; --ink-2: #c4bcae; --muted: #8f8778;
    --line: #35302a; --accent: #e07a5f; --accent-ink: #1f1b16; --accent-soft: #3a2721; --star: #f0b62f;
    --shadow: 0 1px 2px rgba(0,0,0,0.4);
  }
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-ui); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .h2, .h3, .h4 { font-family: var(--font); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; letter-spacing: -0.01em; }
h1 { font-size: 2rem; } .h2, h2 { font-size: 1.5rem; } .h3, h3 { font-size: 1.2rem; } .h4 { font-size: 1rem; font-family: var(--font-ui); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); font-size: .8rem; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }
.wrap { max-width: 1080px; margin: 0 auto; padding-inline: 20px; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 58px; }
.brand { font-family: var(--font); font-size: 1.35rem; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand-mark { color: var(--accent); }
.site-search { flex: 1; max-width: 360px; } .site-search input { width: 100%; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.site-nav > a:not(.btn) { color: var(--ink-2); font-weight: 500; } .site-nav > a.active { color: var(--ink); }
.site-footer { padding-block: 40px 24px; color: var(--muted); font-size: .85rem; }

/* Menus */
.menu { position: relative; } .menu summary { list-style: none; cursor: pointer; } .menu summary::-webkit-details-marker { display: none; }
.avatar-btn { display: inline-flex; border-radius: 50%; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 200px; padding: 6px; display: flex; flex-direction: column; z-index: 20; }
.menu-panel a, .menu-panel .linklike, .menu-panel span { display: block; padding: 8px 10px; color: var(--ink); text-align: left; width: 100%; border-radius: 6px; }
.menu-panel a:hover, .menu-panel .linklike:hover { background: var(--surface-2); text-decoration: none; }
.menu-inline { display: inline-block; } .menu-inline .menu-panel { left: 0; right: auto; }
.linklike { background: none; border: 0; font: inherit; color: var(--accent); cursor: pointer; padding: 0; }

/* Buttons & forms */
.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; line-height: 1.3; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); } .btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: .875rem; } .btn-block { display: block; width: 100%; text-align: center; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; } .btn-danger:hover { background: rgba(179,38,30,.06); }
.btn-sso { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 11px; font-size: 1rem; }
.btn-apple { background: #000; color: #fff; border-color: #000; } .btn-apple:hover { background: #111; }
.sso-icon { font-weight: 700; }
.iconbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; width: 30px; height: 30px; cursor: pointer; color: var(--ink-2); } .iconbtn:disabled { opacity: .35; cursor: default; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; } .field input { width: 100%; }
.label { font-weight: 600; font-size: .9rem; } .hint { font-size: .8rem; color: var(--muted); }
.stack > * + * { margin-top: 18px; }
.form { max-width: 620px; } .form-wide { max-width: 860px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.prefixed { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding-left: 10px; }
.prefixed span { color: var(--muted); } .prefixed input { border: 0; flex: 1; } .prefixed:focus-within { outline: 2px solid var(--accent); }
.form-actions { display: flex; gap: 10px; align-items: center; }
.danger-zone { margin-top: 40px; padding-top: 16px; border-top: 1px dashed var(--line); max-width: 860px; }
.search-bar { display: flex; gap: 8px; margin-bottom: 20px; } .search-bar input { flex: 1; }
.flash { padding: 10px 14px; border-radius: 8px; margin: 12px 0; background: var(--surface-2); border: 1px solid var(--line); }
.flash-success { border-color: #9ccc9c; background: #eef7ee; color: #1f5e1f; }
.flash-error { border-color: #e0a3a0; background: #fbeeed; color: #7a1f1a; } .flash ul { margin: 0; padding-left: 18px; }
@media (prefers-color-scheme: dark) { .flash-success { background: #1e2f1e; color: #b7e0b7; } .flash-error { background: #3a1f1d; color: #f0b3ae; } }

/* Layout pieces */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 24px 0 16px; }
.feed-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 24px 0 12px; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.feed-narrow { max-width: 760px; }
.feed-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; }
.feed > * + * { margin-top: 14px; }
.sidebar > * + * { margin-top: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.panel .h4 { margin-bottom: 8px; } .panel-note { margin: 8px 0 0; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.segmented a { padding: 6px 14px; color: var(--ink-2); font-size: .9rem; } .segmented a.active { background: var(--ink); color: var(--bg); }
.pager { display: flex; justify-content: space-between; margin-top: 20px; }
.hero { padding: 48px 0 24px; max-width: 640px; } .hero h1 { font-size: 2.6rem; } .hero p { font-size: 1.1rem; color: var(--ink-2); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.prose { max-width: 680px; font-size: 1.05rem; } .prose p { margin-bottom: 1em; }
.plain-list { list-style: none; padding: 0; margin: 0; } .plain-list li { padding: 4px 0; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.byline { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: .9rem; }
.byline-user { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); }
.review-card-body, .list-card-body { display: grid; grid-template-columns: auto 1fr; gap: 14px; }
.review-card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 4px; }
.review-title { font-size: 1.15rem; margin: 4px 0; } .review-title a { color: var(--ink); }
.review-excerpt { color: var(--ink-2); margin-bottom: 8px; }
.book-link { color: var(--ink); }
.list-title { font-size: 1.15rem; margin: 2px 0 4px; } .list-title a { color: var(--ink); }
.list-stack { display: flex; } .list-stack .cover { margin-right: -22px; box-shadow: 2px 0 6px rgba(0,0,0,.15); } .list-stack .cover:last-child { margin-right: 0; }
.cover-empty { width: 44px; }

/* Covers */
.cover { display: block; object-fit: cover; border-radius: 4px; background: var(--surface-2); flex-shrink: 0; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.cover-xs { width: 34px; height: 50px; } .cover-sm { width: 56px; height: 84px; } .cover-md { width: 96px; height: 144px; } .cover-lg { width: 180px; height: 270px; }
.cover-placeholder { display: flex; align-items: flex-end; padding: 6px; color: #fff; font-family: var(--font); font-size: .7rem; line-height: 1.15; overflow: hidden; background: hsl(var(--hue, 20) 35% 40%); border-left: 4px solid hsl(var(--hue, 20) 35% 28%); }
.cover-md.cover-placeholder { font-size: .85rem; } .cover-lg.cover-placeholder { font-size: 1.2rem; padding: 12px; } .cover-xs.cover-placeholder span { display: none; }

/* Stars */
.stars { display: inline-flex; letter-spacing: 1px; font-size: 1rem; line-height: 1; }
.star, .star.off { color: var(--line); } .star.full { color: var(--star); }
.star.half { background: linear-gradient(90deg, var(--star) 50%, var(--line) 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rating-line { display: inline-flex; align-items: center; gap: 6px; }
.star-input legend { margin-bottom: 4px; } .star-input { border: 0; padding: 0; margin: 0; }
.star-input-row { display: inline-flex; align-items: center; gap: 2px; }
.star-input input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.star-input label { cursor: pointer; font-size: 2rem; line-height: 1; padding: 0 2px; } .star-input label .star { color: var(--line); transition: color .1s; }
.star-input label.lit .star, .star-input label:hover .star { color: var(--star); }
.star-input input:focus-visible + label { outline: 2px solid var(--accent); border-radius: 4px; }
.star-input-hint { margin-left: 10px; font-size: .9rem; min-width: 8em; }

/* Tags */
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap; font-family: var(--font-ui); }
a.chip:hover { text-decoration: none; border-color: var(--ink-2); }
.chip-lg { font-size: 1.1rem; padding: 6px 16px; }
.chip-count { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 6px; font-size: .7rem; }
.chip-genre { background: #e9eef8; color: #2d4a8a; } .chip-format { background: #eef3ea; color: #35592b; } .chip-age-range { background: #f6efe1; color: #7a5410; }
.chip-length { background: #efe9f5; color: #5b3a80; } .chip-readability { background: #e6f2f2; color: #1f5f60; } .chip-pace { background: #fbe9e3; color: #8a3b2a; }
.chip-mood { background: #f7e9f1; color: #7e2f5e; } .chip-theme { background: #ebeee9; color: #444f3d; } .chip-content { background: #f4e3e3; color: #7a1f1a; } .chip-structure { background: #e9ecef; color: #3c4650; }
@media (prefers-color-scheme: dark) {
  .chip-genre { background: #233252; color: #b9c8ec; } .chip-format { background: #24331f; color: #b9d5ae; } .chip-age-range { background: #3d3118; color: #e6c98a; }
  .chip-length { background: #32283f; color: #d2bfea; } .chip-readability { background: #1c3535; color: #a9d6d6; } .chip-pace { background: #3d2620; color: #f0b7a6; }
  .chip-mood { background: #3a2432; color: #e6b3d0; } .chip-theme { background: #2d3229; color: #c5cdbd; } .chip-content { background: #3d2222; color: #eaa9a5; } .chip-structure { background: #2b3037; color: #c2cad3; }
  .chip-count { background: rgba(255,255,255,.12); }
}
.tag-picker { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; }
.tag-picker-tools { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; } .tag-filter { flex: 1; max-width: 280px; }
.tag-group { border: 0; padding: 0; margin: 10px 0 0; } .tag-group legend { font-weight: 600; font-size: .9rem; padding: 0; margin-bottom: 6px; }
.tag-group legend .muted { font-weight: 400; }
.chip-check { cursor: pointer; user-select: none; } .chip-check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chip-check:has(input:checked) { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; font-weight: 600; }
.chip-check:has(input:focus-visible) { outline: 2px solid var(--accent); }
.chip-check.hidden { display: none; }
.more-tags summary { cursor: pointer; color: var(--accent); margin: 8px 0; }
.tag-group-summary { margin-bottom: 10px; } .tag-group-summary .chips { margin-top: 4px; }
section.tag-group { margin: 22px 0; }

/* Avatars */
.avatar { border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-family: var(--font-ui); flex-shrink: 0; }
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; } .avatar-md { width: 40px; height: 40px; font-size: .9rem; } .avatar-lg { width: 84px; height: 84px; font-size: 1.8rem; }

/* Books */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 12px 0 28px; }
.book-card { display: flex; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
.book-card:hover { text-decoration: none; border-color: var(--ink-2); }
.book-card-text { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; min-width: 0; }
.book-head { display: grid; grid-template-columns: auto 1fr; gap: 28px; margin: 28px 0; }
.book-meta h1 { margin-bottom: 4px; } .book-desc { max-width: 640px; color: var(--ink-2); }
.rating-summary { display: flex; align-items: center; gap: 10px; margin: 12px 0 8px; } .rating-big { font-family: var(--font); font-size: 2.2rem; font-weight: 700; line-height: 1; }
.rating-bars { list-style: none; padding: 0; margin: 0 0 14px; max-width: 320px; } .rating-bars li { display: grid; grid-template-columns: 28px 1fr 28px; align-items: center; gap: 8px; font-size: .8rem; }
.rating-bars .bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; } .rating-bars .bar span { display: block; height: 100%; background: var(--star); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.review-form-book { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; } .review-form-book h1, .review-form-book h2 { margin: 0; }
.review-page { max-width: 760px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 28px; margin-top: 24px; }
.review-rating { display: flex; align-items: center; gap: 8px; margin: 8px 0; } .review-rating .stars { font-size: 1.3rem; }
.review-body { font-size: 1.05rem; margin: 10px 0 16px; }
.pick-list { list-style: none; padding: 0; margin: 0; } .pick-list li + li { border-top: 1px solid var(--line); }
.pick-list a, .pick-row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; color: var(--ink); } .pick-row > span:not(.cover) { flex: 1; }

/* Lists */
.list-items { list-style: none; padding: 0; margin: 20px 0; counter-reset: item; }
.list-item { display: grid; grid-template-columns: 28px auto 1fr auto; gap: 14px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.list-pos { font-family: var(--font); font-size: 1.3rem; color: var(--muted); padding-top: 4px; }
.list-item-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; } .list-note { color: var(--ink-2); font-style: italic; margin: 4px 0 0; }
.note-form { display: flex; gap: 6px; margin-top: 6px; } .note-form input { flex: 1; font-size: .9rem; padding: 5px 8px; }
.list-item-actions { display: flex; gap: 4px; } .list-desc { font-size: 1.05rem; color: var(--ink-2); max-width: 680px; }
.add-to-list { margin-bottom: 8px; } .add-to-list .search-bar { margin-bottom: 8px; }

/* Profile */
.profile-head { display: flex; gap: 20px; align-items: flex-start; margin: 28px 0; }
.profile-bio { font-size: 1.05rem; max-width: 600px; } .profile-interests { display: flex; gap: 10px; align-items: baseline; margin: 6px 0 12px; }

/* Auth */
.auth-box { max-width: 420px; margin: 48px auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.auth-buttons > * + * { margin-top: 10px; }
.dev-login { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--line); } .dev-login summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.dev-login .stack > * + * { margin-top: 8px; }

@media (max-width: 800px) {
  .feed-layout { grid-template-columns: 1fr; }
  .site-header .wrap { flex-wrap: wrap; height: auto; padding-block: 10px; gap: 10px; }
  .site-search { order: 3; flex-basis: 100%; max-width: none; }
  .book-head { grid-template-columns: 1fr; } .cover-lg { width: 130px; height: 195px; }
  .grid-2 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
  .list-item { grid-template-columns: 24px auto 1fr; } .list-item-actions { grid-column: 2 / -1; }
}

/* Multi-tag browse */
.selection-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; min-height: 48px; }
.chip-selected { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; font-weight: 600; }
.chip-x { opacity: .6; margin-left: 2px; } a.chip:hover .chip-x { opacity: 1; }
.related-tags { margin-bottom: 20px; } .related-tags .chips { margin-top: 6px; }
.all-tags { margin: 0 0 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.all-tags > summary { cursor: pointer; color: var(--accent); font-weight: 500; padding: 10px 14px; list-style: none; }
.all-tags > summary::-webkit-details-marker { display: none; }
.all-tags > summary::before { content: '▸'; display: inline-block; width: 1em; }
.all-tags[open] > summary::before { content: '▾'; }
.all-tags[open] > summary { border-bottom: 1px solid var(--line); }
/* Capped so an expanded taxonomy never pushes the results off the screen. */
.all-tags-body { padding: 0 14px 14px; max-height: 58vh; overflow-y: auto; }
.all-tags-body .tag-group { margin: 16px 0 0; }
.all-tags-body .tag-group .h3 { font-size: .95rem; }

/* Add-a-book flow */
.near-matches { border: 1px solid var(--star); background: var(--surface); border-radius: var(--radius); padding: 12px 14px; }
.near-matches .pick-list { margin: 8px 0; }
.manual-fallback { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); }
.provenance { margin-top: 6px; }
