/* =====================================================================
   Brandon Ramírez — portfolio
   Design system reproduced from the mockup (.dc.html source of truth).
   Type: Newsreader (serif display) + IBM Plex Mono.
   Editorial, hairline-ruled, restrained. No build step, no framework.
   ===================================================================== */

/* ----- Design tokens --------------------------------------------------*/
:root {
  /* surfaces */
  --bg:          #F8F5EE;   /* page background (warm paper) */
  --bg-warm:     #F4F0E8;   /* cards / masthead panel */
  --bg-sink:     #F1EDE3;   /* recessed panel */
  --navy:        #15243A;   /* deep navy panels */
  --ink:         #2E343B;   /* primary text + dark footer */

  /* text */
  --ink-2:       #3A4453;   /* secondary / italic lead */
  --muted:       #645E51;   /* readable muted label (AA on --bg) */
  --muted-soft:  #8A8275;   /* decorative muted (large text only) */
  --slate:       #545E6E;
  --on-dark:     #EDE7DA;   /* text on navy/ink */
  --on-dark-2:   #C5CBD4;
  --on-dark-mut: #9AA3B0;
  --on-dark-dim: #7E8898;

  /* accents */
  --accent:      #2271B2;   /* editorial blue — links, eyebrows */
  --accent-ink:  #1c5d93;   /* darker blue for AA on light when needed */
  --orange:      #E69F00;   /* hero hairline accent */
  --terracotta:  #BD5B3D;
  --gold:        #C29A4B;
  --graphite:    #6E7A89;
  --green:       #18895f;   /* live / success (AA-safe) */
  --green-dot:   #1B9E77;

  /* hairlines */
  --hair:        rgba(36,42,49,.14);
  --hair-soft:   rgba(36,42,49,.10);
  --hair-strong: rgba(36,42,49,.20);
  --hair-dark:   rgba(237,231,218,.15);

  /* type */
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --mono:  'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* layout */
  --wrap: 1180px;
  --pad-x: clamp(28px, 5vw, 44px);
  --ease: cubic-bezier(.22,1,.36,1);
}

/* ----- Reset / base ---------------------------------------------------*/
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scrollbar-width: none; }
html::-webkit-scrollbar { display: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--accent-ink); }
h1, h2, h3, h4 { font-weight: 400; margin: 0; letter-spacing: -.02em; line-height: 1.08; }
p { margin: 0 0 1em; }
ul { margin: 0; }

/* Skip link (a11y) */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 1000;
  background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-size: 12px; padding: 10px 16px; border-radius: 2px;
}
.skip-link:focus { left: 12px; top: 12px; }

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

/* ----- Layout helpers -------------------------------------------------*/
.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: max(var(--pad-x), env(safe-area-inset-left)); padding-right: max(var(--pad-x), env(safe-area-inset-right)); }
.wrap--wide { max-width: 1320px; }
.rule { height: 1px; background: var(--hair); border: 0; margin: 0; }
.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .22em;
  text-transform: uppercase; color: var(--accent); margin: 0;
}
.eyebrow--muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
/* block padding only — the inline (side) margin comes from .wrap so text never hits the edge */
.section { padding-block: clamp(56px, 9vh, 104px); }
.section__head { margin-bottom: clamp(28px, 5vh, 48px); }
.section-title {
  font-family: var(--serif); font-size: clamp(34px, 5vw, 60px);
  line-height: 1.02; margin: 14px 0 0; color: var(--ink); text-wrap: balance;
}
.lead {
  font-family: var(--serif); font-style: italic; font-weight: 300;
  font-size: clamp(18px, 2.2vw, 25px); line-height: 1.5; color: var(--ink-2);
  max-width: 760px; text-wrap: balance;
}

/* ----- Header / nav ---------------------------------------------------*/
.site-nav {
  position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid var(--hair);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
}
.site-nav__inner {
  max-width: var(--wrap); margin: 0 auto;
  /* viewport-fit=cover lets content bleed under the notch/Dynamic Island — clear it + side notch */
  padding: calc(16px + env(safe-area-inset-top)) max(var(--pad-x), env(safe-area-inset-right)) 16px max(var(--pad-x), env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand img { height: 23px; width: auto; }
.brand span {
  font-family: var(--mono); font-size: 11px; letter-spacing: .2em;
  color: var(--ink); text-transform: uppercase; transition: color .4s ease;
}
.brand img { transition: filter .4s ease; }
.nav-links {
  display: flex; align-items: center; gap: 28px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  list-style: none; padding: 0; margin: 0;
}
.nav-right { display: flex; align-items: center; gap: 18px; }
.nav-a { position: relative; text-decoration: none; color: var(--ink); white-space: nowrap; transition: color .4s ease; }
.nav-a::after {
  content: ''; position: absolute; left: 0; bottom: -5px; width: 0; height: 1px;
  background: var(--accent); transition: width .25s ease;
}
.nav-a:hover::after, .nav-a:focus-visible::after, .nav-a[aria-current="page"]::after { width: 100%; }
.nav-a[aria-current="page"] { color: var(--accent-ink); }

/* language toggle */
.lang-toggle { display: inline-flex; border: 1px solid var(--hair-strong); border-radius: 2px; overflow: hidden; }
.lang-btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em;
  padding: 6px 12px; border: 0; background: transparent; color: var(--muted-soft); cursor: pointer;
  transition: color .4s ease, background .4s ease;
}
.lang-btn:hover { color: var(--ink); background: rgba(34,113,178,.08); }
.lang-btn[aria-pressed="true"] { background: var(--ink); color: #fff; font-weight: 500; }
.lang-toggle { transition: border-color .4s ease; }

/* mobile menu */
.nav-toggle {
  display: none; border: 1px solid var(--ink); background: transparent; cursor: pointer;
  width: 40px; height: 36px; border-radius: 2px; padding: 0; transition: border-color .4s ease;
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  display: block; width: 18px; height: 1.5px; background: var(--ink); margin: 0 auto; position: relative; transition: .2s ease;
}
.nav-toggle span::before, .nav-toggle span::after { content: ''; position: absolute; left: 0; }
.nav-toggle span::before { top: -6px; } .nav-toggle span::after { top: 6px; }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span::after { top: 0; transform: rotate(-45deg); }

@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: flex-start; gap: 18px;
    background: var(--bg); border-bottom: 1px solid var(--hair);
    padding: 22px var(--pad-x); transform: translateY(-8px);
    opacity: 0; pointer-events: none; transition: .2s ease;
  }
  .nav-links.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
}

/* ----- Buttons --------------------------------------------------------*/
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .08em;
  padding: 13px 24px; border-radius: 2px; text-decoration: none; cursor: pointer;
  border: 1px solid transparent;
  transition: transform .25s var(--ease), background .25s ease, color .25s ease, box-shadow .25s ease;
}
.btn--solid { background: var(--ink); color: var(--bg); box-shadow: 0 10px 26px -14px rgba(36,42,49,.7); }
.btn--outline { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn--ghost { color: var(--accent-ink); border-color: var(--hair-strong); background: var(--bg-warm); }
.btn:hover { transform: translateY(-2px); }
.btn--outline:hover { background: var(--ink); color: var(--bg); transform: none; }
.btn--solid:hover { transform: none; }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--bg); }

