/* =====================================================================
   BOUNDARY LAB — design foundation
   Instrument-case dark: charted paper, hairlines, one signal cyan.
   Single shared stylesheet. Pages link ONLY this file.
   ===================================================================== */

/* ---------------------------------------------------------------
   a. TOKENS
   --------------------------------------------------------------- */
:root {
  /* palette — raw named colors */
  --ink-deep-sea: #0B1114;      /* 深海インク  */
  --white-screen: #E6EDEE;      /* 蛍光板ホワイト */
  --panel-gauge: #141E22;       /* 計器盤 */
  --gray-scale: #7C8E93;        /* 目盛グレー */
  --cyan-signal: #2FE0C8;       /* 信号シアン */

  /* palette — roles */
  --color-bg: var(--ink-deep-sea);
  --color-fg: var(--white-screen);
  --color-surface: var(--panel-gauge);
  --color-muted: var(--gray-scale);
  --color-accent: var(--cyan-signal);

  /* derived instrument tones (all from the five above) */
  --hairline: rgba(124, 142, 147, 0.12);
  --hairline-strong: rgba(124, 142, 147, 0.26);
  --hairline-accent: rgba(47, 224, 200, 0.42);
  --grid-line: rgba(124, 142, 147, 0.06);
  --fg-dim: rgba(230, 237, 238, 0.62);
  --fg-ghost: rgba(230, 237, 238, 0.16);
  --accent-wash: rgba(47, 224, 200, 0.10);
  --surface-sunk: rgba(11, 17, 20, 0.72);

  /* type families */
  --font-display: "Space Grotesk", "Helvetica Neue", Helvetica, sans-serif;
  --font-body: "IBM Plex Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* fluid type scale — every step has a deliberate maximum */
  --step--1: clamp(0.78rem, 0.74rem + 0.18vw, 0.9rem);
  --step-0: clamp(0.95rem, 0.9rem + 0.24vw, 1.08rem);
  --step-1: clamp(1.25rem, 1.05rem + 0.9vw, 1.75rem);
  --step-2: clamp(1.9rem, 1.3rem + 2.2vw, 3.1rem);
  --step-3: clamp(2.8rem, 1.5rem + 4.6vw, 5.6rem);
  --step-display: clamp(3.2rem, 7.6vw, 10.5rem);
  --step-label: clamp(0.68rem, 0.64rem + 0.14vw, 0.8rem);

  /* leading + tracking */
  --lh-display: 0.92;
  --lh-display-jp: 1.06;
  --lh-body: 2;
  --lh-tight: 1.35;
  --tr-display: -0.03em;
  --tr-jp-head: 0.01em;
  --tr-body: 0.04em;
  --tr-label: 0.18em;

  /* spacing scale — fluid, capped */
  --space-1: clamp(0.25rem, 0.24rem + 0.1vw, 0.4rem);
  --space-2: clamp(0.5rem, 0.46rem + 0.2vw, 0.75rem);
  --space-3: clamp(0.85rem, 0.75rem + 0.4vw, 1.25rem);
  --space-4: clamp(1.35rem, 1.1rem + 0.8vw, 2rem);
  --space-5: clamp(2rem, 1.5rem + 1.6vw, 3.25rem);
  --space-6: clamp(3rem, 2rem + 3vw, 5.5rem);
  --space-7: clamp(4.5rem, 3rem + 5vw, 9rem);
  --space-8: clamp(6.5rem, 4rem + 7vw, 13rem);

  /* layout */
  --shell: 1760px;
  --page-inline: clamp(1.25rem, 4vw, 4.25rem);
  --gutter: clamp(16px, 1.6vw, 34px);
  --silence: clamp(5rem, 18vh, 14rem);
  --silence-half: clamp(2.75rem, 10vh, 7rem);
  --margin-col: clamp(90px, 7vw, 140px);
  --grid-cell: 96px;

  /* motion */
  --ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out-expo: cubic-bezier(0.87, 0, 0.13, 1);
  --ease-out-power3: cubic-bezier(0.215, 0.61, 0.355, 1);
  --dur-1: 0.35s;
  --dur-2: 0.9s;
  --dur-3: 1.4s;
  --marquee-duration: 34s;
}

