/* ─────────────────────────────────────────────────────────────────────────
   Spark — Celestial Dark Design System
   Extracted faithfully from spark-v2-production/frontend/src/styles/app.css
   Dark mode only (light tokens removed). All routes share this file.
   ───────────────────────────────────────────────────────────────────────── */

/* ── Resets ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: #041026; color-scheme: dark; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea, select, button { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }

/* ── Tokens (dark only) ───────────────────────────────────────────────── */
:root {
  /* Core surface palette */
  --bg:           #041026;
  --bg-overlay:   #061633;
  --card:         #0b1834;
  --card-soft:    rgba(11, 24, 52, 0.74);
  --card-glass:   rgba(11, 24, 52, 0.6);
  --elevated:    #10244a;
  --elevated-2:  #15305d;

  /* Text */
  --fg:           #f8fbff;
  --muted:        #c4d7f4;
  --tertiary:     #7f9cc8;
  --tertiary-2:   #5a78a4;

  /* Accent + status */
  --accent:        #2f7cff;
  --accent-hover:  #64a0ff;
  --accent-deep:   #1f5fcc;
  --accent-glow:   rgba(47, 124, 255, 0.32);
  --success:       #5be5b1;
  --success-soft:  rgba(91, 229, 177, 0.14);
  --warning:       #f6c95b;
  --warning-soft:  rgba(246, 201, 91, 0.14);
  --error:         #ff7b8a;
  --error-soft:    rgba(255, 123, 138, 0.14);
  --premium:       #b88dff;
  --premium-soft:  rgba(184, 141, 255, 0.16);

  /* Lines */
  --border:        #213f78;
  --border-soft:   rgba(33, 63, 120, 0.62);
  --border-strong: #2c54a0;
  --hairline:      rgba(255, 255, 255, 0.06);

  /* Radii */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-2xl: 36px;
  --r-full: 999px;

  /* Spacing scale (matches Tailwind) */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px;
  --space-4: 16px; --space-5: 20px; --space-6: 24px;
  --space-8: 32px; --space-10: 40px; --space-12: 48px;
  --space-16: 64px; --space-20: 80px; --space-24: 96px;

  /* Shadows */
  --shadow-glow:    0 0 28px var(--accent-glow), 0 0 80px rgba(47, 124, 255, 0.08);
  --shadow-card:    0 18px 54px rgba(0, 0, 0, 0.14);
  --shadow-card-lg: 0 28px 90px rgba(0, 0, 0, 0.2);
  --shadow-fab:     0 4px 24px var(--accent-glow);

  /* Type */
  --font-logo:     "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display:  "Bricolage Grotesque", "Plus Jakarta Sans", system-ui, sans-serif;
  --font-body:     "DM Sans", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-label:    "Space Grotesk", "DM Sans", system-ui, sans-serif;
  --font-mono:     "DM Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;

  /* Z layers */
  --z-bg: -2;
  --z-aurora: -1;
  --z-content: 1;
  --z-sticky: 30;
  --z-overlay: 50;
  --z-modal:   60;
  --z-toast:   80;
}