/* ----- Badges ---------------------------------------------------------*/
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 2px; border: 1px solid var(--hair-strong); color: var(--ink); white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--published { color: #1a6e4f; border-color: rgba(26,110,79,.4); }
.badge--accepted  { color: var(--accent-ink); border-color: rgba(34,113,178,.4); }
.badge--review    { color: #9a5a1e; border-color: rgba(154,90,30,.4); }
.badge--progress  { color: var(--graphite); border-color: rgba(110,122,137,.5); }
.badge--simulated { color: var(--terracotta); border-color: rgba(189,91,61,.45); }
.badge--thesis    { color: var(--navy); border-color: rgba(21,36,58,.4); }

/* ----- Cards ----------------------------------------------------------*/
.card {
  background: var(--bg-warm); border: 1px solid var(--hair);
  border-radius: 4px; padding: clamp(22px, 3vw, 34px);
}
.card-lift { transition: transform .25s var(--ease), box-shadow .25s ease, border-color .25s ease, background .25s ease; }
.card-lift:hover { transform: translateY(-4px); box-shadow: 0 24px 60px -34px rgba(36,42,49,.5); border-color: var(--accent); background: var(--bg-sink); }
.card--dark { background: var(--ink); color: var(--on-dark); border-color: transparent; }
.card--navy { background: var(--navy); color: var(--on-dark); border-color: transparent; }
.card--dashed { background: transparent; border-style: dashed; }

/* ----- Colophon / stat strip -----------------------------------------*/
.colophon { border-top: 1px solid var(--hair); }
.colophon__inner { max-width: var(--wrap); margin: 0 auto; display: flex; align-items: stretch; }
.colcell {
  flex: 1; padding: clamp(16px, 2.4vh, 26px) 14px; text-align: center;
  border-right: 1px solid var(--hair); transition: background .3s ease;
}
.colcell:last-child { border-right: 0; }
.colcell:hover { background: rgba(34,113,178,.05); }
.colnum { font-family: var(--serif); font-size: clamp(26px, 3vw, 38px); line-height: 1; transition: color .3s ease; }
.colcell:hover .colnum { color: var(--accent); }
.collabel { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; color: var(--muted); text-transform: uppercase; margin-top: 8px; }

/* ----- Footer ---------------------------------------------------------*/
.site-footer { border-top: 1px solid var(--hair); background: var(--ink); color: var(--on-dark-mut); }
.site-footer__inner {
  max-width: var(--wrap); margin: 0 auto; padding: 14px var(--pad-x);
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
}
.site-footer a { color: var(--on-dark-mut); text-decoration: none; }
.site-footer a:hover { color: var(--on-dark); }
.footer-accent { color: var(--orange); text-transform: none; letter-spacing: .04em; font-size: 12px; text-decoration: none; }
.footer-links { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }

/* ----- Animations (mirror mockup keyframes) --------------------------*/
@keyframes fadeUp   { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ringDraw { from { stroke-dashoffset: 754; } to { stroke-dashoffset: 0; } }
@keyframes glyphIn  { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }
@keyframes dotIn    { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
@keyframes barGrow  { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes blink    { 0%,49% { opacity: 1; } 50%,100% { opacity: .25; } }
@keyframes scan     { 0% { top: 0; opacity: 0; } 30% { opacity: .55; } 100% { top: 100%; opacity: 0; } }

/* entrance reveal via IntersectionObserver */
[data-reveal] { opacity: 0; transform: translateY(16px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
[data-reveal].is-visible { opacity: 1; transform: none; }
[data-reveal][data-reveal-delay="1"] { transition-delay: .08s; }
[data-reveal][data-reveal-delay="2"] { transition-delay: .16s; }
[data-reveal][data-reveal-delay="3"] { transition-delay: .24s; }
[data-reveal][data-reveal-delay="4"] { transition-delay: .32s; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}

/* ----- Animated bar chart (shared) -----------------------------------*/
.bar-track { height: 8px; background: rgba(36,42,49,.10); border-radius: 4px; overflow: hidden; }
.card--navy .bar-track, .card--dark .bar-track { background: rgba(237,231,218,.14); }
.bar-fill { height: 100%; transform-origin: left center; border-radius: 4px; }
.bar-fill.is-animated { animation: barGrow 1.15s var(--ease) both; }
.bar-row { margin-bottom: 18px; }
.bar-row__label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--mono); font-size: 12px; letter-spacing: .04em; margin-bottom: 8px;
}

/* ----- Background canvas ---------------------------------------------*/
.bg-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }

/* ----- Hero (Direction A — masthead) ---------------------------------*/
.hero { position: relative; overflow: hidden; }
.masthead {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; min-height: min(86vh, 760px);
}
.masthead__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 0; border-bottom: 1px solid var(--hair);
  font-family: var(--mono); font-size: 11px; letter-spacing: .2em; color: var(--slate); text-transform: uppercase;
}
.masthead__bar .brand span { color: var(--slate); }
.masthead__body {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: clamp(40px, 7vh, 80px) 0; gap: 0;
}
.masthead__kicker {
  font-family: var(--mono); font-size: clamp(10px, 1.1vw, 12px); letter-spacing: .34em;
  text-transform: uppercase; color: var(--accent);
  animation: fadeUp .7s var(--ease) both;
}
.masthead__name {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(34px, 10vw, 116px); line-height: .98; letter-spacing: -.025em;
  margin: clamp(16px, 2.4vh, 26px) 0 0; color: var(--ink); overflow-wrap: break-word; max-width: 100%;
  animation: fadeUp .7s var(--ease) .06s both;
}
.masthead__hairline { width: 64px; height: 2px; background: var(--orange); margin: clamp(20px, 3.4vh, 34px) 0; }
.masthead__lead {
  font-family: var(--serif); font-style: italic; font-weight: 300;
  font-size: clamp(18px, 2.3vw, 26px); line-height: 1.45; color: var(--ink-2);
  max-width: 760px; margin: 0; text-wrap: balance;
  animation: fadeUp .7s var(--ease) .12s both;
}
.masthead__cta { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: clamp(26px, 4vh, 44px); animation: fadeUp .7s var(--ease) .2s both; }

/* ----- Generic content grids -----------------------------------------*/
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(18px, 2.6vw, 30px); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(18px, 2.6vw, 30px); }
@media (max-width: 820px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* publication row (Papers index) */
.prow {
  display: grid; grid-template-columns: 46px 1fr minmax(140px, 230px); gap: 18px;
  align-items: start; padding: 26px 14px; border-top: 1px solid var(--hair);
  text-decoration: none; color: inherit; transition: background .3s ease;
}
.prow:hover { background: rgba(34,113,178,.08); }
.prow:hover .parrow { transform: translateX(4px); color: var(--accent); }
.prow__num { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 6px; }
.prow__title { font-family: var(--serif); font-size: clamp(21px, 2.6vw, 30px); line-height: 1.12; }
.prow__meta { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; margin-top: 8px; display: flex; flex-wrap: nowrap; gap: 10px 14px; align-items: center; }
.prow__meta > span:last-child { min-width: 0; }   /* let the text wrap beside the pill instead of pushing it to its own line */
.prow__desc { font-size: 16px; line-height: 1.55; color: var(--ink-2); margin-top: 12px; max-width: 60ch; }
.prow__aside { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; }
.prow__aside .big { font-family: var(--serif); font-size: 28px; color: var(--ink); display: block; }
.parrow { display: inline-block; transition: transform .25s ease, color .25s ease; }
@media (max-width: 720px) {
  .prow { grid-template-columns: 32px 1fr; }
  .prow__aside { grid-column: 2; text-align: left; margin-top: 12px; }
}

/* method chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em; color: var(--ink-2);
  padding: 5px 11px; border: 1px solid var(--hair); border-radius: 2px; background: var(--bg-warm);
}

/* big stat */
.bigstat { display: flex; flex-wrap: wrap; gap: clamp(20px, 4vw, 48px); }
.bigstat__item .v { font-family: var(--serif); font-size: clamp(34px, 5vw, 56px); line-height: 1; color: var(--ink); }
.bigstat__item .k { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-top: 8px; }

/* ----- Deep-dive page shell ------------------------------------------*/
.paper-head { padding: clamp(36px, 6vh, 72px) 0 clamp(24px, 4vh, 40px); }
.paper-head__title { font-family: var(--serif); font-size: clamp(34px, 5.2vw, 66px); line-height: 1.02; margin: 18px 0 0; text-wrap: balance; }
.paper-head__sub { font-family: var(--serif); font-style: italic; font-size: clamp(18px, 2.2vw, 24px); color: var(--ink-2); margin: 16px 0 0; max-width: 800px; }
.paper-head__meta { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-top: 16px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.paper-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.abstract { display: grid; grid-template-columns: 1fr minmax(200px, 280px); gap: clamp(24px, 4vw, 56px); }
.abstract__body { font-size: 19px; line-height: 1.65; color: var(--ink-2); }
.abstract__body p { margin-bottom: 1em; }
@media (max-width: 820px) { .abstract { grid-template-columns: 1fr; } }

/* figure caption */
.figcap { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; color: var(--muted); margin-top: 14px; line-height: 1.5; }
.figure { margin: clamp(28px, 5vh, 52px) 0; }
.figure__title { font-family: var(--mono); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--accent); margin-bottom: 16px; }

/* note / callout */
.note {
  font-family: var(--mono); font-size: 12px; line-height: 1.6; color: var(--muted);
  border-left: 2px solid var(--hair-strong); padding: 4px 0 4px 16px; margin: 16px 0;
}
.note--warn { border-left-color: var(--terracotta); color: #7a4a36; }

/* ----- Forms ----------------------------------------------------------*/
.field { margin-bottom: 20px; }
.field label { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.fin {
  width: 100%; font-family: var(--serif); font-size: 17px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--hair-strong); border-radius: 3px;
  padding: 12px 14px; transition: border-color .2s ease, box-shadow .2s ease;
}
.fin:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,113,178,.15); }
textarea.fin { resize: vertical; min-height: 120px; }
select.fin {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23645E51' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
.form-error { font-family: var(--mono); font-size: 12px; color: #b3402a; margin-top: 4px; }

/* ----- Demo UI --------------------------------------------------------*/
.demo-shell { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(24px, 4vw, 48px); align-items: start; }
@media (max-width: 920px) { .demo-shell { grid-template-columns: 1fr; } }
.demo-stage { background: var(--ink); border-radius: 6px; overflow: hidden; color: var(--on-dark); position: relative; }
.demo-stage video, .demo-stage canvas, .demo-stage img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* classify viewfinder fill: GPU → whole image (contain) over a blurred, zoomed copy of itself;
   lite (no GPU) → simple zoom-cover. Live video always fills (cover). */
#preview-bg, #face-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(26px) saturate(1.3); transform: scale(1.18); z-index: 0; }
#face-bg { display: none; }
#preview, #cam-video, #video, #sample-img { position: relative; z-index: 1; }
#cam-video { object-fit: cover; }
body.lite #preview-bg, body.lite #face-bg { display: none !important; }
body.lite #preview { object-fit: cover !important; }
/* viewfinder fill — EVERY breakpoint (desktop + ultrawide included): media absolute-fills the
   stage so the frame is centred (contain) over the blurred backdrop; live feed fills (cover).
   The stage itself provides the box (mobile = full-bleed, others = the --feed 4/3 stage). */
.dx-demo #preview-wrap { position: absolute; inset: 0; max-width: none; max-height: none; }
.dx-demo #preview-wrap > #preview,
.dx-demo #preview-wrap > #cam-video,
.dx-demo .demo-stage > #video,
.dx-demo .demo-stage > #sample-img { position: absolute; inset: 0; width: 100%; height: 100%; }
.dx-demo #preview-wrap > #preview { object-fit: contain; }
.dx-demo #preview-wrap > #cam-video { object-fit: cover; }
.progress { height: 4px; background: rgba(36,42,49,.12); border-radius: 4px; overflow: hidden; }
.progress__bar { height: 100%; width: 0; background: var(--accent); transition: width .25s ease; }
.dropzone {
  border: 1px dashed var(--hair-strong); border-radius: 6px; padding: 28px; text-align: center;
  font-family: var(--mono); font-size: 13px; color: var(--muted); transition: border-color .2s ease, background .2s ease;
  cursor: pointer;
}
.dropzone.is-drag { border-color: var(--accent); background: rgba(34,113,178,.05); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-dot); animation: blink 1.6s steps(1) infinite; display: inline-block; }

/* ----- Roster (deep-dive sidebar nav) --------------------------------*/
.roster { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; }
.roster__label { color: var(--muted); text-transform: uppercase; letter-spacing: .14em; }

/* ----- Utilities ------------------------------------------------------*/
.stack > * + * { margin-top: var(--stack, 16px); }
.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
[hidden] { display: none !important; }

/* dark-section link readability */
.card--navy a, .card--dark a, .demo-stage a { color: var(--gold); }

/* ----- Charts ---------------------------------------------------------*/
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px 20px; margin-bottom: 22px; }
.chart-legend__item { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .04em; color: var(--muted); }
.chart-legend__item i { width: 11px; height: 11px; border-radius: 2px; display: inline-block; }

.stacked-row { display: grid; grid-template-columns: minmax(120px, 230px) 1fr; gap: 16px; align-items: center; margin-bottom: 12px; }
.stacked-row__label { font-family: var(--mono); font-size: 11.5px; letter-spacing: .02em; color: var(--ink-2); }
.stacked-bar { display: flex; height: 22px; border-radius: 3px; overflow: hidden; background: rgba(36,42,49,.06); }
.stacked-seg { height: 100%; width: 0; }
@media (max-width: 640px) { .stacked-row { grid-template-columns: 1fr; gap: 6px; } }

.chart-axes { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(18px, 3vw, 32px); }
.axis-panel { background: var(--bg-warm); border: 1px solid var(--hair); border-radius: 4px; padding: 20px; }
.axis-panel__title { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; margin-bottom: 16px; line-height: 1.4; min-height: 2.4em; }
.axis-best { color: var(--green); }
@media (max-width: 820px) { .chart-axes { grid-template-columns: 1fr; } }

.chart-flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; }
.flow-box { flex: 1 1 160px; min-width: 140px; background: var(--bg-warm); border: 1px solid var(--hair); border-radius: 4px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.flow-box__n { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; color: var(--accent); }
.flow-box__t { font-family: var(--serif); font-size: 17px; line-height: 1.25; color: var(--ink); }
.flow-arrow { align-self: center; font-family: var(--mono); color: var(--muted); font-size: 18px; }
@media (max-width: 640px) { .flow-arrow { transform: rotate(90deg); } .chart-flow { flex-direction: column; } .flow-box { flex-basis: auto; } }

.weighted-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.weighted-node { background: var(--bg-warm); border: 1px solid var(--hair); border-radius: 4px; padding: 22px 16px; text-align: center; }
.weighted-node__t { font-family: var(--serif); font-size: 19px; color: var(--ink); }
@media (max-width: 640px) { .weighted-grid { grid-template-columns: repeat(2, 1fr); } }

/* governance ladder (ΣTMF) */
.gov-ladder { display: flex; flex-direction: column; gap: 10px; }
.gov-level { display: grid; grid-template-columns: 64px 1fr; gap: 16px; align-items: center; padding: 16px 18px; border-radius: 4px; border: 1px solid var(--hair); background: var(--bg-warm); position: relative; }
.gov-level__tag { font-family: var(--mono); font-weight: 600; font-size: 15px; letter-spacing: .04em; }
.gov-level__name { font-family: var(--serif); font-size: 18px; color: var(--ink); }
.gov-level__desc { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.5; }
.gov-level[data-lvl="0"] { border-left: 4px solid #4f9d77; }
.gov-level[data-lvl="1"] { border-left: 4px solid #8aa84a; }
.gov-level[data-lvl="2"] { border-left: 4px solid var(--gold); }
.gov-level[data-lvl="3"] { border-left: 4px solid #d08a3c; }
.gov-level[data-lvl="4"] { border-left: 4px solid var(--terracotta); background: #f7ece6; }
.gov-human { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--terracotta); }
.gov-human::before { content: '⚑'; }

/* bibtex + roster */
.bibtex__pre { font-family: var(--mono); font-size: 12px; line-height: 1.6; background: var(--bg-warm); border: 1px solid var(--hair); border-radius: 4px; padding: 18px; overflow-x: auto; white-space: pre; color: var(--ink-2); margin-top: 14px; }
.roster-list { display: flex; flex-direction: column; }
.roster-list .prow { border-top: 1px solid var(--hair); align-items: center; }

/* =====================================================================
   Bespoke motion + polish pass — coherent shadows, liquid-glass header,
   cursor-reactive cards/buttons, chart entrance + hover micro-interactions.
   ===================================================================== */
:root {
  --shadow-1: 0 1px 2px rgba(36,42,49,.05), 0 6px 16px -10px rgba(21,36,58,.20);
  --shadow-2: 0 2px 8px rgba(36,42,49,.06), 0 24px 50px -28px rgba(21,36,58,.34);
  --shadow-3: 0 40px 90px -44px rgba(21,36,58,.48);
  --glass-edge: inset 0 1px 0 rgba(255,255,255,.55);
}

/* masthead edition line now single → center it; align preprint pill+button */
.masthead__bar { justify-content: center; }
.paper-actions { align-items: center; }

/* ---- coherent shadow system (applied across surfaces) ---- */
.card { box-shadow: var(--shadow-1); transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease), background .3s var(--ease); }
.card-lift:hover { transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: var(--accent); background: var(--bg-sink); }
.demo-stage { box-shadow: var(--shadow-1); }
.btn--solid { box-shadow: var(--shadow-1); }
.btn--solid:hover { box-shadow: var(--shadow-2); }
.btn--outline:hover, .btn--ghost:hover { box-shadow: var(--shadow-1); }

/* ---- liquid-glass header (macOS-like: blur + saturation + bright edge) ---- */
.site-nav {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  box-shadow: var(--glass-edge);
  transition: background .45s var(--ease), box-shadow .45s var(--ease), border-color .45s var(--ease);
}
.site-nav.is-scrolled {
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  border-bottom-color: rgba(237,231,218,.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 12px 34px -18px rgba(0,0,0,.5);
}
.site-nav.is-scrolled .brand span, .site-nav.is-scrolled .nav-edition { color: var(--on-dark-2); }
.site-nav.is-scrolled .brand img { animation: none; filter: brightness(0) invert(.92) drop-shadow(0 1px 6px rgba(127,178,224,.45)); }
.site-nav.is-scrolled .nav-a { color: var(--on-dark-2); }
.site-nav.is-scrolled .nav-a[aria-current="page"] { color: #fff; }
.site-nav.is-scrolled .nav-a:hover { color: #fff; }
.site-nav.is-scrolled .nav-toggle span,
.site-nav.is-scrolled .nav-toggle span::before,
.site-nav.is-scrolled .nav-toggle span::after { background: var(--on-dark); }
.site-nav.is-scrolled .lang-btn { color: var(--on-dark-mut); }
.site-nav.is-scrolled .lang-btn:hover { color: #fff; background: rgba(237,231,218,.10); }
.site-nav.is-scrolled .lang-btn[aria-pressed="true"] { color: #fff; background: rgba(237,231,218,.14); }
.site-nav.is-scrolled .lang-toggle { border-color: rgba(237,231,218,.25); }
.site-nav.is-scrolled .nav-toggle { border-color: rgba(237,231,218,.25); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .site-nav { background: color-mix(in srgb, var(--bg) 95%, transparent); }
}

/* ---- cursor-reactive surfaces (JS sets the transform; these prep + fall back) ---- */
@media (hover: hover) and (pointer: fine) {
  .card-lift { will-change: transform; }
  [data-magnetic] { transition: transform .28s var(--ease); }
}

/* ---- chart entrance (on reveal) + hover micro-interactions ---- */
[data-reveal].is-visible .bar-fill { animation: barGrow 1.15s var(--ease) both; transform-origin: left center; }
[data-reveal].is-visible .weighted-node,
[data-reveal].is-visible .flow-box,
[data-reveal].is-visible .gov-level { animation: fadeUp .55s var(--ease) both; }
[data-reveal].is-visible .weighted-node:nth-child(2),
[data-reveal].is-visible .flow-box:nth-child(2),
[data-reveal].is-visible .gov-level:nth-child(2) { animation-delay: .07s; }
[data-reveal].is-visible .weighted-node:nth-child(3),
[data-reveal].is-visible .flow-box:nth-child(3),
[data-reveal].is-visible .gov-level:nth-child(3) { animation-delay: .14s; }
[data-reveal].is-visible .flow-box:nth-child(4),
[data-reveal].is-visible .gov-level:nth-child(4) { animation-delay: .21s; }
[data-reveal].is-visible .gov-level:nth-child(5) { animation-delay: .28s; }

.weighted-node, .flow-box, .axis-panel, .gov-level { transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease); }
.weighted-node:hover, .flow-box:hover, .axis-panel:hover { transform: translateY(-3px); box-shadow: var(--shadow-1); border-color: var(--hair-strong); }
.gov-level:hover { transform: translateX(5px); box-shadow: var(--shadow-1); }
.bar-row { transition: transform .25s var(--ease); }
.bar-row:hover { transform: translateX(3px); }
.bar-row:hover .bar-fill { filter: saturate(1.15) brightness(1.04); }

@media (prefers-reduced-motion: reduce) {
  [data-reveal].is-visible .bar-fill,
  [data-reveal].is-visible .weighted-node,
  [data-reveal].is-visible .flow-box,
  [data-reveal].is-visible .gov-level { animation: none; }
  .weighted-node:hover, .flow-box:hover, .axis-panel:hover, .gov-level:hover, .bar-row:hover { transform: none; }
}

/* =====================================================================
   Glass system, site-wide particle field, fixed glass footer, dynamic
   monogram, loading splash — all GPU-gated (body.lite = lightweight fallback).
   ===================================================================== */
:root {
  --glass:        color-mix(in srgb, var(--bg-warm) 66%, transparent);
  --footer-h: 0px;
}

/* more side breathing room on phones / tablets */
@media (max-width: 900px) { :root { --pad-x: clamp(36px, 6.5vw, 60px); } }
@media (max-width: 560px) { :root { --pad-x: clamp(30px, 8vw, 42px); } }

/* site-wide animated particle field (JS injects #bgfx, fixed behind everything) */
#bgfx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
body.lite #bgfx { display: none; }

/* reserve space for the fixed footer */
body { padding-bottom: var(--footer-h); }
.contact-band { padding-bottom: calc(48px + var(--footer-h)); margin-bottom: calc(-1 * var(--footer-h)); }

/* ---- glass on cards + popups (only with GPU fx + backdrop-filter support) ---- */
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  body:not(.lite) .card {
    background: var(--glass);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    border-color: rgba(255,255,255,.30);
    box-shadow: var(--shadow-2), var(--glass-edge);
  }
}

/* ---- fixed glass footer (dark navy glass — coherent with scrolled header) ---- */
.site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: color-mix(in srgb, var(--ink) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid rgba(237,231,218,.08); color: var(--on-dark-2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 -12px 34px -20px rgba(0,0,0,.5);
}
.site-footer a { color: var(--on-dark-2); }
.site-footer a:hover { color: var(--on-dark); }
.site-footer .footer-accent { color: var(--orange); }
.site-footer__inner { padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
body.lite .site-footer { -webkit-backdrop-filter: none; backdrop-filter: none; background: color-mix(in srgb, var(--navy) 96%, transparent); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .site-footer { background: color-mix(in srgb, var(--navy) 96%, transparent); } }

/* ---- dynamic monogram — cool living glow, coherent with the glass ---- */
.brand img { animation: monoGlow 7s var(--ease) infinite alternate; }
@keyframes monoGlow {
  0%   { filter: drop-shadow(0 0 0 rgba(34,113,178,0)) hue-rotate(0deg); }
  100% { filter: drop-shadow(0 2px 7px rgba(34,113,178,.5)) hue-rotate(-14deg); }
}
body.lite .brand img { animation: none; }

/* ---- loading splash — centered monogram, strong glass, fades on load ---- */
#splash {
  position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bg) 56%, transparent);
  -webkit-backdrop-filter: blur(30px) saturate(150%); backdrop-filter: blur(30px) saturate(150%);
  transition: opacity .5s var(--ease), visibility .5s var(--ease);
}
#splash img { width: 60px; height: auto; animation: splashPulse 1.4s var(--ease) infinite; }
#splash.is-hidden { opacity: 0; visibility: hidden; }
@keyframes splashPulse { 0%,100% { opacity: .45; transform: scale(.95); } 50% { opacity: 1; transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { #splash img, .brand img { animation: none; } }

/* ---- model-loading overlay inside the viewfinder (monogram pulse) ---- */
.dx-loading {
  position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px;
  background: color-mix(in srgb, #0b1320 64%, transparent);
  -webkit-backdrop-filter: blur(8px) saturate(140%); backdrop-filter: blur(8px) saturate(140%);
}
.dx-loading[hidden] { display: none; }
.dx-loading img { width: 56px; height: auto; filter: brightness(0) invert(.92) drop-shadow(0 1px 8px rgba(127,178,224,.45)); animation: splashPulse 1.4s var(--ease) infinite; }
.dx-loading__txt  { font-family: var(--mono); font-size: 13px; letter-spacing: .08em; color: var(--on-dark); margin: 0; }
.dx-loading__hint { font-family: var(--mono); font-size: 11px; letter-spacing: .04em; color: var(--on-dark-mut); margin: 0; max-width: 280px; }
@media (prefers-reduced-motion: reduce) { .dx-loading img { animation: none; } }

/* header edition tag (collapsed from the old masthead bar) */
.nav-edition { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--slate); white-space: nowrap; transition: color .4s ease; }
@media (max-width: 720px) { .nav-edition { display: none; } }

/* clickable accent pill (e.g. request preprint via contact) */
.badge--accent { color: var(--accent-ink); border-color: rgba(34,113,178,.4); }
a.badge { text-decoration: none; cursor: pointer; transition: background .2s var(--ease), transform .2s var(--ease), border-color .2s var(--ease); }
a.badge:hover { background: rgba(34,113,178,.10); border-color: rgba(34,113,178,.6); transform: translateY(-1px); }

/* =====================================================================
   Dark "experience" theme for live-demo pages (body.dx) — inverted palette,
   sectioned vertical scroll with soft blending, the demo as the protagonist.
   ===================================================================== */
body.dx {
  background:
    radial-gradient(1100px 700px at 76% -8%, rgba(34,113,178,.20), transparent 60%),
    linear-gradient(180deg, #15243A 0%, #101b2c 55%, #0c1422 100%);
  background-attachment: fixed;
  color: var(--on-dark);
}
body.dx #bgfx { opacity: .6; }

/* dark glass header / footer (keep the inherited backdrop-filter, recolor) */
.dx .site-nav { background: color-mix(in srgb, #15243A 55%, transparent); border-bottom-color: rgba(237,231,218,.10); box-shadow: inset 0 1px 0 rgba(255,255,255,.07); }
.dx .site-nav.is-scrolled { background: color-mix(in srgb, #15243A 72%, transparent); border-bottom-color: rgba(237,231,218,.16); }
.dx .brand span, .dx .nav-edition { color: var(--on-dark-2); }
.dx .brand img { animation: none; filter: brightness(0) invert(.92) drop-shadow(0 1px 6px rgba(127,178,224,.45)); }
.dx #splash { background: color-mix(in srgb, #0c1422 62%, transparent); }
.dx #splash img { filter: brightness(0) invert(.92); }
.dx .nav-a { color: var(--on-dark-2); }
.dx .nav-a[aria-current="page"] { color: #fff; }
.dx .nav-toggle span, .dx .nav-toggle span::before, .dx .nav-toggle span::after { background: var(--on-dark); }
.dx .lang-btn { color: var(--on-dark-mut); }
.dx .lang-btn:hover { color: #fff; background: rgba(237,231,218,.10); }
.dx .lang-btn[aria-pressed="true"] { color: #fff; background: rgba(237,231,218,.14); }
.dx .site-footer { background: color-mix(in srgb, #15243A 60%, transparent); border-top-color: rgba(237,231,218,.10); color: var(--on-dark-mut); box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 -12px 34px -20px rgba(0,0,0,.5); }
.dx .site-footer a { color: var(--on-dark-2); }
.dx .site-footer a:hover { color: #fff; }
.dx .site-footer .footer-accent { color: var(--orange); }

/* typography + surfaces on dark */
.dx .eyebrow { color: #7fb2e0; }
.dx .section-title, .dx h1, .dx h2, .dx h3 { color: #fff; }
.dx .lead { color: var(--on-dark-2); }
.dx .collabel, .dx .mono, .dx .status { color: var(--on-dark-mut); }
.dx .note { color: var(--on-dark-2); border-left-color: rgba(237,231,218,.28); }
.dx .note--warn { border-left-color: var(--orange); }
body.dx .card { background: color-mix(in srgb, #1b2c44 72%, transparent); border-color: rgba(237,231,218,.14); box-shadow: var(--shadow-3), inset 0 1px 0 rgba(255,255,255,.05); color: var(--on-dark-2); }
.dx .fin { background: rgba(12,20,34,.6); border-color: rgba(237,231,218,.18); color: var(--on-dark); }
.dx .fin:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,113,178,.28); }
.dx .btn--solid { background: var(--accent); color: #fff; border-color: var(--accent); }
.dx .btn--outline { color: var(--on-dark); border-color: rgba(237,231,218,.30); }
.dx .btn--outline:hover { background: rgba(237,231,218,.08); }
.dx .btn--ghost { color: var(--on-dark-2); background: rgba(237,231,218,.05); border-color: rgba(237,231,218,.22); }
.dx .btn--ghost:hover { color: #fff; background: rgba(237,231,218,.10); border-color: rgba(237,231,218,.45); }
.dx .badge { color: var(--on-dark-2); border-color: rgba(237,231,218,.22); }
.dx .badge--accent { color: #7fb2e0; border-color: rgba(127,178,224,.5); }
.dx .demo-stage { background: #0b1320; border: 1px solid rgba(127,178,224,.34); box-shadow: var(--shadow-3); }
.dx .progress { background: rgba(237,231,218,.12); }

/* ----- sectioned scroll + soft blending ----- */
.dx-section { padding: clamp(40px, 8vh, 92px) 0; position: relative; }
.dx-hero { min-height: 76vh; display: flex; align-items: center; }
.dx-hero .section-title { font-size: clamp(34px, 6vw, 72px); line-height: 1.03; }
.dx-stage { padding-top: 0; }
.dx-section + .dx-section::before { content: ''; position: absolute; top: 0; left: 8%; right: 8%; height: 1px; background: linear-gradient(90deg, transparent, rgba(237,231,218,.16), transparent); }
/* old in-info cue — kept hidden; replaced by .dx-cue-mobile */
.dx-cue { display: none; }

/* mobile scroll cue — visible only below 768px */
.dx-cue-mobile {
  margin: clamp(18px,4vh,36px) 0; font-family: var(--mono); font-size: 11px;
  letter-spacing: .22em; text-transform: uppercase; color: var(--on-dark-mut);
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.dx-cue-mobile::after { content: '↓'; animation: cueBob 1.8s var(--ease) infinite; }
@keyframes cueBob { 0%,100% { transform: translateY(0); opacity: .55; } 50% { transform: translateY(5px); opacity: 1; } }
@media (min-width: 768px) { .dx-cue-mobile { display: none; } }
@media (prefers-reduced-motion: reduce) { .dx-cue-mobile::after { animation: none; } }

/* animated up-arrow between back link and codename — only when description out of view */
.dx-back__up {
  background: none; border: 1px solid rgba(237,231,218,.18); border-radius: 50%;
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--on-dark-mut); cursor: pointer;
  transition: color .25s ease, border-color .25s ease, opacity .3s ease, transform .3s ease;
  animation: arrowBob 2s var(--ease) infinite;
  opacity: 0; visibility: hidden; pointer-events: none;
}
.dx-back__up.is-visible { opacity: 1; visibility: visible; pointer-events: auto; }
.dx-back__up:hover { color: #fff; border-color: rgba(237,231,218,.35); }
@keyframes arrowBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) { .dx-back__up { animation: none; } }

/* ===== unified demo shell — 1 / 2 / 3 responsive blocks ===== */
.dx-back { margin: 18px 0 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: nowrap; }
.dx-back > .btn { flex: 0 0 auto; }
.dx-back .dx-codename { margin: 0; flex: 0 0 auto; align-self: center; line-height: 1.1; }

/* quick-start tutorial on the description screen */
.dx-steps { margin-top: 20px; }
.dx-steps__title { font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: #7fb2e0; margin: 0 0 10px; }
.dx-steps ol { margin: 0; padding: 0; list-style: none; counter-reset: dxstep; display: flex; flex-direction: column; gap: 10px; }
.dx-steps li { counter-increment: dxstep; position: relative; padding-left: 36px; font-size: 15px; line-height: 1.5; color: var(--on-dark-2); }
.dx-steps li::before {
  content: counter(dxstep); position: absolute; left: 0; top: -1px;
  width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px; color: #7fb2e0; border: 1px solid rgba(127,178,224,.4); background: rgba(127,178,224,.08);
}
.dx-shell { display: grid; gap: clamp(26px, 4vw, 60px); align-items: center; padding: clamp(18px, 3.5vh, 36px) 0; }
.dx-info, .dx-readout, .dx-demo { width: 100%; min-width: 0; }
.dx-title { font-family: var(--serif); font-weight: 500; font-size: clamp(30px, 4.4vw, 52px); line-height: 1.03; color: #fff; margin: 10px 0 0; letter-spacing: -.01em; }
.dx-info .lead { margin-top: 16px; }
.dx-info { transition: opacity .3s var(--ease); }
/* one-word Italian codename above the title */
.dx-codename { font-family: var(--serif); font-style: italic; font-size: clamp(16px, 1.7vw, 21px); color: #7fb2e0; letter-spacing: .01em; margin: 0 0 4px; }
/* functional name under the codename title */
.dx-subtitle { font-family: var(--serif); font-style: italic; font-size: clamp(16px, 1.9vw, 22px); color: var(--on-dark-2); margin: 6px 0 0; line-height: 1.2; }
.dx-demo .demo-stage { max-height: min(64vh, 620px); margin-inline: auto; width: 100%; }
.dx-readout { display: flex; flex-direction: column; gap: 12px; }
/* classify verdict is integrated on the feed (HUD) → no separate outside readout, any viewport */
body[data-page="demo-classify"] .dx-readout { display: none; }
.dx-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }

/* ----- mobile (default): two snap screens — [description + cue] and [demo] ----- */
.dx-shell { grid-template-columns: 1fr; }
.dx-demo, .dx-readout { grid-column: 1; }
/* mandatory snap lives on the document scroller (only on demo pages, only on phones) */
@media (max-width: 767px) {
  /* header height reserved so snapped screens never hide under the sticky nav */
  html:has(.dx-shell) { scroll-snap-type: y mandatory; scroll-padding-top: 68px; }
  /* screen 1 anchor = the back row (keeps it clear of the header); description centred below */
  .dx-back { scroll-snap-align: start; scroll-snap-stop: always; scroll-margin-top: 68px; }
  .dx-shell { padding-top: 0; }
  .dx-info {
    /* centre the tutorial in the space left between the sticky header and the fixed footer */
    min-height: calc(100dvh - 68px - 50px - var(--footer-h, 48px));
    display: flex; flex-direction: column; justify-content: center;
  }
  .dx-cue-mobile { margin-top: clamp(20px, 4vh, 36px); }
  /* screen 2: full-bleed, full-height demo — the dark-glass header + footer float over it;
     -68 scroll-margin pulls the stage top to y=0 so the header overlays the feed */
  .dx-demo {
    scroll-snap-align: start; scroll-snap-stop: always; scroll-margin-top: -68px;
    min-height: 100dvh;
    margin-inline: calc(50% - 50vw); width: 100vw;
    padding: 0; display: flex; flex-direction: column;
  }
  .dx-demo { position: relative; }
  .dx-demo .demo-stage { flex: 1; max-height: none; width: 100%; border-radius: 0; aspect-ratio: auto; }
  /* media FILLS the full-screen stage. iOS Safari does not resolve height:100% on a flex-item's
     child, so the <video>/<img> shrank to intrinsic size (top-anchored, empty below) while the
     absolute canvas filled — the detection box floated in the gap. Absolute-fill all of them so
     feed, sample image and overlay occupy the exact same box → feed fills + box aligns. */
  .dx-demo .demo-stage > #video,
  .dx-demo .demo-stage > #sample-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  /* classify wraps its media in #preview-wrap — fill the stage with it too */
  #preview-wrap { position: absolute !important; inset: 0; max-width: none !important; max-height: none !important; }
  #preview-wrap #preview, #preview-wrap #cam-video { position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-width: none !important; max-height: none !important; object-fit: contain; }
  #preview-wrap #cam-video { object-fit: cover; }
  /* camera-permission error floats above the controls; hide the rest (the on-feed HUD covers
     state, the model note lives in Details) so nothing overlaps the bottom HUD/selectors */
  .dx-demo > #cam-error { position: absolute; left: 16px; right: 16px; bottom: calc(var(--footer-h, 48px) + 84px); z-index: 6; margin: 0; text-align: center; }
  .dx-demo > .progress, .dx-demo > #status, .dx-demo > #faceapi-cam-note { display: none; }
  /* on-feed pills: top below the floating back arrow, bottom above the footer.
     .dx-ovl.dx-ovl--top = 3 classes (0,3,0) → beats the later .dx-ovl--top.dx-ovl--split (0,2,0).
     ALWAYS visible + clickable (no JS opacity gating — that could hide the controls). */
  .dx-demo .dx-ovl.dx-ovl--top    { top: calc(68px + 70px + env(safe-area-inset-top)); bottom: auto; left: 14px; right: 14px; }
  .dx-demo .dx-ovl.dx-ovl--bottom { bottom: calc(var(--footer-h, 48px) + 30px); top: auto; left: 14px; right: 14px; }
  .dx-demo .dx-ovl { opacity: 1; }
  /* floating glass "back to info" button — own row above the top pills, centred */
  .dx-back__up.is-visible {
    position: fixed; top: calc(68px + 16px + env(safe-area-inset-top)); left: 50%;
    z-index: 46; width: 40px; height: 40px; font-size: 18px;
    background: rgba(244,240,231,.6); color: #10192b; border: 1px solid rgba(16,25,43,.3);
    -webkit-backdrop-filter: saturate(170%) blur(13px); backdrop-filter: saturate(170%) blur(13px);
    box-shadow: 0 6px 18px -8px rgba(0,0,0,.5);
    animation: arrowBobCenter 2s var(--ease) infinite;   /* centred bob keeps the -50% x offset */
  }
  .dx-back__up.is-visible:hover { color: #10192b; background: rgba(244,240,231,.78); border-color: var(--accent); }
  @keyframes arrowBobCenter { 0%,100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -4px); } }
  @media (prefers-reduced-motion: reduce) { .dx-back__up.is-visible { animation: none; transform: translateX(-50%); } }
}

/* ----- tablet / desktop: TWO blocks ~40/60, the whole demo fits in one screen (no page scroll) ----- */
@media (min-width: 768px) {
  /* lock demo pages to a single viewport — header + back row + shell + footer all fit */
  body:has(.dx-shell) { overflow: hidden; }
  /* available height = viewport − header − back row − footer */
  .dx-shell {
    grid-template-columns: minmax(0, 0.66fr) minmax(0, 1fr);
    height: calc(100dvh - 58px - 64px - var(--footer-h, 48px)); min-height: 0;
    align-content: center; padding-block: 0; scroll-snap-type: none;
  }
  .dx-info    { display: block; grid-column: 1; grid-row: 1 / span 2; align-self: center; min-height: 0; scroll-snap-align: none; }
  .dx-demo    { grid-column: 2; grid-row: 1; align-self: center; min-height: 0; scroll-snap-align: none; }
  /* cap the stage to the height actually available so nothing overflows the screen */
  .dx-demo .demo-stage { flex: 0 1 auto; max-height: calc(100dvh - 58px - 64px - var(--footer-h, 48px)); }
  .dx-shell--feed .demo-stage { aspect-ratio: 4 / 3; }   /* face stage shape on desktop (mobile fills the screen) */
  .dx-readout { grid-column: 2; grid-row: 2; min-height: 0; }
}
/* ----- ultrawide: THREE blocks — info | readout | feed ----- */
@media (min-width: 1600px) {
  body.dx #main.wrap { max-width: 1580px; }
  .dx-shell   { grid-template-columns: minmax(0, 0.6fr) minmax(0, 0.78fr) minmax(0, 1.6fr); }
  .dx-info    { grid-column: 1; grid-row: 1; align-self: center; }
  .dx-readout { grid-column: 2; grid-row: 1; align-self: center; }
  .dx-demo    { grid-column: 3; grid-row: 1; align-self: center; }
}

/* ----- tablet / large PORTRAIT: one screen, stacked — description on top, demo fills the rest ----- */
@media (min-width: 768px) and (orientation: portrait) {
  .dx-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    height: calc(100dvh - 58px - 64px - var(--footer-h, 48px));
    align-content: stretch;
    /* top pad clears the back button · bottom pad clears the floating footer · row-gap separates info/demo;
       all three eat into the demo row, so the viewfinder ends up shorter (the "menos alto" the user asked for) */
    padding: clamp(12px, 2.6vh, 28px) 0 clamp(10px, 2vh, 22px);
    row-gap: clamp(12px, 2.2vh, 24px);
  }
  .dx-info { grid-column: 1; grid-row: 1; align-self: start; }
  .dx-demo {
    grid-column: 1; grid-row: 2; align-self: stretch; min-height: 0;
    position: relative; display: flex; flex-direction: column;
  }
  /* stage fills the lower row; the feed fills the stage (mirror the mobile absolute-fill so
     the image/feed centres and never top-anchors) */
  .dx-demo .demo-stage { flex: 1; width: 100%; height: auto; max-height: none; aspect-ratio: auto; position: relative; }
  .dx-demo .demo-stage > #video,
  .dx-demo .demo-stage > #sample-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
  #preview-wrap { position: absolute !important; inset: 0; max-width: none !important; max-height: none !important; }
  #preview-wrap #preview, #preview-wrap #cam-video { position: absolute; inset: 0; width: 100% !important; height: 100% !important; max-width: none !important; max-height: none !important; object-fit: contain; }
  #preview-wrap #cam-video { object-fit: cover; }
}

/* ===== on-feed controls — glass pills, auto-contrast vs the feed ===== */
.demo-stage { position: relative; overflow: hidden;
  /* adaptive palette: JS overwrites from sampled feed luminance. defaults assume a dark feed */
  --pill-bg: rgba(244,240,231,.5); --pill-ink: #10192b; --pill-ring: rgba(16,25,43,.34);
  --pill-on-bg: var(--accent); --pill-on-ink: #fff; }
.dx-ovl { position: absolute; z-index: 4; display: flex; gap: 8px; flex-wrap: wrap; max-width: calc(100% - 24px); }
.dx-ovl--top    { top: 12px; left: 12px; }
.dx-ovl--bottom { left: 12px; right: 12px; bottom: 12px; justify-content: center; }
.dx-pill, .dx-seldrop {
  font-family: var(--mono); font-size: 12px; letter-spacing: .03em; line-height: 1; white-space: nowrap;
  padding: 9px 14px; border-radius: 999px; cursor: pointer;
  color: var(--pill-ink); background: var(--pill-bg); border: 1px solid var(--pill-ring);
  -webkit-backdrop-filter: blur(11px) saturate(160%); backdrop-filter: blur(11px) saturate(160%);
  box-shadow: 0 3px 12px rgba(0,0,0,.2); text-shadow: 0 1px 2px rgba(0,0,0,.12);
  transition: background .25s var(--ease), color .25s var(--ease), border-color .25s var(--ease), transform .18s var(--ease); }
.dx-pill:hover, .dx-seldrop:hover { transform: translateY(-1px); border-color: var(--pill-ink); }
/* selected pill: tinted, NOT opaque — keeps the backdrop refraction visible through it (opaque
   accent used to paint over the glass, so the effect "disappeared" the moment a pill was chosen) */
.dx-pill.is-on { background: rgba(34,113,178,.6); background: color-mix(in srgb, var(--pill-on-bg) 60%, transparent); color: var(--pill-on-ink); border-color: var(--pill-on-bg); text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.dx-pill[hidden] { display: none; }
.dx-pill:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.dx-pill--icon { display: inline-flex; align-items: center; gap: 7px; }
.dx-pill svg { width: 14px; height: 14px; flex: none; }
/* caption/legend below the feed (legible on dark) */
.dx-legend { font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--on-dark-2); max-width: 540px; margin: 10px auto 0; text-align: center; }
.dx-pill.is-drag { outline: 2px dashed var(--pill-on-bg); outline-offset: 2px; }
/* integrated dropdown for >2 options, styled as a glass pill */
.dx-seldrop { -webkit-appearance: none; appearance: none; padding-right: 30px;
  background-image: linear-gradient(transparent, transparent), url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23ffffff' stroke-width='1.5'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; }
.dx-seldrop option { color: #10192b; background: #F4F0E7; }

/* two HUD bars (top/bottom) split left/right, integrated into the viewfinder */
.dx-ovl--split { left: 12px; right: 12px; justify-content: space-between; align-items: flex-start; gap: 10px; }
.dx-ovl--top.dx-ovl--split { top: 12px; }
.dx-ovl--bottom.dx-ovl--split { bottom: 12px; align-items: flex-end; }
.dx-srcgroup, .dx-selgroup, .dx-enrollgroup { display: flex; gap: 8px; flex-wrap: wrap; }
.dx-selgroup { flex-direction: column; align-items: flex-end; justify-content: flex-end; gap: 6px; margin-left: auto; }
.dx-selgroup .dx-seldrop { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
/* on-feed result HUD (age · gender · match) */
.dx-hud { max-width: min(56%, 320px); padding: 12px 14px; border-radius: 12px; font-family: var(--mono);
  color: var(--pill-ink); background: var(--pill-bg); border: 1px solid var(--pill-ring);
  -webkit-backdrop-filter: blur(11px) saturate(160%); backdrop-filter: blur(11px) saturate(160%);
  box-shadow: 0 3px 12px rgba(0,0,0,.22); }
.dx-hud__row { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.dx-hud__main { font-family: var(--serif); font-size: clamp(18px, 2.3vw, 24px); margin-top: 4px; line-height: 1.1; }
.dx-hud__main span { font-weight: 500; }
.dx-hud__match { margin-top: 8px; font-size: 11px; }
.dx-hud__match .bar-track { margin-top: 5px; }
.dx-hud__desc { font-size: 12px; margin-top: 6px; opacity: .85; }
.dx-hud .collabel { display: none; }
.dx-hud #age-model-tag { font-size: 10px; opacity: .7; margin-top: 4px; }

/* ===== liquid glass (iOS-style) =====
   On Chromium (html.glass-liquid, set in JS) the backdrop is bent through the SVG displacement
   filter for real refraction — the rounded-rect form is "felt" through edge lensing of whatever
   sits behind. No fake specular rim: the element keeps its original 1px border. Safari/Firefox
   fall back to the plain blurred glass; nothing breaks. */
.dx-pill, .dx-hud, .dx-loading { position: relative; isolation: isolate; }
html.glass-liquid .dx-pill,
html.glass-liquid .dx-seldrop,
html.glass-liquid .dx-hud {
  /* light blur so the rim lens stays visible; text legibility comes from the text-shadow */
  -webkit-backdrop-filter: url(#liquid-glass) blur(3px) saturate(175%);
  backdrop-filter: url(#liquid-glass) blur(3px) saturate(175%);
}
html.glass-liquid .dx-loading,
html.glass-liquid .dx-modal__card {
  -webkit-backdrop-filter: url(#liquid-glass-lg) blur(9px) saturate(150%);
  backdrop-filter: url(#liquid-glass-lg) blur(9px) saturate(150%);
}
html.glass-liquid .site-nav,
html.glass-liquid .dx .site-nav,
html.glass-liquid .site-footer,
html.glass-liquid .dx .site-footer {
  -webkit-backdrop-filter: url(#liquid-glass-lg) blur(13px) saturate(155%);
  backdrop-filter: url(#liquid-glass-lg) blur(13px) saturate(155%);
}
/* lite (no GPU / slow) keeps the plain blurred glass; the displacement layer never loads there. */
@media (prefers-reduced-transparency: reduce) {
  html.glass-liquid .dx-pill, html.glass-liquid .dx-seldrop, html.glass-liquid .dx-hud,
  html.glass-liquid .dx-loading, html.glass-liquid .site-nav, html.glass-liquid .site-footer,
  html.glass-liquid .dx .site-nav, html.glass-liquid .dx .site-footer { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* face + classify keep 2 columns even on ultrawide (their result lives on the feed) */
@media (min-width: 1600px) {
  .dx-shell--feed,
  body[data-page="demo-classify"] .dx-shell { grid-template-columns: minmax(0, 0.6fr) minmax(0, 1.7fr); }
  .dx-shell--feed .dx-info,
  body[data-page="demo-classify"] .dx-info { grid-column: 1; grid-row: 1; }
  .dx-shell--feed .dx-demo,
  body[data-page="demo-classify"] .dx-demo { grid-column: 2; grid-row: 1; }
}

/* details / how-it-works modal (declutters the long notes) */
.dx-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(8,14,24,.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); opacity: 0; transition: opacity .3s var(--ease); }
.dx-modal[hidden] { display: none; }
.dx-modal.open { opacity: 1; }
.dx-modal__card { max-width: 600px; max-height: 86vh; overflow: auto; padding: 28px; position: relative; }
.dx-modal__title { font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 0 0 14px; }
.dx-modal__x { position: absolute; top: 10px; right: 14px; background: none; border: 0; font-size: 26px; line-height: 1; color: inherit; cursor: pointer; opacity: .55; transition: opacity .2s ease; }
.dx-modal__x:hover { opacity: 1; }
.dx-modal .note { margin: 10px 0; }

/* ---- color-mix fallback (Safari <16.2, Firefox <113): solid glass surfaces ---- */
@supports not (background: color-mix(in srgb, red, transparent)){
  .site-nav{ background:#f4f0e8; }
  .site-nav.is-scrolled{ background:#2e343b; }
  .site-footer{ background:#2e343b; }
  .dx .site-nav{ background:#15243a; }
  .dx .site-nav.is-scrolled{ background:#101b2c; }
  .dx .site-footer{ background:#101b2c; }
  body.dx .card{ background:#1b2c44; }
  #splash{ background:#f4f0e8; }
  .dx #splash{ background:#0c1422; }
  .dx-loading{ background:#0b1320; }
}