/* ---------------------------------------------------------------
   b. RESET
   --------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html,
body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd, ul, ol, pre {
  margin: 0;
  padding: 0;
}

ul[class],
ol[class] { list-style: none; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--color-bg);
  scrollbar-color: rgba(124, 142, 147, 0.4) transparent;
  scrollbar-width: thin;
}

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

img, video { height: auto; }

input, button, textarea, select {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ---------------------------------------------------------------
   c. BASE ELEMENTS
   --------------------------------------------------------------- */
body {
  min-height: 100%;
  background-color: transparent;
  color: var(--color-fg);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--step-0);
  line-height: var(--lh-body);
  letter-spacing: var(--tr-body);
  font-feature-settings: "palt" 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

body.is-loading {
  overflow: hidden;
  height: 100vh;
}

/* graph-paper ground: the page slides over a fixed chart grid */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, var(--grid-line) 0 1px, transparent 1px),
    linear-gradient(180deg, var(--grid-line) 0 1px, transparent 1px);
  background-size: var(--grid-cell) var(--grid-cell);
  background-position: 0 0;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-body);
  font-weight: 700;
  font-feature-settings: "palt" 1;
  letter-spacing: var(--tr-jp-head);
  line-height: var(--lh-display-jp);
  word-break: keep-all;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

h1 { font-size: var(--step-display); line-height: 1.02; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
h5, h6 {
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--color-muted);
  line-height: 1.4;
}

p { max-width: 62ch; }
p + p { margin-top: var(--space-3); }

strong, b { font-weight: 700; }
small { font-size: var(--step--1); }

/* links: hairline underline drawn from the left */
a {
  color: inherit;
  text-decoration: none;
  position: relative;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 1px;
  transition: background-size var(--dur-1) var(--ease-out-power3), color var(--dur-1) var(--ease-out-power3);
}

a:hover,
a:focus-visible { background-size: 100% 1px; }

a[data-underline="off"],
a.nav-link,
a.no-rule { background-image: none; }

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

hr {
  border: 0;
  height: 1px;
  background: var(--hairline);
}

::selection {
  background: var(--color-accent);
  color: var(--color-bg);
  text-shadow: none;
}

:focus { outline: none; }

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

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(124, 142, 147, 0.4);
  border-radius: 0;
}
::-webkit-scrollbar-thumb:hover { background: rgba(124, 142, 147, 0.62); }
::-webkit-scrollbar-corner { background: transparent; }

/* ---------------------------------------------------------------
   d. GRAIN — no extra markup, native 240px tile (never stretched)
   --------------------------------------------------------------- */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-repeat: repeat;
  background-size: 240px 240px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------
   e. LAYOUT UTILITIES
   --------------------------------------------------------------- */
.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--page-inline);
  position: relative;
}

/* the margins outside the shell are the instrument's bezel, not leftovers */
.shell--ruled::before,
.shell--ruled::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--hairline);
  pointer-events: none;
}
.shell--ruled::before { left: 0; }
.shell--ruled::after { right: 0; }

.bleed {
  width: 100%;
  margin-inline: 0;
  max-width: none;
}

.section {
  position: relative;
  padding-block: var(--silence);
}

.section--tight { padding-block: var(--silence-half); }

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gutter);
  align-items: start;
}

.g-col-1 { grid-column: span 1; }
.g-col-2 { grid-column: span 2; }
.g-col-3 { grid-column: span 3; }
.g-col-4 { grid-column: span 4; }
.g-col-5 { grid-column: span 5; }
.g-col-6 { grid-column: span 6; }
.g-col-7 { grid-column: span 7; }
.g-col-8 { grid-column: span 8; }
.g-col-9 { grid-column: span 9; }
.g-col-10 { grid-column: span 10; }
.g-col-11 { grid-column: span 11; }
.g-col-12 { grid-column: span 12; }

