/* Blue, Material-3-style palette (light + dark). Theme: auto, or forced via <html data-theme="light|dark">. */
:root {
  --bg: #ffffff;
  --surface: #f0f4f9;
  --surface-2: #e9eef6;
  --surface-3: #dde3ea;
  --ink: #1f1f1f;
  --muted: #444746;
  --faint: #747775;
  --line: #e1e5ea;
  --primary: #0b57d0;
  --primary-ink: #ffffff;
  --primary-soft: #d3e3fd;
  --primary-soft-ink: #041e49;
  --ea: #146c2e;  --ea-bg: #c4eed0;
  --fc: #7a4b00;  --fc-bg: #ffdfa6;
  --grad: linear-gradient(90deg, #4285f4 0%, #9b72cb 55%, #d96570 100%);
  --shadow: 0 1px 2px rgba(60,64,67,.15), 0 1px 3px 1px rgba(60,64,67,.08);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131314; --surface: #1e1f20; --surface-2: #282a2c; --surface-3: #333537;
    --ink: #e3e3e3; --muted: #c4c7c5; --faint: #8e918f; --line: #2f3133;
    --primary: #a8c7fa; --primary-ink: #062e6f; --primary-soft: #004a77; --primary-soft-ink: #c2e7ff;
    --ea: #6dd58c; --ea-bg: #0f5223; --fc: #ffb951; --fc-bg: #5c3c00;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131314; --surface: #1e1f20; --surface-2: #282a2c; --surface-3: #333537;
  --ink: #e3e3e3; --muted: #c4c7c5; --faint: #8e918f; --line: #2f3133;
  --primary: #a8c7fa; --primary-ink: #062e6f; --primary-soft: #004a77; --primary-soft-ink: #c2e7ff;
  --ea: #6dd58c; --ea-bg: #0f5223; --fc: #ffb951; --fc-bg: #5c3c00;
  --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: 15px/1.55 "Inter", ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-weight: 500; letter-spacing: -0.015em; line-height: 1.25; }
h1 { font-size: 2rem; margin: 0 0 8px; }
h2 { font-size: 1.25rem; margin: 32px 0 12px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* Header */
.top { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 24px; height: 68px; }
.brand { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand:hover { text-decoration: none; }
.search { flex: 1; max-width: 620px; position: relative; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; fill: var(--faint); }
.search input { width: 100%; height: 46px; padding: 0 20px 0 46px; border: 0; border-radius: 999px;
  background: var(--surface); color: var(--ink); font: inherit; }
.search input::placeholder { color: var(--faint); }
.search input:focus { outline: none; background: var(--surface-2); box-shadow: inset 0 0 0 2px var(--primary); }
nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
nav a { padding: 8px 14px; border-radius: 999px; color: var(--muted); font-weight: 500; }
nav a:hover { background: var(--surface); text-decoration: none; }
nav a.on { background: var(--primary-soft); color: var(--primary-soft-ink); }
.theme { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  cursor: pointer; display: grid; place-items: center; }
.theme:hover { background: var(--surface); }
.theme svg { width: 20px; height: 20px; fill: currentColor; }

/* Home */
.intro { padding: 40px 0 8px; }
.intro p { color: var(--muted); margin: 0 0 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-l { display: inline-flex; align-items: center; height: 36px; padding: 0 16px; border-radius: 999px;
  background: var(--surface); color: var(--ink); font-weight: 500; font-size: .92rem; border: 0; cursor: pointer; }
.chip-l:hover { background: var(--surface-2); text-decoration: none; }
.chip-l.on { background: var(--primary-soft); color: var(--primary-soft-ink); }
.shelf { margin-top: 36px; }
.shelf-h { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.shelf-h h2 { margin: 0; }
.shelf-h .note { color: var(--faint); font-size: .85rem; }
.shelf-h a { margin-left: auto; font-weight: 500; font-size: .92rem; white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 16px; }
.card { display: flex; flex-direction: column; padding: 12px; border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.card:hover { text-decoration: none; background: var(--surface-2); }
.cover { position: relative; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; background: var(--surface-3); }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; }
.cover .ph { position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 12px; font-size: .85rem; line-height: 1.3;
  color: var(--muted); background: linear-gradient(160deg, var(--surface-2), var(--surface-3)); }
.card-body { padding: 10px 2px 0; display: flex; flex-direction: column; gap: 2px; }
.card .t { font-weight: 500; font-size: .92rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .a { color: var(--muted); font-size: .8rem; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.card .m { color: var(--faint); font-size: .78rem; }
.badge { align-self: flex-start; display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; margin-bottom: 4px; white-space: nowrap; vertical-align: 2px; }
.badge.ea { color: var(--ea); background: var(--ea-bg); }
.badge.fc { color: var(--fc); background: var(--fc-bg); }
.empty { color: var(--faint); padding: 24px; border-radius: var(--radius); background: var(--surface); margin: 0; }

/* Browse */
.browse { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 32px; padding-top: 28px; align-items: start; }
.filters { position: sticky; top: 92px; max-height: calc(100vh - 110px); overflow: auto; padding: 20px; border-radius: var(--radius); background: var(--surface); }
.filters summary { display: none; }
.filters fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
.filters legend { font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; padding: 0; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--bg); color: var(--muted); font-size: .85rem; font-weight: 500; cursor: pointer; }
.seg label:hover { color: var(--ink); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--primary-soft); color: var(--primary-soft-ink); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--primary); }
.publist label { display: flex; align-items: center; gap: 10px; padding: 6px 4px; font-size: .9rem; cursor: pointer; border-radius: 8px; }
.publist label:hover { background: var(--surface-2); }
.publist input { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; flex: none; }
.publist .nm { flex: 1; min-width: 0; }
.publist .n { color: var(--faint); font-size: .8rem; font-variant-numeric: tabular-nums; }
.dates { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 8px; color: var(--faint); }
.dates input { width: 100%; min-width: 0; height: 36px; padding: 0 10px; border: 0; border-radius: 10px; background: var(--bg); color: var(--ink); font: inherit; font-size: .88rem; }
.dates input:focus { outline: 2px solid var(--primary); }
.actions { display: flex; align-items: center; gap: 12px; }
.btn, .actions button { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 20px; border-radius: 999px; border: 0;
  background: var(--surface-2); color: var(--ink); font: inherit; font-weight: 500; font-size: .92rem; cursor: pointer; }
.btn:hover, .actions button:hover { text-decoration: none; filter: brightness(0.97); }
.btn.primary, .actions button { background: var(--primary); color: var(--primary-ink); }
.results-h { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 8px; color: var(--muted); }
.results-h strong { color: var(--ink); font-weight: 600; }
.sort select { height: 38px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: .9rem; cursor: pointer; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.thumb { flex: none; width: 72px; height: 96px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-body { min-width: 0; flex: 1; }
.row .tl { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.row .t { font-weight: 500; font-size: 1.05rem; color: var(--ink); }
.row .st { color: var(--muted); font-weight: 400; }
.row .a { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.row .m { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--faint); font-size: .84rem; margin-top: 4px; }
.row .m a { color: var(--faint); }
.row .d { color: var(--muted); font-size: .9rem; margin: 8px 0 0; max-width: 80ch; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted) !important; font-size: .76rem; font-weight: 500; }
.tag:hover { text-decoration: none; background: var(--surface-3); }
.dot { color: var(--surface-3); }
.pager { display: flex; gap: 12px; justify-content: center; align-items: center; padding: 28px 0; color: var(--muted); }

/* Book */
.book { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 48px; padding-top: 40px; align-items: start; }
.book-cover { position: sticky; top: 100px; }
.book-cover img { width: 100%; border-radius: 12px; box-shadow: var(--shadow); display: block; }
.book-main h1 { margin-top: 4px; }
.book .sub { font-size: 1.15rem; color: var(--muted); margin: 0 0 12px; }
.book .by { font-size: 1rem; margin: 0 0 24px; color: var(--ink); }
.panel { background: var(--surface); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 20px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 0; }
.facts dt { color: var(--faint); }
.facts dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.eds { border-collapse: collapse; width: 100%; font-size: .92rem; }
.eds th, .eds td, .pubs-t th, .pubs-t td { text-align: left; padding: 10px 16px 10px 0; border-bottom: 1px solid var(--line); }
.eds tr:last-child td, .pubs-t tr:last-child td { border-bottom: 0; }
.eds th, .pubs-t th { color: var(--faint); font-weight: 500; font-size: .8rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .86rem; }
.buy { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 28px; }
.panel h2 { margin: 0 0 12px; font-size: 1.05rem; }
.desc { max-width: 72ch; color: var(--ink); }
.src { color: var(--faint); font-size: .8rem; margin-top: 16px; }

/* Publishers / about */
.pubgroup { margin-top: 28px; }
.pubs-t { border-collapse: collapse; width: 100%; max-width: 680px; }
.pubs-t .r { text-align: right; font-variant-numeric: tabular-nums; }
.page { padding-top: 40px; }
.prose { max-width: 72ch; }
.prose p { color: var(--muted); }
.foot { color: var(--faint); font-size: .82rem; padding-top: 56px; padding-bottom: 40px; }

@media (max-width: 860px) {
  .wrap { padding: 0 16px; }
  .top-in { height: auto; flex-wrap: wrap; gap: 8px 12px; padding-top: 10px; padding-bottom: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .top-in { gap: 8px; }
  nav { gap: 0; }
  nav a { padding: 6px 8px; font-size: .88rem; }
  .theme { width: 34px; height: 34px; }
  .brand { font-size: 1.15rem; }
  .browse { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 16px; }
  .filters { position: static; max-height: none; padding: 0; }
  .filters summary { display: flex; align-items: center; gap: 8px; padding: 12px 20px; font-weight: 500; cursor: pointer; list-style: none; }
  .filters summary::-webkit-details-marker { display: none; }
  .filters summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); }
  .filters[open] summary::after { transform: rotate(-135deg); }
  .filters .nf { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: var(--primary-ink); font-size: .75rem; }
  .filters form { padding: 4px 20px 20px; }
  .filters .publist { max-height: 220px; overflow: auto; }
  .book { grid-template-columns: minmax(0, 1fr); gap: 24px; padding-top: 24px; }
  .book-cover { position: static; max-width: 180px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .card { padding: 8px; }
  .intro { padding-top: 24px; }
  h1 { font-size: 1.6rem; }
  .row { gap: 14px; }
  .thumb { width: 56px; height: 75px; }
}
