/* Light theme by default; dark follows the OS unless the user toggles. */
:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --text: #1b1c20;
  --muted: #6b6f78;
  --line: #e3e1d9;
  --chip: #ecebe4;
  --accent: #2d5be3;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #eceef3;
    --muted: #9aa1ad;
    --line: #262a33;
    --chip: #1f232c;
    --accent: #7c9cff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --text: #eceef3;
  --muted: #9aa1ad;
  --line: #262a33;
  --chip: #1f232c;
  --accent: #7c9cff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }

.masthead { border-bottom: 1px solid var(--line); padding: 2rem 0 1.25rem; }
.title-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.01em;
}

.meta { color: var(--muted); font-size: 0.9rem; margin: 0.4rem 0 0; }

.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  width: 42px;
  height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:focus-visible,
input:focus-visible,
.pill:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.controls { display: flex; flex-direction: column; gap: 0.9rem; padding: 1.25rem 0 0.5rem; }

.search input {
  width: 100%;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.pill {
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 0.88rem;
  cursor: pointer;
}

.pill[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  padding: 0.5rem 0 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.badge {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: color-mix(in srgb, hsl(var(--h) 70% 50%) 18%, transparent);
  color: hsl(var(--h) 70% 60%);
}

.card h2 { font-size: 1.08rem; line-height: 1.3; margin: 0; }
.card h2 a { color: var(--text); text-decoration: none; }
.card h2 a:hover { text-decoration: underline; }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.card footer {
  margin-top: auto;
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.empty { text-align: center; color: var(--muted); padding: 3rem 0; }
.foot { color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); padding: 1.25rem 0 2.5rem; }

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

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .title-row { align-items: flex-start; }
}
