/* Shared shell colors. Smithy palette reference and attribution are recorded in NOTICE. */
:root {
  color-scheme: light;
  --page-bg: #f9fafb;
  --page-fg: #111827;
  --muted: #6b7280;
  --line: #d1d5db;
  --border: #e5e7eb;
  --surface: #ffffff;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --on-accent: #ffffff;
  --control-border: #6b7280;
  --note: #2f6fb3;
  --tip: #2e7d4f;
  --important: #7c4dbd;
  --warning: #b45309;
  --caution: #b3402f;
  --ok: #2e7d4f;
  --danger: #b3402f;
  /* Indigo-to-slate layers for reviewed inline illustrations. Supplied artifacts are unchanged. */
  --s0: #4338ca;
  --s1: #4f46e5;
  --s2: #6366f1;
  --s3: #6366a8;
  --s4: #64748b;
  --s5: #5b6b73;
  --s6: #4b6a86;
  --s7: #44608f;
  --s8: #4a5578;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page-bg: #0f1014;
    --page-fg: #e5e7eb;
    --muted: #8b93a8;
    --line: #40455a;
    --border: #26283a;
    --surface: #17181f;
    --accent: #a5b4fc;
    --accent-soft: #1e1b4b;
    --on-accent: #1e1b4b;
    --control-border: #8b93a8;
    color-scheme: dark;
    --note: #6ea8e8;
    --tip: #6cc08f;
    --important: #b48ef0;
    --warning: #fbbf24;
    --caution: #ec7d6c;
    --ok: #6cc08f;
    --danger: #ec7d6c;
    --s0: #c7d2fe;
    --s1: #a5b4fc;
    --s2: #9ca3f5;
    --s3: #9fa5cc;
    --s4: #8b93a8;
    --s5: #93a8b3;
    --s6: #86a7c6;
    --s7: #8aa3d4;
    --s8: #9aa3c8;
  }
}

:root[data-theme="dark"] {
  --page-bg: #0f1014;
  --page-fg: #e5e7eb;
  --muted: #8b93a8;
  --line: #40455a;
  --border: #26283a;
  --surface: #17181f;
  --accent: #a5b4fc;
  --accent-soft: #1e1b4b;
  --on-accent: #1e1b4b;
  --control-border: #8b93a8;
  color-scheme: dark;
  --note: #6ea8e8;
  --tip: #6cc08f;
  --important: #b48ef0;
  --warning: #fbbf24;
  --caution: #ec7d6c;
  --ok: #6cc08f;
  --danger: #ec7d6c;
  --s0: #c7d2fe;
  --s1: #a5b4fc;
  --s2: #9ca3f5;
  --s3: #9fa5cc;
  --s4: #8b93a8;
  --s5: #93a8b3;
  --s6: #86a7c6;
  --s7: #8aa3d4;
  --s8: #9aa3c8;
}

/* Base */

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--page-fg);
  font-family: var(--font-sans);
  line-height: 1.6;
}

a {
  color: var(--accent);
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

:not(pre) > code {
  overflow-wrap: anywhere;
  background: var(--surface);
  border-radius: 4px;
  padding: 0.1em 0.3em;
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
}

/* Shiki writes both themes as CSS variables. */
.shiki,
.shiki span {
  color: var(--shiki-light);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .shiki,
  :root:not([data-theme="light"]) .shiki span {
    color: var(--shiki-dark);
  }
}

:root[data-theme="dark"] .shiki,
:root[data-theme="dark"] .shiki span {
  color: var(--shiki-dark);
}

table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.95em;
}

[role="region"] {
  overflow-x: auto;
}

th,
td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}

tr:first-child th,
tr:first-child td {
  background: var(--surface);
  font-weight: 600;
}

img,
svg {
  max-width: 100%;
  height: auto;
}

/* Frame */

.skip-link {
  position: absolute;
  left: -999px;
}

.skip-link:focus {
  left: 16px;
  top: 16px;
}

.site-header,
.site-footer,
main {
  max-width: 76rem;
  margin: 0 auto;
  padding: 16px;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.brand {
  color: var(--page-fg);
  font-weight: 700;
  text-decoration: none;
}

.site-links {
  display: flex;
  gap: 16px;
}

.site-links a {
  color: var(--muted);
  text-decoration: none;
}

.site-links a.current,
.site-links a:hover {
  color: var(--page-fg);
}

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Islands. Each mount is empty without JavaScript, so it takes no space. */

#site-search {
  position: relative;
  margin-left: auto;
}

.search input {
  width: 16rem;
  max-width: 60vw;
  padding: 6px 10px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--page-bg);
  color: var(--page-fg);
  font: inherit;
}

