/* ===== ADHD Capital ===== */

:root {
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', Times, serif;

  /* dark (default) — logo palette: black + cyan neon glow */
  --bg: #04070b;
  --fg: #bfe6f7;
  --fg-strong: #eaf8ff;
  --fg-muted: #6f93a4;
  --fg-faint: #41606e;
  --accent: #8fe6ff;
  --line: rgba(127, 220, 255, 0.14);
  --glow: rgba(120, 210, 255, 0.55);
  --halo: rgba(86, 176, 232, 0.12);
  --up: #74e0a3;    /* gains */
  --down: #ff7d92;  /* declines */
}

html.light {
  --bg: #eef5fa;
  --fg: #0d2a36;
  --fg-strong: #04141d;
  --fg-muted: #5a7d8c;
  --fg-faint: #9bb6c2;
  --accent: #0a86b8;
  --line: rgba(12, 70, 100, 0.16);
  --glow: rgba(40, 150, 200, 0.30);
  --halo: rgba(120, 185, 225, 0.20);
  --up: #1f9d57;
  --down: #d6536a;
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;   /* no surprise font inflation on iOS rotation */
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  background-color: var(--bg);
  background-image: radial-gradient(60rem 44rem at 50% 50%, var(--halo), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--fg);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .35s ease, color .35s ease;
}

/* ===== Top bar ===== */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  /* clear the notch / rounded corners on phones */
  padding: max(1.4rem, env(safe-area-inset-top)) max(1.6rem, env(safe-area-inset-right)) 1.4rem max(1.6rem, env(safe-area-inset-left));
}
@media (min-width: 768px) {
  .topbar { padding: max(1.8rem, env(safe-area-inset-top)) max(2.2rem, env(safe-area-inset-right)) 1.8rem max(2.2rem, env(safe-area-inset-left)); }
}

/* Wordmark: logo mark + serif name, top-left — sized in proportion (Paradigm-style) */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;           /* logo sits close to the text */
  text-decoration: none;
  color: var(--fg-strong);
}
.brandmark {
  width: 40px;
  height: 40px;
  flex: none;
  display: block;
  margin: -5px 0;         /* glow overflows the bar without enlarging its row */
  transform: translateY(-3px);   /* nudge up so the D sits level with the wordmark */
  /* mark.png is cropped tight to the D and transparent — scales cleanly, no edge */
}
.brand-name {
  font-family: var(--font-serif);
  font-size: clamp(19px, 1.9vw, 25px);   /* matched to the logo height, modest like Paradigm */
  font-weight: 500;
  letter-spacing: 0.005em;
  line-height: 1;
}
@media (max-width: 420px) {
  .brandmark { width: 34px; height: 34px; }
  .brand-name { font-size: 18px; }
}

.controls { display: flex; align-items: center; gap: 1.2rem; }
.brand { cursor: default; }

/* Sign in button — ASCII bracket style, matching ADHDECK */
.signin {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  max-width: 42vw;
  white-space: nowrap;
  padding: 6px 4px;
  background: transparent;
  border: 0;
  color: var(--fg-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .18s ease, letter-spacing .18s ease;
}
@media (min-width: 768px) { .signin { font-size: 12px; } }
.signin .br {
  display: inline-block;
  transform: scaleY(1.7);
  color: var(--accent);
  text-shadow: 0 0 8px var(--glow);
  transition: transform .2s ease, text-shadow .2s ease;
}
.signin .signin-label { overflow: hidden; text-overflow: ellipsis; }
.signin:hover { color: var(--accent); }
.signin:hover .br { transform: scaleY(2); text-shadow: 0 0 16px var(--glow); }
.signin:focus-visible { outline: none; color: var(--accent); }
.signin.is-authed { letter-spacing: 0.1em; text-transform: none; }
/* signed in but onboarding unfinished → brackets burn amber + a nudge appears */
.signin.is-pending .br { color: #ffd87a; text-shadow: 0 0 8px rgba(255, 201, 107, 0.65), 0 0 16px rgba(255, 201, 107, 0.4); }
.signin.is-pending:hover .br { text-shadow: 0 0 16px rgba(255, 201, 107, 0.85); }
.onb-nudge {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: #ffd87a; text-decoration: none; white-space: nowrap;
  text-shadow: 0 0 8px rgba(255, 201, 107, 0.45);
  animation: onbPulse 2.6s ease-in-out infinite;
}
.onb-nudge:hover { color: #ffe6a8; text-shadow: 0 0 12px rgba(255, 201, 107, 0.7); }
@keyframes onbPulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .onb-nudge { animation: none; opacity: 0.9; } }
@media (max-width: 560px) { .onb-nudge { display: none; } }

/* Join Us → sign-in gate (shown in the apply modal when signed out) */
.apply-gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.85rem;
  padding: 1.6rem 0 0.8rem;
  animation: gateIn .3s ease-out both;
}
@keyframes gateIn { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: none; } }
.apply-gate-mark { width: 52px; height: 52px; filter: drop-shadow(0 0 12px var(--glow)); opacity: 0.95; }
.apply-gate-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(24px, 3.4vw, 30px);
  line-height: 1.05;
  color: var(--fg-strong);
  text-shadow: 0 0 18px var(--glow);
}
.apply-gate-msg { margin: 0; max-width: 38ch; color: var(--fg-muted); font-size: 14px; line-height: 1.6; }
.apply-gate-btn { font-size: 15px; letter-spacing: 0.32em; margin-top: 0.4rem; }
.apply-gate-btn .br { transform: scaleY(1.95); }
.apply-gate-btn:hover .br { transform: scaleY(2.15); }

