/* ==========================================================================
   FOGLE design system
   Light: masterpiece red on dirty white
   Dark:  Payne's gray ground with dirty white ink
   Type:  Space Grotesk (retro curved display), IBM Plex Sans, IBM Plex Mono
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;

  --dirty-white:      #F2EFE6;
  --bg:               #F2EFE6;
  --bg-sunken:        #EAE6DA;
  --surface:          #FBF9F4;
  --surface-2:        #F5F2E9;

  --ink:              #191714;
  --ink-2:            #4B4740;
  --ink-3:            #6A6459;

  --red:              #9E1B1B;   /* masterpiece red */
  --red-hover:        #831414;
  --red-ink:          #8A1717;
  --on-red:           #FFFFFF;
  --payne:            #4C5D6B;   /* Payne's gray */
  --asphalt:          #4C5D6B;
  --water:            #3F6E80;
  --park:             #5A7E58;
  --kerb:             #C9C2B2;

  --line:             #D8D2C4;
  --line-strong:      #BFB8A7;
  --focus:            #9E1B1B;

  --d1: #9E1B1B;
  --d2: #B0602A;
  --d3: #8A7420;
  --d4: #3F6B54;
  --d5: #4C5D6B;
  --d6: #6B4E71;

  --shadow-1: 0 1px 2px rgba(25, 23, 20, .06), 0 2px 8px rgba(25, 23, 20, .04);
  --shadow-2: 0 2px 6px rgba(25, 23, 20, .08), 0 12px 32px rgba(25, 23, 20, .09);

  --s1: .25rem; --s2: .5rem;  --s3: .75rem; --s4: 1rem;
  --s5: 1.5rem; --s6: 2rem;   --s7: 3rem;   --s8: 4rem;
  --s9: 6rem;

  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  --maxw: 1180px;
  --ease: cubic-bezier(.22, .61, .36, 1);

  --font-display: "Space Grotesk", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-body:    "IBM Plex Sans", "Segoe UI", Tahoma, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:            #1A2027;
  --bg-sunken:     #141A20;
  --surface:       #232C35;
  --surface-2:     #2A343E;
  --ink:           #EDEAE0;
  --ink-2:         #C3C9CF;
  --ink-3:         #A3ACB5;
  --red:           #C4302B;
  --red-hover:     #D8443E;
  --red-ink:       #F09189;
  --on-red:        #FFFFFF;
  --payne:         #8FA3B3;
  --asphalt:       #3C4956;
  --water:         #4E8598;
  --park:          #6E9A6B;
  --kerb:          #55636F;
  --line:          #37434F;
  --line-strong:   #4A5866;
  --focus:         #F09189;
  --d1: #EE8078; --d2: #E0A25F; --d3: #D6C36A;
  --d4: #79B597; --d5: #9FB3C2; --d6: #B192B8;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.25);
  --shadow-2: 0 2px 6px rgba(0,0,0,.45), 0 14px 36px rgba(0,0,0,.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:            #1A2027;
    --bg-sunken:     #141A20;
    --surface:       #232C35;
    --surface-2:     #2A343E;
    --ink:           #EDEAE0;
    --ink-2:         #C3C9CF;
    --ink-3:         #A3ACB5;
    --red:           #C4302B;
    --red-hover:     #D8443E;
    --red-ink:       #F09189;
    --on-red:        #FFFFFF;
    --payne:         #8FA3B3;
    --asphalt:       #3C4956;
    --water:         #4E8598;
    --park:          #6E9A6B;
    --kerb:          #55636F;
    --line:          #37434F;
    --line-strong:   #4A5866;
    --focus:         #F09189;
    --d1: #EE8078; --d2: #E0A25F; --d3: #D6C36A;
    --d4: #79B597; --d5: #9FB3C2; --d6: #B192B8;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 2px 8px rgba(0,0,0,.25);
    --shadow-2: 0 2px 6px rgba(0,0,0,.45), 0 14px 36px rgba(0,0,0,.4);
  }
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.14;
  margin: 0 0 var(--s4);
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: clamp(2.35rem, 5.4vw, 3.9rem); letter-spacing: -.028em; }
h2 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); letter-spacing: -.022em; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.0625rem; }
p  { margin: 0 0 var(--s4); max-width: 68ch; }