.search-results {
  position: absolute;
  right: 0;
  z-index: 10;
  width: 22rem;
  max-width: calc(100vw - 32px);
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  background: var(--page-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.search-results li a {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 6px 8px;
  color: var(--page-fg);
  text-decoration: none;
}

.search-results li.selected a,
.search-results li a:hover {
  background: var(--surface);
}

.search-results small,
.search-empty {
  color: var(--muted);
}

.search-empty {
  padding: 6px 8px;
}

.theme-toggle,
.menu-toggle {
  padding: 6px 10px;
  border: 1px solid var(--control-border);
  border-radius: 8px;
  background: var(--page-bg);
  color: var(--page-fg);
  font: inherit;
  cursor: pointer;
}

.menu-toggle {
  display: none;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

.theme-icon {
  display: block;
  width: 1.15rem;
  height: 1.15rem;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.theme-system {
  --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='2' y='3' width='20' height='14' rx='2'/><path d='M8 21h8M12 17v4'/></svg>");
}

.theme-light {
  --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'><circle cx='12' cy='12' r='4'/><path d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/></svg>");
}

.theme-dark {
  --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'><path d='M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z'/></svg>");
}

/* The copy button of a code block. The islands wrap each block in div.code-block. */

.code-block {
  position: relative;
  margin: 1em 0;
}

.code-block > pre {
  margin: 0;
}

.copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: 6px;
  background: var(--page-bg);
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}

.copy-button::before {
  content: "";
  width: 1rem;
  height: 1rem;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'><rect x='9' y='9' width='12' height='12' rx='2'/><path d='M5 15H4a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v1'/></svg>");
}

.copy-button[data-state="copied"] {
  color: var(--ok);
}

.copy-button[data-state="copied"]::before {
  --icon: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6L9 17l-5-5'/></svg>");
}

.copy-button[data-state="failed"] {
  color: var(--danger);
}

.copy-button::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 50%;
  right: calc(100% + 6px);
  transform: translateY(-50%);
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--page-fg);
  color: var(--page-bg);
  font: 600 0.75rem/1.4 var(--font-sans);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.code-block:hover .copy-button,
.copy-button:focus-visible,
.copy-button:not([data-state="idle"])[data-state] {
  opacity: 1;
}

.copy-button:hover::after,
.copy-button:focus-visible::after,
.copy-button:not([data-state="idle"])[data-state]::after {
  opacity: 1;
}

@media (hover: none) {
  .copy-button {
    opacity: 1;
  }
}

/* A narrow screen shows the menu button. The main links stay visible without JavaScript. */

@media (max-width: 760px) {
  .menu-toggle {
    display: inline-block;
  }

  .site-header {
    gap: 8px 16px;
  }

  #site-theme {
    margin-left: auto;
  }

  #site-search {
    order: 3;
    margin-left: 0;
    width: 100%;
  }

  .search input {
    width: 100%;
    max-width: none;
  }

  .site-links {
    flex-wrap: wrap;
    order: 4;
  }

  :root[data-js] .site-links {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  :root[data-js][data-nav-open] .site-links {
    display: flex;
  }
}

/* Landing page and articles */

.hero h1 {
  font-size: clamp(2rem, 6vw, 3.25rem);
  margin-bottom: 0.25em;
}

.article-list {
  list-style: none;
  padding: 0;
}

.article-card {
  border-top: 1px solid var(--border);
  padding: 12px 0;
}

.article-meta {
  color: var(--muted);
  font-size: 0.875rem;
}

/* Docs pages */

.docs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}

@media (min-width: 900px) {
  .docs-layout {
    grid-template-columns: 14rem minmax(0, 1fr);
  }
}

@media (min-width: 1200px) {
  .docs-layout {
    grid-template-columns: 14rem minmax(0, 1fr) 12rem;
  }
}

.docs-sidebar ul,
.docs-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.docs-sidebar li,
.docs-toc li {
  margin: 2px 0;
}

.docs-sidebar .depth-1,
.docs-toc .depth-1 {
  padding-left: 12px;
}

.docs-sidebar .depth-2 {
  padding-left: 24px;
}

.docs-sidebar a,
.docs-toc a {
  color: var(--muted);
  text-decoration: none;
}

.docs-sidebar a.current,
.docs-sidebar a:hover,
.docs-toc a:hover {
  color: var(--page-fg);
}

.docs-toc a[aria-current] {
  color: var(--accent);
  font-weight: 600;
}

.docs-sidebar a.current {
  font-weight: 600;
}

