/* ==========================================================================
   What's it to ya?  —  whats-it-to-ya.com
   Design system + component library
   Single source of truth for all visual styling.
   To rebrand the site, edit the tokens in :root below.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS
   -------------------------------------------------------------------------- */
:root {
  /* Brand */
  --brand-900: #1e1b4b;
  --brand-800: #2e1065;
  --brand-700: #4c1d95;
  --brand-600: #6d28d9;
  --brand-500: #8b5cf6;
  --brand-300: #c4b5fd;
  --brand-100: #ede9fe;

  --accent-600: #d97706;
  --accent-500: #f59e0b;
  --accent-300: #fcd34d;
  --accent-100: #fef3c7;

  /* Neutrals */
  --ink-900: #0f1020;
  --ink-800: #1c1d33;
  --ink-700: #2f3050;
  --ink-500: #5b5d7e;
  --ink-400: #8386a5;
  --ink-300: #b9bbd0;
  --ink-200: #dcdde8;
  --ink-100: #eef0f6;
  --ink-050: #f7f8fc;
  --white: #ffffff;

  /* Semantic */
  --ok-600: #059669;
  --ok-100: #d1fae5;
  --warn-600: #d97706;
  --warn-100: #fef3c7;
  --err-600: #dc2626;
  --err-100: #fee2e2;
  --info-600: #2563eb;
  --info-100: #dbeafe;

  /* Applied surfaces */
  --bg: var(--ink-050);
  --surface: var(--white);
  --surface-2: var(--ink-050);
  --surface-3: var(--ink-100);
  --border: var(--ink-200);
  --border-strong: var(--ink-300);
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --text-subtle: var(--ink-400);
  --link: var(--brand-600);
  --link-hover: var(--brand-700);

  /* Type */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.5rem;
  --fs-2xl: 1.875rem;
  --fs-3xl: 2.25rem;
  --fs-4xl: 3rem;
  --fs-5xl: 3.75rem;

  --lh-tight: 1.15;
  --lh-snug: 1.35;
  --lh-normal: 1.6;
  --lh-loose: 1.75;

  /* Space (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;
  --s-20: 5rem;
  --s-24: 6rem;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Elevation */
  --sh-xs: 0 1px 2px rgba(15, 16, 32, 0.06);
  --sh-sm: 0 1px 3px rgba(15, 16, 32, 0.08), 0 1px 2px rgba(15, 16, 32, 0.04);
  --sh-md: 0 4px 12px rgba(15, 16, 32, 0.08), 0 2px 4px rgba(15, 16, 32, 0.04);
  --sh-lg: 0 12px 28px rgba(15, 16, 32, 0.12), 0 4px 10px rgba(15, 16, 32, 0.06);
  --sh-xl: 0 24px 56px rgba(15, 16, 32, 0.16);
  --sh-focus: 0 0 0 3px var(--brand-300);

  /* Layout */
  --wrap: 1180px;
  --wrap-narrow: 760px;
  --header-h: 64px;

  /* Motion */
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 380ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode — opt-in via [data-theme="dark"], set by theme.js */
[data-theme="dark"] {
  --bg: #0b0c18;
  --surface: #14152a;
  --surface-2: #1b1d36;
  --surface-3: #232544;
  --border: #2a2c4d;
  --border-strong: #3a3d66;
  --text: #eef0f6;
  --text-muted: #a9adcc;
  --text-subtle: #8386a5;
  --link: var(--brand-300);
  --link-hover: #ddd6fe;
  --sh-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
  --sh-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --sh-lg: 0 12px 28px rgba(0, 0, 0, 0.55);
  --sh-xl: 0 24px 56px rgba(0, 0, 0, 0.6);
}

/* --------------------------------------------------------------------------
   2. RESET
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background var(--t-base), color var(--t-base);
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--s-3);
  line-height: var(--lh-tight);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p { margin: 0 0 var(--s-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--link-hover); text-decoration: underline; }

img, svg, video, iframe { max-width: 100%; }
img, svg, video { height: auto; display: block; }

ul, ol { margin: 0 0 var(--s-4); padding-left: var(--s-5); }
li { margin-bottom: var(--s-2); }

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}
code {
  background: var(--surface-3);
  padding: 0.15em 0.4em;
  border-radius: var(--r-sm);
  color: var(--brand-700);
}
[data-theme="dark"] code { color: var(--brand-300); }
pre {
  background: var(--ink-900);
  color: var(--ink-100);
  padding: var(--s-4);
  border-radius: var(--r-md);
  overflow-x: auto;
  line-height: var(--lh-snug);
}
pre code { background: none; padding: 0; color: inherit; }

kbd {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  padding: 0.1em 0.4em;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--s-10) 0;
}

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--brand-600);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--brand-300); color: var(--brand-900); }

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

/* --------------------------------------------------------------------------
   3. LAYOUT
   -------------------------------------------------------------------------- */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--s-5);
}
.wrap--narrow { max-width: var(--wrap-narrow); }

