/* ========== DESIGN SYSTEM — LIGHT MODE ========== */
:root {
  color-scheme: light;

  /* Backgrounds */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e8eaed;
  --line: #e2e5ea;
  --line-strong: #c8cdd6;

  /* Text */
  --text: #0f1117;
  --text-2: #3a3f4a;
  --muted: #6b7280;

  /* Brand — pulled from logo */
  --navy: #181c2e;
  --purple: #5b3ff0;
  --purple-mid: #7c5af5;
  --purple-light: #ede9fe;
  --purple-glow: rgba(91, 63, 240, 0.18);

  /* Semantic */
  --green: #16a34a;
  --green-light: #dcfce7;
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --coral: #dc2626;
  --coral-light: #fee2e2;
  --gold: #b45309;
  --gold-light: #fef3c7;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15,17,30,0.06);
  --shadow-md: 0 4px 12px rgba(15,17,30,0.10);
  --shadow-lg: 0 12px 32px rgba(15,17,30,0.12);
  --shadow-xl: 0 24px 48px rgba(15,17,30,0.14);
  --shadow-glow: 0 0 0 3px var(--purple-glow);

  /* Transitions */
  --transition-fast: 140ms cubic-bezier(0.2, 0.9, 0.4, 1.1);
  --transition-smooth: 240ms cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Subtle ambient glow */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background:
    radial-gradient(circle at 10% 20%, rgba(91,63,240,0.05), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(124,90,245,0.04), transparent 40%);
  pointer-events: none;
  z-index: -1;
}

/* ── Typography ── */
h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--navy);
}

h1 span.accent {
  background: linear-gradient(135deg, var(--purple), var(--purple-mid));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.3;
  color: var(--navy);
}

h3 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--purple);
  margin-bottom: 0.5rem;
}

/* ── Layout ── */
.site-header,
main {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
}

/* ── Navbar ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 12px;
  padding: 0.65rem 1.25rem;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--navy);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-logo {
  flex-shrink: 0;
  display: block;
  height: 40px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.nav-links a:hover { color: var(--purple); }

/* ── Hero ── */
.hero-compact {
  padding: 2.5rem 0 1.75rem;
}

.hero-count {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 1.1rem;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.hero-count b { color: var(--text); font-weight: 800; }
.hero-count .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--purple); }

.hero-text-small {
  color: var(--muted);
  max-width: 480px;
  font-size: 1rem;
  margin-top: 0.75rem;
  line-height: 1.6;
}

/* ── Library section ── */
.library { padding-bottom: 4rem; }

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 12px;
  z-index: 9;
  padding: 13px 16px;
  margin-bottom: 1.75rem;
  background: rgba(245, 246, 248, 0.88);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Appears only when a theme from the Theme Studio is active — one click clears it. */
.theme-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: center;
  border: 1.5px solid #ddd6fe;
  background: #f5f3ff;
  color: #5b3ff0;
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  font: 700 12px/1 'Inter', system-ui, sans-serif;
  transition: background .14s ease, border-color .14s ease;
}
.theme-chip:hover { background: #ede9fe; border-color: #c4b5fd; }
.theme-chip b { font-weight: 800; }
.theme-chip__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, #5b3ff0, #ec4899);
}

.search-wrap {
  flex: 2;
  min-width: 200px;
}