a { color: var(--red-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--red-hover); }

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

hr { border: 0; border-top: 1px solid var(--line); margin: var(--s7) 0; }

::selection { background: var(--red); color: var(--on-red); }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- 3. Layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--s5); }
.section { padding-block: var(--s9); }
.section--tight { padding-block: var(--s8); }
.section--sunken { background: var(--bg-sunken); }
.section-head { max-width: 62ch; margin-bottom: var(--s7); }
.eyebrow {
  font-family: var(--font-mono);
  font-size: .75rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 var(--s3);
  font-weight: 500;
}
.lede { font-size: 1.15rem; color: var(--ink-2); }
.muted { color: var(--ink-2); }
.small { font-size: .9rem; }

.grid { display: grid; gap: var(--s5); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1000px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px)  { .grid-4, .grid-2 { grid-template-columns: 1fr; } }

/* ---------- 4. Skip link + scroll progress ---------- */
.skip-link {
  position: fixed; top: 0; left: 0; z-index: 200;
  transform: translateY(-120%);
  background: var(--red); color: var(--on-red);
  padding: var(--s3) var(--s5);
  font-weight: 600; border-radius: 0 0 var(--radius) 0;
  text-decoration: none;
  transition: transform .18s var(--ease);
}
.skip-link:focus { transform: translateY(0); color: var(--on-red); }

.scroll-progress {
  position: fixed; inset: 0 auto auto 0;
  height: 3px; width: 100%;
  transform: scaleX(0); transform-origin: 0 50%;
  background: var(--red);
  z-index: 120;
  pointer-events: none;
}

/* ---------- 5. Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 110;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.site-header.is-stuck { border-bottom-color: var(--line); background: color-mix(in srgb, var(--bg) 96%, transparent); }
.header-inner { display: flex; align-items: center; gap: var(--s5); height: 68px; }

.brand { display: inline-flex; align-items: center; gap: var(--s3); text-decoration: none; color: var(--ink); }
.brand:hover { color: var(--ink); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-word { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: .06em; }

.nav { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.nav a.nav-link {
  display: inline-block;
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-size: .95rem; font-weight: 500;
  transition: color .16s var(--ease), background .16s var(--ease);
}
.nav a.nav-link:hover { color: var(--ink); background: var(--surface-2); }
.nav a.nav-link[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--red); }

.header-actions { display: flex; align-items: center; gap: var(--s2); margin-left: var(--s2); }

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: inline-grid; place-items: center;
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease), transform .16s var(--ease);
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-2); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn svg { width: 18px; height: 18px; }

.nav-toggle { display: none; }

.mobile-menu {
  position: fixed; inset: 68px 0 0 0;
  background: var(--bg);
  z-index: 105;
  padding: var(--s5);
  display: none;
  overflow-y: auto;
}
.mobile-menu.is-open { display: block; }
.mobile-menu a {
  display: block;
  padding: var(--s4) var(--s2);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.35rem;
}
.mobile-menu a:hover { color: var(--red-ink); }
.mobile-menu .btn { margin-top: var(--s5); width: 100%; }
body.menu-open { overflow: hidden; }

@media (max-width: 1000px) {
  /* Matches the specificity of `.nav a.nav-link` above, which otherwise wins
     and leaves the desktop links overflowing the header. */
  .nav a.nav-link { display: none; }
  .nav-toggle { display: inline-grid; }
}
@media (max-width: 480px) {
  .header-actions .btn { display: none; }
}

/* ---------- 6. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  font-family: var(--font-body);
  font-size: 1rem; font-weight: 600;
  padding: var(--s3) var(--s5);
  min-height: 46px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease),
              transform .16s var(--ease), box-shadow .16s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }

.btn-primary { background: var(--red); color: var(--on-red); box-shadow: var(--shadow-1); }
.btn-primary:hover { background: var(--red-hover); color: var(--on-red); box-shadow: var(--shadow-2); }

.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }

.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }

/* ---------- 7. Hero ---------- */
.hero { padding-block: var(--s8) var(--s9); position: relative; overflow: hidden; }

