/* Brain — neural archive. Readable first: sans body, upright serif display. Tokens: docs/DESIGN.md */
:root {
  --bg: #eef3f8;
  --surface: #f8fbfd;
  --surface-2: #e1e9f1;
  --line: #c3d0dd;
  --text: #08111c;
  --muted: #2f4256;
  --faint: #5c6f83;
  --accent: #0057a8;
  --accent-soft: rgba(0, 87, 168, 0.1);
  --mark: rgba(0, 140, 230, 0.2);
  --on-accent: #f8fbfd;
  --danger: #b3261e;
  --shadow: 0 1px 0 rgba(8, 17, 28, 0.06);
  --scrim: rgba(8, 17, 28, 0.36);
  --shadow-pop: 0 16px 48px rgba(8, 17, 28, 0.16);
  --field-node: rgba(8, 30, 56, 0.6);
  --field-line: rgba(0, 87, 168, 0.32);
  --grain-opacity: 0.035;
  --signal: #0a74c9;
  --signal-glow: rgba(10, 116, 201, 0.22);
  --tick: rgba(0, 87, 168, 0.45);
  --hud-grid: rgba(0, 87, 168, 0.06);
  --mask-solid: #000;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.55 0 0 0 0 0.7 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --radius: 10px; --radius-sm: 6px; --radius-lg: 16px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --tap: 44px;
  --gutter: 16px;
  --k-session: #3f8cff; --k-decision: #8b7bff; --k-lesson: #f0567a; --k-preference: #2fc79a;
  --k-browse: #7f9cc0; --k-digest: #c07dff; --k-note: #7d8a99; --k-todo: #f2a93b;
  --k-skill: #22b8b8; --k-agent: #3fb6ff; --k-prompt: #a99cff; --k-highlight: #d9c65a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #05070a; --surface: #0a0f16; --surface-2: #0f1620; --line: #1b2836;
    --text: #e6eef7; --muted: #a8b9cb; --faint: #6d8196; --accent: #3fd0ff; --on-accent: #05070a;
    --accent-soft: rgba(63, 208, 255, 0.1); --mark: rgba(63, 208, 255, 0.22); --danger: #ff6b6b;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.5); --scrim: rgba(0, 0, 0, 0.62); --shadow-pop: 0 16px 48px rgba(0, 0, 0, 0.6);
    --field-node: rgba(206, 236, 255, 0.62); --field-line: rgba(60, 150, 220, 0.3); --grain-opacity: 0.025; --signal: #3fd0ff;
    --signal-glow: rgba(63, 208, 255, 0.28); --tick: rgba(63, 208, 255, 0.5); --hud-grid: rgba(63, 208, 255, 0.035);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #05070a; --surface: #0a0f16; --surface-2: #0f1620; --line: #1b2836;
  --text: #e6eef7; --muted: #a8b9cb; --faint: #6d8196; --accent: #3fd0ff; --on-accent: #05070a;
  --accent-soft: rgba(63, 208, 255, 0.1); --mark: rgba(63, 208, 255, 0.22); --danger: #ff6b6b;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.5); --scrim: rgba(0, 0, 0, 0.62); --shadow-pop: 0 16px 48px rgba(0, 0, 0, 0.6);
  --field-node: rgba(206, 236, 255, 0.62); --field-line: rgba(60, 150, 220, 0.3); --grain-opacity: 0.025; --signal: #3fd0ff;
  --signal-glow: rgba(63, 208, 255, 0.28); --tick: rgba(63, 208, 255, 0.5); --hud-grid: rgba(63, 208, 255, 0.035);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--sans); font-feature-settings: 'cv11', 'ss01'; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; }
body { -webkit-tap-highlight-color: transparent; }
body::after { content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; background-image: var(--grain); opacity: var(--grain-opacity); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--accent); color: var(--on-accent); }
#app { position: relative; z-index: 1; }