main { flex: 1 0 auto; }

.section { padding-block: var(--s-12); }
.section--tight { padding-block: var(--s-8); }
.section--alt { background: var(--surface-2); }

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--s-4);
  z-index: 200;
  background: var(--brand-700);
  color: var(--white);
  padding: var(--s-3) var(--s-5);
  border-radius: 0 0 var(--r-md) var(--r-md);
  font-weight: 600;
  font-size: var(--fs-sm);
}
.skip-link:focus { top: 0; color: var(--white); text-decoration: none; }

/* --------------------------------------------------------------------------
   4. HEADER + NAV
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
@supports not (backdrop-filter: blur(1px)) {
  .site-header { background: var(--surface); }
}

.site-header__inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--s-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  font-weight: 800;
  font-size: var(--fs-md);
  letter-spacing: -0.03em;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.brand:hover { color: var(--text); text-decoration: none; }
.brand__mark { width: 32px; height: 32px; flex-shrink: 0; }
.brand__text { display: inline-block; }
.brand__text em {
  font-style: normal;
  color: var(--accent-500);
}

/* Primary tabs */
.tabs {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin-left: auto;
  list-style: none;
  padding: 0;
  margin-bottom: 0;
}
.tabs li { margin: 0; }
.tabs__link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-full);
  font-size: var(--fs-base);
  font-weight: 550;
  color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.tabs__link:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}
.tabs__link[aria-current="page"] {
  background: var(--brand-600);
  color: var(--white);
}
.tabs__link[aria-current="page"]:hover { background: var(--brand-700); color: var(--white); }
.tabs__icon { width: 16px; height: 16px; opacity: 0.85; }

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-shrink: 0;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-muted);
  transition: all var(--t-fast);
  position: relative;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
}
.icon-btn svg { width: 18px; height: 18px; }

.icon-btn__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--r-full);
  background: var(--accent-500);
  color: var(--ink-900);
  font-size: 10px;
  font-weight: 800;
  display: none;
  place-items: center;
  line-height: 18px;
  text-align: center;
}
.icon-btn__badge[data-count]:not([data-count="0"]) { display: grid; }

.nav-toggle { display: none; }

/* Mobile nav */
@media (max-width: 900px) {
  .nav-toggle { display: inline-grid; }
  .tabs {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--sh-lg);
    padding: var(--s-3);
    margin: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: max-height var(--t-slow), opacity var(--t-fast);
  }
  .tabs[data-nav-open="true"] {
    max-height: 70vh;
    opacity: 1;
    pointer-events: auto;
    overflow-y: auto;
  }
  .tabs__link {
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    font-size: var(--fs-md);
  }
  .brand__text { font-size: var(--fs-base); }
}

