:root {
  color-scheme: dark;
  --bg: #101216; --strip: #14161a; --panel: #1a1d23; --inset: #111317; --line: #ffffff1b; --line-strong: #ffffff38;
  --text: #eef0ea; --text-2: #ffffffc2; --text-3: #9c9f99;
  --button: #ffffff0d; --button-hover: #ffffff1c; --on-primary: #15171c; --error: #ffb4a6;
  /* Matches the example scenes' paper, so a preview canvas blends into its cell. */
  --paper: #16181b;
  --sans: Inter, "SF Pro Text", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --round: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", var(--sans);
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --gutter: clamp(16px, 2vw, 36px);
  --cell-inset: clamp(5px, .5vw, 10px);
  font-family: var(--sans); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; scrollbar-color: var(--line-strong) transparent;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f2; --strip: #fafaf7; --panel: #fcfcfa; --inset: #eeefeb;
  --line: #22282020; --line-strong: #22282042; --text: #252925; --text-2: #535951; --text-3: #787c72;
  --button: #24282406; --button-hover: #24282410; --on-primary: #fff; --error: #a33c2c;
  --paper: #fbfbf8;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
p, h1, h2, h3 { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
[hidden] { display: none !important; }
/* Canvas text must rasterize exactly like the exported standalone HTML. */
canvas { -webkit-font-smoothing: auto; }

/* Page chrome */
.topbar { position: relative; z-index: 10; display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 24px; padding: 0 var(--gutter); background: var(--strip); border-bottom: 1px solid var(--line); }
.wordmark { display: flex; align-items: center; gap: 9px; font: 700 20px var(--sans); letter-spacing: -.03em; white-space: nowrap; }
.brand-mark { width: 24px; height: 24px; fill: currentColor; }
.dimension-switch { display: flex; align-self: stretch; gap: 18px; margin-right: auto; }
.dimension-switch a, .dimension-switch button { position: relative; display: inline-flex; align-items: center; gap: 5px; padding: 0 2px; border: 0; background: none; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.dimension-switch a[aria-current=page], .dimension-switch a:hover, .dimension-switch button:hover { color: var(--text); }
.dimension-switch a[aria-current=page]::after { content: ''; position: absolute; inset: auto 0 -1px; height: 2px; background: var(--text); }
.text-button { background: none; border: 0; color: var(--text-2); padding: 6px 0; font-size: 13px; }
.text-button:hover { color: var(--text); }
main { width: 100%; padding: 0 var(--gutter); margin: auto; }
.skill-download { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex-shrink: 0; height: 32px; padding: 0 14px; border: 1px solid var(--text); border-radius: 4px; color: var(--on-primary); font-size: 11px; font-weight: 550; white-space: nowrap; background: var(--text); }
.skill-download:hover { opacity: .85; }
.download-dialog { --star-gold: #edc45a; width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; overflow: auto; border: 1px solid var(--line-strong); border-radius: 18px; color: var(--text); background: var(--paper); box-shadow: 0 32px 120px #0005; }
.download-dialog::backdrop { background: #0e12187a; backdrop-filter: blur(6px); }
.download-dialog .download-close { position: absolute; top: 12px; right: 16px; width: 34px; height: 34px; border: 0; border-radius: 50%; }
.download-content { padding: 42px 36px 36px; text-align: center; }
.download-art { display: block; width: 216px; height: 144px; margin: 0 auto 20px; overflow: visible; }
.star-main { fill: var(--star-gold); stroke: var(--star-gold); stroke-width: 3; stroke-linejoin: round; transform-box: fill-box; transform-origin: center; }
.star-ring, .star-burst { opacity: 0; fill: none; stroke: var(--star-gold); stroke-width: 2; stroke-linecap: round; transform-origin: 120px 80px; }
.star-burst circle { fill: var(--star-gold); stroke: none; }
.download-dialog[open] .star-main { animation: star-like 3.6s ease-in-out infinite; }
.download-dialog[open] .star-ring { animation: star-ring 3.6s ease-out infinite; }
.download-dialog[open] .star-burst { animation: star-burst 3.6s ease-out infinite; }
@keyframes star-like {
  0%, 8%, 100% { transform: scale(1) rotate(0); fill: var(--paper); }
  13% { transform: scale(.82) rotate(-8deg); fill: var(--paper); }
  22% { transform: scale(1.16) rotate(5deg); fill: var(--star-gold); }
  30% { transform: scale(.96) rotate(-2deg); }
  38%, 88% { transform: scale(1) rotate(0); fill: var(--star-gold); }
}
@keyframes star-ring {
  0%, 14% { opacity: 0; transform: scale(.75); }
  16% { opacity: .5; transform: scale(.75); }
  38%, 100% { opacity: 0; transform: scale(1.55); }
}
@keyframes star-burst {
  0%, 16% { opacity: 0; transform: scale(.65); }
  23% { opacity: 1; transform: scale(.95); }
  42%, 100% { opacity: 0; transform: scale(1.16); }
}
@media (prefers-reduced-motion: reduce) {
  .download-dialog[open] .star-main, .download-dialog[open] .star-ring, .download-dialog[open] .star-burst { animation: none; }
}
.download-dialog h2 { font-size: clamp(27px, 4vw, 32px); font-weight: 650; line-height: 1.3; letter-spacing: -.04em; text-wrap: balance; }
#download-message { margin-top: 10px; color: var(--text-2); font-size: 13px; line-height: 1.7; text-wrap: balance; }
.download-actions { margin-top: 28px; }
.download-star { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 18px; border: 1px solid var(--text); border-radius: 4px; background: var(--text); color: var(--on-primary); font-size: 13px; font-weight: 550; }
.download-star:hover { opacity: .85; }
.download-star svg { width: 18px; height: 18px; fill: currentColor; }
@media (max-width: 480px) {
  .download-content { padding-inline: 24px; }
  .download-art { width: 192px; height: 128px; }
}
.skill-download svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tools { display: flex; gap: 8px; align-items: center; min-width: 0; }
.github-cta { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: 4px; color: var(--text-2); }
.github-cta:hover { background: var(--button-hover); color: var(--text); }
.github-cta svg { width: 21px; height: 21px; fill: currentColor; }
.language-toggle { height: 32px; min-width: 32px; padding: 0 5px; border: 0; background: transparent; color: var(--text-2); font-size: 11px; }
.language-toggle:hover { color: var(--text); background: var(--button-hover); }
.effect-search { position: relative; min-width: 0; }
.search-panel { position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; width: 340px; max-width: calc(100vw - 32px); max-height: min(400px, 65dvh); overflow: auto; padding: 5px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--panel); box-shadow: 0 12px 36px #0002; }
.search-result { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 8px; border-radius: 4px; }
.search-result:hover, .search-result[aria-selected=true] { background: var(--button-hover); }
.search-preview { display: block; width: 72px; height: 48px; flex-shrink: 0; border-radius: 4px; background: var(--paper); border: 1px solid var(--line); }
.search-result-body { display: grid; gap: 2px; min-width: 0; }
.search-result strong { font-size: 13px; font-weight: 600; }
.search-result small { font: 10px/1.5 var(--mono); color: var(--text-3); }
.search-empty { padding: 20px 12px; font-size: 13px; color: var(--text-2); }
body[data-view=gallery] .tools > .skill-download { display: none; }
.search { display: flex; align-items: center; gap: 8px; height: 32px; min-width: 0; padding: 0 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; }
.search:focus-within { border-color: var(--line-strong); }
.search svg { width: 14px; height: 14px; fill: none; stroke: var(--text-3); stroke-width: 1.5; stroke-linecap: round; flex-shrink: 0; }
.search input { width: 140px; min-width: 0; background: none; border: 0; outline: 0; font-size: 11px; }
.search input::placeholder { color: var(--text-3); }
.search kbd { font: 11px var(--mono); color: var(--text-3); border: 1px solid var(--line-strong); border-radius: 5px; padding: 1px 6px; }
.icon-button { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; background: transparent; border: 1px solid var(--line); border-radius: 4px; color: var(--text-3); }
.icon-button:hover { background: var(--button-hover); color: var(--text); }
.icon-button::before { content: ""; width: 12px; height: 12px; background: currentColor; }
.icon-button[data-icon=play]::before { clip-path: polygon(18% 4%, 96% 50%, 18% 96%); }
.icon-button[data-icon=pause]::before { clip-path: polygon(12% 4%, 38% 4%, 38% 96%, 12% 96%, 12% 4%, 62% 4%, 62% 96%, 88% 96%, 88% 4%, 62% 4%); }
.icon-button[data-icon=close]::before { clip-path: polygon(14% 4%, 50% 40%, 86% 4%, 96% 14%, 60% 50%, 96% 86%, 86% 96%, 50% 60%, 14% 96%, 4% 86%, 40% 50%, 4% 14%); }

/*
 * Periodic table. Columns are bottom-aligned; each family is named once above its tallest column, and the title sits
 * in the gap above the short middle columns. Cells are sheets of paper: the family colour marks only the symbol.
 */
.periodic-table { display: grid; grid-template-columns: repeat(var(--columns, 15), minmax(0, 1fr)); gap: 4px; margin-top: 12px; }
.periodic-table[aria-busy=true] { position: relative; overflow: hidden; }
/* One shimmer layer for the whole skeleton, instead of animating every placeholder. */
.periodic-table[aria-busy=true]::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(110deg, transparent 35%, #ffffff0c 50%, transparent 65%); animation: table-loading 1.8s ease-in-out infinite; }
@keyframes table-loading { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.periodic-table[aria-busy=true] .zoom::before { content: ""; position: absolute; width: 36%; aspect-ratio: 1; left: 32%; top: 34%; border-radius: 25%; background: var(--line); }
.series-label { grid-column: var(--column); grid-row: var(--row); align-self: end; justify-self: start; display: flex; align-items: center; gap: 5px; padding: 0 0 4px 6px; border: 0; background: none; font-size: 10px; line-height: 1; color: var(--text-3); white-space: nowrap; }
.series-label::before { content: ''; width: 3px; height: 9px; background: var(--fill); }
.element { grid-column: var(--column); grid-row: calc(var(--row) + 1); position: relative; aspect-ratio: 3 / 4; container-type: inline-size; min-width: 0; padding: 0; overflow: hidden; text-align: left; color: var(--text); background: var(--paper); border: 1px solid var(--line); border-radius: 3px; transition: border-color .15s; }
.element:hover, .element:focus-visible { z-index: 2; border-color: var(--fill); outline: 0; }
/* Outline demos show the middle of their sheet at full cell width. Text has its own camera fitted to the words. */
.zoom { position: absolute; inset: 0; overflow: hidden; }
.zoom canvas { position: absolute; left: 50%; top: 52%; width: 150%; height: auto; aspect-ratio: 8 / 5; translate: -50% -50%; }
.element[data-preview=text] .zoom { inset: 32% 8% 25%; container-type: size; }
.element[data-preview=text] .zoom canvas { width: min(calc(100cqw * var(--preview-width-scale, 1)), calc(100cqh * var(--preview-height-scale, 1))); height: auto; left: 50%; top: 50%; translate: var(--preview-x, -50%) var(--preview-y, -50%); }
.element-symbol, .element-number, .element-name { position: absolute; }
.element-symbol { left: 8%; top: 7%; font: 650 clamp(15px, 29cqw, 32px)/1 var(--round); letter-spacing: -.025em; color: var(--fill); }
.element-number { right: 8%; top: 8%; font: clamp(8px, 11cqw, 11px)/1 var(--mono); color: var(--text-3); opacity: .65; }
.element-name { left: 8%; right: 8%; bottom: 6%; overflow: hidden; text-overflow: ellipsis; font-size: clamp(10px, 14cqw, 14px); font-weight: 550; line-height: 1.2; white-space: nowrap; }
.table-intro { grid-row: 1 / 3; grid-column: var(--intro-columns, 1 / -1); min-width: 0; align-self: start; padding-top: 0; text-align: center; pointer-events: none; z-index: 1; }
.table-title { min-width: 0; }
.table-title h1 { font: 620 clamp(28px, 4.5vw, 58px)/1.15 var(--sans); letter-spacing: .045em; text-indent: .045em; white-space: nowrap; }
.table-title h1 strong { font: inherit; }
html[lang=en] .table-title h1 { font-size: clamp(26px, 3.1vw, 46px); letter-spacing: -.03em; text-indent: 0; }
html[lang=en] .element-name { font-size: clamp(8px, 12cqw, 12px); white-space: normal; }
.table-title h1 span { display: block; margin-top: 12px; font: 10px/1.3 var(--mono); letter-spacing: .22em; text-indent: .22em; text-transform: uppercase; color: var(--text-3); }
.product-intro { padding: 0 14px 6px; pointer-events: auto; }
.product-actions { display: flex; align-items: center; justify-content: center; gap: 20px; margin-top: 16px; }
.product-actions .skill-download { min-width: 180px; height: 46px; gap: 28px; padding-inline: 24px; border-radius: 6px; font-size: 15px; }
.page-status { color: var(--text-3); font-size: 13px; margin-top: 16px; text-align: center; }
.page-status:empty { display: none; }
.empty { text-align: center; padding: 56px 20px; color: var(--text-2); font-size: 14px; }

@media (min-width: 1101px) {
  /* Fill both axes beneath the 62px header.
     Tiny-height windows can scroll instead of clipping controls or cell labels. */
  .gallery-page { padding-top: 12px; padding-bottom: 18px; }
  .gallery-page { height: calc(100dvh - 62px); min-height: 540px; display: flex; flex-direction: column; }
  .periodic-table { container-type: inline-size; margin-top: 0; }
  .periodic-table { flex: 1; min-height: 0; grid-template-rows: 24px repeat(5, minmax(0, 1fr)); }
  .periodic-table .element { aspect-ratio: auto; min-height: 0; container-type: size; }
  .periodic-table .element-symbol { font-size: clamp(15px, min(29cqw, 24cqh), 32px); }
  .table-title h1 { font-size: clamp(28px, min(4.5cqw, 6.7dvh), 58px); }
  /* Center on the whole table; keep the hit area confined to the title and download. */
  .periodic-table .table-intro { grid-row: 1 / 3; grid-column: 1 / -1; place-self: center; }
  .product-intro { padding-top: 0; }
  .product-actions { margin-top: 16px; }
  .series-label { padding-top: 0; }

}

/* Keep the preview, transport and code in the viewport. Long parameter
   lists scroll within their column; small screens retain normal page scrolling. */
.detail-page { max-width: 1800px; height: calc(100dvh - 62px); min-height: 540px; display: flex; flex-direction: column; padding: 12px var(--gutter); }
.back-link { display: inline-flex; align-items: center; flex-shrink: 0; min-height: 36px; font-size: 13px; color: var(--text-2); }
.back-link:hover { color: var(--text); }
.detail-header { display: flex; align-items: center; flex-shrink: 0; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.detail-symbol { color: #fff; display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; font: 700 22px/1 var(--round); letter-spacing: -.02em; background: var(--fill); border-radius: 10px; }
.detail-identity { flex: 1; min-width: 0; }
.detail-identity h1 { font-size: clamp(22px, 2vw, 28px); font-weight: 700; line-height: 1.25; letter-spacing: .02em; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 2px; font-size: 12px; color: var(--text-2); }
#recipe-id { font-family: var(--mono); color: var(--text-3); }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: "preview controls" "code controls"; flex: 1; min-height: 0; }
.preview-panel { grid-area: preview; display: flex; flex-direction: column; padding: 16px 20px 16px 0; min-width: 0; min-height: 0; }
.preview-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; border-radius: 12px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.detail-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-2); background: linear-gradient(110deg, transparent 35%, #ffffff0c 50%, transparent 65%); }
.detail-page[aria-busy=false] .detail-loading { display: none; }
#canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.transport { display: flex; align-items: center; flex-shrink: 0; gap: 14px; padding-top: 12px; }
.transport .icon-button { border-radius: 50%; }
.transport input { flex: 1; min-width: 10px; }
.transport span { min-width: 70px; text-align: right; color: var(--text-2); font: 12px var(--mono); white-space: nowrap; }
.recipe-description { flex-shrink: 0; margin-top: 8px; color: var(--text-2); font-size: 13px; line-height: 1.5; }
.controls { grid-area: controls; display: flex; flex-direction: column; min-height: 0; padding: 12px 16px 16px 20px; border-left: 1px solid var(--line); overflow: auto; scrollbar-width: thin; }
.controls > * { flex-shrink: 0; }
.controls-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.controls-heading h3 { font-size: 15px; font-weight: 600; letter-spacing: .08em; }
.parameter { margin-bottom: 14px; }
.parameter label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 13px; }
.parameter output { font: 12px var(--mono); color: var(--text-2); }
input[type=range] { --fill-to: 0%; appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 20px; margin: 0; background: none; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--text) var(--fill-to), var(--line-strong) var(--fill-to)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%; background: var(--text); box-shadow: 0 0 0 3px var(--fill, var(--panel)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-strong); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--text); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--text); }
.field { display: block; font-size: 12px; color: var(--text-2); }
.parameter select, .field textarea, .field input { display: block; width: 100%; padding: 8px 10px; font-size: 13px; color: var(--text); background: var(--inset); border: 1px solid var(--line-strong); border-radius: 8px; }
.parameter select { appearance: none; padding-right: 30px; background: var(--inset) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='m3 4.5 3 3 3-3' fill='none' stroke='%23838b80' stroke-width='1.5'/%3E%3C/svg%3E") right 10px center / 12px no-repeat; }
.field textarea, .field input { margin-top: 6px; }
.field textarea { resize: vertical; line-height: 1.6; margin-bottom: 16px; }
.two-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.backend-state { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 16px; font-size: 12px; }
.backend-state span { padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--text-2); }
.backend-state .backend-ready { color: var(--text); border-color: var(--text); }
.code-panel { grid-area: code; min-width: 0; margin-right: 20px; padding: 12px 0 0; border-top: 1px solid var(--line); }
.code-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.code-tabs { display: flex; flex-shrink: 0; padding: 3px; background: var(--inset); border: 1px solid var(--line); border-radius: 10px; }
.code-tabs button { padding: 6px 12px; background: none; border: 0; border-radius: 7px; color: var(--text-2); font: 12px var(--mono); white-space: nowrap; }
.code-tabs button:hover { color: var(--text); }
.code-tabs button[aria-selected=true] { background: var(--text); color: var(--on-primary); }
#toggle-code { flex-shrink: 0; min-height: 36px; }
#code-note { margin-top: 8px; font-size: 12px; line-height: 1.5; color: var(--text-3); }
#scene-source { max-height: min(22dvh, 180px); margin: 8px 0 0; padding: 10px 12px; overflow: auto; white-space: pre; font: 12px/1.65 var(--mono); color: var(--text-2); background: var(--inset); border: 1px solid var(--line); border-radius: 10px; scrollbar-width: thin; }
.status { min-width: 0; margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--text-2); }
.status.error, .page-status.error { color: var(--error); }
.primary, .secondary { height: 38px; padding: 0 18px; flex-shrink: 0; font-size: 13px; font-weight: 600; white-space: nowrap; border-radius: 9px; }
.primary { background: var(--text); border: 1px solid var(--text); color: var(--on-primary); }
.primary:hover:enabled { background: var(--text); filter: brightness(.9); }
.secondary { background: var(--button); border: 1px solid var(--line-strong); color: var(--text); }
.secondary:hover:enabled { background: var(--button-hover); }

@media (max-width: 1100px) {
  .topbar { gap: 16px; }
  .dimension-switch { gap: 14px; }
  .search input { width: 115px; }
  :root { --cell-inset: clamp(8px, 1vw, 12px); }
  .series-label { display: none; }
  .periodic-table { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .element { grid-column: auto; grid-row: auto; }
  .table-intro { grid-column: 1 / -1; grid-row: auto; padding: 30px 0 28px; }
  .table-title h1 { font-size: 40px; }
  .product-intro { padding-bottom: 0; }
  .detail-layout { grid-template-columns: minmax(0, 1fr) 280px; }
}
@media (max-width: 900px) {
  .topbar { height: auto; min-height: 104px; flex-wrap: wrap; gap: 0 12px; padding-top: 10px; padding-bottom: 10px; }
  .dimension-switch { margin-left: auto; margin-right: 0; align-self: auto; }
  .dimension-switch a, .dimension-switch button { min-height: 30px; }
  .dimension-switch a[aria-current=page]::after { display: none; }
  .tools { width: 100%; margin-top: 8px; }
  .effect-search { flex: 1; }
  .search input { width: 100%; }
}
@media (max-width: 680px) {
  .wordmark { font-size: 19px; }
  .brand-mark { width: 23px; height: 23px; }
  .dimension-switch { margin-left: auto; margin-right: 0; gap: 10px; align-self: auto; }
  .dimension-switch a, .dimension-switch button { min-height: 30px; padding: 0; font-size: 11px; }
  .dimension-switch a[aria-current=page]::after { display: none; }
  .tools { width: 100%; margin-top: 8px; }
  .tools > .skill-download { display: none; }
  .search kbd, #recipe-id { display: none; }
  .effect-search { flex: 1; }
  .search-panel { left: 0; right: auto; }
  .search { width: 100%; }
  .search input { width: 100%; }
  .periodic-table { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .table-intro { padding: 28px 0 30px; }
  .table-title h1 { font-size: 34px; }
  html[lang=en] .table-title h1 { font-size: clamp(23px, 6.8vw, 34px); }
  .table-title h1 span { margin-top: 10px; font-size: 9px; letter-spacing: .15em; text-indent: .15em; }
  .element-symbol { font-size: 28px; }
  .element-number { font-size: 10px; }
  .element-name { font-size: 13px; }
  html[lang=en] .element-name { font-size: 12px; }
  body[data-view=detail] .tools { width: 100%; justify-content: flex-end; }
  .detail-page { height: auto; min-height: 0; }
  .detail-header { flex-wrap: wrap; gap: 8px 12px; }
  .detail-header .back-link { order: -1; flex-basis: 100%; min-height: 28px; }
  .detail-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; grid-template-areas: "preview" "controls" "code"; }
  .preview-panel, .controls { padding: 12px 0; }
  .preview-stage { flex: none; height: clamp(160px, 25dvh, 240px); }
  .controls { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .code-panel { margin-right: 0; }
  #parameters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
  .parameter label { flex-wrap: wrap; gap: 2px 8px; }
  .backend-state { padding-top: 12px; }
  .code-heading { flex-wrap: wrap; gap: 8px 12px; }
  .code-tabs { flex: 1; }
  .code-tabs button { flex: 1; padding: 6px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .periodic-table[aria-busy=true]::after { animation: none; display: none; }
  button, .element { transition: none; }
  .element:hover, .element:focus-visible { scale: none; }
}

/* A quiet, keyboard-accessible mode switch. Theme bootstrap also works before hydration. */
.theme-toggle { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--text-3); cursor: pointer; }
.theme-toggle:hover { background: var(--button-hover); border-color: var(--line-strong); }
.theme-toggle > span { display: grid; place-items: center; }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:root:not([data-theme="dark"]) .theme-when-dark, :root[data-theme="dark"] .theme-when-light { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* The atom and its settings share one workspace; only long controls and code scroll. */
.detail-split { height: calc(100dvh - 62px); min-height: 650px; }
.detail-split .detail-layout { grid-template-columns: minmax(0, 1fr) minmax(340px, 30%); grid-template-rows: minmax(0, 1fr); grid-template-areas: "preview settings"; column-gap: 24px; flex: 1; }
.detail-visuals { grid-area: preview; display: flex; min-width: 0; min-height: 0; }
.detail-settings { grid-area: settings; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding-left: 24px; border-left: 1px solid var(--line); }
.detail-split .preview-panel { width: 100%; padding: 12px 0; }
.detail-split .preview-stage { flex: 1; height: auto; min-height: 160px; }
.detail-split .transport { padding-top: 8px; }
.detail-split .recipe-description { margin-top: 6px; }
.detail-split .controls { flex: 0 1 auto; max-height: calc(100% - 150px); padding: 12px 0; border: 0; }
.detail-split .controls-heading { margin-bottom: 8px; }
.detail-split .parameter { margin-bottom: 10px; }
.detail-split .backend-state { margin-top: 0; padding-top: 10px; }
.detail-split .code-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; margin: 0 0 12px; padding-top: 8px; }
.detail-split .code-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; flex-shrink: 0; }
.detail-split .code-tabs button { flex: 1; padding: 6px; font-size: 11px; }
.detail-split #toggle-code { font-size: 12px; }
.detail-split #code-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.detail-split #code-note { margin-top: 4px; flex-shrink: 0; }
.detail-split #scene-source { flex: 1; min-height: 0; max-height: none; margin-top: 6px; }
.detail-split .status:empty { display: none; }
@media (max-width: 1100px) {
  .detail-split { height: auto; min-height: calc(100dvh - 62px); }
  .detail-split .preview-stage { flex: none; height: clamp(200px, 36dvh, 360px); }
  .detail-split .controls { max-height: 300px; }
  .detail-split #scene-source { max-height: 160px; }
}
@media (max-width: 800px) {
  .detail-split .detail-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; grid-template-areas: "preview" "settings"; }
  .detail-settings { margin-top: 20px; padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .detail-split .controls { max-height: none; overflow: visible; }
}
@media (max-width: 680px) {
  .detail-split .detail-header { flex-wrap: nowrap; }
  .detail-split .detail-header .back-link { order: 0; flex-basis: auto; font-size: 12px; }
  .detail-split .preview-stage { height: clamp(164px, 24dvh, 220px); }
}

/* Combination demos: each card is a scene with a timeline of the atoms that build it. Scenes keep their own
   footage colours in both themes; the page around them follows the theme. */
.combos-page { max-width: 1440px; padding-top: 28px; padding-bottom: 72px; }
.combo-sets { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; }
.combo-sets button { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--button); color: var(--text-2); font-size: 13px; font-weight: 600; }
.combo-sets button:hover { color: var(--text); background: var(--button-hover); }
.combo-sets button[aria-pressed=true] { background: var(--text); border-color: var(--text); color: var(--on-primary); }
.combos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 36px 24px; }
.combo-card { margin: 0; min-width: 0; }
.combo-card canvas { display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; background: #000; }
.combo-card figcaption { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 12px; }
.combo-card figcaption b { font-size: 15px; font-weight: 650; }
.combo-card .tag { padding: 2px 7px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--text-2); font: 11px var(--mono); }
.combo-card .use { color: var(--text-3); font-size: 12px; }
.combo-card .how { margin-top: 4px; color: var(--text-2); font-size: 13px; }
.tracks { --label: 84px; position: relative; display: grid; gap: 3px; margin-top: 12px; }
html[lang=en] .tracks { --label: 112px; }
.track { display: grid; grid-template-columns: var(--label) 1fr; align-items: center; }
.track a { overflow: hidden; color: var(--text-2); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.track a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.track a b { margin-right: 4px; color: var(--c); font: 700 11px var(--round); }
.track .lane { position: relative; height: 8px; border-radius: 4px; background: var(--line); }
.track .lane i { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--c); opacity: .35; transition: opacity .15s; }
.track .lane i.on { opacity: 1; }
.playhead { position: absolute; top: -3px; bottom: -3px; left: calc(var(--label) + (100% - var(--label)) * var(--x, 0)); width: 1.5px; background: var(--text); pointer-events: none; }
@media (max-width: 680px) {
  .combos-page { padding-top: 16px; }
  .combos { gap: 28px; }
}
@media (prefers-reduced-motion: reduce) { .track .lane i { transition: none; } }

/* Attribution stays available without taking space from the one-screen table. */
.credits-dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 0; border: 1px solid var(--line-strong); color: var(--text); background: var(--paper); }
.credits-dialog::backdrop { background: #14181088; backdrop-filter: blur(3px); }
.credits-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 26px; border-bottom: 1px solid var(--line); }
.credits-heading h2 { margin-top: 5px; font-size: 25px; font-weight: 600; }
.credits-eyebrow { font: 9px/1.4 var(--mono); letter-spacing: .08em; color: var(--text-3); }
.credits-body { padding: 26px 28px; font-size: 13px; line-height: 1.9; }
.credits-reference { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 0; margin-top: 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.credits-reference b { font-size: 14px; font-weight: 550; }
.credits-reference small { display: block; margin-top: 3px; font-size: 11px; color: var(--text-3); }
.credits-reference:hover b { text-decoration: underline; text-underline-offset: 3px; }
.credits-note { margin-top: 20px; color: var(--text-3); font-size: 11px; }
@media (max-width: 680px) {
  .credits-heading { padding: 18px 20px; }
  .credits-heading h2 { font-size: 21px; }
  .credits-body { padding: 20px; }
}