.search-wrap span {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.search-wrap input {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: var(--shadow-glow);
}

.search-wrap input::placeholder { color: var(--muted); opacity: 0.6; }

/* ── Filter dropdowns (Category + Suit) ── */
.select-wrap {
  flex: 1;
  min-width: 150px;
}

.select-wrap span {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.select-wrap select {
  width: 100%;
  padding: 0.7rem 2.2rem 0.7rem 1rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--text);
  font: 700 0.88rem/1 'Inter', system-ui, sans-serif;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 14 14' fill='none'%3E%3Cpath d='M3 5l4 4 4-4' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.select-wrap select:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: var(--shadow-glow);
}

/* The Suit dropdown reads as the "look" picker — give it a hint of brand. */
#suit-select { border-color: var(--purple-light); color: var(--purple); }

/* ── Custom Category dropdown (matches the catalog's own dropdowns) ── */
.catdd { position: relative; }
.catdd-trigger {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 46px; padding: 0.7rem 1rem;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-md);
  color: var(--text); font: 700 0.9rem/1 'Inter', system-ui, sans-serif; cursor: pointer;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.catdd-trigger:hover { border-color: var(--line-strong); }
.catdd-trigger:focus-visible { outline: none; border-color: var(--purple); box-shadow: var(--shadow-glow); }
.catdd.open .catdd-trigger { border-color: var(--purple); box-shadow: var(--shadow-glow); }
.catdd-chev { flex-shrink: 0; color: var(--muted); transition: transform .2s ease; }
.catdd.open .catdd-chev { transform: rotate(180deg); }
.catdd-menu {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 30;
  max-height: 340px; overflow-y: auto; margin: 0; padding: 7px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-8px) scale(.98); transform-origin: top; pointer-events: none;
  transition: opacity .18s cubic-bezier(.22,1,.36,1), transform .18s cubic-bezier(.22,1,.36,1);
}
.catdd.open .catdd-menu { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.catdd-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm); cursor: pointer;
  font: 600 13.5px/1.2 'Inter', system-ui, sans-serif; color: var(--text-2);
  transition: background .12s ease, color .12s ease;
}
.catdd-item:hover, .catdd-item.is-hl { background: var(--purple-light); color: var(--purple); }
.catdd-item[aria-selected="true"] { color: var(--purple); font-weight: 800; }
.catdd-item .ct-n { font-weight: 600; font-size: 11.5px; color: var(--muted); }
.catdd-item:hover .ct-n, .catdd-item.is-hl .ct-n,
.catdd-item[aria-selected="true"] .ct-n { color: var(--purple); }

