:root {
  --bg: #f4f1ea;
  --surface: #fbf9f4;
  --ink: #1b1a17;
  --muted: #6d685e;
  --line: #ddd7ca;
  --accent: #c2410c;
  --chip: #ebe6db;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  /* category tints for image-less cards */
  --t-agents: #e8dccb; --t-health: #d9e4dc; --t-mind: #e2dceb; --t-play: #f0d9cc;
  --t-media: #dfe3ea; --t-tools: #e6e3d1; --t-research: #dde6e6; --t-web: #ead9de; --t-early: #e4e1dc;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131210; --surface: #1b1a17; --ink: #efebe2; --muted: #9a948a; --line: #2e2c28;
    --accent: #f08a4b; --chip: #262420;
    --t-agents: #2a241c; --t-health: #1c2620; --t-mind: #231f2b; --t-play: #2b1f19;
    --t-media: #1d2128; --t-tools: #25241b; --t-research: #1b2525; --t-web: #2a1e22; --t-early: #22211e;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131210; --surface: #1b1a17; --ink: #efebe2; --muted: #9a948a; --line: #2e2c28;
  --accent: #f08a4b; --chip: #262420;
  --t-agents: #2a241c; --t-health: #1c2620; --t-mind: #231f2b; --t-play: #2b1f19;
  --t-media: #1d2128; --t-tools: #25241b; --t-research: #1b2525; --t-web: #2a1e22; --t-early: #22211e;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { display: block; max-width: 100%; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }

/* header */
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 0; position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.mark { font-family: var(--serif); font-size: 22px; text-decoration: none; letter-spacing: -0.01em; }
.top nav { display: flex; gap: 22px; align-items: center; font-size: 14px; }
.top nav a { text-decoration: none; color: var(--muted); }
.top nav a:hover { color: var(--ink); }
.theme {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
}
.theme:hover { color: var(--ink); }

/* hero */
.hero { padding: 96px 0 72px; border-bottom: 1px solid var(--line); }
.eyebrow, .count, .meta, .stack, .filters button, dd {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.hero h1 {
  font-family: var(--serif); font-weight: 400; font-size: clamp(44px, 7.4vw, 104px);
  line-height: 0.98; letter-spacing: -0.025em; margin: 18px 0 28px; max-width: 15ch;
}
.hero h1 em { color: var(--accent); }
.lede { font-size: clamp(17px, 1.6vw, 20px); max-width: 58ch; color: var(--muted); margin: 0; }
.stats { display: flex; gap: 48px; margin: 48px 0 0; flex-wrap: wrap; }
.stats div { display: flex; flex-direction: column-reverse; }
.stats dt { font-family: var(--serif); font-size: 44px; line-height: 1; }
.stats dd { margin: 0 0 6px; }

/* section heads */
section { padding: 80px 0 24px; }
.sec-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap;
  margin-bottom: 36px;
}
h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 4vw, 52px); margin: 0; letter-spacing: -0.015em; }