/* --------------------------------------------------------------------------
   5. BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn--primary {
  background: var(--brand-600);
  color: var(--white);
  box-shadow: var(--sh-sm);
}
.btn--primary:hover { background: var(--brand-700); color: var(--white); box-shadow: var(--sh-md); }

.btn--accent {
  background: var(--accent-500);
  color: var(--ink-900);
  box-shadow: var(--sh-sm);
}
.btn--accent:hover { background: var(--accent-600); color: var(--ink-900); box-shadow: var(--sh-md); }

.btn--outline {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn--outline:hover { background: var(--surface-3); color: var(--text); border-color: var(--brand-500); }

.btn--ghost { background: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }

.btn--sm { padding: var(--s-2) var(--s-3); font-size: var(--fs-sm); }
.btn--lg { padding: var(--s-4) var(--s-8); font-size: var(--fs-md); }
.btn--block { width: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  align-items: center;
}

/* --------------------------------------------------------------------------
   6. BADGES / PILLS / CHIPS
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 0.2em 0.65em;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge--free { background: var(--ok-100); color: var(--ok-600); }
.badge--paid { background: var(--accent-100); color: var(--accent-600); }
.badge--sub { background: var(--info-100); color: var(--info-600); }
.badge--owned { background: var(--ok-100); color: var(--ok-600); }
.badge--soon { background: var(--surface-3); color: var(--text-muted); }
.badge--beta { background: var(--brand-100); color: var(--brand-700); }
.badge--new { background: var(--err-100); color: var(--err-600); }

[data-theme="dark"] .badge--free,
[data-theme="dark"] .badge--owned { background: rgba(5,150,105,0.18); color: #34d399; }
[data-theme="dark"] .badge--paid { background: rgba(217,119,6,0.18); color: var(--accent-300); }
[data-theme="dark"] .badge--sub { background: rgba(37,99,235,0.18); color: #93c5fd; }
[data-theme="dark"] .badge--beta { background: rgba(109,40,217,0.22); color: var(--brand-300); }
[data-theme="dark"] .badge--new { background: rgba(220,38,38,0.18); color: #fca5a5; }

.tag {
  display: inline-block;
  padding: 0.15em 0.6em;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
}

.tag-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* Filter chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  list-style: none;
  padding: 0;
  margin: 0;
}
.chip {
  padding: var(--s-2) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 550;
  transition: all var(--t-fast);
}
.chip:hover { border-color: var(--brand-500); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: var(--white);
}

/* --------------------------------------------------------------------------
   7. CARDS
   -------------------------------------------------------------------------- */
.grid {
  display: grid;
  gap: var(--s-5);
}
.grid--1 { grid-template-columns: 1fr; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid--books { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s-8); }

.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.card--hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg);
  border-color: var(--brand-300);
}
.card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--brand-800), var(--brand-600));
  display: grid;
  place-items: center;
  overflow: hidden;
}
.card__media img { width: 100%; height: 100%; object-fit: cover; }
.card__media-icon { width: 52px; height: 52px; color: rgba(255, 255, 255, 0.9); }
.card__body {
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  flex: 1;
}
.card__eyebrow {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.card__title {
  font-size: var(--fs-md);
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}
.card__title a { color: var(--text); }
.card__title a:hover { color: var(--link); text-decoration: none; }
.card__text {
  color: var(--text-muted);
  font-size: var(--fs-base);
  margin: 0;
  flex: 1;
}
.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
  font-size: var(--fs-xs);
  color: var(--text-subtle);
}
.card__meta span { display: inline-flex; align-items: center; gap: var(--s-1); }
.card__meta svg { width: 13px; height: 13px; }
.card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  margin-top: auto;
  flex-wrap: wrap;
}

.price {
  font-size: var(--fs-lg);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}
.price small {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--text-subtle);
  letter-spacing: 0;
}
.price--free { color: var(--ok-600); }

