/* ══════════════════════════════════════════════════════════════════════════
   Bolteryx — design tokens, reset and primitives
   Shared by the public site and the admin panel.
   ══════════════════════════════════════════════════════════════════════════ */

@layer tokens, reset, base, components, utilities;

@layer tokens {
  :root,
  [data-theme='light'] {
    /* Voltage palette */
    --volt-50:  #f4f1ff;
    --volt-100: #e7e0ff;
    --volt-200: #d1c4ff;
    --volt-300: #b19dff;
    --volt-400: #8f70ff;
    --volt-500: #6342eb;   /* primary brand in light mode */
    --volt-600: #5231db;
    --volt-700: #4221c4;
    --volt-800: #33159e;
    --volt-900: #200a6e;

    --cyan-300: #0284c7;
    --cyan-400: #0369a1;
    --cyan-500: #0284c7;   /* secondary in light mode */
    --cyan-600: #075985;

    --pink-400: #e11d48;
    --pink-500: #be123c;   /* tertiary in light mode */

    --amber-400: #d97706;
    --amber-500: #b45309;
    --lime-400:  #65a30d;
    --lime-500:  #4d7c0f;

    /* Neutral ramp — crisp slate for light mode */
    --ink-0:   #ffffff;
    --ink-50:  #f8fafc;
    --ink-100: #f1f5f9;
    --ink-200: #e2e8f0;
    --ink-300: #cbd5e1;
    --ink-400: #94a3b8;
    --ink-500: #64748b;
    --ink-600: #475467;
    --ink-700: #334155;
    --ink-750: #1e293b;
    --ink-800: #0f172a;
    --ink-850: #090d16;
    --ink-900: #050811;
    --ink-950: #020307;

    /* Semantic surfaces */
    --bg:            #ffffff;
    --bg-raised:     #f8fafc;
    --surface:       rgba(15 23 42 / 0.035);
    --surface-hover: rgba(15 23 42 / 0.06);
    --surface-solid: #f1f5f9;
    --surface-card:  #ffffff;
    --hairline:      rgba(15 23 42 / 0.10);
    --hairline-soft: rgba(15 23 42 / 0.05);
    --border-color:  #e2e8f0;

    --text:      #0b0f19;  /* Deep charcoal ink, 15:1 contrast */
    --text-soft: #334155;  /* Slate 700, 7.5:1 contrast */
    --text-mute: #64748b;  /* Slate 500, 4.6:1 contrast */

    --success: #059669;
    --warning: #d97706;
    --danger:  #dc2626;
    --info:    #0284c7;

    /* Type */
    --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --step--2: clamp(0.69rem, 0.67rem + 0.10vw, 0.75rem);
    --step--1: clamp(0.80rem, 0.77rem + 0.15vw, 0.88rem);
    --step-0:  clamp(0.94rem, 0.91rem + 0.17vw, 1.03rem);
    --step-1:  clamp(1.13rem, 1.07rem + 0.29vw, 1.30rem);
    --step-2:  clamp(1.35rem, 1.25rem + 0.49vw, 1.64rem);
    --step-3:  clamp(1.62rem, 1.46rem + 0.79vw, 2.07rem);
    --step-4:  clamp(1.94rem, 1.70rem + 1.22vw, 2.61rem);
    --step-5:  clamp(2.33rem, 1.96rem + 1.84vw, 3.29rem);
    --step-6:  clamp(2.80rem, 2.25rem + 2.72vw, 4.15rem);
    --step-7:  clamp(2.75rem, 2.00rem + 3.90vw, 5.23rem);

    /* Space */
    --sp-1: 0.25rem; --sp-2: 0.5rem;  --sp-3: 0.75rem; --sp-4: 1rem;
    --sp-5: 1.5rem;  --sp-6: 2rem;    --sp-7: 3rem;    --sp-8: 4rem;
    --sp-9: 6rem;    --sp-10: 8rem;

    --radius-xs: 6px;  --radius-sm: 10px; --radius:   14px;
    --radius-lg: 20px; --radius-xl: 28px; --radius-full: 999px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow:    0 4px 16px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, 0.09), 0 8px 16px -4px rgba(0, 0, 0, 0.05);
    --glow-volt: 0 0 0 1px rgba(99, 66, 235, 0.2), 0 8px 24px -6px rgba(99, 66, 235, 0.35);
    --glow-cyan: 0 0 0 1px rgba(2, 132, 199, 0.2), 0 8px 24px -6px rgba(2, 132, 199, 0.35);

    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    --container: 1220px;
    --header-h: 72px;

    color-scheme: light;
  }

  /* ── Dark Theme Tokens ─────────────────────────────────────────────────── */
  [data-theme='dark'] {
    --volt-50:  #f2efff;
    --volt-100: #e4dcff;
    --volt-200: #c9b8ff;
    --volt-300: #a891ff;
    --volt-400: #8f70ff;
    --volt-500: #7c5cff;   /* primary */
    --volt-600: #6c4cf1;
    --volt-700: #5738d4;
    --volt-800: #3f27a0;
    --volt-900: #241659;

    --cyan-300: #6ef7e6;
    --cyan-400: #38ecd6;
    --cyan-500: #22e6d2;   /* secondary */
    --cyan-600: #10bfae;

    --pink-400: #ff5c96;
    --pink-500: #ff3d81;   /* tertiary */

    --amber-400: #ffc24d;
    --lime-400:  #b5f23d;

    /* Neutral ramp — cold, near-black */
    --ink-0:   #ffffff;
    --ink-50:  #f6f7fb;
    --ink-100: #e8eaf2;
    --ink-200: #c9cee0;
    --ink-300: #9aa3bd;
    --ink-400: #6f7896;
    --ink-500: #4c5470;
    --ink-600: #333a52;
    --ink-700: #232941;
    --ink-750: #1b2035;
    --ink-800: #141828;
    --ink-850: #0f1220;
    --ink-900: #0a0c17;
    --ink-950: #05060b;

    /* Semantic surfaces */
    --bg:            var(--ink-950);
    --bg-raised:     var(--ink-900);
    --surface:       rgba(255 255 255 / 0.026);
    --surface-hover: rgba(255 255 255 / 0.05);
    --surface-solid: var(--ink-850);
    --surface-card:  var(--ink-900);
    --hairline:      rgba(255 255 255 / 0.08);
    --hairline-soft: rgba(255 255 255 / 0.045);
    --border-color:  rgba(255 255 255 / 0.08);

    --text:      var(--ink-100);
    --text-soft: var(--ink-300);
    --text-mute: var(--ink-400);

    --success: #35d9a0;
    --warning: #ffb340;
    --danger:  #ff5c7c;
    --info:    var(--cyan-500);

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow:    0 8px 30px -12px rgb(0 0 0 / 0.6);
    --shadow-lg: 0 30px 70px -25px rgb(0 0 0 / 0.75);
    --glow-volt: 0 0 0 1px rgb(124 92 255 / 0.35), 0 12px 40px -12px rgb(124 92 255 / 0.55);
    --glow-cyan: 0 0 0 1px rgb(34 230 210 / 0.3), 0 12px 40px -14px rgb(34 230 210 / 0.45);

    color-scheme: dark;
  }

  /* Accent helpers */
  [data-accent='violet'] { --accent: var(--volt-500); --accent-soft: rgba(99, 66, 235, 0.08); }
  [data-accent='cyan']   { --accent: var(--cyan-500); --accent-soft: rgba(2, 132, 199, 0.08); }
  [data-accent='pink']   { --accent: var(--pink-500); --accent-soft: rgba(225, 29, 72, 0.08); }
  [data-accent='amber']  { --accent: var(--amber-400); --accent-soft: rgba(217, 119, 6, 0.08); }
  [data-accent='lime']   { --accent: var(--lime-400); --accent-soft: rgba(101, 163, 13, 0.08); }
  :where([data-accent]) { --accent: var(--volt-500); }

  [data-theme='dark'] [data-accent='violet'] { --accent: var(--volt-500); --accent-soft: rgb(124 92 255 / 0.14); }
  [data-theme='dark'] [data-accent='cyan']   { --accent: var(--cyan-500); --accent-soft: rgb(34 230 210 / 0.14); }
  [data-theme='dark'] [data-accent='pink']   { --accent: var(--pink-500); --accent-soft: rgb(255 61 129 / 0.14); }
  [data-theme='dark'] [data-accent='amber']  { --accent: var(--amber-400); --accent-soft: rgb(255 194 77 / 0.14); }
  [data-theme='dark'] [data-accent='lime']   { --accent: var(--lime-400); --accent-soft: rgb(181 242 61 / 0.14); }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }

  html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 1rem);
  }

  body {
    font-family: var(--font-body);
    font-size: var(--step-0);
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    overflow-x: hidden;
  }

  img, svg, video, canvas { display: block; max-width: 100%; height: auto; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; background: none; border: 0; }
  a { color: inherit; text-decoration: none; }
  ul, ol { list-style: none; padding: 0; }
  table { border-collapse: collapse; width: 100%; }
  summary { cursor: pointer; list-style: none; }
  summary::-webkit-details-marker { display: none; }

  :focus-visible {
    outline: 2px solid var(--volt-400);
    outline-offset: 3px;
    border-radius: var(--radius-xs);
  }

  ::selection { background: rgba(99, 66, 235, 0.2); color: var(--text); }
  [data-theme='dark'] ::selection { background: rgb(124 92 255 / 0.35); color: #fff; }

  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: var(--bg-raised); }
  ::-webkit-scrollbar-thumb {
    background: var(--ink-300);
    border-radius: 99px;
    border: 2px solid var(--bg-raised);
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--ink-400); }

  [data-theme='dark'] ::-webkit-scrollbar-track { background: var(--ink-900); }
  [data-theme='dark'] ::-webkit-scrollbar-thumb {
    background: var(--ink-700);
    border: 2px solid var(--ink-900);
  }
  [data-theme='dark'] ::-webkit-scrollbar-thumb:hover { background: var(--ink-600); }

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

