/* ==========================================================================
   SpiderStream design system — v1 tokens and base components
   Mobile-first, dark surfaces, restrained accent. No preprocessor.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #070709;
  --bg-elev-1: #0f0f12;
  --bg-elev-2: #16161a;
  --bg-elev-3: #1f1f24;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);

  /* Text */
  --text: #f4f3f1;
  --text-muted: #9d9ca4;
  --text-faint: #65646c;

  /* Accent (electric teal) and semantic colors */
  --accent: #d8232f;
  --accent-strong: #b81d27;
  --accent-ink: #ffffff;
  --live: #d8232f;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #fb7185;

  /* Focus ring */
  --ring: 0 0 0 3px rgba(216, 35, 47, 0.45);

  /* Typography */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --text-3xl: clamp(2rem, 1.4rem + 2.5vw, 3rem);
  --leading: 1.55;

  /* Spacing scale (4px base) */
  --s-1: 0.25rem;
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-5: 1.25rem;
  --s-6: 1.5rem;
  --s-8: 2rem;
  --s-10: 2.5rem;
  --s-12: 3rem;
  --s-16: 4rem;

  /* Radii, shadows, motion */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-2: 0 2px 4px rgba(0, 0, 0, 0.45), 0 16px 40px -16px rgba(0, 0, 0, 0.7);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 160ms;

  /* Layout */
  --container: 72rem;
  --gutter: 1rem;
  --header-h: 3.75rem;
  --tap: 44px;

  /* Safe areas (notched devices) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  color-scheme: dark;
}

@media (min-width: 48em) {
  :root { --gutter: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --dur: 0ms; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
.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; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; font-weight: 650; }
p { margin: 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }
::selection { background: rgba(216, 35, 47, 0.35); }

.skip-link {
  position: absolute; left: var(--s-4); top: -100px;
  padding: var(--s-2) var(--s-3); background: var(--accent); color: var(--accent-ink);
  border-radius: var(--r-sm); font-weight: 600; z-index: 100;
}
.skip-link:focus { top: var(--s-2); }

.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.page { flex: 1 0 auto; padding-bottom: calc(var(--s-12) + var(--safe-bottom)); }
.section { padding-block: var(--s-10); }
.section--tight { margin-top: var(--s-6); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: var(--text-sm); }
.link { color: var(--accent); font-weight: 500; }

/* --------------------------------------------------------------------------
   Header & navigation
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner { display: flex; align-items: center; gap: var(--s-4); height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--text); font-weight: 700; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand__mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-md); background: var(--accent); color: var(--accent-ink); }
.brand__name { font-size: var(--text-lg); }
.site-nav { display: none; gap: var(--s-1); margin-left: var(--s-4); }
@media (min-width: 48em) { .site-nav { display: flex; } }
.site-nav__link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--s-3);
  border-radius: var(--r-md); color: var(--text-muted); font-weight: 500;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.site-nav__link:hover { color: var(--text); background: var(--bg-elev-2); text-decoration: none; }
.site-nav__link.is-active { color: var(--text); background: var(--bg-elev-2); }
.site-header__actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }

.menu { position: relative; }
.menu__trigger { list-style: none; display: inline-flex; align-items: center; gap: var(--s-2); }
.menu__trigger::-webkit-details-marker { display: none; }
.menu__label { display: none; }
@media (min-width: 40em) { .menu__label { display: inline; } }
.avatar { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--bg-elev-3); color: var(--text); font-size: var(--text-sm); font-weight: 700; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 12rem;
  background: var(--bg-elev-2); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-2); padding: var(--s-1); z-index: 60;
}
.menu__item {
  display: block; width: 100%; text-align: left; padding: var(--s-2) var(--s-3); border: 0; background: transparent;
  color: var(--text); border-radius: var(--r-sm); min-height: 40px;
}
.menu__item:hover { background: var(--bg-elev-3); text-decoration: none; }
.menu__item--danger { color: var(--danger); }

.site-footer { border-top: 1px solid var(--border); padding-block: var(--s-6); padding-bottom: calc(var(--s-6) + var(--safe-bottom)); font-size: var(--text-sm); }
.site-footer__inner { display: flex; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 0 var(--s-5); border-radius: var(--r-md);
  border: 1px solid transparent; font-weight: 600; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-strong); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--bg-elev-2); }
.btn--danger { background: transparent; color: var(--danger); border-color: rgba(251, 113, 133, 0.4); }
.btn--sm { min-height: 40px; padding: 0 var(--s-3); font-size: var(--text-sm); }
@media (pointer: coarse) { .btn--sm { min-height: var(--tap); } }
.btn--lg { min-height: 52px; padding: 0 var(--s-6); font-size: var(--text-lg); }
.btn--block { width: 100%; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form { display: grid; gap: var(--s-5); }
.field { display: grid; gap: var(--s-2); }
.field__row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s-3); }
.label { font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); }
.input {
  width: 100%; min-height: var(--tap); padding: 0 var(--s-4);
  background: var(--bg-elev-1); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input::placeholder { color: var(--text-faint); }
.input:focus-visible { border-color: var(--accent); box-shadow: var(--ring); }
.input.is-invalid { border-color: var(--danger); }
.field__hint { font-size: var(--text-xs); color: var(--text-faint); }
.field__error { font-size: var(--text-sm); color: var(--danger); }
.checkbox { display: flex; align-items: center; gap: var(--s-3); min-height: var(--tap); color: var(--text-muted); font-size: var(--text-sm); cursor: pointer; }
.checkbox input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

/* --------------------------------------------------------------------------
   Cards, grids, badges, alerts
   -------------------------------------------------------------------------- */