/* ===== Language box (dropdown) ===== */
.lang { position: relative; }

.lang-trigger {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 6px 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
@media (min-width: 768px) { .lang-trigger { font-size: 12px; } }
.lang-trigger:hover, .lang.open .lang-trigger {
  border-color: var(--accent);
  color: var(--fg-strong);
  box-shadow: 0 0 10px rgba(143, 230, 255, 0.12);
}
.lang-caret { font-size: 9px; transition: transform .2s ease; color: var(--fg-faint); }
.lang.open .lang-caret { transform: rotate(180deg); color: var(--accent); }

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 150px;
  margin: 0;
  padding: 5px;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 1px;
  animation: menuIn .16s ease-out both;
}
.lang-menu[hidden] { display: none; }
@keyframes menuIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

.lang-item {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 8px 9px;
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-muted);
  transition: color .15s ease, background-color .15s ease;
}
.lang-item:hover { color: var(--fg-strong); background-color: rgba(143, 230, 255, 0.06); }
.lang-item[aria-selected="true"] { color: var(--accent); }
.lang-item .code { font-size: 10px; letter-spacing: 0.16em; color: var(--fg-faint); }
.lang-item[aria-selected="true"] .code { color: var(--accent); }

/* ===== Hero ===== */
.hero {
  position: relative;
  z-index: 10;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem max(1rem, env(safe-area-inset-right)) 4rem max(1rem, env(safe-area-inset-left));
}

.field-wrap {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}

/* the morphing square→circle field */
.ascii-field,
.spark-field {
  grid-area: 1 / 1;
  margin: 0;
  font-family: var(--font-mono);
  white-space: pre;
  line-height: 1.05;
  letter-spacing: 0;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
.ascii-field {
  color: var(--fg-strong);
  text-shadow: 0 0 6px var(--glow), 0 0 16px var(--glow);
  cursor: crosshair;
  pointer-events: auto;
  animation: fieldFadeIn 1.1s ease-out both;
}
.spark-field {
  color: #ffffff;
  text-shadow: 0 0 6px var(--accent), 0 0 16px var(--glow);
}
@keyframes fieldFadeIn { 0% { opacity: 0; } 100% { opacity: 1; } }

/* ===== Tagline (Paradigm-style serif prose) — caption below the figure ===== */
.tagline {
  position: absolute;
  left: 50%;
  bottom: clamp(1.4rem, 5vh, 3rem);
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  width: max-content;
  max-width: 90vw;
  font-family: var(--font-serif);
  font-size: clamp(17px, 2vw, 23px);
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--fg);
  text-align: center;
}

/* ===== Access nodes + connector wires (Paradigm-style) ===== */
.wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}
.wires line {
  stroke: var(--wire-stroke, var(--line));   /* idle colour fed by a var so ID rules don't beat state rules */
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  opacity: 0.7;
  transition: stroke .25s ease, opacity .25s ease;
}
/* the always-live wire reads brighter at idle — set the var, NOT stroke directly,
   so .active / .dashed (plain class rules) still win over this ID selector */
#wire-join { --wire-stroke: rgba(127, 220, 255, 0.22); }
.wires line.active {
  stroke: var(--accent);
  opacity: 1;
  filter: drop-shadow(0 0 4px var(--glow));
}