/* Blurred top down plan of the model, sitting behind the hero as ground
   texture. Masked away from the headline so contrast never suffers. */
.hero-plan {
  position: absolute; inset: -8% -4% -12% -4%;
  z-index: 0; pointer-events: none;
  opacity: .42;
  filter: blur(22px) saturate(.85);
  -webkit-mask-image: radial-gradient(115% 90% at 74% 42%, #000 0%, #000 34%, transparent 76%);
          mask-image: radial-gradient(115% 90% at 74% 42%, #000 0%, #000 34%, transparent 76%);
}
.hero-plan canvas { width: 100%; height: 100%; display: block; }
:root[data-theme="dark"] .hero-plan { opacity: .3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero-plan { opacity: .3; } }
@media (max-width: 720px) { .hero-plan { opacity: .22; } }

.hero > .wrap { position: relative; z-index: 1; }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: var(--s8);
  align-items: center;
}
@media (max-width: 980px) { .hero-grid { grid-template-columns: 1fr; gap: var(--s7); } }

.hero h1 { margin-bottom: var(--s5); }
.hero .lede { font-size: 1.22rem; max-width: 52ch; }
.hero-note { margin-top: var(--s5); font-family: var(--font-mono); font-size: .8rem; color: var(--ink-3); }
.hero-rule { width: 64px; height: 3px; background: var(--red); margin-bottom: var(--s5); border-radius: 2px; }

/* ---------- 8. Twin viewer ---------- */
.twin {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.twin-bar {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  font-family: var(--font-mono); font-size: .75rem;
  color: var(--ink-2); letter-spacing: .04em;
}
.twin-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--d4); flex: none; }
.twin-canvas-holder { position: relative; aspect-ratio: 16 / 11; background: var(--bg-sunken); }
@media (max-width: 620px) { .twin-canvas-holder { aspect-ratio: 4 / 3.4; } }
.twin-canvas-holder canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
.twin-canvas-holder canvas:active { cursor: grabbing; }

.twin-loading {
  position: absolute; inset: 0;
  display: grid; place-content: center; gap: var(--s3); justify-items: center;
  background: var(--bg-sunken);
  transition: opacity .4s var(--ease), visibility .4s;
  font-family: var(--font-mono); font-size: .75rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
}
.twin-loading.is-done { opacity: 0; visibility: hidden; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--red);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.twin-legend {
  position: absolute; left: var(--s4); bottom: var(--s4);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--s3);
  font-family: var(--font-mono); font-size: .68rem;
  color: var(--ink-2);
  display: grid; gap: 4px;
  backdrop-filter: blur(6px);
  max-width: 46%;
}
.legend-row { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.twin-hint {
  position: absolute; right: var(--s4); bottom: var(--s4);
  font-family: var(--font-mono); font-size: .68rem; color: var(--ink-3);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 4px 8px; border-radius: var(--radius-sm);
}
@media (max-width: 620px) { .twin-hint { display: none; } .twin-legend { max-width: 60%; } }

.mode-bar {
  display: flex; flex-wrap: wrap; gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.mode-btn {
  font-family: var(--font-mono); font-size: .72rem;
  letter-spacing: .07em; text-transform: uppercase;
  padding: var(--s2) var(--s3);
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 999px; cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
.mode-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface); }
.mode-btn[aria-pressed="true"] { background: var(--red); color: var(--on-red); border-color: var(--red); }

/* ---------- 9. Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s5);
  box-shadow: var(--shadow-1);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.card h3 { margin-bottom: var(--s2); }
.card p { margin: 0; color: var(--ink-2); font-size: .96rem; }

.card-icon { width: 38px; height: 38px; margin-bottom: var(--s4); color: var(--red-ink); }
.card-num { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .12em; color: var(--ink-3); margin-bottom: var(--s3); }

.problem-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s4); }
.problem-list li { display: grid; grid-template-columns: 26px 1fr; gap: var(--s3); align-items: start; color: var(--ink-2); }
.problem-list svg { width: 20px; height: 20px; color: var(--red-ink); margin-top: 3px; }
.problem-list strong { color: var(--ink); font-weight: 600; }

/* ---------- 10. Steps ---------- */
.steps { display: grid; gap: var(--s5); }
.step {
  display: grid; grid-template-columns: 46px 1fr; gap: var(--s4);
  padding-bottom: var(--s5);
  border-bottom: 1px solid var(--line);
}
.step:last-child { border-bottom: 0; padding-bottom: 0; }
.step-n {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line-strong);
  font-family: var(--font-mono); font-size: .85rem; font-weight: 600;
}
.step h3 { margin-bottom: var(--s2); }
.step p { margin: 0; color: var(--ink-2); }