/* ── Suit channels: backgrounds + dropdown skins ── */
body { transition: background 0.4s ease, color 0.4s ease; }
body.bg-aurora   { background: linear-gradient(135deg, #eaf4ff, #efeaff 45%, #ffeef6); }
body.bg-gradient { background: linear-gradient(135deg, #f4ecff, #ffe9f4); }
body.bg-neon     { background: radial-gradient(120% 90% at 20% 0%, #1a1f3c, #0b0e1c 70%); color: #cdd5ee; }

/* Neon background is dark — flip the page chrome so text stays readable. */
body.bg-neon h1 { color: #fff; }
body.bg-neon .hero-text-small { color: #aab4d4; }
body.bg-neon .brand { color: #fff; }
body.bg-neon .nav { background: rgba(11,14,28,0.82); border-bottom-color: rgba(255,255,255,0.08); }
body.bg-neon .nav-links a { color: #aab4d4; }
body.bg-neon .select-wrap span,
body.bg-neon .search-wrap span { color: #8b95b8; }

/* Dropdown (select) skins applied to the page filter dropdowns. */
.select-wrap select.dd-aurora   { background-color: #f3efff; border-color: #d8ccff; color: #5b3ff0; }
.select-wrap select.dd-gradient { background-color: #fdf0fa; border-color: #f3cce8; color: #be1e8a; }
.select-wrap select.dd-neon     { background-color: #161a33; border-color: #3a2f6b; color: #e7ebf5; }

/* ── Snippet Grid ── */
.snippet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

/* ── Card ── */
.snippet-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--transition-smooth),
    box-shadow var(--transition-smooth),
    border-color var(--transition-fast);
}

.snippet-card:hover {
  transform: translateY(-5px);
  border-color: var(--purple-mid);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(91,63,240,0.08);
}

/* When a card skin is being "tried", let it span the whole card — the inner
   regions go transparent so the skin's surface/gradient reads across the card,
   not just the body strip. */
.is-trying-card .component-preview,
.is-trying-card .card-footer,
.is-trying-card .variant-meta {
  background: transparent;
}
.is-trying-card .component-preview {
  border-top-color: rgba(15, 17, 30, 0.06);
  border-bottom-color: rgba(15, 17, 30, 0.06);
}
.is-trying-card .card-footer {
  border-top-color: rgba(15, 17, 30, 0.06);
}

/* Keep text legible when the dark/colour-fill skins re-skin the whole catalog. */
.is-trying-card.card-gradient h3,
.is-trying-card.card-neon h3 { color: #fff; }
.is-trying-card.card-gradient .type-body-sm,
.is-trying-card.card-neon .type-body-sm,
.is-trying-card.card-gradient .variant-label,
.is-trying-card.card-neon .variant-label,
.is-trying-card.card-gradient .variant-count,
.is-trying-card.card-neon .variant-count { color: rgba(255, 255, 255, 0.82); }

/* Colour-theory harmony cards are colour-filled too — keep text readable when tried. */
.is-trying-card[class*="card-h-"] h3 { color: #fff; }
.is-trying-card[class*="card-h-"] .type-body-sm,
.is-trying-card[class*="card-h-"] .variant-label,
.is-trying-card[class*="card-h-"] .variant-count { color: rgba(255, 255, 255, 0.85); }

.card-body { padding: 1.2rem; }

.card-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.card-category {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--purple);
  background: var(--purple-light);
  padding: 0.2rem 0.6rem;
  border-radius: 40px;
}

.token-pill {
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--gold-light);
  padding: 0.2rem 0.6rem;
  border-radius: 40px;
  color: var(--gold);
  border: 1px solid rgba(180,83,9,0.15);
}

.snippet-card h3 { margin-bottom: 0.25rem; }

.snippet-card .type-body-sm {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  margin-top: 0.35rem;
}

/* ── Component preview ──
   flex:1 lets the preview absorb any extra card height, so the footer always
   pins to the bottom and rows of uneven cards never leave a gap below it. */
.component-preview {
  position: relative;
  flex: 1;
  background: #f8f9fb;
  border-top: 1.5px solid var(--line);
  border-bottom: 1.5px solid var(--line);
  padding: 2rem 1.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100px;
}

/* ── Variant carousel ── */
.variant-viewport {
  width: 100%;
  overflow: hidden;
}

.has-variants .variant-viewport {
  cursor: grab;
  touch-action: pan-y;
}

.has-variants .variant-viewport:active { cursor: grabbing; }

.variant-track {
  display: flex;
  transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.variant-slide {
  flex: 0 0 100%;
  min-width: 0;          /* never let a wide child stretch the slide past the viewport */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 96px;
  padding: 18px 16px;   /* vertical room too, so badges/tooltips poking above (e.g. -11px) aren't clipped by the viewport */
}
/* Keep each preview at its natural width (no flex-squish that would clip nowrap
   content like tables); fitPreviews() then scales any oversized one to fit. */
.variant-slide > * { flex-shrink: 0; }

/* Fixed-width demos (modal dialog = 320, alert = 300) overflow the carousel on
   narrow cards and get clipped on the sides. Cap them to the slide in the PREVIEW
   only — the copied code keeps its natural width. */
.variant-slide .dlg { width: 100%; max-width: 320px; }
.variant-slide .alert { width: 100%; max-width: 300px; }

/* Dropdown menus open downward and would be clipped by the carousel's
   overflow:hidden — give those slides vertical room (trigger near the top) so the
   open menu stays visible. Trigger stays horizontally CENTERED (roomy slides +
   fitPreviews keep the open menu inside the preview). */
.variant-slide:has(.dropdown) {
  align-items: flex-start;
  min-height: 210px;
  padding-top: 14px;
}
/* Safety net: never let an open menu exceed the visible preview width. */
.variant-slide .dropdown-menu { max-width: calc(100% - 4px); }

/* Smooth the Steps "Try me" stepping animation (preview only). */
.variant-slide .stp-i,
.variant-slide .stp-c,
.variant-slide .stpd-d { transition: color .3s ease, background-color .3s ease, border-color .3s ease, width .25s cubic-bezier(.34,1.56,.64,1), height .25s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease; }

/* Neural-net "Try me" showcase — bigger diagram + interactive controls (idea5). */
.sc__body .nn { width: 100%; max-width: 460px; margin: 0 auto; }
.nn-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 18px; }
.nn-ctrl { border: 1px solid #e2e8f0; background: #fff; border-radius: 40px; padding: 9px 16px; font: 700 13px/1 'Inter', system-ui, sans-serif; color: #334155; cursor: pointer; transition: border-color .15s ease, color .15s ease, transform .15s ease; }
.nn-ctrl:hover { border-color: #5b3ff0; color: #5b3ff0; transform: translateY(-2px); }
.nn-status { width: 100%; text-align: center; margin-top: 2px; font: 600 12.5px/1.4 'Inter', system-ui, sans-serif; color: #64748b; }

.variant-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  color: var(--text-2);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  z-index: 2;
  transition: opacity var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.snippet-card:hover .variant-arrow,
.snippet-card:focus-within .variant-arrow { opacity: 1; }

.variant-arrow:hover { border-color: var(--purple); color: var(--purple); }
.variant-arrow--prev { left: 0.6rem; }
.variant-arrow--next { right: 0.6rem; }

.variant-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1.2rem;
  background: var(--surface);
}

.variant-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

.variant-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.variant-dots {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* For >10 variants: a slim progress bar instead of an unreadable dot row. */
.variant-prog {
  flex: 1;
  max-width: 130px;
  height: 5px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.variant-prog > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--purple);
  transition: width 0.25s ease;
}

.variant-dot {
  width: 7px;
  height: 7px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--line-strong);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.variant-dot:hover { background: var(--muted); }

.variant-dot.active {
  width: 20px;
  border-radius: 4px;
  background: var(--purple);
}

/* ── Card footer ── */
.card-footer {
  display: flex;
  gap: 0.6rem;
  padding: 0.8rem 1.2rem;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.card-action {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 38px;
  padding: 0 0.9rem;
  border-radius: var(--radius-sm);
  font: 700 0.78rem/1 'Inter', system-ui, sans-serif;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  transition: all var(--transition-fast);
}

.card-action:hover {
  border-color: var(--purple);
  color: var(--purple);
  transform: translateY(-1px);
}

/* The irresistible CTA: glowing gradient + a shine sweep on hover. */
.card-action--try {
  position: relative;
  overflow: hidden;
  border-color: transparent;
  background: linear-gradient(135deg, var(--purple), var(--purple-mid));
  color: #fff;
  box-shadow: 0 2px 10px rgba(91,63,240,0.35);
}

.card-action--try::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,0.45) 50%, transparent 80%);
  transform: translateX(-120%);
  transition: transform 550ms ease;
  pointer-events: none;
}

.card-action--try:hover {
  border-color: transparent;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(91,63,240,0.5);
}

.card-action--try:hover::before { transform: translateX(120%); }

@media (prefers-reduced-motion: reduce) {
  .card-action--try::before { transition: none; }
}

/* While a button component is being tried, the Try buttons take on its class.
   Keep them filling the footer slot regardless of the component's own width. */
.card-footer .is-trying { flex: 1; }

/* Floating control that appears while a component is being tried. */
#try-reset {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 600 0.82rem/1 'Inter', system-ui, sans-serif;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  z-index: 1200;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

#try-reset.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

#try-reset strong { font-weight: 800; color: var(--purple); }

.try-reset__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.try-reset__x {
  margin-left: 4px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
}

/* Transient message when a component has no live target on the page yet. */
#try-toast {
  position: fixed;
  left: 50%;
  top: 24px;
  transform: translateX(-50%) translateY(-20px);
  max-width: min(420px, calc(100% - 2rem));
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--navy);
  color: #fff;
  font: 600 0.82rem/1.4 'Inter', system-ui, sans-serif;
  text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  z-index: 1600;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

#try-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Slide-in Try panel ── */
#try-stage {
  position: fixed;
  inset: 0;
  z-index: 1300;
  visibility: hidden;
}
#try-stage[aria-hidden="false"] { visibility: visible; }

#try-scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 30, 0.28);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s ease;
}
#try-stage[aria-hidden="false"] #try-scrim { opacity: 1; }

#try-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 50px rgba(15, 17, 30, 0.25);
  transform: translateX(100%);
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}
#try-stage[aria-hidden="false"] #try-panel { transform: translateX(0); }

.try-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--line);
}
.try-panel__eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--purple);
  margin-bottom: 0.35rem;
}
.try-panel__title { font-size: 1.15rem; }
.try-panel__close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.try-panel__close:hover { background: var(--coral-light); border-color: var(--coral); color: var(--coral); }

.try-panel__stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 2rem 1.5rem;
  overflow: auto;
  background:
    radial-gradient(circle at 50% 0%, rgba(91,63,240,0.05), transparent 60%),
    var(--bg);
}

/* Edge-to-edge shells (e.g. the App sidebar) fill the panel. */
.try-panel__stage.is-fill {
  padding: 0;
  place-items: stretch;
  background: var(--surface);
}

/* Loading screen (LoaderTry) — center-screen takeover with cycling text. */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  background: rgba(245, 246, 248, 0.55);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  opacity: 0;
  visibility: hidden;
  cursor: pointer;
  transition: opacity 0.25s ease;
}
#loading-screen[aria-hidden="false"] { opacity: 1; visibility: visible; }
/* The loader sits in a real card; the card wears the active card skin and the
   Cancel button wears the active button skin (so it's a live combo). */
.ls__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  min-width: 320px;
  min-height: 240px;
  padding: 44px 52px;
  border-radius: var(--radius-xl);
  background: #fff;
  color: var(--text);
  box-shadow: 0 24px 60px rgba(15, 17, 30, 0.18);
  cursor: default;
}
.ls__loader {
  display: grid;
  place-items: center;
  transform: scale(1.5);
}
.ls__text {
  min-height: 1em;
  font: 800 16px/1 'Inter', system-ui, sans-serif;
  letter-spacing: 0.01em;
  color: inherit;
}
.ls__actions { display: flex; gap: 10px; }
.ls__cancel {
  min-height: 40px;
  padding: 0 22px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  font: 700 13px/1 'Inter', system-ui, sans-serif;
  cursor: pointer;
}
.ls__next {
  min-height: 40px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--purple), var(--purple-mid));
  color: #fff;
  font: 700 13px/1 'Inter', system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(91,63,240,0.35);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.ls__next:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(91,63,240,0.5); }
