:root {
  color-scheme: light;
  --bg: #efe6d6;
  --ink: #1b1612;
  --muted: #5c5348;
  --paper: #f7f1e6;
  --card: #fffdf8;
  --line: #e0d5c4;
  --mast: #1b1612;
  --mast-ink: #f6f0e6;
  --mast-muted: #cbbba6;
  --accent: #9c341f;
  --focus: #9c341f;
  --paid: #9c341f;
  --free: #1d6b43;
  --seller: #2c4a73;
  --none: #6d6256;
  --affiliate: #8a5a12;
  --subscription: #6a3d78;
  --shadow: 0 1px 0 rgba(27, 22, 18, 0.04), 0 16px 40px rgba(27, 22, 18, 0.08);
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12100e;
  --ink: #f3ece2;
  --muted: #c4b6a4;
  --paper: #1c1814;
  --card: #241f1a;
  --line: #3c332b;
  --mast: #0c0b0a;
  --mast-ink: #f6f0e6;
  --mast-muted: #cbbba6;
  --accent: #e07a62;
  --focus: #f0a48f;
  --paid: #e07a62;
  --free: #7dcea5;
  --seller: #9db7dd;
  --none: #c4b6a4;
  --affiliate: #e2c07a;
  --subscription: #d7b0e0;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: clip;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.02em; line-height: 1.12; }
h1 { margin: 0; font-size: clamp(2.1rem, 4vw, 3.25rem); }
h2 { margin: 0; font-size: clamp(1.45rem, 2vw, 1.85rem); }
h3 { margin: 0 0 8px; font-size: 1.2rem; }
p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: var(--card);
  color: var(--ink);
  padding: 8px 12px;
  z-index: 5;
}
.skip:focus { top: 12px; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wrap { width: min(1120px, calc(100% - 32px)); margin-inline: auto; }
.mast { background: var(--mast); color: var(--mast-ink); }
.mast-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  padding: 28px 0 26px;
}
.mast a { text-decoration: none; }
.mast a:hover { text-decoration: underline; text-underline-offset: 4px; }
.kicker, .filter-label, .host {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 0 0 8px;
  text-wrap: balance;
}
.kicker { color: var(--mast-muted); }
.lede { max-width: 42rem; color: var(--mast-muted); font-size: 1.05rem; }
.mast .lede { margin-top: 10px; }

.theme {
  flex: none;
  background: transparent;
  color: var(--mast-ink);
  border: 1px solid rgba(246, 240, 230, 0.35);
  border-radius: 999px;
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
}
.theme:hover { border-color: var(--mast-ink); }

.status {
  min-height: 0;
  margin: 0 auto;
  color: var(--accent);
  font-weight: 600;
}
.status:empty { display: none; }
.status:not(:empty) { padding-top: 14px; }

#app { padding: 22px 0 28px; }
.loading { color: var(--muted); }

.search { display: grid; gap: 6px; margin-bottom: 16px; }
.search label { font-size: 0.85rem; font-weight: 650; }
.search input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 48px;
}
.search input::placeholder { color: var(--muted); }

