/* =====================================================================
   atlas.css -- human anatomy atlas
   visual language: dark ink, hairline gold, museum instrument
   tokens are re-declared here so the page stands alone
   ===================================================================== */
:root {
  --bg-dark: #0a0a0f;
  --bg-card: #111118;
  --bg-card-hover: #16161f;
  --ink: #f0f0f5;
  --ink-muted: #8888a0;
  --ink-dim: #555570;
  --gold: #c5a059;
  --gold-light: #edd892;
  --border: #1e1e2a;
  --hair: rgba(255,255,255,0.07);
  --hair-strong: rgba(255,255,255,0.13);
  --accent: #6cd7c2;
  --font: 'Source Sans 3', system-ui, sans-serif;
  --mono: 'Source Code Pro', ui-monospace, monospace;
  --rail-w: 268px;
  --rail-w-r: 300px;
  --nav-h: 56px;
  --mast-h: 118px;
  --dock-h: 74px;
  --ease: cubic-bezier(.22,.61,.36,1);
}
*, *before, *after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg-dark); }
body {
  font-family: var(--font);
  font-weight: 300;
  color: var(--ink);
  background: var(--bg-dark);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 3px; }
::selection { background: rgba(197,160,89,.3); color: var(--ink); }
img, canvas { max-width: 100%; }

/* ---------------- backdrop field ---------------- */
.bg-field { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-aurora { position: absolute; border-radius: 50%; filter: blur(72px); opacity: .5; }
.bg-aurora-1 {
  width: 46vw; height: 46vw; left: -8vw; top: 6vh;
  background: radial-gradient(circle at 30% 30%, rgba(197,160,89,.16), transparent 68%);
  animation: drift-1 34s var(--ease) infinite alternate;
}
.bg-aurora-2 {
  width: 40vw; height: 40vw; right: -6vw; bottom: -4vh;
  background: radial-gradient(circle at 60% 40%, rgba(108,215,194,.09), transparent 66%);
  animation: drift-2 41s var(--ease) infinite alternate;
}
@keyframes drift-1 { to { transform: translate3d(6vw,4vh,0) scale(1.12); } }
@keyframes drift-2 { to { transform: translate3d(-5vw,-3vh,0) scale(1.08); } }
.bg-grid {
  position: absolute; inset: 0; opacity: .5;
  background-image:
    linear-gradient(to right, rgba(255,255,255,.028) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,.028) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px;
  mask-image: radial-gradient(ellipse at 50% 34%, #000 12%, transparent 76%);
}
.bg-noise {
  position: absolute; inset: 0; opacity: .035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.85' numOctaves='4' stitchTiles='stitch' type='fractalNoise'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: 70; pointer-events: none;
  background: rgba(6,6,10,.62); opacity: 0; transition: opacity .3s var(--ease);
}
html.rail-open-left body::after, html.rail-open-right body::after { opacity: 1; pointer-events: auto; }

/* ---------------- nav ---------------- */
.nav {
  position: sticky; top: 0; z-index: 60; height: var(--nav-h);
  background: rgba(10,10,15,.9); backdrop-filter: blur(12px) saturate(1.2);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 22px;
  display: flex; align-items: center; justify-content: space-between; height: 100%; gap: 18px;
}
.nav-brand {
  font-size: 14px; font-weight: 500; letter-spacing: -.1px; color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; gap: 9px; white-space: nowrap;
}
.nav-brand .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 0 3px rgba(197,160,89,.14);
}
.nav-links { display: flex; gap: 24px; list-style: none; margin: 0; padding: 0; overflow-x: auto; scrollbar-width: none; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  position: relative; display: block; padding: 7px 0; font-size: 12.5px;
  color: var(--ink-muted); text-decoration: none; transition: color .18s var(--ease); white-space: nowrap;
}
.nav-links a::after {
  content: ''; position: absolute; left: 0; right: 100%; bottom: 0; height: 1px;
  background: linear-gradient(to right, var(--gold), transparent); transition: right .3s var(--ease);
}
.nav-links a:hover { color: var(--gold); }
.nav-links a:hover::after, .nav-links a.active::after { right: 0; }
.nav-links a.active { color: var(--gold-light); }

/* ---------------- masthead ---------------- */
.masthead { display: none; }
.mast-inner {
  max-width: 1320px; margin: 0 auto; padding: 0 22px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 26px; flex-wrap: wrap;
}
.kicker {
  font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .2em;
  text-transform: uppercase; color: var(--gold); margin-bottom: 8px;
}
.mast-copy h1 {
  margin: 0; font-size: clamp(25px, 3.6vw, 41px); font-weight: 300;
  letter-spacing: -1.1px; line-height: 1.04; color: var(--ink);
}
.lead {
  margin: 9px 0 0; max-width: 62ch; font-size: 13.4px; font-weight: 300;
  color: var(--ink-muted); line-height: 1.62; text-wrap: pretty;
}
.mast-stats { display: flex; gap: 26px; align-items: flex-end; }
.stat { display: flex; flex-direction: column; gap: 3px; padding-left: 11px; border-left: 1px solid var(--border); }
.stat b {
  font-family: var(--mono); font-size: 19px; font-weight: 500; color: var(--gold-light);
  letter-spacing: -.4px; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat span {
  font-family: var(--mono); font-size: 9px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-dim);
}

/* ---------------- glass primitive ---------------- */
.glass {
  background: linear-gradient(160deg, rgba(20,20,28,.82), rgba(13,13,19,.78));
  backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--hair);
  border-radius: 4px;
  box-shadow: 0 26px 60px -28px rgba(0,0,0,.9), inset 0 1px 0 rgba(255,255,255,.045);
}

