/* HookEm portal — indigo/violet ops console.
   Dark-first navy, boxed cards, grid texture. Self-hosted type, no CDN.
   See docs/DESIGN_DIRECTION.md for the full system. */

/* -------------------------------------------------------------------------- */
/* Fonts (self-hosted variable)                                               */
/* -------------------------------------------------------------------------- */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("fonts/PlusJakartaSans-Variable.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
/* The hidden attribute must always win over component display rules. */
[hidden] { display: none !important; }

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Variable.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* -------------------------------------------------------------------------- */
/* Design tokens — dark-first                                                 */
/* -------------------------------------------------------------------------- */
:root {
  color-scheme: dark;

  --bg: #0B0E1A;
  --bg-raised: #0F1526;
  --bg-soft: #151B2E;
  --bg-hover: #1A2238;
  --ink: #F8FAFC;
  --muted: #94A3B8;
  /* #8B9BB0 ≥4.5:1 on --bg #0B0E1A (old #64748B failed contrast) */
  --faint: #8B9BB0;
  --line: rgba(148, 163, 184, .12);
  --line-strong: rgba(148, 163, 184, .22);
  --accent: #6366F1;
  --accent-hover: #818CF8;
  --accent-ink: #FFFFFF;
  --accent-dim: color-mix(in srgb, var(--accent) 16%, transparent);
  --accent-violet: #8B5CF6;
  --accent-blue: #3B82F6;
  --signal: #A78BFA;
  --signal-ink: #1E1035;
  --danger: #F87171;
  --danger-soft: color-mix(in srgb, #F87171 14%, transparent);
  --warn: #FBBF24;
  --warn-soft: color-mix(in srgb, #FBBF24 16%, transparent);
  --focus: #818CF8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35), 0 6px 16px rgba(0, 0, 0, .28);
  --shadow-glow: 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent),
                 0 12px 40px color-mix(in srgb, var(--accent-violet) 18%, transparent);
  --glow-violet: color-mix(in srgb, var(--accent-violet) 22%, transparent);
  --glow-indigo: color-mix(in srgb, var(--accent) 18%, transparent);
  --grid-line: rgba(148, 163, 184, .045);
  --grid-size: 48px;

  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --r-xs: .4rem;
  --r-sm: .55rem;
  --r-md: .875rem;   /* 14px */
  --r-lg: 1rem;      /* 16px */
  --r-xl: 1.125rem;  /* 18px */
  --r-pill: 999px;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --dur: 220ms;
  --dur-slow: 320ms;

  --container: 72rem;
  --sidebar-w: 15.5rem;
  --nav-h: 3.65rem;
  --nav-h-scrolled: 3.05rem;
  --mobile-nav-h: 3.75rem;
  --touch: 2.75rem; /* 44px minimum touch target */
  --space-section: clamp(1.75rem, 4vw, 2.6rem);
  --body-measure: 65ch;
  --bp-phone: 767px;
  --bp-tablet: 1023px;
}

/* Settings — tokenized boxed cards (matches billing / pipeline) */
.settings-shell {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(1.25rem, 3.5vw, 2.25rem) clamp(1rem, 4vw, 2rem) 2.5rem;
}
.settings-head {
  max-width: 42rem;
  margin-bottom: 1.5rem;
}
.settings-head .pipeline-kicker { margin: 0 0 .35rem; }
.settings-head h1 {
  font-size: clamp(1.75rem, 3.8vw, 2.45rem);
  margin: 0 0 .35rem;
}
.settings-head p,
.card-copy {
  color: var(--muted);
  margin: 0;
  font-size: .95rem;
  line-height: 1.5;
}
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 1.1rem;
}
.settings-card {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  padding: clamp(1.1rem, 3vw, 1.5rem);
  min-width: 0;
}
.usage-card { grid-column: 1 / -1; }
.card-number {
  float: right;
  color: var(--faint);
  font: 700 .7rem var(--mono);
  letter-spacing: .06em;
}
.settings-card h2 {
  margin: 0 0 .35rem;
  font-size: 1.15rem;
}
.settings-card form {
  display: grid;
  gap: .65rem;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
}
.settings-card .field { margin: 0; }
.settings-card .btn { justify-self: start; min-height: var(--touch); }
.connected-row,
.plan-state {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg-soft);
  padding: .85rem 1rem;
  margin-top: 1rem;
}
.connected-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.connected-row form {
  border: 0;
  padding: 0;
  margin: 0;
}
.connected-row .status-live {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  font-size: .9rem;
}
.connected-row .status-live i {
  display: inline-block;
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  flex: 0 0 auto;
}
.tos-warning {
  margin-top: 1rem;
  padding: .85rem 1rem;
  border-radius: var(--r-md);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line));
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  color: var(--ink);
  font-size: .82rem;
  line-height: 1.45;
}
.tos-warning strong {
  display: block;
  color: var(--warn);
  margin-bottom: .2rem;
  font-size: .78rem;
  font-family: var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.plan-state { display: grid; gap: .25rem; }
.plan-state span,
.plan-state small { color: var(--muted); }
.plan-state strong { color: var(--ink); font-size: 1.05rem; }
.usage-stat {
  display: flex;
  align-items: baseline;
  gap: .7rem;
  margin-top: .75rem;
}
.usage-stat strong {
  font: 700 clamp(2.2rem, 6vw, 3.5rem) / 1 var(--mono);
  color: var(--accent-hover);
  letter-spacing: -.03em;
}
.usage-stat > span { color: var(--muted); font-weight: 600; }
.usage-split {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.1rem;
  color: var(--muted);
  font: 600 .75rem var(--mono);
  margin-top: .65rem;
}
.settings-alert {
  max-width: 42rem;
  margin: 0 0 1.25rem;
  padding: .75rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: .9rem;
  font-weight: 500;
}
.settings-alert.ok {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.settings-alert.error {
  color: var(--ink);
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}
/* settings-grid stacks at ≤1023 (see global responsive block) */

/* Explicit light mode (toggle + system when user hasn't chosen) */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #F1F5F9;
  --bg-raised: #FFFFFF;
  --bg-soft: #E8EEF7;
  --bg-hover: #DDE5F2;
  --ink: #0F172A;
  --muted: #64748B;
  --faint: #94A3B8;
  --line: rgba(15, 23, 42, .08);
  --line-strong: rgba(15, 23, 42, .14);
  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --accent-ink: #FFFFFF;
  --accent-dim: color-mix(in srgb, var(--accent) 10%, transparent);
  --accent-violet: #7C3AED;
  --accent-blue: #2563EB;
  --signal: #8B5CF6;
  --signal-ink: #FFFFFF;
  --danger: #DC2626;
  --danger-soft: color-mix(in srgb, #DC2626 12%, transparent);
  --warn: #D97706;
  --warn-soft: color-mix(in srgb, #D97706 14%, transparent);
  --focus: #6366F1;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 12px 28px rgba(15, 23, 42, .08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 16px rgba(15, 23, 42, .06);
  --shadow-glow: 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent),
                 0 10px 28px color-mix(in srgb, var(--accent-violet) 10%, transparent);
  --glow-violet: color-mix(in srgb, var(--accent-violet) 14%, transparent);
  --glow-indigo: color-mix(in srgb, var(--accent) 12%, transparent);
  --grid-line: rgba(15, 23, 42, .05);
}

/* System preference only when no explicit theme */
@media (prefers-color-scheme: light) {
  html:not([data-theme]) {
    color-scheme: light;
    --bg: #F1F5F9;
    --bg-raised: #FFFFFF;
    --bg-soft: #E8EEF7;
    --bg-hover: #DDE5F2;
    --ink: #0F172A;
    --muted: #64748B;
    --faint: #94A3B8;
    --line: rgba(15, 23, 42, .08);
    --line-strong: rgba(15, 23, 42, .14);
    --accent: #4F46E5;
    --accent-hover: #4338CA;
    --accent-ink: #FFFFFF;
    --accent-dim: color-mix(in srgb, var(--accent) 10%, transparent);
    --accent-violet: #7C3AED;
    --accent-blue: #2563EB;
    --signal: #8B5CF6;
    --signal-ink: #FFFFFF;
    --danger: #DC2626;
    --danger-soft: color-mix(in srgb, #DC2626 12%, transparent);
    --warn: #D97706;
    --warn-soft: color-mix(in srgb, #D97706 14%, transparent);
    --focus: #6366F1;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 12px 28px rgba(15, 23, 42, .08);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 16px rgba(15, 23, 42, .06);
    --shadow-glow: 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent),
                   0 10px 28px color-mix(in srgb, var(--accent-violet) 10%, transparent);
    --glow-violet: color-mix(in srgb, var(--accent-violet) 14%, transparent);
    --glow-indigo: color-mix(in srgb, var(--accent) 12%, transparent);
    --grid-line: rgba(15, 23, 42, .05);
  }
}

/* Aliases used by older markup / inline styles */
:root, html[data-theme="light"], html:not([data-theme]) {
  --paper: var(--bg);
  --paper-raised: var(--bg-raised);
  --paper-soft: var(--bg-soft);
}

/* -------------------------------------------------------------------------- */
/* Base                                                                       */
/* -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  min-width: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15.5px;
  font-weight: 450;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 480px at 12% -8%, var(--glow-indigo), transparent 58%),
    radial-gradient(720px 420px at 92% 4%, var(--glow-violet), transparent 55%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, var(--grid-size) var(--grid-size), var(--grid-size) var(--grid-size);
  background-attachment: fixed;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
}

/* Landing-page studio — tokenized workbench */
.site-builder {
  max-width: 94rem;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(.85rem, 3vw, 1.5rem) 2rem;
  min-width: 0;
}
.site-builder-head {
  display: flex;
  gap: 1.25rem 2rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.site-builder-head h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.4rem);
  max-width: 18ch;
  margin: .2rem 0 .4rem;
}
.site-builder-head p { color: var(--muted); max-width: 42rem; margin: 0; }
.site-builder-kicker {
  color: var(--accent-hover);
  font: 700 .69rem/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.site-publish-state {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
  border-radius: var(--r-md);
  padding: .65rem .85rem;
  display: flex;
  align-items: center;
  gap: .55rem;
  font: 600 .72rem var(--mono);
  color: var(--muted);
}
.site-state-dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--signal) 13%, transparent);
}
.site-workbench {
  display: grid;
  grid-template-columns: minmax(18rem, 22rem) minmax(0, 1fr);
  min-height: 72vh;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--bg-raised);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.site-controls {
  padding: 1.1rem;
  max-height: calc(100vh - 7rem);
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--bg-raised);
  min-width: 0;
}
.site-panel-title {
  display: flex;
  gap: .75rem;
  padding: .75rem 0;
  margin-top: .35rem;
  border-top: 1px solid var(--line);
}
.site-panel-title:first-child { border-top: 0; margin-top: 0; }
.site-panel-title > span {
  font: 700 .65rem var(--mono);
  color: var(--accent-hover);
  padding-top: .2rem;
}
.site-panel-title h2 { font-size: .9rem; margin: 0; }
.site-panel-title p { font-size: .75rem; color: var(--muted); margin: .15rem 0 0; }
.site-field {
  display: grid;
  gap: .35rem;
  margin: .75rem 0;
  color: var(--muted);
  font: 650 .68rem var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.site-field small {
  float: right;
  color: var(--faint);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.site-field input,
.site-field textarea,
.site-field select {
  width: 100%;
  max-width: 100%;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: .72rem .78rem;
  /* ≥16px prevents iOS Safari focus-zoom */
  font: 500 1rem / 1.45 var(--font);
  resize: vertical;
  min-height: var(--touch);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.site-field input:focus,
.site-field textarea:focus,
.site-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}
.site-choice-group { border: 0; padding: 0; margin: .5rem 0 1rem; }
.site-choice-group legend {
  color: var(--muted);
  font: 650 .68rem var(--mono);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: .5rem;
  padding: 0;
}
.site-swatches { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
.site-swatches label {
  position: relative;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .55rem;
  display: grid;
  gap: .35rem;
  color: var(--muted);
  font-size: .72rem;
  min-height: var(--touch);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), color var(--dur);
}
.site-swatches input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}
.site-swatches label:hover { border-color: var(--line-strong); color: var(--ink); }
.site-swatches label:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.site-swatches label:has(input:checked) {
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
.site-swatches i {
  height: 1.1rem;
  border-radius: 3px;
  background: var(--sw);
  border: 1px solid var(--line);
}
[data-swatch=nocturne] { --sw: linear-gradient(90deg, #0b1020 0 32%, #7c5cff 32% 58%, #eaf0ff 58%); }
[data-swatch=cobalt] { --sw: linear-gradient(90deg, #071a2b 0 32%, #32b7db 32% 58%, #f1f7f8 58%); }
[data-swatch=oxide] { --sw: linear-gradient(90deg, #21130f 0 32%, #e0633d 32% 58%, #f1dfc7 58%); }
[data-swatch=paper] { --sw: linear-gradient(90deg, #ece9e0 0 40%, #17191d 40% 70%, #bc3f31 70%); }
.site-toggles { display: grid; gap: .4rem; }
.site-toggles label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: .65rem .75rem;
  font-size: .8rem;
  cursor: pointer;
  min-height: var(--touch);
  transition: border-color var(--dur) var(--ease), background var(--dur);
}
.site-toggles label:hover { background: var(--bg-soft); }
.site-toggles input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}
.site-toggles label:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.site-toggles i {
  width: 2.1rem;
  height: 1.15rem;
  border-radius: var(--r-pill);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  position: relative;
  flex: 0 0 auto;
  transition: background var(--dur) var(--ease), border-color var(--dur);
}
.site-toggles i::after {
  content: "";
  position: absolute;
  width: .75rem;
  height: .75rem;
  top: .12rem;
  left: .15rem;
  border-radius: 50%;
  background: var(--faint);
  transition: transform var(--dur) var(--ease), background var(--dur);
}
.site-toggles input:checked + i {
  background: var(--accent-dim);
  border-color: var(--accent);
}
.site-toggles input:checked + i::after {
  transform: translateX(.85rem);
  background: var(--accent);
}
.site-contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.site-publish {
  width: 100%;
  margin-top: 1rem;
  justify-content: space-between;
  min-height: 2.75rem;
}
.site-publish-note {
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.5;
  margin: .7rem .15rem 0;
}
.site-publish-note a { color: var(--accent-hover); }
.site-canvas {
  min-width: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.site-canvas-bar {
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  padding: 0 .9rem;
  gap: .75rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font: 600 .68rem var(--mono);
}
.site-browser-dots { display: flex; gap: .3rem; }
.site-browser-dots i {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: var(--bg-hover);
}
.site-browser-dots i:first-child { background: color-mix(in srgb, var(--danger) 55%, var(--bg-hover)); }
.site-viewport-switch {
  margin-left: auto;
  display: flex;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.site-viewport-switch button {
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg-soft);
  min-width: var(--touch);
  min-height: var(--touch);
  padding: .35rem .55rem;
  font: 600 .68rem var(--mono);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur);
}
.site-viewport-switch button:last-child { border-right: 0; }
.site-viewport-switch button:hover { color: var(--ink); background: var(--bg-hover); }
.site-viewport-switch button.is-active {
  color: var(--accent-ink);
  background: var(--accent);
}
.site-frame-wrap {
  flex: 1;
  padding: clamp(.5rem, 2vw, 1.25rem);
  display: flex;
  justify-content: center;
  min-height: 36rem;
  overflow: auto;
  min-width: 0;
}
#sg-preview {
  width: 100%;
  height: 100%;
  min-height: 36rem;
  border: 0;
  border-radius: var(--r-sm);
  background: #fff;
  box-shadow: var(--shadow);
  transition: width var(--dur-slow) var(--ease);
}
/* site-workbench stacks at ≤1023 (see global responsive block) */
a { color: inherit; }
h1, h2, h3 {
  line-height: 1.12;
  letter-spacing: -.028em;
  margin: 0 0 .4em;
  font-weight: 650;
}
h1 { font-size: clamp(1.75rem, 3.8vw, 2.45rem); font-weight: 680; }
h2 { font-size: clamp(1.2rem, 2.2vw, 1.55rem); }
h3 { font-size: .9rem; }
p { margin: 0 0 .75em; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
::selection {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--ink);
}
.wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2rem);
}

/* -------------------------------------------------------------------------- */
/* Sticky compressing nav                                                     */
/* -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid transparent;
  transition:
    height var(--dur-slow) var(--ease),
    background var(--dur-slow) var(--ease),
    border-color var(--dur-slow) var(--ease),
    box-shadow var(--dur-slow) var(--ease);
}
.topbar.is-scrolled {
  height: var(--nav-h-scrolled);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom-color: var(--line);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .18);
}
.topbar .row {
  display: flex;
  align-items: center;
  gap: .85rem;
  height: 100%;
  padding: 0 clamp(1rem, 4vw, 2rem);
  max-width: var(--container);
  margin: 0 auto;
  transition: gap var(--dur-slow) var(--ease);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 720;
  letter-spacing: -.035em;
  text-decoration: none;
  font-size: 1.05rem;
  transition: transform var(--dur) var(--ease), opacity var(--dur);
}
.brand:hover { opacity: .92; }
.brand .dot {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: .45rem;
  background: linear-gradient(145deg, var(--accent), var(--accent-violet));
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .9rem;
  letter-spacing: 0;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent),
              0 4px 14px color-mix(in srgb, var(--accent) 25%, transparent);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur);
}
.brand:hover .dot {
  transform: scale(1.04);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent),
              0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.topbar.is-scrolled .brand { font-size: .98rem; }
.topbar.is-scrolled .brand .dot {
  width: 1.45rem;
  height: 1.45rem;
  font-size: .8rem;
}
.spacer { margin-left: auto; }
.who {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 500;
}
.who b { color: var(--ink); font-weight: 620; }

/* Theme toggle */
.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  min-height: var(--touch);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
  transition:
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.theme-toggle:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--bg-soft);
}
.theme-toggle:active { transform: scale(.96); }
.theme-toggle svg { width: 1.05rem; height: 1.05rem; display: block; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
html[data-theme="light"] .theme-toggle .icon-sun { display: block; }
html[data-theme="light"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: light) {
  html:not([data-theme]) .theme-toggle .icon-sun { display: block; }
  html:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* -------------------------------------------------------------------------- */
/* Buttons                                                                    */
/* -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  cursor: pointer;
  font: 600 .9rem/1 var(--font);
  letter-spacing: -.01em;
  padding: .72rem 1.15rem;
  min-height: var(--touch);
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  color: var(--ink);
  text-decoration: none;
  transition:
    transform var(--dur) var(--ease),
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    color var(--dur) var(--ease);
}
.btn:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line-strong));
  box-shadow: var(--shadow-sm);
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: color-mix(in srgb, var(--accent) 80%, transparent);
  box-shadow: 0 1px 0 color-mix(in srgb, #fff 18%, transparent) inset,
              0 6px 18px color-mix(in srgb, var(--accent) 22%, transparent);
}
.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 1px 0 color-mix(in srgb, #fff 22%, transparent) inset,
              0 10px 24px color-mix(in srgb, var(--accent) 28%, transparent);
}
.btn.ghost {
  background: transparent;
  box-shadow: none;
}
.btn.ghost:hover {
  background: var(--bg-soft);
  box-shadow: none;
}
.btn.sm {
  padding: .55rem .9rem;
  font-size: .8rem;
  min-height: var(--touch); /* ≥44px tap target */
}
.btn:active { transform: translateY(1px) scale(.985); }
.btn:disabled {
  cursor: wait;
  opacity: .68;
  transform: none;
  box-shadow: none;
}
.btn.loading::before {
  content: "";
  width: .8rem;
  height: .8rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: 0 0 auto;
}
.btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}
.btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  box-shadow: none;
}

/* -------------------------------------------------------------------------- */
/* Auth                                                                       */
/* -------------------------------------------------------------------------- */
.auth {
  min-height: calc(100dvh - var(--nav-h) - 5rem);
  display: grid;
  place-items: center;
  padding: clamp(1.5rem, 5vw, 3rem) 1rem;
}
.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  padding: clamp(1.5rem, 4vw, 2.4rem);
  position: relative;
  overflow: hidden;
}
/* Shared boxed-surface primitive (cards, tiles, pipeline steps) */
.surface {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 40%, transparent), transparent);
  pointer-events: none;
}
.auth .card { width: 100%; max-width: 26rem; }
.auth .card h1 { margin-bottom: .25rem; }
.field { display: block; margin: 0 0 1rem; }
.field span {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: .4rem;
  font-weight: 650;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  max-width: 100%;
  padding: .78rem .9rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  /* ≥16px prevents iOS Safari focus-zoom */
  font: 500 1rem / 1.45 var(--font);
  min-height: var(--touch);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur);
}
.field input::placeholder { color: var(--faint); opacity: .85; }
.field input:hover { border-color: color-mix(in srgb, var(--accent) 30%, var(--line-strong)); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: var(--bg-raised);
}
.field input[aria-invalid="true"] {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line-strong));
}
.field input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px var(--danger-soft);
}
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.lead {
  color: var(--muted);
  font-size: 1rem;
  margin: 0 0 .2rem;
  line-height: 1.5;
}
.err {
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--ink);
  padding: .7rem .85rem;
  border-radius: var(--r-sm);
  font-size: .85rem;
  margin-bottom: 1rem;
  font-weight: 500;
}
.notice {
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  padding: .7rem .85rem;
  border-radius: var(--r-sm);
  font-size: .85rem;
  margin-bottom: 1rem;
}
.divider {
  display: flex;
  align-items: center;
  gap: .8rem;
  color: var(--faint);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin: 1.25rem 0;
}
.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--line);
  flex: 1;
}
.btn.oauth {
  width: 100%;
  justify-content: center;
  margin-top: .55rem;
  background: var(--bg);
}
.btn.oauth:hover {
  background: var(--bg-soft);
  border-color: var(--line-strong);
}
.auth-link {
  color: var(--accent);
  font-weight: 620;
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  transition: border-color var(--dur), color var(--dur);
}
.auth-link:hover {
  border-bottom-color: var(--accent);
  color: var(--accent-hover);
}

