/* ════════════════════════════════════════════════════════════════
   BarabashFlow — paper grid, square edges, expensive minimal.
   ════════════════════════════════════════════════════════════════ */

:root,
:root[data-theme="light"] {
  --bg:        #f6f4ee;
  --bg-tint:   #efece4;
  --surface:   #ffffff;
  --surface-2: #fbfaf6;
  --hair:      rgba(15, 15, 15, 0.08);
  --hair-2:    rgba(15, 15, 15, 0.16);

  --ink:       #0e0e0e;
  --ink-2:     #2a2a28;
  --muted:     #6b6b66;
  --soft:      #9c9c95;

  --grid-dot:  rgba(15, 15, 15, 0.10);

  --node-bg:   #ffffff;
  --node-bd:   rgba(15, 15, 15, 0.18);
  --node-sh:   0 1px 0 rgba(15, 15, 15, 0.04),
               0 18px 36px -18px rgba(15, 15, 15, 0.22);
  --node-sh-h: 0 1px 0 rgba(15, 15, 15, 0.06),
               0 28px 60px -18px rgba(15, 15, 15, 0.30);

  --edge:      rgba(15, 15, 15, 0.32);
  --edge-soft: rgba(15, 15, 15, 0.18);

  --shadow-modal: 0 60px 140px -36px rgba(15, 15, 15, 0.34),
                  0 16px 36px -14px rgba(15, 15, 15, 0.18);

  --logo-glow: radial-gradient(closest-side, rgba(0,0,0,0.08), transparent 70%);

  --ok:        #2f7d3a;
  --ok-glow:   rgba(47, 125, 58, 0.28);
  --cta-bg:    #0e0e0e;
  --cta-ink:   #f6f4ee;
  --cta-sh:    0 18px 36px -18px rgba(15,15,15,0.42);
}

:root[data-theme="dark"] {
  --bg:        #0d0d0d;
  --bg-tint:   #131313;
  --surface:   #151515;
  --surface-2: #1a1a1a;
  --hair:      rgba(245, 244, 240, 0.08);
  --hair-2:    rgba(245, 244, 240, 0.16);

  --ink:       #f5f4f0;
  --ink-2:     #d6d4cd;
  --muted:     #8d8b84;
  --soft:      #5b5955;

  --grid-dot:  rgba(245, 244, 240, 0.08);

  --node-bg:   #171717;
  --node-bd:   rgba(245, 244, 240, 0.14);
  --node-sh:   0 1px 0 rgba(245, 244, 240, 0.04),
               0 22px 48px -22px rgba(0, 0, 0, 0.9);
  --node-sh-h: 0 1px 0 rgba(245, 244, 240, 0.06),
               0 28px 60px -22px rgba(0, 0, 0, 1);

  --edge:      rgba(245, 244, 240, 0.32);
  --edge-soft: rgba(245, 244, 240, 0.16);

  --shadow-modal: 0 60px 140px -30px rgba(0, 0, 0, 0.7),
                  0 16px 36px -14px rgba(0, 0, 0, 0.6);

  --logo-glow: radial-gradient(closest-side, rgba(245,244,240,0.10), transparent 70%);

  --ok:        #6cd47a;
  --ok-glow:   rgba(108, 212, 122, 0.32);
  --cta-bg:    #f5f4f0;
  --cta-ink:   #0d0d0d;
  --cta-sh:    0 24px 48px -24px rgba(0,0,0,0.8);
}

