:root {
  --bg: #f5f2ea;
  --surface: #fffdf8;
  --surface-2: #ece7db;
  --ink: #1b1a17;
  --ink-2: #5d5a52;
  --ink-3: #8b877c;
  --line: #ddd7c9;
  --accent: #1d7a55;
  --focus: #1d7a55;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 14px;
  --gutter: clamp(16px, 4vw, 48px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e10;
    --surface: #161619;
    --surface-2: #1f1f23;
    --ink: #ecebe6;
    --ink-2: #a9a7a0;
    --ink-3: #75736d;
    --line: #2a2a2f;
    --accent: #66d9a6;
    --focus: #66d9a6;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e10;
  --surface: #161619;
  --surface-2: #1f1f23;
  --ink: #ecebe6;
  --ink-2: #a9a7a0;
  --ink-3: #75736d;
  --line: #2a2a2f;
  --accent: #66d9a6;
  --focus: #66d9a6;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; margin: 0; }

/* header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px var(--gutter);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.mark { font-family: var(--serif); font-size: 24px; text-decoration: none; }
.top nav { display: flex; gap: clamp(12px, 2.5vw, 28px); font-size: 14px; flex-wrap: wrap; justify-content: flex-end; }
.top nav a { text-decoration: none; color: var(--ink-2); }
.top nav a:hover { color: var(--ink); }

/* hero */
.hero { position: relative; min-height: min(78vh, 720px); display: grid; align-items: end; padding: 0 var(--gutter) clamp(40px, 8vh, 88px); overflow: hidden; }
.hero-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-copy { position: relative; max-width: 900px; }
.eyebrow { font-family: var(--mono); font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 16px; }
.hero h1 { font-size: clamp(44px, 8.5vw, 112px); line-height: 0.95; }
.hero h1 em { color: var(--accent); }
.lede { font-size: clamp(17px, 2vw, 20px); color: var(--ink-2); max-width: 640px; margin: 24px 0 0; }

/* sections */
main > section:not(.hero) { padding: clamp(48px, 8vw, 96px) var(--gutter) 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.section-head h2, .ask-head h2 { font-size: clamp(34px, 5vw, 56px); }
.section-head p { color: var(--ink-2); margin: 0; }

/* ask */
.ask-head p { color: var(--ink-2); margin: 8px 0 24px; max-width: 560px; }
.ask-form { display: flex; gap: 10px; max-width: 760px; }
.ask-form input {
  flex: 1; min-width: 0; padding: 15px 18px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); font-size: 17px;
}
.ask-form input:focus { outline: none; border-color: var(--accent); }
.ask-form button, .chips button, .filters button, .follow button {
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.ask-form button { padding: 0 22px; background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 500; white-space: nowrap; }
.ask-form button:disabled { opacity: 0.5; cursor: progress; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; max-width: 900px; }
.chips button, .follow button { padding: 7px 14px; font-size: 14px; color: var(--ink-2); }
.chips button:hover, .follow button:hover, .filters button:hover { color: var(--ink); border-color: var(--ink-3); }
.ask-status { min-height: 1.5em; color: var(--ink-2); font-size: 14px; margin: 16px 0 0; }
.ask-status.error { color: #c2410c; }

/* generated view */
.view { margin-top: 18px; border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px); background: var(--surface); padding: clamp(20px, 4vw, 44px); }
.view-q { font-family: var(--mono); font-size: 13px; color: var(--ink-3); margin: 0 0 10px; }
.view h3.view-title { font-size: clamp(32px, 4.5vw, 52px); line-height: 1.05; }
.view .view-intro { color: var(--ink-2); font-size: 18px; max-width: 720px; margin: 12px 0 0; }
.block { margin-top: clamp(28px, 4vw, 44px); animation: rise 0.5s both; }
.block:nth-of-type(2) { animation-delay: 0.08s; }
.block:nth-of-type(3) { animation-delay: 0.16s; }
.block:nth-of-type(4) { animation-delay: 0.24s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .block { animation: none; } }
.block > h4 { font-family: var(--mono); font-weight: 400; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 14px; }
.block-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.mini { text-align: left; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); overflow: hidden; cursor: pointer; padding: 0; display: flex; flex-direction: column; }
.mini canvas { width: 100%; aspect-ratio: 16 / 9; display: block; }
.mini .mini-body { padding: 12px 14px 14px; }
.mini strong { display: block; font-weight: 600; }
.mini span { color: var(--ink-2); font-size: 14px; }
.spot { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(18px, 3vw, 36px); align-items: start; }
.spot canvas { width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius); background: var(--bg); display: block; }
.spot p { margin: 0 0 12px; font-size: 17px; }
.spot ul, .detail ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.spot li, .detail li { margin-bottom: 6px; }
.compare-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.compare { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 15px; }
.compare th, .compare td { text-align: left; vertical-align: top; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.compare tr:last-child td { border-bottom: 0; }
.compare thead th { font-weight: 600; background: var(--bg); }
.compare thead th canvas { width: 100%; height: 56px; display: block; border-radius: 8px; margin-bottom: 8px; }
.compare tbody th { font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; width: 1%; white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.timeline li { position: relative; display: grid; grid-template-columns: 120px 1fr; gap: 16px; padding: 0 0 20px 22px; align-items: center; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 50%; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.timeline canvas { width: 120px; height: 68px; border-radius: 8px; background: var(--bg); display: block; }
.timeline .when { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.timeline button { all: unset; cursor: pointer; font-weight: 600; }
.clusters { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cluster { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--bg); }
.cluster h5 { font-family: var(--serif); font-size: 26px; font-weight: 400; margin: 0 0 6px; }
.cluster p { color: var(--ink-2); margin: 0 0 12px; font-size: 15px; }
.cluster .pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px 4px 6px; font-size: 13px; background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.pill i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.note p { font-size: 18px; max-width: 720px; margin: 0; }
.follow { display: flex; flex-wrap: wrap; gap: 8px; margin-top: clamp(28px, 4vw, 40px); padding-top: 20px; border-top: 1px solid var(--line); }
.loading { display: grid; gap: 14px; }
.loading .bar { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.loading .bar.big { height: 44px; width: 60%; }
.loading canvas { width: 100%; height: 160px; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* work grid */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { padding: 6px 14px; font-size: 14px; color: var(--ink-2); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 18px; }
.card {
  display: flex; flex-direction: column; text-align: left; padding: 0; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--ink-3); }
@media (prefers-reduced-motion: reduce) { .card, .card:hover { transition: none; transform: none; } }
.card canvas { width: 100%; aspect-ratio: 16 / 10; display: block; background: var(--bg); border-bottom: 1px solid var(--line); }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card h3 { font-size: 28px; line-height: 1.1; }
.card p { margin: 0; color: var(--ink-2); font-size: 15px; overflow-wrap: anywhere; }
.meta { margin-top: auto; padding-top: 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
.meta .star::before { content: "★ "; }
.card[hidden] { display: none; }

/* archive */
.archive-list { list-style: none; margin: 0; padding: 0; columns: 3 280px; column-gap: 32px; }
.archive-list li { break-inside: avoid; padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: baseline; }
.archive-list .y { font-family: var(--mono); font-size: 12px; color: var(--ink-3); flex: none; width: 36px; }
.archive-list a { text-decoration: none; font-weight: 500; }
.archive-list a:hover { text-decoration: underline; }
.archive-list span.d { color: var(--ink-2); font-size: 14px; }

/* footer */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 64px var(--gutter) 40px; color: var(--ink-3); font-size: 14px; }

/* detail dialog */
.detail { width: min(920px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: calc(var(--radius) + 6px); background: var(--surface); color: var(--ink); }
.detail::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); }
.detail canvas { width: 100%; aspect-ratio: 21 / 9; display: block; background: var(--bg); }
.detail-text { padding: clamp(20px, 4vw, 36px); display: grid; gap: 14px; }
.detail h2 { font-size: clamp(34px, 5vw, 52px); line-height: 1; }
.detail .tagline { font-size: 19px; color: var(--ink-2); margin: 0; }
.detail .summary { margin: 0; font-size: 17px; }
.detail .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.detail .tags span { font-family: var(--mono); font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.detail .links { display: flex; flex-wrap: wrap; gap: 10px; }
.detail .links a { padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; font-weight: 500; }
.detail .links a.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.detail .close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 20px; line-height: 1; }

@media (max-width: 640px) {
  .top nav a[href="#archive"], .top nav a[href^="https://github"] { display: none; }
  .ask-form { flex-direction: column; }
  .ask-form button { padding: 13px; }
  .spot { grid-template-columns: 1fr; }
  .timeline li { grid-template-columns: 84px 1fr; }
  .timeline canvas { width: 84px; height: 48px; }
}