/* Tier picker on signup */
.tier-pick {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .65rem;
}
.tier-option {
  position: relative;
  cursor: pointer;
  margin: 0;
  padding: .95rem .85rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg);
  display: block;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    background var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.tier-option:hover {
  border-color: var(--line-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.tier-option:has(input:checked),
.tier-option.is-selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
  box-shadow: var(--shadow-glow);
}
.tier-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.tier-option b {
  display: block;
  font-size: .88rem;
  margin-bottom: .25rem;
}
.tier-option .stat {
  font-size: 1.25rem;
  margin: .15rem 0;
}
.tier-option .small { line-height: 1.3; }

/* -------------------------------------------------------------------------- */
/* Dashboard layout                                                           */
/* -------------------------------------------------------------------------- */
main {
  padding: clamp(1.35rem, 3.5vw, 2.1rem) 0 4.5rem;
  min-width: 0;
}
.pagehead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .55rem 1rem;
  margin-bottom: 1.5rem;
}
.pagehead h1 { overflow-wrap: anywhere; margin-bottom: .15rem; }
.pagehead .muted { font-size: .92rem; }

/* Getting started */
.gs-card {
  margin: 0 0 1.5rem;
  padding: clamp(1.15rem, 3vw, 1.55rem) clamp(1.15rem, 3.5vw, 1.65rem);
  background:
    linear-gradient(155deg, color-mix(in srgb, var(--accent) 9%, var(--bg-raised)), var(--bg-raised) 55%),
    var(--bg-raised);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.gs-card::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -8%;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--signal) 12%, transparent), transparent 70%);
  pointer-events: none;
}
.gs-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: .55rem .85rem;
  margin-bottom: .55rem;
  position: relative;
}
.gs-kicker {
  margin: 0 0 .25rem;
  font-size: .7rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}