@layer base {
  h1, h2, h3, h4, h5 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.028em;
    text-wrap: balance;
  }

  h1 { font-size: var(--step-6); }
  h2 { font-size: var(--step-4); }
  h3 { font-size: var(--step-2); }
  h4 { font-size: var(--step-1); }

  p { text-wrap: pretty; }

  code, kbd, pre { font-family: var(--font-mono); font-size: 0.9em; }

  hr { border: 0; border-top: 1px solid var(--hairline); margin: var(--sp-6) 0; }
}

@layer components {
  /* ── Layout ──────────────────────────────────────────────────────────── */
  .wrap {
    width: min(100% - 2.5rem, var(--container));
    margin-inline: auto;
  }
  .wrap--narrow { width: min(100% - 2.5rem, 800px); }
  .wrap--wide   { width: min(100% - 2.5rem, 1440px); }

  .section { padding-block: clamp(4rem, 9vw, 8rem); position: relative; }
  .section--tight { padding-block: clamp(2.5rem, 5vw, 4.5rem); }

  .stack > * + * { margin-top: var(--flow, 1rem); }

  /* ── Eyebrow / section heading ───────────────────────────────────────── */
  .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-mono);
    font-size: var(--step--2);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--volt-600);
    font-weight: 600;
  }
  .eyebrow::before {
    content: '';
    width: 22px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--volt-500));
  }
  [data-theme='dark'] .eyebrow {
    color: var(--volt-300);
    font-weight: 500;
  }
  [data-theme='dark'] .eyebrow::before {
    background: linear-gradient(90deg, transparent, var(--volt-400));
  }

  .section-head { max-width: 62ch; margin-bottom: var(--sp-7); }
  .section-head h2 { margin-block: 0.7rem 0.9rem; }
  .section-head p { color: var(--text-soft); font-size: var(--step-1); }

  /* ── Gradient text ───────────────────────────────────────────────────── */
  .gradient-text {
    background: linear-gradient(100deg, var(--volt-600) 0%, #0284c7 48%, var(--pink-500) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    display: inline;
  }
  [data-theme='dark'] .gradient-text {
    background: linear-gradient(100deg, var(--volt-300) 0%, var(--cyan-400) 48%, var(--pink-400) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    display: inline;
  }

  /* ── Buttons ─────────────────────────────────────────────────────────── */
  .btn {
    --btn-bg: var(--surface-card);
    --btn-fg: var(--text);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.78rem 1.4rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-weight: 550;
    font-size: var(--step--1);
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition: transform 0.25s var(--ease-spring), box-shadow 0.25s var(--ease-out),
                background-color 0.2s, border-color 0.2s, color 0.2s;
    isolation: isolate;
  }
  .btn:hover { transform: translateY(-2px); background: var(--surface-hover); }
  .btn:active { transform: translateY(0); }

  .btn--primary {
    --btn-fg: #ffffff;
    border-color: transparent;
    background: var(--volt-500);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(99, 66, 235, 0.25);
  }
  .btn--primary:hover {
    box-shadow: var(--glow-volt);
    background: var(--volt-600);
    color: #ffffff;
  }
  [data-theme='dark'] .btn--primary {
    --btn-fg: #0a0616;
    background: linear-gradient(100deg, var(--volt-400), var(--cyan-400));
    color: #0a0616;
  }
  [data-theme='dark'] .btn--primary:hover {
    background: linear-gradient(100deg, var(--volt-300), var(--cyan-300));
    color: #0a0616;
    box-shadow: var(--glow-volt);
  }

  .btn--ghost {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }
  .btn--ghost:hover {
    border-color: var(--ink-400);
    background: var(--bg-raised);
    color: var(--volt-600);
  }
  [data-theme='dark'] .btn--ghost {
    background: transparent;
    border: 1px solid var(--hairline);
    box-shadow: none;
    color: var(--text);
  }
  [data-theme='dark'] .btn--ghost:hover {
    border-color: var(--volt-500);
    background: var(--surface-hover);
    color: var(--volt-200);
  }

  .btn--danger { border-color: rgba(220, 38, 38, 0.25); color: var(--danger); background: rgba(220, 38, 38, 0.06); }
  .btn--danger:hover { background: rgba(220, 38, 38, 0.12); }

  .btn--success { border-color: rgba(5, 150, 105, 0.25); color: var(--success); background: rgba(5, 150, 105, 0.06); }
  .btn--success:hover { background: rgba(5, 150, 105, 0.12); }

  .btn--sm { padding: 0.48rem 0.95rem; font-size: var(--step--2); }
  .btn--lg { padding: 1rem 1.9rem; font-size: var(--step-0); }
  .btn--block { width: 100%; }
  .btn--icon { padding: 0.55rem; aspect-ratio: 1; border-radius: var(--radius-full); }
  .btn[disabled], .btn[aria-disabled='true'] { opacity: 0.45; pointer-events: none; }

  .btn__arrow { transition: transform 0.3s var(--ease-out); }
  .btn:hover .btn__arrow { transform: translateX(3px); }

  /* ── Surfaces ────────────────────────────────────────────────────────── */
  .card {
    position: relative;
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.3s, transform 0.35s var(--ease-out), background-color 0.3s, box-shadow 0.3s;
  }
  .card--hover:hover {
    transform: translateY(-4px);
    border-color: rgba(99, 66, 235, 0.35);
    box-shadow: var(--shadow);
  }
  [data-theme='dark'] .card {
    background: var(--surface);
    border: 1px solid var(--hairline);
    backdrop-filter: blur(14px);
    box-shadow: none;
  }
  [data-theme='dark'] .card--hover:hover {
    border-color: rgb(124 92 255 / 0.4);
    background: var(--surface-hover);
    box-shadow: var(--shadow);
  }

  /* Hairline gradient edge */
  .card--edge::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(140deg, rgba(99, 66, 235, 0.4), transparent 38%, transparent 62%, rgba(2, 132, 199, 0.3));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.8;
  }
  [data-theme='dark'] .card--edge::before {
    background: linear-gradient(140deg, rgb(124 92 255 / 0.55), transparent 38%, transparent 62%, rgb(34 230 210 / 0.4));
    opacity: 0.9;
  }

  /* ── Badges & pills ──────────────────────────────────────────────────── */
  .badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.62rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--surface-solid);
    font-family: var(--font-mono);
    font-size: var(--step--2);
    letter-spacing: 0.04em;
    color: var(--text-soft);
    white-space: nowrap;
  }
  .badge--volt    { border-color: rgba(99, 66, 235, 0.25); background: rgba(99, 66, 235, 0.08); color: #432ac4; }
  .badge--cyan    { border-color: rgba(2, 132, 199, 0.25); background: rgba(2, 132, 199, 0.08); color: #0369a1; }
  .badge--pink    { border-color: rgba(225, 29, 72, 0.25); background: rgba(225, 29, 72, 0.08); color: #be123c; }
  .badge--success { border-color: rgba(5, 150, 105, 0.25); background: rgba(5, 150, 105, 0.08); color: #047857; }
  .badge--warning { border-color: rgba(217, 119, 6, 0.25); background: rgba(217, 119, 6, 0.08); color: #b45309; }
  .badge--danger  { border-color: rgba(220, 38, 38, 0.25); background: rgba(220, 38, 38, 0.08); color: #b91c1c; }
  .badge--mute    { color: var(--text-mute); }

  [data-theme='dark'] .badge { background: var(--surface); border-color: var(--hairline); }
  [data-theme='dark'] .badge--volt    { border-color: rgb(124 92 255 / 0.35); background: rgb(124 92 255 / 0.12); color: var(--volt-200); }
  [data-theme='dark'] .badge--cyan    { border-color: rgb(34 230 210 / 0.35); background: rgb(34 230 210 / 0.1);  color: var(--cyan-300); }
  [data-theme='dark'] .badge--pink    { border-color: rgb(255 61 129 / 0.35); background: rgb(255 61 129 / 0.1);  color: var(--pink-400); }
  [data-theme='dark'] .badge--success { border-color: rgb(53 217 160 / 0.35); background: rgb(53 217 160 / 0.1);  color: var(--success); }
  [data-theme='dark'] .badge--warning { border-color: rgb(255 179 64 / 0.35); background: rgb(255 179 64 / 0.1);  color: var(--warning); }
  [data-theme='dark'] .badge--danger  { border-color: rgb(255 92 124 / 0.35); background: rgb(255 92 124 / 0.1);  color: var(--danger); }

  .badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
  .badge__dot--pulse { animation: pulse-dot 2s var(--ease-in-out) infinite; }

  /* ── Forms ───────────────────────────────────────────────────────────── */
  .field {
    display: flex;
    flex-direction: column;
    gap: 0.42rem;
    justify-content: flex-start;
  }
  .field__label {
    font-size: var(--step--1);
    font-weight: 550;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 1.4rem;
  }
  .field__label .req { color: var(--danger); }
  .field__hint {
    font-size: var(--step--2);
    color: var(--text-mute);
    line-height: 1.4;
    margin-top: 0.15rem;
  }
  .field__error {
    font-size: var(--step--2);
    font-weight: 500;
    color: var(--danger);
    display: flex;
    gap: 0.35rem;
    align-items: center;
    line-height: 1.4;
    margin-top: 0.25rem;
  }
  .field__error i,
  .field__error svg {
    flex-shrink: 0;
  }

  .input, .select, .textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    min-height: 2.55rem;
    box-sizing: border-box;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: var(--step--1);
    line-height: 1.5;
    transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  }
  .input::placeholder, .textarea::placeholder { color: #94a3b8; }
  .input:hover, .select:hover, .textarea:hover { border-color: #94a3b8; }
  .input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--volt-500);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(99, 66, 235, 0.15);
  }
  .textarea { resize: vertical; min-height: 7rem; line-height: 1.6; }

  .select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat !important;
    background-position: right 0.85rem center !important;
    background-size: 14px 14px !important;
    padding-right: 2.3rem;
    cursor: pointer;
  }
  .select option { background-color: #ffffff; color: var(--text); }

  [data-theme='dark'] .input,
  [data-theme='dark'] .select,
  [data-theme='dark'] .textarea {
    background-color: rgb(255 255 255 / 0.03);
    border-color: var(--hairline);
    color: var(--text);
  }
  [data-theme='dark'] .input::placeholder,
  [data-theme='dark'] .textarea::placeholder { color: var(--ink-500); }
  [data-theme='dark'] .input:hover,
  [data-theme='dark'] .select:hover,
  [data-theme='dark'] .textarea:hover { border-color: rgb(255 255 255 / 0.16); }
  [data-theme='dark'] .input:focus,
  [data-theme='dark'] .select:focus,
  [data-theme='dark'] .textarea:focus {
    background-color: rgb(124 92 255 / 0.06);
    box-shadow: 0 0 0 3px rgb(124 92 255 / 0.16);
    border-color: var(--volt-500);
  }
  [data-theme='dark'] .select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aa3bd' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat !important;
    background-position: right 0.85rem center !important;
    background-size: 14px 14px !important;
  }
  [data-theme='dark'] .select option { background-color: var(--ink-850); color: var(--text); }

  .input--error, .select--error, .textarea--error {
    border-color: var(--danger) !important;
    background-color: rgba(220, 38, 38, 0.04);
  }
  .input--error:focus, .select--error:focus, .textarea--error:focus {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2) !important;
  }
  [data-theme='dark'] .input--error,
  [data-theme='dark'] .select--error,
  [data-theme='dark'] .textarea--error {
    border-color: var(--danger) !important;
    background-color: rgb(255 92 124 / 0.08);
  }
  [data-theme='dark'] .input--error:focus,
  [data-theme='dark'] .select--error:focus,
  [data-theme='dark'] .textarea--error:focus {
    box-shadow: 0 0 0 3px rgba(255, 92, 124, 0.25) !important;
  }

  .check {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    cursor: pointer;
    font-size: var(--step--1);
    color: var(--text-soft);
  }
  .check input[type='checkbox'], .check input[type='radio'] {
    appearance: none;
    flex: none;
    width: 1.15rem;
    height: 1.15rem;
    margin-top: 0.15rem;
    border: 1px solid #94a3b8;
    border-radius: 5px;
    background: #ffffff;
    transition: 0.2s;
    display: grid;
    place-content: center;
  }
  .check input[type='radio'] { border-radius: 50%; }
  .check input:checked {
    background: var(--volt-500);
    border-color: transparent;
  }
  .check input[type='checkbox']:checked::after {
    content: '';
    width: 0.32rem; height: 0.6rem;
    border: solid #ffffff;
    border-width: 0 2.2px 2.2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
  }
  .check input[type='radio']:checked::after {
    content: ''; width: 0.42rem; height: 0.42rem; border-radius: 50%; background: #ffffff;
  }
  [data-theme='dark'] .check input[type='checkbox'],
  [data-theme='dark'] .check input[type='radio'] {
    border-color: var(--ink-500);
    background: rgb(255 255 255 / 0.03);
  }
  [data-theme='dark'] .check input:checked {
    background: linear-gradient(135deg, var(--volt-500), var(--cyan-500));
  }
  [data-theme='dark'] .check input[type='checkbox']:checked::after {
    border-color: #08060f;
  }
  [data-theme='dark'] .check input[type='radio']:checked::after {
    background: #08060f;
  }

  .switch { display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer; }
  .switch input { appearance: none; width: 2.6rem; height: 1.45rem; border-radius: 99px;
    background: #cbd5e1; position: relative; transition: 0.25s; flex: none; }
  .switch input::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 1.05rem; height: 1.05rem; border-radius: 50%;
    background: #ffffff; box-shadow: 0 1px 3px rgba(0,0,0,0.15); transition: 0.25s var(--ease-spring);
  }
  .switch input:checked { background: var(--volt-500); }
  .switch input:checked::after { left: calc(100% - 1.05rem - 3px); background: #fff; }
  [data-theme='dark'] .switch input { background: var(--ink-700); }
  [data-theme='dark'] .switch input::after { background: var(--ink-300); box-shadow: none; }
  [data-theme='dark'] .switch input:checked { background: linear-gradient(90deg, var(--volt-500), var(--cyan-500)); }

  .form-grid { display: grid; gap: var(--sp-4); align-items: start; }
  @media (min-width: 640px) {
    .form-grid--2 { grid-template-columns: 1fr 1fr; }
    .form-grid--3 { grid-template-columns: repeat(3, 1fr); }
    .form-grid .span-2 { grid-column: span 2; }
    .form-grid .span-full { grid-column: 1 / -1; }
  }

  /* ── Alerts ──────────────────────────────────────────────────────────── */
  .alert {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--surface-card);
    font-size: var(--step--1);
  }
  .alert--success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
  .alert--error   { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
  .alert--warning { border-color: #fde68a; background: #fffbeb; color: #92400e; }
  .alert--info    { border-color: #bae6fd; background: #f0f9ff; color: #0369a1; }

  [data-theme='dark'] .alert { border-color: var(--hairline); background: var(--surface); }
  [data-theme='dark'] .alert--success { border-color: rgb(53 217 160 / 0.35); background: rgb(53 217 160 / 0.08); color: #a7f3d6; }
  [data-theme='dark'] .alert--error   { border-color: rgb(255 92 124 / 0.35); background: rgb(255 92 124 / 0.08); color: #ffc2cd; }
  [data-theme='dark'] .alert--warning { border-color: rgb(255 179 64 / 0.35); background: rgb(255 179 64 / 0.08); color: #ffdca8; }
  [data-theme='dark'] .alert--info    { border-color: rgb(34 230 210 / 0.3);  background: rgb(34 230 210 / 0.07); color: #a6f5ec; }

  /* ── Toasts (Global - Panel, Site & Auth) ──────────────────────────────── */
  .toast-stack {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    width: min(26rem, calc(100vw - 2.5rem));
    pointer-events: none;
  }
  .toast {
    pointer-events: auto;
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    padding: 0.9rem 1.15rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 12px 36px -4px rgba(0, 0, 0, 0.12), 0 4px 12px -2px rgba(0, 0, 0, 0.05);
    animation: toastRise 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: var(--step--1);
    line-height: 1.45;
    color: var(--text);
  }
  [data-theme='dark'] .toast {
    background: rgba(16, 20, 32, 0.96);
    border-color: var(--hairline);
    box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.07);
    color: var(--text);
  }

  .toast--error   { border-left: 4px solid var(--danger); }
  .toast--success { border-left: 4px solid var(--success); }
  .toast--warning { border-left: 4px solid var(--warning); }
  .toast--info    { border-left: 4px solid var(--info); }

  .toast__icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-top: 0.05rem;
  }
  .toast--error   .toast__icon { color: var(--danger); background: rgba(220, 38, 38, 0.12); }
  .toast--success .toast__icon { color: var(--success); background: rgba(5, 150, 105, 0.12); }
  .toast--warning .toast__icon { color: var(--warning); background: rgba(217, 119, 6, 0.12); }
  .toast--info    .toast__icon { color: var(--info); background: rgba(2, 132, 199, 0.12); }

  [data-theme='dark'] .toast--error   .toast__icon { color: #ff6b8b; background: rgba(255, 92, 124, 0.18); }
  [data-theme='dark'] .toast--success .toast__icon { color: #3be8ab; background: rgba(53, 217, 160, 0.18); }
  [data-theme='dark'] .toast--warning .toast__icon { color: #ffbe4d; background: rgba(255, 179, 64, 0.18); }
  [data-theme='dark'] .toast--info    .toast__icon { color: #38efdb; background: rgba(34, 230, 210, 0.18); }

  .toast__body {
    flex: 1;
    min-width: 0;
    word-break: break-word;
    font-weight: 500;
  }

  .toast__close {
    flex-shrink: 0;
    margin-left: auto;
    margin-top: -0.15rem;
    margin-right: -0.35rem;
    background: transparent;
    border: none;
    padding: 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-mute);
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s, background-color 0.15s;
  }
  .toast__close:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.06);
  }
  [data-theme='dark'] .toast__close:hover {
    background: rgba(255, 255, 255, 0.1);
  }

  .toast.is-leaving {
    opacity: 0;
    transform: translateX(24px) scale(0.96);
    transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
  }

  @keyframes toastRise {
    from {
      opacity: 0;
      transform: translateY(16px) scale(0.96);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }

  @media (max-width: 640px) {
    .toast-stack {
      left: 1rem;
      right: 1rem;
      bottom: 1rem;
      width: auto;
    }
  }

  /* ── Progress ────────────────────────────────────────────────────────── */
  .progress {
    height: 6px;
    border-radius: 99px;
    background: #e2e8f0;
    overflow: hidden;
  }
  .progress__bar {
    height: 100%;
    border-radius: inherit;
    background: var(--volt-500);
    transition: width 0.7s var(--ease-out);
  }
  .progress--danger  .progress__bar { background: var(--danger); }
  .progress--success .progress__bar { background: var(--success); }

  [data-theme='dark'] .progress { background: rgb(255 255 255 / 0.07); }
  [data-theme='dark'] .progress__bar { background: linear-gradient(90deg, var(--volt-500), var(--cyan-400)); }
  [data-theme='dark'] .progress--danger  .progress__bar { background: linear-gradient(90deg, var(--pink-500), var(--warning)); }
  [data-theme='dark'] .progress--success .progress__bar { background: linear-gradient(90deg, var(--success), var(--cyan-400)); }

  /* ── Avatars ─────────────────────────────────────────────────────────── */
  .avatar {
    --size: 2.4rem;
    width: var(--size);
    height: var(--size);
    border-radius: 50%;
    object-fit: cover;
    flex: none;
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, var(--volt-500), #1e293b);
    border: 1px solid var(--border-color);
    font-family: var(--font-display);
    font-size: calc(var(--size) * 0.36);
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.02em;
    overflow: hidden;
  }
  .avatar--sm { --size: 1.9rem; }
  .avatar--lg { --size: 3.4rem; }
  .avatar--xl { --size: 5.5rem; }

  .avatar-stack { display: flex; }
  .avatar-stack .avatar { margin-left: -0.6rem; border: 2px solid var(--bg); }
  .avatar-stack .avatar:first-child { margin-left: 0; }

  /* ── Tables ──────────────────────────────────────────────────────────── */
  .table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border-color); }
  .table { font-size: var(--step--1); min-width: 100%; }
  .table th {
    text-align: left;
    padding: 0.8rem 1rem;
    font-family: var(--font-mono);
    font-size: var(--step--2);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-mute);
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
  }
  .table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
  .table tbody tr:last-child td { border-bottom: 0; }
  .table tbody tr { transition: background-color 0.15s; }
  .table tbody tr:hover { background: var(--surface-hover); }
  .table--clickable tbody tr { cursor: pointer; }

  [data-theme='dark'] .table-wrap { border-color: var(--hairline); }
  [data-theme='dark'] .table th { background: rgb(255 255 255 / 0.025); border-bottom-color: var(--hairline); }
  [data-theme='dark'] .table td { border-bottom-color: var(--hairline-soft); }
  [data-theme='dark'] .table tbody tr:hover { background: rgb(255 255 255 / 0.022); }

  /* ── Empty state ─────────────────────────────────────────────────────── */
  .empty {
    display: grid;
    place-items: center;
    gap: 0.7rem;
    padding: clamp(2.5rem, 6vw, 4.5rem) 1.5rem;
    text-align: center;
    color: var(--text-mute);
  }
  .empty__icon {
    width: 3.4rem; height: 3.4rem;
    display: grid; place-items: center;
    border-radius: var(--radius);
    background: var(--surface-solid);
    border: 1px solid var(--border-color);
    color: var(--volt-500);
  }
  .empty h3 { font-size: var(--step-1); color: var(--text); }
  [data-theme='dark'] .empty__icon { background: var(--surface); border-color: var(--hairline); color: var(--volt-300); }

  /* ── Noise + aurora backdrop ─────────────────────────────────────────── */
  .noise {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: 0.02;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  }
  [data-theme='dark'] .noise {
    opacity: 0.035;
    mix-blend-mode: overlay;
  }

  .aurora {
    position: fixed;
    inset: -30vh -10vw auto;
    height: 90vh;
    z-index: 0;
    pointer-events: none;
    filter: blur(100px);
    opacity: 0.22;
  }
  .aurora span {
    position: absolute;
    border-radius: 50%;
    animation: drift 26s var(--ease-in-out) infinite;
  }
  .aurora span:nth-child(1) {
    width: 46vw; height: 46vw; left: 4%; top: 8%;
    background: radial-gradient(circle, rgba(99, 66, 235, 0.35), transparent 68%);
  }
  .aurora span:nth-child(2) {
    width: 38vw; height: 38vw; right: 6%; top: 0;
    background: radial-gradient(circle, rgba(2, 132, 199, 0.3), transparent 68%);
    animation-delay: -9s;
  }
  .aurora span:nth-child(3) {
    width: 30vw; height: 30vw; left: 42%; top: 30%;
    background: radial-gradient(circle, rgba(225, 29, 72, 0.2), transparent 68%);
    animation-delay: -17s;
  }

  [data-theme='dark'] .aurora {
    opacity: 0.5;
    filter: blur(90px);
  }
  [data-theme='dark'] .aurora span {
    mix-blend-mode: screen;
  }
  [data-theme='dark'] .aurora span:nth-child(1) {
    background: radial-gradient(circle, rgb(124 92 255 / 0.75), transparent 68%);
  }
  [data-theme='dark'] .aurora span:nth-child(2) {
    background: radial-gradient(circle, rgb(34 230 210 / 0.55), transparent 68%);
  }
  [data-theme='dark'] .aurora span:nth-child(3) {
    background: radial-gradient(circle, rgb(255 61 129 / 0.42), transparent 68%);
  }

  /* Faint circuit grid */
  .grid-lines {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
      linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
      linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 25%, transparent 75%);
  }
  [data-theme='dark'] .grid-lines {
    background-image:
      linear-gradient(rgb(255 255 255 / 0.028) 1px, transparent 1px),
      linear-gradient(90deg, rgb(255 255 255 / 0.028) 1px, transparent 1px);
  }

  /* ── Theme toggle ────────────────────────────────────────────────────── */
  .theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: var(--surface-card);
    color: var(--text-soft);
    cursor: pointer;
    transition: color 0.2s, background-color 0.2s, border-color 0.2s, transform 0.2s var(--ease-spring);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  }
  .theme-toggle:hover {
    color: var(--text);
    background: var(--surface-hover);
    border-color: var(--ink-400);
    transform: scale(1.05);
  }
  .theme-toggle__sun,
  .theme-toggle__moon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }
  :root:not([data-theme='dark']) .theme-toggle__sun,
  [data-theme='light'] .theme-toggle__sun {
    display: none !important;
  }
  :root:not([data-theme='dark']) .theme-toggle__moon,
  [data-theme='light'] .theme-toggle__moon {
    display: inline-flex !important;
  }
  [data-theme='dark'] .theme-toggle__sun {
    display: inline-flex !important;
  }
  [data-theme='dark'] .theme-toggle__moon {
    display: none !important;
  }

  /* Logo contrast adaptation */
  :root:not([data-theme='dark']) .logo__img,
  [data-theme='light'] .logo__img {
    filter: brightness(0) saturate(100%);
  }
  [data-theme='dark'] .logo__img {
    filter: none;
  }
}

@layer utilities {
  .flex        { display: flex; }
  .grid        { display: grid; }
  .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; }
  .flex-wrap   { flex-wrap: wrap; }
  .flex-col    { flex-direction: column; }
  .flex-1      { flex: 1; }
  .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-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }

  .mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); }
  .mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); }
  .mt-6 { margin-top: var(--sp-6); } .mt-7 { margin-top: var(--sp-7); }
  .mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); }
  .mb-4 { margin-bottom: var(--sp-4); } .mb-5 { margin-bottom: var(--sp-5); }
  .mb-6 { margin-bottom: var(--sp-6); }

  .text-center { text-align: center; }
  .text-right  { text-align: right; }
  .text-soft   { color: var(--text-soft); }
  .text-mute   { color: var(--text-mute); }
  .text-volt   { color: var(--volt-300); }
  .text-cyan   { color: var(--cyan-400); }
  .text-danger { color: var(--danger); }
  .text-success{ color: var(--success); }
  .text-warning{ color: var(--warning); }

  .fs--2 { font-size: var(--step--2); } .fs--1 { font-size: var(--step--1); }
  .fs-1  { font-size: var(--step-1); }  .fs-2  { font-size: var(--step-2); }
  .fs-3  { font-size: var(--step-3); }

  .mono { font-family: var(--font-mono); }
  .display { font-family: var(--font-display); }
  .bold { font-weight: 650; }
  .semi { font-weight: 550; }
  .upper { text-transform: uppercase; letter-spacing: 0.12em; }
  .nowrap { white-space: nowrap; }
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .relative { position: relative; }
  .w-full { width: 100%; }
  .hidden { display: none !important; }

  .clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

  .sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }

  .skip-link {
    position: absolute; top: 0.5rem; left: 0.5rem; z-index: 999;
    padding: 0.6rem 1rem; border-radius: var(--radius-sm);
    background: var(--volt-500); color: #fff; font-weight: 600;
    transform: translateY(-200%);
    transition: transform 0.2s;
  }
  .skip-link:focus { transform: translateY(0); }
}

/* ── Keyframes ───────────────────────────────────────────────────────────── */
@keyframes drift {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  33%      { transform: translate3d(4vw, 3vh, 0) scale(1.12); }
  66%      { transform: translate3d(-3vw, -2vh, 0) scale(0.94); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
  50%      { opacity: 0.6; box-shadow: 0 0 0 4px rgb(255 255 255 / 0); }
}

@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Scroll-reveal: elements start hidden only when JS is present to reveal them */
.js [data-reveal] { opacity: 0; transform: translateY(22px); }
.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

/* Brand Logo */
.logo {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  line-height: 1;
}
.logo__img {
  height: 46px;
  width: auto;
  max-width: 220px;
  display: block;
  object-fit: contain;
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.2s ease;
}
.logo:hover .logo__img {
  opacity: 0.95;
  transform: translateY(-1px);
  filter: drop-shadow(0 0 16px rgb(124 92 255 / 0.5));
}