.ls__hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 28px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}
@media (prefers-reduced-motion: reduce) {
  #loading-screen { transition: none; }
}

/* Showcase modal (DiagramTry) — a centered card with a close button. */
#showcase {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  background: rgba(15, 17, 30, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  cursor: pointer;
  transition: opacity 0.25s ease;
}
#showcase[aria-hidden="false"] { opacity: 1; visibility: visible; }
.sc__card {
  position: relative;
  padding: 44px 52px;
  border-radius: var(--radius-xl);
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 17, 30, 0.22);
  cursor: default;
}
.sc__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.sc__body { display: grid; place-items: center; }
.sc__body .nn { width: 420px; height: 280px; }   /* the diagram, big */

/* Modal overlay (ModalTry) — real centered dialog over a blurred page. */
#modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1350;
  display: grid;
  place-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity .22s ease;
}
#modal-overlay[aria-hidden="false"] { opacity: 1; visibility: visible; }
.mo__scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 30, 0.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.mo__slot {
  position: relative;
  transform: scale(.96);
  transition: transform .22s cubic-bezier(.22, 1, .36, 1);
}
#modal-overlay[aria-hidden="false"] .mo__slot { transform: scale(1); }
@media (prefers-reduced-motion: reduce) {
  #modal-overlay, .mo__slot { transition: none; }
}