.gs-head h2 {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
  letter-spacing: -.02em;
}
.gs-note {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: .92rem;
  max-width: 44rem;
  overflow-wrap: anywhere;
  position: relative;
}
.gs-note b { color: var(--ink); font-weight: 650; }
.gs-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .7rem;
  position: relative;
}
.gs-step {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  min-width: 0;
  padding: .9rem .95rem;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--bg-soft) 70%, var(--bg-raised));
  border: 1px solid var(--line);
  position: relative;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    background var(--dur),
    transform var(--dur) var(--ease);
}
.gs-step:hover { transform: translateY(-1px); }
.gs-step.is-done {
  opacity: .88;
  border-color: color-mix(in srgb, var(--accent) 22%, var(--line));
}
.gs-step.is-done .gs-num {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-raised));
  color: var(--accent);
  border-color: transparent;
}
.gs-step.is-current {
  background: var(--bg-raised);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: var(--shadow-sm);
}
.gs-step.is-current::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55rem;
  bottom: .55rem;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}
.gs-num {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: .78rem;
  font-weight: 750;
  letter-spacing: .01em;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
}
.gs-step.is-current .gs-num {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.gs-body { display: grid; gap: .2rem; min-width: 0; }
.gs-label {
  font-weight: 650;
  letter-spacing: -.01em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.gs-step.is-current .gs-label { color: var(--ink); }
.gs-desc {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.gs-now {
  align-self: flex-start;
  margin-top: auto;
  font-size: .65rem;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .22rem .5rem;
  border-radius: var(--r-pill);
  background: var(--signal);
  color: var(--signal-ink);
  border: 1px solid color-mix(in srgb, var(--signal-ink) 10%, transparent);
}
.gs-step > .gs-num { margin-bottom: .05rem; }

/* Badges / chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .7rem;
  font-weight: 720;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .32rem .62rem;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--line);
}
.badge.tier {
  background: var(--signal);
  color: var(--signal-ink);
  border-color: transparent;
}
.badge.ok {
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-raised));
  color: var(--accent-hover); /* #818CF8 ≥4.5:1 on raised */
  border-color: transparent;
}
.badge.pend {
  background: color-mix(in srgb, var(--warn) 22%, var(--bg-raised));
  color: #FDE68A; /* amber-200 ≥4.5:1 on dark amber wash */
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}
html[data-theme="light"] .badge.pend {
  color: #92400E;
  background: color-mix(in srgb, var(--warn) 18%, #fff);
}

/* Grids & tiles */
.grid { display: grid; gap: 1.1rem; min-width: 0; }
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
.cols-demos { grid-template-columns: repeat(auto-fill, minmax(min(100%, 14.5rem), 1fr)); gap: .9rem; }
.stats-grid { gap: .9rem; }

.tile {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.15rem 1.2rem 1.25rem;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  position: relative;
  overflow: hidden;
  transition:
    transform var(--dur-slow) var(--ease),
    box-shadow var(--dur-slow) var(--ease),
    border-color var(--dur-slow) var(--ease);
}
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 5%, transparent), transparent 42%);
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease);
  pointer-events: none;
}
.tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
}
.tile:hover::after { opacity: 1; }
.tile-accent {
  border-color: color-mix(in srgb, var(--accent) 48%, var(--line));
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 8%, var(--bg-raised)), var(--bg-raised) 55%);
}
.tile-accent:hover {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--line));
  box-shadow: var(--shadow-glow);
}
.tile h3 {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 720;
  margin: 0;
}
.tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .55rem;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.stat-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: .75rem;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.stat {
  font-size: clamp(1.65rem, 4vw, 2.05rem);
  font-weight: 720;
  letter-spacing: -.035em;
  line-height: 1.05;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.stat.accent,
.stat[style*="accent"] { color: var(--accent); }
.stat small {
  font-size: .92rem;
  color: var(--faint);
  font-weight: 520;
  letter-spacing: -.01em;
}
.tile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .55rem;
  margin: .55rem 0 0;
  font-size: .82rem;
  color: var(--muted);
  position: relative;
  z-index: 1;
}
.chip {
  display: inline-flex;
  align-items: center;
  font-size: .68rem;
  font-weight: 720;
  letter-spacing: .02em;
  padding: .18rem .45rem;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.chip.ok {
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-raised));
  color: var(--accent);
  border-color: transparent;
}
.chip.subtle { color: var(--faint); }
.trend {
  font-size: .7rem;
  font-weight: 750;
  letter-spacing: .01em;
  font-variant-numeric: tabular-nums;
  padding: .15rem .4rem;
  border-radius: var(--r-pill);
  white-space: nowrap;
}
.trend.up {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.trend.down {
  color: var(--danger);
  background: var(--danger-soft);
}
.trend.flat {
  color: var(--faint);
  background: var(--bg-soft);
}

/* Sparklines */
.spark {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 1.75rem;
  min-width: 3.2rem;
  flex: 0 0 auto;
  padding: .1rem 0;
}
.spark i {
  display: block;
  width: .28rem;
  min-height: 2px;
  height: var(--h, 40%);
  border-radius: 2px 2px 1px 1px;
  background: color-mix(in srgb, var(--accent) 55%, var(--line-strong));
  opacity: .85;
  transition: height .35s var(--ease);
}
.spark.accent i { background: var(--accent); }
.spark i:last-child {
  opacity: 1;
  background: var(--signal);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--signal-ink) 8%, transparent);
}

.meter {
  height: .42rem;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  overflow: hidden;
  margin-top: .8rem;
  border: 1px solid var(--line);
  position: relative;
  z-index: 1;
}
.meter > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--signal)));
  border-radius: var(--r-pill);
  transition: width .65s var(--ease-out);
}

/* Sections */
.section {
  margin-top: var(--space-section);
  min-width: 0;
}
.section > h2 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .35rem .6rem;
  margin-bottom: .85rem;
}
.section > h2 .count {
  font-size: .82rem;
  color: var(--faint);
  font-weight: 520;
  letter-spacing: -.01em;
}

/* Demo gallery */
.demo-gallery { gap: .85rem; }
.demo {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  transition:
    transform var(--dur-slow) var(--ease),
    box-shadow var(--dur-slow) var(--ease),
    border-color var(--dur-slow) var(--ease);
}
.demo:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
}
.demo:hover .thumb img { transform: scale(1.045); }
.demo:hover .thumb-veil { opacity: .14; }
.demo:hover .demo-link {
  border-color: var(--accent);
  color: var(--accent);
}
.demo .thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 10% 0%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 55%),
    linear-gradient(145deg, var(--bg-soft), var(--line));
  display: grid;
  place-items: center;
  color: var(--faint);
}
.demo .thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .5s var(--ease-out);
}
.thumb-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 40%, color-mix(in srgb, var(--ink) 22%, transparent));
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.thumb-fallback {
  font-size: .78rem;
  font-weight: 620;
  letter-spacing: .02em;
  text-align: center;
  padding: .75rem;
  color: var(--muted);
  max-width: 90%;
  overflow-wrap: anywhere;
}
.demo .body { padding: .9rem 1rem 1.05rem; }
.demo .name {
  font-weight: 640;
  letter-spacing: -.015em;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.demo .foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .7rem;
  gap: .5rem;
}
.demo-link { flex: 0 0 auto; }
.demo.is-pending { opacity: .92; }
.demo.is-pending .thumb {
  background:
    repeating-linear-gradient(-45deg, var(--bg-soft), var(--bg-soft) 8px,
      color-mix(in srgb, var(--line) 70%, var(--bg-soft)) 8px,
      color-mix(in srgb, var(--line) 70%, var(--bg-soft)) 16px);
}

/* Replies */
.replies { display: grid; gap: .7rem; }
.reply {
  display: grid;
  gap: .25rem;
  padding: 1rem 1.15rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-md);
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
  min-width: 0;
}
.reply:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--line-strong);
  transform: translateX(2px);
}
.reply .from {
  font-weight: 650;
  overflow-wrap: anywhere;
  letter-spacing: -.015em;
}
.reply .snip {
  color: var(--muted);
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.reply .at {
  color: var(--faint);
  font-size: .76rem;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* Empty states */
.empty {
  text-align: center;
  padding: clamp(2rem, 5vw, 2.75rem) 1.25rem;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background:
    radial-gradient(80% 70% at 50% 0%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 60%),
    var(--bg-soft);
  overflow-wrap: anywhere;
  display: grid;
  justify-items: center;
  gap: .55rem;
}
.empty-icon {
  width: 3rem;
  height: 3rem;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  color: var(--accent);
  margin-bottom: .15rem;
}
.empty-icon svg {
  width: 1.35rem;
  height: 1.35rem;
  display: block;
}
.empty-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
  letter-spacing: -.02em;
}
.empty-body {
  margin: 0;
  max-width: 28rem;
  font-size: .9rem;
  line-height: 1.5;
  color: var(--muted);
}
.empty b { color: var(--ink); font-weight: 650; }

/* Footer */
.foot-site {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 1.5rem 0;
  color: var(--faint);
  font-size: .8rem;
  letter-spacing: .01em;
}

/* -------------------------------------------------------------------------- */
/* Controls                                                                   */
/* -------------------------------------------------------------------------- */
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .85rem;
}
.section-head h2 { margin-bottom: .25rem; }
.control-copy {
  margin: 0;
  max-width: 48rem;
  font-size: .9rem;
}
.control-card {
  padding: clamp(1rem, 3vw, 1.4rem);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.control-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
}
.action-form { min-width: 0; }
.control-btn {
  width: 100%;
  min-height: 4.7rem;
  justify-content: space-between;
  align-items: flex-start;
  text-align: left;
  border-radius: var(--r-md);
  padding: .9rem 1rem;
  gap: .65rem;
  position: relative;
  overflow: hidden;
}
.control-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background var(--dur);
}
.control-label {
  display: grid;
  gap: .3rem;
  min-width: 0;
  flex: 1 1 auto;
}
.control-name {
  line-height: 1.25;
  font-weight: 650;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}
.control-hint {
  font-size: .72rem;
  font-weight: 550;
  letter-spacing: .01em;
  color: var(--muted);
  line-height: 1.3;
}

