/* ==========================================================================
   samsterjam.com: One Dark + Monocraft
   ========================================================================== */

@font-face {
  font-family: 'Monocraft';
  src: url('/fonts/Monocraft.ttf') format('truetype');
  font-display: swap;
}

:root {
  /* One Dark */
  --bg: #21252b;
  --bg-deep: #1b1f24;
  --surface: #282c34;
  --surface-2: #2c313a;
  --line: #3e4451;
  --line-soft: rgba(171, 178, 191, 0.09);
  --text: #abb2bf;
  --text-hi: #dcdfe4;
  --muted: #8b919d;
  --comment: #5c6370;

  --blue: #61afef;
  --purple: #c678dd;
  --green: #98c379;
  --red: #e06c75;
  --orange: #d19a66;
  --yellow: #e5c07b;
  --cyan: #56b6c2;

  --accent: var(--blue);
  --heat: linear-gradient(90deg, var(--purple), var(--red), var(--orange), var(--yellow));

  --font: 'Monocraft', ui-monospace, 'Cascadia Mono', 'DejaVu Sans Mono', monospace;
  --max: 1240px;
  --gutter: clamp(16px, 4vw, 32px);
  --r: 6px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --nav-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.7 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

::selection { background: var(--purple); color: var(--bg-deep); }

img, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; }
kbd {
  font: inherit; font-size: 0.85em; padding: 0 5px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px; color: var(--text-hi);
}
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; border-radius: 2px; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--yellow); color: var(--bg-deep); padding: 6px 10px; }
.skip:focus { left: 8px; }

/* ---------- Type ---------- */
.section-title, .page-title, .p-title, .h2, .h3 { color: var(--text-hi); font-weight: normal; line-height: 1.2; }
.section-title { font-size: clamp(22px, 3vw, 28px); margin-bottom: 8px; display: flex; align-items: baseline; gap: 14px; }
.page-title { font-size: clamp(30px, 5vw, 48px); margin-bottom: 12px; }
.h2 { font-size: 19px; margin-bottom: 12px; }
.h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: 10px; }

