/* Bookshelf — a modern rebuild of the Books Gallery demo
   One stylesheet, no frameworks. Light + dark themes via CSS variables. */

:root {
  --bg: #f6f6f9;
  --surface: #ffffff;
  --surface-2: #f0f0f6;
  --text: #16161d;
  --muted: #6a6a7c;
  --line: #e4e4ee;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --brand-soft: #eceafd;
  --accent: #e07a1f;
  --good: #12805c;
  --bad: #c0392b;
  --star: #f5a524;
  --shadow: 0 1px 2px rgb(20 20 40 / 6%), 0 8px 24px -12px rgb(20 20 40 / 18%);
  --shadow-lg: 0 2px 4px rgb(20 20 40 / 8%), 0 24px 48px -16px rgb(20 20 40 / 30%);
  --radius: 14px;
  --radius-sm: 9px;
  --ring: 0 0 0 3px rgb(79 70 229 / 35%);
  --cols: 4;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0f0f15;
  --surface: #181821;
  --surface-2: #20202c;
  --text: #ececf4;
  --muted: #9a9ab0;
  --line: #2a2a38;
  --brand: #8b84ff;
  --brand-ink: #11111a;
  --brand-soft: #25234a;
  --accent: #f0a04b;
  --good: #3ccf9b;
  --bad: #ff7b6b;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -12px rgb(0 0 0 / 60%);
  --shadow-lg: 0 2px 4px rgb(0 0 0 / 50%), 0 24px 48px -16px rgb(0 0 0 / 80%);
  --ring: 0 0 0 3px rgb(139 132 255 / 45%);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f0f15;
    --surface: #181821;
    --surface-2: #20202c;
    --text: #ececf4;
    --muted: #9a9ab0;
    --line: #2a2a38;
    --brand: #8b84ff;
    --brand-ink: #11111a;
    --brand-soft: #25234a;
    --accent: #f0a04b;
    --good: #3ccf9b;
    --bad: #ff7b6b;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 8px 24px -12px rgb(0 0 0 / 60%);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / 50%), 0 24px 48px -16px rgb(0 0 0 / 80%);
    --ring: 0 0 0 3px rgb(139 132 255 / 45%);
    color-scheme: dark;
  }
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--brand); text-underline-offset: 2px; }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { width: min(1280px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--brand); color: var(--brand-ink); padding: 8px 14px; border-radius: 8px;
  transition: top 0.15s;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--brand); text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }
.brand span { color: var(--text); }
.brand-mark { width: 28px; height: 28px; max-width: none; object-fit: contain; flex: none; border-radius: 6px; }