/* ---------------- stage ---------------- */
.stage {  /* the stage must not become a stacking island: an explicit index here would trap the fixed rails under the drawer scrim and eat every tap meant for a search result row; see tools/probe_pile.py */

  position: relative; z-index: auto;
  display: grid;
  grid-template-columns: minmax(0, var(--rail-w)) minmax(0, 1fr) minmax(0, var(--rail-w-r));
  gap: 12px; padding: 4px 22px 0;
  max-width: 1320px; margin: 0 auto; align-items: start;
}

/* ---------------- rails ---------------- */
.rail {
  display: flex; flex-direction: column; min-height: 0;
  max-height: calc(100dvh - var(--nav-h) - var(--mast-h) - var(--dock-h) - var(--foot-h, 78px) - 26px);
  overflow-y: auto; overflow-x: hidden; padding: 13px 12px 10px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  scrollbar-width: 8px;
}
.rail::-webkit-scrollbar { width: 7px; }
.rail::-webkit-scrollbar-thumb { background: #23232f; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.rail::-webkit-scrollbar-thumb:hover { background: #34343f; background-clip: padding-box; }
.rail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 11px; flex-wrap: wrap; }
.rail-title {
  font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: .19em;
  text-transform: uppercase; color: var(--gold);
}
.rail-actions { display: flex; gap: 5px; }
.mini {
  font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-dim); background: transparent; border: 1px solid var(--border);
  border-radius: 3px; padding: 4px 7px; cursor: pointer;
  transition: color .18s, border-color .18s, background .18s;
}
.mini:hover { color: var(--gold); border-color: rgba(197,160,89,.45); background: rgba(197,160,89,.07); }