:root {
  --font-display: 'Saira Extended', 'Inter', system-ui, sans-serif;
  --font-body:    'Inter', -apple-system, system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --node-w: 158px;
  --node-h: 144px;        /* photo + body */
  --node-thumb-h: 88px;   /* preview area */
  --logo-d: 296px;
  --grid:   28px;
  --tick:   16px;         /* corner-frame L-tick length */
  --frame-inset: clamp(18px, 2.4vmin, 30px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%; width: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  user-select: none;
  transition: background 0.4s ease, color 0.4s ease;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; border-radius: 0; }
input, textarea, select, button, .btn, .modal, .node, .card, .auth-card { border-radius: 0; }

/* ── Dotted graph-paper grid background ──────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: radial-gradient(circle at 1px 1px, var(--grid-dot) 1px, transparent 0);
  background-size: var(--grid) var(--grid);
  background-position: 0 0;
  pointer-events: none;
}
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse at 50% 35%, transparent 0%, var(--bg) 75%);
  pointer-events: none;
}

/* ── Corner-frame ticks (editorial signature) ────────────────── */
.frame-ticks {
  position: fixed;
  inset: var(--frame-inset);
  z-index: 1;
  pointer-events: none;
}
.frame-ticks span {
  position: absolute;
  width: var(--tick);
  height: var(--tick);
  border-color: var(--hair-2);
  border-style: solid;
  border-width: 0;
  opacity: 0;
  animation: ticksIn 0.9s cubic-bezier(0.16, 1, 0.3, 1) 1.4s forwards;
}
.frame-ticks span:nth-child(1) { top: 0;    left: 0;  border-top-width: 1px;    border-left-width: 1px;  }
.frame-ticks span:nth-child(2) { top: 0;    right: 0; border-top-width: 1px;    border-right-width: 1px; }
.frame-ticks span:nth-child(3) { bottom: 0; left: 0;  border-bottom-width: 1px; border-left-width: 1px;  }
.frame-ticks span:nth-child(4) { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }
@keyframes ticksIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Layout ───────────────────────────────────────────────────── */
.app {
  position: fixed; inset: 0;
  z-index: 2;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  /* iOS safe-area aware padding (notch / home indicator) */
  padding:
    max(clamp(28px, 3.6vmin, 48px), env(safe-area-inset-top, 0px))
    max(clamp(36px, 5vmin,   72px), env(safe-area-inset-right, 0px))
    max(clamp(28px, 3.6vmin, 48px), env(safe-area-inset-bottom, 0px))
    max(clamp(36px, 5vmin,   72px), env(safe-area-inset-left, 0px));
  gap: clamp(14px, 2.2vmin, 28px);
}

/* ── Top bar ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  z-index: 5;
  padding-bottom: clamp(10px, 1.4vmin, 18px);
  border-bottom: 1px solid var(--hair);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-display);
  font-weight: 300;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink);
  white-space: nowrap;
  text-decoration: none;
  transition: opacity 0.2s ease;
}
.brand:hover { opacity: 0.78; }
.brand-logo {
  height: 28px;
  width: auto;
  display: inline-block;
  flex-shrink: 0;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: filter 0.4s ease;
}
:root[data-theme="dark"] .brand-logo {
  filter: invert(0.94) hue-rotate(180deg);
}
.brand-name {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.28em;
  color: var(--ink);
}
.brand-rule {
  width: 22px;
  height: 1px;
  background: var(--hair-2);
  display: inline-block;
  flex-shrink: 0;
}
.brand-suffix {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.26em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand-sep {
  color: var(--soft);
  display: inline-block;
  transform: translateY(-1px);
}

.nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-2);
  white-space: nowrap;
}
.status-dot {
  width: 7px; height: 7px;
  background: var(--ok);
  display: inline-block;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 var(--ok-glow);
  animation: statusPulse 2.4s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
@keyframes statusPulse {
  0%   { box-shadow: 0 0 0 0   var(--ok-glow); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0   transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .status-dot { animation: none; }
}

.nav-divider {
  width: 1px;
  height: 18px;
  background: var(--hair-2);
  display: inline-block;
  flex-shrink: 0;
}

.nav-group {
  display: inline-flex;
  align-items: center;
  padding: 0;
  background: transparent;
  border: 0;
}
.nav-group button {
  padding: 6px 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--soft);
  border: 0;
  background: transparent;
  position: relative;
  transition: color 0.2s ease;
}
.nav-group button:hover { color: var(--ink-2); }
.nav-group button.is-active {
  color: var(--ink);
}
.nav-group button.is-active::after {
  content: '';
  position: absolute;
  left: 9px; right: 9px; bottom: 0;
  height: 1px;
  background: var(--ink);
}

.icon-btn {
  width: 32px; height: 32px;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}
.icon-btn:hover { color: var(--ink); background: var(--hair); }
.icon-btn:focus-visible { color: var(--ink); outline: 1px solid var(--ink); outline-offset: 2px; }
.icon-btn svg { width: 15px; height: 15px; }

/* ── Hero (portrait left · title + meta right) ──────────────── */
.hero {
  display: flex;
  align-items: center;
  gap: clamp(18px, 2.4vmin, 28px);
  z-index: 3;
  pointer-events: none;
  padding: clamp(8px, 1.4vmin, 16px) 4px 0;
}
.hero .portrait {
  width: clamp(72px, 9vmin, 96px);
  height: clamp(72px, 9vmin, 96px);
  background: var(--surface) center/cover no-repeat;
  border: 1px solid var(--hair-2);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
  display: inline-block;
}
.hero .portrait[data-empty="true"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, rgba(0,0,0,0.06) 0 4px, transparent 4px 8px);
}
:root[data-theme="dark"] .hero .portrait[data-empty="true"]::before {
  background:
    repeating-linear-gradient(45deg, rgba(245,244,240,0.05) 0 4px, transparent 4px 8px);
}
.hero-stack {
  display: flex;
  flex-direction: column;
  gap: clamp(8px, 1.2vmin, 14px);
  min-width: 0;
}