/* --------------------------------------------------------------------------
   8. HERO
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(1000px 500px at 12% -10%, rgba(139, 92, 246, 0.22), transparent 65%),
    radial-gradient(800px 420px at 92% 8%, rgba(245, 158, 11, 0.16), transparent 62%),
    linear-gradient(170deg, var(--brand-900) 0%, #241a5e 48%, var(--brand-700) 100%);
  color: #f4f2ff;
  padding-block: var(--s-24) var(--s-20);
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 35%, #000 25%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 35%, #000 25%, transparent 72%);
  pointer-events: none;
}
.hero__inner { position: relative; z-index: 1; text-align: center; }
.hero__kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent-300);
  margin-bottom: var(--s-6);
  backdrop-filter: blur(6px);
}
.hero h1 {
  font-size: clamp(2.25rem, 6vw, var(--fs-5xl));
  color: var(--white);
  margin-bottom: var(--s-5);
  letter-spacing: -0.04em;
  text-wrap: balance;
}
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent-300), var(--accent-500));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero__lede {
  font-size: var(--fs-md);
  color: rgba(244, 242, 255, 0.82);
  max-width: 62ch;
  margin: 0 auto var(--s-8);
  line-height: var(--lh-loose);
  text-wrap: pretty;
}
.hero .btn-row { justify-content: center; }
.hero__stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-8);
  margin-top: var(--s-16);
  padding-top: var(--s-8);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.hero__stat { text-align: center; }
.hero__stat b {
  display: block;
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.03em;
}
.hero__stat span {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(244, 242, 255, 0.6);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   9. PAGE HEADER
   -------------------------------------------------------------------------- */
.page-head {
  padding-block: var(--s-12) var(--s-8);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.page-head__inner { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-6); flex-wrap: wrap; }
.page-head h1 {
  font-size: clamp(1.75rem, 4vw, var(--fs-3xl));
  margin-bottom: var(--s-3);
}
.page-head__lede {
  color: var(--text-muted);
  font-size: var(--fs-md);
  max-width: 68ch;
  margin: 0;
  line-height: var(--lh-loose);
  text-wrap: pretty;
}
.page-head__aside { flex-shrink: 0; }

.breadcrumb {
  display: flex;
  gap: var(--s-2);
  list-style: none;
  padding: 0;
  margin: 0 0 var(--s-4);
  font-size: var(--fs-sm);
  color: var(--text-subtle);
  flex-wrap: wrap;
}
.breadcrumb li { margin: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: var(--s-2); color: var(--border-strong); }

/* --------------------------------------------------------------------------
   10. TOOLBAR (search + filters)
   -------------------------------------------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-5) 0;
}
.search {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}
.search svg {
  position: absolute;
  left: var(--s-4);
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-subtle);
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: var(--s-3) var(--s-4) var(--s-3) var(--s-10);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.search input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--sh-focus);
}
.search input::placeholder { color: var(--text-subtle); }

.select {
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: var(--fs-base);
  cursor: pointer;
}
.select:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--sh-focus); }

.result-count {
  font-size: var(--fs-sm);
  color: var(--text-subtle);
  margin-left: auto;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   11. LIST ROWS (documents)
   -------------------------------------------------------------------------- */
.rows { display: flex; flex-direction: column; gap: var(--s-3); }

.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.row:hover {
  border-color: var(--brand-300);
  box-shadow: var(--sh-md);
  transform: translateX(2px);
}
.row__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  background: var(--brand-100);
  color: var(--brand-700);
  flex-shrink: 0;
}
[data-theme="dark"] .row__icon { background: rgba(109, 40, 217, 0.24); color: var(--brand-300); }
.row__icon svg { width: 21px; height: 21px; }
.row__main { min-width: 0; }
.row__title {
  font-weight: 650;
  font-size: var(--fs-md);
  margin: 0 0 var(--s-1);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.row__title a { color: var(--text); }
.row__desc {
  color: var(--text-muted);
  font-size: var(--fs-base);
  margin: 0 0 var(--s-2);
}
.row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-1) var(--s-4);
  font-size: var(--fs-xs);
  color: var(--text-subtle);
}
.row__meta span { display: inline-flex; align-items: center; gap: var(--s-1); }
.row__meta svg { width: 13px; height: 13px; flex-shrink: 0; }
.row__actions { display: flex; align-items: center; gap: var(--s-2); flex-shrink: 0; }

