:root {
  --ink: #261b18;
  --ink-soft: #6b5a53;
  --paper: #f3eee2;
  --paper-strong: #fffaf1;
  --line: rgba(79, 52, 40, 0.12);
  --line-strong: rgba(79, 52, 40, 0.18);
  --panel: rgba(255, 250, 241, 0.88);
  --accent: #8b3f2f;
  --accent-soft: rgba(139, 63, 47, 0.12);
  --forest: #3d5a4b;
  --forest-soft: rgba(61, 90, 75, 0.16);
  --gold: #c0964a;
  --shadow: 0 18px 40px rgba(61, 44, 33, 0.08);
  --radius: 24px;
  --radius-sm: 18px;
  --max-width: 1260px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(192, 150, 74, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(139, 63, 47, 0.12), transparent 26%),
    linear-gradient(180deg, #f8f4ea 0%, #eee5d6 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  padding: 0.75rem 0.9rem;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(139, 63, 47, 0.42);
  box-shadow: 0 0 0 4px rgba(139, 63, 47, 0.12);
}

pre {
  margin: 0;
  overflow-x: auto;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  background: rgba(248, 244, 234, 0.78);
  border-bottom: 1px solid rgba(79, 52, 40, 0.08);
}

.topbar-inner,
.page-shell {
  width: min(var(--max-width), calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
}

.brand-mark {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.top-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.top-links a {
  min-height: 38px;
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  color: var(--ink-soft);
  font-weight: 700;
}

.top-links a.is-active,
.top-links a:hover {
  background: var(--accent-soft);
  color: var(--ink);
}

.page-shell {
  padding: 28px 0 44px;
}

.library-shell,
.stats-shell,
.sync-shell {
  display: grid;
  gap: 22px;
}

.hero-card,
.panel,
.metric-tile {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.56);
  box-shadow: var(--shadow);
}

.hero-card,
.panel {
  border-radius: var(--radius);
  padding: 24px;
}

.compact-hero {
  padding: 20px 24px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.9fr);
  gap: 24px;
  align-items: center;
}

.hero-card h1,
.panel h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  letter-spacing: -0.03em;
}

.hero-card h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  line-height: 0.96;
}

.hero-copy,
.meta-text,
.stack-item span,
.book-meta,
.book-dates,
.book-review {
  color: var(--ink-soft);
}

.eyebrow,
.metric-label {
  margin: 0 0 0.45rem;
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}

.hero-stats,
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metrics-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-tile {
  border-radius: 22px;
  padding: 20px 18px;
}

.metric-tile strong {
  display: block;
  font-size: clamp(1.7rem, 3vw, 2.7rem);
  line-height: 1;
}

.content-grid {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header p {
  margin: 0 0 4px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span {
  font-size: 0.82rem;
  font-weight: 700;
}

.filter-panel,
.results-panel {
  position: relative;
  overflow: hidden;
}

.filter-panel::before,
.results-panel::before,
.hero-card::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), rgba(255, 255, 255, 0.28), var(--gold));
  opacity: 0.72;
}

.filter-panel {
  position: sticky;
  top: 94px;
  padding: 18px;
}

.results-panel {
  padding: 22px;
}

.results-panel .panel-header {
  margin-bottom: 20px;
}

.results-panel .meta-text {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(139, 63, 47, 0.08);
  font-size: 0.86rem;
  font-weight: 700;
}

.filter-panel .field {
  margin-bottom: 12px;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(198px, 1fr));
  gap: 16px;
}

.book-card {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 251, 246, 0.96));
  border: 1px solid rgba(79, 52, 40, 0.08);
  border-radius: 20px;
  overflow: hidden;
  min-height: 100%;
  box-shadow: 0 12px 24px rgba(61, 44, 33, 0.07);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 34px rgba(61, 44, 33, 0.1);
  border-color: var(--line-strong);
}

.book-cover-link {
  display: block;
  background:
    linear-gradient(180deg, rgba(61, 90, 75, 0.94), rgba(30, 49, 41, 0.98)),
    radial-gradient(circle at top left, rgba(192, 150, 74, 0.22), transparent 34%);
  padding: 10px 10px 0;
}

.book-cover-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 0.67 / 1;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.book-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.book-cover-fallback {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 50%),
    radial-gradient(circle at top left, rgba(192, 150, 74, 0.26), transparent 35%);
}