.hero-title {
  font-family: var(--font-display);
  font-weight: 200;
  font-stretch: expanded;
  font-size: clamp(26px, 4.2vmin, 52px);
  letter-spacing: 0.02em;
  line-height: 0.98;
  margin: 0;
  color: var(--ink);
  max-width: 22ch;
}
.hero-title em {
  font-style: italic;
  font-weight: 200;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.hero-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.hero-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.hero-sub:empty { display: none; }
.hero-sub:empty + .meta-sep { display: none; }
.meta-sep {
  color: var(--soft);
  font-weight: 400;
  letter-spacing: 0;
}

/* ── Graph stage ─────────────────────────────────────────────── */
.stage {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  --par-x: 0px;
  --par-y: 0px;
  cursor: grab;
}
.stage.is-panning { cursor: grabbing; }

/* Inner viewport — wheel-zoom + drag-pan target. Defaults inherit from JS. */
.stage-inner {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  transform:
    translate(var(--view-pan-x, 0px), var(--view-pan-y, 0px))
    scale(var(--view-zoom, 1));
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}
.stage-inner.is-interacting { transition: none; }

.zoom-indicator {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 6;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--soft);
  padding: 4px 8px;
  border: 1px solid var(--hair-2);
  background: var(--surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.zoom-indicator.is-visible { opacity: 1; }
#logo-stage,
.node,
#graph-edges {
  /* parallax: the stage applies a 2D drift via CSS vars from JS */
  will-change: transform;
}
.stage > #logo-stage,
.stage > #graph-edges {
  transform-origin: 50% 50%;
}
.stage > #logo-stage {
  /* keep our centered translate AND add parallax */
  transform: translate(calc(-50% + var(--par-x)), calc(-50% + var(--par-y)));
}
.stage > #graph-edges {
  transform: translate(var(--par-x), var(--par-y));
}
.stage > .node:not(.is-dragging) {
  /* compose: position translate + parallax + magnetic + entrance lift + entrance scale */
  transform:
    translate(
      calc(-50% + var(--mag-x) + var(--par-x)),
      calc(-50% + var(--mag-y) + var(--par-y) + var(--enter-y))
    )
    scale(var(--enter-scale));
}

#graph-edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 1;
}

.edge {
  fill: none;
  stroke: var(--edge-soft);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  transition: stroke 0.25s ease;
}
.edge.is-center { stroke: var(--edge); }

/* Logo holder — block, not flex (canvas would collapse) */
#logo-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--logo-d);
  height: var(--logo-d);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}
#logo-stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--logo-glow);
  pointer-events: none;
  z-index: 0;
}
#logo-stage canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  z-index: 1;
}

#logo-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 300;
  font-stretch: expanded;
  font-size: clamp(80px, 16vmin, 140px);
  letter-spacing: 0.04em;
  color: var(--ink);
  text-transform: uppercase;
  z-index: 1;
  pointer-events: none;
}
#logo-fallback.is-shown { display: flex; }

#logo-status {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--soft);
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.3s ease;
}
#logo-status.is-shown { opacity: 1; }
#logo-status.is-error { color: #b91c1c; }
:root[data-theme="dark"] #logo-status.is-error { color: #ff7676; }

/* ── Nodes (photo + body) ─────────────────────────────────────── */
.node {
  position: absolute;
  width: var(--node-w);
  min-height: var(--node-h);
  padding: 0;
  transform: translate(-50%, -50%);
  background: var(--node-bg);
  border: 1px solid var(--node-bd);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  text-align: left;
  box-shadow: var(--node-sh);
  z-index: 3;
  overflow: hidden;
  transition:
    border-color 0.2s ease,
    box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.25s ease;
  will-change: transform, left, top;
  touch-action: none;
}
.node:hover,
.node:focus-visible {
  border-color: var(--ink);
  box-shadow: var(--node-sh-h);
  outline: none;
}
.node.is-dragging {
  cursor: grabbing;
  z-index: 8;
  box-shadow: var(--node-sh-h);
  transition: none;
}

.node-thumb {
  position: relative;
  width: 100%;
  height: var(--node-thumb-h);
  background: var(--bg-tint) center/cover no-repeat;
  flex-shrink: 0;
  border-bottom: 1px solid var(--hair);
}
.node-thumb[data-empty="true"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(45deg, rgba(0,0,0,0.06) 0 4px, transparent 4px 9px);
}
:root[data-theme="dark"] .node-thumb[data-empty="true"]::before {
  background:
    repeating-linear-gradient(45deg, rgba(245,244,240,0.04) 0 4px, transparent 4px 9px);
}
.node-thumb[data-empty="true"]::after {
  content: '';
  position: absolute;
  top: 12px; left: 12px;
  width: 9px; height: 9px;
  background: var(--node-accent, var(--ink));
  opacity: 0.85;
}