@media (max-width: 640px) {
  .row { grid-template-columns: auto 1fr; }
  .row__actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* --------------------------------------------------------------------------
   12. VIDEO GALLERY
   -------------------------------------------------------------------------- */
.video-card__thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--ink-800), var(--brand-800));
  cursor: pointer;
  border: 0;
  padding: 0;
  width: 100%;
  display: block;
  overflow: hidden;
}
.video-card__thumb img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform var(--t-slow), filter var(--t-base);
}
.card--hover:hover .video-card__thumb img { transform: scale(1.05); }
.video-card__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 16, 32, 0.28);
  transition: background var(--t-base);
}
.video-card__thumb:hover .video-card__play { background: rgba(15, 16, 32, 0.12); }
.video-card__play span {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--sh-lg);
  transition: transform var(--t-base);
}
.video-card__thumb:hover .video-card__play span { transform: scale(1.09); }
.video-card__play svg { width: 22px; height: 22px; color: var(--brand-700); margin-left: 3px; }
.video-card__duration {
  position: absolute;
  right: var(--s-2);
  bottom: var(--s-2);
  padding: 0.15em 0.5em;
  border-radius: var(--r-sm);
  background: rgba(15, 16, 32, 0.85);
  color: var(--white);
  font-size: var(--fs-xs);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.embed {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--ink-900);
  border-radius: var(--r-md);
  overflow: hidden;
}
.embed iframe, .embed video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* --------------------------------------------------------------------------
   13. BOOK CARDS
   -------------------------------------------------------------------------- */
.book { display: flex; flex-direction: column; gap: var(--s-4); }
.book__cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: var(--r-sm) var(--r-md) var(--r-md) var(--r-sm);
  overflow: hidden;
  background: linear-gradient(150deg, var(--brand-800), var(--brand-600));
  box-shadow: var(--sh-lg), -6px 0 0 -1px rgba(0,0,0,0.16) inset;
  transition: transform var(--t-slow), box-shadow var(--t-slow);
  display: block;
}
.book__cover::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 11px;
  background: linear-gradient(90deg, rgba(0,0,0,0.32), rgba(255,255,255,0.09) 62%, rgba(0,0,0,0.06));
  z-index: 2;
}
.book:hover .book__cover { transform: translateY(-6px) rotate(-0.8deg); box-shadow: var(--sh-xl); }
.book__cover img { width: 100%; height: 100%; object-fit: cover; }
.book__cover-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--s-6) var(--s-5) var(--s-6) var(--s-6);
  text-align: left;
  color: var(--white);
}
.book__cover-fallback b {
  font-family: var(--font-serif);
  font-size: var(--fs-lg);
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
  margin-bottom: var(--s-3);
}
.book__cover-fallback i {
  font-style: normal;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.72;
}
.book__lock {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  z-index: 3;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  background: rgba(15, 16, 32, 0.7);
  color: var(--accent-300);
  backdrop-filter: blur(4px);
}
.book__lock svg { width: 15px; height: 15px; }
.book__info { display: flex; flex-direction: column; gap: var(--s-2); }
.book__title {
  font-family: var(--font-serif);
  font-size: var(--fs-md);
  font-weight: 700;
  margin: 0;
  line-height: var(--lh-snug);
}
.book__author { font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }
.book__blurb { font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }

/* --------------------------------------------------------------------------
   14. EMPTY / LOADING / ERROR STATES
   -------------------------------------------------------------------------- */
.empty {
  text-align: center;
  padding: var(--s-16) var(--s-6);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
}
.empty__icon {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--s-5);
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  background: var(--surface-3);
  color: var(--text-subtle);
}
.empty__icon svg { width: 28px; height: 28px; }
.empty h3 { margin-bottom: var(--s-2); }
.empty p { color: var(--text-muted); max-width: 48ch; margin: 0 auto var(--s-5); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--r-sm);
  color: transparent !important;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-card { height: 320px; border-radius: var(--r-lg); }