.book-card-body {
  padding: 12px 14px 14px;
  display: grid;
  gap: 7px;
  align-content: start;
  flex: 1 1 auto;
}

.book-card-topline {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rating-pill,
.shelf-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0.15rem 0.58rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}

.rating-pill {
  background: rgba(61, 90, 75, 0.08);
}

.tone-low {
  background: rgba(139, 63, 47, 0.15);
}

.tone-mid {
  background: rgba(192, 150, 74, 0.2);
}

.tone-high {
  background: rgba(61, 90, 75, 0.16);
}

.tone-neutral {
  background: rgba(107, 90, 83, 0.12);
}

.book-title {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 1.08rem;
  line-height: 1.14;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.book-title a:hover,
.book-author:hover {
  text-decoration: underline;
}

.book-author-row {
  margin: 0;
}

.book-author,
.book-meta,
.book-dates,
.book-review {
  margin: 0;
}

.book-author {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--forest);
  letter-spacing: -0.01em;
}

.book-meta {
  font-size: 0.76rem;
  line-height: 1.45;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #7a655b;
}

.book-dates {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.book-review {
  font-size: 0.84rem;
  line-height: 1.5;
  color: #594a44;
  padding-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-shelves {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 1px;
}

.shelf-pill {
  background: linear-gradient(180deg, rgba(139, 63, 47, 0.12), rgba(139, 63, 47, 0.07));
  color: #7b3426;
  font-size: 0.72rem;
  min-height: 22px;
  border: 1px solid rgba(139, 63, 47, 0.08);
}

.empty-state {
  border-radius: 20px;
  border: 1px dashed rgba(79, 52, 40, 0.22);
  padding: 28px;
  text-align: center;
}

.pagination {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.nav-button {
  min-height: 40px;
  padding: 0.62rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.nav-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.page-info {
  color: var(--ink-soft);
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.summary-chip {
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.56);
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.96), rgba(248, 243, 233, 0.9)),
    radial-gradient(circle at top right, rgba(192, 150, 74, 0.12), transparent 38%);
  box-shadow: var(--shadow);
}

.panel-span-2 {
  grid-column: 1 / -1;
}

.summary-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.summary-chip {
  padding: 13px 14px 12px;
}

.summary-chip span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.summary-chip strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.25;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
}

.bar-list,
.stack-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 7px;
  padding: 11px 13px 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(247, 240, 228, 0.86));
  border: 1px solid rgba(79, 52, 40, 0.07);
  box-shadow: 0 8px 18px rgba(61, 44, 33, 0.045);
}

.bar-row-topline,
.stack-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.bar-row-topline span {
  font-weight: 700;
  line-height: 1.3;
  font-size: 0.92rem;
}

.bar-row-topline strong,
.stack-item strong {
  font-size: 0.96rem;
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(61, 90, 75, 0.09);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.stack-list {
  gap: 8px;
}

.stack-item {
  padding: 12px 13px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(248, 241, 230, 0.88)),
    radial-gradient(circle at top right, rgba(192, 150, 74, 0.12), transparent 36%);
  border: 1px solid rgba(79, 52, 40, 0.07);
  box-shadow: 0 8px 18px rgba(61, 44, 33, 0.045);
}

.stack-item strong {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 1rem;
  line-height: 1.2;
}

.stack-link,
.stack-title {
  display: inline-block;
  text-wrap: balance;
}

.stack-link {
  transition: color 140ms ease;
}

.stack-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.stack-meta {
  flex: 0 0 auto;
  text-align: right;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--ink-soft);
  font-weight: 700;
}

.command-stack {
  border-radius: 18px;
  background: rgba(38, 27, 24, 0.95);
  color: #f8f4ea;
  padding: 16px;
}

@media (max-width: 980px) {
  .hero-grid,
  .content-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .summary-chips {
    grid-template-columns: 1fr;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-panel {
    position: static;
  }

  .stack-item {
    gap: 10px;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 0;
  }

  .page-shell,
  .topbar-inner {
    width: min(var(--max-width), calc(100% - 20px));
  }

  .hero-card,
  .panel {
    padding: 18px;
  }

  .hero-stats,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bar-row-topline,
  .stack-item {
    flex-direction: column;
  }

  .stack-meta {
    text-align: left;
  }
}