.node-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--node-bg);
}

.node-cat {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.node-cat::before {
  content: '';
  width: 7px; height: 7px;
  background: var(--node-accent, var(--ink));
  display: inline-block;
  flex-shrink: 0;
}
.node-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-stretch: expanded;
  font-size: 13px;
  letter-spacing: 0.06em;
  line-height: 1.2;
  color: var(--ink);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Footer (CTA) ────────────────────────────────────────────── */
.footer {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(16px, 3vmin, 36px);
  z-index: 4;
  padding-top: clamp(10px, 1.6vmin, 18px);
  border-top: 1px solid var(--hair);
}

.footer-side {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.footer-left { justify-content: flex-start; }
.footer-right { justify-content: flex-end; }
.footer-mono { font-family: var(--font-mono); }
.footer-mono.muted { color: var(--soft); }
.footer-mono.strong { color: var(--ink); letter-spacing: 0.30em; }

.cta {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-display);
  font-weight: 300;
  font-stretch: expanded;
  font-size: 11px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--cta-ink);
  background: var(--cta-bg);
  padding: 17px 30px 17px 34px;
  position: relative;
  border: 1px solid var(--cta-bg);
  cursor: pointer;
  transition:
    transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    gap 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--cta-sh);
}
.cta-label { display: inline-block; }
.cta-arrow {
  width: 12px;
  height: 12px;
  color: var(--cta-ink);
  flex-shrink: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.cta:hover {
  transform: translateY(-2px);
  gap: 20px;
  box-shadow:
    0 28px 56px -22px rgba(15,15,15,0.55),
    0 4px 0 0 var(--cta-bg);
}
.cta:hover .cta-arrow { transform: translate(2px, -2px); }
.cta:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }
:root[data-theme="dark"] .cta:hover {
  box-shadow:
    0 32px 64px -22px rgba(0,0,0,0.85),
    0 4px 0 0 var(--cta-bg);
}

/* graph-hint removed — interaction is self-explanatory (cursor change) */

/* ════════════════════════════════════════════════════════════════
   Modal — square card, photo on top, whole thing scrolls
   ════════════════════════════════════════════════════════════════ */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vmin, 56px);
}
.modal-root.is-open { pointer-events: auto; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 15, 15, 0.36);
  backdrop-filter: blur(10px) saturate(115%);
  -webkit-backdrop-filter: blur(10px) saturate(115%);
  opacity: 0;
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
:root[data-theme="dark"] .modal-backdrop { background: rgba(0, 0, 0, 0.62); }
.modal-root.is-open .modal-backdrop { opacity: 1; }

.modal {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  /* dvh = visible viewport on iOS Safari (excludes URL bar + bottom toolbar
     when they're showing), so the modal never extends behind browser chrome. */
  max-height: min(880px, calc(100dvh - 24px));
  background: var(--surface);
  box-shadow: var(--shadow-modal);
  border: 1px solid var(--hair-2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(28px) scale(0.96);
  opacity: 0;
  transition:
    transform 0.42s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-root.is-open .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--hair-2);
  z-index: 10;
  transition: background 0.2s ease, transform 0.25s ease;
}
:root[data-theme="dark"] .modal-close { background: rgba(20, 20, 20, 0.86); }
.modal-close:hover { transform: rotate(90deg); }

/* Scroll wrapper — everything inside scrolls vertically as ONE column */
.modal-scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}
.modal-scroll::-webkit-scrollbar { width: 6px; }
.modal-scroll::-webkit-scrollbar-thumb { background: var(--hair-2); }

/* Photos at top of the card — full aspect ratio, no cropping. */
.modal-media {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: var(--bg-tint);
}
.modal-media:empty { display: none; }
.modal-media img {
  width: 100%;
  height: auto;
  display: block;
  background: var(--bg-tint);
  border-bottom: 1px solid var(--hair);
  /* no object-fit: image keeps its natural proportions; scroll handles tall ones */
}
.modal-media img:last-child { border-bottom: 0; }

.modal-body {
  padding: 32px clamp(26px, 3.4vmin, 40px) clamp(26px, 3vmin, 32px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-cat {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-cat::before {
  content: '';
  display: inline-block;
  width: 24px; height: 1px;
  background: var(--ink);
  opacity: 0.6;
}
.modal-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-stretch: expanded;
  font-size: clamp(24px, 3vmin, 34px);
  letter-spacing: 0.04em;
  line-height: 1.1;
  margin: 0;
  color: var(--ink);
  text-transform: uppercase;
}
.modal-desc {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-2);
  white-space: pre-wrap;
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  padding-top: 18px;
  border-top: 1px solid var(--hair);
  margin-top: 4px;
}

.btn {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 12px 22px;
  border: 1px solid var(--hair-2);
  background: transparent;
  color: var(--ink);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink); }
