/* ═══════════════════════════════════════════════════════════════════
   UWC Docs — Design System
   BEM-based layout and component styles
   ═══════════════════════════════════════════════════════════════════ */

/* ── Design tokens ─────────────────────────────────────────────────── */
:root {
  /* Layout */
  --topbar-height: 60px;
  --sidebar-width: 272px;
  --content-max-width: 820px;
  --toc-width: 220px;
  --sidebar-transition: 280ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Brand gradient */
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --brand-color: #6366f1;
  --brand-color-hover: #4f46e5;
  --brand-color-light: hsl(243, 100%, 96%);
  --brand-color-border: hsl(243, 80%, 88%);

  /* Surface */
  --surface-bg:       #ffffff;
  --surface-dim:      hsl(240, 25%, 98.5%);
  --surface-raised:   #ffffff;
  --surface-overlay:  rgba(15, 15, 30, 0.55);

  /* Border */
  --border-color:     hsl(240, 12%, 91%);
  --border-color-dim: hsl(240, 8%, 95%);

  /* Text */
  --text-primary:     hsl(240, 12%, 10%);
  --text-secondary:   hsl(240, 8%, 36%);
  --text-muted:       hsl(240, 5%, 56%);
  --text-inverse:     #ffffff;

  /* Shadows */
  --shadow-xs:   0 1px 2px rgba(15, 15, 30, 0.04);
  --shadow-sm:   0 1px 4px rgba(15, 15, 30, 0.06), 0 1px 2px rgba(15, 15, 30, 0.04);
  --shadow-md:   0 4px 12px rgba(15, 15, 30, 0.08), 0 2px 4px rgba(15, 15, 30, 0.04);
  --shadow-lg:   0 8px 24px rgba(15, 15, 30, 0.10), 0 4px 8px rgba(15, 15, 30, 0.06);
  --shadow-xl:   0 16px 48px rgba(15, 15, 30, 0.12), 0 8px 16px rgba(15, 15, 30, 0.06);

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  /* Content spacing */
  --content-pad-x: 2.5rem;
  --content-pad-y: 2.5rem;
  --content-gap: 2rem;

  /* Forwarded sl-* aliases (keep legacy compat) */
  --sl-color-primary-600: var(--brand-color);
  --sl-color-primary-700: var(--brand-color-hover);
  --sl-color-neutral-0:   var(--surface-bg);
  --sl-color-neutral-200: var(--border-color);
  --sl-border-radius-medium: var(--radius-md);
  --sl-font-sans: var(--font-sans);
  --sl-font-mono: var(--font-mono);
  --sl-line-height-normal: 1.75;
  --sl-font-weight-normal: 400;
  --sl-font-weight-semibold: 600;
  --sl-font-weight-bold: 700;
  --sl-font-size-x-small: 0.75rem;
  --sl-font-size-small: 0.875rem;
  --sl-font-size-medium: 1rem;
  --sl-font-size-large: 1.125rem;
  --sl-focus-ring: 0 0 0 3px hsl(243 80% 65% / 35%);
  --sl-focus-ring-offset: 0px;
  --docs-border-color: var(--border-color);
  --docs-border-width: 1px;
  --docs-border-radius: var(--radius-md);
  --docs-background-color: var(--surface-bg);
  --docs-content-padding: var(--content-pad-x);
  --docs-content-vertical-spacing: var(--content-gap);
  --docs-content-max-width: var(--content-max-width);
  --docs-sidebar-width: var(--sidebar-width);
  --docs-content-toc-max-width: var(--toc-width);
  --docs-search-overlay-background: var(--surface-overlay);
  --docs-shadow-x-large: var(--shadow-xl);
}