/* ── Background canvas: starfield + aurora + soft gradient floor ───────── */
body {
  font-family: var(--font-body);
  color: var(--fg);
  background: transparent;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  font-feature-settings: "ss01" on, "cv11" on;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
  background-color: var(--bg);
  background-image:
    radial-gradient(1px 1px at 25% 20%, rgba(255,255,255,0.92), transparent 60%),
    radial-gradient(1px 1px at 65% 35%, rgba(182,214,255,0.75), transparent 60%),
    radial-gradient(1.5px 1.5px at 82% 70%, rgba(255,255,255,0.88), transparent 60%),
    radial-gradient(1px 1px at 12% 78%, rgba(255,255,255,0.6), transparent 60%),
    radial-gradient(1px 1px at 45% 55%, rgba(182,214,255,0.55), transparent 60%),
    radial-gradient(1.5px 1.5px at 90% 18%, rgba(255,255,255,0.8), transparent 60%),
    radial-gradient(1200px 700px at 18% -10%, rgba(13,110,253,0.28), transparent 62%),
    radial-gradient(900px 600px at 82% -5%, rgba(56,182,255,0.2), transparent 62%),
    radial-gradient(1100px 600px at 50% 115%, rgba(10,26,58,0.7), transparent 70%);
  background-size:
    220px 220px, 180px 180px, 310px 310px,
    260px 260px, 200px 200px, 340px 340px,
    100% 100%, 100% 100%, 100% 100%;
  background-position:
    0 0, 40px 60px, 100px 30px,
    70px 120px, 150px 80px, 20px 200px,
    center, center, center;
  background-repeat:
    repeat, repeat, repeat, repeat, repeat, repeat,
    no-repeat, no-repeat, no-repeat;
}

body::after {
  content: "";
  position: fixed;
  inset: -20% -12% auto -12%;
  height: 88vh;
  z-index: var(--z-aurora);
  pointer-events: none;
  background:
    radial-gradient(55% 70% at 22% 32%, rgba(110,231,183,0.5), transparent 55%),
    radial-gradient(50% 70% at 56% 18%, rgba(56,182,255,0.45), transparent 60%),
    radial-gradient(45% 65% at 80% 42%, rgba(167,139,250,0.4), transparent 60%),
    radial-gradient(50% 60% at 40% 58%, rgba(13,110,253,0.32), transparent 60%);
  filter: blur(70px) saturate(140%);
  mix-blend-mode: screen;
  opacity: 0.78;
  animation:
    aurora-drift 26s ease-in-out infinite alternate,
    aurora-hue 40s linear infinite;
  will-change: transform, opacity, filter;
}

@keyframes aurora-drift {
  0%   { transform: translate3d(-6%,-3%,0) scale(1);    opacity: 0.5; }
  25%  { transform: translate3d( 4%, 5%,0) scale(1.08); opacity: 0.8; }
  50%  { transform: translate3d( 7%,-2%,0) scale(1.14); opacity: 0.9; }
  75%  { transform: translate3d(-3%, 4%,0) scale(1.05); opacity: 0.65; }
  100% { transform: translate3d( 6%,-1%,0) scale(1.02); opacity: 0.55; }
}
@keyframes aurora-hue {
  from { filter: blur(70px) saturate(140%) hue-rotate(0deg); }
  to   { filter: blur(70px) saturate(140%) hue-rotate(360deg); }
}

/* ── Typography ───────────────────────────────────────────────────────── */
.font-logo    { font-family: var(--font-logo); }
.font-display { font-family: var(--font-display); }
.font-body    { font-family: var(--font-body); }
.font-label   { font-family: var(--font-label); }
.font-mono    { font-family: var(--font-mono); font-feature-settings: "tnum"; }

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.01em; font-weight: 700; margin: 0; color: var(--fg); }
p { margin: 0; line-height: 1.55; }
.tabular { font-variant-numeric: tabular-nums; }
.eyebrow { font-family: var(--font-label); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.26em; text-transform: uppercase; color: var(--tertiary); }
.label   { font-family: var(--font-label); font-size: 0.78rem; font-weight: 600; color: var(--muted); }
.muted   { color: var(--muted); }
.tertiary{ color: var(--tertiary); }

