/* ==========================================================================
   atparisi.com — site stylesheet
   Hand-written, framework-free. Light/dark via CSS custom properties.
   ========================================================================== */

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #f7f6f2;
  --bg-elevated: #ffffff;
  --bg-sunken: #efede7;
  --text: #17171a;
  --text-muted: #5d5c58;
  --text-faint: #8b8a85;
  --border: #e3e0d8;
  --border-strong: #cfcbc1;

  --accent: #e0562b;
  --accent-strong: #b8431c;
  --accent-soft: rgba(224, 86, 43, 0.12);
  --accent-contrast: #ffffff;
  --accent-2: #2b7de0;

  --code-bg: #f0eee8;
  --shadow-sm: 0 1px 2px rgba(20, 18, 12, 0.06), 0 1px 1px rgba(20, 18, 12, 0.04);
  --shadow-md: 0 8px 24px rgba(20, 18, 12, 0.08), 0 2px 6px rgba(20, 18, 12, 0.05);

  --radius: 14px;
  --radius-sm: 8px;
  --header-h: 64px;

  /* highlight.js token colors */
  --hl-comment: #7a776f;
  --hl-keyword: #a626a4;
  --hl-string: #50a14f;
  --hl-number: #986801;
  --hl-type: #c18401;
  --hl-title: #4078f2;
  --hl-meta: #4078f2;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #111114;
  --bg-elevated: #19191e;
  --bg-sunken: #0c0c0f;
  --text: #ecebe8;
  --text-muted: #a4a3a0;
  --text-faint: #6f6e6b;
  --border: #27272d;
  --border-strong: #3a3a42;

  --accent: #ff8a5b;
  --accent-strong: #ffa580;
  --accent-soft: rgba(255, 138, 91, 0.14);
  --accent-contrast: #1a0d07;
  --accent-2: #6aa9ff;

  --code-bg: #141418;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.45);

  --hl-comment: #7f8590;
  --hl-keyword: #c678dd;
  --hl-string: #98c379;
  --hl-number: #d19a66;
  --hl-type: #e5c07b;
  --hl-title: #61afef;
  --hl-meta: #61afef;

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 1.5rem);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

img, video, canvas, svg { display: block; max-width: 100%; }
img, video { height: auto; }

a {
  color: var(--accent-strong);
  text-decoration: none;
  text-underline-offset: 0.18em;
  transition: color 120ms ease;
}
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 700;
  color: var(--text);
  text-wrap: balance;
}
h1 { font-size: clamp(2.25rem, 5vw, 3.5rem); font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }

p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 1.4rem; }
li + li { margin-top: 0.35rem; }

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

code, pre, kbd {
  font-family: var(--font-mono);
  font-size: 0.875em;
}
:not(pre) > code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  font-size: 0.85em;
  color: var(--text);
}
pre {
  margin: 0 0 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  line-height: 1.55;
  tab-size: 4;
}
pre code { background: none; border: 0; padding: 0; font-size: 0.85rem; color: var(--text); }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin-bottom: 0.75rem;
}
.eyebrow::before {
  content: "";
  width: 1.5rem;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.lead {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 60ch;
}

.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); }

/* --------------------------------------------------------------------------
   Header / nav
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-contrast);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-sub {
  display: none;
  color: var(--text-faint);
  font-weight: 500;
}
@media (min-width: 720px) { .brand-sub { display: inline; } }
@media (max-width: 480px) {
  .brand > span:not(.brand-mark) { display: none; }
  .nav a { padding: 0.4rem 0.6rem; font-size: 0.9rem; }
  .theme-toggle { margin-left: 0.25rem; }
  .container { padding: 0 1.1rem; }
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.nav a {
  position: relative;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 120ms ease, background-color 120ms ease;
}
.nav a:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--text); background: var(--bg-elevated); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }

.theme-toggle {
  margin-left: 0.5rem;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* --------------------------------------------------------------------------
   Buttons, chips, cards
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, border-color 120ms ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--text-faint); }
.btn:active { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.875rem; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; padding: 0; margin: 0; list-style: none; }
.chips li { margin: 0; }
.chip {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 1.5rem; }

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */

main { padding-bottom: 4rem; }