.nav-label {
  display: block;
  margin: 12px 0 4px;
  color: var(--page-fg);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.docs-rail {
  display: none;
}

/* Keep heading navigation available when browser islands cannot run. */
@media (max-width: 1199px) {
  :root:not([data-js]) .docs-rail {
    display: block;
    grid-column: 1 / -1;
    order: -1;
    padding: 12px 0;
    border-block: 1px solid var(--line);
    font-size: 0.875rem;
  }
}

@media (min-width: 1200px) {
  .docs-rail {
    display: block;
    position: sticky;
    top: 16px;
    align-self: start;
    font-size: 0.875rem;
  }
}

.page-source {
  margin-top: 32px;
  font-size: 0.875rem;
}

/* Building blocks */

.status-banner {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
}

.badge {
  display: inline-block;
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 0 6px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: middle;
}

.callout {
  --callout: var(--note);
  border-left: 4px solid var(--callout);
  background: var(--surface);
  border-radius: 0 8px 8px 0;
  margin: 1em 0;
  padding: 4px 16px;
}

.callout.tip {
  --callout: var(--tip);
}

.callout.important {
  --callout: var(--important);
}

.callout.warning {
  --callout: var(--warning);
}

.callout.caution {
  --callout: var(--caution);
}

.callout-label {
  color: var(--callout);
  font-weight: 700;
}

.diagram {
  margin: 1.5em 0;
  overflow-x: auto;
}

/* The diagram SVG sets its own white --bg and dark --fg. Use the page colors. */
.diagram svg {
  max-width: none;
  --bg: transparent !important;
  --fg: var(--page-fg) !important;
}

.layer-stack {
  margin: 1.5em 0;
}

.layer-stack ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: layer;
}

.layer-stack li {
  display: grid;
  grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--surface);
  margin: 4px 0;
  padding: 6px 12px;
}

.layer-stack li:nth-child(1) { border-left-color: var(--s0); }
.layer-stack li:nth-child(2) { border-left-color: var(--s1); }
.layer-stack li:nth-child(3) { border-left-color: var(--s2); }
.layer-stack li:nth-child(4) { border-left-color: var(--s3); }
.layer-stack li:nth-child(5) { border-left-color: var(--s4); }
.layer-stack li:nth-child(6) { border-left-color: var(--s5); }
.layer-stack li:nth-child(7) { border-left-color: var(--s6); }
.layer-stack li:nth-child(8) { border-left-color: var(--s7); }
.layer-stack li:nth-child(n + 9) { border-left-color: var(--s8); }

.layer-name {
  font-weight: 600;
}