/* search */
.searchbox { position: relative; display: flex; align-items: center; margin-bottom: 11px; }
.searchbox .ico {
  position: absolute; left: 9px; width: 13px; height: 13px; fill: none;
  stroke: var(--ink-dim); stroke-width: 1.6; pointer-events: none;
}
.searchbox input {
  width: 100%; padding: 9px 28px 9px 28px; font-family: var(--font); font-size: 12.5px;
  color: var(--ink); background: rgba(8,8,12,.72); border: 1px solid var(--border);
  border-radius: 3px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.searchbox input::placeholder { color: var(--ink-dim); opacity: 1; }
.searchbox input:focus { border-color: rgba(197,160,89,.5); box-shadow: 0 0 0 3px rgba(197,160,89,.08); }
.searchbox input::-webkit-search-cancel-button { display: none; }
.searchbox .clear {
  position: absolute; right: 6px; width: 18px; height: 18px; padding: 0;
  border: none; background: transparent; color: var(--ink-dim); cursor: pointer;
  font-size: 12px; line-height: 1; border-radius: 50%;
}
.searchbox .clear:hover { color: var(--gold); }
.searchbox .clear[hidden] { display: none; }

/* system items */
.sys-list { display: flex; flex-direction: column; gap: 1px; }
.sys-item {
  display: grid; grid-template-columns: 3px 1fr auto; align-items: center; gap: 9px;
  width: 100%; padding: 7px 8px 7px 0; text-align: left; cursor: pointer;
  background: transparent; border: none; border-bottom: 1px solid rgba(255,255,255,.028);
  border-radius: 2px; transition: background .2s var(--ease);
}
.sys-item:hover { background: rgba(255,255,255,.03); }
.sys-bar { width: 3px; height: 17px; border-radius: 2px; opacity: .3; transition: opacity .25s, box-shadow .25s; }
.sys-name {
  font-size: 12.2px; color: #eceef5; letter-spacing: -.1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .2s;
}
.sys-count {
  font-family: var(--mono); font-size: 9.5px; color: #a8aec4;
  font-variant-numeric: tabular-nums; opacity: .8;
}
.sys-item[aria-pressed=true] .sys-bar { opacity: 1; box-shadow: 0 0 9px rgba(255,255,255,.16); }
.sys-item[aria-pressed=true] .sys-name { color: var(--ink); }
.sys-item[aria-pressed=true] .sys-count { color: var(--gold); opacity: 1; }
.sys-item[aria-pressed=true] { background: linear-gradient(to right, rgba(197,160,89,.09), transparent 70%); }
.sys-list[hidden] { display: none; }

/* results */
.results-head {
  display: flex; gap: 5px; align-items: baseline; margin: 2px 0 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold);
}
.results-head[hidden] { display: none; }
#results-count { font-size: 12px; color: var(--gold-light); }
.results { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.result-item {
  display: grid; grid-template-columns: auto 1fr 7px; align-items: center; gap: 9px;
  width: 100%; padding: 7px 8px 7px 6px; text-align: left; cursor: pointer;
  background: transparent; border: none; border-left: 1px solid transparent;
  border-radius: 2px; transition: background .2s, border-color .2s;
}
.result-item:hover { background: rgba(197,160,89,.07); border-left-color: var(--gold); }
.result-item.active { background: rgba(197,160,89,.12); border-left-color: var(--gold-light); }
.res-num { font-family: var(--mono); font-size: 8.5px; color: var(--ink-dim); font-style: normal; }
.res-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.res-fr { font-size: 12.2px; font-weight: 400; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-en { font-style: normal; font-family: var(--mono); font-size: 8.6px; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-dot { width: 7px; height: 7px; border-radius: 50%; opacity: .85; }
.empty { font-size: 11.5px; color: var(--ink-dim); text-align: left; margin: 6px 0; font-style: italic; }
.empty[hidden] { display: none; }

.rail-foot { margin-top: auto; padding-top: 12px; }
.legend-line { display: flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim); }
#visible-count { color: var(--gold-light); font-size: 11px; }
.pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* ---------------- viewport ---------------- */
.viewport {
  position: relative; grid-column: 2; min-width: 0;
  height: calc(100dvh - var(--nav-h) - var(--mast-h) - var(--dock-h) - var(--foot-h, 78px) - 26px);
  min-height: 420px; max-height: 860px;
  border: 1px solid var(--border); border-radius: 4px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 22%, #12121a 0%, #0a0a0f 62%);
}
#gl { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; outline: none; }
html.is-grabbing #gl { cursor: grabbing; }
.vp-frame { position: absolute; inset: 9px; pointer-events: none; }
.vp-frame .c { position: absolute; width: 15px; height: 15px; border: 1px solid rgba(197,160,89,.4); }
.vp-frame .c.tl { left: 0; top: 0; border-right: none; border-bottom: none; }
.vp-frame .c.tr { right: 0; top: 0; border-left: none; border-bottom: none; }
.vp-frame .c.bl { left: 0; bottom: 0; border-right: none; border-top: none; }
.vp-frame .c.br { right: 0; bottom: 0; border-left: none; border-top: none; }
.vp-caption {
  position: absolute; left: 50%; top: 13px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; pointer-events: none; max-width: 78%;
}
#scene-caption {
  font-family: var(--mono); font-size: 9px; letter-spacing: .26em; text-transform: uppercase;
  color: rgba(237,216,146,.7); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.caption-line { flex: 1 1 34px; height: 1px; background: linear-gradient(to right, transparent, rgba(197,160,89,.35)); }
.caption-line:last-child { background: linear-gradient(to left, transparent, rgba(197,160,89,.35)); }

.view-controls {
  position: absolute; top: 12px; right: 12px; display: flex; align-items: center; gap: 6px;
  padding: 6px; border-radius: 4px;
}
.vc-group { display: flex; gap: 3px; }
.vc {
  font-family: var(--mono); font-size: 9.5px; font-weight: 500; letter-spacing: .07em;
  color: var(--ink-muted); background: transparent; border: 1px solid transparent;
  border-radius: 3px; padding: 5px 8px; cursor: pointer; position: relative; overflow: hidden;
  transition: color .18s, border-color .18s, background .18s;
}
.vc::after {
  content: ''; position: absolute; left: 8%; right: 100%; bottom: 3px; height: 1px;
  background: var(--gold); transition: right .28s var(--ease);
}
.vc:hover { color: var(--gold-light); border-color: var(--hair); background: rgba(255,255,255,.04); }
.vc:hover::after { right: 8%; }
.vc.active { color: var(--bg-dark); background: var(--gold); border-color: var(--gold); }
.vc.active::after { display: none; }
.vc.wide { min-width: 34px; text-align: center; text-transform: uppercase; }
.vc-sep { width: 1px; height: 15px; background: var(--border); margin: 0 2px; }
.vc.accent { color: var(--bg-dark); background: linear-gradient(180deg, var(--gold-light), var(--gold)); border-color: transparent; font-weight: 600; }
.vc.accent:hover { filter: brightness(1.08); color: var(--bg-dark); }

/* quiz */
.quiz-bar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 999px;
  border-color: rgba(197,160,89,.3);
}
.quiz-bar[hidden] { display: none; }
.quiz-tag { font-family: var(--mono); font-size: 8.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.quiz-ask { font-size: 12.5px; color: var(--ink); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiz-score { font-family: var(--mono); font-size: 11px; color: var(--gold-light); font-variant-numeric: tabular-nums; }
.quiz-bar.flash-ok { border-color: rgba(108,215,194,.75); box-shadow: 0 0 0 3px rgba(108,215,194,.14); }
.quiz-bar.flash-no { border-color: rgba(214,106,106,.7); }

/* loader */
.loader {
  position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
  background: radial-gradient(ellipse at 50% 45%, rgba(16,16,22,.96), rgba(8,8,11,.99));
  transition: opacity .45s var(--ease);
}
.loader[hidden] { display: none; }
.loader.fade { opacity: 0; pointer-events: none; }
.loader-ring { position: relative; width: 116px; height: 116px; }
.loader-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.lr-track { fill: none; stroke: rgba(255,255,255,.07); stroke-width: 2; }
.lr-bar {
  fill: none; stroke: var(--gold); stroke-width: 2; stroke-linecap: round;
  stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset .5s var(--ease);
  filter: drop-shadow(0 0 7px rgba(197,160,89,.55));
}
.loader-pct {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 21px; font-weight: 500; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.loader-pct span { font-size: 10px; color: var(--gold); margin-left: 1px; }
.loader-copy { text-align: center; position: relative; overflow: hidden; padding: 4px 14px; }
.loader-title { font-size: 12.5px; color: var(--ink); letter-spacing: -.1px; }
.loader-sub { font-family: var(--mono); font-size: 9px; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-dim); margin-top: 5px; }
.loader-bar { width: 210px; height: 2px; margin: 12px auto 0; background: rgba(255,255,255,.08); border-radius: 2px; overflow: hidden; }
.loader-bar i { display: block; height: 100%; width: 0; background: linear-gradient(to right, var(--gold), var(--gold-light)); transition: width .5s var(--ease); }
.loader-scan {
  position: absolute; left: 0; right: 0; top: 0; height: 42%;
  background: linear-gradient(to bottom, transparent, rgba(197,160,89,.055), transparent);
  animation: scan 2.9s linear infinite;
}
@keyframes scan { 0% { transform: translateY(-120%); } 100% { transform: translateY(320%); } }

.fatal {
  position: absolute; inset: 0; z-index: 22; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px;
  background: radial-gradient(ellipse at 50% 45%, rgba(18,12,12,.97), rgba(8,8,11,.99));
}
.fatal[hidden] { display: none; }
.fatal-title { font-size: 14px; color: #e0a0a0; letter-spacing: -.2px; }
.fatal-msg { font-family: var(--mono); font-size: 10.5px; color: var(--ink-dim); max-width: 46ch; margin: 0; line-height: 1.6; }
.btn-primary {
  font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--bg-dark); background: linear-gradient(180deg, var(--gold-light), var(--gold));
  border: none; border-radius: 3px; padding: 9px 16px; cursor: pointer;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ---------------- detail rail ---------------- */
.rail-right { padding: 14px 13px 10px; }
.detail-empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 34px 12px; text-align: center;
}
.detail-empty[hidden] { display: none; }
.ico-big { width: 34px; height: 34px; fill: none; stroke: var(--border); stroke-width: 1.2; }
.detail-empty p { margin: 0; font-size: 11.5px; color: var(--ink-dim); font-style: italic; line-height: 1.6; }
.detail-body[hidden] { display: none; }
.detail-kicker { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; }
.sys-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px currentColor; flex: none; }
.detail-kicker span { font-family: var(--mono); font-size: 9px; letter-spacing: .17em; text-transform: uppercase; color: var(--ink-muted); }
.detail-name {
  margin: 0 0 5px; font-size: 17px; font-weight: 400; letter-spacing: -.35px;
  line-height: 1.24; color: var(--ink); text-wrap: balance;
}
.detail-latin { font-family: var(--mono); font-size: 9.5px; color: var(--ink-dim); line-height: 1.55; margin-bottom: 14px; }
.detail-latin:empty { display: none; }
.detail-spec { margin: 0 0 14px; padding: 0; border-top: 1px solid var(--border); }
.detail-spec > div {
  display: flex; justify-content: space-between; gap: 12px; padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.detail-spec dt {
  flex: none; font-family: var(--mono); font-size: 8.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-dim); padding-top: 2px;
}
.detail-spec dd {
  margin: 0; font-size: 11.5px; color: var(--ink-muted); text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.detail-sys-desc {
  font-size: 12.5px; line-height: 1.68; color: #cdd2e0;
  padding: 11px 12px; border-left: 2px solid rgba(197,160,89,.45);
  background: rgba(197,160,89,.04); border-radius: 0 3px 3px 0; margin-bottom: 14px;
}
.detail-sys-desc:empty { display: none; }
.detail-actions { display: flex; gap: 7px; }
.btn-ghost {
  flex: 1; font-family: var(--mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-muted); background: rgba(255,255,255,.03); border: 1px solid var(--border);
  border-radius: 3px; padding: 8px 6px; cursor: pointer; transition: color .18s, border-color .18s, background .18s;
}
.btn-ghost:hover { color: var(--gold); border-color: rgba(197,160,89,.5); background: rgba(197,160,89,.08); }
.credit { border-top: 1px solid var(--border); margin-top: 18px; }
.credit-line { font-family: var(--mono); font-size: 8.5px; letter-spacing: .15em; text-transform: uppercase; color: var(--gold); }
.credit-note { margin: 6px 0 0; font-size: 9.8px; line-height: 1.55; color: var(--ink-dim); }
.disclaimer { margin: 8px 0 0; font-size: 9.6px; line-height: 1.5; color: var(--ink-dim); font-style: italic; }

/* ---------------- dock ---------------- */
.dock {
  position: relative; z-index: 30; display: flex; align-items: center; gap: 16px;
  max-width: 1320px; margin: 12px auto 0; padding: 11px 16px;
  border-radius: 4px;
}
.dock-btn {
  display: none; align-items: center; gap: 7px; font-family: var(--mono); font-size: 9px;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink-muted);
  background: transparent; border: 1px solid var(--border); border-radius: 3px;
  padding: 9px 11px; cursor: pointer;
}
.dock-btn[aria-pressed=true] { color: var(--gold); border-color: rgba(197,160,89,.5); }
.ico-dots, .ico-star { width: 9px; height: 9px; border-radius: 50%; background: currentColor; opacity: .65; }
.explode-wrap { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.explode-label {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  font-family: var(--mono); font-size: 9px; letter-spacing: .15em; text-transform: uppercase; color: var(--ink-muted);
}
.explode-label output { font-size: 11px; color: var(--gold-light); font-variant-numeric: tabular-nums; }
.range { position: relative; height: 20px; display: flex; align-items: center; }
.range input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  appearance: none; background: transparent; cursor: ew-resize; z-index: 3;
}
.range input::-webkit-slider-running-track { background: transparent; border: none; }
.range input::-webkit-slider-thumb {
  appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--gold-light), var(--gold));
  border: 1px solid rgba(0,0,0,.5); box-shadow: 0 0 0 4px rgba(197,160,89,.13), 0 2px 6px rgba(0,0,0,.6);
  margin-top: -6px;
}
.range input::-moz-range-track { background: transparent; border: none; }
.range input::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; border: 1px solid rgba(0,0,0,.5);
  background: var(--gold); margin-top: -6px; box-shadow: 0 0 0 4px rgba(197,160,89,.13);
}
.range-track {
  position: absolute; left: 0; right: 0; height: 3px; border-radius: 3px;
  background: rgba(255,255,255,.09); overflow: hidden; z-index: 1;
}
.range-track i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(to right, rgba(197,160,89,.55), var(--gold-light));
  box-shadow: 0 0 9px rgba(197,160,89,.4);
}
.range-ticks { position: absolute; left: 0; right: 0; top: 13px; display: flex; justify-content: space-between; z-index: 2; pointer-events: none; }
.range-ticks i { width: 1px; height: 4px; background: rgba(255,255,255,.13); }