.search-box {
  flex: 1; max-width: 560px; margin-inline: auto; position: relative;
  display: flex; align-items: center;
}
.search-box .ico { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.search-box input[type='search'] {
  width: 100%; height: 42px; padding: 0 44px 0 42px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.search-box input::placeholder { color: var(--muted); }
.search-box input[type='search']:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: var(--ring); }
.search-box input::-webkit-search-cancel-button { margin-right: -24px; cursor: pointer; }
.search-box kbd {
  position: absolute; right: 14px; font: 12px/1 ui-monospace, monospace; color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 3px 6px; background: var(--surface);
}
.search-box input:focus ~ kbd, .search-box input:not(:placeholder-shown) ~ kbd { display: none; }

.top-actions { display: flex; gap: 6px; align-items: center; }
.country-pick select { height: 40px; width: auto; min-width: 110px; padding: 0 30px 0 12px; border-color: transparent; background-color: transparent; font-weight: 600; font-size: 14px; }
.country-pick select:hover { background-color: var(--surface-2); }
.rate-note { margin-top: 6px; font-size: 12.5px; }
.d-note { font-size: 13px; margin-top: -6px; }
.desc-more { justify-self: start; }
.price .approx { font-weight: 400; color: var(--muted); font-size: 0.8em; margin-right: 1px; }

/* ---------- Buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px;
  text-decoration: none; color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.05s, color 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--brand); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.icon { width: 40px; padding: 0; }
.btn.block { width: 100%; }
.btn[aria-pressed='true'] { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; font-weight: 600; padding: 4px; }
.link:hover { text-decoration: underline; }

.count-pill {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-size: 12px; font-weight: 700;
}

select, input[type='text'], input[type='search'] {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); width: 100%;
}
select { appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%239a9ab0' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select:focus, input:focus-visible { outline: none; border-color: var(--brand); box-shadow: var(--ring); }

.sun { display: none; }
:root[data-theme='dark'] .sun { display: block; }
:root[data-theme='dark'] .moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .sun { display: block; }
  :root:not([data-theme='light']) .moon { display: none; }
}

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 28px; padding: 28px 0 56px; align-items: start; }

.filters {
  position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 18px;
  scrollbar-width: thin;
}
.filters-head { display: flex; align-items: center; gap: 8px; }
.filters-head h2 { font-size: 16px; margin-right: auto; }

.facet { border: 0; margin: 0; padding: 0; min-width: 0; }
.facet legend, .facet > label, .facet label:not(.check):not(.switch) {
  display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 8px; padding: 0;
}
.facet.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.check-list { display: flex; flex-direction: column; gap: 2px; max-height: 232px; overflow: auto; margin-right: -6px; padding-right: 6px; scrollbar-width: thin; }
.check { display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.check:hover { background: var(--surface-2); }
.check input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; flex: none; }
.check .n { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.check.disabled { opacity: 0.45; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed='true'] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.chip.is-empty { opacity: 0.45; }

.range-head { display: flex; justify-content: space-between; align-items: baseline; }
.range-head label { margin-bottom: 4px !important; }
.range-head output { font-weight: 700; font-variant-numeric: tabular-nums; }
input[type='range'] { width: 100%; accent-color: var(--brand); margin: 6px 0 0; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--line); position: relative; transition: background 0.2s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 2px rgb(0 0 0 / 30%); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

.only-mobile { display: none; }

/* ---------- Page head ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.page-head h1 { font-size: 26px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.select-wrap select { width: auto; min-width: 190px; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.segmented button { width: 40px; height: 38px; border: 0; background: transparent; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button:hover { background: var(--surface-2); }
.segmented button[aria-pressed='true'] { background: var(--brand-soft); color: var(--brand); }
.segmented button:focus-visible { border-radius: 0; }

.active-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.active-chips:empty { display: none; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 12px;
  border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 600; border: 0;
}
.tag button { all: unset; cursor: pointer; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; }
.tag button:hover { background: color-mix(in srgb, var(--brand) 20%, transparent); }
.tag button:focus-visible { box-shadow: var(--ring); }

/* ---------- Results ---------- */
.results { display: grid; gap: 18px; outline: none; }
.results.grid { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
.results.covers { grid-template-columns: repeat(calc(var(--cols) + 2), minmax(0, 1fr)); gap: 14px; }
.results.list { grid-template-columns: 1fr; gap: 12px; }

.card {
  position: relative; display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  animation: rise 0.35s both;
}
.results .card:nth-child(1) { animation-delay: 0ms; }
.results .card:nth-child(2) { animation-delay: 25ms; }
.results .card:nth-child(3) { animation-delay: 50ms; }
.results .card:nth-child(4) { animation-delay: 75ms; }
.results .card:nth-child(5) { animation-delay: 100ms; }
.results .card:nth-child(6) { animation-delay: 125ms; }
.results .card:nth-child(7) { animation-delay: 150ms; }
.results .card:nth-child(8) { animation-delay: 175ms; }
.results .card:nth-child(9) { animation-delay: 200ms; }
.results .card:nth-child(10) { animation-delay: 225ms; }
.results .card:nth-child(11) { animation-delay: 250ms; }
.results .card:nth-child(12) { animation-delay: 275ms; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.cover-btn {
  all: unset; display: block; cursor: pointer; position: relative;
  background: linear-gradient(160deg, var(--surface-2), color-mix(in srgb, var(--surface-2) 70%, var(--brand-soft)));
  padding: 18px 18px 10px;
}
.cover-btn:focus-visible { box-shadow: inset var(--ring); }
.cover-btn img {
  width: 100%; aspect-ratio: 2 / 3; object-fit: contain; border-radius: 4px;
  filter: drop-shadow(0 8px 14px rgb(0 0 0 / 28%));
  transition: transform 0.25s;
}
.card:hover .cover-btn img { transform: scale(1.03); }

.badge {
  position: absolute; top: 10px; left: 10px; z-index: 2; pointer-events: none; background: var(--bad); color: #fff; font-weight: 800;
  font-size: 12px; padding: 3px 8px; border-radius: 999px; letter-spacing: 0.02em;
}

.heart {
  position: absolute; top: 8px; right: 8px; z-index: 2; width: 34px; height: 34px; border-radius: 50%;
  border: 0; cursor: pointer; display: grid; place-items: center; color: var(--muted);
  background: color-mix(in srgb, var(--surface) 90%, transparent); box-shadow: var(--shadow);
  transition: transform 0.15s, color 0.15s;
}
.heart:hover { transform: scale(1.1); color: var(--bad); }
.heart[aria-pressed='true'] { color: var(--bad); }
.heart[aria-pressed='true'] svg { fill: currentColor; }

.card-body { padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { font-size: 16px; }
.card h3 a, .card h3 button { all: unset; cursor: pointer; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: inherit; text-decoration: none; }
.card h3 a:hover, .card h3 button:hover { color: var(--brand); }
.card h3 a:focus-visible, .card h3 button:focus-visible { box-shadow: var(--ring); }
.card .author a, .meta-line a { color: inherit; }
.author { font-size: 13.5px; color: var(--muted); }
.meta-line { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.fmt { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.fmt span { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

.rating { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; }
.rating svg { color: var(--star); }
.rating small { color: var(--muted); font-weight: 400; }

.card-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { display: flex; align-items: baseline; gap: 8px; }
.price strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.price s { color: var(--muted); font-size: 13px; }

.buy {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 9px;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 13px; text-decoration: none;
}
.buy:hover { filter: brightness(1.1); }

/* list layout */
.results.list .card { flex-direction: row; align-items: stretch; }
.results.list .cover-btn { width: 118px; flex: none; padding: 12px; align-self: flex-start; background: none; }
.results.list .card { align-items: flex-start; }
.results.list .badge { top: 8px; left: 8px; }
.results.list .card-body { padding: 16px 18px; }
.results.list .card h3 { font-size: 18px; }
.results.list .blurb { display: block; }
.blurb { display: none; font-size: 14px; color: var(--muted); display: none; overflow: hidden; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.results.list .blurb { display: -webkit-box; }
.results.list .card-foot { justify-content: flex-start; gap: 18px; }

/* covers layout */
.results.covers .card-body, .results.covers .heart { display: none; }
.results.covers .cover-btn { padding: 10px; }
.results.covers .card:hover .heart { display: grid; }

mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Empty / pager ---------- */
.empty { text-align: center; padding: 64px 16px; display: grid; justify-items: center; gap: 10px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 20px; }
.empty .btn { margin-top: 8px; }

.pager { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 30px; flex-wrap: wrap; }
.pager button {
  min-width: 40px; height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pager button:hover:not(:disabled) { background: var(--surface-2); }
.pager button[aria-current='page'] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager .gap { color: var(--muted); padding: 0 4px; }
.pager .size { display: flex; align-items: center; gap: 8px; margin-left: 16px; font-size: 13px; color: var(--muted); }
.pager .size select { height: 40px; width: auto; }

/* ---------- Detail dialog ---------- */
.detail {
  width: min(960px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0;
  border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: auto;
}
.detail::backdrop { background: rgb(8 8 20 / 62%); backdrop-filter: blur(3px); }
.detail[open] { animation: pop 0.22s both; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } }

.detail-nav { position: sticky; top: 0; z-index: 3; display: flex; justify-content: flex-end; gap: 4px; padding: 10px 10px 0; height: 0; overflow: visible; }
.detail-nav .btn { background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: var(--shadow); font-size: 20px; }

.detail-body { display: grid; grid-template-columns: 300px 1fr; gap: 32px; padding: 32px; }
.d-cover { background: linear-gradient(160deg, var(--surface-2), var(--brand-soft)); border-radius: var(--radius); padding: 24px; align-self: start; position: sticky; top: 32px; }
.d-cover img { width: 100%; aspect-ratio: 2 / 3; object-fit: contain; filter: drop-shadow(0 14px 22px rgb(0 0 0 / 35%)); }
.d-main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.d-main h2 { font-size: 28px; padding-right: 130px; }
.d-sub { color: var(--muted); font-size: 16px; margin-top: -6px; }
.d-price { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.d-price strong { font-size: 30px; font-variant-numeric: tabular-nums; }
.d-price s { color: var(--muted); }
.d-price .save { color: var(--good); font-weight: 700; font-size: 14px; }
.d-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.d-actions .buy { height: 44px; padding: 0 22px; font-size: 15px; border-radius: 11px; }
.d-actions .btn { height: 44px; }
.d-actions .btn[aria-pressed='true'] { color: var(--bad); }
.d-desc { color: var(--text); display: grid; gap: 10px; max-width: 68ch; }
.d-desc h3, .d-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.d-desc p { margin: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.d-specs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; margin: 0; }
.d-specs div { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.d-specs dt { color: var(--muted); }
.d-specs dd { margin: 0; text-align: right; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.d-specs dd button { all: unset; cursor: pointer; color: var(--brand); }
.d-specs dd button:hover { text-decoration: underline; }
.d-specs dd button:focus-visible { box-shadow: var(--ring); }
.d-specs .wide { grid-column: 1 / -1; }
.d-related { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 12px; }
.d-related button { all: unset; cursor: pointer; border-radius: 8px; padding: 6px; background: var(--surface-2); }
.d-related button:hover { background: var(--brand-soft); }
.d-related button:focus-visible { box-shadow: var(--ring); }
.d-related img { width: 100%; aspect-ratio: 2 / 3; object-fit: contain; }

/* ---------- Misc ---------- */
.footer { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: 13px; }
.foot-nav { margin-bottom: 8px; }
.copy { margin: 10px 0 0; }
.legal, .book-page, .page-list { padding: 32px 0 56px; }
.legal h1, .page-list h1 { font-size: 32px; margin-bottom: 16px; }
.legal-body { max-width: 68ch; display: grid; gap: 14px; }
.legal-body p, .legal-body li { line-height: 1.65; }
.legal-body h2 { font-size: 18px; margin-top: 8px; }
.legal-body ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.legal-meta { color: var(--muted); font-size: 13px; }
.legal-body h3 { font-size: 16px; margin-top: 4px; }
.lede { font-size: 17px; color: var(--muted); max-width: 68ch; }
.blog-nav { font-weight: 700; white-space: nowrap; }
.blog-list { display: grid; gap: 12px; margin-top: 22px; }
.blog-card { display: block; text-decoration: none; color: inherit; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: var(--surface); }
.blog-card h2 { font-size: 18px; margin: 4px 0 6px; }
.blog-card p { color: var(--muted); margin: 0; }
.blog-card:hover { border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.post-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.post-table th, .post-table td { border-bottom: 1px solid var(--line); text-align: left; padding: 8px 10px; vertical-align: top; }
.post-cta { margin: 4px 0 0; }
.book-page .page-article { display: grid; grid-template-columns: min(280px, 32vw) 1fr; gap: 32px; align-items: start; }
.book-page h1 { font-size: 32px; }
.page-list .results { margin-top: 22px; }
.env-hint { background: var(--surface-2); padding: 12px 14px; border-radius: 10px; overflow: auto; font-size: 13px; }
@media (max-width: 900px) { .book-page .page-article { grid-template-columns: 1fr; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); animation: rise 0.25s both;
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) { :root { --cols: 3; } }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding-top: 18px; }
  .only-mobile { display: inline-flex; }
  .filters {
    position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(340px, 92vw); max-height: none; border-radius: 0 var(--radius) var(--radius) 0;
    transform: translateX(-105%); transition: transform 0.25s; visibility: hidden;
  }
  .filters.open { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  body.filters-open::after { content: ''; position: fixed; inset: 0; background: rgb(8 8 20 / 50%); z-index: 55; }
  .top-actions .label { display: none; }
  .detail-body { grid-template-columns: 1fr; padding: 22px; gap: 22px; }
  .d-cover { position: static; max-width: 260px; margin-inline: auto; }
  .d-main h2 { padding-right: 0; font-size: 24px; }
  .page-head h1 { font-size: 22px; }
}

@media (max-width: 760px) { :root { --cols: 2; } .results { gap: 12px; } }

@media (max-width: 560px) {
  .topbar-inner { gap: 8px; }
  .brand span { display: none; }
  .search-box kbd { display: none; }
  .select-wrap select { min-width: 0; }
  .results.list .cover-btn { width: 96px; padding: 8px; }
  .results.list .card-body { padding: 12px; }
  .results.list .card h3 { font-size: 15px; }
  .results.list .blurb { display: none; }
  .results.list .card-foot { flex-wrap: wrap; gap: 8px 14px; }
  .card-body { padding: 10px 12px 12px; }
  .card h3 { font-size: 14.5px; }
  .price strong { font-size: 16px; }
  .card-foot { flex-direction: column; align-items: stretch; }
  .results.grid .buy { justify-content: center; }
  .d-specs { grid-template-columns: 1fr; }
  .pager .size { margin-left: 0; width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