.notice {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-base);
  align-items: flex-start;
}
.notice svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.notice--info { background: var(--info-100); border-color: transparent; color: #1e40af; }
.notice--warn { background: var(--warn-100); border-color: transparent; color: #92400e; }
.notice--ok { background: var(--ok-100); border-color: transparent; color: #065f46; }
[data-theme="dark"] .notice--info { background: rgba(37,99,235,0.14); color: #93c5fd; }
[data-theme="dark"] .notice--warn { background: rgba(217,119,6,0.14); color: var(--accent-300); }
[data-theme="dark"] .notice--ok { background: rgba(5,150,105,0.14); color: #6ee7b7; }

/* --------------------------------------------------------------------------
   15. MODAL / DRAWER
   -------------------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: var(--s-5);
  background: rgba(10, 10, 24, 0.62);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}
.modal[data-open="true"] { opacity: 1; pointer-events: auto; }
.modal__panel {
  width: 100%;
  max-width: 880px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  transform: translateY(12px) scale(0.985);
  transition: transform var(--t-base);
}
.modal[data-open="true"] .modal__panel { transform: none; }
.modal__panel--sm { max-width: 460px; }
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.modal__head h2 { margin: 0; font-size: var(--fs-lg); }
.modal__body { padding: var(--s-6); }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-6);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   16. FOOTER
   -------------------------------------------------------------------------- */
.site-footer {
  margin-top: var(--s-20);
  background: var(--ink-900);
  color: var(--ink-300);
  padding-block: var(--s-12) var(--s-6);
  font-size: var(--fs-base);
}
.site-footer a { color: var(--ink-200); }
.site-footer a:hover { color: var(--white); }
.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr repeat(3, 1fr);
  gap: var(--s-8);
  padding-bottom: var(--s-10);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--s-6); }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
}
.footer-brand .brand { color: var(--white); margin-bottom: var(--s-4); }
.footer-brand p { color: var(--ink-400); font-size: var(--fs-sm); max-width: 34ch; }
.footer-col h4 {
  color: var(--white);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: var(--s-4);
}
.footer-col ul { list-style: none; padding: 0; margin: 0; }
.footer-col li { margin-bottom: var(--s-2); font-size: var(--fs-sm); }
.footer-bottom {
  padding-top: var(--s-6);
  display: flex;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--ink-500);
}

/* --------------------------------------------------------------------------
   17. PROSE (docs / legal / long-form)
   -------------------------------------------------------------------------- */
.prose { max-width: 72ch; font-size: var(--fs-md); line-height: var(--lh-loose); }
.prose > h2 { margin-top: var(--s-10); padding-bottom: var(--s-2); border-bottom: 1px solid var(--border); }
.prose > h3 { margin-top: var(--s-8); }
.prose ul, .prose ol { padding-left: var(--s-6); }
.prose blockquote {
  margin: var(--s-6) 0;
  padding: var(--s-2) var(--s-5);
  border-left: 3px solid var(--brand-500);
  color: var(--text-muted);
  font-style: italic;
}
.prose table { width: 100%; border-collapse: collapse; margin: var(--s-6) 0; font-size: var(--fs-base); }
.prose th, .prose td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); text-align: left; }
.prose th { background: var(--surface-2); font-weight: 650; }

/* Wide tables must scroll inside their column, never widen the page. */
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 460px; }
.prose .table-scroll table { margin: var(--s-6) 0; }

/* Long unbroken strings (emails, URLs, code) must not force overflow. */
.prose { overflow-wrap: break-word; word-break: break-word; }
.prose code { overflow-wrap: anywhere; }

/* Legal / long-form document layout ------------------------------------- */
.legal { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: var(--s-12); align-items: start; }
@media (max-width: 900px) { .legal { grid-template-columns: minmax(0, 1fr); gap: var(--s-8); } }
/* Grid items default to min-width:auto, which floors them at their min-content
   width. A wide table would then widen the whole page instead of scrolling
   inside its own wrapper. Explicit 0 lets them shrink. */