/* ── Dark theme ────────────────────────────────────────────────────── */
html.sl-theme-dark {
  color-scheme: dark;

  --brand-color-light: hsl(243, 40%, 18%);
  --brand-color-border: hsl(243, 30%, 28%);

  --surface-bg:       hsl(235, 18%, 9%);
  --surface-dim:      hsl(235, 15%, 12%);
  --surface-raised:   hsl(235, 14%, 14%);
  --surface-overlay:  rgba(0, 0, 0, 0.72);

  --border-color:     hsl(235, 10%, 20%);
  --border-color-dim: hsl(235, 8%, 16%);

  --text-primary:     hsl(240, 10%, 94%);
  --text-secondary:   hsl(240, 6%, 70%);
  --text-muted:       hsl(240, 5%, 50%);

  --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm:  0 1px 4px rgba(0, 0, 0, 0.4);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-xl:  0 16px 48px rgba(0, 0, 0, 0.5);

  --sl-color-neutral-0: var(--surface-bg);
  --sl-color-neutral-200: var(--border-color);
  --docs-background-color: var(--surface-bg);
  --docs-border-color: var(--border-color);
  --docs-search-overlay-background: var(--surface-overlay);
}

/* ── Utilities ─────────────────────────────────────────────────────── */
html.sl-theme-dark .only-light,
html:not(.sl-theme-dark) .only-dark { display: none !important; }

.visually-hidden:not(:focus-within) {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  border: none !important; overflow: hidden !important;
  white-space: nowrap !important; padding: 0 !important;
}

/* ── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  height: 100%;
  box-sizing: border-box;
  line-height: var(--sl-line-height-normal);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: var(--sl-font-weight-normal);
  line-height: var(--sl-line-height-normal);
  color: var(--text-primary);
  background-color: var(--surface-bg);
  padding: 0; margin: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a:focus, button:focus { outline: none; }
a:focus-visible, button:focus-visible {
  outline: var(--sl-focus-ring);
  outline-offset: var(--sl-focus-ring-offset);
  border-radius: var(--radius-sm);
}

::selection {
  background-color: hsl(243, 80%, 88%);
  color: hsl(243, 60%, 20%);
}

html.sl-theme-dark ::selection {
  background-color: hsl(243, 40%, 30%);
  color: hsl(243, 80%, 90%);
}

/* ─────────────────────────────────────────────────────────────────────
   TOPBAR
   ───────────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  height: var(--topbar-height);
  background-color: var(--surface-bg);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
}

html.sl-theme-dark .topbar {
  background-color: var(--surface-dim);
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
  padding-inline: 1.25rem;
}

/* Brand */
.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  margin-right: 0.5rem;
  flex-shrink: 0;
}

.topbar__brand-gem {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  background: var(--brand-gradient);
  border-radius: var(--radius-md);
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 8px hsl(243 75% 59% / 35%);
}

.topbar__brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.topbar__brand-sub {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  display: none;
}

@media (min-width: 640px) {
  .topbar__brand-sub { display: inline; }
}

/* Nav links */
.topbar__spacer { flex: 1; }

.topbar__links {
  display: none;
  align-items: center;
  gap: 0.25rem;
}

@media (min-width: 768px) {
  .topbar__links { display: flex; }
}

.topbar__link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-full);
  transition: background 150ms, color 150ms;
}

.topbar__link:hover {
  background: var(--surface-dim);
  color: var(--text-primary);
}

/* Actions */
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 0.5rem;
}

.topbar__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: background 150ms, color 150ms;
  flex-shrink: 0;
}

.topbar__icon-btn:hover {
  background: var(--surface-dim);
  color: var(--text-primary);
}

/* Theme toggle icons */
.topbar__theme-icon { display: none; }

html:not(.sl-theme-dark) .topbar__theme-icon--dark { display: block; }
html.sl-theme-dark    .topbar__theme-icon--light { display: block; }

/* Mobile menu button */
.topbar__menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  margin-right: 0.25rem;
  transition: background 150ms, color 150ms;
  flex-shrink: 0;
}

.topbar__menu-btn:hover {
  background: var(--surface-dim);
  color: var(--text-primary);
}

@media (max-width: 900px) {
  .topbar__menu-btn { display: inline-flex; }
}