/* a faint cyan glint streams inward along each wire — same calm clock as the hero */
.wire-glint {
  stroke: var(--accent);
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  opacity: 0.8;
  stroke-dasharray: 4 96;          /* one short lit segment per normalised 100u line */
  filter: drop-shadow(0 0 3px var(--glow));
  animation: wireGlint 8.5s linear infinite;
}
@keyframes wireGlint { from { stroke-dashoffset: 0; } to { stroke-dashoffset: 100; } }

/* when a node is hovered, bright dashes stream OUT of the hub to the other two
   modules — a moving "data transmission" (the wires run centre→node, so a
   negative dashoffset animation travels outward, away from the hub). */
.wires line.dashed {
  stroke: var(--accent);
  opacity: 1;
  stroke-width: 2;
  stroke-dasharray: 4 12;          /* fewer, fatter pulses → the transmission reads clearly */
  stroke-linecap: round;           /* each dash glows like a travelling packet */
  filter: drop-shadow(0 0 5px var(--glow));
  animation: wireTx 0.7s linear infinite;
}
@keyframes wireTx { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -16; } }

/* the always-on idle glint would fight the transmission — mute it while engaged */
.wires.engaged .wire-glint { opacity: 0; }

/* ===== Central hub where the three wires converge ===== */
.hub {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  width: 18px; height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--fg-faint);
  background: var(--bg);
  pointer-events: none;
  transition: border-color .25s ease, box-shadow .25s ease;
}
.hub-core {
  width: 5px; height: 5px;
  background: rgba(143, 230, 255, 0.22);
  box-shadow: none;
  transition: width .25s ease, height .25s ease, background-color .25s ease, box-shadow .25s ease;
}
.hub.lit { border-color: var(--accent); box-shadow: 0 0 12px var(--glow); }
.hub.lit .hub-core { width: 9px; height: 9px; background: var(--accent); box-shadow: 0 0 8px var(--glow); }

.nodes { position: absolute; inset: 0; z-index: 3; pointer-events: none; }

/* the whole button (box + label + padding) is one large hit target;
   it's anchored by the box edge that meets the wire. */
.node {
  position: absolute;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: none;
  border: 0;
  font-family: var(--font-mono);
  cursor: pointer;
  pointer-events: auto;
}
.node--right { flex-direction: row; }       /* [box][label] — box on the inner side */
.node--left  { flex-direction: row-reverse; }
.node:focus-visible { outline: none; }

.node-box {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--bg);
  border: 1px dashed var(--fg-faint);
  color: var(--fg-muted);
  transition: border-color .2s ease, color .2s ease, box-shadow .2s ease;
}
.node:hover .node-box, .node:focus-visible .node-box { border-color: var(--accent); color: var(--fg-strong); }

.node-q { font-size: 16px; line-height: 1; }
/* active boxes hold a faint dormant square that grows + brightens on hover/focus */
.node-fill {
  width: 7px; height: 7px;
  background: rgba(143, 230, 255, 0.22);
  box-shadow: none;
  transition: width .25s ease, height .25s ease, background-color .25s ease, box-shadow .25s ease;
}
.node--join:hover .node-fill, .node--join:focus-visible .node-fill, .node--join.is-hot .node-fill,
.node--manifest:hover .node-fill, .node--manifest:focus-visible .node-fill, .node--manifest.is-hot .node-fill,
.node--projects:hover .node-fill, .node--projects.is-hot .node-fill {
  width: 13px; height: 13px;
  background: var(--accent);
  box-shadow: 0 0 9px var(--glow);
}

.node-info {
  display: flex;
  align-items: center;
  min-height: 30px;            /* match .node-box so the label centres against the square */
  gap: 0.6rem;
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.62;
  transition: opacity .2s ease;
}
.node:hover .node-info, .node:focus-visible .node-info { opacity: 1; }

.node-label { color: var(--fg-strong); }
.node-state { color: var(--fg-muted); font-size: 11px; }
.node--locked .node-state { letter-spacing: 0.2em; }

.node--join .node-box { border-style: solid; border-color: var(--accent); }
.node--join .node-arrow { color: var(--accent); font-size: 15px; transition: transform .2s ease; }
.node--join:hover .node-box { box-shadow: 0 0 12px var(--glow); }
.node--join:hover .node-arrow { transform: translateX(3px); }