/* ── Top app navigation (mirrors <Navigation /> in spark) ─────────────── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 14px 24px;
  background: rgba(4, 16, 38, 0.72);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.app-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-logo);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.app-nav__brand-mark {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #8aa9ff 100%);
  color: white;
  font-weight: 800;
  box-shadow: var(--shadow-glow);
}
.app-nav__links {
  display: flex; align-items: center; gap: 4px;
  margin-left: var(--space-4);
}
.app-nav__link {
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: var(--r-full);
  transition: color 160ms ease, background 160ms ease;
}
.app-nav__link:hover { color: var(--fg); background: rgba(255,255,255,0.04); }
.app-nav__link[aria-current="page"] {
  color: var(--fg);
  background: rgba(47, 124, 255, 0.12);
}
.app-nav__spacer { flex: 1; }
.app-nav__action {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px;
  border-radius: var(--r-full);
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 0.85rem;
}
.app-nav__action--ghost { border: 1px solid var(--border); color: var(--muted); }
.app-nav__action--ghost:hover { color: var(--fg); border-color: var(--border-strong); }
.app-nav__action--primary { background: var(--accent); color: white; }
.app-nav__action--primary:hover { background: var(--accent-hover); }
.app-nav__avatar {
  width: 36px; height: 36px;
  border-radius: var(--r-full);
  display: grid; place-items: center;
  background: var(--elevated);
  border: 1px solid var(--border);
  font-family: var(--font-label);
  font-weight: 700;
  color: var(--muted);
}

/* Mobile bottom nav (spark uses this on small screens) */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: var(--z-sticky);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(4, 16, 38, 0.88);
  border-top: 1px solid var(--border-soft);
  backdrop-filter: blur(20px);
}
.mobile-nav__row { display: flex; align-items: center; justify-content: space-around; gap: 4px; }
.mobile-nav__item {
  flex: 1; min-height: 56px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: var(--font-label); font-size: 0.66rem; font-weight: 600;
  color: var(--tertiary);
  border-radius: var(--r-md);
  padding: 6px;
}
.mobile-nav__item[aria-current="page"] { color: var(--fg); background: rgba(47, 124, 255, 0.12); }
.mobile-nav__item svg { width: 22px; height: 22px; }

@media (max-width: 768px) {
  .mobile-nav { display: block; }
  .app-nav__links, .app-nav__action--ghost { display: none; }
}

/* ── Page container ───────────────────────────────────────────────────── */
.page { padding: 32px 24px 96px; min-height: calc(100vh - 64px); position: relative; z-index: var(--z-content); }
.page--narrow { max-width: 720px; margin: 0 auto; }
.page--medium { max-width: 960px; margin: 0 auto; }
.page--wide   { max-width: 1280px; margin: 0 auto; }
@media (max-width: 767px) {
  /* Reserve room for mobile bottom-nav (≈70px) + floating dev toolbar (≈40px) + safe-area */
  .page { padding: 20px 16px calc(180px + env(safe-area-inset-bottom)); }
}

