/* t4as portfolio v2 — one theme for every page.
   Tokens first; components below only reference tokens. */

@font-face { font-family: "Inter"; src: url("../fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --font-display: var(--font-sans);

  --radius: 10px;
  --radius-lg: 16px;
  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 32px);
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* dark (default) */
  --bg: #0b0d10;
  --surface: #12161b;
  --surface-2: #181d24;
  --surface-sunken: #07090b;
  --border: #252b34;
  --border-soft: #1a1f26;
  --text: #e8ecf1;
  --text-muted: #9ba5b2;
  --text-faint: #69727e;
  --accent: #3ddc97;
  --accent-ink: #03140c;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --c-green: #3ddc97;
  --c-cyan: #56c2f2;
  --c-magenta: #d690f5;
  --c-amber: #f2b64a;
  --c-red: #ff6f6f;
  --code-bg: #07090b;
  --code-text: #d6dde6;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 30px -12px rgba(0,0,0,.6);
  --grid-line: rgba(255,255,255,.035);
  color-scheme: dark;
}

/* Light theme: follows OS unless the toggle picked one. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f6f3; --surface: #ffffff; --surface-2: #f0f1ed; --surface-sunken: #eceee9;
    --border: #dadcd5; --border-soft: #e7e9e3;
    --text: #15181c; --text-muted: #50585f; --text-faint: #7b838b;
    --accent: #0a855a; --accent-ink: #ffffff;
    --c-green: #0a855a; --c-cyan: #06699f; --c-magenta: #8f2fb5; --c-amber: #9a5a06; --c-red: #c42b2b;
    --shadow: 0 1px 2px rgba(20,24,28,.05), 0 12px 30px -16px rgba(20,24,28,.18);
    --grid-line: rgba(20,24,28,.05);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f6f3; --surface: #ffffff; --surface-2: #f0f1ed; --surface-sunken: #eceee9;
  --border: #dadcd5; --border-soft: #e7e9e3;
  --text: #15181c; --text-muted: #50585f; --text-faint: #7b838b;
  --accent: #0a855a; --accent-ink: #ffffff;
  --c-green: #0a855a; --c-cyan: #06699f; --c-magenta: #8f2fb5; --c-amber: #9a5a06; --c-red: #c42b2b;
  --shadow: 0 1px 2px rgba(20,24,28,.05), 0 12px 30px -16px rgba(20,24,28,.18);
  --grid-line: rgba(20,24,28,.05);
  color-scheme: light;
}

/* Code panes stay dark in both themes: re-scope tokens inside them. */
pre[class*="language-"], .r-code, .r-tree, .radar-code, .code-dark {
  --text: #e8ecf1; --text-muted: #9ba5b2; --text-faint: #69727e;
  --c-green: #3ddc97; --c-cyan: #56c2f2; --c-magenta: #d690f5; --c-amber: #f2b64a; --c-red: #ff6f6f;
  --border: #252b34; --surface-sunken: #07090b;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 16px/1.65 var(--font-sans); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, video, svg { max-width: 100%; height: auto; }
img, video { display: block; }
picture { display: contents; }
/* <source> must not become a grid/flex item once <picture> is display:contents (it left empty cells in galleries) */
source { display: none; }
a { color: inherit; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -.015em; margin: 0; }
p { margin: 0; }
.muted { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 6px; }
.skip-link:focus { left: 8px; }
.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 600 17px/1 var(--font-mono); text-decoration: none; letter-spacing: -.02em; }
.brand-mark { width: 14px; height: 14px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.brand-cursor { color: var(--accent); animation: blink 1.1s steps(1) infinite; margin-left: 1px; }
@keyframes blink { 50% { opacity: 0; } }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a { padding: 8px 12px; border-radius: 8px; font-size: 14.5px; color: var(--text-muted); text-decoration: none; transition: color .15s, background .15s; }
.nav a:hover, .nav a[aria-current] { color: var(--text); background: var(--surface-2); }
.theme-toggle {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme]) .theme-toggle .i-moon { display: block; }
}
@media (max-width: 640px) {
  .topbar-inner { gap: 8px; }
  .nav a { padding: 8px 8px; font-size: 14px; }
  .nav .nav-gh { display: none; }
}