/* ===== OUR PROJECTS — a deck of squares with ASCII art ===== */
.node--projects { align-items: flex-start; }
.node--projects .node-box { border-style: solid; border-color: var(--accent); }
.node--projects:hover .node-box { box-shadow: 0 0 12px var(--glow); }

.proj-deck {
  position: absolute;
  top: calc(100% + 14px);
  left: 0;                         /* hangs under the marker, opening into the right margin */
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.proj {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: 116px;
  text-align: center;
  text-decoration: none;
  color: inherit;
}
.proj-art {
  position: relative;
  width: 116px;
  height: 116px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--line);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.proj-ascii {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 8px;
  line-height: 1.05;
  white-space: pre;
  color: var(--accent);
  text-shadow: 0 0 6px var(--glow);
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
/* equity-curve chart: green up-ticks, red declines, cyan markers, faint area fill */
.proj-ascii .up   { color: var(--up);   text-shadow: 0 0 6px rgba(116, 224, 163, 0.6); }
.proj-ascii .down { color: var(--down); text-shadow: 0 0 6px rgba(255, 125, 146, 0.6); }
.proj-ascii .mid  { color: var(--accent); }
.proj-ascii .fill { color: var(--fg-faint); text-shadow: none; }
.proj-q { font-size: 36px; line-height: 1; color: var(--fg-faint); }
.proj-name {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-strong);
}
.proj-name--muted { color: var(--fg-faint); }
#projAdhdeck .proj-name { text-transform: none; } /* adhdeck wordmark stays lowercase */
.proj-desc {
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
}

/* active project — glows (live) */
.proj--active { cursor: pointer; }
.proj--active .proj-art { border-color: var(--accent); box-shadow: 0 0 12px var(--glow); }
.proj--active:hover .proj-art { box-shadow: 0 0 20px var(--glow); border-color: var(--fg-strong); }
.proj--active:hover .proj-name { color: var(--accent); }

/* locked project — dormant, no glow */
.proj--locked .proj-art { border-style: dashed; border-color: var(--fg-faint); }

/* ===== Manifest node (active, with teaser text below) ===== */
.node--manifest { align-items: flex-start; gap: 6px; }
.node--manifest .node-box { border-style: solid; border-color: var(--accent); }
.node--manifest .node-arrow { color: var(--accent); font-size: 15px; transition: transform .2s ease; }
.node--manifest:hover .node-box { box-shadow: 0 0 12px var(--glow); }
.node--manifest:hover .node-arrow { transform: translateX(3px); }

.manifest-teaser {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;                       /* hangs under the marker, opening into the left margin */
  width: min(280px, 22vw);        /* stays inside the left margin at any width */
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
}
/* the JOIN node sits on the right, so its teaser hangs open into the right margin */
.node--join { align-items: flex-start; }
.join-teaser { left: 0; right: auto; }
.manifest-text {
  display: block;
  font-family: var(--font-serif);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-muted);
  transition: color .2s ease;
}
.manifest-teaser:hover .manifest-text,
.manifest-teaser:focus-visible .manifest-text { color: var(--fg); }
.manifest-more {
  display: inline-block;
  margin-top: 0.7rem;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity .22s ease, transform .22s ease;
}
.manifest-teaser:hover .manifest-more,
.manifest-teaser:focus-visible .manifest-more { opacity: 1; transform: none; }

/* JOIN teaser: three lines with breathing room; the final line is the seal — the punchline.
   Accent + a touch heavier + soft glow so it reads as the "get in" mark, not decoration. */
.join-copy { display: flex; flex-direction: column; gap: 0.5em; }
.join-seal {
  margin-top: 0.15em;
  color: var(--accent);
  font-weight: 500;
  text-shadow: 0 0 10px var(--glow);
}

/* ambient life: locked boxes breathe (dormant-but-powered), join box has a heartbeat */
.node--locked .node-box { animation: boxBreath 8.5s ease-in-out infinite; }
.node--right.node--locked .node-box { animation-delay: -4.25s; }
@keyframes boxBreath {
  0%, 100% { border-color: var(--fg-faint); box-shadow: 0 0 0 0 transparent; }
  50%      { border-color: color-mix(in srgb, var(--fg-faint) 55%, var(--accent));
             box-shadow: 0 0 7px -1px var(--glow); }
}
.node--locked .node-q { animation: qBreath 8.5s ease-in-out infinite; }
.node--right.node--locked .node-q { animation-delay: -4.25s; }
@keyframes qBreath { 0%, 100% { opacity: 0.55; } 50% { opacity: 0.85; } }