.kicker { color: var(--green); font-size: 13px; display: inline-flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.dot { width: 8px; height: 8px; background: var(--green); }

/* ---------- Buttons & pills ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border: 1px solid var(--line); border-radius: var(--r);
  color: var(--text-hi); background: var(--surface); font-size: 14px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease);
}
.btn:hover { text-decoration: none; border-color: var(--blue); transform: translateY(-1px); }
.btn-solid { background: var(--blue); border-color: var(--blue); color: var(--bg-deep); }
.btn-solid:hover { background: #7dbff3; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.linkish { color: var(--blue); }
.linkish:hover { text-decoration: underline; text-underline-offset: 3px; }

.pill { font-size: 11px; padding: 1px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; line-height: 1.7; }
.pill-wip { color: var(--yellow); }
.pill-failed { color: var(--red); }
.pill-badge { color: var(--yellow); align-self: flex-start; border-style: dashed; }
.pill-badge::before { content: '★ '; }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50; height: var(--nav-h);
  background: rgba(33, 37, 43, 0.82);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}
.nav-inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text-hi); font-size: 16px; }
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 15px; height: 15px; flex: none;
  background:
    linear-gradient(var(--blue) 0 0) 0 0 / 5px 5px no-repeat,
    linear-gradient(var(--purple) 0 0) 5px 0 / 5px 5px no-repeat,
    linear-gradient(var(--red) 0 0) 10px 0 / 5px 5px no-repeat,
    linear-gradient(var(--cyan) 0 0) 0 5px / 5px 5px no-repeat,
    linear-gradient(var(--orange) 0 0) 10px 5px / 5px 5px no-repeat,
    linear-gradient(var(--green) 0 0) 0 10px / 5px 5px no-repeat,
    linear-gradient(var(--yellow) 0 0) 5px 10px / 5px 5px no-repeat,
    linear-gradient(var(--blue) 0 0) 10px 10px / 5px 5px no-repeat;
  transition: transform 0.4s var(--ease);
}
.logo:hover .logo-mark { transform: rotate(90deg); }
.nav-links { display: flex; gap: clamp(14px, 3vw, 28px); font-size: 14px; }
.nav-links a { color: var(--text); position: relative; padding: 4px 0; }
.nav-links a:hover, .nav-links a[aria-current] { color: var(--text-hi); text-decoration: none; }
.nav-links a[aria-current]::after, .nav-links a:hover::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px; background: var(--heat);
}

/* ---------- Hero ---------- */
.hero { position: relative; padding: clamp(72px, 14vh, 150px) 0 clamp(56px, 10vh, 110px); overflow: hidden; }
.hero-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: -1px -1px;
  mask-image: radial-gradient(ellipse 80% 70% at 30% 45%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 30% 45%, #000 20%, transparent 75%);
}
.hero-inner { position: relative; z-index: 1; }
.hero-bg {
  position: absolute; inset: 0 0 0 30%; z-index: 0; pointer-events: none;
  mask-image: linear-gradient(90deg, transparent 0%, #000 60%), linear-gradient(0deg, transparent 0%, #000 22%);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 60%), linear-gradient(0deg, transparent 0%, #000 22%);
  mask-composite: intersect; -webkit-mask-composite: source-in;
}
.hero-slide {
  position: absolute; inset: 0; background: center / cover no-repeat;
  opacity: 0;
  transition: opacity 1.8s var(--ease);
}
.hero-slide.active { opacity: 0.6; }
@media (max-width: 899px) { .hero-bg { inset: 0; } .hero-slide.active { opacity: 0.25; } }
.hero-name {
  position: relative; display: inline-block;
  font-weight: normal; color: var(--text-hi);
  font-size: clamp(44px, 10.5vw, 128px); line-height: 1.05; letter-spacing: -0.01em;
  margin-bottom: 22px; cursor: default;
}
.hero-name canvas { position: absolute; left: 0; top: 0; pointer-events: none; }
.hero-name.rasterizing { color: transparent; }
.hero-name.rastered { transition: color 0.35s; }
@media (prefers-reduced-motion: no-preference) {
  /* hidden from first paint until raster.js draws it (raster.js adds .rastered on fallback) */
  .js .hero-name[data-raster]:not(.rastered) { color: transparent; }
}
.hero-lede { font-size: clamp(16px, 2vw, 20px); color: var(--text-hi); margin-bottom: 30px; max-width: 46ch; }
.hero-links { display: flex; flex-wrap: wrap; gap: 10px; }
.raster-hud {
  position: absolute; left: 0; top: 100%; font-size: 11px; line-height: 1.6; color: var(--comment);
  letter-spacing: 0;
  opacity: 0; transition: opacity 0.3s; white-space: nowrap;
}
.rasterizing .raster-hud, .raster-hud.show { opacity: 1; }

/* ---------- Sections ---------- */
.section { padding: clamp(56px, 9vw, 96px) 0; border-top: 1px solid var(--line-soft); }
.hero + .section { border-top: 0; padding-top: 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; margin-bottom: 26px; }

/* ---------- Project cards ---------- */
.card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  grid-auto-flow: dense;
}
.card {
  display: flex; flex-direction: column; color: inherit;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r);
  overflow: hidden; position: relative;
  transition: border-color 0.25s, transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.card:hover { text-decoration: none; border-color: var(--line); transform: translateY(-3px); box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35); }
.card-media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--bg-deep); }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.8s var(--ease); }
.card-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.3s; }
.card-media video.playing { opacity: 1; }
.card-media-empty {
  display: grid; place-items: center;
  background:
    linear-gradient(var(--line-soft) 1px, transparent 1px) 0 0 / 12px 12px,
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px) 0 0 / 12px 12px,
    var(--bg-deep);
}
.card-placeholder { font-size: 12px; color: var(--comment); }
.card-placeholder span::before { content: '// '; }
.card-static:hover { transform: none; box-shadow: none; }
.card-static:hover .card-title { color: var(--text-hi); }
.card:hover .card-media img { transform: scale(1.03); }
.card-scan {
  position: absolute; left: 0; right: 0; height: 30%; top: -30%; pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(229, 192, 123, 0.10) 85%, rgba(229, 192, 123, 0.5) 100%);
  mix-blend-mode: screen; opacity: 0;
}
.card:hover .card-scan { animation: scan 1.1s var(--ease) 1; }
@keyframes scan { 0% { top: -30%; opacity: 1; } 100% { top: 100%; opacity: 0.4; } }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title { font-weight: normal; color: var(--text-hi); font-size: 16px; line-height: 1.35; }
.card:hover .card-title { color: var(--blue); }
.card-short { color: var(--text); font-size: 13px; line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-lg .card-short { -webkit-line-clamp: 2; }
.card-meta { margin-top: auto; padding-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); }
.card-meta span + span::before { content: '·'; margin-right: 14px; color: var(--comment); }
.card-meta span + span { display: inline-flex; }