/* Toasts (AlertTry) — trying an alert fires a real notification, top-right. */
#toast-host {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
#toast-host .toast { pointer-events: auto; }
.toast {
  transform: translateX(120%);
  opacity: 0;
  transition: transform .32s cubic-bezier(.22, 1, .36, 1), opacity .32s ease;
}
.toast.in { transform: none; opacity: 1; }
.toast .alert { box-shadow: 0 12px 32px rgba(15, 17, 30, 0.16); }
@media (prefers-reduced-motion: reduce) { .toast { transition: opacity .2s ease; transform: none; } }

/* A loose piece dropped into the sidebar shell sits in a labelled slot. */
.sb__slot {
  margin: 6px 4px 2px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #fbfaff;
}
.sb__slot-label {
  font: 800 11px/1 'Inter', system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8b5cf6;
}
.sb__slot-body { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.try-panel__foot {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--line);
}
.try-panel__foot .button { width: 100%; }

@media (prefers-reduced-motion: reduce) {
  #try-scrim, #try-panel { transition: none; }
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 3rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1.5px dashed var(--line-strong);
}

.empty-state h3 { margin-bottom: 0.5rem; color: var(--text-2); }
.empty-state p  { color: var(--muted); font-size: 0.9rem; }

/* ── Buttons ── */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  font-family: inherit;
  white-space: nowrap;
}

