/* Tokens. Spacing follows a 4px scale; radii are 6, 8 and 12. */
:root {
  --bg: #ffffff;
  --bg-sidebar: #f6f6f4;
  --surface: #f0f0ed;
  --border: #e3e3de;
  --border-strong: #c9c9c2;
  --text: #1a1a18;
  --text-2: #4f4f49;
  --text-3: #6b6b64;
  --accent: #b8440f;
  --accent-soft: #fbeee6;
  --on-strong: #ffffff;
  --live: #15803d;
  --signin: #b45309;
  --prototype: #1d4ed8;
  --neutral: #7c7c75;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", Menlo, monospace;
  --sidebar-width: 272px;
  --topbar-height: 52px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #141413;
  --bg-sidebar: #0e0e0d;
  --surface: #20201e;
  --border: #2b2b28;
  --border-strong: #42423d;
  --text: #ecece8;
  --text-2: #b7b7b0;
  --text-3: #8f8f88;
  --accent: #f59052;
  --accent-soft: #2a1b11;
  --on-strong: #141413;
  --live: #4ade80;
  --signin: #fbbf24;
  --prototype: #7fb0ff;
  --neutral: #8f8f88;
  color-scheme: dark;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }
button { font: inherit; color: inherit; }
code { font: 0.9em var(--mono); background: var(--surface); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1:focus { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 8px 12px; border-radius: 8px;
  background: var(--text); color: var(--bg); text-decoration: none;
}
.skip-link:focus { top: 12px; }
.icon {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}

/* Shell */
.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg-sidebar); border-right: 1px solid var(--border);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-height); padding: 0 16px; flex: none;
  text-decoration: none; border-bottom: 1px solid var(--border);
}
.monogram {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--text); color: var(--bg);
  font: 600 11px/1 var(--mono); letter-spacing: 0.02em;
}
.brand-text { display: grid; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 14px; font-weight: 600; }
.brand-text small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  min-height: 36px; padding: 6px 12px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-size: 14px;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--text); font-weight: 500; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-nav h2 {
  margin: 20px 12px 4px;
  font: 500 12px/1.5 var(--sans); color: var(--text-3);
}
.sidebar-foot {
  display: flex; gap: 16px; flex: none;
  padding: 12px 20px; border-top: 1px solid var(--border);
  font-size: 13px;
}
.sidebar-foot a { color: var(--text-3); text-decoration: none; }
.sidebar-foot a:hover { color: var(--text); text-decoration: underline; }

/* Status: a dot plus a text label. Private is a ring so it differs by shape too. */
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--neutral); }
.dot-live, .status-live .dot { background: var(--live); }
.dot-signin, .status-signin .dot { background: var(--signin); }
.dot-prototype, .status-prototype .dot { background: var(--prototype); }
.dot-private, .status-private .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--neutral); }
.status {
  display: inline-flex; align-items: center; gap: 6px;
  font: 12px/1.5 var(--mono); color: var(--text-2); white-space: nowrap;
}

/* Top bar */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--topbar-height); padding: 0 20px; flex: none;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--text-3); }
.crumbs a { color: var(--text-3); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs [aria-current="page"] { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-link {
  display: inline-flex; align-items: center; gap: 4px;
  height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--text-2); text-decoration: none;
}
.topbar-link:hover { border-color: var(--border-strong); color: var(--text); }
.icon-button {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border: 0; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-button:hover { background: var(--surface); color: var(--text); }
.menu-toggle { display: none; }
.backdrop { display: none; }

/* Page */
.view { flex: 1; width: 100%; max-width: 808px; margin: 0 auto; padding: 48px 32px 80px; }
.view:focus { outline: none; }
.view h1 { font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -0.02em; }
.view h2 { font-size: 16px; line-height: 1.4; font-weight: 600; }
.view section { margin-top: 40px; }
.view section > h2 { margin-bottom: 12px; }
.page-head > * + * { margin-top: 12px; }
.lede { max-width: 62ch; font-size: 16px; color: var(--text-2); }
.body { max-width: 62ch; color: var(--text-2); }
.view p a, .links-list a, .next-links a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.view p a:hover, .links-list a:hover, .next-links a:hover { text-decoration-color: var(--accent); }

/* Start page */
.view[data-view="home"]:not(.has-thread) {
  display: flex; flex-direction: column; justify-content: center;
  min-height: calc(100vh - var(--topbar-height)); min-height: calc(100dvh - var(--topbar-height));
}
.hero { padding-bottom: 6vh; }
.eyebrow { font: 12px/1.5 var(--mono); color: var(--text-3); }
.hero h1 { margin-top: 12px; font-size: clamp(30px, 4.6vw, 44px); line-height: 1.1; letter-spacing: -0.03em; }
.hero .lede { margin-top: 16px; }
.composer {
  display: flex; align-items: center; gap: 8px; margin-top: 32px;
  padding: 8px 8px 8px 16px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--bg);
}
.composer:focus-within { border-color: var(--text-3); }
.composer input {
  flex: 1; min-width: 0; height: 36px; border: 0; background: transparent;
  color: var(--text); font: inherit;
}
.composer input::placeholder { color: var(--text-3); }
.composer input:focus { outline: none; }
.send {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 8px; background: var(--text); color: var(--bg); cursor: pointer;
}
.send:hover { opacity: 0.85; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--text-2); font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.footnote { margin-top: 12px; font-size: 12px; color: var(--text-3); }
.starters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 40px; }
.starter {
  display: grid; gap: 4px; height: 100%; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 12px; text-decoration: none;
}
.starter:hover { border-color: var(--border-strong); background: var(--bg-sidebar); }
.starter strong { font-size: 14px; font-weight: 600; }
.starter span { font-size: 13px; color: var(--text-3); line-height: 1.45; }