/* neural field */
#field { position: fixed; inset: 0; z-index: 0; pointer-events: none; display: none; }
.has-field #field { display: block; }
.field-tip { position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none; max-width: 220px; font: 500 13px/1.35 var(--sans); background: var(--text); color: var(--bg); padding: 6px 8px; border-radius: var(--radius-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-hot, .field-hot body { cursor: pointer; }

/* shell: sidebar on desktop, tab bar on phone (see the max-width block at the end) */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.side { position: sticky; top: 0; height: 100vh; height: 100dvh; padding: 20px 12px 16px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); }
.brand { font: 400 28px/1 var(--serif); padding: 4px 10px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 0 10px; min-height: 40px; border-radius: var(--radius-sm); color: var(--muted); font: 500 15px/1 var(--sans); transition: background 0.15s, color 0.15s; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover, .nav a.on { background: var(--surface-2); color: var(--text); }
.nav a.on svg { color: var(--accent); }
.side-foot { margin-top: auto; font: 500 13px/1.5 var(--sans); color: var(--faint); padding: 0 10px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.side-foot a, .side-link { color: var(--muted); }
.side-link { border: 0; background: none; padding: 0; font: inherit; }
.side-foot a:hover, .side-link:hover { color: var(--text); }

main { min-width: 0; width: 100%; max-width: 800px; margin: 0 auto; padding: 28px clamp(20px, 4vw, 48px) 96px; }
.top { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.searchbox, .bigsearch { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; transition: border-color 0.15s, box-shadow 0.15s; }
.searchbox { flex: 1; min-height: var(--tap); }
.searchbox svg, .bigsearch svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.searchbox input, .bigsearch input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 16px; padding: 0; }
.searchbox input { min-height: 42px; }
.searchbox input:focus-visible, .bigsearch input:focus-visible, .composer input:focus-visible { outline: 0; }
.searchbox:focus-within, .bigsearch:focus-within, .composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbox input::placeholder, .bigsearch input::placeholder, .composer input::placeholder, .field::placeholder, textarea.big::placeholder { color: var(--faint); }
.bigsearch input::-webkit-search-cancel-button { display: none; }
kbd { font: 11px var(--mono); color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; flex: none; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 0 16px; font: 500 15px/1 var(--sans); white-space: nowrap; min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background 0.15s, border-color 0.15s, color 0.15s; }
.btn:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 28%, var(--line)); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--text)); border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: var(--radius-sm); }
.btn.lg { min-height: 52px; padding: 0 24px; font-size: 16px; border-radius: 999px; }
.btn.icon { width: var(--tap); padding: 0; flex: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger); border-color: var(--danger); color: var(--bg); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:active, .chips button:active, a.mem:active, .proj:active, .skill:active { transform: scale(0.985); }
@media (pointer: coarse) { .btn.sm { min-height: var(--tap); } }

h1 { font: 400 clamp(32px, 4.2vw, 44px)/1.1 var(--serif); margin: 0 0 8px; letter-spacing: -0.01em; overflow-wrap: anywhere; }
h1 em, .display em, .display-sm em { color: var(--accent); font-style: italic; }
h1.h-sm { font-size: clamp(26px, 3.4vw, 34px); line-height: 1.15; }
h2 { font: 600 15px/1.3 var(--sans); color: var(--text); margin: 36px 0 12px; display: flex; align-items: baseline; gap: 8px; }
h2 .count { color: var(--faint); font-weight: 500; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); margin: 0 0 24px; max-width: 64ch; }
.sub code, .hint code, .set-row code { font: 13px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.hint { color: var(--muted); font-size: 14px; margin: 12px 0 0; }

/* home */
.home-head { margin-bottom: 20px; }
.home-head .sub { margin: 0; }
.bigsearch { min-height: 52px; padding: 0 14px; margin-bottom: 12px; }
.bigsearch input { min-height: 50px; font-size: 17px; }
.badge { font: 500 12px/1 var(--sans); color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 5px 9px; flex: none; }
#results:empty { display: none; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tile { padding: 16px 18px; min-width: 0; }
.tile + .tile { border-left: 1px solid var(--line); }
.tile b { display: block; font: 400 34px/1 var(--serif); font-variant-numeric: tabular-nums; margin-bottom: 6px; }
.tile span { display: block; font: 500 13px/1.3 var(--sans); color: var(--muted); }
.heat-card { display: flex; align-items: center; justify-content: space-between; gap: 20px 32px; flex-wrap: wrap; }
.heat-wrap { overflow-x: auto; padding: 2px 0; max-width: 100%; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); gap: 3px; width: max-content; }
.heat i { width: 11px; height: 11px; border-radius: 3px; background: var(--surface-2); }
.heat i[data-l="1"] { background: color-mix(in srgb, var(--accent) 28%, var(--surface-2)); }
.heat i[data-l="2"] { background: color-mix(in srgb, var(--accent) 52%, var(--surface-2)); }
.heat i[data-l="3"] { background: color-mix(in srgb, var(--accent) 76%, var(--surface-2)); }
.heat i[data-l="4"] { background: var(--accent); }
.src { list-style: none; margin: 0; padding: 0; flex: 1 1 180px; max-width: 280px; font-size: 14px; }
.src li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; color: var(--muted); }
.src li + li { border-top: 1px solid var(--line); }
.src b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }

/* memory cards */
.stream { display: flex; flex-direction: column; gap: 8px; }
.mem { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; transition: background 0.15s, border-color 0.15s, transform 0.15s; }
a.mem:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 18%, var(--line)); }
.mem-top { display: flex; align-items: center; min-width: 0; font: 500 13px/1.3 var(--sans); color: var(--muted); margin-bottom: 8px; white-space: nowrap; }
.mem-top > * { flex: none; }
.mem-top > .clip { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.mem-top > * + *::before { content: '·'; margin: 0 7px; color: var(--faint); }
.mem-top > .pin { margin-left: auto; padding-left: 10px; }
.mem-top > .pin::before { content: none; }
.mem-title { font: 600 16px/1.4 var(--sans); margin-bottom: 4px; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mem-body { color: var(--muted); font-size: 14.5px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.mem-body p { margin: 0; display: inline; }
.mem-title mark, .mem-body mark, .md mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 2px; }
.mem-url { font: 12px var(--mono); color: var(--faint); margin-top: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kind { --c: var(--k-note); display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.kind i { font-style: normal; color: var(--c); font-size: 11px; line-height: 1; }
.chip { color: var(--text); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.pin { color: var(--accent); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--gutter) * -1) 20px; padding: 4px var(--gutter); }
.chips::-webkit-scrollbar { display: none; }
.chips button { position: relative; flex: none; min-height: 36px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: transparent; padding: 0 14px; color: var(--muted); font: 500 14px var(--sans); transition: background 0.15s, color 0.15s, border-color 0.15s; }
.chips button::after { content: ''; position: absolute; inset: -4px 0; }
.chips button:hover { color: var(--text); border-color: color-mix(in srgb, var(--text) 28%, var(--line)); }
.chips button.on { background: var(--text); border-color: var(--text); color: var(--bg); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
.proj { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; transition: background 0.15s, border-color 0.15s, transform 0.15s; }
.proj:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 18%, var(--line)); }
.proj h3 { margin: 0 0 6px; font: 600 17px/1.3 var(--sans); overflow-wrap: anywhere; }
.proj p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.proj .when { color: var(--faint); margin-top: 8px; }

.md { line-height: 1.65; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3 { font-family: var(--sans); font-weight: 600; letter-spacing: 0; color: var(--text); margin: 1.4em 0 0.4em; display: block; line-height: 1.3; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; }
.md p { margin: 0.5em 0; }
.md ul, .md ol { padding-left: 1.3em; margin: 0.4em 0; }
.md li { margin: 0.15em 0; }
.md code { font: 13px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 2px solid var(--accent); margin: 0.6em 0; padding-left: 12px; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }

/* detail, forms */
.back { margin: 0 0 20px; font-size: 14px; }
.back a { color: var(--muted); display: inline-flex; align-items: center; min-height: 32px; }
.back a:hover { color: var(--text); }
.detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; margin-bottom: 10px; font: 500 13px/1.6 var(--sans); color: var(--muted); }
.link { color: var(--accent); overflow-wrap: anywhere; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0; }
.actions .push { margin-left: auto; }
textarea.big, input.field, select.field { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; outline: none; min-height: 48px; font-size: 16px; transition: border-color 0.15s, box-shadow 0.15s; }
textarea.big { min-height: 200px; resize: vertical; line-height: 1.55; display: block; }
select.field { appearance: none; -webkit-appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
textarea.big:focus, input.field:focus, select.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.row > * { flex: 1; min-width: 140px; }
.row > .btn { flex: none; }
.row > select.field { flex: 0 1 150px; min-width: 120px; }
.capture-bar { display: flex; gap: 8px; align-items: center; margin-top: 16px; }
.capture-bar .btn.primary { flex: 1; min-height: 48px; }
.mic { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: grid; place-items: center; flex: none; }
.mic svg { width: 20px; height: 20px; }
.mic.live { animation: pulse 1.2s infinite; background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 50%, transparent); } 100% { box-shadow: 0 0 0 16px color-mix(in srgb, var(--danger) 0%, transparent); } }

/* ask */
.ask { display: flex; flex-direction: column; min-height: calc(100vh - 200px); min-height: calc(100dvh - 200px); }
.chat { display: flex; flex-direction: column; gap: 20px; margin: 8px 0 24px; }
.bubble.q { align-self: flex-end; max-width: 85%; background: var(--surface-2); border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg); padding: 10px 14px; overflow-wrap: anywhere; }
.bubble.a h2 { margin-top: 20px; }
.bubble.a.skel { padding: 0; max-width: 420px; }
.suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 24px; }
.suggest .btn { white-space: normal; text-align: left; justify-content: flex-start; padding: 10px 16px; line-height: 1.35; }
.composer { position: sticky; bottom: 20px; margin-top: auto; display: flex; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 6px; box-shadow: var(--shadow-pop); transition: border-color 0.15s, box-shadow 0.15s; }
.composer input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 0 10px; min-height: var(--tap); font-size: 16px; }
.cite { color: var(--accent); font: 500 12px var(--mono); }