.btn.primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.btn.primary:hover { transform: translateY(-1px); border-color: var(--ink); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn[hidden] { display: none !important; }

/* ── Contact form ────────────────────────────────────────────── */
.contact-modal .modal-media { display: none; }
.contact-intro {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-2);
  margin: 0;
}

.form {
  display: grid;
  gap: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input,
.field textarea {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--hair-2);
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
  resize: none;
}
.field textarea { min-height: 110px; max-height: 220px; resize: vertical; }
.field input:focus,
.field textarea:focus {
  border-color: var(--ink);
  background: var(--surface-2);
}

.form-status {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  min-height: 14px;
  color: var(--muted);
}
.form-status.is-success { color: #166534; }
:root[data-theme="dark"] .form-status.is-success { color: #5eea9a; }
.form-status.is-error   { color: #b91c1c; }
:root[data-theme="dark"] .form-status.is-error   { color: #ff7676; }

/* ════════════════════════════════════════════════════════════════
   Cursor-following node hint — "Drag or click" label.
   Negative (ink fill, paper text). Desktop-only: hidden on touch.
   ════════════════════════════════════════════════════════════════ */
.node-hint {
  position: fixed;
  top: 0; left: 0;
  z-index: 28;
  padding: 6px 10px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(14px, 16px) scale(0.92);
  transform-origin: 0 0;
  transition:
    opacity   0.16s ease,
    transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 20px -10px rgba(15, 15, 15, 0.45);
  will-change: transform, left, top;
}
.node-hint.is-visible {
  opacity: 1;
  transform: translate(14px, 16px) scale(1);
}
:root[data-theme="dark"] .node-hint {
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, 0.85);
}
@media (hover: none) and (pointer: coarse) {
  .node-hint { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .node-hint { transition: opacity 0.16s ease; }
}

/* ════════════════════════════════════════════════════════════════
   Pan hint — mobile-only chip telling the user the graph is draggable.
   Auto-fades in shortly after load, dismisses on first interaction
   (pointerdown on .stage) or after a few seconds.
   ════════════════════════════════════════════════════════════════ */
.graph-pan-hint {
  display: none;            /* shown only on touch / narrow viewports */
  position: fixed;
  /* Lift clear of the iOS Safari bottom toolbar (chrome ≠ safe-area-inset),
     so the chip is actually visible on phones instead of hiding under it. */
  bottom: max(78px, calc(env(safe-area-inset-bottom) + 78px));
  left: 50%;
  transform: translate(-50%, 8px);
  z-index: 24;
  padding: 9px 14px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  white-space: nowrap;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 12px 28px -14px rgba(15,15,15,0.45);
  transition:
    opacity   0.32s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}
.graph-pan-hint svg { width: 14px; height: 14px; }
.graph-pan-hint.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
@media (hover: none) and (pointer: coarse), (max-width: 760px) {
  .graph-pan-hint { display: inline-flex; }
}
:root[data-theme="dark"] .graph-pan-hint {
  box-shadow: 0 12px 28px -14px rgba(0,0,0,0.8);
}

/* ════════════════════════════════════════════════════════════════
   Cookie consent — bottom-right popup + dedicated policy modal.
   ════════════════════════════════════════════════════════════════ */
.cookie-bot {
  position: fixed;
  bottom: clamp(18px, 2.6vmin, 28px);
  right:  clamp(18px, 2.6vmin, 28px);
  z-index: 26;
  width: 320px;
  max-width: calc(100vw - 36px);
  opacity: 0;
  visibility: hidden;
  transform: translate(16px, 32px) scale(0.94);
  transform-origin: 100% 100%;
  transition:
    opacity   0.45s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.6s  cubic-bezier(0.34, 1.56, 0.64, 1),
    visibility 0s linear 0.6s;
  pointer-events: none;
}
.cookie-bot.is-open {
  opacity: 1;
  visibility: visible;
  transform: translate(0, 0) scale(1);
  transition:
    opacity   0.45s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.6s  cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}
.cookie-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hair-2);
  box-shadow:
    0 26px 60px -22px rgba(15,15,15,0.30),
    0 12px 28px -16px rgba(15,15,15,0.16);
  padding: 18px 18px 14px;
}
:root[data-theme="dark"] .cookie-card {
  box-shadow:
    0 26px 60px -22px rgba(0,0,0,0.7),
    0 12px 28px -16px rgba(0,0,0,0.5);
}
.cookie-close {
  position: absolute;
  top: 6px; right: 8px;
  width: 22px; height: 22px;
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1;
  color: var(--soft);
  background: transparent;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
}
.cookie-close:hover { color: var(--ink); background: var(--hair); }
.cookie-text {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  margin: 0 0 12px;
  padding-right: 18px;
}
.cookie-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cookie-accept,
.cookie-policy {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 9px 14px;
  border: 1px solid var(--hair-2);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.cookie-accept {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.cookie-accept:hover { transform: translateY(-1px); }
.cookie-policy:hover { background: var(--surface-2); border-color: var(--ink); }

.cookie-policy-body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cookie-policy-body p { margin: 0; }
.cookie-policy-body h4 {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 14px 0 2px;
}
.cookie-policy-body ul {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cookie-policy-body li::marker { color: var(--soft); }
.cookie-policy-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-tint);
  padding: 1px 6px;
  border: 1px solid var(--hair);
  color: var(--ink);
}
.cookie-policy-body strong { color: var(--ink); font-weight: 500; }

@media (max-width: 600px) {
  .cookie-bot {
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
    right:  max(10px, env(safe-area-inset-right, 10px));
    left:   max(10px, env(safe-area-inset-left, 10px));
    width: auto;
    max-width: none;
    transform: translate(0, 32px) scale(0.96);
  }
  .cookie-bot.is-open { transform: translate(0, 0) scale(1); }
  .cookie-card { padding: 16px 16px 14px; }
  .cookie-text { font-size: 11px; padding-right: 24px; }
}

/* ════════════════════════════════════════════════════════════════
   Mascot bot — floating helper bottom-left. Monospace, square, hairlines.
   ════════════════════════════════════════════════════════════════ */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.mascot-bot {
  position: fixed;
  bottom: clamp(18px, 2.6vmin, 28px);
  left:   clamp(18px, 2.6vmin, 28px);
  z-index: 25;
  width: 360px;
  max-width: calc(100vw - 36px);
  opacity: 0;
  visibility: hidden;
  transform: translate(-14px, 42px) scale(0.92);
  transform-origin: 0% 100%;
  transition:
    opacity   0.5s   cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.72s  cubic-bezier(0.34, 1.56, 0.64, 1),
    visibility 0s linear 0.72s;
  pointer-events: none;
}
.mascot-bot.is-open {
  opacity: 1;
  visibility: visible;
  transform: translate(0, 0) scale(1);
  transition:
    opacity   0.5s   cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.72s  cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.mascot-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hair-2);
  box-shadow:
    0 38px 84px -28px rgba(15,15,15,0.34),
    0 16px 32px -16px rgba(15,15,15,0.18);
  padding: 22px 22px 18px;
}
:root[data-theme="dark"] .mascot-card {
  box-shadow:
    0 38px 84px -28px rgba(0,0,0,0.7),
    0 16px 32px -16px rgba(0,0,0,0.55);
}

.mascot-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 26px; height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--soft);
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}
.mascot-close:hover { color: var(--ink); background: var(--hair); }
.mascot-close:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }

.mascot-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: flex-start;
}

.mascot-avatar {
  width: 56px; height: 56px;
  flex-shrink: 0;
  position: relative;
  animation: mascotBob 4.5s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
.mascot-avatar img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
:root[data-theme="dark"] .mascot-avatar img {
  filter: invert(0.94) hue-rotate(180deg);
}
@keyframes mascotBob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-4px) rotate(1deg); }
}
@media (prefers-reduced-motion: reduce) {
  .mascot-avatar { animation: none; }
}

.mascot-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mascot-bubble {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--ink);
  margin: 0;
  min-height: 38px;
}
.mascot-bubble::after {
  content: '▍';
  margin-left: 2px;
  font-weight: 400;
  opacity: 0.55;
  animation: mascotCaret 0.9s steps(2) infinite;
}
.mascot-bubble.is-done::after { content: none; }
@keyframes mascotCaret { 50% { opacity: 0; } }

.mascot-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mascot-form input {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.01em;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--hair-2);
  padding: 9px 0;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease;
  width: 100%;
  min-width: 0;
}
.mascot-form input::placeholder { color: var(--soft); }
.mascot-form input:focus { border-bottom-color: var(--ink); }

.mascot-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.mascot-send {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  padding: 9px 18px;
  background: var(--ink);
  color: var(--bg);
  border: 1px solid var(--ink);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1), opacity 0.2s ease;
}
.mascot-send:hover  { transform: translateY(-1px); }
.mascot-send[disabled] { opacity: 0.5; cursor: wait; transform: none; }