/* ---------------- rail toggles (mobile) ---------------- */
.rail-toggle {
  display: none; position: fixed; bottom: calc(var(--dock-h) + 16px); z-index: 55;
  font-family: var(--mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-muted); background: rgba(14,14,20,.94); backdrop-filter: blur(10px);
  border: 1px solid var(--hair-strong); border-radius: 999px; padding: 9px 13px; cursor: pointer;
}
.rail-toggle-left { left: 14px; }
.rail-toggle-right { right: 14px; }
.rail-toggle[aria-pressed=true] { color: var(--gold); border-color: rgba(197,160,89,.55); }

/* ---------------- footer ---------------- */
.attribution {
  position: relative; z-index: 15; max-width: 1320px; margin: 0 auto;
  padding: 16px 22px 26px; display: flex; gap: 16px; flex-wrap: wrap;
  justify-content: space-between; align-items: center;
  border-top: 1px solid var(--border); margin-top: 16px;
  font-size: 10.5px; color: var(--ink-dim);
}
.attribution a { color: var(--ink-muted); text-decoration: none; letter-spacing: .02em; }
.attribution a:hover { color: var(--gold); }
.noscript { padding: 40px; text-align: center; color: var(--ink-muted); }

/* ---------------- responsive ---------------- */
@media (max-width: 1100px) {
  .stage { grid-template-columns: minmax(0,1fr); padding-top: 0; }
  .viewport {
    grid-column: 1;
    /* the chrome heights are published by fitStage() from the real boxes, so the
     * canvas fills the page exactly once and the page cannot scroll under 100dvh */
    height: calc(100dvh - var(--nav-h) - var(--mast-h) - var(--dock-h) - var(--foot-h, 78px) - 8px);
  }
  .rail {
    position: fixed; top: var(--nav-h); bottom: 0; width: min(84vw, 316px); z-index: 80;
    max-height: none; border-radius: 0; transform: translateX(-102%);
    transition: transform .34s var(--ease); background: linear-gradient(160deg, rgba(16,16,22,.97), rgba(11,11,16,.97));
  }
  .rail-left { left: 0; border-left: none; }
  .rail-right { right: 0; left: auto; transform: translateX(102%); }
  html.rail-open-left .rail-left, html.rail-open-right .rail-right { transform: translateX(0); }
  .dock-btn { display: inline-flex; }
  .rail-toggle { display: block; }
  .mast-stats { gap: 18px; }
}
@media (max-width: 700px) {
  .nav-inner, .mast-inner, .stage, .attribution { padding-left: 13px; padding-right: 13px; }
  .masthead { padding-top: 10px; padding-bottom: 8px; }
  .mast-inner { align-items: flex-start; flex-direction: column; gap: 8px; }
  .mast-copy h1 { font-size: clamp(21px, 6vw, 27px); letter-spacing: -.5px; }
  .kicker { font-size: 9px; letter-spacing: .16em; margin-bottom: 5px; }
  .lead {
    font-size: 12px; line-height: 1.45; margin-top: 5px;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .mast-stats { width: 100%; justify-content: space-between; gap: 8px; margin-top: 2px; }
  .stat { padding-left: 8px; }
  .stat b { font-size: 15px; }
  .stat span { font-size: 8px; letter-spacing: .1em; }
  .viewport { min-height: 380px; border-radius: 3px; }
  .view-controls { top: 8px; right: 8px; left: 8px; flex-wrap: wrap; justify-content: center; }
  .vc { min-height: 32px; padding: 7px 9px; }
  .vc.wide { flex: 1 1 auto; }
  .vc-sep { display: none; }
  .quiz-bar { bottom: 8px; width: calc(100% - 16px); justify-content: center; flex-wrap: wrap; }
  .quiz-ask { max-width: 60vw; }
  .dock { gap: 10px; padding: 10px 11px; }
  .dock-btn { padding: 12px 10px; min-height: 44px; }
  .range input { min-height: 44px; }
  .rail-toggle { padding: 12px 14px; min-height: 44px; }
  .vp-caption { top: 52px; }
  .attribution { padding-top: 10px; padding-bottom: 16px; margin-top: 8px; gap: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *before, *after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
  .bg-aurora { animation: none; }
  .loader-scan { display: none; }
}

/* ---- hover tooltip on the 3D view (mirrors the reference atlas .part-hover) ---- */
.part-hover {
  position: absolute;
  z-index: 24;
  max-width: 250px;
  padding: 7px 11px 8px;
  pointer-events: none;
  border: 1px solid var(--border);
  border-left: 2px solid var(--gold);
  border-radius: 3px;
  background: rgba(17,17,24,.94);
  color: var(--ink);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .01em;
  line-height: 1.25;
  box-shadow: 0 10px 26px rgba(0,0,0,.5);
  backdrop-filter: blur(6px);
  opacity: 0;
  transform: translate3d(0,4px,0);
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}
.part-hover:not([hidden]) { opacity: 1; transform: translate3d(0,0,0); }
.part-hover[hidden] { display: none; }

/* ---- system selector: presets row + system description (reference .layer-presets / .context-note) ---- */
.sys-presets { display: flex; gap: 6px; margin: 2px 0 10px; }
.preset { flex: 1 1 auto; padding: 5px 9px; font-family: var(--font); font-size: 11px;
  font-weight: 500; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-muted); background: var(--bg-card); cursor: pointer;
  border: 1px solid var(--border); border-radius: 2px;
  transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease); }