/* featured */
.featured { display: grid; gap: 88px; }
.feat { display: grid; grid-template-columns: 1.35fr 1fr; gap: 48px; align-items: center; }
.feat:nth-child(even) { grid-template-columns: 1fr 1.35fr; }
.feat:nth-child(even) .shot { order: 2; }
.shot {
  display: block; text-decoration: none; color: inherit;
  border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface);
  aspect-ratio: 16 / 10; position: relative;
  box-shadow: 0 1px 0 rgba(0,0,0,.02), 0 24px 48px -28px rgba(40,30,10,.35);
}
.shot img { width: 100%; height: 100%; object-fit: cover; object-position: top center; transition: transform .6s ease; }
a.shot:hover img { transform: scale(1.025); }
.feat h3 { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 3.6vw, 48px); line-height: 1.02; margin: 10px 0 14px; letter-spacing: -0.015em; }
.feat p { margin: 0 0 12px; }
.feat .detail { color: var(--muted); font-size: 15px; }
.meta { display: flex; gap: 14px; }
.stack { display: flex; flex-wrap: wrap; gap: 6px; margin: 18px 0 20px; }
.stack span { background: var(--chip); padding: 3px 8px; border-radius: 4px; font-size: 11px; }
.cta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; font-weight: 500; }
.cta a { text-decoration: none; border-bottom: 1px solid currentColor; padding-bottom: 1px; }
.cta a:first-child { color: var(--accent); }
.cta .local { color: var(--muted); font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* generated cover for image-less projects */
.cover {
  width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: space-between;
  padding: clamp(16px, 3vw, 32px); background: var(--tint, var(--chip));
}
.cover .glyph { font-family: var(--serif); font-style: italic; font-size: clamp(56px, 8vw, 120px); line-height: .9; letter-spacing: -0.03em; opacity: .85; }
.cover .tag { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.grid .cover .glyph { font-size: clamp(40px, 4.4vw, 60px); }
.grid .cover .glyph.long { font-size: clamp(32px, 3.2vw, 44px); }
.cover .glyph.long { font-size: clamp(44px, 5.5vw, 80px); }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button {
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 11px;
}
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.filters button:hover:not([aria-pressed="true"]) { color: var(--ink); border-color: var(--muted); }

/* grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 40px 28px; }
.card { display: flex; flex-direction: column; animation: rise .35s ease both; }
.card .shot { aspect-ratio: 16 / 10; box-shadow: none; }
.card h3 { font-size: 19px; font-weight: 600; margin: 16px 0 4px; letter-spacing: -0.01em; display: flex; justify-content: space-between; gap: 12px; }
.card h3 .yr { font-family: var(--mono); font-weight: 400; font-size: 12px; color: var(--muted); padding-top: 4px; white-space: nowrap; }
.card p { margin: 0; font-size: 15px; color: var(--muted); }
.card .stack { margin: 12px 0 0; }
.card .go { margin-top: 10px; font-size: 14px; font-weight: 500; color: var(--accent); text-decoration: none; }
.card .go:hover { text-decoration: underline; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* writing */
.writing { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); counter-reset: w; }
.writing li {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 16px; align-items: baseline;
  padding: 18px 0; border-bottom: 1px solid var(--line); counter-increment: w;
}
.writing li::before { content: counter(w, decimal-leading-zero); font-family: var(--mono); font-size: 12px; color: var(--muted); }
.writing .t { font-family: var(--serif); font-size: clamp(22px, 2.4vw, 30px); line-height: 1.1; }
.writing .n { color: var(--muted); font-size: 14px; text-align: right; }

/* footer */
footer { padding: 120px 0 64px; border-top: 1px solid var(--line); margin-top: 80px; }
footer .big { font-family: var(--serif); font-size: clamp(40px, 6vw, 84px); line-height: 1; margin: 0 0 28px; letter-spacing: -0.02em; }
footer .links { display: flex; gap: 28px; flex-wrap: wrap; margin: 0 0 56px; font-size: 17px; }
footer .links a { text-decoration: none; border-bottom: 1px solid var(--line); }
footer .links a:hover { border-color: var(--ink); }
footer .fine { color: var(--muted); font-size: 13px; margin: 0; }

@media (max-width: 860px) {
  .feat, .feat:nth-child(even) { grid-template-columns: 1fr; gap: 24px; }
  .feat:nth-child(even) .shot { order: 0; }
  .featured { gap: 64px; }
  .hero { padding: 56px 0 48px; }
  .top nav a:not(:last-of-type) { display: none; }
  .grid { grid-template-columns: 1fr; }
  .writing li { grid-template-columns: 36px 1fr; }
  .writing .n { grid-column: 2; text-align: left; }
  .stats { gap: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Additions for the merged catalogue. Original layout retained. */
.project-search{display:flex;align-items:center;gap:20px;margin:0 0 20px;color:var(--muted);font:12px var(--mono)}
.project-search input{flex:1;min-width:0;border:1px solid var(--line);border-radius:6px;background:var(--surface);color:var(--ink);font:14px var(--sans);padding:13px 15px}
#search-count{margin-bottom:24px}.project-details{margin-top:12px;font-size:13px;color:var(--muted)}.project-details summary{cursor:pointer}.project-details p{font-size:13px;margin-top:8px}.project-status{font:11px var(--mono);color:var(--muted);margin-top:12px}.card{min-width:0}.card .go{overflow-wrap:anywhere}.cover .glyph{overflow-wrap:anywhere}a:focus-visible,button:focus-visible,input:focus-visible,summary:focus-visible{outline:2px solid var(--accent);outline-offset:4px}html{scroll-padding-top:85px}
@media(max-width:860px){.top nav a[href="#index"]{display:block}.top nav{gap:14px}.project-search{align-items:stretch;flex-direction:column;gap:8px}}

/* Project resources and detail pages, using the original portfolio typography. */
.resource-links {display:flex;flex-wrap:wrap;gap:10px 20px;margin-top:22px;font-size:13px;line-height:1.6}
.resource-links a {color:var(--accent);text-decoration:none;border-bottom:1px solid var(--line);padding-bottom:3px}
.resource-links a:hover {border-color:var(--accent)}
.index-note,.case-caption {color:var(--muted);font-size:14px;max-width:65ch}
.more-projects {margin:64px 0 0;border-top:1px solid var(--line);padding:24px 0}
.more-projects>summary {font:34px var(--serif);cursor:pointer}
.more-projects>summary .count {margin-left:20px}
.archive-row {display:grid;grid-template-columns:1fr 2fr;gap:30px;padding:24px 0;border-bottom:1px solid var(--line)}
.archive-row h3 {font:25px var(--serif);margin:0 0 7px}
.archive-row p {margin:0 0 8px;max-width:65ch;font-size:14px}
.archive-note {color:var(--muted);font-size:13px!important}
.case {padding:55px 0 100px}.case .back {display:inline-block;color:var(--muted);font-size:14px;margin-bottom:36px}
.case h1 {font:clamp(48px,8vw,96px)/1.04 var(--serif);letter-spacing:-.025em;margin:18px 0 25px}
.case-intro {font-size:clamp(19px,2.5vw,25px);line-height:1.55;color:var(--muted);max-width:44ch}
.case .resource-links {margin-bottom:38px;font-size:15px}
.case-image {width:100%;max-height:720px;object-fit:contain;background:var(--surface);border:1px solid var(--line);border-radius:6px}
.case-image.chart {background:white}.case-body {max-width:730px;margin:35px auto 65px}
.case-body section {padding:26px 0 12px}.case-body h2 {font-size:36px}.case-body p {font-size:17px;line-height:1.8;color:var(--muted)}
.source-tree {border:1px solid var(--line);padding:15px;border-radius:4px}.source-tree summary {cursor:pointer;font-size:14px}
.source-tree ul {padding-left:18px;max-height:340px;overflow:auto;font-size:12px;overflow-wrap:anywhere}
.case-note {border-left:2px solid var(--line);padding-left:18px}
@media(max-width:600px){.archive-row{grid-template-columns:1fr;gap:8px}.case{padding-top:25px}.case-body h2{font-size:30px}.case .top nav{gap:12px}.resource-links{gap:10px 16px}}

[hidden] { display: none !important; }
