@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: 'Work Sans';
  src: url('assets/work-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;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #f3ede2;
  --paper-2: #ebe3d4;
  --ink: #1c1a16;
  --ink-soft: #3a352d;
  --muted: #6b6256;
  --rule: #c9bfad;
  --accent: #9c3a22;
  --accent-soft: #f0d9cf;
  --focus: #1c1a16;
  --shadow: 0 12px 40px rgba(28,26,22,0.12);
}
[data-theme="dark"], html[data-theme="dark"] {
  --paper: #1a1814;
  --paper-2: #232019;
  --ink: #f3ede2;
  --ink-soft: #d8d0c2;
  --muted: #a89f90;
  --rule: #3a352d;
  --accent: #e07a5a;
  --accent-soft: #3a241c;
  --focus: #f3ede2;
  --shadow: 0 12px 40px rgba(0,0,0,0.4);
}
@media (prefers-color-scheme: dark) {
  html[data-theme="auto"] {
    --paper: #1a1814;
    --paper-2: #232019;
    --ink: #f3ede2;
    --ink-soft: #d8d0c2;
    --muted: #a89f90;
    --rule: #3a352d;
    --accent: #e07a5a;
    --accent-soft: #3a241c;
    --focus: #f3ede2;
    --shadow: 0 12px 40px rgba(0,0,0,0.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Work Sans', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
a { color: inherit; }
button, input, select { font: inherit; }

.masthead { position: sticky; top: 0; z-index: 10; background: var(--paper); }
.masthead-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.25rem 0.75rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.brand { text-decoration: none; display: flex; flex-direction: column; line-height: 1; }
.brand-mark {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.35rem;
  text-transform: lowercase;
}
.masthead-nav { display: flex; gap: 0.5rem; }
.theme-toggle {
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  padding: 0.4rem 0.75rem;
  border-radius: 2px;
  cursor: pointer;
}
.masthead-rule { height: 1px; background: var(--rule); }

.hero { padding: 3rem 1.25rem 2.5rem; }
.hero-inner { max-width: 1180px; margin: 0 auto; }
.hero-kicker {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 1rem;
  text-transform: lowercase;
}
.hero-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  line-height: 1.05;
  margin: 0 0 1rem;
  max-width: 16ch;
}
.hero-lede {
  font-size: 1.1rem;
  color: var(--ink-soft);
  max-width: 52ch;
  margin: 0;
}

.toolbar { padding: 1.5rem 1.25rem; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: var(--paper-2); }
.toolbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 0.35rem; flex: 1 1 220px; }
.field-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: lowercase;
}
.field input, .field select {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  border-radius: 2px;
  min-height: 40px;
}
.field input:focus, .field select:focus, button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.toggle {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  border-radius: 2px;
  cursor: pointer;
  min-height: 40px;
}
.toggle[aria-pressed="true"] {
  background: var(--accent);
  color: var(--paper);
  border-color: var(--accent);
}

.stories-wrap { padding: 2rem 1.25rem 4rem; }
.stories { max-width: 1180px; margin: 0 auto; display: grid; gap: 0; }
.item {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: start;
}
.item:first-child { border-top: 1px solid var(--rule); }
.item-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.item-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.5rem;
  line-height: 1.15;
  margin: 0 0 0.5rem;
}
.item-summary { color: var(--ink-soft); margin: 0; max-width: 60ch; }
.open-item {
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 0.5rem 0.9rem;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
}
.open-item:hover { background: var(--ink); color: var(--paper); }

.empty-state {
  max-width: 1180px;
  margin: 2rem auto;
  padding: 2rem;
  border: 1px dashed var(--rule);
  text-align: center;
  color: var(--muted);
}
.empty-state button { margin-top: 1rem; }

.footer { padding: 2rem 1.25rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.85rem; }
.footer p { max-width: 1180px; margin: 0 auto; }

.detail {
  border: none;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  width: min(760px, 92vw);
  max-height: 86vh;
  overflow: auto;
  border-radius: 4px;
  box-shadow: var(--shadow);
}
.detail::backdrop { background: rgba(28,26,22,0.55); }
.detail-inner { padding: 2rem 2rem 2.5rem; }
.detail-header { display: flex; justify-content: space-between; align-items: start; gap: 1rem; margin-bottom: 1.5rem; }
.detail-close {
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  padding: 0.4rem 0.75rem;
  border-radius: 2px;
  cursor: pointer;
}
.detail-title {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 2rem;
  line-height: 1.1;
  margin: 0.5rem 0 0;
}
.detail-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: var(--muted);
}
.detail-body p { margin: 0 0 1.25rem; color: var(--ink-soft); font-size: 1.05rem; line-height: 1.7; }
.detail-actions { margin-top: 2rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }
.save-item {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--paper);
  padding: 0.6rem 1rem;
  border-radius: 2px;
  cursor: pointer;
}
.save-item[aria-pressed="true"] { background: transparent; color: var(--accent); }

@media (max-width: 640px) {
  .item { grid-template-columns: 1fr; }
  .open-item { justify-self: start; }
  .hero-title { font-size: 2rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