.preset:hover { color: var(--ink); border-color: var(--hair-strong); }
.preset[aria-pressed=true] { color: #0d0d12; background: var(--gold); border-color: var(--gold); }
.sys-desc { margin: 0 0 10px; padding: 9px 10px; font-size: 11.5px; line-height: 1.5;
  color: #c9cede; background: rgba(255,255,255,.05);
  border-left: 2px solid var(--gold); border-radius: 2px; }
.sys-desc[hidden] { display: none; }

/* ---- physical switch on each system row (reference shadcn Switch) ---- */
.sys-item { grid-template-columns: 3px 1fr auto auto; }
.sys-switch { position: relative; width: 30px; height: 16px; flex: none; padding: 0;
  cursor: pointer; background: rgba(255,255,255,.07); border: 1px solid var(--border);
  border-radius: 999px; transition: background .22s var(--ease), border-color .22s var(--ease); }
.sys-switch::after { content: ""; position: absolute; top: 1px; left: 1px;
  width: 12px; height: 12px; border-radius: 50%; background: var(--ink-dim);
  transition: transform .22s var(--ease), background .22s var(--ease); }
.sys-item[aria-pressed=true] .sys-switch { background: rgba(197,160,89,.32); border-color: var(--gold); }
.sys-item[aria-pressed=true] .sys-switch::after { transform: translateX(14px); background: var(--gold); }

/* ---- element descriptor: context note + member list (reference .context-note / .member-list) ---- */
.d-context { margin: 8px 0 0; padding: 7px 9px; font-size: 10.5px; line-height: 1.45;
  font-style: italic; color: var(--ink-dim); background: rgba(255,255,255,.02);
  border-left: 2px solid var(--hair-strong); border-radius: 2px; }
.d-context[hidden] { display: none; }
.d-members { margin-top: 12px; border-top: 1px solid var(--hair); }
.d-members[hidden] { display: none; }
.d-members h3 { margin: 10px 0 4px; font-size: 10px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); }
.d-members button { display: block; width: 100%; padding: 6px 4px; text-align: left;
  font-family: var(--font); font-size: 11.5px; color: var(--ink-muted);
  background: transparent; border: none; border-bottom: 1px solid rgba(255,255,255,.03);
  cursor: pointer; transition: color .18s var(--ease), padding-left .18s var(--ease); }
