/* ======================================================================
   Mediahax design system — one file, no build step, no CDN.
   Dark-first token system; [data-theme="light"] flips the surfaces.
   Reference class: Linear / Vercel / Attio (hairline borders, elevation
   ladder, one accent, tabular numbers). See docs/design-notes.md.
   ====================================================================== */

@font-face {
  font-family: "Inter";
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;

  /* Surfaces: page + 3 elevations */
  --bg-0: #0e0f11;
  --bg-1: #16181c;
  --bg-2: #1e2126;
  --bg-3: #262a31;

  /* Hairlines */
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .14);
  --edge-highlight: inset 0 1px 0 rgba(255, 255, 255, .04);

  /* Text */
  --text-1: #f0f2f5;
  --text-2: #b4bcc8;
  --text-3: #8b93a1;

  /* Accent */
  --accent: #5e6ad2;
  --accent-hover: #6c78e0;
  --accent-text: #a5acff;
  --accent-muted: rgba(94, 106, 210, .16);

  /* Status */
  --success: #3fb950;  --success-bg: rgba(63, 185, 80, .12);
  --warning: #d29922;  --warning-bg: rgba(210, 153, 34, .12);
  --danger:  #f85149;  --danger-bg:  rgba(248, 81, 73, .12);

  /* Chart categorical — fixed assignment order, CVD-validated on --bg-1 */
  --chart-1: #3987e5;
  --chart-2: #199e70;
  --chart-3: #c98500;
  --chart-4: #9085e9;
  --chart-5: #e66767;
  --chart-6: #008300;
  --grid-line: #2c2c2e;

  /* Type */
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", monospace;
  --text-xs: .6875rem;
  --text-sm: .8125rem;
  --text-md: .875rem;
  --text-lg: 1rem;
  --text-xl: clamp(1.125rem, 1rem + .5vw, 1.375rem);
  --text-kpi: clamp(1.375rem, 1.1rem + 1vw, 1.75rem);

  /* Space (4px grid) & radii */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-full: 999px;

  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .4), 0 0 0 1px var(--border);
  --ease: cubic-bezier(.25, .46, .45, .94);

  /* Page glow (dark only; zeroed in light) */
  --shell-glow: radial-gradient(80rem 40rem at 70% -10%, rgba(94, 106, 210, .07), transparent);
}

[data-theme="light"] {
  color-scheme: light;
  --bg-0: #fafafa;
  --bg-1: #ffffff;
  --bg-2: #f4f4f5;
  --bg-3: #ececee;
  --border: rgba(0, 0, 0, .09);
  --border-strong: rgba(0, 0, 0, .16);
  --edge-highlight: none;
  --text-1: #111318;
  --text-2: #4b5261;
  --text-3: #6e7686;
  --accent-text: #4a3aa7;
  --success: #1a7f37;
  --warning: #9a6700;
  --danger:  #cf222e;
  --chart-1: #2a78d6;
  --chart-2: #1baf7a;
  --chart-3: #eda100;
  --chart-4: #4a3aa7;
  --chart-5: #e34948;
  --chart-6: #008300;
  --grid-line: #e4e4e7;
  --shadow-pop: 0 8px 24px rgba(0, 0, 0, .12), 0 0 0 1px var(--border);
  --shell-glow: none;
}

/* ---------------------------------------------------------------- reset */
*, ::before, ::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--shell-glow), var(--bg-0);
  color: var(--text-1);
  font: var(--text-md)/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: .78em var(--font-mono); background: var(--bg-2); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: rgba(94, 106, 210, .35); }
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation: none !important; transition: none !important; }
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100%; }
/* Mobile: the sidebar becomes a horizontal, scrollable nav strip.
   (aside.sidebar out-specifies the base .sidebar rule declared further down.) */
@media (max-width: 768px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  aside.sidebar {
    flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden;
    border-right: none; border-bottom: 1px solid var(--border);
    padding: var(--sp-2) var(--sp-3); gap: var(--sp-1);
  }
  aside.sidebar .sidebar-logo { padding: 0 var(--sp-2) 0 0; }
  aside.sidebar .logo-name, aside.sidebar .logo-tag,
  aside.sidebar .nav-group-label, aside.sidebar .sidebar-foot { display: none; }
  aside.sidebar .nav-group { margin: 0; display: flex; gap: var(--sp-1); flex: none; }
  aside.sidebar .nav-item { white-space: nowrap; }
}