.legal > * { min-width: 0; }

.legal__toc {
  position: sticky; top: calc(var(--header-h) + var(--s-6));
  padding: var(--s-5);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
}
@media (max-width: 900px) { .legal__toc { position: static; } }
.legal__toc h2 {
  margin: 0 0 var(--s-3);
  font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-subtle);
}
.legal__toc ol { list-style: none; padding: 0; margin: 0; counter-reset: toc; }
.legal__toc li { counter-increment: toc; margin-bottom: var(--s-1); }
.legal__toc a {
  display: block; padding: var(--s-1) 0;
  color: var(--text-muted); text-decoration: none; line-height: 1.35;
}
.legal__toc a::before { content: counter(toc) ". "; color: var(--text-subtle); }
.legal__toc a:hover { color: var(--brand-600); }

.legal__meta {
  display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5);
  margin: 0 0 var(--s-8);
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs); color: var(--text-subtle);
}
.legal__meta b { color: var(--text); font-weight: 600; }

.prose h2[id] { scroll-margin-top: calc(var(--header-h) + var(--s-6)); }

/* A short "you must edit this" flag for template legal copy. */
.fillme {
  display: inline-block;
  padding: 1px 7px;
  border-radius: var(--r-sm);
  background: var(--warn-100);
  color: #92400e;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: .85em;
  font-weight: 600;
  /* Short values stay on one line; long template sentences must wrap. */
  overflow-wrap: break-word;
  max-width: 100%;
}
[data-theme="dark"] .fillme { background: rgba(217,119,6,.18); color: var(--accent-300); }

/* --------------------------------------------------------------------------
   18. UTILITIES
   -------------------------------------------------------------------------- */
/* Defensive: inline SVG icons inside text-level elements must never
   balloon to their intrinsic size if a specific rule is missing. */
.badge svg, .tag svg, .chip svg, .row__title svg,
.card__eyebrow svg, .breadcrumb svg, .folio-count svg, .result-count svg {
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  vertical-align: -0.125em;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--s-4); }
.mt-6 { margin-top: var(--s-6); }
.mt-8 { margin-top: var(--s-8); }
.mb-6 { margin-bottom: var(--s-6); }
.mb-8 { margin-bottom: var(--s-8); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--s-2); }
.gap-4 { gap: var(--s-4); }
.wrap-gap { flex-wrap: wrap; }
.full { width: 100%; }

/* --------------------------------------------------------------------------
   19. TOASTS
   -------------------------------------------------------------------------- */
.toasts {
  position: fixed;
  bottom: var(--s-5);
  right: var(--s-5);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  max-width: min(380px, calc(100vw - 2 * var(--s-5)));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  background: var(--ink-900);
  color: var(--ink-100);
  box-shadow: var(--sh-xl);
  font-size: var(--fs-base);
  animation: toast-in var(--t-base) ease-out;
}
.toast svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.toast--ok svg { color: #34d399; }
.toast--err svg { color: #f87171; }
.toast--info svg { color: #93c5fd; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   20. PRINT
   -------------------------------------------------------------------------- */
@page { size: Letter; margin: 0.75in; }

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --text-muted: #333; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-header, .site-footer, .toolbar, .toasts, .nav-toggle,
  .header-actions, .btn, .chips, .hero__stats { display: none !important; }
  .hero { background: #fff !important; color: #000; padding-block: 0 var(--s-6); }
  .hero h1, .hero__lede { color: #000 !important; }
  .hero h1 em { -webkit-text-fill-color: #000; }
  .hero::after { display: none; }
  .card, .row, .empty {
    border: 1px solid #ccc;
    box-shadow: none;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  a { color: #000; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 9pt; color: #555; }
  .grid { display: block; }
  .card { margin-bottom: 12pt; }
  h1, h2, h3 { break-after: avoid; page-break-after: avoid; }
}