/* ── Cards ────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 24px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-card);
}
.card--lg { padding: 32px; border-radius: var(--r-xl); box-shadow: var(--shadow-card-lg); }
.card--quiet { background: rgba(11, 24, 52, 0.38); }

.glass-card {
  background: linear-gradient(135deg, rgba(11,24,52,0.7) 0%, rgba(16,36,74,0.6) 50%, rgba(11,24,52,0.7) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(47, 124, 255, 0.12);
  border-radius: var(--r-lg);
  transition: all 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
.glass-card:hover {
  border-color: rgba(47, 124, 255, 0.28);
  background: linear-gradient(135deg, rgba(11,24,52,0.82) 0%, rgba(16,36,74,0.72) 50%, rgba(11,24,52,0.82) 100%);
  box-shadow: 0 8px 40px rgba(47,124,255,0.1), 0 0 80px rgba(47,124,255,0.04);
  transform: translateY(-2px);
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--r-md);
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 180ms ease, color 180ms ease, border-color 180ms ease, transform 100ms ease, box-shadow 180ms ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn--primary {
  background: var(--accent); color: white;
  box-shadow: 0 12px 34px var(--accent-glow);
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost {
  border: 1px solid var(--border); color: var(--fg);
  background: rgba(11, 24, 52, 0.42);
}
.btn--ghost:hover { border-color: var(--accent); background: var(--elevated); }
.btn--quiet { color: var(--muted); }
.btn--quiet:hover { color: var(--fg); background: rgba(255, 255, 255, 0.04); }
.btn--danger { background: var(--error); color: #1a0509; }
.btn--danger:hover { filter: brightness(1.06); }
.btn--block { width: 100%; }
.btn--lg { min-height: 52px; padding: 0 24px; font-size: 1rem; border-radius: var(--r-lg); }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 0.82rem; border-radius: var(--r-sm); }
.btn--icon { width: 44px; min-height: 44px; padding: 0; border-radius: var(--r-md); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }

/* Pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 12px;
  border-radius: var(--r-full);
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 0.72rem;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  border: 1px solid var(--border-soft);
}
.pill--accent  { background: rgba(47,124,255,0.12); color: var(--accent-hover); border-color: rgba(47,124,255,0.32); }
.pill--success { background: var(--success-soft); color: var(--success); border-color: rgba(91,229,177,0.32); }
.pill--warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(246,201,91,0.32); }
.pill--error   { background: var(--error-soft);   color: var(--error);   border-color: rgba(255,123,138,0.32); }
.pill--premium { background: var(--premium-soft); color: var(--premium); border-color: rgba(184,141,255,0.32); }

/* ── Form controls ────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-family: var(--font-label); font-size: 0.82rem; font-weight: 600; color: var(--fg); }
.field__hint  { font-size: 0.72rem; color: var(--tertiary); }
.field__error { font-size: 0.78rem; color: var(--error); }
.input, .textarea, .select {
  width: 100%;
  padding: 11px 14px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-family: var(--font-body);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input::placeholder, .textarea::placeholder { color: var(--tertiary-2); }
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 124, 255, 0.25);
}
.input--invalid, .textarea--invalid { border-color: var(--error); box-shadow: 0 0 0 3px rgba(255,123,138,0.2); }
.textarea { min-height: 96px; resize: vertical; }

/* Toggle switch */
.switch {
  position: relative;
  width: 42px; height: 24px;
  border-radius: var(--r-full);
  background: var(--border);
  transition: background 200ms ease;
  flex-shrink: 0;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: white; border-radius: var(--r-full);
  transition: transform 200ms ease;
}
.switch[aria-checked="true"]::before { transform: translateX(18px); }

/* Checkbox */
.checkbox {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--elevated);
  display: inline-grid; place-items: center;
  flex-shrink: 0;
  transition: background 160ms ease, border-color 160ms ease;
}
.checkbox[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox[aria-checked="true"]::after {
  content: "";
  width: 10px; height: 5px;
  border-left: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(-45deg) translate(0, -1px);
}

/* Radio */
.radio {
  width: 18px; height: 18px;
  border-radius: var(--r-full);
  border: 1px solid var(--border-strong);
  background: var(--elevated);
  position: relative;
  flex-shrink: 0;
}
.radio[aria-checked="true"] { border-color: var(--accent); }
.radio[aria-checked="true"]::after {
  content: ""; position: absolute; inset: 3px;
  background: var(--accent); border-radius: var(--r-full);
}

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px;
  padding: 4px;
  border-radius: var(--r-full);
  background: rgba(11, 24, 52, 0.55);
  border: 1px solid var(--border-soft);
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs__item {
  position: relative;
  flex: 1;
  min-height: 40px;
  padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-full);
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--muted);
  white-space: nowrap;
  transition: color 160ms ease, background 160ms ease;
}
.tabs__item[aria-selected="true"] {
  color: var(--fg);
  background: var(--accent);
  box-shadow: 0 4px 14px var(--accent-glow);
}
.tabs__item[aria-selected="true"] .tabs__count { background: rgba(255,255,255,0.18); color: white; }
.tabs__count {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: var(--r-full);
  background: rgba(47, 124, 255, 0.16);
  color: var(--accent-hover);
  font-size: 0.7rem; font-weight: 700;
}