/* ─────────────────────────────────────────────────────────────────────
   SIDEBAR
   ───────────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  z-index: 40;
  width: var(--sidebar-width);
  background-color: var(--surface-dim);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: translate var(--sidebar-transition);
}

html.sl-theme-dark .sidebar {
  background-color: var(--surface-dim);
}

/* Mobile: slide off-screen */
@media (max-width: 900px) {
  .sidebar {
    top: 0;
    translate: -100%;
    box-shadow: var(--shadow-xl);
    z-index: 60;
  }

  html.sidebar-open .sidebar {
    translate: 0;
  }

  /* Overlay behind sidebar on mobile */
  html.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 59;
    background: var(--surface-overlay);
  }
}

/* Scrollable nav area */
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.75rem 0 2rem;
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.sidebar__nav:hover {
  scrollbar-color: var(--border-color) transparent;
}

.sidebar__nav::-webkit-scrollbar { width: 4px; }
.sidebar__nav::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: var(--radius-full);
}
.sidebar__nav:hover::-webkit-scrollbar-thumb {
  background: var(--border-color);
}

/* Header (visible in sidebar on mobile, hidden on desktop since topbar covers it) */
.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.875rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

@media (min-width: 901px) {
  .sidebar__header { display: none; }
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-weight: 700;
}

.sidebar__brand-gem {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  background: var(--brand-gradient);
  border-radius: var(--radius-sm);
  color: #fff;
  flex-shrink: 0;
}

.sidebar__version {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--border-color);
  padding: 0.1875rem 0.5rem;
  border-radius: var(--radius-full);
}

/* Search wrap */
.sidebar__search-wrap {
  padding: 0.75rem 1rem;
  flex-shrink: 0;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  height: 36px;
  padding: 0 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--surface-bg);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: border-color 150ms, box-shadow 150ms;
  white-space: nowrap;
  overflow: hidden;
}

.search-box svg { flex-shrink: 0; color: var(--text-muted); }

.search-box span {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-box:hover {
  border-color: hsl(243, 40%, 70%);
}

.search-box:focus-visible {
  outline: var(--sl-focus-ring);
  border-color: var(--brand-color);
}

.sidebar__search-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.375rem;
  height: 1.375rem;
  padding-inline: 0.25rem;
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-dim);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

/* Section */
.sidebar__section {
  padding: 0.25rem 0;
}

.sidebar__section + .sidebar__section {
  border-top: 1px solid var(--border-color-dim);
  margin-top: 0.5rem;
  padding-top: 0.75rem;
}

.sidebar__section-title {
  padding: 0.375rem 1.25rem;
  margin: 0 0 0.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.sidebar__list {
  list-style: none;
  padding: 0; margin: 0;
}

.sidebar__item { margin: 0; padding: 0 0.5rem; }

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 450;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 120ms, color 120ms;
  line-height: 1.4;
}

.sidebar__link:hover {
  background: color-mix(in oklab, var(--surface-bg) 60%, var(--border-color));
  color: var(--text-primary);
}

.sidebar__link.active-link {
  background: var(--brand-color-light);
  color: var(--brand-color);
  font-weight: 600;
}

html.sl-theme-dark .sidebar__link:hover {
  background: var(--surface-raised);
  color: var(--text-primary);
}

html.sl-theme-dark .sidebar__link.active-link {
  background: var(--brand-color-light);
  color: hsl(243, 80%, 75%);
}

/* ─────────────────────────────────────────────────────────────────────
   MAIN LAYOUT
   ───────────────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
  padding: var(--content-pad-y) var(--content-pad-x);
}

@media (max-width: 900px) {
  .main {
    margin-left: 0;
    padding: 1.5rem 1.25rem;
  }
}

@media (max-width: 600px) {
  .main { padding: 1.25rem 1rem; }
}

/* ─────────────────────────────────────────────────────────────────────
   CONTENT + TOC GRID
   ───────────────────────────────────────────────────────────────────── */
.content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 3rem;
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.content--with-toc {
  grid-template-columns: 1fr var(--toc-width);
  max-width: calc(var(--content-max-width) + var(--toc-width) + 3rem);
}

.content__body {
  order: 1;
  min-width: 0;
}

.content:not(.content--with-toc) .content__toc { display: none; }