.d-members button:hover { color: var(--gold-light); padding-left: 8px; }
.d-members .more { padding: 7px 4px; font-size: 10.5px; font-style: italic; color: var(--ink-dim); }

/* ---- attribution links in the credit line (reference .source-link) ---- */
.credit-src { color: var(--gold); text-decoration: none; border-bottom: 1px solid transparent;
  font-size: 10.5px; letter-spacing: .04em; transition: color .18s var(--ease),
  border-color .18s var(--ease); }
.credit-src:hover { color: var(--gold-light); border-bottom-color: var(--gold); }

/* ---- reference-atlas parity chrome (parity_ui.py) ---- */
.vp-hints {
  position: absolute; left: 10px; bottom: 9px; z-index: 22; display: flex;
  gap: 12px; flex-wrap: wrap; pointer-events: none;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-dim);
}
.vp-hints span { display: inline-flex; align-items: center; gap: 5px; }
.vp-hints i { width: 5px; height: 5px; border-radius: 999px; background: var(--gold); opacity: .55; }

.sys-badge {
  margin-left: 7px; padding: 1px 5px; border-radius: 999px;
  border: 1px solid var(--hair-strong); background: rgba(197,160,89,.10);
  font-family: var(--mono); font-size: 8.5px; color: var(--gold-light);
  font-variant-numeric: tabular-nums;
}
.bulk-hide {
  background: none; border: none; padding: 2px 0; cursor: pointer;
  font-family: var(--mono); font-size: 9px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-dim);
}
.bulk-hide:hover { color: var(--gold); }