/* Job status chips — text ≥4.5:1 on chip surface */
.job-status {
  display: inline-flex;
  align-items: center;
  gap: .28rem;
  white-space: nowrap;
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: .28rem .5rem;
  border-radius: var(--r-pill);
  flex: 0 0 auto;
  color: var(--muted);
  background: color-mix(in srgb, var(--bg-soft) 80%, transparent);
  border: 1px solid var(--line);
}
.control-btn.primary .job-status.idle,
.control-btn.primary .job-status:not(.queued):not(.running):not(.done):not(.failed) {
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent-ink) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent-ink) 18%, transparent);
}
.job-status.idle { color: var(--muted); }
/* Amber pill: light ink on dark amber wash (dark theme) */
.job-status.queued,
.control-btn.primary .job-status.queued,
.control-btn.danger .job-status.queued,
.control-btn.ghost .job-status.queued {
  color: #FEF3C7; /* amber-100 — high contrast on dark amber wash */
  background: color-mix(in srgb, var(--warn) 28%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--warn) 50%, transparent);
}
html[data-theme="light"] .job-status.queued,
html[data-theme="light"] .control-btn.primary .job-status.queued,
html[data-theme="light"] .control-btn.danger .job-status.queued,
html[data-theme="light"] .control-btn.ghost .job-status.queued {
  color: #78350F; /* amber-900 on light amber wash */
  background: color-mix(in srgb, var(--warn) 24%, #fff);
  border-color: color-mix(in srgb, var(--warn) 42%, transparent);
}
.job-status.running,
.control-btn.primary .job-status.running,
.control-btn.danger .job-status.running,
.control-btn.ghost .job-status.running {
  color: var(--signal-ink);
  background: var(--signal);
  border-color: color-mix(in srgb, var(--signal-ink) 12%, transparent);
}
.job-status.done,
.control-btn.primary .job-status.done,
.control-btn.danger .job-status.done,
.control-btn.ghost .job-status.done {
  color: var(--accent-hover);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--accent) 32%, transparent);
}
.job-status.failed,
.control-btn.primary .job-status.failed,
.control-btn.danger .job-status.failed,
.control-btn.ghost .job-status.failed {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}
.job-status.running i {
  display: inline-block;
  animation: spin 1s linear infinite;
}

.control-btn.state-queued::before { background: var(--warn); }
.control-btn.state-running::before {
  background: var(--signal);
  box-shadow: 0 0 12px color-mix(in srgb, var(--signal) 60%, transparent);
}
.control-btn.state-done::before { background: var(--accent); }
.control-btn.state-failed::before { background: var(--danger); }
.control-btn.primary.state-queued {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 35%, transparent);
}
.control-btn.primary.state-running {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--signal) 45%, transparent), var(--shadow-sm);
  animation: pulse-ring 1.8s var(--ease) infinite;
}
.control-btn.primary.state-done { filter: saturate(1.05); }
.control-btn.primary.state-failed {
  background: color-mix(in srgb, var(--danger) 12%, var(--accent));
  border-color: var(--danger);
}

.activity-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.activity-head h3 {
  font-size: .9rem;
  margin: 0;
  letter-spacing: -.015em;
}
.activity-list {
  list-style: none;
  padding: 0;
  margin: .45rem 0 0;
}
.activity-list li {
  display: block;
  padding: .72rem .4rem;
  border-bottom: 1px solid var(--line);
  font-size: .85rem;
  min-width: 0;
  border-radius: var(--r-xs);
  transition: background var(--dur) var(--ease);
}
.activity-list li:hover:not(.activity-empty) {
  background: var(--bg-soft);
}
.activity-list li:last-child { border: 0; }
.activity-list .activity-empty {
  display: flex;
  color: var(--muted);
  justify-content: center;
  padding: 1.15rem;
  text-align: center;
}
/* One row: label (truncate) + status (fixed) + time (fixed) */
.activity-row {
  display: flex;
  align-items: center;
  gap: .5rem .65rem;
  min-width: 0;
}
.activity-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}
.activity-row .job-status {
  flex: 0 0 auto;
}
.activity-row time {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: .7rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
/* Progress is the valuable line — full width, never truncated mid-word */
.activity-progress {
  margin: .3rem 0 0;
  font-size: .8rem;
  line-height: 1.35;
  color: var(--muted);
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}

/* Toast */
.toast {
  position: fixed;
  right: max(.75rem, calc((100vw - var(--container)) / 2));
  bottom: 1rem;
  z-index: 50;
  max-width: min(24rem, calc(100vw - 1.5rem));
  padding: .85rem 1.05rem;
  border-radius: var(--r-md);
  color: var(--signal-ink);
  background: var(--signal);
  border: 1px solid color-mix(in srgb, var(--signal-ink) 14%, transparent);
  box-shadow: var(--shadow);
  font-size: .88rem;
  font-weight: 650;
  animation: toast-in .3s var(--ease);
}
.toast[hidden] { display: none; }

/* -------------------------------------------------------------------------- */
/* Reveal animations (default visible without .js)                            */
/* -------------------------------------------------------------------------- */
.js .reveal {
  opacity: 0;
  transform: translateY(16px);
}
.js .reveal.revealed {
  opacity: 1;
  transform: none;
  transition: opacity .55s var(--ease), transform .55s var(--ease);
  transition-delay: calc(var(--reveal-i, 0) * 60ms);
}

/* -------------------------------------------------------------------------- */
/* Admin tables                                                               */
/* -------------------------------------------------------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.table th,
.table td {
  text-align: left;
  padding: .7rem .75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  color: var(--muted);
  font-weight: 650;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: color-mix(in srgb, var(--bg-soft) 55%, var(--bg-raised));
}
.table tbody tr {
  transition: background var(--dur) var(--ease);
}
.table tr:hover td { background: var(--bg-soft); }
.table code {
  font-family: var(--mono);
  font-size: .76rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.row-detail-link {
  color: inherit;
  font-weight: 620;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--dur), border-color var(--dur);
}
.row-detail-link:hover {
  color: var(--accent);
  border-bottom-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.fleet-row:hover .row-detail-link {
  color: var(--accent);
}
.table-shell {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-raised);
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm);
  /* Visible scroll affordance — page never scrolls sideways */
  background-image:
    linear-gradient(to right, var(--bg-raised) 30%, transparent),
    linear-gradient(to left, var(--bg-raised) 30%, transparent),
    linear-gradient(to right, rgba(0, 0, 0, .22), transparent),
    linear-gradient(to left, rgba(0, 0, 0, .22), transparent);
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 2.5rem 100%, 2.5rem 100%, .75rem 100%, .75rem 100%;
  background-attachment: local, local, scroll, scroll;
}
.table-shell .table {
  width: 100%;
  min-width: 36rem;
  margin: 0;
}
.table-shell .table th:first-child,
.table-shell .table td:first-child { padding-left: 1.05rem; }
.table-shell .table th:last-child,
.table-shell .table td:last-child { padding-right: 1.05rem; }
.table-shell .table tr:last-child td { border-bottom: 0; }

