:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #6b6560;
  --border: #e7e3de;
  --accent: #c2410c;
  --accent-soft: #fff1e8;
  --warn: #a16207;
  --warn-soft: #fef6dc;
  --shadow: 0 1px 2px rgba(28, 25, 23, .05);
  --serif: "Source Serif 4", Georgia, serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210;
    --surface: #1d1a17;
    --text: #ece8e3;
    --muted: #a39d96;
    --border: #2f2a26;
    --accent: #fb923c;
    --accent-soft: #2c1d12;
    --warn: #facc15;
    --warn-soft: #2a2410;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
}
a { color: inherit; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }

/* Masthead */
.masthead { border-bottom: 1px solid var(--border); background: var(--surface); }
.masthead-inner {
  display: flex; flex-wrap: wrap; gap: 8px 24px;
  align-items: flex-end; justify-content: space-between;
  padding-top: 28px; padding-bottom: 20px;
}
h1 { font: 700 2.1rem/1.1 var(--serif); margin: 0; letter-spacing: -.01em; }
.tagline { margin: 6px 0 0; color: var(--muted); }
.updated { margin: 0; font-size: .875rem; color: var(--muted); }

/* Toolbar */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: space-between; padding-top: 20px; padding-bottom: 4px;
}
.toolbar input {
  flex: 1 1 220px; min-width: 0;
  font: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 12px;
}
.toolbar input:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.toolbar-buttons { display: flex; gap: 8px; }
button {
  font: 500 .875rem var(--sans); color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; cursor: pointer;
}
button:hover { border-color: var(--muted); }

/* Sections and lists */
.section-title {
  font: 600 .8rem var(--sans); text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 32px 0 12px;
}
.lists { display: grid; gap: 10px; }

details.list {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
}
details.list > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
}
details.list > summary::-webkit-details-marker { display: none; }
summary .chev {
  flex: none; width: 10px; height: 10px; margin-right: 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform .15s ease;
}
details[open] > summary .chev { transform: rotate(45deg); }
summary .name { font: 600 1.15rem/1.3 var(--serif); }
summary .count { margin-left: auto; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.badge {
  font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--warn-soft); color: var(--warn); white-space: nowrap;
}

ol.items { list-style: none; margin: 0; padding: 0 16px 6px; counter-reset: rank; }
ol.items li {
  counter-increment: rank;
  display: grid; grid-template-columns: 28px 1fr auto; gap: 4px 12px;
  padding: 14px 0; border-top: 1px solid var(--border);
}
ol.items li::before {
  content: counter(rank);
  font: 700 1rem/1.4 var(--serif); color: var(--accent);
}
.item-body { min-width: 0; }
.item-title { font-weight: 600; line-height: 1.35; text-decoration: none; }
.item-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.meta { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.meta .metric { color: var(--accent); font-weight: 500; }
.summary { margin: 6px 0 0; font-size: .95rem; }
.thumb {
  width: 96px; height: 64px; object-fit: cover; border-radius: 6px;
  background: var(--border);
}
.sublists { display: grid; gap: 8px; padding: 4px 16px 16px; }
details.list.sub { background: var(--bg); box-shadow: none; border-radius: 10px; }
details.list.sub > summary { padding: 11px 14px; }
details.list.sub summary .name { font-size: 1rem; }
details.list.sub ol.items { padding: 0 14px 4px; }
.empty { padding: 14px 0; color: var(--muted); border-top: 1px solid var(--border); margin: 0; }

.error {
  margin-top: 24px; padding: 12px 14px; border-radius: 8px;
  background: var(--warn-soft); color: var(--warn);
}
.footer { color: var(--muted); font-size: .8rem; padding-top: 24px; padding-bottom: 40px; }
.footer p { margin: 8px 0; }

@media (max-width: 560px) {
  h1 { font-size: 1.7rem; }
  .thumb { width: 72px; height: 48px; }
  ol.items li { grid-template-columns: 22px 1fr auto; gap: 4px 10px; }
}