/* on hover/focus, stop the ambient loops so the crisp hover state wins cleanly */
.node:hover .node-box, .node:focus-visible .node-box,
.node:hover .node-q,   .node:focus-visible .node-q { animation: none; }

/* ===== Phones & portrait tablets: the absolute "wire" layout needs a wide, short
   viewport, so below 900px we drop it and stack the figure → tagline → nodes,
   and let the page scroll instead of clipping. ===== */
@media (max-width: 900px) {
  body { overflow-x: hidden; overflow-y: auto; }   /* allow scroll; nothing gets clipped */

  .wires, .hub { display: none; }                  /* hover-wire choreography is desktop-only */

  .hero {
    min-height: 100svh;                            /* stable against mobile URL-bar resize */
    justify-content: center;
    padding: clamp(5.5rem, 14vh, 7rem) max(1.1rem, env(safe-area-inset-right))
             clamp(2.5rem, 7vh, 3.5rem) max(1.1rem, env(safe-area-inset-left));
  }

  .field-wrap { width: 100%; }

  .tagline {
    position: static;
    transform: none;
    width: auto;                                   /* override base max-content → wrap to fit */
    margin: 1.5rem auto 0;
    max-width: min(30ch, 90vw);                    /* vw bound guarantees no horizontal clip */
    font-size: clamp(16px, 4.4vw, 21px);
  }

  /* nodes become a centred, full-width tappable column */
  .nodes {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.1rem;
    width: min(360px, 90vw);                       /* vw bound, not % of a maybe-wider parent */
    margin: 1.8rem auto 0;
    z-index: 4;
  }
  .node {
    position: static;
    transform: none;
    width: 100%;
    max-width: 100%;
    padding: 12px 10px;                            /* ≥44px tall touch target */
  }
  .node--left, .node--right { flex-direction: row; }
  .node-info { opacity: 1; min-width: 0; }         /* no hover on touch → keep labels legible */

  /* manifest, join & projects: [box][label] on the first row, content wraps beneath it */
  .node--manifest, .node--join, .node--projects { flex-wrap: wrap; align-items: center; }
  .manifest-teaser {
    position: static;
    order: 3;
    flex-basis: 100%;
    min-width: 0;                                  /* let the flex item shrink below content */
    width: auto;
    max-width: 100%;
    margin-top: 0.6rem;
  }
  .manifest-text { overflow-wrap: anywhere; }
  .manifest-more { opacity: 1; transform: none; }

  /* projects deck stacks under the label */
  .proj-deck {
    position: static;
    order: 3;
    flex-basis: 100%;
    flex-wrap: wrap;
    margin-top: 0.8rem;
  }

  /* roomier tap area for the language switch */
  .lang-trigger { padding: 9px 12px; }
}

/* Landscape phones / very short viewports: trim the vertical rhythm so less scroll */
@media (max-width: 900px) and (max-height: 560px) {
  .hero { padding-top: clamp(4.5rem, 18vh, 5.5rem); padding-bottom: 2rem; }
  .tagline { margin-top: 1rem; }
  .nodes { margin-top: 1.1rem; }
}

/* ===== Apply modal ===== */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(2, 6, 10, 0.72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
html.light .modal-backdrop { background: rgba(40, 70, 90, 0.30); }

/* animated ASCII contour rings radiating around the open dialog (drawn by JS).
   sits above the backdrop, below the panel (DOM order handles the stacking). */
.modal-fx {
  position: absolute;
  inset: 0;
  margin: 0;
  pointer-events: none;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.08;
  letter-spacing: 0;
  white-space: pre;
  color: var(--accent);
  text-shadow: 0 0 6px var(--glow);   /* soft glow so the wisps read as light, not text */
  opacity: 0;
  transition: opacity .7s ease;
  user-select: none;
  -webkit-user-select: none;
}
.modal-fx.is-on { opacity: 0.42; }

.modal-panel {
  position: relative;
  width: min(440px, 92vw);
  max-height: min(88vh, 88dvh);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 2.2rem 2rem 2rem;
  background: var(--bg);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(143, 230, 255, 0.06), 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: modalIn .25s ease-out both;
}
@keyframes modalIn { 0% { opacity: 0; transform: translateY(8px); } 100% { opacity: 1; transform: none; } }

.modal-x {
  position: absolute; top: 0.4rem; right: 0.5rem;
  width: 40px; height: 40px;             /* comfortable touch target */
  display: grid; place-items: center;
  background: none; border: 0; cursor: pointer;
  color: var(--fg-muted); font-size: 24px; line-height: 1;
  transition: color .18s ease;
}
.modal-x:hover { color: var(--fg-strong); }

.modal-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 28px;
  color: var(--fg-strong);
}
.modal-intro {
  margin: 0 0 1.4rem;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-muted);
}

