/* 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;
  --space-section: clamp(1.75rem, 4vw, 2.6rem);
}

/* 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: 2.5rem; }
.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);
}
@media (max-width: 760px) {
  .settings-grid { grid-template-columns: 1fr; }
  .usage-card { grid-column: auto; }
}

/* 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%;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: .72rem .78rem;
  font: 500 .88rem/1.45 var(--font);
  resize: vertical;
  min-height: 2.5rem;
  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: 2.5rem;
  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: 2.5rem;
  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: 2.5rem;
  min-height: 2.5rem;
  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);
}
@media (max-width: 900px) {
  .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; }
}
@media (max-width: 520px) {
  .site-contact-grid { grid-template-columns: 1fr; }
  .site-builder { padding: .75rem .65rem 1.5rem; }
  .site-workbench { border-radius: var(--r-lg); }
}
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: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  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;
  gap: .5rem;
  cursor: pointer;
  font: 600 .9rem/1 var(--font);
  letter-spacing: -.01em;
  padding: .72rem 1.15rem;
  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: .5rem .85rem;
  font-size: .8rem;
  min-height: 2.5rem; /* ≥40px 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 {
  width: 100%;
  padding: .78rem .9rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--ink);
  font: 500 .95rem var(--font);
  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);
  border-color: transparent;
}
.badge.pend {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}

/* 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: anywhere;
}
.control-hint {
  font-size: .68rem;
  font-weight: 550;
  letter-spacing: .01em;
  opacity: .72;
  line-height: 1.25;
}

/* Job status chips */
.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;
  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);
}
.control-btn.danger .job-status,
.control-btn.ghost .job-status {
  color: inherit;
  background: color-mix(in srgb, currentColor 8%, transparent);
  border-color: color-mix(in srgb, currentColor 18%, transparent);
}
.job-status.idle { opacity: .78; }
.job-status.queued,
.control-btn.primary .job-status.queued,
.control-btn.danger .job-status.queued,
.control-btn.ghost .job-status.queued {
  color: #5c4208;
  background: color-mix(in srgb, #d8a13a 28%, var(--bg-raised));
  border-color: color-mix(in srgb, #d8a13a 45%, transparent);
  opacity: 1;
}
html[data-theme="light"] .job-status.queued,
html[data-theme="light"] .control-btn.primary .job-status.queued {
  color: #5c4208;
}
.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);
  opacity: 1;
}
.job-status.done,
.control-btn.primary .job-status.done,
.control-btn.danger .job-status.done,
.control-btn.ghost .job-status.done {
  color: var(--accent);
  background: var(--bg-raised);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  opacity: 1;
}
.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);
  opacity: 1;
}
.job-status.running i {
  display: inline-block;
  animation: spin 1s linear infinite;
}

.control-btn.state-queued::before { background: #d8a13a; }
.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, #d8a13a 30%, 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: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1rem;
  padding: .68rem .35rem;
  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 {
  color: var(--muted);
  justify-content: center;
  padding: 1.15rem;
  text-align: center;
}
.activity-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 550;
}
.activity-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .55rem .8rem;
  color: var(--faint);
  flex: 0 1 auto;
  min-width: 0;
}
.activity-meta time {
  font-family: var(--mono);
  font-size: .7rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* 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;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--bg-raised);
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm);
}
.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; }
.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 — mobile-first breakpoints 360 / 768 / 1280                     */
/* -------------------------------------------------------------------------- */
@media (max-width: 860px) {
  .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; }
  .gs-now { margin-top: 0; align-self: center; }
  .tier-pick { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .control-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body { font-size: 15px; }
}