/* Conversation */
.thread { display: grid; gap: 16px; }
.message { max-width: 62ch; }
.message-user { justify-self: end; padding: 8px 16px; border-radius: 12px; background: var(--surface); }
.message-guide { color: var(--text); }
.message-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 14px; }
.has-thread .composer { margin-top: 32px; }

/* Projects */
.group-head { display: grid; gap: 4px; margin-bottom: 16px; }
.group-head p { font-size: 14px; color: var(--text-3); }
.count { margin-left: 4px; font: 12px/1 var(--mono); color: var(--text-3); font-weight: 400; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card {
  display: grid; gap: 8px; align-content: start; height: 100%; padding: 16px;
  border: 1px solid var(--border); border-radius: 12px; text-decoration: none;
}
.card:hover { border-color: var(--border-strong); background: var(--bg-sidebar); }
.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-top strong { font-size: 15px; font-weight: 600; }
.card-kind { font: 12px/1.5 var(--mono); color: var(--text-3); }
.card-summary { font-size: 14px; color: var(--text-2); line-height: 1.5; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { padding: 2px 8px; border-radius: 6px; background: var(--surface); font: 12px/1.5 var(--mono); color: var(--text-2); }

/* Project page */
.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.kind { font: 12px/1.5 var(--mono); color: var(--text-3); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 8px; }
.button {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 16px; border: 1px solid var(--border-strong); border-radius: 8px;
  background: transparent; color: var(--text); font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer;
}
.button:hover { background: var(--surface); }
.button-primary { border-color: var(--text); background: var(--text); color: var(--bg); }
.button-primary:hover { background: var(--text); opacity: 0.85; }
.project-body { display: grid; grid-template-columns: minmax(0, 1fr) 208px; gap: 48px; }
.bullets { display: grid; gap: 8px; padding-left: 20px; list-style: disc; color: var(--text-2); }
.bullets li::marker { color: var(--border-strong); }
.callout { padding: 16px 20px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; background: var(--accent-soft); }
.callout p { color: var(--text-2); }
.facts { margin-top: 40px; font-size: 14px; }
.facts h2 { margin: 20px 0 8px; font: 500 12px/1.5 var(--sans); color: var(--text-3); }
.facts h2:first-child { margin-top: 0; }
.facts p { color: var(--text-2); line-height: 1.5; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 56px; padding-top: 24px; border-top: 1px solid var(--border); }
.pager a { display: flex; align-items: center; gap: 12px; text-decoration: none; font-size: 14px; font-weight: 500; }
.pager a:hover { color: var(--accent); }
.pager small { display: block; font-size: 12px; font-weight: 400; color: var(--text-3); }
.pager-next { justify-content: flex-end; text-align: right; }

/* How I work */
.steps { counter-reset: step; display: grid; gap: 16px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 0 12px; }
.steps li::before { content: counter(step, decimal-leading-zero); grid-row: span 2; font: 12px/1.9 var(--mono); color: var(--accent); }
.steps strong { font-weight: 600; }
.steps p { max-width: 62ch; color: var(--text-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 16px; text-align: left; vertical-align: top; }
thead th { font: 500 12px/1.5 var(--sans); color: var(--text-3); background: var(--bg-sidebar); }
tbody tr { border-top: 1px solid var(--border); }
tbody th { font-weight: 600; white-space: nowrap; }
tbody td { color: var(--text-2); }
.links-list { display: grid; gap: 8px; }
.links-list li { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 4px 16px; }
.links-list span { color: var(--text-2); }

/* About */
.toolbox { display: grid; border: 1px solid var(--border); border-radius: 12px; }
.toolbox > div { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 4px 16px; padding: 12px 16px; }
.toolbox > div + div { border-top: 1px solid var(--border); }
.toolbox dt { font-weight: 600; }
.toolbox dd { color: var(--text-2); }
.next-links { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 40px; }

/* Contact */
.contact-main {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 32px;
  padding: 16px 20px; border: 1px solid var(--border-strong); border-radius: 12px;
}
.contact-main > span { display: grid; min-width: 0; }
.contact-main strong { font: 500 12px/1.5 var(--sans); color: var(--text-3); }
.contact-main a { font-size: 16px; font-weight: 500; text-decoration: none; overflow-wrap: anywhere; }
.contact-main a:hover { text-decoration: underline; }
.contact-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.contact-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: 12px; text-decoration: none; color: var(--text-2);
}
.contact-row:hover { border-color: var(--border-strong); background: var(--bg-sidebar); color: var(--text); }
.contact-row span { display: grid; line-height: 1.4; }
.contact-row strong { color: var(--text); font-weight: 600; }
.contact-row small { font: 12px/1.5 var(--mono); color: var(--text-3); }

.noscript { margin: 0; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--bg-sidebar); font-size: 14px; }

/* Narrow screens: the sidebar becomes a drawer. */
@media (max-width: 880px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(300px, 86vw);
    transform: translateX(-100%); visibility: hidden;
    transition: transform 0.18s ease, visibility 0s linear 0.18s;
  }
  .drawer-open .sidebar { transform: none; visibility: visible; transition: transform 0.18s ease; }
  .backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / 0.4); }
  .menu-toggle { display: inline-grid; margin-left: -8px; }
  .topbar { padding: 0 16px; }
  .view { padding: 32px 20px 64px; }
  .project-body { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (max-width: 640px) {
  .starters, .contact-list { grid-template-columns: minmax(0, 1fr); }
  .links-list li, .toolbox > div { grid-template-columns: minmax(0, 1fr); }
  .contact-main { align-items: flex-start; flex-direction: column; }
  .view h1 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