/* manifest (reading) modal */
.modal-panel--read { width: min(560px, 92vw); padding: 2.6rem 2.4rem 2.4rem; }
.modal-panel--read .modal-title { margin-bottom: 1.1rem; font-size: 30px; }
.manifest-body { display: flex; flex-direction: column; gap: 1rem; }
.manifest-body p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.62;
  color: var(--fg);
}
.manifest-body .manifest-sign {
  margin-top: 0.5rem;
  font-style: italic;
  color: var(--fg-strong);
}

/* apply (join) modal: wider, two-column grid so the detailed form stays scannable */
.modal-panel--apply { width: min(600px, 94vw); padding: 2.4rem 2.2rem 2rem; }

.apply-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1rem; align-items: start; }
/* the [hidden] attribute must win over the grid/flex display above */
.apply-form[hidden], .apply-gate[hidden] { display: none; }
.apply-form > .full,
.apply-form .form-section,
.apply-form .markets,
.apply-form .apply-submit { grid-column: 1 / -1; }

/* section dividers */
.form-section {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0.9rem 0 0.1rem;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--accent);
}
.form-section:first-of-type { margin-top: 0; }
.form-section::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.apply-form label,
.apply-form .field {
  display: flex; flex-direction: column; gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.apply-form .field-label { color: var(--fg-muted); }
.req { color: var(--accent); margin-left: 0.25em; }

/* markets: toggle chips */
.apply-form .chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.check {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--fg-muted);
  transition: border-color .18s ease, color .18s ease, box-shadow .18s ease;
}
.check:hover { border-color: var(--accent); color: var(--fg-strong); }
.check input {
  appearance: none; -webkit-appearance: none;
  width: 12px; height: 12px; margin: 0; flex: none;
  border: 1px solid var(--fg-faint);
  background: transparent;
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.check input:checked { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 8px var(--glow); }
.check:has(input:checked) { border-color: var(--accent); color: var(--fg-strong); }
.check input:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }

.apply-form input, .apply-form textarea {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--fg-strong);
  background: transparent;
  border: 1px solid var(--line);
  padding: 0.6rem 0.7rem;
  border-radius: 0;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
  resize: vertical;
}
.apply-form input:focus, .apply-form textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 10px var(--glow);
}
.apply-form input::placeholder, .apply-form textarea::placeholder {
  color: var(--fg-faint);
  text-transform: none;
  letter-spacing: 0;
  opacity: 1;
}
/* only flag a field once the user has actually interacted with it (not on first open) */
.apply-form input:user-invalid, .apply-form textarea:user-invalid { border-color: rgba(255, 120, 120, 0.55); }
.apply-submit {
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--accent);
  border: 0;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: filter .18s ease, box-shadow .18s ease;
}
.apply-submit:hover { filter: brightness(1.08); box-shadow: 0 0 14px var(--glow); }

.apply-thanks {
  margin: 0.4rem 0 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--fg-strong);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .ascii-field { animation: none; }
  .modal-panel { animation: none; }
  /* the reduce block above only kills transitions — explicitly stop the ambient loops too */
  .node--locked .node-box, .node--locked .node-q,
  .wires line.dashed { animation: none !important; }
  .wire-glint { display: none !important; }
  * { transition: none !important; }
}

/* ===== Modal on small screens (kept last so it wins over the base modal/form rules) ===== */
@media (max-width: 560px) {
  .modal-panel { width: 100%; padding: 2rem 1.4rem 1.6rem; }
  .modal-panel--read { padding: 2.2rem 1.4rem 1.8rem; }
  .modal-panel--apply { width: 100%; padding: 2rem 1.4rem 1.6rem; }
  .modal-title { font-size: 24px; }
  .modal-panel--read .modal-title { font-size: 26px; }
  .manifest-body p { font-size: 15px; line-height: 1.58; }
  /* single column on phones */
  .apply-form { grid-template-columns: 1fr; }
  /* 16px inputs stop iOS from auto-zooming the page on focus */
  .apply-form input, .apply-form textarea { font-size: 16px; }
}