/* Stacked definition cards for tables (phones) — enabled via .table-cards */
@media (max-width: 767px) {
  .table-shell.table-cards {
    overflow-x: visible;
    background-image: none;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    background-color: transparent;
  }
  .table-shell.table-cards .table {
    min-width: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 .75rem;
  }
  .table-shell.table-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .table-shell.table-cards tbody tr {
    display: block;
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    padding: .35rem 0;
    margin: 0;
  }
  .table-shell.table-cards tbody tr:hover td {
    background: transparent;
  }
  .table-shell.table-cards tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: normal;
    overflow-wrap: anywhere;
    min-height: var(--touch);
  }
  .table-shell.table-cards tbody td:last-child {
    border-bottom: 0;
  }
  .table-shell.table-cards tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 45%;
    text-align: left;
    font-family: var(--mono);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    padding-top: .15rem;
  }
  .table-shell.table-cards tbody td:not([data-label])::before,
  .table-shell.table-cards tbody td[data-label=""]::before {
    content: none;
  }
  .table-shell.table-cards .table th:first-child,
  .table-shell.table-cards .table td:first-child,
  .table-shell.table-cards .table th:last-child,
  .table-shell.table-cards .table td:last-child {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
.job-error {
  max-width: 24rem;
  overflow-wrap: anywhere;
  color: var(--muted);
}

/* -------------------------------------------------------------------------- */
/* Keyframes                                                                  */
/* -------------------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes pulse-ring {
  0%, 100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--signal) 0%, transparent), var(--shadow-sm);
  }
  50% {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--signal) 22%, transparent), var(--shadow-sm);
  }
}

/* -------------------------------------------------------------------------- */
/* Responsive — stack, never squeeze · 360 / 390 / 414 / 768 / 1024 / 1440   */
/* Cardinal rule: when space runs out, elements STACK at full size/padding.   */
/* -------------------------------------------------------------------------- */

/* Readable measure on wide screens */
.lead,
.landing-lede,
.section-lead,
.card-copy,
.empty-body,
.muted.control-copy,
.settings-head p {
  max-width: var(--body-measure);
}
h1, h2, .pagehead h1 {
  overflow-wrap: anywhere;
  hyphens: auto;
}

/* Tablet and below: multi-column product grids collapse */
@media (max-width: 1023px) {
  .gs-steps { grid-template-columns: minmax(0, 1fr); }
  .gs-step {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .65rem .75rem;
  }
  .gs-step > .gs-num { margin: 0; }
  .gs-body { flex: 1 1 10rem; min-width: 0; }
  .gs-now { margin-top: 0; align-self: center; }
  .tier-pick { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .usage-card { grid-column: auto; }
  .billing-grid { grid-template-columns: 1fr; }
  .site-workbench { grid-template-columns: 1fr; }
  .site-controls {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .site-frame-wrap { min-height: 28rem; }
  #sg-preview { min-height: 28rem; }
  .site-builder-head { align-items: flex-start; flex-direction: column; }
  .site-publish-state { margin-left: 0; }
  .cols-3 { grid-template-columns: minmax(0, 1fr); }
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
  .control-grid { grid-template-columns: minmax(0, 1fr); }
  .pagehead {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .75rem;
  }
  .pagehead .spacer { display: none; }
}

@media (max-width: 767px) {
  body { font-size: 15.5px; }
  .who { display: none; }
  .cols-demos { grid-template-columns: minmax(0, 1fr); }
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .activity-row {
    flex-wrap: wrap;
    row-gap: .35rem;
  }
  .activity-name {
    flex: 1 1 100%;
    max-width: 100%;
  }
  .demo .foot { flex-wrap: wrap; }
  .control-btn {
    min-height: 4.2rem;
    align-items: center;
  }
  .stat-row { align-items: center; }
  main { padding: 1.25rem 0 3rem; }
  .wrap {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }
  .topbar .row {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    gap: .55rem;
  }
  .topbar {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--nav-h) + env(safe-area-inset-top, 0px));
  }
  .topbar.is-scrolled {
    height: calc(var(--nav-h-scrolled) + env(safe-area-inset-top, 0px));
  }
  .toast {
    left: max(.75rem, env(safe-area-inset-left, 0px));
    right: max(.75rem, env(safe-area-inset-right, 0px));
    max-width: none;
  }
  .gs-card {
    margin-bottom: 1.2rem;
    padding: 1.1rem 1rem;
  }
  .gs-step.is-current::before {
    top: .4rem;
    bottom: .4rem;
  }
  /* Forms: full-width actions on phones — never shrink */
  .auth .btn,
  .settings-card .btn,
  .settings-card form .btn,
  .billing-actions .btn,
  .billing-actions form,
  .billing-actions form .btn,
  .gs-next .btn,
  .gs-step .btn,
  .gs-step form,
  .gs-step form .btn {
    width: 100%;
    max-width: 100%;
    justify-content: center;
  }
  .billing-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .connected-row {
    flex-direction: column;
    align-items: stretch;
  }
  .connected-row .btn { width: 100%; justify-content: center; }
  .gs-step {
    grid-template-columns: auto 1fr;
  }
  .gs-step .btn,
  .gs-step form,
  .gs-step .chip {
    grid-column: 1 / -1;
    justify-self: stretch;
  }
  .settings-card .btn { justify-self: stretch; }
  .tile,
  .settings-card,
  .billing-card,
  .control-card,
  .section,
  .pipe-step {
    /* Full padding preserved — never compress cards on phones */
    padding-left: max(1rem, .95rem);
    padding-right: max(1rem, .95rem);
  }
}

/* Phone floor ~360–414 — still stack, never squeeze type/cards */
@media (max-width: 414px) {
  .tile { padding: 1.05rem 1rem; }
  .control-card { padding: 1rem; }
  .control-btn {
    flex-wrap: wrap;
    gap: .45rem;
  }
  .job-status { font-size: .64rem; }
  .pagehead { gap: .45rem; }
  .badge { font-size: .66rem; }
  .gs-head { flex-direction: column; }
  .gs-step { padding: .85rem .9rem; }
  .brand { font-size: .98rem; }
  .auth .card { padding: 1.35rem 1.15rem; }
  .site-contact-grid { grid-template-columns: 1fr; }
  .site-builder { padding: .85rem max(.75rem, env(safe-area-inset-left)) 1.5rem max(.75rem, env(safe-area-inset-right)); }
  .site-workbench { border-radius: var(--r-lg); }
}

@media (min-width: 1280px) {
  .wrap { padding-left: 2rem; padding-right: 2rem; }
  .stats-grid { gap: 1.05rem; }
  .section { margin-top: 2.75rem; }
}

@media (min-width: 1440px) {
  .wrap { padding-left: 2.25rem; padding-right: 2.25rem; }
}

/* -------------------------------------------------------------------------- */
/* Reduced motion                                                             */
/* -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .js .reveal,
  .js .reveal.revealed {
    opacity: 1;
    transform: none;
    transition: none !important;
    transition-delay: 0s !important;
  }
  .demo:hover .thumb img { transform: none; }
  .control-btn.primary.state-running { animation: none; }
  .tile:hover,
  .demo:hover,
  .reply:hover,
  .gs-step:hover,
  .tier-option:hover,
  .btn:hover {
    transform: none;
  }
  #sg-preview { transition: none !important; }
  .site-toggles i,
  .site-toggles i::after,
  .site-swatches label {
    transition: none !important;
  }
}

/* -------------------------------------------------------------------------- */
/* App shell — left sidebar + main column                                     */
/* -------------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100dvh;
  min-width: 0;
}
.app-sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: var(--sidebar-w);
  height: 100dvh;
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: 1rem .85rem 1.1rem;
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  border-right: 1px solid var(--line);
  z-index: 45;
  overflow-y: auto;
}
.app-sidebar .brand {
  margin: .15rem .35rem 1rem;
  font-size: 1.02rem;
}
.side-nav {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  flex: 1 1 auto;
}
.side-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .7rem .75rem;
  min-height: var(--touch);
  border-radius: var(--r-md);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
  border: 1px solid transparent;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}
.side-link:hover {
  color: var(--ink);
  background: var(--bg-soft);
}
.side-link.is-active {
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-raised));
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  box-shadow: var(--shadow-sm);
}
.side-link.is-soon {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}
.side-link .side-ico {
  width: 1.15rem;
  height: 1.15rem;
  flex: 0 0 auto;
  opacity: .9;
}
.side-link .side-soon {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--faint);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  padding: .15rem .4rem;
}
.side-foot {
  margin-top: auto;
  padding-top: .85rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: .55rem;
}
.side-who {
  font-size: .78rem;
  color: var(--muted);
  padding: 0 .35rem;
  overflow-wrap: anywhere;
}
.side-who b { color: var(--ink); font-weight: 650; }
.app-column {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.app-shell .topbar {
  max-width: none;
}
.app-shell .topbar .row {
  max-width: none;
}
.app-shell .app-column > .wrap.foot-wrap,
.app-shell .app-column > footer {
  margin-top: auto;
}
body.has-app-shell .foot-site {
  margin-top: 1.5rem;
}
body.has-app-shell {
  padding-bottom: 0;
}

/* Mobile: hamburger drawer + bottom nav (≤1023px) */
.sidebar-toggle {
  display: none;
  place-items: center;
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  min-height: var(--touch);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
}
.sidebar-toggle svg { width: 1.15rem; height: 1.15rem; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 44;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 46;
  height: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
  padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom, 0px));
  padding-left: max(.4rem, env(safe-area-inset-left, 0px));
  padding-right: max(.4rem, env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--bg-raised) 94%, transparent);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  justify-content: space-around;
  align-items: stretch;
  gap: .2rem;
}
.mobile-nav a {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  font-size: .65rem;
  font-weight: 650;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--r-sm);
  padding: .35rem .2rem;
  min-width: 0;
  min-height: var(--touch);
}
.mobile-nav a.is-active {
  color: var(--accent-hover);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.mobile-nav a svg {
  width: 1.2rem;
  height: 1.2rem;
}
.mobile-nav a.is-soon,
.mobile-nav span.is-soon {
  opacity: .45;
  pointer-events: none;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  font-size: .65rem;
  font-weight: 650;
  color: var(--muted);
  min-width: 0;
  min-height: var(--touch);
}
.mobile-nav span.is-soon svg {
  width: 1.2rem;
  height: 1.2rem;
}

/* Scroll lock while drawer open (position fixed set by JS via class) */
body.is-scroll-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

@media (max-width: 1023px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(var(--sidebar-w), calc(100vw - 3rem));
    max-width: 20rem;
    height: 100dvh;
    height: 100svh;
    padding-top: max(1rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(1.1rem, env(safe-area-inset-bottom, 0px));
    transform: translateX(-105%);
    transition: transform var(--dur-slow) var(--ease);
    box-shadow: var(--shadow);
    z-index: 45;
  }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .sidebar-toggle { display: grid; }
  .mobile-nav { display: flex; }
  body.has-app-shell {
    padding-bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
  }
  body.has-app-shell .toast {
    bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px) + 1rem);
  }
  body.has-app-shell .foot-wrap {
    padding-bottom: .5rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  .app-sidebar { transition: none !important; }
}

/* -------------------------------------------------------------------------- */
/* Pipeline stepper (dashboard spine)                                         */
/* -------------------------------------------------------------------------- */
.pipeline {
  display: grid;
  gap: .75rem;
  margin: 0 0 1.5rem;
}
.pipeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: .75rem 1rem;
  margin-bottom: .15rem;
}
.pipeline-kicker {
  margin: 0 0 .2rem;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-hover);
}
.pipeline-head h2 {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
}
/* Pause control: state label + one action (not a red multi-message box) */
.pipeline-stop {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .35rem .4rem .35rem .55rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-sm);
}
.pipeline-stop .job-status {
  margin: 0;
}
.pipeline-stop .btn {
  flex: 0 0 auto;
  min-height: 2.25rem;
  padding: .4rem .85rem;
  border-radius: var(--r-pill);
}
.pipeline-stop .btn.danger {
  /* only warn when actively stopping is meaningful — keep quiet when idle */
  color: var(--ink);
  border-color: var(--line);
  background: transparent;
}
.pipeline-stop .btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
}
.pipeline-stop[data-state="running"] .btn.danger,
.pipeline-stop[data-state="queued"] .btn.danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
}

/* Desktop: wrap cards at ~230px min — never squeeze 5 into narrow columns */
.pipeline-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14.5rem, 1fr));
  gap: .85rem;
}
.pipe-step {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  min-width: 0;
  padding: 1.15rem 1.15rem 1.2rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition:
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
/* Horizontal accent bar (desktop / wide) */
.pipe-step::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: transparent;
}
.pipe-step.is-done::before {
  background: linear-gradient(90deg, var(--accent), var(--accent-violet));
}
.pipe-step.is-current {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-glow);
}
.pipe-step.is-current::before {
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
}
/* Locked: readable, not dim-on-dim */
.pipe-step.is-locked {
  opacity: 1;
  background: var(--bg-soft);
  border-color: var(--line);
}
.pipe-step.is-locked .pipe-title {
  color: var(--ink);
}
.pipe-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem;
}
.pipe-num {
  width: 1.65rem;
  height: 1.65rem;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 750;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-soft));
  color: var(--accent-hover);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  flex: 0 0 auto;
}
.pipe-step.is-done .pipe-num {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-raised));
  color: var(--accent-hover);
}
.pipe-step.is-current .pipe-num {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.pipe-step.is-locked .pipe-num {
  background: color-mix(in srgb, var(--bg-hover) 80%, var(--bg-soft));
  color: var(--muted);
  border-color: var(--line-strong);
}
.pipe-status {
  font-family: var(--mono);
  font-size: .62rem;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .18rem .42rem;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pipe-step.is-done .pipe-status {
  color: var(--accent-hover);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: transparent;
}
.pipe-step.is-current .pipe-status {
  color: var(--signal-ink);
  background: var(--signal);
  border-color: transparent;
}
.pipe-step.is-locked .pipe-status {
  color: var(--muted);
  background: color-mix(in srgb, var(--bg-hover) 70%, transparent);
  border-color: var(--line);
}
.pipe-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -.015em;
  line-height: 1.25;
}
.pipe-copy {
  margin: 0;
  font-size: .84rem;
  color: var(--muted);
  line-height: 1.45;
  flex: 1 1 auto;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}
.pipe-lock-reason {
  margin: 0;
  font-size: .84rem;
  font-weight: 550;
  color: var(--ink);
  font-style: normal;
  line-height: 1.4;
  overflow-wrap: break-word;
  word-break: normal;
  hyphens: none;
}
.pipe-action {
  margin-top: .2rem;
}
.pipe-action .btn,
.pipe-action .action-form .btn {
  width: 100%;
  justify-content: center;
}
.pipe-action .btn:disabled,
.pipe-action .action-form .btn:disabled {
  opacity: .65;
  cursor: not-allowed;
}
.pipe-action .control-btn {
  min-height: 2.6rem;
  padding: .55rem .75rem;
  align-items: center;
}
.pipe-action .control-label { gap: .1rem; }
.pipe-action .control-hint { display: none; }
.pipe-action .job-status { display: none; }

.pipeline-activity {
  margin-top: .25rem;
}
.pipeline-activity .control-card {
  /* reuse control-card chrome */
}
.pipeline-activity .activity-head {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.dash-layout {
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 1100px) {
  .dash-layout.has-side {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 20rem);
    align-items: start;
  }
  .dash-layout.has-side .pipeline-activity {
    position: sticky;
    top: calc(var(--nav-h) + .75rem);
  }
}

/* Hero glow behind page heads / landing cards */
.glow-card {
  position: relative;
  isolation: isolate;
}
.glow-card::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -20% -10% auto;
  height: 70%;
  background: radial-gradient(ellipse at 50% 0%, var(--glow-violet), transparent 70%);
  pointer-events: none;
}