.section { padding: 3.5rem 0 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.section-head h2 { margin: 0; }

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */

.hero {
  position: relative;
  padding: 4.5rem 0 3.5rem;
  overflow: hidden;
  isolation: isolate;
}
.hero-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.hero-bg canvas { width: 100%; height: 100%; }
.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, var(--bg));
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3rem;
  align-items: center;
}
@media (max-width: 800px) {
  .hero { padding: 3rem 0 2.5rem; }
  .hero-grid { grid-template-columns: 1fr; gap: 2rem; }
  .hero-photo { order: -1; }
}
.hero h1 { margin: 0 0 0.75rem; }
.hero h1 .wave { display: inline-block; transform-origin: 70% 70%; }
.hero .lead { margin-bottom: 1.75rem; }

.hero-photo {
  position: relative;
  width: 220px;
  justify-self: center;
}
.hero-photo img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  background: var(--bg-elevated);
}
.hero-photo::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 32px;
  border: 1px dashed var(--border-strong);
  z-index: -1;
}
.hero-photo::after {
  content: "";
  position: absolute;
  right: -14px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: var(--shadow-md);
  z-index: 1;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.hero-meta li { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; }
.hero-meta svg { width: 16px; height: 16px; color: var(--accent); }

.dropdown { position: relative; display: inline-block; }
.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  min-width: 200px;
  padding: 0.4rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 20;
}
.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}
.dropdown-menu a:hover { background: var(--accent-soft); text-decoration: none; }
.dropdown-menu svg { width: 16px; height: 16px; color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Two-column content layout (about + sidebar; wiki article + toc)
   -------------------------------------------------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 3.5rem;
  align-items: start;
}
.layout-narrow-side { grid-template-columns: minmax(0, 1fr) 260px; }
.layout > * { min-width: 0; }
@media (max-width: 900px) {
  .layout, .layout-narrow-side { grid-template-columns: 1fr; gap: 2.5rem; }
}
.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  display: grid;
  gap: 1.25rem;
}
@media (max-width: 900px) { .sidebar { position: static; } }

.side-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 0.75rem;
}

/* --------------------------------------------------------------------------
   Timeline (experience)
   -------------------------------------------------------------------------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li {
  position: relative;
  padding-left: 2rem;
  padding-bottom: 2.25rem;
  margin: 0;
}
.timeline > li::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 0.55rem;
  bottom: -0.55rem;
  width: 2px;
  background: var(--border);
}
.timeline > li:last-child::before { display: none; }
.timeline > li::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45rem;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--bg);
  border: 3px solid var(--accent);
}
.timeline > li:first-child::after { background: var(--accent); }
.tl-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 0.35rem;
}
.tl-head h3 { font-size: 1.15rem; }
.tl-org { color: var(--text-muted); font-weight: 500; }
.tl-org a { color: inherit; }
.tl-date {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-faint);
  white-space: nowrap;
}
.timeline ul { margin: 0.6rem 0 0; padding-left: 1.2rem; color: var(--text-muted); }
.timeline ul li { margin-top: 0.4rem; }
.timeline ul li::marker { color: var(--accent); }

.edu { display: grid; gap: 1rem; }
.edu-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: start;
  padding: 1.1rem 1.25rem;
}
.edu-item .edu-year {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-faint);
  padding-top: 0.25rem;
  min-width: 6.5rem;
}
.edu-item h3 { font-size: 1.05rem; margin-bottom: 0.15rem; }
.edu-item p { margin: 0; color: var(--text-muted); font-size: 0.95rem; }

/* --------------------------------------------------------------------------
   Projects
   -------------------------------------------------------------------------- */

.page-hero {
  padding: 3.5rem 0 2.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 3rem;
  align-items: center;
}
@media (max-width: 800px) { .page-hero { grid-template-columns: 1fr; gap: 1.5rem; } }
.page-hero h1 { margin-bottom: 0.75rem; }
.page-hero-art {
  width: 100%;
  max-width: 360px;
  justify-self: end;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transform: rotate(1.5deg);
}
.page-hero-art img { width: 100%; }
@media (max-width: 800px) { .page-hero-art { justify-self: start; transform: none; } }