.sidebar {
  display: flex; flex-direction: column;
  background: var(--bg-0);
  border-right: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-3);
  overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: var(--sp-1) var(--sp-2) var(--sp-5);
}
.logo-mark {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), #8a5ed2);
  color: #fff; font-weight: 700; font-size: 14px;
  display: grid; place-items: center;
}
.logo-mark-img { width: 30px; height: 30px; flex: none; display: block; }
.logo-name { font-weight: 600; font-size: var(--text-md); letter-spacing: -.01em; }
.logo-tag {
  margin-left: auto; font: 500 10px/1.6 var(--font-mono); text-transform: uppercase;
  color: var(--accent-text); background: var(--accent-muted);
  padding: 0 6px; border-radius: 4px;
}

.nav-group { margin-top: var(--sp-5); }
.nav-group:first-of-type { margin-top: 0; }
.nav-group-label {
  font-size: var(--text-xs); font-weight: 500; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3);
  padding: 0 var(--sp-2) var(--sp-2);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 var(--sp-2); border-radius: var(--r-sm);
  color: var(--text-2); font-size: var(--text-sm); font-weight: 500;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.nav-item:hover { background: var(--bg-2); color: var(--text-1); text-decoration: none; }
.nav-item.active { background: var(--accent-muted); color: var(--text-1); }
.nav-icon { width: 18px; text-align: center; font-size: 14px; flex: none; }
.nav-item .dot { margin-left: auto; }

.sidebar-foot {
  margin-top: auto; padding-top: var(--sp-5);
  font-size: var(--text-xs); color: var(--text-3);
}

/* --------------------------------------------------------------- topbar */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  display: flex; align-items: center; gap: var(--sp-4);
  height: 56px; padding: 0 var(--sp-6); flex: none;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-0) 82%, transparent);
  backdrop-filter: blur(12px);
  position: relative; z-index: 10;
}
.page-title { font-size: var(--text-lg); font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.page-sub { font-size: var(--text-xs); color: var(--text-3); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--sp-3); }
.client-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: var(--r-full);
}
.avatar {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #d2691e, #a0341f);
  color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}
.client-chip b { font-size: var(--text-sm); font-weight: 600; }
.client-chip span { font-size: var(--text-xs); color: var(--text-3); }

.icon-btn {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  border: none; background: transparent; color: var(--text-2); cursor: pointer;
  display: grid; place-items: center;
  transition: background .12s var(--ease), color .12s var(--ease);
}
.icon-btn:hover { background: var(--bg-2); color: var(--text-1); }
.icon-btn svg { width: 16px; height: 16px; }
[data-theme="light"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: none; }
.icon-moon { display: none; }
.icon-sun { display: block; }

.content { flex: 1; overflow-y: auto; padding: var(--sp-6); scrollbar-gutter: stable; }
.content::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 8px; border: 3px solid var(--bg-0); }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--edge-highlight);
  padding: var(--sp-5);
}
.card-title {
  font-size: var(--text-md); font-weight: 600; letter-spacing: -.01em;
  display: flex; align-items: center; gap: var(--sp-2);
}
.card-sub { font-size: var(--text-xs); color: var(--text-3); margin-top: 2px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); }

/* KPI tile */
.kpi-label {
  font-size: var(--text-xs); font-weight: 500; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-3);
}
.kpi-value { font-size: var(--text-kpi); font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-row { display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.spark { width: 100%; height: 32px; margin-top: var(--sp-3); display: block; }

/* Delta badge — class set server-side from DESIRABILITY, not sign */
.delta {
  font: 500 var(--text-xs)/1 var(--font-mono);
  padding: 3px 7px; border-radius: var(--r-full); white-space: nowrap;
}
.delta.up   { color: var(--success); background: var(--success-bg); }
.delta.down { color: var(--danger);  background: var(--danger-bg); }
.delta.flat { color: var(--text-3);  background: var(--bg-2); }

/* Inner tile (recessed stat inside a card) */
.tile {
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: var(--sp-3);
}
.tile-value { font-size: var(--text-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.tile-label { font-size: var(--text-xs); color: var(--text-3); }

/* --------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--r-full);
  font: 500 var(--text-xs)/1.5 var(--font-ui);
  border: 1px solid var(--border); color: var(--text-2);
  white-space: nowrap;
}
.badge.ok    { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); background: var(--success-bg); }
.badge.warn  { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); background: var(--warning-bg); }
.badge.err   { color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 35%, transparent);  background: var(--danger-bg); }
.badge.brand { color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-muted); }

.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--text-3); }
.dot.ok { background: var(--success); }
.dot.warn { background: var(--warning); }
.dot.err { background: var(--danger); }
.dot.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }

/* -------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 var(--sp-3);
  font: 500 var(--text-sm)/1 var(--font-ui);
  border-radius: var(--r-sm); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-2); border-color: var(--border-strong); color: var(--text-1); }
.btn-secondary:hover { background: var(--bg-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text-1); }
.btn-sm { height: 26px; padding: 0 10px; font-size: var(--text-xs); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------------- forms */
label { font-size: var(--text-xs); font-weight: 500; color: var(--text-2); display: block; margin-bottom: 4px; }
.input, select.input {
  height: 32px; padding: 0 10px;
  background: var(--bg-0);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  color: var(--text-1); font: var(--text-sm) var(--font-ui);
}
.input::placeholder { color: var(--text-3); }
.input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-muted); }

/* --------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg-1); color: var(--text-3);
  font-size: var(--text-xs); font-weight: 500;
  text-transform: uppercase; letter-spacing: .05em; text-align: left;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 10px var(--sp-3); border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.center, th.center { text-align: center; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.tnum { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ bar meter */
.meter { height: 8px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--chart-1); border-radius: 2px; }
.meter.thin { height: 5px; }

/* -------------------------------------------------------- sample overlay */
.is-sample .sample-dim { opacity: .5; filter: saturate(.5); }
.sample-note { font-size: var(--text-xs); color: var(--text-3); margin-top: var(--sp-3); }

/* ------------------------------------------------------------- skeleton */
.skeleton { border-radius: var(--r-sm); background: var(--bg-2); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .05), transparent);
  animation: shimmer 1.6s infinite;
}
@keyframes shimmer { from { translate: -100% 0; } to { translate: 100% 0; } }