.button.primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-mid));
  color: #fff;
  box-shadow: 0 2px 8px rgba(91,63,240,0.25);
}

.button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(91,63,240,0.35);
}

.button.primary:active { transform: translateY(0); }

.button.ghost {
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-2);
}

.button.ghost:hover {
  border-color: var(--purple);
  color: var(--purple);
}

/* ── Modal ── */
.snippet-modal {
  margin: auto;               /* re-instate the dialog centering the global reset stripped */
  width: min(800px, calc(100% - 2rem));
  max-height: 85vh;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  padding: 1.75rem;
  box-shadow: var(--shadow-xl);
  overflow-y: auto;
}

.snippet-modal::backdrop {
  background: rgba(15, 17, 30, 0.45);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

/* ── Language tabs (code modal) ── */
.lang-tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  margin-bottom: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.lang-tab {
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.9rem;
  font: 700 0.78rem/1 'Inter', system-ui, sans-serif;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.lang-tab:hover { color: var(--text); }
.lang-tab.active {
  background: var(--surface);
  color: var(--purple);
  box-shadow: var(--shadow-sm);
}

.code-panel {
  background: #0f1117;
  border-radius: var(--radius-md);
  border: 1px solid #2a2d3a;
  padding: 1.25rem;
  overflow: auto;
  max-height: 52vh;
  margin-bottom: 1.25rem;
}

.code-panel code {
  font-family: 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.65;
  color: #a8b8d0;
  white-space: pre;
}

/* Syntax highlighting tokens (One-Dark-ish palette). */
.code-panel .tok-com  { color: #5c6370; font-style: italic; }
.code-panel .tok-str  { color: #98c379; }
.code-panel .tok-tag  { color: #e06c75; }
.code-panel .tok-attr { color: #d19a66; }
.code-panel .tok-kw   { color: #c678dd; }
.code-panel .tok-num  { color: #56b6c2; }

.copy-button { width: 100%; }

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.icon-button:hover {
  background: var(--coral-light);
  border-color: var(--coral);
  color: var(--coral);
}

/* ── Utility ── */
.hidden { display: none !important; }

.copy-button.success {
  background: var(--green);
  box-shadow: 0 4px 14px rgba(22,163,74,.25);
}

/* ── Reduced motion ──
   Respect the user's OS setting across the whole UI and every live preview.
   (Animated snippets also ship their own reduced-motion rules in their code.) */
@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;
  }
}

/* ── Animations ── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.snippet-card { animation: fadeSlideUp 0.4s ease backwards; }
.snippet-card:nth-child(1) { animation-delay: 0.02s; }
.snippet-card:nth-child(2) { animation-delay: 0.05s; }
.snippet-card:nth-child(3) { animation-delay: 0.08s; }
.snippet-card:nth-child(4) { animation-delay: 0.11s; }
.snippet-card:nth-child(5) { animation-delay: 0.14s; }
.snippet-card:nth-child(6) { animation-delay: 0.17s; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Responsive ── */
@media (max-width: 768px) {
  .controls { flex-direction: column; align-items: stretch; position: static; }
  .filter-group { justify-content: flex-start; }
  .snippet-grid { grid-template-columns: 1fr; }
  .nav { position: static; margin-top: 0; flex-wrap: wrap; gap: 0.75rem; }
}