.card {
  background: var(--bg-elev-1); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: var(--s-6); box-shadow: var(--shadow-1);
}
.card__icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--bg-elev-3); color: var(--accent); margin-bottom: var(--s-4); font-size: var(--text-lg); }
.card__title { font-size: var(--text-lg); margin-bottom: var(--s-2); }
.card__body { color: var(--text-muted); }
.grid { display: grid; gap: var(--s-4); }
@media (min-width: 40em) { .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 48em) { .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.badge { display: inline-flex; align-items: center; gap: var(--s-1); padding: 2px 10px; border-radius: var(--r-pill); font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
.badge--muted { background: var(--bg-elev-3); color: var(--text-muted); }
.badge--accent { background: rgba(216, 35, 47, 0.16); color: #ff6b74; }
.badge--live { background: rgba(244, 63, 94, 0.15); color: var(--live); }
.alert { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid; margin-top: var(--s-4); font-size: var(--text-sm); }
.alert--success { background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.35); color: var(--success); }
.alert--danger { background: rgba(251, 113, 133, 0.1); border-color: rgba(251, 113, 133, 0.35); color: var(--danger); }
.dl { display: grid; gap: var(--s-3); margin: 0; }
.dl > div { display: flex; justify-content: space-between; gap: var(--s-4); border-bottom: 1px solid var(--border); padding-bottom: var(--s-2); }
.dl dt { color: var(--text-muted); font-size: var(--text-sm); }
.dl dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.stat { display: grid; gap: var(--s-1); }
.stat__label { color: var(--text-muted); font-size: var(--text-sm); }
.stat__value { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -0.02em; }

/* --------------------------------------------------------------------------
   Page scaffolding
   -------------------------------------------------------------------------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-8); }
@media (max-width: 40em) {
  .page-header { flex-direction: column; align-items: stretch; gap: var(--s-3); }
  .page-header__actions .btn { flex: 1 1 auto; }
}
.page-title { font-size: var(--text-2xl); }
.eyebrow { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--accent); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: var(--s-2); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 4px rgba(216, 35, 47, 0.2); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(216, 35, 47, 0.25); } 50% { box-shadow: 0 0 0 7px rgba(216, 35, 47, 0); } }

.hero { padding-block: var(--s-12) var(--s-8); position: relative; isolation: isolate; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 50% at 20% 0%, rgba(216, 35, 47, 0.10), transparent 70%),
    transparent;
}
.hero__inner { max-width: 44rem; }
.hero__title { font-size: var(--text-3xl); margin-block: var(--s-3) var(--s-4); }
.hero__lead { color: var(--text-muted); font-size: var(--text-lg); max-width: 36rem; }
.hero__actions { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-8); }
@media (max-width: 30em) { .hero__actions .btn { width: 100%; } }

.auth { display: grid; place-items: center; padding-block: var(--s-8); gap: var(--s-4); }
.auth__card { width: 100%; max-width: 26rem; }
.auth__header { margin-bottom: var(--s-6); }
.auth__title { font-size: var(--text-xl); margin-bottom: var(--s-1); }
.auth__footer { font-size: var(--text-sm); text-align: center; }
.body--auth .page { display: flex; flex-direction: column; justify-content: center; }

.error-page { text-align: center; display: grid; gap: var(--s-4); justify-items: center; padding-block: var(--s-16); }

/* Mini lists (dashboard favourites / recent) */
.mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-1); }
.mini-list__item { display: flex; align-items: center; gap: var(--s-3); min-height: var(--tap); padding: var(--s-1) var(--s-2); border-radius: var(--r-md); color: var(--text); }
.mini-list__item:hover { background: var(--bg-elev-2); text-decoration: none; }
.mini-list__logo { width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--bg-elev-3); display: grid; place-items: center; font-weight: 700; color: var(--text-muted); overflow: hidden; flex: 0 0 auto; }
.mini-list__logo img { width: 100%; height: 100%; object-fit: contain; }

/* Plans */
.page-header--center { justify-content: center; text-align: center; }
.plans { align-items: stretch; }
.plan { position: relative; display: flex; flex-direction: column; gap: var(--s-3); }
.plan--featured { border-color: rgba(216, 35, 47, 0.6); box-shadow: 0 0 0 1px rgba(216, 35, 47, 0.6), var(--shadow-2); }
.plan__badge { position: absolute; top: var(--s-4); right: var(--s-4); }
.plan__price { font-size: var(--text-2xl); letter-spacing: -0.02em; }
.plan__price strong { font-weight: 700; }
.plan__features { margin: 0 0 auto; padding-left: 1.2em; color: var(--text-muted); display: grid; gap: var(--s-1); font-size: var(--text-sm); }

/* Pagination */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); font-size: var(--text-sm); }
.pager__summary { margin: 0; }
.pager__list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-1); }
.pager__btn, .pager__page { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; min-height: 40px; padding: 0 var(--s-3); border-radius: var(--r-md); border: 1px solid var(--border-strong); color: var(--text); font-weight: 500; }
.pager__btn:hover, .pager__page:hover { background: var(--bg-elev-2); text-decoration: none; }
.pager__page.is-current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pager__btn.is-disabled { opacity: 0.4; pointer-events: none; }
.pager__gap { display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--s-2); color: var(--text-faint); }