/* --------------------------------------------------------------- charts */
.chart-svg { display: block; width: 100%; height: auto; }
.axis-label { font: 400 10px var(--font-ui); fill: var(--text-3); }
.legend { display: flex; gap: var(--sp-4); font-size: var(--text-xs); color: var(--text-2); flex-wrap: wrap; }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ----------------------------------------------------------------- HTMX */
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-request.dim-while-loading { opacity: .6; }
::view-transition-old(*), ::view-transition-new(*) { animation-duration: .18s; }

/* ============================================================ AGENT DECK */
/* UI-only hero for the master agent at the top of Overview. Facade — no chat
   backend. Center-aligned; pure-CSS animation; motion killed under
   prefers-reduced-motion. */
.deck {
  position: relative; overflow: hidden; text-align: center;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: var(--sp-8) var(--sp-6) var(--sp-6);
  margin-bottom: var(--sp-6);
  background:
    radial-gradient(50rem 22rem at 50% -30%, rgba(94, 106, 210, .22), transparent 60%),
    radial-gradient(36rem 18rem at 15% 130%, rgba(63, 198, 224, .10), transparent 55%),
    radial-gradient(36rem 18rem at 85% 130%, rgba(138, 94, 210, .12), transparent 55%),
    var(--bg-1);
  box-shadow: var(--edge-highlight);
}
/* Ambient gradient sheen drifting across the band. */
.deck::before {
  content: ""; position: absolute; inset: -1px; z-index: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 34%, rgba(120, 130, 240, .08) 50%, transparent 66%);
  background-size: 240% 100%;
  animation: deck-sheen 9s linear infinite;
}
[data-theme="light"] .deck {
  background:
    radial-gradient(50rem 22rem at 50% -30%, rgba(94, 106, 210, .14), transparent 60%),
    radial-gradient(36rem 18rem at 15% 130%, rgba(63, 198, 224, .07), transparent 55%),
    radial-gradient(36rem 18rem at 85% 130%, rgba(138, 94, 210, .08), transparent 55%),
    var(--bg-1);
}
@keyframes deck-sheen { from { background-position: 120% 0; } to { background-position: -120% 0; } }

.deck-top { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; }

/* --- Orb: dual counter-rotating conic rings + orbiting particle +
       breathing glow + pulsing core. ~92px. --- */