/* ── TOC ─────────────────────────────────────────────────────────── */
.content__toc {
  order: 2;
  min-width: 0;
}

.content__toc-title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.75rem 1rem;
  padding: 0;
}

.content__toc ul {
  position: sticky;
  top: calc(var(--topbar-height) + 1.5rem);
  max-height: calc(100vh - var(--topbar-height) - 3rem);
  overflow-y: auto;
  list-style: none;
  padding: 0; margin: 0;
  border-left: 2px solid var(--border-color);
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
}

.content__toc ul:hover {
  scrollbar-color: var(--border-color) transparent;
}

.content__toc li {
  padding: 0;
  margin: 0;
}

.content__toc li:not(:last-child) { margin-bottom: 0.25rem; }

.content__toc li[data-level='3'] { padding-left: 0.875rem; }
.content__toc li[data-level='4'],
.content__toc li[data-level='5'] { padding-left: 1.75rem; }

.content__toc a {
  display: block;
  padding: 0.3rem 0 0.3rem 1rem;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: color 150ms, border-color 150ms;
}

.content__toc a:hover {
  color: var(--text-primary);
  border-left-color: var(--border-color);
}

.content__toc a.active {
  color: var(--brand-color);
  border-left-color: var(--brand-color);
  font-weight: 600;
}

.content__toc .top a {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

/* Collapse TOC on < 1024px */
@media (max-width: 1100px) {
  .content--with-toc {
    grid-template-columns: 1fr;
    max-width: var(--content-max-width);
  }

  .content__toc {
    order: -1;
    overflow: hidden;
  }

  .content__toc-title { display: none; }

  .content__toc ul {
    position: static;
    max-height: none;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.25rem 1.25rem;
    border-left: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 0 0.75rem 0.25rem;
    margin-bottom: 1.5rem;
    scrollbar-width: thin;
  }

  .content__toc li { white-space: nowrap; padding-left: 0 !important; }
  .content__toc li:not(:last-child) { margin-bottom: 0; }

  .content__toc a {
    border-left: none;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    margin: 0;
    background: transparent;
  }

  .content__toc a.active {
    background: var(--brand-color-light);
    border-left: none;
    color: var(--brand-color);
  }

  .content__toc [data-level]:not([data-level='2']) { display: none; }
}

/* ─────────────────────────────────────────────────────────────────────
   TYPOGRAPHY
   ───────────────────────────────────────────────────────────────────── */
.content__body h1,
.content__body h2,
.content__body h3,
.content__body h4,
.content__body h5,
.content__body h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--text-primary);
  margin: 0 0 1rem;
  padding-top: 2rem;
  scroll-margin-top: calc(var(--topbar-height) + 1.5rem);
}

.content__body h1 { font-size: 2.125rem; padding-top: 0; margin-bottom: 0.5rem; }
.content__body h2 {
  font-size: 1.375rem;
  padding-top: 2.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.625rem;
}
.content__body h3 { font-size: 1.125rem; color: var(--text-secondary); }
.content__body h4 { font-size: 1rem; color: var(--text-secondary); }
.content__body h5 { font-size: 0.9375rem; }
.content__body h6 { font-size: 0.875rem; color: var(--text-muted); }

/* Page title description */
.content__body > p:first-of-type {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.65;
}

p { margin: 0 0 1.25rem; }

img { max-width: 100%; }

a {
  color: var(--brand-color);
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color 150ms, text-decoration-color 150ms;
}

a:hover {
  color: var(--brand-color-hover);
  text-decoration-color: currentColor;
}

/* Inline code */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.8125em;
  font-weight: 500;
  color: hsl(243, 60%, 55%);
  background: var(--brand-color-light);
  border: 1px solid var(--brand-color-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.4em;
}

html.sl-theme-dark :not(pre) > code {
  color: hsl(243, 80%, 75%);
  background: hsl(243, 30%, 16%);
  border-color: hsl(243, 25%, 25%);
}

/* Anchor headings */
.anchor-heading {
  position: relative;
  color: inherit;
  text-decoration: none;
}

.anchor-heading a { text-decoration: none; color: inherit; }