/* ---------- shared bits ---------- */
.eyebrow { font: 500 12.5px/1.4 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.eyebrow-live { display: inline-flex; align-items: center; gap: 10px; color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse 2.4s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); } 70%, 100% { box-shadow: 0 0 0 10px transparent; } }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 18px; border-radius: 9px;
  font: 500 15px/1 var(--font-sans); text-decoration: none; border: 1px solid transparent;
  transition: transform .15s var(--ease), background .15s, border-color .15s, color .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn-ghost { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn-ghost:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.chips li { font: 500 12.5px/1 var(--font-mono); padding: 6px 9px; border-radius: 6px; background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border-soft); }
.chips-sm li { font-size: 11.5px; padding: 4px 7px; }
.section { padding-block: clamp(56px, 8vw, 96px); }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px 32px; margin-bottom: 28px; }
.section-label { font: 600 13px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 10px; }
.section-label::before { content: ""; width: 18px; height: 1px; background: currentColor; }
.link-arrow { color: var(--accent); font-weight: 500; font-size: 15px; }
.link-arrow span { display: inline-block; transition: transform .2s var(--ease); }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: clamp(32px, 5vw, 64px); align-items: center; padding-block: clamp(48px, 8vw, 104px) clamp(32px, 5vw, 56px); }
.hero-copy { display: grid; gap: 22px; }
.hero-title { font-size: clamp(2.3rem, 5.2vw, 3.9rem); font-weight: 700; letter-spacing: -.035em; line-height: 1.04; text-wrap: balance; }
.hero-lead { font-size: clamp(1.05rem, 1.6vw, 1.2rem); color: var(--text-muted); max-width: 56ch; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }

.scope { margin: 0; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.scope-bar, .scope-foot { display: flex; align-items: center; gap: 12px; padding: 10px 14px; font: 500 11.5px/1 var(--font-mono); color: var(--text-faint); letter-spacing: .03em; }
.scope-bar { border-bottom: 1px solid var(--border-soft); }
.scope-foot { border-top: 1px solid var(--border-soft); justify-content: space-between; }
.scope-foot b { color: var(--accent); font-weight: 600; }
.scope-led { width: 7px; height: 7px; border-radius: 50%; background: var(--c-red); box-shadow: 0 0 8px var(--c-red); animation: blink 1.6s steps(1) infinite; }
.scope-trig { margin-left: auto; color: var(--c-amber); }
.scope-svg { display: block; width: 100%; padding: 14px 8px 6px; background: var(--surface-sunken); }
.scope-grid { stroke: var(--grid-line); stroke-width: 1; }
.scope-label { font: 600 11px var(--font-mono); fill: var(--text-faint); text-anchor: end; }
.trace { fill: none; stroke-width: 2; stroke-linejoin: round; }
@media (prefers-reduced-motion: no-preference) {
  .trace { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.4s var(--ease) forwards; animation-delay: calc(var(--i) * .18s + .2s); }
  .decode { opacity: 0; animation: fade .5s ease forwards; animation-delay: calc(2.2s + var(--i) * .35s); }
}
.tr-cs { stroke: var(--c-amber); } .tr-clk { stroke: var(--c-cyan); } .tr-mosi { stroke: var(--c-green); } .tr-rdy { stroke: var(--c-magenta); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.decode rect { fill: color-mix(in srgb, var(--c-green) 16%, transparent); stroke: color-mix(in srgb, var(--c-green) 55%, transparent); }
.decode text { font: 600 9.5px var(--font-mono); fill: var(--c-green); text-anchor: middle; }
@keyframes fade { to { opacity: 1; } }
.scope-cursor { stroke: color-mix(in srgb, var(--text) 35%, transparent); stroke-width: 1; stroke-dasharray: 3 3; animation: sweep 7s linear 2.8s infinite; opacity: 0; }
@keyframes sweep { 0% { transform: translateX(0); opacity: 1; } 95% { opacity: 1; } 100% { transform: translateX(640px); opacity: 0; } }

.facts { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; }
.fact { padding: 20px 22px; display: grid; gap: 4px; border-left: 1px solid var(--border-soft); }
.fact:first-child { border-left: 0; }
.fact b { font: 600 20px/1.2 var(--font-mono); letter-spacing: -.02em; }
.fact span { font-size: 14px; color: var(--text-muted); }
@media (max-width: 860px) { .facts { grid-template-columns: 1fr 1fr; } .fact:nth-child(3) { border-left: 0; } .fact:nth-child(n+3) { border-top: 1px solid var(--border-soft); } }

/* ---------- featured ---------- */
.featured { display: grid; gap: 20px; }
.feature {
  display: grid; grid-template-columns: 1.1fr 1fr; text-decoration: none; border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; background: var(--surface); box-shadow: var(--shadow);
  transition: border-color .2s, transform .25s var(--ease);
}
.feature:nth-child(even) { grid-template-columns: 1fr 1.1fr; }
.feature:nth-child(even) .feature-media { order: 2; }
.feature:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-2px); }
.feature:hover .link-arrow span { transform: translateX(4px); }
.feature-media { position: relative; min-height: 300px; background: var(--surface-sunken); overflow: hidden; }
.feature-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.feature:hover .feature-media img { transform: scale(1.03); }
.feature-body { padding: clamp(24px, 3.5vw, 40px); display: grid; gap: 14px; align-content: center; }
.feature-body h3 { font-size: clamp(1.4rem, 2.4vw, 1.85rem); letter-spacing: -.025em; }
.feature-body > p:not(.eyebrow) { color: var(--text-muted); }
@media (max-width: 820px) {
  .feature, .feature:nth-child(even) { grid-template-columns: 1fr; }
  .feature:nth-child(even) .feature-media { order: 0; }
  .feature-media { min-height: 0; aspect-ratio: 16 / 9; }
}

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px; margin: 0; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.stat { background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column-reverse; gap: 4px; }
.stat dt { font-size: 13px; color: var(--text-muted); line-height: 1.35; }
.stat dd { margin: 0; font: 600 22px/1.1 var(--font-mono); letter-spacing: -.02em; color: var(--text); }
.stats-sm .stat { padding: 10px 12px; }
.stats-sm .stat dd { font-size: 17px; }
.stats-sm .stat dt { font-size: 12px; }

/* ---------- project grid ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter {
  font: 500 13.5px/1 var(--font-sans); padding: 9px 13px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted); transition: all .15s;
}
.filter span { font-family: var(--font-mono); font-size: 12px; opacity: .7; margin-left: 4px; }
.filter:hover { color: var(--text); border-color: var(--text-faint); }
.filter[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.grid { display: grid; gap: 18px; }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.card-project {
  display: flex; flex-direction: column; text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); overflow: hidden; transition: border-color .2s, transform .25s var(--ease), opacity .25s;
}
.card-project:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); transform: translateY(-3px); }
.card-project[hidden] { display: none; }
.card-media { aspect-ratio: 16 / 10; background: var(--surface-sunken); overflow: hidden; border-bottom: 1px solid var(--border-soft); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.card-project:hover .card-media img { transform: scale(1.04); }
.card-placeholder {
  width: 100%; height: 100%; display: grid; place-items: center; font: 700 48px/1 var(--font-mono); color: var(--accent); letter-spacing: -.05em;
  background: radial-gradient(circle at 30% 30%, var(--accent-soft), transparent 60%), repeating-linear-gradient(0deg, var(--grid-line) 0 1px, transparent 1px 24px), repeating-linear-gradient(90deg, var(--grid-line) 0 1px, transparent 1px 24px);
}
.card-body { padding: 18px 20px 20px; display: grid; gap: 8px; align-content: start; flex: 1; }
.card-body h3 { font-size: 1.12rem; letter-spacing: -.015em; }
.card-summary { font-size: 14.5px; color: var(--text-muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-body .chips { margin-top: 6px; }
.empty { padding: 24px 0; }

/* ---------- about ---------- */
.about { display: grid; grid-template-columns: 1fr 1.1fr; gap: clamp(32px, 6vw, 72px); align-items: start; }
.about-copy { display: grid; gap: 18px; }
.about-copy .section-label { margin-bottom: 6px; }
.about-lead { font-size: 1.3rem; line-height: 1.5; letter-spacing: -.01em; }
.focus { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border-soft); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.focus-item { background: var(--surface); padding: 24px; display: grid; gap: 8px; align-content: start; }
.focus-n { font: 500 12px/1 var(--font-mono); color: var(--accent); }
.focus-item h3 { font-size: 1.05rem; }
.focus-item p { font-size: 14.5px; color: var(--text-muted); }
@media (max-width: 900px) { .about { grid-template-columns: 1fr; } }
@media (max-width: 520px) { .focus { grid-template-columns: 1fr; } }

.cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--border-soft); }
.cta h2 { font-size: 1.4rem; margin-bottom: 6px; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--border-soft); margin-top: 40px; padding-block: 36px 28px; font-size: 14.5px; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; }
.footer-brand { font: 600 16px/1 var(--font-mono); margin-bottom: 8px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: start; }
.footer-links a { color: var(--text-muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }
.footer-bottom { margin-top: 24px; font-size: 13px; font-family: var(--font-mono); }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; }
.footer-aside a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- project page ---------- */
.project-head { padding-block: clamp(32px, 5vw, 56px) 28px; display: grid; gap: 18px; }
.crumbs { display: flex; gap: 8px; font: 500 13px/1 var(--font-mono); color: var(--text-faint); }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.project-title { font-size: clamp(2rem, 4.6vw, 3.3rem); font-weight: 700; letter-spacing: -.035em; line-height: 1.06; max-width: 22ch; text-wrap: balance; }
.project-lead { font-size: clamp(1.05rem, 1.7vw, 1.22rem); color: var(--text-muted); max-width: 68ch; }
.project-head .stats { margin-top: 8px; }
.status { color: var(--c-amber); }
.status-complete, .status-shipped { color: var(--c-green); }
.project-cover { margin-block: 8px 0; }
.project-cover img { width: 100%; max-height: 620px; object-fit: cover; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface-sunken); }
.project-body { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 56px; padding-block: 40px; align-items: start; }
.project--wide .project-body { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1000px) { .project-body { grid-template-columns: minmax(0, 1fr); } .side { display: none; } }
.side { position: sticky; top: 84px; display: grid; gap: 16px; }
.side-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; }
.side-title { font: 600 11.5px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 12px; }
.toc { display: grid; gap: 2px; max-height: 50vh; overflow: auto; }
.toc a { display: block; font-size: 14px; color: var(--text-muted); text-decoration: none; padding: 5px 0 5px 12px; border-left: 2px solid var(--border-soft); line-height: 1.35; }
.toc a:hover { color: var(--text); }
.toc a.is-active { color: var(--accent); border-left-color: var(--accent); }
.glance { margin: 0; display: grid; gap: 10px; font-size: 14px; }
.glance dt { color: var(--text-faint); font: 500 12px/1.2 var(--font-mono); }
.glance dd { margin: 2px 0 0; }
.project-foot { display: grid; gap: 22px; padding-block: 24px 16px; border-top: 1px solid var(--border-soft); margin-top: 16px; }
.project-foot .section-label { margin-top: 24px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.pager a { display: grid; gap: 4px; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; font-weight: 600; background: var(--surface); transition: border-color .2s; }
.pager a:hover { border-color: var(--accent); }
.pager span { font-weight: 400; font-size: 13px; font-family: var(--font-mono); }
.pager-next { text-align: right; grid-column: 2; }

/* ---------- prose (article bodies) ---------- */
.prose { min-width: 0; font-size: 17px; line-height: 1.72; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-size: 1.65rem; letter-spacing: -.025em; margin-top: 2.4em; padding-top: .2em; }
.prose h3 { font-size: 1.2rem; margin-top: 2em; }
.prose h4 { font-size: 1rem; margin-top: 1.6em; }
.prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: .6em; }
.prose > :first-child { margin-top: 0; }
.prose a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .35em; }
.prose li::marker { color: var(--text-faint); }
.prose strong { font-weight: 600; }
.prose :not(pre) > code { font: 500 .86em var(--font-mono); background: var(--surface-2); border: 1px solid var(--border-soft); padding: .12em .38em; border-radius: 5px; }
.prose blockquote { margin-inline: 0; padding: 4px 0 4px 18px; border-left: 3px solid var(--accent); color: var(--text-muted); }
.prose hr { border: 0; border-top: 1px solid var(--border-soft); margin-block: 2.5em; }
.prose img { border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-sunken); cursor: zoom-in; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.prose th { font: 600 12px/1.3 var(--font-mono); text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.prose .header-anchor { color: inherit; text-decoration: none; }
.prose figure { margin: 1.6em 0; }
.prose figcaption, .prose .caption { font-size: 14px; color: var(--text-muted); margin-top: 8px; text-align: center; }
.prose p > img:only-child { margin-inline: auto; }

/* Markdown helpers (shortcodes) */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px; margin-block: 1.4em; }
.gallery-grid p { margin: 0; display: contents; }
.gallery-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 14px; margin-block: 1.4em; }
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 18px 20px; }
.card h4 { font-size: 1rem; margin: 0 0 6px; }
.card p, .card li { font-size: 15px; color: var(--text-muted); }
.card > * + * { margin-top: .5em; }
.card ul { padding-left: 1.1em; margin: 0; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 24px; align-items: start; }
.columns > * { margin: 0; }
.callout { border: 1px solid var(--border); border-left: 3px solid var(--c-cyan); border-radius: 0 var(--radius) var(--radius) 0; background: var(--surface); padding: 16px 20px; }
.callout > * + * { margin-top: .6em; }
.callout-title { font: 600 12.5px/1.2 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--c-cyan); }
.callout-solution { border-left-color: var(--c-green); } .callout-solution .callout-title { color: var(--c-green); }
.callout-warn { border-left-color: var(--c-amber); } .callout-warn .callout-title { color: var(--c-amber); }
.media video, .media .yt { width: 100%; border-radius: var(--radius); border: 1px solid var(--border); background: #000; }
.yt { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; }
.yt img { width: 100%; height: 100%; object-fit: cover; border: 0; border-radius: 0; opacity: .85; transition: opacity .2s; cursor: pointer; }
.yt:hover img { opacity: 1; }
.yt-play { position: absolute; inset: 0; margin: auto; width: 68px; height: 48px; border-radius: 12px; background: rgba(0,0,0,.72); }
.yt-play::after { content: ""; position: absolute; inset: 0; margin: auto; width: 0; height: 0; border-style: solid; border-width: 10px 0 10px 17px; border-color: transparent transparent transparent #fff; transform: translateX(2px); }
.yt:hover .yt-play { background: #e62117; }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 18px; }
.video-grid .media { margin: 0; }

/* Syntax highlighting (Prism tokens), always on a dark pane. */
pre[class*="language-"] {
  background: var(--code-bg); color: var(--code-text); border: 1px solid #1d232b; border-radius: var(--radius);
  padding: 18px 20px; overflow-x: auto; font: 400 13.5px/1.65 var(--font-mono); tab-size: 4;
}
code[class*="language-"] { font-family: var(--font-mono); }
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #6b7686; font-style: italic; }
.token.punctuation { color: #9aa4b1; }
.token.keyword, .token.boolean, .token.important, .token.atrule { color: #d690f5; }
.token.string, .token.char, .token.attr-value, .token.inserted { color: #3ddc97; }
.token.number, .token.constant, .token.symbol { color: #f2b64a; }
.token.function, .token.class-name { color: #56c2f2; }
.token.operator, .token.entity, .token.url { color: #c7d0db; }
.token.macro, .token.directive, .token.property, .token.tag { color: #ff9e7a; }

/* ---------- gallery page ---------- */
.gallery-head { padding-block: clamp(32px, 5vw, 56px) 24px; display: grid; gap: 14px; }
.masonry { columns: 4 260px; column-gap: 12px; padding-bottom: 40px; }
.masonry a { display: block; margin-bottom: 12px; break-inside: avoid; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border-soft); background: var(--surface-sunken); }
.masonry img { width: 100%; height: auto; transition: transform .5s var(--ease), opacity .3s; }
.masonry a:hover img { transform: scale(1.03); }

/* ---------- notes (sub-pages of a project) ---------- */
.note-head { padding-block: clamp(32px, 5vw, 48px) 8px; display: grid; gap: 14px; }
.note-body { max-width: 820px; padding-block: 24px 48px; }
.note-body .prose table { font-size: 14px; }

/* reveal on scroll (JS adds .in) */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s var(--ease), transform .6s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.section-tight { padding-top: 24px; }
.project-cover--contain img { object-fit: contain; max-height: 560px; background: var(--surface-sunken); }
.stats-sm { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Home: proof links, linked facts, how-I-work band */
.hero-proofs { list-style: none; padding: 0; margin: 4px 0 26px; display: grid; gap: 8px; }
.hero-proofs li { position: relative; padding-left: 20px; font-size: 15px; }
.hero-proofs li::before { content: "→"; position: absolute; left: 0; color: var(--accent); font-family: var(--font-mono); }
.hero-proofs a { color: var(--text); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 4px; }
.hero-proofs a:hover { text-decoration-color: var(--accent); }
a.fact { color: inherit; text-decoration: none; transition: background .2s; }
a.fact:hover { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
a.fact:hover b { color: var(--accent); }
.how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 860px) { .how { grid-template-columns: 1fr; } }
.how-item { display: block; padding: 20px 22px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: inherit; text-decoration: none; transition: border-color .2s; }
.how-item:hover { border-color: var(--accent); }
.how-item h3 { font-size: 1.02rem; margin: 0 0 8px; letter-spacing: -.01em; }
.how-item p { margin: 0; font-size: 14px; color: var(--text-muted); line-height: 1.55; }

/* Home hero: BLE hop view (replaces the logic-analyser drawing) */
.hopview { padding: 12px 10px 8px; }
.hv-row { stroke: var(--grid-line); stroke-width: 1; }
.hv-adv-band { fill: color-mix(in srgb, var(--c-cyan) 9%, transparent); }
.hv-lbl { font: 600 9.5px var(--font-mono); fill: var(--text-faint); text-anchor: end; }
.hv-lbl-adv { fill: var(--c-cyan); }
.hv-advpk { fill: var(--c-cyan); }
.hv-conn { fill: var(--c-magenta); }
.hv-tag { font: 600 9px var(--font-mono); fill: var(--c-magenta); text-anchor: middle; }
.hv-path { fill: none; stroke: color-mix(in srgb, var(--c-green) 35%, transparent); stroke-width: 1; stroke-dasharray: 2 3; }
.hv-pred { fill: none; stroke: var(--c-amber); stroke-width: 1.2; }
.hv-pkt { fill: var(--c-green); }
.hv-cursor { stroke: color-mix(in srgb, var(--text) 30%, transparent); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.hopview.anim .pk { opacity: 0; transition: opacity .25s ease; }
.hopview.anim .pk.on { opacity: 1; }
.hopview.anim .hv-pred.on { animation: hv-ring .5s ease-out; }
@keyframes hv-ring { from { transform-box: fill-box; transform-origin: center; transform: scale(1.8); opacity: 0; } to { transform-box: fill-box; transform-origin: center; transform: scale(1); opacity: 1; } }