/* ── Progress + meter ─────────────────────────────────────────────────── */
.progress { height: 8px; border-radius: var(--r-full); background: var(--elevated); overflow: hidden; }
.progress__bar { height: 100%; background: linear-gradient(90deg, var(--accent) 0%, #8aa9ff 100%); transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1); }
.progress--ring { width: 132px; height: 132px; }
.progress-ring__track { stroke: var(--elevated); }
.progress-ring__fill  { stroke: var(--accent); transition: stroke-dashoffset 600ms cubic-bezier(0.16, 1, 0.3, 1); }

/* ── Stats ────────────────────────────────────────────────────────────── */
.stat {
  padding: 16px;
  border: 1px solid var(--border-soft);
  background: rgba(11, 24, 52, 0.55);
  border-radius: var(--r-md);
  min-width: 0;
}
.stat__label { font-family: var(--font-label); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase; color: var(--tertiary); }
.stat__value { font-family: var(--font-display); font-size: 1.85rem; font-weight: 700; color: var(--fg); margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat__delta { font-family: var(--font-mono); font-size: 0.74rem; color: var(--success); margin-top: 4px; }
.stat__delta--down { color: var(--error); }

/* ── Animations ───────────────────────────────────────────────────────── */
@keyframes card-enter { from { opacity: 0; transform: translateY(24px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes pulse-glow { 0%,100% { box-shadow: 0 0 20px rgba(47,124,255,0.08), 0 0 60px rgba(47,124,255,0.03); } 50% { box-shadow: 0 0 28px rgba(47,124,255,0.15), 0 0 80px rgba(47,124,255,0.06); } }
@keyframes float-slow  { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes breathe     { 0%,100% { opacity: 0.4; transform: scale(1); } 50% { opacity: 0.8; transform: scale(1.04); } }
@keyframes slide-up    { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fab-pulse   { 0%,100% { box-shadow: 0 4px 24px rgba(47,124,255,0.3), 0 0 0 0 rgba(47,124,255,0.4); } 50% { box-shadow: 0 4px 32px rgba(47,124,255,0.5), 0 0 0 12px rgba(47,124,255,0); } }
@keyframes shimmer     { 0% { background-position: -200% center; } 100% { background-position: 200% center; } }
@keyframes spin        { to { transform: rotate(360deg); } }

.anim-card-enter { animation: card-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
.anim-pulse-glow { animation: pulse-glow 3s ease-in-out infinite; }
.anim-float      { animation: float-slow 4s ease-in-out infinite; }
.anim-breathe    { animation: breathe 6s ease-in-out infinite; }
.anim-slide-up   { animation: slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
.anim-fab-pulse  { animation: fab-pulse 2.5s ease-in-out infinite; }
.anim-spin       { animation: spin 1s linear infinite; }

/* Skeleton shimmer (spark's loading state) */
.shimmer {
  background: linear-gradient(90deg, rgba(16,36,74,0.4) 0%, rgba(47,124,255,0.08) 40%, rgba(16,36,74,0.4) 80%);
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
  border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ── Grid helpers ─────────────────────────────────────────────────────── */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
.grid--4 { grid-template-columns: 1fr 1fr; }
@media (min-width: 720px) {
  .grid--2 { grid-template-columns: 1fr 1fr; }
  .grid--3 { grid-template-columns: 1fr 1fr 1fr; }
  .grid--4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
}
@media (min-width: 1024px) {
  .grid--3 { grid-template-columns: repeat(3, 1fr); }
}

/* Card grid with stagger (mirrors spark's card-grid) */
.card-grid > * { animation: card-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
@media (min-width: 768px) {
  .card-grid > *:nth-child(1) { animation-delay: 0ms; }
  .card-grid > *:nth-child(2) { animation-delay: 80ms; }
  .card-grid > *:nth-child(3) { animation-delay: 160ms; }
  .card-grid > *:nth-child(4) { animation-delay: 240ms; }
  .card-grid > *:nth-child(5) { animation-delay: 320ms; }
  .card-grid > *:nth-child(6) { animation-delay: 400ms; }
  .card-grid > *:nth-child(7) { animation-delay: 480ms; }
  .card-grid > *:nth-child(8) { animation-delay: 560ms; }
  .card-grid > *:nth-child(9) { animation-delay: 640ms; }
}

/* ── Match-style cards ────────────────────────────────────────────────── */
.match-card {
  position: relative;
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, rgba(11,24,52,0.7) 0%, rgba(16,36,74,0.6) 50%, rgba(11,24,52,0.7) 100%);
  border: 1px solid rgba(47, 124, 255, 0.12);
  backdrop-filter: blur(20px);
  transition: all 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
.match-card:hover {
  transform: translateY(-2px);
  border-color: rgba(47, 124, 255, 0.28);
  box-shadow: 0 8px 40px rgba(47, 124, 255, 0.1);
}
.match-card__row { display: flex; align-items: center; gap: 12px; }
.match-card__avatar {
  width: 48px; height: 48px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, rgba(47,124,255,0.32) 0%, rgba(184,141,255,0.32) 100%);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 1.2rem;
  color: var(--fg);
  border: 1px solid rgba(255,255,255,0.08);
}
.match-card__name { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--fg); margin: 0; }
.match-card__handle { font-size: 0.78rem; color: var(--tertiary); margin: 2px 0 0; }
.match-card__similarity {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--accent-hover);
  background: rgba(47,124,255,0.12);
  padding: 2px 8px;
  border-radius: var(--r-full);
}
.match-card__deadline {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--warning);
}

/* ── Modal / sheet ────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(4, 16, 38, 0.72);
  backdrop-filter: blur(8px);
  z-index: var(--z-overlay);
  animation: slide-up 200ms ease both;
}
.modal {
  position: fixed; inset: 0;
  z-index: var(--z-modal);
  display: grid; place-items: center;
  padding: 24px;
  pointer-events: none;
}
.modal__panel {
  pointer-events: auto;
  width: 100%;
  max-width: 480px;
  background: linear-gradient(180deg, rgba(11,24,52,0.96) 0%, rgba(16,36,74,0.96) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-card-lg);
  padding: 28px;
  animation: card-enter 240ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.modal__title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin-bottom: 12px; }
.modal__close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  color: var(--muted);
  display: grid; place-items: center;
}
.modal__close:hover { background: rgba(255,255,255,0.06); color: var(--fg); }

/* Mobile bottom sheet variant */
.sheet {
  position: fixed; bottom: 0; left: 0; right: 0;
  z-index: var(--z-modal);
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(11,24,52,0.94) 0%, rgba(16,36,74,0.96) 100%);
  border-top: 1px solid var(--border);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  animation: slide-up 280ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Toast / banner ───────────────────────────────────────────────────── */
.banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 0.88rem;
  animation: slide-up 200ms ease both;
}
.banner--error   { background: var(--error-soft);   color: var(--error);   border: 1px solid rgba(255,123,138,0.24); }
.banner--success { background: var(--success-soft); color: var(--success); border: 1px solid rgba(91,229,177,0.24); }
.banner--warning { background: var(--warning-soft); color: var(--warning); border: 1px solid rgba(246,201,91,0.24); }
.banner--info    { background: rgba(47,124,255,0.1); color: var(--accent-hover); border: 1px solid rgba(47,124,255,0.24); }

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 64px 24px;
}
.empty__icon {
  width: 80px; height: 80px;
  border-radius: var(--r-full);
  background: rgba(47,124,255,0.1);
  border: 1px solid rgba(47,124,255,0.2);
  display: inline-grid; place-items: center;
  margin-bottom: 24px;
  position: relative;
}
.empty__icon::before {
  content: ""; position: absolute; inset: -8px;
  border-radius: var(--r-full);
  background: rgba(47,124,255,0.06);
  z-index: -1;
  animation: breathe 6s ease-in-out infinite;
}
.empty__title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
.empty__body  { color: var(--muted); max-width: 360px; margin: 0 auto 24px; }
.empty__actions { display: inline-flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ── Tables (admin) ───────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th, .table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.table th {
  font-family: var(--font-label);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tertiary);
  background: rgba(255,255,255,0.02);
}
.table tbody tr:hover { background: rgba(47,124,255,0.05); }
.table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--card-soft);
  backdrop-filter: blur(14px);
}

/* ── Floating action button ───────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 24px; right: 16px;
  z-index: var(--z-sticky);
  width: 56px; height: 56px;
  border-radius: var(--r-lg);
  background: var(--accent);
  color: white;
  display: grid; place-items: center;
  box-shadow: var(--shadow-fab);
}
.fab--lg { width: 64px; height: 64px; }
@media (min-width: 768px) { .fab { display: none; } }

/* ── Utilities ────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }
.text-sm { font-size: 0.86rem; } .text-xs { font-size: 0.74rem; } .text-lg { font-size: 1.1rem; } .text-xl { font-size: 1.28rem; } .text-2xl { font-size: 1.55rem; } .text-3xl { font-size: 1.9rem; } .text-4xl { font-size: 2.4rem; } .text-5xl { font-size: 3rem; } .text-6xl { font-size: 3.6rem; }
.font-bold { font-weight: 700; } .font-semibold { font-weight: 600; } .font-medium { font-weight: 500; }
.text-accent { color: var(--accent-hover); }
.text-error  { color: var(--error); }
.text-warning{ color: var(--warning); }
.text-success{ color: var(--success); }
.w-full { width: 100%; }
.shrink-0 { flex-shrink: 0; }
.hidden { display: none !important; }
@media (max-width: 640px) { .sm-hidden { display: none !important; } }
@media (min-width: 768px) { .md-hidden { display: none !important; } }

/* ── Dev toolbar (state + version toggle on every page) ───────────────── */
.dev-toolbar {
  position: fixed;
  bottom: calc(92px + env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: rgba(11, 24, 52, 0.94);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.dev-toolbar::-webkit-scrollbar { display: none; }
@media (min-width: 768px) {
  .dev-toolbar {
    bottom: 16px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: auto;
    overflow: visible;
  }
}
.dev-toolbar__group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: rgba(4, 16, 38, 0.7);
  border-radius: var(--r-full);
  flex-shrink: 0;
}
.dev-toolbar__chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--tertiary);
  padding: 6px 12px;
  border-radius: var(--r-full);
  transition: color 160ms ease, background 160ms ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.dev-toolbar__chip:hover { color: var(--fg); }
.dev-toolbar__chip[aria-pressed="true"] {
  background: var(--accent);
  color: white;
}
.dev-toolbar__label {
  font-family: var(--font-label);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--tertiary);
  padding-left: 8px;
  padding-right: 2px;
  flex-shrink: 0;
}
@media (max-width: 480px) {
  .dev-toolbar__label { display: none; }
  .dev-toolbar__chip { padding: 6px 10px; font-size: 0.68rem; }
}

/* Hide states by default; system.js shows the active one */
[data-state] { display: none; }
[data-state].is-active { display: block; }
[data-version] { display: none; }
[data-version].is-active { display: contents; }

/* Improved-only annotation chip */
.diff-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: rgba(91, 229, 177, 0.12);
  color: var(--success);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid rgba(91, 229, 177, 0.24);
}
.diff-chip::before { content: "▲"; font-size: 0.6rem; }

/* AS-IS warning chip for known issues */
.note-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: rgba(246, 201, 91, 0.1);
  color: var(--warning);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid rgba(246, 201, 91, 0.24);
}
.note-chip::before { content: "▲"; font-size: 0.6rem; }

/* Decorative spark mark (matches Spark Logo SVG) */
.spark-mark {
  display: inline-grid; place-items: center;
  width: 80px; height: 80px;
  color: var(--accent);
}
.spark-mark--lg { width: 120px; height: 120px; }