.project-list { display: grid; gap: 2rem; }
.project {
  scroll-margin-top: calc(var(--header-h) + 1.5rem);
  overflow: hidden;
}
.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.75rem 0;
}
.project-head h2 { font-size: 1.6rem; margin-bottom: 0.2rem; }
.project-tagline { color: var(--text-muted); margin: 0; }
.project-body { padding: 1.25rem 1.75rem 1.75rem; }
.project-body > :last-child { margin-bottom: 0; }
.project-split > * { min-width: 0; }
.project-media {
  margin: 1.25rem 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
}
.project-media img, .project-media video { width: 100%; }
.project-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 1.5rem;
  align-items: start;
}
.project-split .project-media { margin: 0; }
@media (max-width: 720px) { .project-split { grid-template-columns: 1fr; } }
.project-media--sm { max-width: 320px; }
.project-tags { margin-top: 1rem; }

.gl-frame {
  aspect-ratio: 1 / 1;
  max-width: 480px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
}
.gl-frame canvas { width: 100%; height: 100%; }

.toc { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 0.4rem 0.75rem;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
  font-size: 0.92rem;
  text-decoration: none;
  transition: color 120ms ease, border-color 120ms ease;
}
.toc a:hover { color: var(--text); border-color: var(--text-faint); }
.toc a[aria-current="page"], .toc a.is-active { color: var(--accent-strong); border-color: var(--accent); font-weight: 600; }
.toc .toc-sub { padding-left: 0.9rem; }
.toc .toc-group {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 1rem 0 0.4rem;
}
.toc .toc-group:first-child { margin-top: 0; }

/* --------------------------------------------------------------------------
   Wiki
   -------------------------------------------------------------------------- */

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}
.topic-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.15rem 1.25rem;
  text-decoration: none;
  color: var(--text);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}
.topic-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.topic-card h3 { font-size: 1.05rem; }
.topic-card p { margin: 0; color: var(--text-muted); font-size: 0.9rem; }
.topic-card .topic-kind {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.article-head { margin-bottom: 2rem; }
.article-head h1 { font-size: clamp(2rem, 4vw, 2.75rem); margin-bottom: 0.5rem; }
.article-head .lead { font-size: 1.1rem; margin: 0; }
.article-head .crumbs {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-faint);
  margin-bottom: 1rem;
}
.article-head .crumbs a { color: var(--text-muted); }

.prose > h2 {
  font-size: 1.4rem;
  margin: 2.5rem 0 0.9rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}
.prose > h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose > h3 { font-size: 1.15rem; margin: 1.75rem 0 0.6rem; }
.prose p, .prose li { color: var(--text); }
.prose li { color: var(--text-muted); }
.prose li strong, .prose li b { color: var(--text); }
.prose img { border-radius: var(--radius-sm); border: 1px solid var(--border); }
.prose ul.eq { list-style: none; padding-left: 0; display: grid; gap: 0.35rem; }
.prose ul.eq li {
  min-width: 0;
  overflow-x: auto;
  padding: 0.45rem 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1.02rem;
}
.prose li pre { margin-top: 0.6rem; }
mjx-container { display: inline-block !important; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: middle; }

.repo-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.repo-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.repo-card svg { width: 28px; height: 28px; flex: none; color: var(--text-muted); }
.repo-card .repo-name { font-family: var(--font-mono); font-weight: 600; font-size: 0.95rem; }
.repo-card .repo-desc { color: var(--text-muted); font-size: 0.9rem; margin: 0; }
.repo-card .repo-arrow { margin-left: auto; color: var(--text-faint); }

.callout {
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1.25rem 0;
}
.callout > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Filter lab (interactive Bode plots)
   -------------------------------------------------------------------------- */

.lab {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 0;
  margin: 1.5rem 0;
  overflow: hidden;
}
@media (max-width: 720px) { .lab { grid-template-columns: 1fr; } }
.lab-plots { display: grid; grid-template-rows: 1fr 1fr; padding: 0.75rem 0.5rem 0.25rem; }
.lab-plots canvas { width: 100%; height: 100%; }
.lab-plot { position: relative; height: 220px; }
.lab-controls {
  padding: 1.25rem;
  border-left: 1px solid var(--border);
  background: var(--bg-sunken);
  display: grid;
  gap: 1.1rem;
  align-content: start;
}
@media (max-width: 720px) { .lab-controls { border-left: 0; border-top: 1px solid var(--border); } }
.lab-controls label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.lab-controls .val {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  float: right;
  font-weight: 500;
}
.lab-controls .check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}
.lab-controls .check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.lab-coefs {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.lab-coefs span b { color: var(--text-muted); font-weight: 500; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  margin: 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}
input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--border-strong);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 999px;
  background: var(--accent);
  border: 3px solid var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}