/* Featured card: 2 columns × 1 row. The image fills whatever height the row's
   neighbours give it, so it never adds vertical space of its own. */
@media (min-width: 760px) {
  .card-lg { grid-column: span 2; }
  .card-lg .card-media { aspect-ratio: auto; flex: 1 1 0; min-height: 200px; }
  .card-lg .card-media img { position: absolute; inset: 0; }
  .card-lg .card-body { flex: none; }
  .card-lg .card-title { font-size: 19px; }
}

/* ---------- About ---------- */
.about { display: grid; gap: 48px; grid-template-columns: 1fr; }
@media (min-width: 960px) { .about { grid-template-columns: 1.1fr 1fr; gap: 72px; } }
.about-head { display: flex; align-items: center; gap: 26px; margin-bottom: 22px; }
.about-head .section-title { margin: 0; }
.about-p { max-width: 62ch; margin-bottom: 16px; }
.about-p:first-of-type { color: var(--text-hi); }

/* logo framed like a selected object in an editor */
.avatar { position: relative; width: 96px; flex: none; margin: 4px 4px 18px; }
.avatar img { width: 100%; border-radius: 4px; image-rendering: auto; }
.avatar::before { content: ''; position: absolute; inset: -5px; border: 1px solid var(--blue); pointer-events: none; }
.avatar .handle { position: absolute; width: 7px; height: 7px; background: var(--bg); border: 1px solid var(--blue); }
.h-tl { left: -8px; top: -8px; } .h-tr { right: -8px; top: -8px; } .h-bl { left: -8px; bottom: -8px; } .h-br { right: -8px; bottom: -8px; }
.avatar figcaption { position: absolute; left: -5px; top: calc(100% + 8px); font-size: 10px; color: var(--blue); white-space: nowrap; }
.avatar img { transition: transform 0.5s var(--ease); }
.avatar:hover img { transform: rotate(-6deg) scale(1.04); }

.journey { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 0; margin-top: 26px; counter-reset: j; }
.journey li { display: inline-flex; align-items: baseline; gap: 8px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font-size: 13px; color: var(--text-hi); }
.journey li + li { margin-left: 30px; position: relative; }
.journey li + li::before { content: ''; position: absolute; left: -26px; top: 50%; width: 18px; height: 2px; background: repeating-linear-gradient(90deg, var(--comment) 0 3px, transparent 3px 5px); }
.journey li + li::after { content: ''; position: absolute; left: -10px; top: calc(50% - 4px); border: 4px solid transparent; border-left-color: var(--comment); }
.j-note { font-size: 11px; color: var(--muted); }
.journey li.now { border-color: var(--green); }
.journey li.now .j-note { color: var(--green); }