/* ---------- 11. Data sources ---------- */
.sources { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--s4); }
@media (max-width: 860px) { .sources { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.source {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--s5);
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.source:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.source-mark { height: 34px; margin-bottom: var(--s4); color: var(--ink); }
.source-name { font-size: .88rem; color: var(--ink-2); margin: 0 0 var(--s2); }
.source-use { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); margin: 0; }

/* ---------- 12. Audience ---------- */
.audience { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--s4); }
@media (max-width: 1000px) { .audience { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 560px)  { .audience { grid-template-columns: 1fr; } }
.audience-item { padding: var(--s5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.audience-item h3 { font-size: 1.05rem; }
.audience-item p { font-size: .93rem; margin: 0; color: var(--ink-2); }

/* ---------- 13. FAQ ---------- */
.faq { display: grid; gap: var(--s2); max-width: 820px; }
.faq details {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .18s var(--ease);
}
.faq details[open] { border-color: var(--line-strong); }
.faq summary {
  cursor: pointer; list-style: none;
  padding: var(--s4) var(--s5);
  font-family: var(--font-display); font-weight: 600; font-size: 1.05rem;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  color: var(--ink);
  transition: background .16s var(--ease);
}
.faq summary:hover { background: var(--surface-2); }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; flex: none; width: 11px; height: 11px;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .22s var(--ease);
}
.faq details[open] summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.faq .faq-body { padding: 0 var(--s5) var(--s5); color: var(--ink-2); }
.faq .faq-body p:last-child { margin-bottom: 0; }

/* ---------- 14. Forms ---------- */
.form-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--s7);
  box-shadow: var(--shadow-1);
}
@media (max-width: 620px) { .form-shell { padding: var(--s5); } }

.field { margin-bottom: var(--s5); }
.field label { display: block; font-size: .875rem; font-weight: 600; color: var(--ink); margin-bottom: var(--s2); }
.field .req { color: var(--red-ink); }
.field .hint { font-size: .8rem; color: var(--ink-3); margin-top: var(--s2); }

.input, .select, .textarea {
  width: 100%;
  font-family: var(--font-body); font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: var(--s3) var(--s4);
  min-height: 46px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--red);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 22%, transparent);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 1; }

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) calc(50% + 2px), calc(100% - 15px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: var(--s8);
}

.field.has-error .input, .field.has-error .select, .field.has-error .textarea { border-color: var(--red); }
.error-text {
  display: none; align-items: center; gap: 6px;
  font-size: .82rem; color: var(--red-ink); margin-top: var(--s2); font-weight: 500;
}
.field.has-error .error-text { display: flex; }

.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 52px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; display: grid; place-items: center;
  background: transparent; border: 0; color: var(--ink-3); cursor: pointer;
  border-radius: var(--radius-sm);
}
.pw-toggle:hover { color: var(--ink); background: var(--surface-2); }
.pw-toggle svg { width: 18px; height: 18px; }

/* Clipped rather than pushed off-screen, so it cannot widen the scroll box. */
.hp-field {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

.form-status { display: none; margin-top: var(--s5); padding: var(--s4); border-radius: var(--radius-sm); font-size: .95rem; }
.form-status.is-visible { display: block; }
.form-status.is-success { background: color-mix(in srgb, var(--d4) 16%, var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--d4) 45%, var(--line)); }
.form-status.is-error   { background: color-mix(in srgb, var(--red) 12%, var(--surface)); color: var(--ink); border: 1px solid color-mix(in srgb, var(--red) 40%, var(--line)); }
.form-status strong { display: block; margin-bottom: 4px; }

.btn-spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite; }