/* -------------------------------------------------------------------------- */
/* Marketing landing (anonymous /)                                            */
/* -------------------------------------------------------------------------- */
.landing {
  padding-bottom: 3rem;
}
.landing-hero {
  position: relative;
  padding: clamp(2.5rem, 8vw, 5.5rem) 0 clamp(2rem, 5vw, 3.5rem);
  overflow: hidden;
}
.landing-hero::before {
  content: "";
  position: absolute;
  width: min(28rem, 70vw);
  height: min(28rem, 70vw);
  left: 50%;
  top: -10%;
  transform: translateX(-50%);
  background: radial-gradient(circle, var(--glow-violet), transparent 68%);
  pointer-events: none;
  z-index: 0;
}
.landing-hero .wrap { position: relative; z-index: 1; }
.landing-hero h1 {
  max-width: 16ch;
  font-size: clamp(2.2rem, 6vw, 3.6rem);
  letter-spacing: -.04em;
  margin-bottom: .75rem;
}
.landing-lede {
  max-width: 38rem;
  color: var(--muted);
  font-size: clamp(1.02rem, 2vw, 1.2rem);
  line-height: 1.55;
  margin: 0 0 1.5rem;
}
.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  align-items: center;
  margin-bottom: 1rem;
}
.landing-note {
  color: var(--faint);
  font-size: .82rem;
  margin: 0;
}
.landing-section {
  padding: clamp(2.5rem, 6vw, 4rem) 0;
}
.landing-section h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  margin-bottom: .35rem;
}
.landing-section .section-lead {
  color: var(--muted);
  max-width: 36rem;
  margin: 0 0 1.5rem;
}
.how-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .9rem;
}
.how-card {
  padding: 1.25rem 1.2rem 1.4rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  min-width: 0;
}
.how-num {
  display: inline-grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: var(--r-pill);
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 750;
  margin-bottom: .85rem;
  background: linear-gradient(145deg, var(--accent), var(--accent-violet));
  color: #fff;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent);
}
.how-card h3 {
  font-size: 1.05rem;
  margin: 0 0 .4rem;
  letter-spacing: -.02em;
}
.how-card p {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.5;
}
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .9rem;
  align-items: stretch;
}
.price-card {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding: 1.35rem 1.25rem 1.45rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur), border-color var(--dur);
}
.price-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--line-strong);
}
.price-card.is-featured {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-glow);
  background:
    linear-gradient(165deg, color-mix(in srgb, var(--accent) 10%, var(--bg-raised)), var(--bg-raised) 55%);
}
.price-tier {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent-hover);
}
.price-amt {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 720;
  letter-spacing: -.03em;
  line-height: 1.05;
}
.price-amt small {
  font-size: .85rem;
  font-weight: 520;
  color: var(--muted);
  letter-spacing: 0;
}
.price-feats {
  list-style: none;
  margin: .35rem 0 1rem;
  padding: 0;
  flex: 1 1 auto;
}
.price-feats li {
  padding: .4rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .88rem;
}
.price-card .btn { width: 100%; justify-content: center; margin-top: auto; }
.landing-cta {
  text-align: center;
  padding: clamp(2rem, 5vw, 3rem) 1.5rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.landing-cta::before {
  content: "";
  position: absolute;
  inset: -40% 20% auto;
  height: 80%;
  background: radial-gradient(ellipse, var(--glow-indigo), transparent 70%);
  pointer-events: none;
}
.landing-cta h2 { position: relative; margin-bottom: .4rem; }
.landing-cta p { position: relative; color: var(--muted); margin: 0 0 1.1rem; }
.landing-cta .landing-actions { position: relative; justify-content: center; }

/* Pipeline: single column + left connector below 1024 — never squeeze 5→2 */
@media (max-width: 1023px) {
  .pipeline-track {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-left: 1.15rem;
    margin-left: .35rem;
    border-left: 2px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  }
  .pipe-step {
    margin: 0 0 .85rem;
    overflow: visible;
  }
  .pipe-step:last-child {
    margin-bottom: 0;
    grid-column: auto;
  }
  /* Dot on the vertical connector */
  .pipe-step::after {
    content: "";
    position: absolute;
    left: calc(-1.15rem - 5px);
    top: 1.15rem;
    width: .55rem;
    height: .55rem;
    border-radius: 50%;
    background: var(--bg-soft);
    border: 2px solid color-mix(in srgb, var(--accent) 45%, var(--line));
    box-shadow: 0 0 0 3px var(--bg);
    z-index: 1;
  }
  .pipe-step.is-done::after {
    background: var(--accent);
    border-color: var(--accent);
  }
  .pipe-step.is-current::after {
    background: var(--accent-violet);
    border-color: var(--accent-violet);
    box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent);
  }
  .pipe-step.is-locked::after {
    background: var(--bg-soft);
    border-color: var(--line-strong);
  }
  /* Keep top accent strip subtle on mobile cards */
  .pipe-step::before { border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .how-grid,
  .pricing-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .landing-actions { flex-direction: column; align-items: stretch; }
  .landing-actions .btn,
  .landing-cta .landing-actions .btn,
  .price-card .btn {
    width: 100%;
    justify-content: center;
    min-height: var(--touch);
  }
  .landing-hero h1 {
    max-width: none;
    font-size: clamp(1.85rem, 9vw, 2.6rem);
  }
  .landing-section { padding: clamp(2rem, 8vw, 3rem) 0; }
  .how-card,
  .price-card {
    padding: 1.25rem 1.15rem 1.4rem;
  }
  /* Marketing topbar CTAs don't cram — secondary can hide if tight */
  .topbar .btn.sm { min-height: var(--touch); }
}
@media (max-width: 414px) {
  .topbar .row > .btn.ghost.sm { display: none; }
}

/* -------------------------------------------------------------------------- */
/* Territory map picker — full-viewport app screen (no page scroll)           */
/* -------------------------------------------------------------------------- */

/* Lock the app shell: no page scrollbar on /territory */
body.territory-full {
  overflow: hidden;
  height: 100dvh;
  max-height: 100dvh;
}
body.territory-full .app-shell {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
body.territory-full .app-column {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.territory-full .app-column > .topbar {
  flex: 0 0 auto;
}
body.territory-full .app-column > .wrap.foot-wrap,
body.territory-full .app-column > footer,
body.territory-full .foot-wrap {
  display: none !important;
}

.territory-page {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.territory-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: .45rem .75rem .55rem;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  overflow: hidden;
}

/* Compact single-row toolbar */
.territory-toolbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: .5rem .65rem;
  padding: .35rem .55rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.territory-brand {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
}
.territory-brand h1 {
  margin: 0;
  font-size: .98rem;
  letter-spacing: -.02em;
  font-weight: 700;
  white-space: nowrap;
}
.territory-info-btn {
  display: inline-grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  min-width: 1.7rem;
  min-height: 1.7rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  cursor: pointer;
}
.territory-info-btn:hover {
  color: var(--ink);
  background: var(--bg-hover);
  border-color: var(--line-strong);
}
.territory-info-btn[aria-expanded="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
}
.territory-info-pop {
  position: absolute;
  top: calc(100% + .4rem);
  left: 0;
  z-index: 20;
  width: min(18rem, 70vw);
  padding: .65rem .75rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  font-size: .82rem;
  line-height: 1.4;
  color: var(--muted);
}
.territory-cap {
  display: inline-block;
  margin-left: .25rem;
  padding: .08rem .4rem;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: .7rem;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
}

/* Segmented Draw / Cities control */
.territory-modes {
  display: inline-flex;
  gap: 0;
  padding: .15rem;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  flex: 0 1 auto;
  min-width: 0;
}
.mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: .82rem;
  min-height: 2.1rem;
  min-width: 0;
  padding: .25rem .7rem;
  cursor: pointer;
  line-height: 1;
}
.mode-btn .mode-ico {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  opacity: .9;
}
.mode-btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  box-shadow: var(--shadow-glow, 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent),
    0 4px 16px color-mix(in srgb, var(--accent-violet) 28%, transparent));
  font-weight: 700;
}
.mode-btn:not(.is-active):hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.territory-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: .35rem;
  margin-left: auto;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
}
.territory-draw-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  gap: .3rem;
  align-items: center;
}
.territory-draw-actions[hidden] { display: none !important; }

/* Slim status strip */
.territory-status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: .45rem;
  padding: .28rem .6rem;
  border-radius: var(--r-sm);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: .8rem;
  color: var(--muted);
  min-width: 0;
  min-height: 1.85rem;
}
.territory-status #terr-status-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.territory-status .status-dot {
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}
.territory-status.is-ok .status-dot { background: var(--accent); }
.territory-status.is-warn .status-dot { background: var(--warn); }
.territory-status.is-err .status-dot { background: var(--danger); }
.territory-status .status-meta {
  margin-left: auto;
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--ink);
  flex: 0 0 auto;
  white-space: nowrap;
}
.territory-status .status-meta.is-over { color: var(--danger); }

/* Map fills ALL remaining height — no fixed rem height */
.territory-map-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: auto;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: #0B0E1A;
  box-shadow: var(--shadow);
  touch-action: pan-x pan-y;
}
.territory-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: pan-x pan-y;
}
.territory-map .maplibregl-canvas-container,
.territory-map .maplibregl-canvas {
  touch-action: pan-x pan-y;
}
.territory-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(4px);
  z-index: 2;
  touch-action: manipulation;
}
.territory-overlay .empty {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow);
  max-width: 22rem;
  width: 100%;
}
.territory-overlay .btn { margin-top: .75rem; min-height: var(--touch); }

/* Floating dismissible instruction card — not layout flow */
.territory-howto {
  position: absolute;
  top: .65rem;
  left: .65rem;
  z-index: 3;
  max-width: min(16.5rem, calc(100% - 5rem));
  padding: .55rem .65rem .6rem;
  background: color-mix(in srgb, var(--bg-raised) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  pointer-events: auto;
  touch-action: manipulation;
  backdrop-filter: blur(8px);
}
.territory-howto-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .15rem;
}
.territory-howto-kicker {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--accent-violet, #8B5CF6);
  font-weight: 600;
}
.territory-howto-dismiss {
  min-width: 1.75rem;
  min-height: 1.75rem;
  padding: 0 .3rem;
  line-height: 1;
  font-size: 1.05rem;
  color: var(--muted);
}
.territory-howto-body {
  margin: 0;
  font-size: .8rem;
  line-height: 1.35;
  color: var(--ink);
}

/* City chips + hover label float over the map */
.territory-chips-float {
  position: absolute;
  left: .65rem;
  right: .65rem;
  bottom: .65rem;
  z-index: 3;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  max-height: 30%;
  overflow: auto;
  pointer-events: none;
}
.territory-chips-float[hidden] { display: none !important; }
.territory-chips-float .territory-chip,
.territory-chips-float li {
  pointer-events: auto;
}
.territory-selected li,
.territory-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem;
  padding: .25rem .35rem .25rem .6rem;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-raised));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  font-size: .78rem;
  color: var(--ink);
  min-height: 2rem;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
}
.territory-chip-name {
  font-weight: 550;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.territory-chip-remove {
  min-height: 1.65rem;
  min-width: 1.65rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
}
.territory-hover-pill {
  position: absolute;
  top: .65rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  padding: .28rem .65rem;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink);
  max-width: min(20rem, calc(100% - 7rem));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  backdrop-filter: blur(6px);
}
.territory-hover-pill[hidden] { display: none !important; }