.daybar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.daybar h1 { flex: 1; margin: 0; }
.empty { color: var(--muted); padding: 32px 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); font-size: 15px; }
.empty p { margin: 0; }
.empty a:not(.btn) { color: var(--accent); }
.empty code { font: 13px var(--mono); }
.fail .btn { margin-top: 14px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: calc(100vw - 32px); background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: var(--radius); font: 500 14px/1.3 var(--sans); z-index: 95; box-shadow: var(--shadow-pop); animation: rise 0.2s ease-out; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.err { color: var(--danger); font-size: 14px; margin: 12px 0 0; }
.small { font-size: 14px; margin: 16px 0 0; }
.small a, a.inline { color: var(--accent); }
.actions.center { justify-content: center; margin: 16px 0 0; }

/* settings */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; padding: 14px 0; }
.set-row:first-child { padding-top: 0; } .set-row:last-child { padding-bottom: 0; }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-row > div:first-child { flex: 1 1 220px; min-width: 0; }
.set-row b { display: block; font-weight: 600; font-size: 15px; }
.set-row p { margin: 2px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg button { border: 1px solid transparent; background: transparent; border-radius: 8px; min-height: 36px; padding: 0 14px; font: 500 14px var(--sans); color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); border-color: var(--line); color: var(--text); }
.code-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 6px; font: 500 14px/1.3 var(--sans); color: var(--muted); }
.code-h:first-child { margin-top: 0; }
.snippet pre { font: 13px/1.55 var(--mono); background: var(--surface-2); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; margin: 0; white-space: pre; }
.snippet > p { margin: 0 0 4px; color: var(--muted); font-size: 14.5px; }

/* skeletons shaped like the cards they stand in for */
.skel { pointer-events: none; }
.skel i { display: block; height: 10px; border-radius: 4px; background: var(--surface-2); margin: 8px 0; animation: shimmer 1.4s ease-in-out infinite; }
.skel i:first-child { width: 30%; height: 8px; margin-top: 2px; }
.skel i:nth-child(2) { width: 60%; height: 16px; }
.skel i:nth-child(3) { width: 90%; margin-bottom: 2px; }
.skel-h { height: 40px; width: 50%; border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: 24px; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { 50% { opacity: 0.5; } }

.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 96; text-align: center; font: 500 13px/1.4 var(--sans); padding: calc(8px + env(safe-area-inset-top)) var(--gutter) 8px; background: var(--text); color: var(--bg); }
.demo-banner { display: flex; align-items: center; gap: 12px; margin: 0 0 20px; padding: 4px 4px 4px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 14px; line-height: 1.4; }
.demo-banner span { flex: 1; min-width: 0; padding: 6px 0; }
.demo-banner a { color: var(--accent); white-space: nowrap; }
.demo-banner button { flex: none; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); border-radius: var(--radius-sm); font-size: 18px; line-height: 1; }
.demo-banner button:hover { background: var(--surface-2); color: var(--text); }

