:root {
  color-scheme: dark;
  --ink: #f2f2f2;
  --muted: #9a9a9a;
  --faint: #6e6e6e;
  --line: #292929;
  --line-strong: #3a3a3a;
  --surface: #101010;
  --surface-raised: #151515;
  --surface-soft: #1a1a1a;
  --sidebar: #0c0c0c;
  --accent: #a78bfa;
  --accent-soft: #30245b;
  --accent-on-soft: #d5c8ff;
  --focus: #d6c7ff;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-code: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sidebar-width: 240px;
  --topbar-height: 40px;
}
* { box-sizing: border-box; }
html { background: var(--surface); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--surface); color: var(--ink); font-family: var(--font-ui); font-size: 13px; line-height: 1.5; }
button, input, select { font: inherit; }
button, a, input, select, summary { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button, summary { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.skip-link { position: fixed; z-index: 100; top: -50px; left: 12px; padding: 8px 12px; background: var(--accent); color: #0d0d0d; font-weight: 700; text-decoration: none; }
.skip-link:focus { top: 8px; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; display: flex; width: var(--sidebar-width); flex-direction: column; overflow-y: auto; border-right: 1px solid var(--line); background: var(--sidebar); padding: 16px 12px 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 14px; font-weight: 700; letter-spacing: -.01em; text-decoration: none; }
.brand small { display: block; margin-top: 1px; color: var(--faint); font-size: 10px; font-weight: 500; letter-spacing: .02em; }
.brand-mark { display: grid; width: 24px; height: 24px; place-items: center; border: 1px solid var(--line-strong); background: #191919; color: var(--ink); font-size: 12px; font-weight: 800; }
.sidebar-search { margin: 26px 0 18px; }
.sidebar-search label, .catalogue-toolbar label, .setting-label, .theme-controls label { display: block; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.sidebar-search input, .catalogue-toolbar input, .catalogue-toolbar select, .setting input, .setting select, .theme-controls select { display: block; width: 100%; min-height: 34px; margin-top: 5px; border: 1px solid var(--line); border-radius: 4px; background: #151515; color: var(--ink); padding: 7px 9px; }
.sidebar-search input::placeholder, .catalogue-toolbar input::placeholder { color: var(--faint); }
.sidebar-nav { display: grid; gap: 2px; }
.sidebar-heading { margin: 15px 8px 5px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-nav a { display: flex; min-height: 32px; align-items: center; gap: 10px; border-left: 2px solid transparent; color: var(--muted); padding: 6px 8px; text-decoration: none; }
.sidebar-nav a:hover { color: var(--ink); background: #151515; }
.sidebar-nav a[aria-current="page"] { border-left-color: #f2f2f2; background: #202020; color: #fff; }
.nav-glyph { width: 16px; color: var(--faint); text-align: center; }
.sidebar-nav a[aria-current="page"] .nav-glyph { color: #fff; }
.sidebar-spacer { flex: 1; }
.sidebar-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 13px 8px 0; color: var(--faint); font-size: 11px; }
.sidebar-foot a { color: var(--muted); text-decoration: none; }
.sidebar-foot a:hover { color: var(--ink); }
.main-column { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { position: sticky; z-index: 10; top: 0; display: flex; height: var(--topbar-height); align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgb(16 16 16 / 94%); padding: 0 24px; backdrop-filter: blur(12px); }
.topbar-path { display: flex; min-width: 0; align-items: center; gap: 8px; overflow: hidden; color: var(--faint); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.topbar-path a { color: var(--muted); text-decoration: none; }
.topbar-path a:hover, .topbar-actions a:hover { color: var(--ink); }
.topbar-actions { display: flex; gap: 18px; }
.topbar-actions a { color: var(--muted); font-size: 12px; text-decoration: none; }
.menu-toggle { display: none; border: 0; background: none; color: var(--muted); padding: 8px 0; }
.page-wrap { max-width: 1440px; padding: 12px 28px 40px; }
main { min-width: 0; }
.catalogue-toolbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.section-kicker { display: block; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: .09em; line-height: 1.2; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; color: var(--ink); font-size: 24px; letter-spacing: -.03em; line-height: 1.15; }
h2 { margin-bottom: 0; color: var(--ink); font-size: 15px; letter-spacing: -.01em; line-height: 1.2; }
h3 { font-size: 13px; }
.catalogue-toolbar-controls { display: grid; width: min(510px, 46%); grid-template-columns: minmax(210px, 1fr) 150px; gap: 10px; }
.catalogue-filterline { display: none; min-height: 36px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); color: var(--faint); }
.filter-links { display: flex; gap: 4px; }
.filter-links button, .section-actions button { min-width: 34px; min-height: 32px; border: 1px solid transparent; background: transparent; color: var(--muted); padding: 5px 10px; }
.filter-links button:hover, .section-actions button:hover { border-color: var(--line-strong); color: var(--ink); }
.filter-links button[aria-pressed="true"] { border-color: var(--line-strong); background: var(--surface-soft); color: var(--ink); }
.discovery-sections { display: grid; gap: 30px; padding-top: 12px; }
.catalogue-section { min-width: 0; }
.section-heading { display: flex; min-height: 28px; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 8px; }
.catalogue-section .section-kicker { display: none; }
.section-heading h2 { margin-top: 4px; }
.section-actions { display: flex; align-items: center; gap: 5px; color: var(--faint); font-size: 11px; }
.section-actions button { border-color: var(--line); padding: 4px 9px; }
.catalogue-row { display: grid; grid-auto-columns: 320px; grid-auto-flow: column; gap: 12px; overflow-x: auto; overscroll-behavior-inline: contain; padding-bottom: 8px; scrollbar-color: var(--line-strong) transparent; }
.catalogue-card { position: relative; width: 320px; min-width: 0; border: 1px solid var(--line); background: var(--surface-raised); }
.catalogue-card:hover { border-color: var(--line-strong); }
.card-preview { display: flex; height: 246px; align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid var(--line); background: #171717; text-decoration: none; }
.card-preview iframe { display: block; width: 280px; height: 210px; max-width: 100%; border: 0; pointer-events: none; }
.preview-play { position: absolute; top: 9px; right: 9px; min-height: 30px; border: 1px solid rgb(255 255 255 / 22%); border-radius: 3px; background: rgb(0 0 0 / 65%); color: #fff; padding: 4px 9px; font-size: 11px; }
.preview-play:hover { background: #000; }
.card-caption { display: flex; min-height: 34px; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 11px; }
.card-name { color: var(--ink); font-size: 13px; font-weight: 600; text-decoration: none; }
.card-name:hover { color: var(--accent-on-soft); }
.card-category { color: var(--faint); font-size: 10px; white-space: nowrap; }
.all-components { margin-top: 42px; border-top: 1px solid var(--line); padding-top: 26px; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.results-grid .catalogue-card { min-width: 0; }
.results-grid .card-preview { height: 210px; }
.results-grid .empty-state { grid-column: 1 / -1; }
.empty-state { border: 1px dashed var(--line-strong); padding: 34px; color: var(--muted); text-align: center; }
.empty-state button, .detail-actions button, .detail-actions a, .install-row button, .file-row button, .code-toolbar button, [data-reset-settings] { min-height: 36px; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--surface-soft); color: var(--ink); padding: 7px 11px; text-decoration: none; }
.empty-state button:hover, .detail-actions button:hover, .detail-actions a:hover, .install-row button:hover, .file-row button:hover, .code-toolbar button:hover, [data-reset-settings]:hover { border-color: var(--accent); }
.site-footer { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); margin-top: 44px; padding-top: 14px; color: var(--faint); font-size: 11px; }
.site-footer nav { display: flex; gap: 14px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* Detail and documentation */
.detail-inner { width: min(880px, 100%); margin: 0 auto; }
.breadcrumb { display: flex; gap: 8px; margin-bottom: 22px; color: var(--faint); font-size: 11px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.detail-header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.detail-header h1 { margin: 5px 0 8px; font-size: 28px; }
.detail-header p { max-width: 620px; margin-bottom: 0; color: var(--muted); font-size: 14px; }
.detail-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.preview-card, .content-card, .theme-card { border: 1px solid var(--line); background: var(--surface-raised); }
.preview-card-head { display: flex; min-height: 40px; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 6px 14px; }
.preview-card-head h2 { margin-top: 4px; }
.preview-toolbar { display: flex; align-items: end; gap: 8px; }
.preview-toolbar label { color: var(--muted); font-size: 10px; }
.preview-toolbar select { display: block; min-height: 32px; margin-top: 3px; border: 1px solid var(--line-strong); background: var(--surface-soft); color: var(--ink); padding: 5px 8px; }
.preview-toolbar button { min-height: 32px; border: 1px solid var(--line-strong); background: var(--surface-soft); color: var(--ink); padding: 5px 10px; }
.preview-stage { min-height: 420px; background: #171717; }
.detail-frame { display: block; width: 100%; height: 420px; border: 0; }
.settings-disclosure { margin: 12px 0 24px; border: 1px solid var(--line); background: var(--surface-raised); }
.settings-disclosure summary { padding: 12px 14px; color: var(--ink); font-weight: 600; }
.settings-disclosure[open] summary { border-bottom: 1px solid var(--line); }
.settings-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; padding: 14px; }
.setting-check { display: flex; min-height: 36px; align-items: center; gap: 8px; color: var(--ink); }
.setting-check input { width: 16px; height: 16px; accent-color: var(--accent); }
[data-reset-settings] { margin: 0 14px 14px; }
.detail-content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.content-card { min-width: 0; padding: 18px; }
.content-card.full { grid-column: 1 / -1; }
.content-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.content-heading h2, .content-card > h2 { margin: 5px 0 14px; font-size: 17px; }
.source-version { color: var(--faint); font-family: var(--font-code); font-size: 11px; }
.tab-list { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin: 0 -18px 14px; padding: 0 18px; }
.tab-list button { min-height: 38px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 6px 12px; }
.tab-list button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--ink); }
.code-wrap { min-width: 0; overflow: hidden; border: 1px solid var(--line); background: #0b0b0b; }
.code-toolbar { display: flex; min-height: 36px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 4px 8px 4px 11px; color: var(--faint); font-family: var(--font-code); font-size: 10px; }
.code-toolbar button { min-height: 28px; border-color: var(--line); padding: 4px 8px; font-family: var(--font-ui); font-size: 11px; }
pre { max-width: 100%; margin: 0; overflow: auto; color: #dbdbdb; font-family: var(--font-code); font-size: 12px; line-height: 1.65; white-space: pre; }
.code-wrap pre { padding: 14px; }
.copy-status { min-height: 19px; margin: 7px 0; color: var(--accent-on-soft); font-size: 11px; }
.content-card h3 { margin: 18px 0 7px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.content-card > p, .content-card li, .docs-prose p { color: var(--muted); }
.content-card pre:not(.code-wrap pre) { border: 1px solid var(--line); padding: 11px; }
.source-file-select { margin-bottom: 12px; }
.file-list { display: grid; gap: 5px; margin-top: 12px; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding: 7px 0; }
.file-row code, .install-row code, code { color: #d8cfff; font-family: var(--font-code); font-size: 12px; }
.file-row button { min-height: 30px; padding: 4px 8px; font-size: 11px; }
.install-row { display: flex; align-items: stretch; gap: 7px; margin: 14px 0; }
.install-row code { min-width: 0; flex: 1; overflow: auto; border: 1px solid var(--line); background: #0b0b0b; padding: 9px 10px; white-space: nowrap; }
.link-row { display: flex; flex-wrap: wrap; gap: 12px; }
.link-row a { color: var(--accent-on-soft); font-size: 11px; text-decoration: none; }
.link-row a:hover { text-decoration: underline; }
.data-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; color: var(--muted); font-size: 12px; text-align: left; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 7px; vertical-align: top; }
th { color: var(--ink); font-weight: 600; }
.bullet-list { margin: 0; padding-left: 18px; }
.license-list { display: grid; gap: 10px; }
.license-row { display: grid; grid-template-columns: minmax(150px, .6fr) 1.4fr; gap: 24px; border-top: 1px solid var(--line); padding: 18px 0; }
.license-row h2 { margin-bottom: 4px; }
.license-row p { margin-bottom: 7px; }
.page-heading { max-width: 680px; margin-bottom: 34px; }
.page-heading h1 { margin: 6px 0 10px; }
.page-heading p { margin-bottom: 0; color: var(--muted); font-size: 14px; }
.docs-prose { width: min(820px, 100%); margin: 0 auto; }
.docs-prose section { border-top: 1px solid var(--line); padding: 23px 0; }
.docs-prose h2 { margin-bottom: 11px; font-size: 17px; }
.docs-prose pre { margin: 13px 0; border: 1px solid var(--line); background: #0b0b0b; padding: 13px; }
.docs-prose code { color: var(--accent-on-soft); }
.notice { margin-bottom: 20px; border-left: 2px solid var(--accent); background: var(--accent-soft); padding: 13px 15px; color: var(--accent-on-soft); }
.notice a { color: inherit; }

/* Theme workspace */
.theme-layout { display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 14px; }
.theme-card { padding: 18px; }
.theme-card h2 { margin-bottom: 16px; font-size: 17px; }
.theme-control-grid { display: grid; gap: 10px; }
.theme-controls select { min-height: 36px; }
.swatches { display: flex; gap: 7px; margin: 18px 0; }
.swatch { display: inline-flex; min-height: 28px; align-items: center; border: 1px solid var(--line); padding: 4px 8px; color: var(--muted); font-size: 10px; }
.swatch-accent { border-color: var(--accent); color: var(--accent-on-soft); }
.swatch-surface { background: var(--surface-soft); }
.swatch-text { color: var(--ink); }
.theme-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.theme-preview { border: 1px solid var(--line); background: var(--surface-raised); }
.theme-preview iframe { display: block; width: 100%; height: 210px; border: 0; }
.theme-preview p { margin: 0; border-top: 1px solid var(--line); padding: 9px 11px; color: var(--muted); font-size: 11px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 900px) {
  :root { --sidebar-width: 0px; }
  .sidebar { width: min(280px, 86vw); transform: translateX(-102%); transition: transform .18s ease; box-shadow: 12px 0 40px rgb(0 0 0 / 40%); }
  html[data-sidebar-open="true"] .sidebar { transform: translateX(0); }
  .main-column { margin-left: 0; }
  .topbar { padding: 0 14px; }
  .menu-toggle { display: inline-flex; align-items: center; gap: 6px; }
  .menu-toggle, .sidebar-nav a, .sidebar-search input, .catalogue-toolbar input, .catalogue-toolbar select, .filter-links button, .preview-play { min-height: 44px; }
  .topbar-path { margin-left: 10px; margin-right: auto; }
  .topbar-actions { display: none; }
  .page-wrap { padding: 20px 16px 34px; }
  .catalogue-toolbar { position: static; width: auto; height: auto; overflow: visible; clip: auto; display: block; }
  .catalogue-toolbar-controls { width: 100%; margin-top: 16px; }
  .catalogue-filterline { display: flex; }
  .discovery-sections { padding-top: 16px; }
  .settings-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .page-wrap { padding-right: 12px; padding-left: 12px; }
  h1 { font-size: 22px; }
  .catalogue-toolbar > div:first-child { display: none; }
  .catalogue-toolbar-controls { margin-top: 0; }
  .catalogue-toolbar-controls label:nth-child(2) { display: none; }
  .catalogue-toolbar-controls { display: grid; grid-template-columns: 1fr; }
  .catalogue-filterline { min-height: 44px; }
  .discovery-sections { gap: 25px; padding-top: 20px; }
  .catalogue-row { display: grid; grid-auto-columns: 1fr; grid-auto-flow: row; gap: 10px; overflow: visible; }
  .catalogue-card { width: 100%; }
  .card-preview, .results-grid .card-preview { height: min(256px, calc((100vw - 24px) * .7)); }
  .catalogue-card, .catalogue-row .catalogue-card { width: 100%; }
  .card-preview iframe, .results-grid .card-preview iframe { width: 100%; height: 100%; }
  .results-grid { grid-template-columns: 1fr; }
  .all-components { margin-top: 30px; }
  .section-actions span { display: none; }
  .section-heading { min-height: 34px; }
  .detail-inner, .docs-prose { width: 100%; }
  .detail-header { display: block; }
  .detail-actions { margin-top: 16px; }
  .preview-card-head { align-items: start; }
  .preview-toolbar { display: grid; grid-template-columns: 1fr 1fr; }
  /* Detail previews keep the component-specific inline height set by browser.mjs.
     Gallery cards use the compact 256px mobile crop above; detail pages must be
     tall enough to show docks, composers, and timelines without inner scrolling. */
  .preview-stage { min-height: 420px; }
  .detail-frame { min-height: 420px; }
  .settings-list, .detail-content, .theme-layout, .theme-preview-grid { grid-template-columns: 1fr; }
  .content-card.full { grid-column: auto; }
  .license-row { grid-template-columns: 1fr; gap: 8px; }
  .site-footer { display: block; }
  .site-footer nav { margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