/* MapLibre controls */
.territory-map-frame .maplibregl-ctrl-group {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.territory-map-frame .maplibregl-ctrl-group button {
  background: transparent;
  border-color: var(--line);
  min-width: var(--touch);
  min-height: var(--touch);
  color: var(--ink);
}
.territory-map-frame .maplibregl-ctrl-group button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.territory-actions .btn {
  min-height: 2.1rem;
  padding-left: .65rem;
  padding-right: .65rem;
  font-size: .82rem;
}
.territory-map-frame .maplibregl-ctrl-attrib {
  background: color-mix(in srgb, var(--bg-raised) 90%, transparent);
  color: var(--muted);
  font-size: 10px;
}
.territory-map-frame .maplibregl-ctrl-attrib a { color: var(--accent); }

/* Tablet / narrow: two compact rows max for chrome, map still fills rest */
@media (max-width: 1023px) {
  /* body.has-app-shell already pads for mobile-nav (border-box) — fill that box */
  body.territory-full .app-shell,
  body.territory-full .app-column {
    height: 100%;
    max-height: 100%;
  }
  .territory-shell {
    padding: .4rem .55rem .45rem;
    gap: .35rem;
  }
  .territory-toolbar {
    flex-wrap: wrap;
    row-gap: .35rem;
    padding: .4rem .5rem;
  }
  .territory-modes {
    order: 3;
    flex: 1 1 100%;
  }
  .territory-modes .mode-btn {
    flex: 1 1 0;
  }
  .territory-actions {
    margin-left: auto;
  }
  .territory-map-frame {
    border-radius: var(--r-sm);
  }
}

/* Phones: edge-to-edge map, chrome ≤2 rows, no page scroll */
@media (max-width: 767px) {
  .territory-shell {
    padding: .35rem 0 0;
    gap: .3rem;
  }
  .territory-toolbar,
  .territory-status {
    margin-left: max(.55rem, env(safe-area-inset-left, 0px));
    margin-right: max(.55rem, env(safe-area-inset-right, 0px));
  }
  .territory-brand h1 { font-size: .92rem; }
  .territory-draw-actions .btn { padding-left: .45rem; padding-right: .45rem; }
  .territory-map-frame {
    width: 100%;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .territory-howto {
    top: auto;
    left: .55rem;
    right: .55rem;
    bottom: .55rem;
    max-width: none;
    width: auto;
  }
  .territory-chips-float {
    left: .55rem;
    right: .55rem;
    bottom: .55rem;
  }
  /* When howto is visible, chips sit above it */
  .territory-howto:not([hidden]) ~ .territory-chips-float {
    bottom: 4.75rem;
  }
  .territory-map-frame .maplibregl-ctrl-top-right {
    top: .45rem;
    right: .45rem;
  }
  .territory-chip-name { max-width: 9rem; }
  .mode-btn span { font-size: .8rem; }
}


/* -------------------------------------------------------------------------- */
/* Getting started (first-run onboarding)                                     */
/* -------------------------------------------------------------------------- */
.gs-card {
  margin: 0 0 1.25rem;
  padding: 1.25rem 1.35rem 1.35rem;
}
.gs-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.gs-head h2 {
  margin: 0;
  font-size: clamp(1.15rem, 2.4vw, 1.4rem);
}
.gs-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: .65rem;
}
.gs-step {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1rem;
  border-radius: var(--r-lg);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.gs-step.is-current {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-glow);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg-raised));
}
.gs-step.is-done {
  opacity: .92;
}
.gs-num {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: .75rem;
  font-weight: 750;
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-soft));
  color: var(--accent-hover);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  flex: 0 0 auto;
}
.gs-step.is-done .gs-num {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-raised));
  color: var(--accent-hover);
}
.gs-step.is-current .gs-num {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.gs-step-title {
  margin: 0;
  font-size: .95rem;
  font-weight: 650;
  letter-spacing: -.015em;
}
.gs-step-copy {
  margin: .15rem 0 0;
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.4;
}
.gs-next {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
  margin-top: 1rem;
  padding-top: .9rem;
  border-top: 1px solid var(--line);
}
.gs-explainer {
  margin: 0 0 1.25rem;
  padding: 1.2rem 1.35rem 1.3rem;
}
.gs-explainer-head h2 {
  margin: 0;
  font-size: clamp(1.1rem, 2.2vw, 1.3rem);
}
.gs-timeline {
  margin: 1rem 0 0;
  padding: 0 0 0 1.15rem;
  display: grid;
  gap: .55rem;
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.45;
}
.gs-timeline li.is-active {
  color: var(--ink);
}
.gs-timeline li.is-active b {
  color: var(--accent-hover);
}
.toast.is-warn {
  background: var(--warn-soft);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}

/* Billing */
.billing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.billing-card {
  padding: 1.25rem 1.35rem 1.4rem;
}
.billing-card h2 {
  margin: .35rem 0 .25rem;
  font-size: 1.15rem;
}
.billing-card .card-copy {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: .9rem;
}
.billing-plan {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .85rem;
}
.billing-plan-name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.billing-plan-price {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-hover);
}
.billing-plan-price small,
.billing-tier-price small {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 500;
}
.billing-caps {
  margin: 0 0 1rem;
  padding: 0 0 0 1.1rem;
  color: var(--muted);
  font-size: .9rem;
  line-height: 1.55;
}
.billing-caps b { color: var(--ink); }
.billing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}
.billing-tiers {
  display: grid;
  gap: .65rem;
}
.billing-tier {
  padding: .75rem .9rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
.billing-tier.is-current {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  box-shadow: var(--shadow-glow);
}
.billing-tier-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}
.billing-tier-price {
  font-family: var(--mono);
  font-weight: 700;
  margin: .2rem 0;
  color: var(--ink);
}
/* billing + gs-step stack rules live in the global responsive block */

/* Live businesses + demo QC */
.live-page{padding-top:2rem;padding-bottom:3rem}.live-head{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:1.25rem}.live-head h1{margin:.15rem 0;font-size:clamp(1.8rem,4vw,2.6rem)}.summary-chips{display:flex;flex-wrap:wrap;gap:.6rem;margin-bottom:1rem}.live-controls{display:grid;grid-template-columns:2fr 1fr 1fr;gap:1rem;padding:1rem;margin-bottom:1rem}.business-table{overflow:auto}.business-table a{color:var(--accent-hover)}
.demo-review{display:grid;grid-template-columns:minmax(230px,300px) minmax(0,1fr);min-height:680px;overflow:hidden}.demo-queue{padding:1rem;border-right:1px solid var(--line);background:var(--bg-soft)}.demo-select{display:none}.demo-list{display:grid;gap:.5rem}.demo-item{display:flex;align-items:center;justify-content:space-between;gap:.5rem;padding:.75rem;border:1px solid transparent;border-radius:var(--r-md);color:var(--ink);text-decoration:none}.demo-item:hover,.demo-item.is-active{background:var(--bg-hover);border-color:var(--line-strong)}.demo-item small{display:block;color:var(--faint);margin-top:.2rem}.demo-stage{display:flex;flex-direction:column;min-width:0}.demo-toolbar,.demo-actions{display:flex;align-items:center;justify-content:space-between;gap:.75rem;padding:.85rem 1rem;border-bottom:1px solid var(--line)}.demo-toolbar>div{display:flex;align-items:center;gap:.6rem}.demo-toolbar a{color:var(--accent-hover)}.demo-frame{width:100%;min-height:550px;flex:1;border:0;background:white}.demo-actions{border:0;border-top:1px solid var(--line)}.qc-actions{display:flex;gap:.5rem}.btn.disabled{pointer-events:none;opacity:.4}
@media(max-width:767px){.live-head{display:grid}.live-controls{grid-template-columns:1fr}.demo-review{display:block;min-height:0}.demo-queue{border:0;border-bottom:1px solid var(--line)}.demo-select{display:grid}.demo-list{display:none}.demo-frame{min-height:65vh}.demo-actions{flex-wrap:wrap}.qc-actions{order:3;width:100%}.qc-actions form,.qc-actions .btn{width:100%}}

/* Hallmark · macrostructure: Manifesto · tone: declarative-direct · anchor hue: indigo (locked palette + grid)
 * theme: system palette · NEW type: Fraunces display (roman+italic) + Instrument Sans body + JetBrains Mono data
 * enrichment: none — typography only · components: contract block · ledger pricing · thesis stack
 * differs from last (Map-Diagram): display style serif-italic vs sans · divider bleed-bands vs single composition · no boxed cards
 * Hallmark · pre-emit critique: P5 H4 E4 S5 R4 V5
 */
@font-face {
  font-family: "Fraunces";
  src: url("fonts/Fraunces-Variable.woff2") format("woff2");
  font-weight: 300 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("fonts/Fraunces-Variable-Italic.woff2") format("woff2");
  font-weight: 300 900; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/InstrumentSans-Variable.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}
:root {
  --font-display: "Fraunces", Georgia, serif;
  --font-copy: "Instrument Sans", var(--font), sans-serif;
  --rule-heavy: 3px solid var(--accent);
}

.mfo { font-family: var(--font-copy); }

/* opening declaration */
.mfo-open { padding: clamp(4rem, 12vh, 8rem) 0 clamp(3rem, 8vh, 5rem); }
.mfo-kicker {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--faint); margin: 0 0 2rem;
}
.mfo-decl {
  font-family: var(--font-display); font-weight: 560; color: var(--ink);
  font-size: clamp(2.8rem, 8.5vw, 6.2rem); line-height: 1.02; letter-spacing: -.015em;
  margin: 0 0 1.6rem; transform: rotate(-1.2deg); transform-origin: left bottom;
  overflow-wrap: anywhere; min-width: 0; max-width: 12ch;
}
.mfo-decl span { display: block; }
.mfo-decl-b { color: var(--muted); }
.mfo-decl-b em { font-style: italic; color: var(--accent-violet); }
.mfo-claim { font-size: 1.15rem; line-height: 1.7; color: var(--muted); max-width: 54ch; margin: 0 0 2rem; }
.mfo-scroll {
  font-family: var(--mono); font-size: .82rem; color: var(--ink); text-decoration: none;
  border-bottom: 2px solid var(--accent); padding-bottom: 3px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.mfo-scroll:hover { color: var(--accent-hover); border-color: var(--accent-hover); }

/* the argument — thesis stack with bleed rhythm */
.mfo-arg { padding: clamp(2rem, 6vh, 4rem) 0; }
.mfo-thesis { border-top: var(--rule-heavy); padding: 2.2rem 0 2.6rem; max-width: 62ch; }
.mfo-thesis.is-shift { margin-left: clamp(0px, 12vw, 220px); border-top-color: var(--accent-violet); }
.mfo-num { font-family: var(--mono); font-size: .85rem; color: var(--signal); letter-spacing: .1em; }
.mfo-thesis h2 {
  font-family: var(--font-display); font-weight: 540; font-size: clamp(1.7rem, 4.2vw, 2.9rem);
  line-height: 1.12; letter-spacing: -.012em; color: var(--ink); margin: .5rem 0 .9rem;
  overflow-wrap: anywhere; min-width: 0;
}
.mfo-thesis p { font-size: 1.02rem; line-height: 1.7; color: var(--muted); margin: 0; }
.mfo-thesis strong { color: var(--ink); font-weight: 600; }

/* the contract */
.mfo-contract-band { padding: clamp(2.5rem, 8vh, 5rem) 0; background: color-mix(in oklab, var(--bg-raised) 55%, var(--bg)); }
.mfo-contract { max-width: 680px; }
.mfo-contract-head {
  font-family: var(--mono); font-size: .72rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink); border-bottom: 1px solid var(--line-strong); padding-bottom: .8rem; margin: 0 0 1.4rem;
}
.mfo-sign { display: flex; align-items: flex-end; gap: 1.6rem; flex-wrap: wrap; }
.mfo-sign-line { flex: 1 1 180px; border-bottom: 1px dashed var(--line-strong); height: 2.2rem; min-width: 0; }
.mfo-cta {
  font-family: var(--font-copy); font-weight: 700; font-size: 1.05rem; text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
  padding: 1.05rem 2.4rem; border-radius: 10px; display: inline-block;
  transition: background var(--dur) var(--ease), transform var(--dur-micro, 120ms) var(--ease-out);
}
.mfo-cta:hover { background: var(--accent-hover); transform: translateY(-1px); }
.mfo-cta:active { transform: translateY(0); }
.mfo-cta:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