.g-start-1 { grid-column-start: 1; }
.g-start-2 { grid-column-start: 2; }
.g-start-3 { grid-column-start: 3; }
.g-start-4 { grid-column-start: 4; }
.g-start-5 { grid-column-start: 5; }
.g-start-6 { grid-column-start: 6; }
.g-start-7 { grid-column-start: 7; }
.g-start-8 { grid-column-start: 8; }
.g-start-9 { grid-column-start: 9; }
.g-start-10 { grid-column-start: 10; }
.g-start-11 { grid-column-start: 11; }
.g-start-12 { grid-column-start: 12; }

.stack > * + * { margin-top: var(--space-3); }
.stack-lg > * + * { margin-top: var(--space-5); }

/* hairlines + rulers */
.rule {
  display: block;
  width: 100%;
  height: 1px;
  background: var(--hairline);
  border: 0;
}
.rule--strong { background: var(--hairline-strong); }
.rule--accent { background: var(--color-accent); }
.rule--dashed {
  height: 0;
  background: none;
  border-top: 1px dashed var(--hairline-strong);
}

.ruler {
  position: relative;
  width: 100%;
  height: 26px;
  border-top: 1px solid var(--hairline-strong);
  background-image: repeating-linear-gradient(
    90deg,
    var(--hairline-strong) 0 1px,
    transparent 1px 48px
  );
  background-repeat: no-repeat;
  background-size: 100% 7px;
  background-position: 0 0;
}
.ruler__code {
  position: absolute;
  top: 10px;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  letter-spacing: var(--tr-label);
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

/* type utilities */
.label,
.mono-label {
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--color-muted);
  line-height: 1.4;
}

.mono,
.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.display-latin {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--lh-display);
  letter-spacing: var(--tr-display);
}
.display-latin--light { font-weight: 300; }

.display-jp {
  font-family: var(--font-body);
  font-weight: 700;
  font-feature-settings: "palt" 1;
  letter-spacing: var(--tr-jp-head);
  line-height: var(--lh-display-jp);
  word-break: keep-all;
}

.body-jp {
  font-feature-settings: "palt" 0;
  line-height: var(--lh-body);
  letter-spacing: var(--tr-body);
}
.body-jp--light { font-weight: 300; }

.muted { color: var(--color-muted); }
.dim { color: var(--fg-dim); }
.accent { color: var(--color-accent); }

/* giant outline word used as background texture */
.outline-word {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 0.8;
  letter-spacing: var(--tr-display);
  color: transparent;
  -webkit-text-stroke: 1px var(--color-muted);
  opacity: 0.12;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

/* oversized index numbers */
.index {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--step-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: var(--fg-ghost);
  line-height: 1;
}
.index--small {
  font-size: var(--step-label);
  font-weight: 500;
  letter-spacing: var(--tr-label);
  color: var(--color-muted);
}

/* vertical marginalia (JP instrument labels in the bezel) */
.marginalia {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: none;
}

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

.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10000;
  transform: translateY(-120%);
  background: var(--color-accent);
  color: var(--color-bg);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--step-label);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
}
.skip-link:focus-visible { transform: translateY(0); }

/* split-text fragments produced by motion.js */
.split-line {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}
.split-unit {
  display: inline-block;
  will-change: transform;
}
.split-space {
  display: inline-block;
  white-space: pre;
}

/* ---------------------------------------------------------------
   e2. COMPONENTS
   --------------------------------------------------------------- */

/* fixed nav — no bar, difference blend keeps it legible everywhere */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 500;
  mix-blend-mode: difference;
  padding: var(--space-3) var(--page-inline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  transition: padding var(--dur-2) var(--ease-out-quart);
}
.site-nav.scrolled { padding-block: var(--space-2); }