.about-side { display: flex; flex-direction: column; gap: 20px; }
.edu { background: var(--surface); border: 1px solid var(--line-soft); border-left: 3px solid var(--cyan); border-radius: var(--r); padding: 16px 18px; }
.edu-school { color: var(--text-hi); font-size: 16px; }
.edu-degree { font-size: 13px; }
.edu-when { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.gpa { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 4px 10px; }
.gpa-v { font-size: 28px; line-height: 1; color: var(--text-hi); }
.gpa-max { font-size: 12px; color: var(--muted); }
.gpa-bar { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(32, 1fr); gap: 2px; margin-top: 6px; }
.gpa-bar i { height: 10px; background: var(--line); }
.gpa-bar i.on { background: var(--cyan); }
@media (prefers-reduced-motion: no-preference) {
  .gpa-bar i.on { animation: gpa-in 0.4s var(--ease) both; animation-delay: calc(var(--i) * 18ms); animation-timeline: view(); animation-range: entry 10% cover 30%; }
}
@keyframes gpa-in { from { background: var(--line); } }

.chip-h { font-size: 11px; font-weight: normal; text-transform: uppercase; letter-spacing: 0.12em; color: var(--comment); margin-bottom: 8px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.cchip, .schip { font-size: 12px; padding: 3px 9px; border-radius: 4px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; gap: 7px; line-height: 1.5; }
.grade { font-weight: normal; font-size: 10px; padding: 0 5px; border-radius: 3px; color: var(--bg-deep); background: var(--blue); }
.grade.g-Ap { background: var(--green); }
.cchip.live { border-color: rgba(229, 192, 123, 0.5); color: var(--text-hi); }
.cchip.live::before { content: ''; width: 6px; height: 6px; background: var(--yellow); }
.schip { border-color: color-mix(in srgb, var(--k) 40%, transparent); color: var(--k); background: color-mix(in srgb, var(--k) 8%, var(--surface)); }
.c-blue { --k: var(--blue); } .c-purple { --k: var(--purple); } .c-green { --k: var(--green); } .c-orange { --k: var(--orange); } .c-cyan { --k: var(--cyan); }

/* ---------- Research & experience: bento ---------- */
/* CBIRD background is baked by scripts/bake-phasor.js */
.bento { display: grid; gap: 12px; margin-top: 22px; grid-template-columns: 1fr; grid-auto-flow: dense; }
@media (min-width: 640px) { .bento { grid-template-columns: repeat(2, 1fr); } .tile-xl, .tile-wide { grid-column: span 2; } }
@media (min-width: 1000px) { .bento { grid-template-columns: repeat(4, 1fr); } .tile-xl { grid-row: span 2; } }

.tile {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 14px;
  padding: 18px 18px 16px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line-soft);
  transition: border-color 0.25s, transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.tile::before { /* accent glow in the corner */
  content: ''; position: absolute; z-index: -1; right: -40%; top: -60%; width: 90%; aspect-ratio: 1;
  background: radial-gradient(circle, color-mix(in srgb, var(--c) 16%, transparent), transparent 65%);
  pointer-events: none;
}
.tile:hover { border-color: color-mix(in srgb, var(--c) 45%, transparent); transform: translateY(-2px); box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3); }
.tile-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--c); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.tile-kicker .pill { text-transform: none; letter-spacing: 0; }
.tile-big { font-size: clamp(24px, 2.6vw, 32px); line-height: 1.1; color: var(--text-hi); margin-top: 8px; }
.tile-label { font-size: 13px; color: var(--text); margin-top: 6px; line-height: 1.5; }
.tile-xl .tile-big { font-size: clamp(40px, 5vw, 64px); background: linear-gradient(90deg, var(--purple), var(--blue)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tile-xl .tile-label { font-size: 15px; color: var(--text-hi); max-width: 36ch; }

.tile-visual {
  position: absolute; z-index: -1; inset: 0; width: 100%; height: 100%; object-fit: cover;
  image-rendering: pixelated; opacity: 0.32;
  mask-image: linear-gradient(200deg, #000 10%, transparent 65%);
  -webkit-mask-image: linear-gradient(200deg, #000 10%, transparent 65%);
}

.t-items { display: grid; gap: 14px; padding-top: 14px; border-top: 1px dashed var(--line-soft); }
.tile-wide .t-items:has(> .t-item + .t-item) { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 22px; }
.t-item { display: grid; grid-template-columns: 7px 1fr; column-gap: 11px; align-items: start; }
.t-item-body { min-width: 0; font-size: 12px; line-height: 1.5; }
.t-item-title { color: var(--text-hi); }
.t-item-sub { color: var(--muted); }
.t-when { color: var(--c); font-size: 11px; margin-top: 2px; }
.led { width: 7px; height: 7px; border-radius: 1px; background: var(--line); margin-top: 5px; } /* centered on the first 18px line */
.led.on { background: var(--green); }

.t-more { grid-column: 2; margin-top: 6px; }
.t-more summary { font-size: 11px; color: var(--comment); cursor: pointer; list-style: none; width: fit-content; }
.t-more summary::-webkit-details-marker { display: none; }
.t-more summary::before { content: '+ '; }
.t-more[open] summary::before { content: '− '; }
.t-more summary:hover { color: var(--c); }
.t-points { display: grid; gap: 6px; font-size: 12px; line-height: 1.55; margin-top: 8px; }
.t-points li { padding-left: 14px; position: relative; }
.t-points li::before { content: '▸'; position: absolute; left: 0; color: var(--c); opacity: 0.7; }

/* research tile: points always open, as numbered full-width tiles */
.t-points-open { grid-column: 1 / -1; counter-reset: p; gap: 8px; margin-top: 14px; }
.t-points-open li { counter-increment: p; padding: 9px 12px 9px 44px; background: rgba(27, 31, 36, 0.75); border: 1px solid var(--line-soft); border-radius: 4px; }
.t-points-open li::before { content: '0x0' counter(p); left: 12px; top: 11px; font-size: 10px; opacity: 1; line-height: 1.55; }

/* ---------- Page head (gallery, 404) ---------- */
.page-head { padding-top: clamp(40px, 7vw, 72px); padding-bottom: 28px; }
.page-head > .muted { max-width: 68ch; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.chip { font-size: 12px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 99px; color: var(--text); }
.chip:hover { border-color: var(--blue); color: var(--text-hi); text-decoration: none; }
.g-section { padding: 26px 0 30px; border-top: 1px solid var(--line-soft); }
.g-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin-bottom: 14px; }
.g-head .h2 { margin: 0; }
.g-head .h2 a { color: var(--text-hi); }
.g-more { margin-left: auto; font-size: 13px; }
.notfound { min-height: 50vh; }
.notfound p { margin-bottom: 18px; }

/* ---------- Justified image grid ---------- */
.jgrid { --row: 200px; display: flex; flex-wrap: wrap; gap: 6px; }
.jgrid::after { content: ''; flex-grow: 1e4; }
.jitem {
  position: relative; display: block; overflow: hidden; border-radius: 3px; background: var(--bg-deep);
  flex-grow: calc(var(--ar) * 100); flex-basis: calc(var(--ar) * var(--row)); aspect-ratio: var(--ar);
  max-height: calc(var(--row) * 1.6);
}
.jitem img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease), filter 0.3s; }
.jitem:hover img { transform: scale(1.04); }
.jgrid:hover .jitem:not(:hover) img { filter: brightness(0.7) saturate(0.8); }
.jcap {
  position: absolute; left: 6px; bottom: 6px; font-size: 11px; color: var(--text-hi);
  background: rgba(27, 31, 36, 0.82); padding: 1px 7px; border-radius: 3px;
}
@media (max-width: 600px) { .jgrid { --row: 120px; gap: 4px; } }

/* ---------- Project page ---------- */
.p-head { padding-top: clamp(28px, 5vw, 48px); padding-bottom: 24px; }
.back { font-size: 13px; color: var(--muted); display: inline-block; margin-bottom: 18px; }
.back:hover { color: var(--blue); }
.p-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.p-title { font-size: clamp(28px, 5vw, 46px); }
.p-short { font-size: clamp(15px, 1.8vw, 18px); color: var(--text-hi); margin: 10px 0 18px; max-width: 60ch; }
.p-meta { display: flex; flex-wrap: wrap; gap: 8px 32px; font-size: 13px; }
.p-meta dt { color: var(--comment); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; }
.p-meta dd { color: var(--text-hi); }
.p-links { display: flex; flex-wrap: wrap; gap: 4px 16px; }

.p-hero { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 860px) { .p-hero { grid-template-columns: 2.2fr 1fr; height: min(64vh, 620px); } .p-hero-single { grid-template-columns: 1fr; } }
.p-hero a, .p-hero-main { display: block; overflow: hidden; border-radius: var(--r); background: var(--bg-deep); min-height: 0; }
.p-hero img, .p-hero video { width: 100%; height: 100%; object-fit: cover; transition: transform 0.8s var(--ease); }
.p-hero a:hover img { transform: scale(1.02); }
.p-hero-side { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
@media (min-width: 860px) { .p-hero-side { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; min-height: 0; } }
.p-hero-side a { aspect-ratio: 16 / 10; }
@media (min-width: 860px) { .p-hero-side a { aspect-ratio: auto; } }
@media (max-width: 859px) { .p-hero-main { aspect-ratio: 16 / 10; } }

.p-body { display: grid; gap: 36px; padding-top: 40px; padding-bottom: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .p-body { grid-template-columns: 1.6fr 1fr; gap: 64px; } }
.p-summary { color: var(--text-hi); font-size: 16px; max-width: 62ch; margin-bottom: 26px; }
.p-section { margin-bottom: 28px; max-width: 64ch; }
.p-section p { margin-bottom: 12px; font-size: 14px; }
.p-section strong { color: var(--text-hi); font-weight: normal; }
.p-how { display: grid; gap: 8px; font-size: 14px; margin-bottom: 12px; }
.p-how li { padding-left: 18px; position: relative; }
.p-how li::before { content: '▸'; position: absolute; left: 0; color: var(--comment); }
.p-gnote { max-width: 68ch; font-size: 14px; margin: -4px 0 18px; }
.p-aside { display: flex; flex-direction: column; gap: 28px; }
.stats { display: grid; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--r); overflow: hidden; }
.stat { background: var(--surface); padding: 11px 16px; font-size: 14px; }
.stat-v { font-weight: normal; background: var(--heat); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-l { color: var(--muted); }
.refs ul { display: grid; gap: 8px; font-size: 13px; }
.refs li::before { content: '↳ '; color: var(--comment); }

.p-gallery { padding-top: 40px; padding-bottom: 20px; }
.p-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 40px; padding-bottom: 64px; }
.pager-link { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border: 1px solid var(--line-soft); border-radius: var(--r); color: var(--text-hi); font-size: 14px; transition: border-color 0.2s; }
.pager-link:hover { border-color: var(--blue); text-decoration: none; }
.pager-link .muted { font-size: 12px; }
.pager-next { text-align: right; }

/* ---------- DDA demo ---------- */
.demo { margin-top: 40px; border: 1px solid var(--line-soft); border-radius: var(--r); background: var(--bg-deep); overflow: hidden; }
.demo-head { padding: 20px 22px 12px; }
.demo-head .muted { font-size: 13px; max-width: 72ch; }
.demo-stage { position: relative; }
.dda { width: 100%; height: clamp(280px, 46vw, 460px); touch-action: none; cursor: crosshair; }
.demo-ui { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 12px 22px 16px; font-size: 13px; border-top: 1px solid var(--line-soft); }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { accent-color: var(--blue); width: 15px; height: 15px; }
.demo-out { margin-left: auto; color: var(--yellow); font-variant-numeric: tabular-nums; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--line-soft); background: var(--bg-deep); margin-top: 0; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 28px; padding-top: 48px; padding-bottom: 28px; }
.footer-big { font-size: clamp(16px, 2.2vw, 21px); color: var(--text-hi); margin-bottom: 6px; overflow-wrap: anywhere; }
.footer-inner .muted { font-size: 13px; }
.footer-links { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.footer-base { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; padding-top: 16px; padding-bottom: 28px; font-size: 12px; border-top: 1px solid var(--line-soft); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 17, 20, 0.96);
  display: grid; place-items: center; padding: 48px 64px 64px;
}
.lightbox[hidden] { display: none; }
.lb-figure { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 100%; max-height: 100%; }
.lb-figure img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 3px; image-rendering: auto; }
.lb-figure img.loading { filter: blur(6px); }
.lb-cap { display: flex; gap: 18px; font-size: 13px; color: var(--muted); }
.lb-title { color: var(--text-hi); }
.lb-btn { position: absolute; color: var(--text); font-size: 34px; width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--r); }
.lb-btn:hover { color: var(--text-hi); background: rgba(255, 255, 255, 0.06); }
.lb-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 8px; top: 50%; transform: translateY(-50%); }
.lb-close { right: 10px; top: 8px; font-size: 28px; }
@media (max-width: 640px) { .lightbox { padding: 48px 8px 72px; } .lb-prev, .lb-next { top: auto; bottom: 10px; transform: none; } }

/* ---------- Debug overlay (press `) ---------- */
.debug * { outline: 1px solid rgba(97, 175, 239, 0.28) !important; }
.debug img, .debug video { outline-color: rgba(229, 192, 123, 0.6) !important; }
.debug a { outline-color: rgba(152, 195, 121, 0.45) !important; }
.hud {
  position: fixed; left: 12px; bottom: 12px; z-index: 90; font-size: 11px; line-height: 1.55;
  background: rgba(27, 31, 36, 0.92); border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px;
  color: var(--text); min-width: 190px; pointer-events: none; white-space: pre; outline: none !important;
}
.hud * { outline: none !important; }
.hud b { color: var(--yellow); font-weight: normal; }
.hud .hud-bar { display: block; height: 22px; margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 110;
  background: var(--surface); color: var(--text-hi); border: 1px solid var(--line); padding: 8px 14px; border-radius: var(--r);
  font-size: 13px; opacity: 0; transition: opacity 0.2s, transform 0.25s var(--ease); pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  body { font-size: 14px; }
  .nav-links { gap: 14px; font-size: 13px; }
  .logo { font-size: 14px; }
}

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