input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--accent);
  border: 3px solid var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 2.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.footer-links { display: flex; gap: 1rem; }
.footer-links a { color: var(--text-muted); display: inline-flex; align-items: center; gap: 0.35rem; }
.footer-links a:hover { color: var(--text); }
.footer-links svg { width: 16px; height: 16px; }

/* --------------------------------------------------------------------------
   highlight.js theme (token colors come from custom properties)
   -------------------------------------------------------------------------- */

.hljs { color: var(--text); background: transparent; }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-name { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--hl-string); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-attr { color: var(--hl-number); }
.hljs-type, .hljs-built_in, .hljs-class .hljs-title, .hljs-title.class_ { color: var(--hl-type); }
.hljs-title, .hljs-title.function_, .hljs-section { color: var(--hl-title); }
.hljs-meta, .hljs-meta .hljs-keyword { color: var(--hl-meta); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* --------------------------------------------------------------------------
   Reveal-on-scroll (subtle)
   -------------------------------------------------------------------------- */

.js .reveal { opacity: 0; transform: translateY(10px); transition: opacity 500ms ease, transform 500ms ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   Photo gallery (justified rows via flex-grow, no JS needed for layout)
   -------------------------------------------------------------------------- */

.gallery-day { margin-top: 2.5rem; }
.gallery-day:first-of-type { margin-top: 0; }
.gallery-day-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.gallery-day-head h2 { font-size: 1.25rem; }
.gallery-day-head .muted { font-family: var(--font-mono); font-size: 0.78rem; }

.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gallery::after { content: ""; flex-grow: 1000; }
.tile {
  position: relative;
  display: block;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
}
.tile i { display: block; }
.tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease, filter 300ms ease;
}
.tile:hover img { transform: scale(1.03); }
.tile:focus-visible { outline-offset: 2px; }
.tile-badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.tile-badge svg { width: 12px; height: 12px; }

/* Lightbox */
.lb {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  background: rgba(8, 8, 10, 0.94);
  color: #fff;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.lb.is-open { display: grid; grid-template-rows: 1fr auto; }
.lb-stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: 3.5rem 4rem 0.5rem;
  min-height: 0;
}
@media (max-width: 720px) { .lb-stage { padding: 3.25rem 0.5rem 0.5rem; } }
.lb-stage img, .lb-stage video {
  max-width: 100%;
  max-height: calc(100vh - 8.5rem);
  border-radius: 6px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  background: #000;
}
.lb-cap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1.25rem 1.1rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.8);
}
.lb-cap .mono { font-size: 0.78rem; color: rgba(255, 255, 255, 0.55); }
.lb-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color 120ms ease;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.18); }
.lb-btn svg { width: 20px; height: 20px; }
.lb-prev { left: 0.75rem; }
.lb-next { right: 0.75rem; }
.lb-close { top: 0.75rem; right: 0.75rem; transform: none; }
@media (max-width: 720px) {
  .lb-prev, .lb-next { top: auto; bottom: 4.25rem; transform: none; width: 40px; height: 40px; }
}
body.lb-lock { overflow: hidden; }

/* Album teaser card on the home page */
.album-card {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  overflow: hidden;
}
.album-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; }
.album-card img:first-child { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; height: 100%; }
@media (max-width: 600px) { .album-card { grid-template-columns: 1fr 1fr; } .album-card img:first-child { grid-column: span 2; grid-row: auto; aspect-ratio: 16 / 9; } }
.album-teaser {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 2rem;
  align-items: center;
}
@media (max-width: 800px) { .album-teaser { grid-template-columns: 1fr; } }

/* Album chapters (one per place) */
.chapter { margin-top: 3.5rem; scroll-margin-top: calc(var(--header-h) + 1.5rem); }
.chapter:first-of-type { margin-top: 0; }
.chapter-head { margin-bottom: 1.25rem; }
.chapter-head .eyebrow { margin-bottom: 0.4rem; }
.chapter-head h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); margin-bottom: 0.25rem; }
.chapter-head .muted { font-family: var(--font-mono); font-size: 0.8rem; margin: 0; }
.chapter .gallery-day { margin-top: 1.5rem; scroll-margin-top: calc(var(--header-h) + 1.5rem); }
.chapter .gallery-day-head h3 { font-size: 1.05rem; }