.nav-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-fg);
}

.nav-list {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.2vw, 2.75rem);
}

.nav-link {
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--color-fg);
  opacity: 0.7;
  padding-block: var(--space-2);
  position: relative;
  transition: opacity var(--dur-1) var(--ease-out-power3);
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 4px;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-1) var(--ease-out-power3);
}
.nav-link:hover,
.nav-link:focus-visible { opacity: 1; }
.nav-link:hover::after,
.nav-link:focus-visible::after,
.nav-link.is-current::after { transform: scaleX(1); }
.nav-link.is-current { opacity: 1; }

.nav-toggle {
  display: none;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--color-fg);
  border: 1px solid var(--hairline-strong);
}

.nav-panel {
  position: fixed;
  inset: 0;
  z-index: 480;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--page-inline);
  transform: translateY(-100%);
  visibility: hidden;
  transition: transform var(--dur-2) var(--ease-in-out-expo), visibility 0s linear var(--dur-2);
}
body.nav-open .nav-panel {
  transform: translateY(0);
  visibility: visible;
  transition: transform var(--dur-2) var(--ease-in-out-expo), visibility 0s linear 0s;
}
.nav-panel a {
  font-size: var(--step-2);
  font-family: var(--font-display);
  font-weight: 300;
  letter-spacing: var(--tr-display);
  min-height: 56px;
  display: flex;
  align-items: center;
}

/* scroll playhead — 1px transport bar at the very top of every page */
.progress-bar,
[data-progress] {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left center;
  z-index: 600;
  pointer-events: none;
}

/* buttons + tabs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--hairline-strong);
  border-radius: 2px;
  background: transparent;
  color: var(--color-fg);
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  transition: border-color var(--dur-1) var(--ease-out-power3), color var(--dur-1) var(--ease-out-power3);
  will-change: transform;
}
.btn:hover,
.btn:focus-visible {
  border-color: var(--hairline-accent);
  color: var(--color-accent);
}
.btn--square {
  width: 48px;
  min-height: 48px;
  padding: 0;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.tab {
  position: relative;
  min-height: 44px;
  padding: var(--space-2) var(--space-1);
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--color-muted);
  transition: color var(--dur-1) var(--ease-out-power3);
}
.tab::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 6px;
  width: 100%;
  height: 1px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-1) var(--ease-out-power3);
}
.tab[aria-selected="true"] { color: var(--color-fg); }
.tab[aria-selected="true"]::after { transform: scaleX(1); }
.tab:hover { color: var(--color-fg); }

/* panels, cards, canvases */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--hairline);
  border-radius: 2px;
  position: relative;
}
.panel--accent { border-color: var(--hairline-accent); }

.canvas-frame {
  background: var(--color-surface);
  border: 1px solid var(--hairline);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.canvas-frame canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* lanes (shared timeline rows) */
.lane {
  position: relative;
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  align-items: center;
  height: 44px;
  border-bottom: 1px solid var(--hairline);
}
.lane:first-of-type { border-top: 1px solid var(--hairline); }
.lane-label {
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--color-muted);
  border-right: 1px solid var(--hairline);
  height: 100%;
  display: flex;
  align-items: center;
  padding-right: var(--space-2);
}
.lane-label__jp {
  font-family: var(--font-body);
  font-size: var(--step--1);
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--fg-dim);
}
.lane-track {
  position: relative;
  height: 100%;
  overflow: hidden;
}