/* ---------- 15. Modal ---------- */
dialog.modal {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  max-width: 460px; width: calc(100% - 2rem);
  box-shadow: var(--shadow-2);
}
dialog.modal::backdrop { background: rgba(15, 18, 22, .55); }
.modal-body { padding: var(--s6); }
.modal-body h3 { margin-bottom: var(--s3); }
.modal-body p { color: var(--ink-2); font-size: .95rem; }
.modal-actions { display: flex; gap: var(--s3); justify-content: flex-end; margin-top: var(--s5); flex-wrap: wrap; }
.modal-summary {
  font-family: var(--font-mono); font-size: .8rem;
  background: var(--bg-sunken); border-radius: var(--radius-sm);
  padding: var(--s3) var(--s4); margin: var(--s4) 0 0;
  display: grid; gap: 4px; color: var(--ink-2);
}
.modal-summary span { color: var(--ink); }

/* ---------- 16. Copy button ---------- */
.copy-line {
  display: inline-flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: var(--s2) var(--s2) var(--s2) var(--s4);
  font-family: var(--font-mono); font-size: .88rem; color: var(--ink);
}
.copy-line a { color: var(--ink); text-decoration: none; }
.copy-line a:hover { color: var(--red-ink); text-decoration: underline; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--radius-sm); color: var(--ink-2);
  font-family: var(--font-body); font-size: .8rem; font-weight: 600;
  padding: 6px var(--s3); cursor: pointer;
  transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.copy-btn:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface); }
.copy-btn svg { width: 14px; height: 14px; }
.copy-btn.is-copied { color: var(--d4); border-color: var(--d4); }

/* ---------- 17. Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-sunken);
  padding-block: var(--s7) var(--s6);
  margin-top: var(--s8);
}
.footer-grid { display: flex; flex-wrap: wrap; gap: var(--s6); justify-content: space-between; align-items: flex-start; }
.footer-links { display: flex; flex-wrap: wrap; gap: var(--s5); }
.footer-links a { color: var(--ink-2); text-decoration: none; font-size: .92rem; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; }
.footer-base {
  margin-top: var(--s6); padding-top: var(--s4);
  border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: var(--s4); justify-content: space-between;
  font-size: .82rem; color: var(--ink-3);
}

/* ---------- 18. Cookie banner ---------- */
.cookie-banner {
  position: fixed; left: var(--s4); right: var(--s4); bottom: var(--s4);
  max-width: 640px; margin-inline: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: var(--s5);
  z-index: 150;
  display: none;
}
.cookie-banner.is-open { display: block; }
.cookie-banner h4 { margin-bottom: var(--s2); font-size: 1rem; }
.cookie-banner p { font-size: .88rem; color: var(--ink-2); margin-bottom: var(--s4); }
.cookie-actions { display: flex; gap: var(--s3); flex-wrap: wrap; }
.cookie-actions .btn { min-height: 40px; padding-inline: var(--s4); font-size: .92rem; }

/* ---------- 19. Floating controls ---------- */
.float-stack {
  position: fixed; right: var(--s4); bottom: var(--s4);
  display: flex; flex-direction: column; gap: var(--s3);
  z-index: 130; align-items: flex-end;
}
.fab {
  display: inline-flex; align-items: center; gap: var(--s2);
  height: 48px; padding-inline: var(--s4);
  border-radius: 999px;
  background: var(--red); color: var(--on-red);
  border: 1px solid transparent;
  font-weight: 600; font-size: .92rem; font-family: var(--font-body);
  box-shadow: var(--shadow-2); cursor: pointer; text-decoration: none;
  transition: background .16s var(--ease), transform .16s var(--ease);
}
.fab:hover { background: var(--red-hover); color: var(--on-red); transform: translateY(-2px); }
.fab svg { width: 18px; height: 18px; }
.fab--ghost {
  background: var(--surface); color: var(--ink);
  border-color: var(--line-strong);
  width: 48px; padding: 0; justify-content: center;
}
.fab--ghost:hover { background: var(--surface-2); color: var(--ink); }
.to-top { opacity: 0; visibility: hidden; transform: translateY(8px); transition: opacity .22s var(--ease), visibility .22s, transform .22s var(--ease); }
.to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }

/* ---------- 20. Chat assistant ---------- */
.chat-panel {
  position: fixed; right: var(--s4); bottom: 84px;
  width: min(380px, calc(100vw - 2rem));
  height: min(540px, calc(100vh - 140px));
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  z-index: 140;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.chat-panel.is-open { display: flex; }
.chat-head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.chat-head h4 { margin: 0; font-size: .98rem; }
.chat-head .small { color: var(--ink-3); font-size: .72rem; font-family: var(--font-mono); }
.chat-close { margin-left: auto; }
.chat-log { flex: 1; overflow-y: auto; padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.msg { max-width: 88%; padding: var(--s3) var(--s4); border-radius: var(--radius); font-size: .92rem; line-height: 1.55; }
.msg.bot { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 3px; }
.msg.user { background: var(--red); color: var(--on-red); align-self: flex-end; border-bottom-right-radius: 3px; }
.msg p { margin: 0 0 var(--s2); max-width: none; }
.msg p:last-child { margin: 0; }
.msg ul { margin: 0 0 var(--s2); padding-left: var(--s5); }
.msg a { color: inherit; }
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); animation: bounce 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 var(--s4) var(--s3); }
.chip {
  font-size: .76rem; padding: 5px var(--s3);
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--ink-2); cursor: pointer;
  font-family: var(--font-body);
  transition: color .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease);
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-2); }

.chat-form { display: flex; gap: var(--s2); padding: var(--s3) var(--s4) var(--s4); border-top: 1px solid var(--line); }
.chat-form .input { min-height: 42px; font-size: .92rem; }
.chat-send { width: 42px; height: 42px; flex: none; border-radius: var(--radius-sm); background: var(--red); color: var(--on-red); border: 0; display: grid; place-items: center; cursor: pointer; }
.chat-send:hover { background: var(--red-hover); }
.chat-send svg { width: 17px; height: 17px; }
.chat-disclaimer { padding: 0 var(--s4) var(--s3); font-size: .68rem; color: var(--ink-3); font-family: var(--font-mono); }

/* ---------- 21. Reveal animation fallback ---------- */
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.is-in { opacity: 1; transform: none; transition: opacity .6s var(--ease), transform .6s var(--ease); }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }
.no-js .reveal { opacity: 1; transform: none; }

/* ---------- 22. Long-form pages ---------- */
.doc { max-width: 760px; }
.doc h2 { font-size: 1.5rem; margin-top: var(--s7); }
.doc h3 { font-size: 1.1rem; margin-top: var(--s5); }
.doc ul, .doc ol { color: var(--ink-2); padding-left: var(--s5); }
.doc li { margin-bottom: var(--s2); }
.doc table { width: 100%; border-collapse: collapse; margin: var(--s4) 0; font-size: .92rem; }
.doc th, .doc td { text-align: left; padding: var(--s3); border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { font-family: var(--font-display); color: var(--ink); }
.doc td { color: var(--ink-2); }
.updated {
  font-family: var(--font-mono); font-size: .78rem; color: var(--ink-3);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: var(--s2) var(--s3); display: inline-block; margin-bottom: var(--s5);
}
.toc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s5); margin-bottom: var(--s6); }
.toc ol { margin: 0; padding-left: var(--s5); }
.toc a { color: var(--ink-2); text-decoration: none; }
.toc a:hover { color: var(--red-ink); text-decoration: underline; }

/* ---------- 23. 404 ---------- */
.error-page { min-height: 62vh; display: grid; place-content: center; text-align: center; padding-block: var(--s9); }
.error-code {
  font-family: var(--font-display); font-size: clamp(5rem, 18vw, 10rem);
  line-height: .9; color: var(--red); margin: 0 0 var(--s4); letter-spacing: -.05em;
}
.error-page p { margin-inline: auto; }
.error-page .btn-row { justify-content: center; }
.error-links { margin-top: var(--s7); display: flex; gap: var(--s5); flex-wrap: wrap; justify-content: center; font-size: .92rem; }

/* ---------- 24. Auth page ---------- */
.auth-shell { max-width: 420px; margin-inline: auto; padding-block: var(--s8); }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--s6); box-shadow: var(--shadow-1); }
.auth-foot { text-align: center; margin-top: var(--s5); font-size: .88rem; color: var(--ink-2); }