/* the ledger */
.mfo-ledger-band { padding: clamp(2.5rem, 8vh, 5rem) 0 2rem; }
.mfo-ledger-title {
  font-family: var(--font-display); font-style: italic; font-weight: 520;
  font-size: clamp(1.5rem, 3.2vw, 2.1rem); color: var(--ink); margin: 0 0 1.6rem;
}
.mfo-fineprint { font-size: .88rem; color: var(--faint); margin: 1.2rem 0 0; }

/* close */
.mfo-close { padding: clamp(3rem, 10vh, 6rem) 0 clamp(4rem, 10vh, 6rem); }
.mfo-close-line {
  font-family: var(--font-display); font-style: italic; font-weight: 540;
  font-size: clamp(2rem, 5.5vw, 3.6rem); line-height: 1.08; color: var(--ink);
  margin: 0 0 1.6rem; max-width: 16ch; overflow-wrap: anywhere; min-width: 0;
}
.mfo-close-row { display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap; }
.mfo-quiet { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--line-strong); padding-bottom: 2px; }
.mfo-quiet:hover { color: var(--ink); }

/* manifesto reveal: horizontal sweep */
.mfo .reveal { opacity: 0; transform: translateX(-16px); transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out); transition-delay: calc(var(--reveal-i, 0) * 80ms); }
.mfo .reveal.revealed { opacity: 1; transform: none; }

@media (max-width: 700px) {
  .mfo-thesis.is-shift { margin-left: 0; }
  .mfo-row { flex-wrap: wrap; gap: .4rem .9rem; }
  .mfo-terms { flex-basis: 100%; order: 4; }
  .mfo-fill { display: none; }
  .mfo-act { margin-left: auto; }
  .mfo-cta { width: 100%; text-align: center; }
  .mfo-sign-line { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .mfo .reveal { transition: opacity 150ms linear; transform: none; }
  .mfo-decl { transform: none; }
}

/* nav anchors (landing) */
.mfo-anchors { display: flex; gap: 1.1rem; margin-left: 1.4rem; }
.mfo-anchors a {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .04em;
  color: var(--muted); text-decoration: none; padding: .3rem .1rem;
  border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.mfo-anchors a:hover { color: var(--ink); border-color: var(--accent); }
.mfo-anchors a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (max-width: 860px) { .mfo-anchors { display: none; } }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* the record — live counters */
.mfo-record { padding: clamp(2rem, 6vh, 3.5rem) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.mfo-record-label { font-family: var(--mono); font-size: .7rem; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); margin: 0 0 1.4rem; }
.mfo-record-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
.mfo-stat-n {
  display: block; font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(1.8rem, 4.5vw, 3.2rem); font-weight: 700; color: var(--ink);
  letter-spacing: -.02em;
}
.mfo-stat-l { font-size: .88rem; color: var(--muted); }
@media (max-width: 700px) { .mfo-record-row { grid-template-columns: minmax(0, 1fr); gap: 1.1rem; } }

/* plan boxes — interactive */
.mfo-plans-band { padding: clamp(2.5rem, 8vh, 5rem) 0 2rem; }
.mfo-plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.1rem; }
.mfo-plan {
  display: flex; flex-direction: column; gap: .9rem; text-decoration: none;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 1.4rem 1.4rem 1.2rem; box-shadow: var(--shadow-sm);
  transition: transform var(--dur) var(--ease-out), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.mfo-plan:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow); }
.mfo-plan:active { transform: translateY(-1px); }
.mfo-plan:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.mfo-plan.is-featured { border-color: var(--accent); box-shadow: var(--shadow-glow, var(--shadow)); }
.mfo-plan-top { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.mfo-plan-name { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.mfo-plan-tag { font-family: var(--mono); font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--signal); }
.mfo-plan-price { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.7rem; color: var(--ink); }
.mfo-plan-price small { color: var(--faint); font-size: .78rem; }
.mfo-plan-caps { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.mfo-plan-caps li { font-size: .92rem; color: var(--muted); }
.mfo-plan-caps li span { font-family: var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; margin-right: .35rem; }
.mfo-plan-go { margin-top: auto; font-weight: 600; font-size: .95rem; color: var(--accent-hover); }
.mfo-plan:hover .mfo-plan-go { text-decoration: underline; }

/* terms of the line — surveyor flow */
.mfo-contract { max-width: 780px; }
.mfo-flow { position: relative; margin: 0 0 2.2rem; }
.mfo-flow-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.mfo-flow-path {
  fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke;
  stroke-linejoin: round; stroke-dasharray: 1200; stroke-dashoffset: 1200;
  transition: stroke-dashoffset 2.6s var(--ease-out) .2s;
}
.mfo-contract.revealed .mfo-flow-path { stroke-dashoffset: 0; }
.mfo-flow-list { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-rows: 104px; }
.mfo-clause { position: relative; display: flex; align-items: center; min-width: 0; }
.mfo-vertex {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0);
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
  transition: transform var(--dur-slow) var(--ease-out);
  transition-delay: calc(.35s + var(--i, 0) * .42s);
  z-index: 1;
}
.mfo-contract.revealed .mfo-vertex { transform: translate(-50%, -50%) scale(1); }
.mfo-clause-card {
  font-family: var(--mono); font-size: .88rem; line-height: 1.55; color: var(--muted);
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: .8rem 1rem; width: calc(50% - 2.6rem); box-shadow: var(--shadow-sm);
  opacity: 0; transform: translateY(6px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out), border-color var(--dur) var(--ease);
  transition-delay: calc(.45s + var(--i, 0) * .42s);
}
.mfo-contract.revealed .mfo-clause-card { opacity: 1; transform: none; }
.mfo-clause-card:hover { border-color: var(--accent-violet); }
.mfo-clause-card span { color: var(--accent); margin-right: .6rem; }
.mfo-clause.is-right { justify-content: flex-end; }
.mfo-sign { max-width: 780px; }
@media (max-width: 640px) {
  .mfo-flow-svg { display: none; }
  .mfo-flow-list { grid-auto-rows: auto; gap: .7rem; }
  .mfo-clause { padding-left: 1.6rem; }
  .mfo-vertex { left: .35rem; top: 1.1rem; transform: scale(0); }
  .mfo-contract.revealed .mfo-vertex { transform: scale(1); }
  .mfo-clause::before {
    content: ""; position: absolute; left: calc(.35rem + 5px); top: 1.6rem; bottom: -1rem;
    border-left: 2px dashed var(--line-strong);
  }
  .mfo-clause:last-child::before { display: none; }
  .mfo-clause-card, .mfo-clause.is-right .mfo-clause-card { width: 100%; }
  .mfo-clause.is-right { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .mfo-flow-path { stroke-dashoffset: 0; transition: none; }
  .mfo-vertex { transform: translate(-50%, -50%) scale(1) !important; transition: none; }
  .mfo-clause-card { opacity: 1; transform: none; transition: none; }
}

/* ── creative pass: bar air, alignment, line motifs ───────────────── */
/* landing topbar: brand left · anchors center · auth right, breathing room */
.topbar:has(.mfo-anchors) { padding-inline: clamp(1.2rem, 4vw, 3rem); gap: .9rem; }
.topbar:has(.mfo-anchors) .mfo-anchors { margin-left: clamp(1rem, 3vw, 2.6rem); margin-right: auto; gap: 1.5rem; }
.topbar:has(.mfo-anchors) .spacer { flex: 0 0 clamp(.5rem, 2vw, 1.5rem); }
.topbar:has(.mfo-anchors) .btn.ghost.sm { margin-right: .65rem; }
.topbar:has(.mfo-anchors) .btn.primary.sm { margin-right: .9rem; }
.mfo-anchors a.is-here { color: var(--ink); border-color: var(--accent); }

/* shared measure so every section starts on the same rhythm */
.mfo { --measure: 62ch; }
.mfo-claim, .mfo-thesis, .mfo-sub, .mfo-fineprint { max-width: var(--measure); }
.mfo-contract, .mfo-sign { margin-inline: auto; }

/* hero spotlight (HP3) — pointer-following soft radial, transform-only */
.mfo-open { position: relative; overflow: clip; }
.mfo-spot {
  position: absolute; width: 640px; height: 640px; left: -320px; top: -320px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in oklab, var(--accent-violet) 13%, transparent) 0%, transparent 62%);
  transform: translate(30vw, 10vh); will-change: transform;
}
@media (pointer: coarse), (prefers-reduced-motion: reduce) { .mfo-spot { display: none; } }

/* drawn underline under “build” */
.mfo-build { position: relative; display: inline-block; }
.mfo-underline { position: absolute; left: -2%; bottom: -.08em; width: 104%; height: .14em; overflow: visible; }
.mfo-underline path {
  fill: none; stroke: var(--accent-violet); stroke-width: 5; stroke-linecap: round;
  vector-effect: non-scaling-stroke; stroke-dasharray: 130; stroke-dashoffset: 130;
  animation: mfo-underline-draw .9s var(--ease-out) 1.1s forwards;
}
@keyframes mfo-underline-draw { to { stroke-dashoffset: 0; } }

/* surveyor coordinates marginalia */
.mfo-coords {
  position: absolute; top: 1.4rem; right: clamp(1rem, 4vw, 3rem);
  font-family: var(--mono); font-size: .62rem; letter-spacing: .18em;
  color: var(--faint); writing-mode: vertical-rl; text-orientation: mixed;
  opacity: .7; user-select: none;
}
@media (max-width: 900px) { .mfo-coords { display: none; } }

/* record: live pulse + increment flash */
.mfo-live {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--signal); margin-right: .6rem; vertical-align: 1px;
  animation: mfo-live 3s ease-in-out infinite;
}
@keyframes mfo-live { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.mfo-stat-n { transition: color var(--dur) var(--ease); }
.mfo-stat-n.is-bump { color: var(--signal); }

/* plan cards ride the shared reveal */
.mfo-plans .reveal { transform: translateY(10px); }
.mfo-plans .reveal.revealed { transform: none; }

/* closing polygon mark — draws when revealed into view */
.mfo-close-mark { width: 44px; height: 44px; margin-bottom: 1rem; display: block; }
.mfo-close-poly {
  fill: color-mix(in oklab, var(--accent) 10%, transparent); stroke: var(--accent);
  stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke;
  stroke-dasharray: 160; stroke-dashoffset: 160; animation: mfo-underline-draw 1.4s var(--ease-out) .2s forwards;
}
.mfo-close-mark circle { fill: var(--bg); stroke: var(--accent); stroke-width: 1.6; }
@media (prefers-reduced-motion: reduce) {
  .mfo-underline path, .mfo-close-poly { animation: none; stroke-dashoffset: 0; }
  .mfo-live { animation: none; opacity: .8; }
}