.marker {
  position: absolute;
  top: 0;
  bottom: 0;
  pointer-events: none;
}
.marker--block {
  background: rgba(124, 142, 147, 0.28);
  border-left: 1px solid var(--hairline-strong);
  border-right: 1px solid var(--hairline-strong);
}
.marker--tick {
  width: 1px;
  top: auto;
  height: 8px;
  bottom: 12px;
  background: var(--color-fg);
}
.marker--fusion {
  width: 1px;
  background: var(--color-accent);
}
.marker--fusion::before {
  content: "";
  position: absolute;
  top: 0;
  left: -3px;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 4px solid var(--color-accent);
}
.marker--truth {
  width: 1px;
  border-left: 1px dashed var(--color-fg);
  background: none;
  opacity: 0.75;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
  background: var(--color-accent);
  transform: translate3d(0, 0, 0);
  will-change: transform;
  pointer-events: none;
}

/* signature: the snapping cut line + its HUD */
.snapline {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
  background: var(--color-accent);
  transform: translate3d(0, 0, 0);
  opacity: 0;
  pointer-events: none;
  will-change: transform;
  z-index: 4;
}
.snapline.is-muted {
  background: none;
  border-left: 1px dashed var(--color-muted);
}
.snap-hud {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate3d(0, 0, 0);
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--color-accent);
  background: var(--surface-sunk);
  padding: 2px 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
}
.snap-hud.is-muted { color: var(--color-muted); }

/* metric card */
.metric-card {
  background: var(--color-surface);
  border: 1px solid var(--hairline);
  border-radius: 2px;
  padding: var(--space-4);
}
.metric-card--lead { border-color: var(--hairline-accent); }
.metric {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--step-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1;
  display: inline-block;
}
.metric-bar {
  display: block;
  width: 100%;
  height: 1px;
  background: var(--hairline-strong);
  position: relative;
  margin-top: var(--space-2);
}
.metric-bar__fill {
  position: absolute;
  inset: 0;
  background: var(--color-fg);
  transform: scaleX(0);
  transform-origin: left center;
}
.metric-card--lead .metric,
.metric-card--lead .metric-bar__fill { color: var(--color-accent); background-color: var(--color-accent); }
.metric-card--lead .metric { background: none; color: var(--color-accent); }

/* code panel — four tones maximum */
.code-panel {
  background: var(--color-surface);
  border: 1px solid var(--hairline);
  border-radius: 2px;
}
.code-panel--accent { border-color: var(--hairline-accent); }
.code-panel pre {
  overflow-x: auto;
  padding: var(--space-3);
  margin: 0;
}
.code-panel code {
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  color: var(--color-fg);
  white-space: pre;
}
.code-line { display: block; }
.code-line__n {
  display: inline-block;
  width: 2.5em;
  color: var(--color-muted);
  opacity: 0.6;
  user-select: none;
}
.tok-com { color: var(--color-muted); }
.tok-fn { color: var(--color-accent); }
.tok-kw { font-weight: 700; }
.code-line--flag { background: var(--accent-wash); }

/* sticky rail */
.rail { position: sticky; top: clamp(5rem, 14vh, 9rem); }
.rail-item {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--step-2);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  color: rgba(124, 142, 147, 0.3);
  position: relative;
  padding-left: var(--space-3);
  transition: color var(--dur-1) var(--ease-out-power3);
}
.rail-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 14px;
  height: 1px;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-1) var(--ease-out-power3);
}
.rail-item.is-active { color: var(--color-fg); }
.rail-item.is-active::before { transform: scaleX(1); }

/* marquee — CSS only, motion.js just duplicates the content */
.marquee {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-block: 1px solid var(--hairline);
  padding-block: var(--space-2);
}
.marquee-track {
  display: flex;
  width: max-content;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--color-muted);
  animation: marquee-run var(--marquee-duration) linear infinite;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-track > * { padding-right: var(--space-4); }

@keyframes marquee-run {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-50%, 0, 0); }
}