/* login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) var(--gutter) max(16px, env(safe-area-inset-bottom)); }
.login .card { width: min(420px, 100%); padding: 28px; }
.login .brand { padding: 0 0 28px; }
.login .btn.primary { width: 100%; min-height: 48px; margin-top: 12px; }
.login .sub { margin-bottom: 20px; }

/* landing: readable, scannable, the brain constellation is the hero */
.landing { max-width: 1200px; margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); font-size: 17px; }
.l-top { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 0; }
.l-top .brand { padding: 0; font-size: 30px; }
.l-nav { display: flex; gap: 4px; margin-left: auto; }
.l-nav a { color: var(--muted); font-size: 15px; padding: 10px 14px; min-height: var(--tap); display: inline-flex; align-items: center; border-radius: 999px; }
.l-nav a:hover { color: var(--text); background: var(--surface); }
.eyebrow { margin: 0 0 16px; font: 600 14px/1.4 var(--sans); color: var(--accent); }
.l-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: center; gap: 32px; padding: clamp(32px, 7vh, 88px) 0 clamp(40px, 6vw, 72px); }
.display { font: 400 clamp(44px, 5.6vw, 76px)/1.04 var(--serif); letter-spacing: -0.02em; margin: 0 0 24px; max-width: 12ch; }
.lede { font-size: clamp(18px, 1.6vw, 20px); line-height: 1.6; color: var(--muted); margin: 0 0 32px; max-width: 34em; }
.l-ctas { display: flex; flex-wrap: wrap; gap: 12px; }
.l-brain { position: relative; aspect-ratio: 1.15; width: 100%; }
.l-brain::before { content: ''; position: absolute; inset: 12%; border-radius: 50%; background: radial-gradient(closest-side, var(--accent-soft), transparent); pointer-events: none; transition: opacity 0.4s var(--ease); }
.l-brain::after { content: ''; position: absolute; inset: 4%; pointer-events: none; background: linear-gradient(var(--hud-grid) 1px, transparent 1px) 0 0 / 100% 32px, linear-gradient(90deg, var(--hud-grid) 1px, transparent 1px) 0 0 / 32px 100%; mask-image: radial-gradient(closest-side, var(--mask-solid) 55%, transparent); -webkit-mask-image: radial-gradient(closest-side, var(--mask-solid) 55%, transparent); }
.l-brain-hit { position: absolute; inset: 0; touch-action: pan-y; cursor: crosshair; }
.l-strip { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px 40px; padding: 28px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.l-strip p { margin: 0; color: var(--muted); font-size: 15px; }
.l-strip ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 12px 36px; }
.l-strip li { font: 400 24px/1.2 var(--serif); color: var(--text); }
.l-sec { padding: clamp(72px, 10vw, 128px) 0 0; scroll-margin-top: 24px; }
.l-h { font: 400 clamp(32px, 4vw, 48px)/1.12 var(--serif); letter-spacing: -0.015em; text-transform: none; color: var(--text); margin: 0 0 20px; display: block; max-width: 22ch; }
.l-h::after { content: none; }
.l-body { color: var(--muted); max-width: 60ch; margin: 0 0 32px; }
.l-steps { list-style: none; padding: 0; margin: 48px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px; }
.l-steps li { border-top: 1px solid var(--line); padding-top: 24px; }
.l-steps h3 { font: 600 19px/1.3 var(--sans); margin: 16px 0 8px; }
.l-steps p { margin: 0; color: var(--muted); }
.l-n { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--accent); color: var(--accent); font: 600 14px/1 var(--sans); }
.l-demo-sec { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 56px; align-items: start; }
.l-demo { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); }
.l-demo-box { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 4px 4px 12px; margin-bottom: 16px; }
.l-demo-box:focus-within { border-bottom-color: var(--accent); }
.l-demo-box svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.l-demo-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: 400 26px/1.2 var(--serif); min-height: var(--tap); }
.l-demo-box input::placeholder { color: var(--faint); }
.l-demo-out { display: flex; flex-direction: column; gap: 10px; min-height: 140px; }
.l-demo-out .mem { background: var(--bg); }
.l-demo .empty { font: 400 16px/1.6 var(--sans); }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 0; }
.copyrow { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 10px 18px; max-width: 720px; }
.copyrow code { flex: 1; min-width: 0; font: 16px var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.l-clients { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; margin: 32px 0 0; max-width: 960px; }
.l-clients > div { padding: 18px 0; border-top: 1px solid var(--line); }
.l-clients dt { font: 600 16px/1.4 var(--sans); margin-bottom: 4px; }
.l-clients dd { margin: 0; color: var(--muted); font-size: 16px; overflow-wrap: anywhere; }
.l-clients code { font: 14px/1.5 var(--mono); color: var(--text); }
.l-faq { max-width: 760px; margin-top: 32px; border-top: 1px solid var(--line); }
.l-faq details { border-bottom: 1px solid var(--line); }
.l-faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 64px; font: 600 18px/1.4 var(--sans); }
.l-faq summary::-webkit-details-marker { display: none; }
.l-faq summary::after { content: '+'; font: 400 24px/1 var(--sans); color: var(--muted); transition: transform 0.2s var(--ease); }
.l-faq details[open] summary::after { transform: rotate(45deg); }
.l-faq details p { margin: 0 0 24px; color: var(--muted); max-width: 64ch; }
.l-final { text-align: center; padding: clamp(96px, 12vw, 160px) 0 32px; display: flex; flex-direction: column; align-items: center; }
.display-sm { font: 400 clamp(36px, 5vw, 60px)/1.1 var(--serif); letter-spacing: -0.02em; margin: 0 0 16px; max-width: 18ch; }
.l-final .lede { margin-bottom: 32px; }
/* skills */
.skills-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.skills-bar .field { flex: 1 1 200px; max-width: 320px; margin: 0; }
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.skill { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-height: 148px; transition: background 0.15s, border-color 0.15s, transform 0.15s; }
a.skill:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--text) 18%, var(--line)); }
.skill h3 { margin: 0 0 4px; font: 600 16px/1.4 var(--sans); overflow-wrap: anywhere; }
.skill p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.skill-src { margin-top: auto; padding-top: 12px; font: 12px var(--mono); color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-add { margin-bottom: 24px; }
.skill-tabs { display: flex; overflow-x: auto; scrollbar-width: none; margin: -6px 0 16px; border-bottom: 1px solid var(--line); }
.skill-tabs button { flex: none; min-height: var(--tap); padding: 0 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font: 500 14px var(--sans); }
.skill-tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.drop { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; padding: 32px 16px; border: 1px dashed var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer; color: var(--muted); font-size: 14.5px; transition: border-color 0.15s, background 0.15s; }
.drop b { color: var(--text); font: 600 16px/1.4 var(--sans); }
.drop:hover, .drop.over, .drop:focus-within { border-color: var(--accent); background: var(--surface-2); }
.drop-list { list-style: none; margin: 12px 0 0; padding: 0; }
.drop-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.drop-list span { font: 12px var(--mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.skill-add .row { margin-top: 12px; }
@media (max-width: 520px) { .skill-add .row { flex-direction: column; align-items: stretch; } .skill-add .row > .btn { min-height: 48px; } }
.skill-from { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.skill-from a { color: var(--accent); }
.skill-use { margin: 24px 0 8px; }
.skill-use h2 { margin-top: 0; }
.skill-use p { margin: 0 0 12px; color: var(--muted); font-size: 14.5px; }
.skill-use .copyrow { border-radius: var(--radius); background: var(--bg); padding: 6px 6px 6px 14px; }
.skill-use .copyrow code { font-size: 13.5px; }

@media (max-width: 960px) {
  .l-hero, .l-demo-sec { grid-template-columns: 1fr; }
  .l-hero { gap: 8px; padding-top: 16px; }
  .l-brain { order: -1; max-width: 520px; margin: 0 auto; }
  .l-steps { grid-template-columns: 1fr; gap: 24px; margin-top: 32px; }
  .l-demo-sec { gap: 8px; }
  .l-clients { grid-template-columns: 1fr; }
  .l-nav { display: none; }
}
@media (max-width: 520px) {
  .landing { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .l-strip li { font-size: 20px; }
  .l-ctas .btn { flex: 1; }
  .copyrow { flex-wrap: wrap; } .copyrow code { flex-basis: 100%; }
}

/* intro: the field ignites */
.intro { position: fixed; inset: 0; z-index: 100; display: grid; place-content: center; justify-items: center; background: var(--bg); cursor: pointer; transition: opacity 0.35s var(--ease), filter 0.35s var(--ease); }
.intro.out { opacity: 0; filter: blur(6px); pointer-events: none; }
.intro-field { position: absolute; inset: 0; }
.intro-word { position: relative; font: italic 400 clamp(88px, 18vw, 200px)/1 var(--serif); letter-spacing: -0.05em; color: var(--text); opacity: 0; filter: blur(14px); animation: resolve 0.6s var(--ease) 0.75s forwards; text-shadow: 0 0 40px var(--bg); }
.intro-note { position: absolute; left: 0; right: 0; bottom: calc(24px + env(safe-area-inset-bottom)); text-align: center; margin: 0; font: 500 13px var(--sans); color: var(--muted); }
.intro.fade { transition: opacity 0.3s var(--ease); }
.intro.fade .intro-word { opacity: 1; filter: none; animation: none; }
/* landing intro: one canvas over a dissolving black stage; durations scale with --intro-k (debug speed only) */
.intro.hero { display: block; background: none; cursor: default; transition: opacity calc(0.3s * var(--intro-k, 1)) var(--ease); }
.intro.hero.land { pointer-events: none; }
.intro-bg { position: absolute; inset: 0; background: radial-gradient(60% 55% at 50% 46%, var(--accent-soft), transparent 70%), var(--bg); }
.intro-hud { position: absolute; inset: 0; pointer-events: none; opacity: 0; animation: hud-in calc(0.45s * var(--intro-k, 1)) var(--ease) calc(0.15s * var(--intro-k, 1)) forwards; transition: opacity calc(0.4s * var(--intro-k, 1)) var(--ease); }
.intro.land .intro-hud { opacity: 0; animation: none; }
.intro-hud i { position: absolute; width: 14px; height: 14px; border: 0 solid var(--tick); }
.intro-hud i:nth-child(1) { top: max(20px, env(safe-area-inset-top)); left: 20px; border-width: 1px 0 0 1px; }
.intro-hud i:nth-child(2) { top: max(20px, env(safe-area-inset-top)); right: 20px; border-width: 1px 1px 0 0; }
.intro-hud i:nth-child(3) { bottom: calc(20px + env(safe-area-inset-bottom)); left: 20px; border-width: 0 0 1px 1px; }
.intro-hud i:nth-child(4) { bottom: calc(20px + env(safe-area-inset-bottom)); right: 20px; border-width: 0 1px 1px 0; }
.intro-hud::before, .intro-hud::after { content: ''; position: absolute; top: 35%; bottom: 35%; width: 7px; background: repeating-linear-gradient(var(--tick) 0 1px, transparent 1px 12px); opacity: 0.6; }
.intro-hud::before { left: 22px; }
.intro-hud::after { right: 22px; }
.intro-hud p { position: absolute; margin: 0; font: 400 11px/1 var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; }
.intro-hud b { font-weight: 400; color: var(--muted); }
.hud-tl { top: max(26px, calc(env(safe-area-inset-top) + 6px)); left: 44px; }
.hud-tr { top: max(26px, calc(env(safe-area-inset-top) + 6px)); right: 44px; }
.hud-bl { bottom: calc(26px + env(safe-area-inset-bottom)); left: 44px; }
.intro-title { position: absolute; left: 0; right: 0; bottom: calc(7vh + env(safe-area-inset-bottom)); text-align: center; pointer-events: none; transition: opacity calc(0.35s * var(--intro-k, 1)) var(--ease), transform calc(0.5s * var(--intro-k, 1)) var(--ease), filter calc(0.35s * var(--intro-k, 1)) var(--ease); }
.intro-name { font: 400 clamp(52px, 6.5vw, 92px)/1 var(--serif); color: var(--text); text-shadow: 0 0 32px var(--bg), 0 0 56px var(--signal-glow); }
.intro-name span { display: inline-block; opacity: 0; filter: blur(10px); transform: translateY(0.12em); margin: 0 0.16em; transition: opacity calc(0.55s * var(--intro-k, 1)) var(--ease), filter calc(0.55s * var(--intro-k, 1)) var(--ease), transform calc(0.6s * var(--intro-k, 1)) var(--ease), margin calc(0.75s * var(--intro-k, 1)) var(--ease); transition-delay: calc(var(--i) * 55ms * var(--intro-k, 1)); }
.intro.name .intro-name span { opacity: 1; filter: blur(0); transform: none; margin: 0 -0.005em; }
.intro-tag { margin: 14px 0 0; font: 400 15px/1.4 var(--sans); color: var(--muted); opacity: 0; transition: opacity calc(0.5s * var(--intro-k, 1)) var(--ease) calc(0.35s * var(--intro-k, 1)); }
.intro.name .intro-tag { opacity: 1; }
.intro.land .intro-title { opacity: 0; filter: blur(6px); transform: translateY(-12px); }
.intro.hero .intro-note { font: 400 12px var(--sans); color: var(--faint); transition: opacity calc(0.3s * var(--intro-k, 1)) var(--ease); }
.intro.land .intro-note { opacity: 0; }
/* the page rises in under the dissolving overlay, top bar first, then the hero copy line by line */
.intro-run .landing > *:not(.l-hero), .intro-run .l-hero-copy > * { opacity: 0; transform: translateY(14px); }
.landing > *, .l-hero-copy > * { transition: opacity calc(0.7s * var(--intro-k, 1)) var(--ease), transform calc(0.8s * var(--intro-k, 1)) var(--ease); }
.l-hero-copy > :nth-child(1) { transition-delay: calc(0.08s * var(--intro-k, 1)); }
.l-hero-copy > :nth-child(2) { transition-delay: calc(0.14s * var(--intro-k, 1)); }
.l-hero-copy > :nth-child(3) { transition-delay: calc(0.2s * var(--intro-k, 1)); }
.l-hero-copy > :nth-child(4) { transition-delay: calc(0.26s * var(--intro-k, 1)); }
.landing > .l-strip { transition-delay: calc(0.3s * var(--intro-k, 1)); }
.intro-fly .l-brain::before, .intro-fly .l-brain::after { opacity: 0; }
#field { transition: opacity calc(0.8s * var(--intro-k, 1)) var(--ease); }
.intro-run #field { opacity: 0; }
.l-brain::after { transition: opacity 0.6s var(--ease); }
@keyframes hud-in { to { opacity: 1; } }
@keyframes resolve { to { opacity: 1; filter: blur(0); } }

@media (prefers-reduced-motion: reduce) {
  .intro.out { filter: none; }
  .landing > *, .l-hero-copy > * { transition: none; }
  .skel i, .skel-h { animation: none; }
  .btn:active, .chips button:active, .mem:active { transform: none; }
  .toast { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  .btn:active, .chips button:active, a.mem:active, .proj:active, .skill:active { transform: none; }
  dialog.sheet[open] { animation: none; }
}

/* phone shell: tab bar with Capture in the middle, everything else behind More */
.tabbar { display: none; }
dialog.sheet { border: 0; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 80dvh; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: var(--surface); color: var(--text); border-top: 1px solid var(--line); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-pop); }
dialog.sheet::backdrop { background: var(--scrim); }
dialog.sheet[open] { animation: sheet-up 0.24s var(--ease); }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
.sheet-grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 8px; }
.sheet a, .sheet button { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 0 14px; border: 0; background: none; border-radius: var(--radius); font: 500 16px/1 var(--sans); color: var(--text); text-align: left; }
.sheet a.on { background: var(--surface-2); }
.sheet a.on svg { color: var(--accent); }
.sheet svg { width: 20px; height: 20px; color: var(--muted); flex: none; }
.sheet hr { border: 0; border-top: 1px solid var(--line); margin: 6px 14px; }
.sheet .quiet { color: var(--muted); }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side, .top { display: none; }
  main { padding: max(20px, calc(env(safe-area-inset-top) + 12px)) max(var(--gutter), env(safe-area-inset-right)) calc(88px + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left)); }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile:nth-child(3) { border-left: 0; }
  .tile:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .src { max-width: none; flex-basis: 100%; }
  .tabbar { display: flex; position: fixed; inset: auto 0 0 0; z-index: 20; background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(20px) saturate(1.4); -webkit-backdrop-filter: blur(20px) saturate(1.4); border-top: 1px solid var(--line); padding: 4px max(4px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left)); }
  .tabbar a, .tabbar button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border: 0; background: none; padding: 0; font: 500 11px/1 var(--sans); color: var(--muted); }
  .tabbar .on { color: var(--text); }
  .tabbar .on svg { color: var(--accent); }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .tab-cap i { display: grid; place-items: center; width: 48px; height: 36px; border-radius: 12px; background: var(--accent); color: var(--on-accent); transition: transform 0.15s; }
  .tabbar .tab-cap:active i { transform: scale(0.94); }
  .tabbar .tab-cap svg, .tabbar .tab-cap.on svg { color: inherit; }
  .bigsearch kbd { display: none; }
  .composer { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .ask { min-height: calc(100dvh - 130px - env(safe-area-inset-bottom) - env(safe-area-inset-top)); }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .actions .push { margin-left: 0; }
  .login .card { padding: 24px 20px; }
}
.l-sec > *, .l-final > * { min-width: 0; }
.l-h, .display, .display-sm { overflow-wrap: anywhere; }
html, body { overflow-x: clip; }
.l-final .display-sm, .l-sec .l-h { display: block; }
.l-final .display-sm::after { content: none; }

/* Public demo */
.l-demo-note { margin-top: 12px; font-size: 14px; color: var(--muted); }
.l-demo-note code { font-family: var(--mono); color: var(--accent); }
