:root {
  --bg: #fdf8ef;
  --bg-alt: #f6ecdd;
  --card: #fffdf8;
  --ink: #2c241b;
  --ink-soft: #6b5c4a;
  --line: #e2d4bd;
  --accent: #b4451f;
  --accent-soft: #f0d9cd;
  --gold: #c98a12;
  --pasta-fill: #f2d49a;
  --pasta-line: #a97d3a;
  --pasta-hole: #e0b872;
  --shadow: 0 1px 2px rgba(65, 45, 20, .06), 0 8px 24px rgba(65, 45, 20, .07);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}

/* Dark tokens are declared twice on purpose: once for viewers on the system
   default (no data-theme stamp), once for an explicit dark choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f;
    --bg-alt: #1f1b14;
    --card: #221d16;
    --ink: #f0e7d8;
    --ink-soft: #b0a08a;
    --line: #3a3126;
    --accent: #e8794c;
    --accent-soft: #3a2419;
    --gold: #e0ad4a;
    --pasta-fill: #d8b46f;
    --pasta-line: #8a6428;
    --pasta-hole: #b8914c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --bg: #17140f;
  --bg-alt: #1f1b14;
  --card: #221d16;
  --ink: #f0e7d8;
  --ink-soft: #b0a08a;
  --line: #3a3126;
  --accent: #e8794c;
  --accent-soft: #3a2419;
  --gold: #e0ad4a;
  --pasta-fill: #d8b46f;
  --pasta-line: #8a6428;
  --pasta-hole: #b8914c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- header ---------- */
header.site {
  border-bottom: 1px solid var(--line);
  background: var(--bg-alt);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(6px);
}

header.site .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 62px;
}

.brand {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand svg { width: 26px; height: 26px; }

nav.site a {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: .92rem;
  margin-left: 22px;
  padding-bottom: 3px;
  border-bottom: 2px solid transparent;
}

nav.site a:hover { color: var(--ink); }
nav.site a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- typography ---------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: 1.5rem; }

.lede { color: var(--ink-soft); font-size: 1.05rem; max-width: 46ch; }

.eyebrow {
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}

/* ---------- decider ---------- */
.hero { padding: 44px 0 4px; text-align: center; }
.hero .lede { margin: 14px auto 0; }

.reroll { text-align: center; }
.reroll .big-btn { margin-top: 0; }

.mood {
  text-align: center;
  margin: 46px auto 72px;
  padding-top: 34px;
  border-top: 1px solid var(--line);
  max-width: 780px;
}

.mood-label { color: var(--ink-soft); font-size: .95rem; margin: 0; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 18px auto 0;
  max-width: 720px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 7px 15px;
  font-size: .85rem;
  cursor: pointer;
  font-family: inherit;
  transition: all .14s ease;
}

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

.big-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 26px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-family: var(--serif);
  font-size: 1.15rem;
  padding: 15px 34px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease, filter .12s ease;
}

.big-btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.big-btn:active { transform: translateY(1px); }

/* ---------- result card ---------- */
.result {
  margin: 26px auto 24px;
  max-width: 780px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: none;
}

.result.show { display: block; animation: rise .35s ease both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.result-top {
  display: flex;
  gap: 26px;
  align-items: center;
  padding: 30px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--line);
}

.result-top .art { flex: 0 0 116px; width: 116px; }
.result-top h2 { font-size: 2rem; margin-bottom: 2px; }
.pron { color: var(--ink-soft); font-style: italic; font-size: .95rem; }

.result-body { padding: 26px 30px 30px; }

.spinner-note { color: var(--ink-soft); font-size: .9rem; margin-top: 18px; min-height: 1.2em; }

/* ---------- meta rows ---------- */
.meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin: 20px 0;
}

.meta div {
  padding: 12px 14px;
  box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line);
}

.meta dt {
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 3px;
}

.meta dd { margin: 0; font-size: .95rem; font-weight: 500; }

/* ---------- browse ---------- */
.browse-head { padding: 44px 0 10px; }
.browse-head h1 { margin-bottom: 10px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 18px 0 26px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 30px;
}

.search {
  flex: 1 1 220px;
  min-width: 180px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: .92rem;
}

.search:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
  display: block;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--pasta-line);
}

.card .art { width: 88px; height: 88px; margin: 0 auto 10px; }
.card h3 { font-size: 1.02rem; margin-bottom: 3px; }
.card .sub { font-size: .78rem; color: var(--ink-soft); font-style: italic; }

.cat-block { margin-bottom: 44px; }
.cat-block header { margin-bottom: 16px; }
.cat-block header p { margin: 4px 0 0; color: var(--ink-soft); font-size: .92rem; }

.pasta-art { width: 100%; height: 100%; display: block; }
.art { width: 100%; aspect-ratio: 1; }

/* ---------- detail ---------- */
.detail-head {
  display: flex;
  gap: 34px;
  align-items: center;
  padding: 44px 0 34px;
  flex-wrap: wrap;
}

.detail-head .art { flex: 0 0 150px; width: 150px; }
.detail-head .titles { flex: 1 1 320px; }
.detail-head h1 { margin-bottom: 6px; }

.tagline { color: var(--ink-soft); margin-top: 8px; }

.badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }

.badge {
  font-size: .76rem;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid transparent;
}

.badge.plain { background: transparent; border-color: var(--line); color: var(--ink-soft); }

.cols {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 34px;
  padding-bottom: 60px;
}

@media (max-width: 720px) {
  .cols { grid-template-columns: 1fr; }
  .result-top { flex-direction: column; text-align: center; gap: 14px; }
  .result-top .art { margin: 0 auto; }
  .detail-head { gap: 20px; }
  .detail-head .art { margin: 0 auto; }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
}

.panel h2 { font-size: 1.15rem; margin-bottom: 10px; }
.panel p { margin: 0 0 12px; }
.panel p:last-child { margin-bottom: 0; }

.diefact {
  border-left: 3px solid var(--gold);
  padding-left: 14px;
  color: var(--ink-soft);
  font-size: .93rem;
}

.fact {
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  font-family: var(--serif);
  font-size: 1.02rem;
}

.backlink {
  display: inline-block;
  margin: 24px 0 0;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: .9rem;
}

.backlink:hover { color: var(--accent); }

footer.site {
  border-top: 1px solid var(--line);
  padding: 28px 0 40px;
  color: var(--ink-soft);
  font-size: .85rem;
  text-align: center;
}

.empty { color: var(--ink-soft); padding: 40px 0; text-align: center; }

/* extrusion diagram */
.extrude-fig { width: 100%; max-width: 340px; margin: 6px auto 0; display: block; }

/* accessibility */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

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