.anchor-heading a::after {
  content: '#';
  color: var(--brand-color);
  margin-inline-start: 0.5rem;
  opacity: 0;
  font-weight: 400;
  font-size: 0.8em;
  transition: opacity 120ms;
}

.anchor-heading:hover a::after,
.anchor-heading:focus-within a::after { opacity: 1; }

/* Lists */
ul, ol {
  padding: 0;
  margin: 0 0 1.25rem 1.75rem;
}

ul { list-style: disc; }
li { padding: 0; margin: 0 0 0.3rem; }
li ul, li ol { margin-top: 0.3rem; }

/* Blockquotes */
blockquote {
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text-secondary);
  background: var(--surface-dim);
  border-left: 4px solid var(--brand-color);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 1.25rem 1.5rem;
  margin: 0 0 1.5rem;
}

blockquote > :first-child { margin-top: 0; }
blockquote > :last-child  { margin-bottom: 0; }

/* hr */
hr {
  border: none;
  border-bottom: 1px solid var(--border-color);
  margin: 2.5rem 0;
}

/* kbd */
kbd {
  font-family: var(--font-mono);
  font-size: 0.8125em;
  background: var(--surface-dim);
  border: 1px solid var(--border-color);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 0.1em 0.4em;
}

/* mark / ins / s */
mark  { background: hsl(50, 100%, 80%); border-radius: var(--radius-sm); padding: 0.1em 0.25em; }
ins   { background: hsl(142, 70%, 85%); color: hsl(142, 60%, 20%); border-radius: var(--radius-sm); text-decoration: none; padding: 0.1em 0.25em; }
s     { background: hsl(0, 80%, 90%);   color: hsl(0, 60%, 30%);   border-radius: var(--radius-sm); text-decoration: none; padding: 0.1em 0.25em; }

/* abbr */
abbr[title] { text-decoration: none; border-bottom: 1px dashed var(--brand-color); cursor: help; }