.mascot-status {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  min-height: 12px;
}
.mascot-status.is-error   { color: #b91c1c; }
.mascot-status.is-success { color: #166534; }
:root[data-theme="dark"] .mascot-status.is-error   { color: #ff7676; }
:root[data-theme="dark"] .mascot-status.is-success { color: #5eea9a; }

.mascot-success-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--ink);
  margin: 0;
  text-transform: none;
}
.mascot-success-text {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  letter-spacing: 0.01em;
  color: var(--ink-2);
  margin: 0;
}

.mascot-stage[hidden] { display: none; }

@media (max-width: 600px) {
  .mascot-bot {
    bottom: max(12px, env(safe-area-inset-bottom, 12px));
    left:   max(10px, env(safe-area-inset-left, 10px));
    right:  max(10px, env(safe-area-inset-right, 10px));
    width: auto;
    max-width: none;
    transform: translate(0, 42px) scale(0.94);
  }
  .mascot-bot.is-open { transform: translate(0, 0) scale(1); }
  .mascot-card { padding: 18px 18px 16px; }
  .mascot-row  { gap: 12px; }
  .mascot-avatar { width: 44px; height: 44px; }
  .mascot-bubble { font-size: 11px; min-height: 32px; }
  .mascot-form input { font-size: 16px; padding: 11px 0; } /* prevent iOS zoom */
  .mascot-send { padding: 11px 18px; font-size: 10px; }
}

/* ════════════════════════════════════════════════════════════════
   Cinematic entrance — staggered reveal on first paint.
   Registered properties so we can interpolate node scale/translate
   alongside the parallax + magnetic transforms.
   ════════════════════════════════════════════════════════════════ */
@property --enter-scale {
  syntax: '<number>';
  inherits: false;
  initial-value: 1;
}
@property --enter-y {
  syntax: '<length>';
  inherits: false;
  initial-value: 0px;
}

.is-loading .node        { opacity: 0; pointer-events: none; }
.is-loading #graph-edges { opacity: 0; }

body:not(.is-loading) .topbar      { animation: enterDown 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.05s both; }
body:not(.is-loading) .hero        { animation: enterUp   0.75s cubic-bezier(0.16, 1, 0.3, 1) 0.20s both; }
body:not(.is-loading) #logo-stage  { animation: logoIn    0.9s cubic-bezier(0.16, 1, 0.3, 1) 0.30s both; }
body:not(.is-loading) #graph-edges { animation: fadeIn    0.7s ease 0.55s both; }
body:not(.is-loading) .footer      { animation: enterUp   0.75s cubic-bezier(0.16, 1, 0.3, 1) 1.10s both; }
body:not(.is-loading) .node        { animation: nodeIn    0.65s cubic-bezier(0.16, 1, 0.3, 1) both; }

@keyframes enterDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes enterUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* Logo: keep the centered translate, tween scale via inner canvas wrapper.
   The host stays at translate(-50%, -50%); scale is on canvas. */
@keyframes logoIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
#logo-stage canvas,
#logo-fallback {
  transform-origin: 50% 50%;
  animation: logoScale 0.95s cubic-bezier(0.16, 1, 0.3, 1) 0.30s both;
}
@keyframes logoScale {
  from { transform: scale(0.74); }
  to   { transform: scale(1); }
}

/* Nodes — animate via registered custom properties so we can compose with
   parallax + magnetic transforms below without overriding them. */
@keyframes nodeIn {
  from { opacity: 0; --enter-scale: 0.92; --enter-y: 14px; }
  to   { opacity: 1; --enter-scale: 1;    --enter-y: 0px;  }
}

/* Magnetic + parallax layer */
.node {
  --mag-x: 0px;
  --mag-y: 0px;
}

/* ════════════════════════════════════════════════════════════════
   Responsive — tablet → phone → small phone, plus touch overrides.
   ════════════════════════════════════════════════════════════════ */

/* Tablet & narrow desktop (≤1024px) — subtle reduction. */
@media (max-width: 1024px) {
  :root {
    --node-w: 150px;
    --node-h: 138px;
    --node-thumb-h: 84px;
    --logo-d: 252px;
  }
  .hero-title { font-size: clamp(24px, 4vmin, 42px); }
  .topbar { gap: 18px; }
}

/* Phone & small tablet (≤760px) — single-column hero, collapsed footer. */
@media (max-width: 760px) {
  :root {
    --node-w: 142px;
    --node-h: 132px;
    --node-thumb-h: 80px;
    --logo-d: 220px;
    --grid: 22px;
    --tick: 12px;
    --frame-inset: clamp(14px, 2vmin, 22px);
  }
  .app {
    padding:
      max(clamp(16px, 2.4vmin, 24px), env(safe-area-inset-top, 0px))
      max(clamp(18px, 3vmin,   28px), env(safe-area-inset-right, 0px))
      max(clamp(16px, 2.4vmin, 24px), env(safe-area-inset-bottom, 0px))
      max(clamp(18px, 3vmin,   28px), env(safe-area-inset-left, 0px));
    gap: clamp(10px, 1.8vmin, 18px);
  }
  .topbar { gap: 12px; padding-bottom: 10px; }
  .brand { gap: 10px; }
  .brand-logo { height: 24px; }
  .brand-name { font-size: 12px; letter-spacing: 0.22em; }
  .brand-suffix, .brand-rule, .status, .nav-divider { display: none; }
  .nav { gap: 6px; }
  .icon-btn { width: 30px; height: 30px; }
  .icon-btn svg { width: 14px; height: 14px; }
  .nav-group button { padding: 5px 7px; font-size: 10px; letter-spacing: 0.20em; }

  .hero { gap: 14px; padding-top: 0; }
  .hero .portrait { width: 56px; height: 56px; }
  .hero-stack { gap: 6px; min-width: 0; }
  .hero-title { font-size: clamp(20px, 5.2vmin, 28px); letter-spacing: 0.02em; line-height: 1.0; }
  .hero-meta { font-size: 10px; gap: 8px; flex-wrap: wrap; letter-spacing: 0.18em; }

  .footer { grid-template-columns: 1fr; justify-items: center; gap: 10px; padding-top: 10px; }
  .footer-left, .footer-right { display: none; }
  .cta { padding: 14px 22px; letter-spacing: 0.28em; font-size: 10px; gap: 10px; }
  .cta-arrow { width: 11px; height: 11px; }
}

/* Phone portrait (≤480px) — aggressive compression. */
@media (max-width: 480px) {
  :root {
    --node-w: 128px;
    --node-h: 118px;
    --node-thumb-h: 68px;
    --logo-d: 172px;
    --grid: 18px;
    --tick: 10px;
  }
  .brand-logo { height: 22px; }
  .brand-name { font-size: 11px; letter-spacing: 0.18em; }
  .hero .portrait { width: 48px; height: 48px; }
  .hero-title { font-size: clamp(18px, 5.8vmin, 24px); }
  .hero-meta { font-size: 9px; gap: 6px; }
  .meta-sep { display: none; }
  .cta { padding: 13px 20px; font-size: 10px; letter-spacing: 0.24em; }
}

/* Very short viewport (landscape phones, ≤500h) — let the page scroll
   so the graph isn't squished into a sliver. */
@media (max-height: 500px) and (max-width: 900px) {
  html, body { overflow: auto; }
  .app { position: relative; min-height: 100vh; }
  .frame-ticks { position: absolute; }
}

/* Touch-primary devices — kill mouse-centric effects that look broken
   without a cursor (parallax drift, magnetic hover). Drag still works
   via pointer events. */
@media (hover: none) and (pointer: coarse) {
  .stage      { --par-x: 0px; --par-y: 0px; }
  .node       { --mag-x: 0px; --mag-y: 0px; }
  .node:hover { border-color: var(--node-bd); box-shadow: var(--node-sh); }
}

/* Modal — comfortable on phones (full-width, edge-to-edge stacking actions).
   Top/bottom padding reserves room for iOS Safari URL bar + bottom toolbar
   so the close (X) and action buttons aren't hidden behind browser chrome.
   `dvh` shrinks when chrome is visible; the hard-coded mins cover the worst
   case (collapsed bars on iPhones where env() returns the notch offset only). */
@media (max-width: 600px) {
  .modal-root {
    padding:
      max(64px, calc(env(safe-area-inset-top, 0px) + 14px))
      12px
      max(80px, calc(env(safe-area-inset-bottom, 0px) + 60px));
  }
  .modal       { max-height: calc(100dvh - 144px); }
  .modal-close { top: 10px; right: 10px; width: 32px; height: 32px; }
  .modal-body  { padding: 24px 18px 20px; gap: 12px; }
  .modal-title { font-size: clamp(20px, 5.4vmin, 26px); letter-spacing: 0.03em; }
  .modal-desc  { font-size: 14px; line-height: 1.6; }
  .modal-cat::before { width: 16px; }
  .modal-actions {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: stretch;
    padding-top: 14px;
  }
  .modal-actions .btn { flex: 1 1 0; min-width: 0; padding: 13px 14px; font-size: 10px; letter-spacing: 0.18em; }
  /* 16px input font prevents iOS Safari from zooming on focus. */
  .field input,
  .field textarea { font-size: 16px; padding: 12px 13px; }
  .field label    { font-size: 9px; letter-spacing: 0.20em; }
  .form          { gap: 12px; }
}