@media (max-width: 640px) {
  .table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .who { display: none; }
  .cols-3,
  .cols-demos { grid-template-columns: minmax(0, 1fr); }
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .control-grid { grid-template-columns: minmax(0, 1fr); }
  .activity-list li {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .activity-meta {
    align-items: flex-end;
    flex-direction: column;
    gap: .2rem;
  }
  .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(.85rem, env(safe-area-inset-left));
    padding-right: max(.85rem, env(safe-area-inset-right));
  }
  .topbar .row {
    padding-left: max(.85rem, env(safe-area-inset-left));
    padding-right: max(.85rem, env(safe-area-inset-right));
    gap: .55rem;
  }
  .toast {
    left: .75rem;
    right: .75rem;
    max-width: none;
  }
  .gs-card {
    margin-bottom: 1.2rem;
    padding: 1rem .95rem;
  }
  .gs-step.is-current::before {
    top: .4rem;
    bottom: .4rem;
  }
}

/* Phone floor ~360 */
@media (max-width: 400px) {
  .tile { padding: 1rem .95rem; }
  .control-card { padding: .9rem; }
  .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: .75rem .8rem; }
  .brand { font-size: .98rem; }
  .auth .card { padding: 1.25rem 1.1rem; }
}

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

/* -------------------------------------------------------------------------- */
/* 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: .62rem .75rem;
  min-height: 2.5rem;
  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 + bottom nav */
.sidebar-toggle {
  display: none;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.sidebar-toggle svg { width: 1.1rem; height: 1.1rem; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 44;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.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));
  padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom));
  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: .3rem .2rem;
  min-width: 0;
  min-height: 2.5rem;
}
.mobile-nav a.is-active {
  color: var(--accent-hover);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.mobile-nav a svg {
  width: 1.15rem;
  height: 1.15rem;
}
.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;
}
.mobile-nav span.is-soon svg {
  width: 1.15rem;
  height: 1.15rem;
}

@media (max-width: 900px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform var(--dur-slow) var(--ease);
    box-shadow: var(--shadow);
  }
  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));
  }
  body.has-app-shell .toast { bottom: calc(var(--mobile-nav-h) + 1rem); }
}

/* -------------------------------------------------------------------------- */
/* 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);
}
.pipeline-track {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .7rem;
}
.pipe-step {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  min-width: 0;
  padding: 1rem .95rem 1.05rem;
  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);
}
.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));
}
.pipe-step.is-locked {
  opacity: .72;
}
.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: var(--bg-soft);
  color: var(--faint);
  border-color: var(--line);
}
.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(--faint);
}
.pipe-title {
  margin: 0;
  font-size: .95rem;
  font-weight: 650;
  letter-spacing: -.015em;
  line-height: 1.25;
}
.pipe-copy {
  margin: 0;
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.4;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}
.pipe-lock-reason {
  margin: 0;
  font-size: .72rem;
  color: var(--faint);
  font-style: normal;
  line-height: 1.35;
}
.pipe-action {
  margin-top: .15rem;
}
.pipe-action .btn,
.pipe-action .action-form .btn {
  width: 100%;
  justify-content: center;
}
.pipe-action .btn:disabled,
.pipe-action .action-form .btn:disabled {
  opacity: .55;
  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 */
}

.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; }