/* ── Tables ─────────────────────────────────────────────────────── */
.table-scroll { max-width: 100%; overflow-x: auto; }
.table-scroll code { white-space: nowrap; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

thead tr {
  background: var(--surface-dim);
}

tr {
  border-bottom: 1px solid var(--border-color);
}

tbody tr:last-child { border-bottom: none; }

th, td {
  text-align: left;
  padding: 0.75rem 1rem;
  line-height: 1.5;
  vertical-align: top;
}

th {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

th.table-name, th.table-event-detail { min-width: 14ch; }
th.table-description { min-width: 40ch; max-width: 60ch; }

th p:first-child, td p:first-child { margin-top: 0; }
th p:last-child,  td p:last-child  { margin-bottom: 0; }

/* ── Callouts ───────────────────────────────────────────────────── */
.callout {
  display: flex;
  gap: 0.875rem;
  background: var(--surface-dim);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--text-muted);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}

.callout::before {
  content: 'ℹ';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem; height: 1.5rem;
  border-radius: 50%;
  background: var(--text-muted);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.callout > :first-child { margin-top: 0; }
.callout > :last-child  { margin-bottom: 0; }

.callout--tip {
  background: var(--brand-color-light);
  border-color: var(--brand-color-border);
  border-left-color: var(--brand-color);
  color: hsl(243, 50%, 30%);
}
html.sl-theme-dark .callout--tip {
  color: hsl(243, 70%, 80%);
}
.callout--tip::before {
  content: 'i';
  font-style: italic;
  background: var(--brand-color);
}

.callout--warning {
  background: hsl(40, 100%, 96%);
  border-color: hsl(40, 80%, 80%);
  border-left-color: hsl(40, 90%, 50%);
  color: hsl(40, 60%, 25%);
}
.callout--warning::before { content: '!'; background: hsl(40, 90%, 50%); }

.callout--danger {
  background: hsl(0, 100%, 97%);
  border-color: hsl(0, 70%, 85%);
  border-left-color: hsl(0, 80%, 55%);
  color: hsl(0, 60%, 28%);
}
.callout--danger::before { content: '‼'; background: hsl(0, 80%, 55%); }

.callout--tip a, .callout--warning a, .callout--danger a { color: inherit; font-weight: 600; }

/* ── Details (accordion) ────────────────────────────────────────── */
.content details {
  background: var(--surface-dim);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.content details summary {
  font-weight: var(--sl-font-weight-semibold);
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  margin: -0.25rem -0.5rem;
  list-style: none;
}

.content details summary::-webkit-details-marker { display: none; }

.content details summary::before {
  content: '▶';
  display: inline-block;
  margin-right: 0.5rem;
  font-size: 0.75em;
  transition: rotate 200ms;
}

.content details[open] summary::before { rotate: 90deg; }

.content details > :nth-child(2) { margin-top: 0.75rem; }
.content details > :last-child   { margin-bottom: 0; }

/* ── Aside ──────────────────────────────────────────────────────── */
.content aside {
  float: right;
  min-width: 280px;
  max-width: 50%;
  background: var(--surface-dim);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

@media (max-width: 600px) {
  .content aside {
    float: none;
    max-width: none;
    margin-left: 0;
  }
}

/* ── Pre / Code blocks ─────────────────────────────────────────── */
pre {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 0 0 1.5rem;
}

/* ── Copy button ────────────────────────────────────────────────── */
.copy-code-button {
  position: absolute;
  top: 0.5rem; right: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.625rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.65);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  transition: opacity 150ms, background 150ms, color 150ms;
}

pre:hover .copy-code-button,
.copy-code-button:focus-visible { opacity: 1; }

.copy-code-button:hover {
  background: rgba(255,255,255,0.14);
  color: #fff;
}

/* ── Component page navigation ──────────────────────────────────── */
.component-page__navigation {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.component-page__navigation a {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.875rem 1.125rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: border-color 150ms, background 150ms, color 150ms;
  flex: 1;
  max-width: 48%;
}

.component-page__navigation a:hover {
  border-color: var(--brand-color-border);
  background: var(--brand-color-light);
  color: var(--brand-color);
}

.component-page__navigation a strong {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.component-page__navigation a:hover strong {
  color: var(--brand-color);
}

.component-page__navigation a:first-child { text-align: left; }
.component-page__navigation a:last-child  { text-align: right; margin-left: auto; }

/* ── External link icon ─────────────────────────────────────────── */
.external-link__icon {
  width: 0.75em; height: 0.75em;
  vertical-align: 0;
  margin-left: 0.2em;
  margin-right: 0.1em;
  opacity: 0.6;
}

/* ─────────────────────────────────────────────────────────────────────
   SEARCH TOKENS (referenced by search.css)
   ───────────────────────────────────────────────────────────────────── */
:root {
  --docs-search-box-background:        var(--surface-bg);
  --docs-search-box-border-color:      var(--border-color);
  --docs-search-box-color:             var(--text-muted);
  --docs-search-dialog-background:     var(--surface-bg);
  --docs-search-text-color:            var(--text-primary);
  --docs-search-text-color-muted:      var(--text-muted);
  --docs-search-border-radius:         var(--radius-lg);
  --docs-search-accent-color:          var(--brand-color);
  --docs-search-icon-color:            var(--text-muted);
  --docs-search-icon-color-active:     var(--text-primary);
  --docs-search-shadow:                var(--shadow-xl);
  --docs-search-result-background-hover: var(--surface-dim);
  --docs-search-result-color-hover:    var(--text-primary);
  --docs-search-result-background-active: var(--brand-color);
  --docs-search-result-color-active:   #fff;
  --docs-search-focus-ring:            var(--sl-focus-ring);
}

html.sl-theme-dark {
  --docs-search-box-background:        var(--surface-raised);
  --docs-search-dialog-background:     var(--surface-raised);
}

/* ─────────────────────────────────────────────────────────────────────
   PRINT
   ───────────────────────────────────────────────────────────────────── */
@media print {
  .topbar, .sidebar, .content__toc, #menu-toggle { display: none !important; }
  .main { margin: 0; padding: 0; }
  .content { display: block; max-width: none; }

  a:not(.anchor-heading)[href]::after { content: ' (' attr(href) ')'; }

  details, pre, .callout {
    border: 1px solid var(--border-color);
  }
}

/* ═══════════════════════════════════════════════════════════════════
   Component page — lead paragraph
   ═══════════════════════════════════════════════════════════════════ */
.comp-lead {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  margin: 0 0 1.75rem;
  line-height: 1.65;
}

/* ═══════════════════════════════════════════════════════════════════
   Component tabs  (Overview / Examples / API)
   ═══════════════════════════════════════════════════════════════════ */
.comp-tabs {
  margin-top: 0;
}

.comp-tabs__nav {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 2rem;
}

.comp-tabs__tab {
  padding: 0.5rem 1.125rem;
  border: none;
  background: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
  line-height: 1;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
}

.comp-tabs__tab:hover {
  color: var(--text-primary);
  background: var(--surface-dim);
}

.comp-tabs__tab--active {
  color: var(--brand-color);
  border-bottom-color: var(--brand-color);
  background: none;
}

.comp-tabs__panel {
  display: none;
}

.comp-tabs__panel--active {
  display: block;
}

/* ═══════════════════════════════════════════════════════════════════
   API reference tables
   ═══════════════════════════════════════════════════════════════════ */
.api-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.api-section-title:first-child {
  margin-top: 0;
}

.api-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.api-table thead tr {
  background: var(--surface-dim);
  border-bottom: 1px solid var(--border-color);
}

.api-table th {
  padding: 0.6rem 0.875rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.api-table td {
  padding: 0.65rem 0.875rem;
  border-bottom: 1px solid var(--border-color-dim);
  vertical-align: top;
}

.api-table tbody tr:last-child td {
  border-bottom: none;
}

.api-table tbody tr:hover td {
  background: var(--surface-dim);
}

.api-name {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--brand-color);
  background: var(--brand-color-light);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.api-name--css {
  font-size: 0.75rem;
}

.api-type {
  font-family: var(--font-mono);
  font-size: 0.775rem;
  color: hsl(220, 60%, 45%);
  background: hsl(220, 80%, 97%);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

html.sl-theme-dark .api-type {
  color: hsl(220, 80%, 75%);
  background: hsl(220, 30%, 18%);
}

.api-default {
  font-family: var(--font-mono);
  font-size: 0.775rem;
  color: var(--text-muted);
  background: var(--surface-dim);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.api-desc {
  color: var(--text-secondary);
  max-width: 400px;
}

.api-empty {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-style: italic;
  padding: 1.5rem 0;
}

/* ── UWC Component Theme Picker ──────────────────────────────────────────── */
.topbar__uwc-theme {
  position: relative;
}

.topbar__uwc-theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 36px;
  padding: 0 0.625rem;
  border: 1px solid var(--surface-border, rgba(0,0,0,0.1));
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  transition: background 150ms, color 150ms, border-color 150ms;
}
.topbar__uwc-theme-btn:hover {
  background: var(--surface-dim);
  color: var(--text-primary);
}

.topbar__uwc-theme-label {
  font-size: 0.75rem;
}

.topbar__uwc-theme-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 9999;
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  min-width: 160px;
  background: var(--surface, #fff);
  border: 1px solid var(--surface-border, rgba(0,0,0,0.1));
  border-radius: var(--radius-lg, 10px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);

  opacity: 0;
  transform: scale(0.96) translateY(-4px);
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  transform-origin: top right;
}
.topbar__uwc-theme-menu.is-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.topbar__uwc-theme-menu li {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 120ms;
}
.topbar__uwc-theme-menu li:hover { background: var(--surface-dim); }
.topbar__uwc-theme-menu li[aria-selected="true"] {
  color: var(--color-primary, #6366f1);
  font-weight: 600;
}

.topbar__uwc-theme-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(0,0,0,0.1);
}
.topbar__uwc-theme-swatch--default  { background: #6366f1; }
.topbar__uwc-theme-swatch--material { background: #6750a4; }
.topbar__uwc-theme-swatch--fluent   { background: #0078d4; }
