@font-face {
  font-family: 'DM Serif Display';
  src: url('../assets/dm-serif.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('../assets/dm-sans.ttf') format('truetype');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('../assets/ibm-plex-mono.ttf') format('truetype');
  font-weight: 400 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4efe6;
  --bg-2: #ece5d8;
  --surface: #fbf8f2;
  --text: #1c1a17;
  --muted: #5a554c;
  --line: #d9d2c4;
  --accent: #2f5d50;
  --accent-ink: #f4efe6;
  --danger: #8a3a2b;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(28,26,23,0.08);
  --focus: 3px solid #2f5d50;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1815;
    --bg-2: #232019;
    --surface: #252219;
    --text: #f0ebe0;
    --muted: #b3ab9a;
    --line: #3a352c;
    --accent: #6fa38f;
    --accent-ink: #1a1815;
    --shadow: 0 10px 30px rgba(0,0,0,0.4);
    --focus: 3px solid #6fa38f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--accent-ink); padding: 8px 12px; z-index: 100;
}
.skip:focus { left: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
}
.brand-name { margin: 0; font-weight: 700; font-size: 16px; }
.brand-sub { margin: 0; font-size: 12px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; }
.header-nav { display: flex; gap: 16px; font-size: 14px; }
.header-nav a { text-decoration: none; color: var(--muted); }
.header-nav a:hover { color: var(--text); }

.hero { padding: 48px 0 32px; }
.hero-grid {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; align-items: end;
}
.hero-copy h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.05; margin: 0 0 16px;
}
.hero-lede { font-size: 17px; color: var(--muted); max-width: 52ch; margin: 0; }
.hero-note { font-size: 13px; color: var(--muted); border-left: 2px solid var(--line); padding-left: 12px; }

.browse { padding: 16px 0 48px; }
.toolbar {
  display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 12px; align-items: end;
  margin-bottom: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--muted); font-family: 'IBM Plex Mono', monospace; text-transform: uppercase; letter-spacing: 0.06em; }
input[type="search"], select {
  height: 44px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; width: 100%;
}
input[type="search"]:focus, select:focus, button:focus-visible {
  outline: var(--focus); outline-offset: 2px;
}

.toggle, .btn {
  height: 44px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer;
}
.toggle[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.results-meta { font-size: 13px; color: var(--muted); margin: 0 0 12px; font-family: 'IBM Plex Mono', monospace; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
@media (prefers-reduced-motion: no-preference) {
  .item:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
}
.item-cat {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent);
}
.item-title { font-family: 'DM Serif Display', Georgia, serif; font-size: 22px; margin: 0; line-height: 1.15; }
.item-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 12px; }
.item-summary { font-size: 14px; color: var(--text); margin: 0; }
.item-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.open-item { background: var(--accent); color: var(--accent-ink); border: none; border-radius: var(--radius-sm); padding: 8px 14px; cursor: pointer; font: inherit; font-size: 14px; }

.empty { text-align: center; padding: 48px 20px; border: 1px dashed var(--line); border-radius: var(--radius); margin-top: 16px; }
.empty h2 { font-family: 'DM Serif Display', Georgia, serif; margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0 0 16px; }

.shortlist-section { padding: 32px 0 64px; border-top: 1px solid var(--line); }
.shortlist-section h2 { font-family: 'DM Serif Display', Georgia, serif; font-size: 30px; margin: 0 0 8px; }
.section-lede { color: var(--muted); margin: 0 0 16px; }
.shortlist { display: flex; flex-wrap: wrap; gap: 8px; }
.shortlist-chip {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.shortlist-chip:hover { background: var(--surface); }

.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(28,26,23,0.55);
  display: grid; place-items: center; padding: 20px;
}
.overlay[hidden] { display: none; }
.detail {
  background: var(--surface); border-radius: var(--radius); max-width: 640px; width: 100%;
  max-height: 88vh; overflow: auto; padding: 24px; position: relative;
  box-shadow: var(--shadow);
}
.close-btn {
  position: absolute; top: 12px; right: 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 10px; cursor: pointer; font: inherit; font-size: 13px;
}
.detail-body h2 { font-family: 'DM Serif Display', Georgia, serif; font-size: 28px; margin: 0 0 4px; padding-right: 70px; }
.detail-cat { font-family: 'IBM Plex Mono', monospace; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin: 0 0 12px; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 14px; margin: 12px 0; }
.detail-meta dt { color: var(--muted); font-size: 12px; font-family: 'IBM Plex Mono', monospace; text-transform: uppercase; letter-spacing: 0.06em; }
.detail-meta dd { margin: 0; }
.detail-body .body { white-space: pre-wrap; font-size: 15px; line-height: 1.6; margin: 16px 0; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.save-item {
  background: var(--accent); color: var(--accent-ink); border: none; border-radius: var(--radius-sm);
  padding: 10px 16px; cursor: pointer; font: inherit;
}
.save-item[aria-pressed="true"] { background: var(--bg-2); color: var(--text); border: 1px solid var(--line); }

.site-footer { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: 13px; }

@media (max-width: 768px) {
  .hero-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr; }
  .detail-meta { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .item { transition: none; }
}