@media (max-width: 860px) {
  .pipeline-track { grid-template-columns: minmax(0, 1fr); }
  .how-grid,
  .pricing-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 641px) and (max-width: 1099px) {
  .pipeline-track { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pipe-step:last-child { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
  .landing-actions { flex-direction: column; align-items: stretch; }
  .landing-actions .btn { justify-content: center; }
}

/* -------------------------------------------------------------------------- */
/* Territory map picker                                                       */
/* -------------------------------------------------------------------------- */
.territory-page {
  /* Full-viewport feel without breaking topbar; map parent is explicitly sized. */
  min-height: calc(100vh - var(--nav-h));
  padding-bottom: 1.5rem;
}
.territory-shell {
  width: min(100%, var(--container));
  margin: 0 auto;
  padding: 1rem 1.25rem 0;
  display: grid;
  gap: .75rem;
}
.territory-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: .75rem 1rem;
  padding: .9rem 1rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.territory-brand h1 {
  margin: 0 0 .2rem;
  font-size: 1.25rem;
  letter-spacing: -.02em;
}
.territory-sub { margin: 0; font-size: .88rem; max-width: 36rem; }
.territory-cap {
  display: inline-block;
  margin-left: .35rem;
  padding: .1rem .45rem;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: .75rem;
  color: var(--muted);
  font-family: var(--mono);
}
.territory-modes {
  display: inline-flex;
  gap: .25rem;
  padding: .2rem;
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  border: 1px solid var(--line);
}
.mode-btn {
  border: 1px solid transparent;
  color: var(--muted);
  font-weight: 550;
}
.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: 650;
}
.mode-btn:not(.is-active):hover {
  background: var(--bg-hover);
  color: var(--ink);
}
.territory-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-left: auto;
  align-items: center;
}
.territory-status {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem .75rem;
  border-radius: var(--r-md);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: .88rem;
  color: var(--muted);
}
.territory-status .status-dot {
  width: .55rem;
  height: .55rem;
  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: .78rem;
  color: var(--ink);
}
.territory-status .status-meta.is-over { color: var(--danger); }

/* Explicit height on frame — MapLibre needs a real box, not only absolute inset. */
.territory-map-frame {
  position: relative;
  width: 100%;
  height: 28rem;
  min-height: 22rem;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--bg-soft);
  box-shadow: var(--shadow);
}
.territory-map {
  width: 100%;
  height: 100%;
}
.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;
}
.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;
}
.territory-overlay .btn { margin-top: .75rem; }

/* Compact dismissible instruction card — map corner overlay */
.territory-howto {
  position: absolute;
  top: .75rem;
  left: .75rem;
  z-index: 3;
  max-width: min(18rem, calc(100% - 5.5rem));
  padding: .65rem .75rem .7rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.territory-howto-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .2rem;
}
.territory-howto-kicker {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--accent-violet, #8B5CF6);
  font-weight: 600;
}
.territory-howto-dismiss {
  min-width: 2rem;
  min-height: 2rem;
  padding: 0 .35rem;
  line-height: 1;
  font-size: 1.1rem;
  color: var(--muted);
}
.territory-howto-body {
  margin: 0;
  font-size: .84rem;
  line-height: 1.4;
  color: var(--ink);
}

.territory-side {
  display: grid;
  gap: .5rem;
  padding: .15rem 0 .5rem;
}
.territory-hint {
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.45;
  padding: .65rem .8rem;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.territory-hint strong { color: var(--ink); font-weight: 650; }
.territory-selected {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.territory-selected li,
.territory-chip {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .35rem .45rem .35rem .7rem;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-raised));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  font-size: .84rem;
  color: var(--ink);
}
.territory-chip-name {
  font-weight: 550;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.territory-chip-remove {
  min-height: 1.85rem;
  padding: .15rem .45rem;
  font-size: .75rem;
}
/* MapLibre attribution / controls blend with portal tokens */
.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: 2.5rem;
  min-height: 2.5rem;
}
.territory-map-frame .maplibregl-ctrl-group button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.territory-actions .btn,
.territory-modes .btn {
  min-height: 2.5rem;
}
.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); }

@media (max-width: 720px) {
  .territory-toolbar { flex-direction: column; align-items: stretch; }
  .territory-actions { margin-left: 0; }
  .territory-map-frame { height: 20rem; min-height: 18rem; }
}

/* -------------------------------------------------------------------------- */
/* 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);
}
@media (max-width: 900px) {
  .billing-grid { grid-template-columns: 1fr; }
  .gs-step {
    grid-template-columns: auto 1fr;
  }
  .gs-step .btn,
  .gs-step form {
    grid-column: 2;
    justify-self: start;
  }
  .gs-step .chip {
    grid-column: 2;
  }
}