.explode-ends {
  display: flex; justify-content: space-between; gap: 8px; margin-top: 3px;
  font-family: var(--mono); font-size: 8px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-dim);
}
.dock-reset {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  background: none; border: 1px solid var(--hair-strong); border-radius: 999px;
  padding: 6px 10px; cursor: pointer; color: var(--ink-muted);
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .12em;
  text-transform: uppercase;
}
.dock-reset:hover { color: var(--gold); border-color: rgba(197,160,89,.55); }

.detail-close {
  position: absolute; top: 8px; right: 9px; width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--hair); border-radius: 999px;
  color: var(--ink-dim); cursor: pointer; font-size: 12px; line-height: 1;
}
.detail-close:hover { color: var(--gold); border-color: rgba(197,160,89,.55); }
.detail-body { position: relative; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.kbd-hint {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  padding: 1px 5px; border: 1px solid var(--hair-strong); border-radius: 3px;
  font-family: var(--mono); font-size: 9px; color: var(--ink-dim);
  background: rgba(255,255,255,.04); pointer-events: none;
}
.searchbox { position: relative; }
.help-wrap { position: relative; }
.help-btn {
  width: 26px; height: 26px; flex: none; border-radius: 999px; cursor: pointer;
  background: rgba(14,14,20,.9); border: 1px solid var(--hair-strong);
  color: var(--ink-muted); font-family: var(--mono); font-size: 11px;
}
.help-btn:hover, .help-btn[aria-expanded=true] { color: var(--gold); border-color: rgba(197,160,89,.55); }
.help-pop {
  position: absolute; right: 0; top: 32px; z-index: 40; width: min(300px, 82vw);
  padding: 10px 12px; border-radius: 4px; text-align: left;
  background: linear-gradient(160deg, rgba(20,20,28,.97), rgba(13,13,19,.97));
  border: 1px solid var(--hair-strong); box-shadow: 0 14px 34px rgba(0,0,0,.5);
}
.help-pop[hidden] { display: none; }
.help-pop h4 {
  margin: 0 0 6px; font-family: var(--mono); font-size: 9px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--gold);
}
.help-pop p { margin: 0; font-size: 11px; line-height: 1.7; color: var(--ink-muted); }