.layer-detail {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

@media (max-width: 520px) {
  .layer-stack li {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
}

/* Version trees (design D22). The deploy fills the banner of an older or unreleased version; a build
   writes it empty, and an empty banner takes no space. */
.version-banner:empty {
  display: none;
}

.version-banner {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--accent-soft);
  color: var(--page-fg);
  text-align: center;
}

.version-banner p {
  margin: 0;
}

.version-select {
  font: inherit;
  color: var(--page-fg);
  background: var(--page-bg);
  border: 1px solid var(--control-border);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
}

/* Gallery specimens. The base HTML remains a complete family catalogue without islands. */
.gallery-index h1,
.gallery-detail h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

.gallery-index,
.gallery-detail {
  padding: 1.5rem 0 3rem;
}

.gallery-layout {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
}

.gallery-rail {
  display: grid;
  gap: 0.25rem;
  align-self: start;
  position: sticky;
  top: 1.5rem;
}

.gallery-rail nav,
.gallery-rail ul {
  display: grid;
  gap: 0.25rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.gallery-rail h2 {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-rail a {
  display: block;
  padding: 0.45rem 0.75rem;
  border-radius: 0.5rem;
  color: var(--muted);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.gallery-rail a:hover,
.gallery-rail a[aria-current] {
  background: var(--accent-soft);
  color: var(--accent);
}

.gallery-main,
.gallery-group,
.gallery-panel,
.gallery-source-file {
  min-width: 0;
}

.gallery-main > p,
.gallery-detail > p {
  color: var(--muted);
  max-width: 65ch;
}

.gallery-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin: 1.75rem 0;
}

.gallery-tools label {
  flex: 1 1 16rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.gallery-tools input {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--control-border);
  border-radius: 0.5rem;
  padding: 0.65rem 0.8rem;
  font: inherit;
  color: var(--page-fg);
  background: var(--surface);
}

.gallery-results {
  margin: 0;
  padding-bottom: 0.65rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.gallery-groups {
  display: grid;
  gap: 2rem;
}

.gallery-group > h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
  scroll-margin-top: 1rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  align-items: stretch;
  gap: 1rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.gallery-card {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
}

.gallery-card:hover,
.gallery-card:focus-within {
  border-color: var(--accent);
}

.gallery-card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--page-fg);
  text-decoration: none;
}

.gallery-card-link:hover {
  text-decoration: none;
}

.gallery-card-preview {
  display: grid;
  place-items: center;
  aspect-ratio: 8 / 5;
  margin: 0.6rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  background: #ffffff;
  color: #111827;
}

.gallery-card-preview img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.gallery-card-body {
  display: grid;
  gap: 0.65rem;
  padding: 0.65rem 1rem 1rem;
}

.gallery-card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.gallery-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.gallery-badge {
  padding: 0.15rem 0.45rem;
  border-radius: 0.35rem;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.gallery-empty {
  padding: 3rem 1.25rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--control-border);
  border-radius: 0.8rem;
}

.gallery-workbench {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface);
  overflow: hidden;
}

.gallery-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.gallery-tab,
.gallery-actions button,
.gallery-empty button,
.gallery-source button {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--control-border);
  border-radius: 0.45rem;
  background: var(--surface);
  color: var(--page-fg);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.gallery-tab[aria-selected="true"] {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.gallery-panel {
  padding: clamp(1rem, 3vw, 2rem);
}

.gallery-preview {
  margin: 0;
  padding: clamp(1rem, 3vw, 2rem);
  overflow: auto;
  border-radius: 0.5rem;
  background: #ffffff;
  color: #111827;
  text-align: center;
}

.gallery-preview img {
  display: block;
  max-width: 100%;
  max-height: 36rem;
  width: auto;
  height: auto;
  margin: auto;
  object-fit: contain;
}

.gallery-preview a {
  color: #4f46e5;
}

.gallery-preview figcaption {
  margin-top: 1rem;
  font-size: 0.875rem;
}

.gallery-source pre {
  max-width: 100%;
  padding: 1rem;
  overflow: auto;
  white-space: pre;
  background: var(--page-bg);
  line-height: 1.65;
}

.gallery-source-file + .gallery-source-file {
  margin-top: 2rem;
}

.gallery-source-heading,
.gallery-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}

.gallery-source-heading h2,
.gallery-source-heading h3 {
  margin: 0;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.gallery-actions {
  padding: 1rem 0;
  font-size: 0.875rem;
}

.gallery-scope {
  margin: 1rem 0;
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--page-fg);
  font-size: 0.875rem;
}

.gallery-dark {
  display: none;
}

:root[data-theme="dark"] .gallery-light:not(.gallery-light-only) {
  display: none;
}

:root[data-theme="dark"] .gallery-dark:not([hidden]) {
  display: block;
}

:root[data-theme="dark"] .gallery-preview.gallery-dark,
:root[data-theme="dark"] .gallery-card-preview.gallery-dark {
  background: #161b22;
  color: #f0f6fc;
}

:root[data-theme="dark"] .gallery-preview.gallery-dark a {
  color: #a5b4fc;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .gallery-light:not(.gallery-light-only) {
    display: none;
  }
  :root:not([data-theme="light"]) .gallery-dark:not([hidden]) {
    display: block;
  }
  :root:not([data-theme="light"]) .gallery-preview.gallery-dark,
  :root:not([data-theme="light"]) .gallery-card-preview.gallery-dark {
    background: #161b22;
    color: #f0f6fc;
  }
  :root:not([data-theme="light"]) .gallery-preview.gallery-dark a {
    color: #a5b4fc;
  }
}

@media (max-width: 760px) {
  .gallery-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
  .gallery-rail {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .gallery-rail nav,
  .gallery-rail ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
}

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

/* Enhanced browsing combines families into one grid; the static headings keep their anchors. */
[data-gallery-index][data-enhanced] .gallery-groups {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: 1rem;
}

[data-gallery-index][data-enhanced] .gallery-group,
[data-gallery-index][data-enhanced] .gallery-grid {
  display: contents;
}

[data-gallery-index][data-enhanced] .gallery-group > h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.gallery-tabs:empty,
.gallery-tools:empty {
  display: none;
}


.site-links a.current {
  color: var(--accent);
  font-weight: 600;
}

.gallery-card-body > p {
  margin: 0;
}

.gallery-card-body > p:not(.gallery-card-meta) {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.gallery-tools > button,
.gallery-empty button {
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 0.5rem;
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.gallery-source-heading {
  font-size: 0.95rem;
  overflow-wrap: anywhere;
}

.gallery-placeholder {
  display: grid;
  align-content: center;
  min-height: 10rem;
  padding: 1rem;
  margin: 0.6rem;
  text-align: center;
  color: var(--muted);
  background: var(--page-bg);
  border-radius: 0.5rem;
}

/* Detail metadata reads as one sentence; card metadata keeps its compact row. */
.gallery-detail > .gallery-card-meta {
  display: block;
  font-size: 0.875rem;
}

.gallery-detail[data-enhanced] .gallery-panel > h2 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