.filter-block { margin-bottom: 10px; }
.filter-label { color: var(--muted); margin-bottom: 6px; }
.chips, .stats { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .stat, .ghost, .solid, .tray-clear, .tray-chip {
  cursor: pointer;
  border-radius: 999px;
  min-height: 40px;
}
.chip, .stat {
  background: transparent;
  border: 1px solid var(--line);
  padding: 0 12px;
}
.chip[aria-pressed="true"], .stat[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.stats { margin: 14px 0 8px; }
.stat { background: var(--card); }

.tally { color: var(--muted); margin: 8px 0 14px; font-size: 0.95rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17.5rem), 1fr));
  gap: 14px;
}
.card {
  display: grid;
  grid-template-columns: 8px 1fr;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  min-width: 0;
}
.spine { background: var(--none); }
.card[data-money="free"] .spine { background: var(--free); }
.card[data-money="seller"] .spine { background: var(--seller); }
.card[data-money="none"] .spine { background: var(--none); }
.card[data-money="affiliate"] .spine { background: var(--affiliate); }
.card[data-money="subscription"] .spine { background: var(--subscription); }
.card[data-money="paid"] .spine { background: var(--paid); }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card-top, .tray-card, .tray-actions, .detail-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .host { margin: 0; color: var(--muted); }
.card h2 a { text-decoration: none; }
.card h2 a:hover { text-decoration: underline; text-underline-offset: 3px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span {
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
}
.price { font-weight: 650; }
.hook, .note, .foot, .noscript { color: var(--muted); }
.hook {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  padding: 0 10px;
  flex: none;
}
.ghost[aria-pressed="true"] {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.empty {
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 28px 22px;
  display: grid;
  gap: 10px;
  justify-items: start;
}
.solid, .tray-go {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fffdf8;
  border: 0;
  text-decoration: none;
  font-weight: 650;
}
:root[data-theme="dark"] .solid,
:root[data-theme="dark"] .tray-go { color: #1b1612; }

.back { margin-bottom: 12px; }
.back a { color: var(--accent); font-weight: 650; }
.detail, .compare { display: grid; gap: 12px; max-width: 78rem; }
.detail {
  border-top: 4px solid var(--none);
  padding-top: 16px;
}
.detail[data-money="paid"] { border-top-color: var(--paid); }
.detail[data-money="free"] { border-top-color: var(--free); }
.detail[data-money="seller"] { border-top-color: var(--seller); }
.detail[data-money="none"] { border-top-color: var(--none); }
.detail[data-money="affiliate"] { border-top-color: var(--affiliate); }
.detail[data-money="subscription"] { border-top-color: var(--subscription); }
.detail .host { color: var(--muted); margin: 0; }
.detail .lede { color: var(--ink); font-size: 1.15rem; max-width: 40rem; }
.facts { display: grid; gap: 10px; margin: 6px 0; }
.facts div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.facts dt { color: var(--muted); font-size: 0.85rem; }
.detail ul, .compare-note ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 8px; }
.note {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 12px;
}
.source a { font-weight: 650; }
.source-host { color: var(--muted); font-weight: 450; }

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
table { border-collapse: collapse; width: 100%; min-width: 640px; }
th, td { text-align: left; vertical-align: top; padding: 12px 14px; border-bottom: 1px solid var(--line); }
thead th { font-family: var(--serif); font-size: 1.2rem; font-weight: 500; }
thead .host { display: block; margin-top: 4px; }
tbody th { color: var(--muted); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }
.compare-notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 14px;
}
.compare-note {
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 4px solid var(--none);
  border-radius: 14px;
  padding: 14px 16px 16px;
  display: grid;
  gap: 8px;
}
.compare-note[data-money="paid"] { border-top-color: var(--paid); }
.compare-note[data-money="free"] { border-top-color: var(--free); }
.compare-note[data-money="seller"] { border-top-color: var(--seller); }
.compare-note[data-money="affiliate"] { border-top-color: var(--affiliate); }
.compare-note[data-money="subscription"] { border-top-color: var(--subscription); }
.compare-note[data-money="none"] { border-top-color: var(--none); }

.tray {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--bg);
  padding: 10px 0 2px;
}
.tray[hidden] { display: none; }
.tray-card {
  background: var(--mast);
  color: var(--mast-ink);
  border-radius: 16px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}
.tray-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.tray-chip, .tray-clear {
  background: transparent;
  color: var(--mast-ink);
  border: 1px solid rgba(246, 240, 230, 0.35);
  padding: 0 12px;
}
.tray-wait { color: var(--mast-muted); font-size: 0.9rem; }
.foot { padding: 8px 0 36px; font-size: 0.9rem; }
.noscript { padding-bottom: 24px; }

@media (max-width: 720px) {
  .wrap { width: min(1120px, calc(100% - 24px)); }
  .mast-row { flex-direction: column; align-items: stretch; padding-top: 20px; }
  .facts div { grid-template-columns: 1fr; gap: 2px; }
  .theme { align-self: flex-start; }
  .tray-card { align-items: stretch; flex-direction: column; }
  .tray-actions { justify-content: flex-start; }
  thead th { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