/* parity: the shortcut card must survive the mobile rail drawers */
@media (max-width: 700px) {
  .help-wrap { position: fixed; top: calc(var(--nav-h) + 8px); right: 46%; left: auto; z-index: 45; }
  .help-pop { position: fixed; top: calc(var(--nav-h) + 40px); right: 8px; left: 8px; width: auto; }
  .vp-hints { font-size: 7.5px; gap: 8px; bottom: 6px; }
  .sys-badge { margin-left: 6px; }
}

/* - inventaire: la grille des pieces en vignettes - */
.inv-panel { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 10px; }
.inv-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.inv-title { font-family: var(--mono); font-size: 9px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--gold); }
.inv-count { font-family: var(--mono); font-size: 9px; color: #a8aec4;
  font-variant-numeric: tabular-nums; margin-right: auto; padding-left: 6px; }
.inv-pager { display: inline-flex; align-items: center; gap: 4px; }
.inv-page { width: 20px; height: 18px; line-height: 1; cursor: pointer; background: none;
  border: 1px solid var(--hair); border-radius: 3px; color: var(--ink-muted); font-size: 9px; }
.inv-page:hover { color: var(--gold); border-color: rgba(197,160,89,.55); }
.inv-page-no { font-family: var(--mono); font-size: 8.5px; color: var(--ink-dim);
  min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 7px; max-height: 430px; overflow-y: auto; padding-right: 2px; }
.inv-card { display: flex; flex-direction: column; gap: 4px; padding: 5px 5px 6px;
  cursor: pointer; text-align: left; background: rgba(255,255,255,.05);
  border: 1px solid var(--hair); border-radius: 3px; transition: border-color .16s; }
.inv-card:hover { border-color: rgba(197,160,89,.45); background: rgba(197,160,89,.06); }
.inv-card[aria-pressed=true] { border-color: rgba(197,160,89,.8);
  background: rgba(197,160,89,.12); box-shadow: inset 0 0 0 1px rgba(197,160,89,.25); }
.inv-thumb { width: 100%; height: 62px; object-fit: contain; display: block;
  background: radial-gradient(ellipse at 50% 42%, #14141c, #08080c);
  border-radius: 2px; image-rendering: auto; }
.inv-label { font-size: 11px; line-height: 1.3; color: #dfe2ee; text-shadow: 0 1px 2px rgba(0,0,0,.8);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; word-break: break-word; }
.inv-card.sans-vignette { opacity: .45; }
.inv-card.sans-vignette .inv-thumb { display: none; }
@media (max-width: 1100px) { .inv-grid { max-height: none; } }