/* ---------- 25. Print ---------- */
@media print {
  :root {
    --bg: #fff; --bg-sunken: #fff; --surface: #fff; --surface-2: #fff;
    --ink: #000; --ink-2: #222; --ink-3: #444; --line: #bbb; --line-strong: #999;
  }
  body { background: #fff; color: #000; font-size: 11pt; line-height: 1.45; }
  .site-header, .scroll-progress, .float-stack, .chat-panel, .cookie-banner,
  .mobile-menu, .skip-link, .mode-bar, .twin-hint, .twin-legend, .chat-suggestions,
  .hero-plan,
  .header-actions, .btn, dialog, .twin-canvas-holder, .form-shell form { display: none !important; }
  .section { padding-block: 12pt; }
  .card, .source, .audience-item { border: 1px solid #bbb; box-shadow: none; page-break-inside: avoid; }
  .faq details { border: 0; page-break-inside: avoid; }
  .faq .faq-body { display: block !important; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #444; }
  h1, h2, h3 { page-break-after: avoid; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .site-footer { border-top: 1px solid #bbb; margin-top: 12pt; }
}

/* ---------- 26. Screen reader only ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---------- 27. Accounts, onboarding and workspace ---------- */
.auth-page { min-height: 70vh; display: grid; align-items: center; }
.auth-shell { max-width: 460px; margin-inline: auto; padding-block: var(--s8); width: 100%; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--s6); box-shadow: var(--shadow-1);
}
.auth-head { margin-bottom: var(--s6); }
.auth-head h1 { font-size: 1.9rem; margin-bottom: var(--s2); }
.auth-head p { color: var(--ink-2); font-size: .96rem; margin: 0; }
.auth-foot { text-align: center; margin-top: var(--s5); font-size: .92rem; color: var(--ink-2); }
.auth-alt {
  margin-top: var(--s5); padding-top: var(--s5);
  border-top: 1px solid var(--line); text-align: center; font-size: .92rem; color: var(--ink-2);
}

.check-row { display: flex; gap: var(--s3); align-items: flex-start; margin-bottom: var(--s5); }
.check-row input[type="checkbox"] {
  width: 18px; height: 18px; margin-top: 3px; flex: none;
  accent-color: var(--red); cursor: pointer;
}
.check-row label { font-size: .9rem; color: var(--ink-2); font-weight: 400; margin: 0; cursor: pointer; }

.pw-meter {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: var(--s2);
}
.pw-meter span { height: 4px; border-radius: 2px; background: var(--line); }
.pw-meter[data-score="1"] span:nth-child(-n+1),
.pw-meter[data-score="2"] span:nth-child(-n+2),
.pw-meter[data-score="3"] span:nth-child(-n+3),
.pw-meter[data-score="4"] span:nth-child(-n+4) { background: var(--red); }
.pw-meter[data-score="3"] span:nth-child(-n+3),
.pw-meter[data-score="4"] span:nth-child(-n+4) { background: var(--d4); }

.forgot {
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--font-body); font-size: .82rem; font-weight: 500;
  color: var(--red-ink); text-decoration: underline; text-underline-offset: 3px;
}
.forgot:hover { color: var(--red-hover); }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }

/* wizard */
.wizard { max-width: 640px; margin-inline: auto; }
.wizard-rail { display: flex; gap: var(--s2); margin-bottom: var(--s6); }
.wizard-rail span {
  flex: 1; height: 4px; border-radius: 2px; background: var(--line);
  transition: background .3s var(--ease);
}
.wizard-rail span.is-active, .wizard-rail span.is-done { background: var(--red); }
.wizard-step h2 { font-size: 1.6rem; }
.wizard-step > p { color: var(--ink-2); margin-bottom: var(--s5); }
.wizard-actions {
  display: flex; gap: var(--s3); justify-content: flex-end;
  margin-top: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--line);
}
.wizard-actions [data-wizard-back] { margin-right: auto; }

.layer-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--s3); margin-bottom: var(--s4); }
@media (max-width: 860px) { .layer-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }
.layer-opt { position: relative; }
.layer-opt input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.layer-opt span {
  display: block; padding: var(--s3) var(--s4);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink-2);
  font-size: .88rem; font-weight: 500; text-align: center;
  transition: border-color .16s var(--ease), background .16s var(--ease), color .16s var(--ease);
}
.layer-opt input:hover + span { border-color: var(--ink-3); color: var(--ink); }
.layer-opt input:checked + span { background: var(--red); border-color: var(--red); color: var(--on-red); }
.layer-opt input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.field-pair { display: grid; grid-template-columns: 2fr 1fr; gap: var(--s4); }
@media (max-width: 560px) { .field-pair { grid-template-columns: 1fr; } }