.orb { position: relative; width: 92px; height: 92px; flex: none; margin-bottom: var(--sp-4); }
.orb::before {  /* breathing glow */
  content: ""; position: absolute; inset: -16px; border-radius: 50%;
  background: radial-gradient(circle, rgba(94, 106, 210, .6), rgba(138, 94, 210, .25) 45%, transparent 72%);
  filter: blur(10px); animation: orb-breathe 4s ease-in-out infinite;
}
.orb-ring, .orb-ring2 {
  position: absolute; border-radius: 50%;
  -webkit-mask: radial-gradient(circle, transparent 57%, #000 60%);
          mask: radial-gradient(circle, transparent 57%, #000 60%);
}
.orb-ring {
  inset: 0;
  background: conic-gradient(from 0deg, #5e6ad2, #8a5ed2, #3fc6e0, #5e6ad2);
  animation: orb-spin 7s linear infinite;
}
.orb-ring2 {  /* thinner, counter-rotating, offset hues */
  inset: 6px;
  background: conic-gradient(from 120deg, transparent, #3fc6e0 30%, transparent 60%, #8a5ed2 85%, transparent);
  -webkit-mask: radial-gradient(circle, transparent 66%, #000 69%, #000 82%, transparent 85%);
          mask: radial-gradient(circle, transparent 66%, #000 69%, #000 82%, transparent 85%);
  animation: orb-spin-rev 11s linear infinite;
}
.orb-core {
  position: absolute; inset: 13px; border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #2a2f3f, #0d0e13);
  display: grid; place-items: center;
  color: #d6ddff; font-size: 26px; line-height: 1;
  box-shadow: inset 0 0 18px rgba(94, 106, 210, .4);
  animation: orb-core-pulse 4s ease-in-out infinite;
}
/* Orbiting particle: a dot carried on a spinning track. */
.orb-orbit {
  position: absolute; inset: -2px; border-radius: 50%;
  animation: orb-spin 5.5s linear infinite;
}
.orb-orbit::after {
  content: ""; position: absolute; top: -3px; left: 50%; translate: -50% 0;
  width: 7px; height: 7px; border-radius: 50%;
  background: #7be3f5; box-shadow: 0 0 10px 2px rgba(123, 227, 245, .8);
}
@keyframes orb-spin { to { transform: rotate(360deg); } }
@keyframes orb-spin-rev { to { transform: rotate(-360deg); } }
@keyframes orb-breathe { 0%, 100% { opacity: .5; transform: scale(1); } 50% { opacity: .95; transform: scale(1.12); } }
@keyframes orb-core-pulse { 0%, 100% { box-shadow: inset 0 0 14px rgba(94,106,210,.35); } 50% { box-shadow: inset 0 0 22px rgba(123,150,255,.6); } }

.deck-title {
  font-size: clamp(1.25rem, 1rem + 1vw, 1.6rem); font-weight: 700; letter-spacing: -.025em;
  background: linear-gradient(90deg, var(--text-1) 30%, #a9b2ff 90%, #7be3f5);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: inline-flex; align-items: center; gap: var(--sp-2);
}
.deck-sub { font-size: var(--text-md); color: var(--text-2); margin-top: 4px; }
.deck-badge {
  font: 600 10px/1 var(--font-mono); text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent-text); background: var(--accent-muted);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  padding: 3px 7px; border-radius: var(--r-full); vertical-align: middle;
}

/* --- Glass input bar with gradient border (centered, max-width) --- */
.deck-bar {
  position: relative; z-index: 1; margin: var(--sp-6) auto 0; max-width: 620px;
  display: flex; align-items: center; gap: var(--sp-3);
  border-radius: 14px; padding: 2px;   /* padding hosts the gradient border */
  background: linear-gradient(90deg, rgba(94, 106, 210, .55), rgba(138, 94, 210, .35), rgba(63, 198, 224, .45));
  transition: box-shadow .2s var(--ease);
}
.deck-bar:focus-within { box-shadow: 0 0 0 3px var(--accent-muted); }
.deck-bar-inner {
  flex: 1; display: flex; align-items: center; gap: var(--sp-3);
  background: var(--bg-0); border-radius: 12px; padding: 0 var(--sp-3);
  height: 54px;
}
.deck-input {
  flex: 1; height: 100%; border: 0; background: transparent; outline: none;
  color: var(--text-1); font: var(--text-md) var(--font-ui); text-align: left;
}
.deck-input::placeholder { color: var(--text-3); }
.deck-kbd {
  font: 500 var(--text-xs)/1 var(--font-mono); color: var(--text-3);
  border: 1px solid var(--border-strong); border-radius: 5px; padding: 3px 6px; flex: none;
}
.deck-send {
  flex: none; width: 42px; height: 42px; margin-right: 3px; border-radius: 10px;
  display: grid; place-items: center; text-decoration: none;
  background: linear-gradient(135deg, var(--accent), #8a5ed2);
  color: #fff; font-size: 18px; font-weight: 700;
  transition: filter .15s var(--ease), transform .15s var(--ease);
}
.deck-send:hover { filter: brightness(1.12); transform: translateY(-1px); text-decoration: none; }

/* --- Suggestion chips (centered) --- */
.deck-chips {
  position: relative; z-index: 1; margin-top: var(--sp-4);
  display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center;
}
.deck-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-sm); color: var(--text-2); text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 6px 12px; background: color-mix(in srgb, var(--bg-2) 60%, transparent);
  transition: border-color .15s var(--ease), color .15s var(--ease), background .15s var(--ease);
}
.deck-chip:hover {
  color: var(--text-1); text-decoration: none;
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: var(--accent-muted);
}
.deck-chip .g { color: var(--accent-text); }

/* --- Live status microline (centered) --- */
.deck-status {
  position: relative; z-index: 1; margin-top: var(--sp-5);
  display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
  font-size: var(--text-xs); color: var(--text-3);
}
.deck-status .sep { opacity: .4; }

@media (max-width: 720px) {
  .deck-kbd { display: none; }
  .deck-status { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
  .deck::before, .orb-ring, .orb-ring2, .orb-orbit, .orb::before, .orb-core { animation: none; }
}

/* ========================================================= CREATIVE STUDIO */
/* Visual creation console + creative gallery. Warm, vibrant (distinct from the
   cool agent deck). The chat thread is an illustrative facade; the input bar is
   wired to the real generation engine. */
.cstudio {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: 16px;
  padding: var(--sp-6); margin-bottom: var(--sp-6);
  background:
    radial-gradient(46rem 20rem at 8% -30%, rgba(244, 63, 94, .16), transparent 60%),
    radial-gradient(40rem 20rem at 100% 130%, rgba(168, 85, 247, .16), transparent 58%),
    radial-gradient(30rem 16rem at 55% 120%, rgba(251, 146, 60, .12), transparent 60%),
    var(--bg-1);
  box-shadow: var(--edge-highlight);
}
[data-theme="light"] .cstudio {
  background:
    radial-gradient(46rem 20rem at 8% -30%, rgba(244, 63, 94, .10), transparent 60%),
    radial-gradient(40rem 20rem at 100% 130%, rgba(168, 85, 247, .10), transparent 58%),
    var(--bg-1);
}
.cstudio-head { display: flex; align-items: center; gap: var(--sp-3); position: relative; z-index: 1; }
.cstudio-mark {
  width: 46px; height: 46px; flex: none; border-radius: 13px;
  background: linear-gradient(135deg, #f43f5e, #a855f7 55%, #fb923c);
  display: grid; place-items: center; color: #fff; font-size: 22px;
  box-shadow: 0 6px 18px -6px rgba(168, 85, 247, .6);
}
.cstudio-title {
  font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em;
  background: linear-gradient(90deg, var(--text-1), #ff9ec4 130%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.cstudio-sub { font-size: var(--text-sm); color: var(--text-2); margin-top: 1px; }
.cstudio-tag {
  margin-left: auto; font: 500 var(--text-xs)/1 var(--font-ui); color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--r-full); padding: 6px 11px;
  background: color-mix(in srgb, var(--bg-2) 60%, transparent); white-space: nowrap;
}
.cstudio-tag b { color: var(--accent-text); }

/* --- chat thread (facade) --- */
.cchat { position: relative; z-index: 1; margin-top: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.cmsg { max-width: 88%; font-size: var(--text-sm); line-height: 1.5; border-radius: 14px; padding: 10px 14px; }
.cmsg.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), #8a5ed2); color: #fff; border-bottom-right-radius: 5px; }
.cmsg.ai { align-self: flex-start; background: var(--bg-2); border: 1px solid var(--border); color: var(--text-1); border-bottom-left-radius: 5px; }
.cmsg .who { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-3); margin-bottom: 5px; }
.cmsg .who .dot { background: var(--success); }
.cthumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.cthumb {
  width: 62px; aspect-ratio: 9/16; border-radius: 8px; position: relative;
  display: grid; place-items: center; font-size: 20px; color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
}
.cthumb::after { content: "▶"; position: absolute; font-size: 9px; color: #fff;
  background: rgba(0,0,0,.45); width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; }

/* --- input bar + format pills (wired to the engine) --- */
.cconsole { position: relative; z-index: 1; margin-top: var(--sp-5); }
.cformats { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.cformats input { position: absolute; opacity: 0; pointer-events: none; }
.cformat {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: var(--text-sm); color: var(--text-2);
  border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 6px 13px; background: color-mix(in srgb, var(--bg-2) 55%, transparent);
  transition: all .14s var(--ease); user-select: none;
}
.cformat:hover { color: var(--text-1); border-color: var(--border-strong); }
.cformats input:checked + .cformat {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, #f43f5e, #a855f7);
  box-shadow: 0 4px 14px -6px rgba(168, 85, 247, .7);
}
.cbar {
  display: flex; align-items: center; gap: var(--sp-3);
  border-radius: 14px; padding: 2px;
  background: linear-gradient(90deg, rgba(244,63,94,.5), rgba(168,85,247,.4), rgba(251,146,60,.45));
  transition: box-shadow .2s var(--ease);
}
.cbar:focus-within { box-shadow: 0 0 0 3px rgba(168, 85, 247, .22); }
.cbar-inner {
  flex: 1; display: flex; align-items: center; gap: var(--sp-3);
  background: var(--bg-0); border-radius: 12px; padding: 0 var(--sp-3); height: 54px;
}
.cbar-inner input[type=text] {
  flex: 1; height: 100%; border: 0; background: transparent; outline: none;
  color: var(--text-1); font: var(--text-md) var(--font-ui);
}
.cbar-inner input::placeholder { color: var(--text-3); }
.cbar select.input { border: 0; background: transparent; color: var(--text-2); max-width: 12rem; }
.cbar-send {
  flex: none; height: 44px; margin-right: 4px; padding: 0 18px; border: 0; border-radius: 10px;
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  background: linear-gradient(135deg, #f43f5e, #a855f7); color: #fff;
  font: 600 var(--text-sm) var(--font-ui);
  transition: filter .15s var(--ease), transform .15s var(--ease);
}
.cbar-send:hover { filter: brightness(1.1); transform: translateY(-1px); }
.cconsole-note { font-size: var(--text-xs); color: var(--text-3); margin-top: var(--sp-3); }

/* --- creative gallery --- */
.creative-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--sp-4);
}
.creative-card {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--edge-highlight); transition: transform .16s var(--ease), border-color .16s var(--ease);
}
.creative-card:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.cframe {
  position: relative; display: grid; place-items: center; overflow: hidden;
}
.cframe .glyph { font-size: 54px; filter: drop-shadow(0 4px 10px rgba(0,0,0,.35)); }
.cframe .cfmt {
  position: absolute; top: 8px; left: 8px; font: 600 var(--text-xs)/1 var(--font-ui);
  color: #fff; background: rgba(0,0,0,.42); backdrop-filter: blur(4px);
  padding: 4px 8px; border-radius: var(--r-full); display: inline-flex; gap: 5px; align-items: center;
}
.cframe .cdur {
  position: absolute; bottom: 8px; right: 8px; font: 600 var(--text-xs)/1 var(--font-mono);
  color: #fff; background: rgba(0,0,0,.5); padding: 4px 7px; border-radius: 6px;
}
.cplay {
  position: absolute; width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,.9); color: #111; display: grid; place-items: center;
  font-size: 16px; padding-left: 3px; box-shadow: 0 6px 18px rgba(0,0,0,.35);
  transition: transform .16s var(--ease);
}
.creative-card:hover .cplay { transform: scale(1.08); }
.creative-body { padding: 12px 14px; display: flex; flex-direction: column; flex: 1; }
.creative-body .t { font-size: var(--text-sm); font-weight: 600; letter-spacing: -.01em; }
.creative-body .a { font-size: var(--text-xs); color: var(--text-3); margin-top: 3px; }
.creative-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: var(--sp-3); }

/* generating shimmer card */
.creative-card.gen .cframe { aspect-ratio: 9/16; background: var(--bg-2); }
.creative-card.gen .cframe::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(168,85,247,.18), transparent);
  animation: shimmer 1.4s infinite;
}
.creative-card.gen .genlabel {
  position: absolute; z-index: 1; font: 600 var(--text-xs) var(--font-ui); color: var(--text-1);
  display: inline-flex; align-items: center; gap: 7px;
}
.creative-card.gen .genlabel .sp {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--accent); border-right-color: transparent;
  animation: orb-spin .8s linear infinite;
}
@media (prefers-reduced-motion: reduce) {
  .creative-card.gen .cframe::after, .creative-card.gen .genlabel .sp { animation: none; }
}

/* carousel stack indicator */
.cframe .cstack {
  position: absolute; bottom: 8px; right: 8px; font: 600 var(--text-xs)/1 var(--font-ui);
  color: #fff; background: rgba(0,0,0,.45); padding: 4px 7px; border-radius: 6px;
}

/* ad-copy card — text preview */
.ccopy { position: relative; padding: 32px 16px 16px; display: flex; flex-direction: column; gap: 8px; min-height: 210px; }
.cfmt.light { color: var(--text-1); background: var(--bg-2); }
.ccopy .cfmt { position: absolute; top: 8px; left: 8px; }
.ccopy-h { font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.ccopy-b { font-size: var(--text-sm); color: var(--text-2); line-height: 1.5; }
.ccopy-cta { margin-top: auto; font-size: var(--text-sm); font-weight: 600; color: var(--accent-text); }

/* landing-page card — mini page mock */
.clp { position: relative; padding: 32px 12px 12px; display: flex; flex-direction: column; gap: 9px; }
.clp .cfmt { position: absolute; top: 8px; left: 8px; z-index: 1; }
.clp-hero { border-radius: 9px; padding: 16px 12px; display: grid; place-items: center; min-height: 84px; }
.clp-h { color: #fff; font-weight: 700; font-size: var(--text-sm); text-align: center; line-height: 1.3; text-shadow: 0 1px 4px rgba(0,0,0,.3); }
.clp-rows { display: flex; flex-direction: column; gap: 5px; }
.clp-rows i { height: 6px; border-radius: 3px; background: var(--bg-3); }
.clp-rows i:first-child { width: 85%; } .clp-rows i:nth-child(2) { width: 95%; }
.clp-buy { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.clp-price { font-weight: 700; }
.clp-btn { font-size: var(--text-xs); font-weight: 600; color: #fff; background: var(--accent); padding: 5px 10px; border-radius: 6px; }

/* ============================================================== LIFECYCLE */
.flow-steps { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.flow-step {
  font-size: var(--text-xs); color: var(--text-1);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 4px 10px; white-space: nowrap;
}
.flow-step.wait { color: var(--text-3); background: transparent; border-style: dashed; }
.flow-arrow { color: var(--text-3); font-size: var(--text-xs); }

/* =========================================================== GUIDED HOME */
/* The agent-led workspace: greet → analyze → plain-language next actions with
   inline results. Left-aligned reading column (like every other screen). */
.home { max-width: 860px; }

/* Agent greeting / hero */
.agent-hero {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-5); border: 1px solid var(--border); border-radius: 16px;
  margin-bottom: var(--sp-5);
  background:
    radial-gradient(44rem 18rem at 0% -50%, rgba(94, 106, 210, .18), transparent 62%),
    var(--bg-1);
  box-shadow: var(--edge-highlight);
}
.agent-hero .orb { width: 56px; height: 56px; flex: none; margin: 0; }
.agent-hero-text { flex: 1; }
.agent-said { font-size: 1.05rem; line-height: 1.5; color: var(--text-1); letter-spacing: -.01em; }
.agent-said b { color: var(--text-1); }
.agent-sub { font-size: var(--text-sm); color: var(--text-3); margin-top: 4px; }

/* Plain summary after analysis — quiet, not a heavy block */
.plan-summary {
  font-size: 1.02rem; line-height: 1.6; color: var(--text-2);
  padding: 2px 2px var(--sp-2); margin-bottom: var(--sp-2);
}
.plan-summary b { color: var(--text-1); }

.plan-heading { font-size: var(--text-xs); font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .08em; margin: var(--sp-5) 0 var(--sp-3); }

/* One recommendation — a tidy horizontal row: icon | text | action on the right */
.reco {
  border: 1px solid var(--border); border-radius: 12px; padding: var(--sp-4);
  margin-bottom: var(--sp-3); background: var(--bg-1); box-shadow: var(--edge-highlight);
  display: flex; align-items: center; gap: var(--sp-4);
  transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.reco:hover { border-color: var(--border-strong); }
.reco.primary {
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background:
    radial-gradient(36rem 12rem at 100% -80%, rgba(94, 106, 210, .14), transparent 70%),
    var(--bg-1);
}
.reco-icon {
  width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(140deg, var(--accent), #8a5ed2);
  box-shadow: 0 4px 12px -5px rgba(94, 106, 210, .7);
}
.reco-icon svg { width: 22px; height: 22px; }
.reco-main { flex: 1; min-width: 0; }
.reco-eyebrow { font-size: var(--text-xs); font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--accent-text); margin-bottom: 3px; }
.reco-title { font-size: 1.02rem; font-weight: 600; letter-spacing: -.01em; }
.reco-why { font-size: var(--text-sm); color: var(--text-2); margin-top: 3px; line-height: 1.5; }
.reco-cta { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.reco-cta .later { font-size: var(--text-xs); color: var(--text-3); background: none; border: 0;
  cursor: pointer; padding: 2px 4px; }
.reco-cta .later:hover { color: var(--text-2); }
@media (max-width: 640px) {
  .reco { flex-wrap: wrap; }
  .reco-cta { flex-direction: row; width: 100%; justify-content: flex-start; }
}

/* Recommendation — done/result state (stacks) */
.reco.done { flex-direction: column; align-items: stretch; gap: 0;
  border-color: color-mix(in srgb, var(--success) 32%, transparent);
  background: radial-gradient(36rem 12rem at 100% -80%, rgba(63, 185, 80, .08), transparent 70%), var(--bg-1); }
.reco-done-head { display: flex; align-items: center; gap: var(--sp-2); }
.reco-done-head .check { width: 24px; height: 24px; flex: none; border-radius: 50%;
  background: var(--success); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.reco-done-said { font-size: var(--text-md); color: var(--text-1); font-weight: 500; }
.reco-result { margin-top: var(--sp-4); }
.reco-copy { background: var(--bg-0); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; font-size: var(--text-sm); color: var(--text-2); white-space: pre-wrap;
  line-height: 1.55; max-height: 12rem; overflow: auto; }

/* Inline landing-page preview strip */
.lp-strip { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  background: var(--bg-0); border: 1px solid var(--border); border-radius: 10px; padding: var(--sp-3); }
.lp-thumb { width: 48px; height: 60px; flex: none; border-radius: 6px;
  background: linear-gradient(150deg, #b5301c, #7a1f12); display: grid; place-items: center;
  color: #fff; font-size: 20px; }
.lp-strip .grow { flex: 1; min-width: 0; }
.publish-status { font-size: var(--text-sm); }

/* Insights (collapsed "what I learned") */
.insights-box { border: 1px solid var(--border); border-radius: 12px; background: var(--bg-1);
  padding: var(--sp-4); box-shadow: var(--edge-highlight); }
.insights-box summary { cursor: pointer; font-weight: 600; font-size: var(--text-md);
  list-style: none; display: flex; align-items: center; gap: var(--sp-2); color: var(--text-2); }
.insights-box summary::-webkit-details-marker { display: none; }
.insights-box summary::before { content: "▸"; color: var(--text-3); transition: transform .15s; }
.insights-box[open] summary::before { transform: rotate(90deg); }
.insight-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.insight-item:last-child { border-bottom: none; }
.insight-item .t { font-weight: 600; font-size: var(--text-sm); }
.insight-item .w { font-size: var(--text-sm); color: var(--text-2); margin-top: 2px; }

/* the quiet "watching your ads" nudge + library link */
.home-nudge { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 12px; padding: var(--sp-3) var(--sp-4);
  margin-top: var(--sp-4); font-size: var(--text-sm); color: var(--text-2);
  background: color-mix(in srgb, var(--bg-2) 50%, transparent); }
.home-nudge .ml-auto { margin-left: auto; }

/* ------------------------------------------------------------- hint (?) */
/* Discreet hover explainer next to section titles. Pure CSS, no JS. */
.hint {
  position: relative; display: inline-grid; place-items: center;
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 1px solid var(--border-strong); color: var(--text-3);
  font: 600 10px/1 var(--font-ui); cursor: help; user-select: none;
}
.hint:hover { color: var(--text-1); border-color: var(--accent); }
.hint::after {
  content: attr(data-tip);
  /* Anchored to the icon's left edge — titles sit at the left of their card, so a
     centered bubble would clip outside the content area. */
  position: absolute; top: calc(100% + 8px); left: -6px;
  width: max-content; max-width: 280px;
  background: var(--bg-3); color: var(--text-1);
  font: 400 var(--text-xs)/1.55 var(--font-ui);
  text-transform: none; letter-spacing: 0; text-align: left; white-space: normal;
  padding: 8px 11px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none; transition: opacity .12s var(--ease);
  z-index: 60;
}
.hint:hover::after, .hint:focus-visible::after { opacity: 1; }
/* Icons sitting near the right edge: flip the bubble so it never clips. */
.hint.tip-left::after { left: auto; right: -6px; translate: 0 0; }

/* -------------------------------------------------- utility (kept tiny) */
.flex { display: flex; } .items-center { align-items: center; } .items-end { align-items: flex-end; }
.items-baseline { align-items: baseline; } .justify-between { justify-content: space-between; }
.wrap { flex-wrap: wrap; } .flex-1 { flex: 1; } .ml-auto { margin-left: auto; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-6 { gap: var(--sp-6); }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); }
.grid { display: grid; gap: var(--sp-4); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-kpi { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.cols-cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 1100px) {
  .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: span 1; }
}
@media (max-width: 640px) {
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .content { padding: var(--sp-4); }
}
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.small { font-size: var(--text-sm); } .tiny { font-size: var(--text-xs); }
.strong { font-weight: 600; }
.good { color: var(--success); } .bad { color: var(--danger); } .warn-text { color: var(--warning); }
.section-title { font-size: var(--text-md); font-weight: 600; letter-spacing: -.01em; margin: var(--sp-6) 0 var(--sp-3); }
.note { font-size: var(--text-xs); color: var(--text-3); line-height: 1.6; }