/* custom cursor — the instrument needle + its bracket */
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 100vh;
  background: linear-gradient(180deg, transparent, var(--color-accent) 14%, var(--color-accent) 86%, transparent);
  opacity: 0;
  transform: translate3d(-100px, 0, 0);
  pointer-events: none;
  z-index: 9000;
  mix-blend-mode: screen;
  will-change: transform;
  transition: opacity var(--dur-1) var(--ease-out-quart);
}
.cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  width: 24px;
  height: 24px;
  border: 1px solid var(--color-muted);
  opacity: 0;
  transform: translate3d(-100px, 0, 0);
  pointer-events: none;
  z-index: 9001;
  will-change: transform;
  transition: opacity var(--dur-1) var(--ease-out-quart), border-color var(--dur-1) var(--ease-out-quart);
}
.cursor-ring::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 2px;
  margin: -1px 0 0 -1px;
  background: var(--color-accent);
}
body.cursor-on .cursor { opacity: 0.45; }
body.cursor-on .cursor-ring { opacity: 0.8; }
body.cursor-hover .cursor-ring { border-color: var(--color-accent); }

/* native cursor stays everywhere except the measuring surfaces */
[data-cursor-hide],
[data-cursor-hide] * { cursor: none; }

@media (pointer: coarse) {
  .cursor,
  .cursor-ring { display: none !important; }
  [data-cursor-hide],
  [data-cursor-hide] * { cursor: auto; }
}

/* preloader */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--space-4);
  padding: var(--page-inline);
  will-change: transform;
}
.preloader-count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--step-3);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1;
  color: var(--color-fg);
}
.preloader-meta {
  font-family: var(--font-mono);
  font-size: var(--step-label);
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--color-muted);
}
.preloader-gauge {
  position: relative;
  width: 100%;
  height: 1px;
  background: var(--hairline-strong);
}
.preloader-gauge__fill {
  position: absolute;
  inset: 0;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left center;
}

/* reveal hooks (JS sets the from-state; content stays visible without JS) */
[data-reveal],
[data-reveal-chars] { will-change: auto; }

/* ---------------------------------------------------------------
   RESPONSIVE — three designed stages
   --------------------------------------------------------------- */
@media (min-width: 1440px) {
  :root { --grid-cell: 112px; }
}

@media (max-width: 1024px) {
  .lane { grid-template-columns: 104px minmax(0, 1fr); }
  .rail { position: static; display: flex; gap: var(--space-4); }
}

@media (max-width: 720px) {
  :root {
    --grid-cell: 56px;
    --silence: clamp(3.5rem, 12vh, 6rem);
  }

  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid > * { grid-column: 1 / -1 !important; }
  .grid > .g-keep-half { grid-column: span 1 !important; }

  .marginalia {
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    letter-spacing: 0.12em;
  }

  .outline-word { font-size: 26vw; }

  .site-nav { padding-inline: var(--page-inline); }
  .nav-list { display: none; }
  .nav-toggle { display: inline-flex; }

  .lane {
    grid-template-columns: minmax(0, 1fr);
    height: 26px;
  }
  .lane-label {
    position: absolute;
    top: 2px;
    left: 0;
    height: auto;
    border-right: 0;
    z-index: 2;
    background: var(--surface-sunk);
    padding-inline: 4px;
  }
  .lane-label__jp { display: none; }

  .rail { flex-wrap: wrap; }
  .rail-item { font-size: var(--step-1); }

  .metric-card { padding: var(--space-3); }
  .code-panel code { font-size: 12.5px; }

  a, .tab, .btn { min-height: 44px; }
}

@media (max-width: 480px) {
  .preloader-count { font-size: var(--step-2); }
}

/* ---------------------------------------------------------------
   f. REDUCED MOTION — the site is fully readable with zero animation
   --------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .marquee-track {
    animation: none !important;
    transform: none !important;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .cursor,
  .cursor-ring { display: none !important; }

  [data-cursor-hide],
  [data-cursor-hide] * { cursor: auto !important; }

  [data-reveal],
  [data-reveal-chars],
  .split-unit {
    opacity: 1 !important;
    transform: none !important;
  }

  .snapline { opacity: 1; }

  #preloader { display: none !important; }

  .nav-panel { transition: none !important; }
}