/* workspace */
.app-bar {
  display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center;
  justify-content: space-between; margin-bottom: var(--s5);
}
.app-meta { display: flex; flex-wrap: wrap; gap: var(--s5); font-family: var(--font-mono); font-size: .75rem; color: var(--ink-3); }
.app-meta strong { display: block; font-family: var(--font-body); font-size: .95rem; color: var(--ink); font-weight: 600; }
.workspace-twin .twin-canvas-holder { aspect-ratio: 16 / 9; }
@media (max-width: 700px) { .workspace-twin .twin-canvas-holder { aspect-ratio: 4 / 3.4; } }

.notice {
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: var(--s4) var(--s5); margin-bottom: var(--s5);
  font-size: .92rem; color: var(--ink-2);
}
.notice strong { color: var(--ink); }

.gate { min-height: 50vh; display: grid; place-content: center; justify-items: center; gap: var(--s4); }

/* Layout displays must not defeat the hidden attribute. */
[hidden] { display: none !important; }

code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; color: var(--ink);
}

/* ---------- 28. Framed pipeline viewer ---------- */
.viewer-frame-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-2);
  background: var(--bg-sunken);
  aspect-ratio: 16 / 9;
}
@media (max-width: 760px) { .viewer-frame-shell { aspect-ratio: 3 / 4; } }
#viewer-frame { width: 100%; height: 100%; border: 0; display: block; }
.copy-line code { background: none; border: 0; padding: 0; }

/* ---------- 29. Town lookup ---------- */
.town-field { position: relative; }

.town-list {
  position: absolute; top: calc(100% - 1.35rem); left: 0; right: 0;
  z-index: 20; margin: 4px 0 0; padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  max-height: 280px; overflow-y: auto;
}
.town-opt {
  padding: var(--s3) var(--s4);
  border-radius: 4px;
  cursor: pointer;
  display: flex; align-items: baseline; gap: var(--s3); justify-content: space-between;
  transition: background .12s var(--ease);
}
.town-opt strong { font-weight: 600; color: var(--ink); font-size: .95rem; }
.town-opt span { font-size: .8rem; color: var(--ink-3); font-family: var(--font-mono); }
.town-opt:hover, .town-opt.is-active { background: var(--surface-2); }
.town-opt--empty { cursor: default; color: var(--ink-3); font-size: .9rem; }
.town-opt--empty:hover { background: none; }

.town-panel {
  margin-top: var(--s5);
  background: var(--bg-sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s5);
}
.town-loading {
  display: flex; align-items: center; gap: var(--s3);
  margin: 0; color: var(--ink-2); font-size: .92rem;
}
.town-loading .spinner { width: 18px; height: 18px; border-width: 2px; }

.town-facts {
  display: grid; grid-template-columns: 11rem 1fr;
  gap: var(--s2) var(--s4); margin: 0;
}
@media (max-width: 560px) { .town-facts { grid-template-columns: 1fr; gap: 2px var(--s4); } }
.town-facts dt {
  font-family: var(--font-mono); font-size: .7rem;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); padding-top: 3px;
}
.town-facts dd { margin: 0; color: var(--ink); font-size: .95rem; }
@media (max-width: 560px) { .town-facts dd { margin-bottom: var(--s3); } }

.town-warn {
  margin: var(--s4) 0 0; padding: var(--s3) var(--s4);
  background: color-mix(in srgb, var(--red) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--red) 35%, var(--line));
  border-radius: var(--radius-sm);
  font-size: .88rem; color: var(--ink);
}
