.theory-search-row { display:flex; gap:16px; align-items:center; }
.theory-search-row input { width:100%; min-width:0; font-size:16px; }
.theory-search-row button { font-size:13px; padding-right:0; }
#theory-index { margin:12px 0 30px; }
#theory-topics { display:grid; grid-template-columns:1fr 1fr; gap:2px 16px; padding:8px 0; }
#theory-topics button { text-align:left; padding-left:0; font-size:13px; opacity:.65; }
#theory-topics button[aria-pressed="true"] { opacity:1; }
.theory-page h2 { font-size:22px; font-weight:400; margin:0 0 18px; }
#theory-description { font-size:14px; line-height:1.75; margin:0 0 24px; max-width:560px; }
#theory-controls { display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px; margin-bottom:20px; }
#theory-controls label { display:flex; gap:12px; align-items:center; flex:1 1 100%; min-width:0; }
#theory-controls input:not([type="range"]) { width:100%; min-width:0; font-size:16px; }
/* A native slider owns its touch gesture; surrounding labels and paper still scroll. */
#theory-controls input[type="range"] { width:100%; min-width:0; accent-color:var(--ink); touch-action:none; }
#theory-controls label>span { min-width:74px; }
#theory-controls button { font-size:12px; }
#theory-controls button[aria-pressed="false"] { opacity:.45; }
.theory-strip { display:flex; gap:6px; margin:10px 0 24px; }
.theory-swatch { flex:1; min-width:0; height:130px; display:flex; align-items:flex-end; justify-content:center; padding:12px 2px; font-size:10px; text-decoration:none; border:1px solid #8884; }
.theory-labels { font-size:12px; margin:6px 0 10px; }
.theory-wheel { display:block; width:min(100%,360px); margin:18px auto; overflow:visible; }
.theory-wheel circle { fill:none; stroke:var(--ink); stroke-width:1; }
.theory-wheel line { stroke:var(--ink); stroke-width:1; opacity:.65; }
.theory-mix-result { height:230px; display:flex; align-items:center; justify-content:center; font-size:20px; border:1px solid #8884; }
.theory-context { position:relative; display:grid; grid-template-columns:1fr 1fr; min-height:250px; }
.theory-context>div { display:flex; align-items:center; justify-content:center; }
.theory-context span { display:block; width:30%; aspect-ratio:1; }
.theory-context .bridge { position:absolute; left:17.5%; top:calc(50% - 2px); width:65%; height:4px; aspect-ratio:auto; }
.theory-type { padding:28px; border:1px solid #8884; }
.theory-type p { font-size:28px; margin:0 0 22px; }
.theory-type small { font-size:13px; }
.theory-proportion { display:flex; height:250px; border:1px solid #8884; }
.theory-proportion>div { min-width:0; display:flex; align-items:flex-end; justify-content:center; padding:14px 0; font-size:11px; }
.theory-sources { margin-top:30px; border-top:1px solid #8884; padding-top:6px; }
.theory-sources a { display:block; color:inherit; font-size:12px; line-height:1.6; padding:12px 0; min-height:44px; }
.theory-sources p,#theory-status { font-size:12px; line-height:1.6; }
#theory-status { min-height:20px; }
@media(max-width:600px) {
 .theory-swatch { height:100px; font-size:10px; }
 .theory-strip { flex-wrap:wrap; gap:4px; }.theory-swatch { flex:1 1 22%; }
 .theory-context { min-height:200px; }.theory-type { padding:24px 16px; }
}
.theory-wheel-disc { display:block; position:relative; width:min(100%,320px); aspect-ratio:1; height:auto; margin:16px auto 28px; padding:0; border:0; border-radius:50%; background:conic-gradient(#f00,#ff0,#0f0,#0ff,#00f,#f0f,#f00); }
.theory-wheel-disc::before { content:''; position:absolute; inset:22%; border-radius:50%; background:var(--paper); }
.theory-wheel-disc svg { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; }
.theory-wheel-disc line { stroke:var(--ink); stroke-width:1; opacity:.65; }
.theory-wheel-disc circle { stroke:var(--ink); stroke-width:1.5; fill:var(--paper); }
.theory-swatch:focus-visible { outline-color:var(--ink); }

.theory-wheel-disc { touch-action:none; user-select:none; -webkit-user-select:none; -webkit-touch-callout:none; cursor:grab; }
.theory-dragging,.theory-dragging .theory-wheel-disc { cursor:grabbing; }

/* Every lesson introduces its idea immediately under the heading. */
.theory-experiment { display:flex; flex-direction:column; }
.theory-experiment #theory-title { order:0; }
.theory-experiment #theory-visual { order:2; margin:4px 0 24px; }
.theory-experiment #theory-description { order:1; }
.theory-experiment #theory-controls { order:3; margin-bottom:6px; }
.theory-experiment #theory-note { order:4; }
#theory-title { scroll-margin-top:24px; }
.theory-lab-frame { padding:18px; background:var(--paper); border:1px solid #8883; }
.theory-lab-stage { position:relative; aspect-ratio:1.5; overflow:hidden; touch-action:none; user-select:none; -webkit-user-select:none; cursor:grab; }
.theory-lab-stage.is-dragging { cursor:grabbing; }
.theory-lab-stage>canvas { display:block; width:100%; height:100%; }
.theory-lab-additive { background:#000; }
.theory-light-handle { position:absolute; transform:translate(-50%,-50%); width:44px; height:44px; padding:0; border:0; background:transparent; color:#fff; font-size:10px; text-shadow:0 1px 3px #000; cursor:grab; }
.theory-light-handle::before { content:''; position:absolute; inset:14px; border:1px solid #fff9; border-radius:50%; }
.theory-light-handle { padding-top:30px; }
.theory-lab-gradients { aspect-ratio:auto; cursor:default; overflow:visible; touch-action:auto; }
.theory-gradient-row+.theory-gradient-row { margin-top:22px; }
.theory-gradient-label { display:flex; justify-content:space-between; font-size:12px; margin-bottom:8px; }
.theory-gradient-label a { color:inherit; min-height:24px; text-decoration:none; }
.theory-gradient-track { position:relative; height:74px; cursor:ew-resize; touch-action:none; }
.theory-gradient-track canvas { width:100%; height:100%; display:block; }
.theory-gradient-marker { position:absolute; top:-4px; bottom:-4px; width:1px; background:#fff; box-shadow:0 0 0 1px #0007; pointer-events:none; transform:translateX(-.5px); }
.theory-gradient-label a:focus-visible,.theory-lab-stage:focus-visible,.theory-gradient-track:focus-visible { outline:1px solid var(--ink); outline-offset:5px; }
.theory-explore { border-top:1px solid #8884; margin-top:30px; padding-top:14px; }
.theory-explore>p { font-size:11px; opacity:.6; margin:0 0 2px; }
#theory-related { display:flex; gap:12px; overflow-x:auto; }
#theory-related button { flex:none; font-size:12px; padding:8px 0; min-height:44px; white-space:nowrap; }
#theory-index { margin:6px 0 20px; }
@media(max-width:600px) {
 .theory-lab-frame { padding:12px; }
 .theory-lab-stage:not(.theory-lab-gradients) { aspect-ratio:1.05; }
 .theory-gradient-track { height:64px; }
 #theory-related { gap:14px; }
}

#theory-search { margin-bottom:32px; }

.theory-gradient-label { align-items:center; margin-bottom:4px; }
.theory-gradient-label a { display:flex; align-items:center; min-height:44px; }

/* Topic selection stays above every experiment. */
.theory-navigation { display:flex; gap:16px; align-items:center; margin-bottom:12px; }
#theory-explore { opacity:.6; flex:0 0 44px; display:flex; align-items:center; justify-content:center; padding:0; min-height:44px; cursor:pointer; }
#theory-explore svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.4; pointer-events:none; }
#theory-explore:hover,#theory-explore:focus-visible { opacity:1; color:var(--ink); }
.theory-navigation select { flex:1; min-width:0; font-size:15px; }
.theory-navigation button { font-size:12px; padding-right:0; white-space:nowrap; }
.theory-explore { margin:0 0 26px; padding:0; border:0; }
.theory-intro { font-size:16px; line-height:1.65; max-width:440px; margin:28px 0; }
#theory-previews { display:grid; grid-template-columns:1fr 1fr; gap:28px 20px; }
.theory-preview { display:block; text-align:left; padding:0; font-size:13px; }
.theory-preview>span:last-child { display:block; padding:10px 0; min-height:44px; }
.theory-mini { display:flex; position:relative; height:150px; overflow:hidden; background:var(--paper); border:0; }
.theory-mini canvas { display:block; width:100%; height:100%; }
.theory-reading { margin-top:28px; border-top:1px solid #8884; padding-top:6px; }
.theory-reading p { font-size:14px; line-height:1.85; max-width:560px; margin:12px 0 20px; }
[hidden] { display:none!important; }
@media(max-width:600px) { .theory-navigation { gap:10px; }#theory-previews { gap:20px 14px; }.theory-mini { height:112px; }.theory-mini-contrast::after { font-size:40px; } }

.theory-lab-triangle { cursor:crosshair; }
.theory-triangle-marker { position:absolute; width:12px; height:12px; border:1px solid #fff; border-radius:50%; box-shadow:0 0 0 1px #111b; transform:translate(-50%,-50%); pointer-events:none; }
.theory-triangle-corner { position:absolute; transform:translate(-50%,-50%); min-width:44px; min-height:44px; padding:0; font-size:11px; }
.theory-triangle-result { display:flex; align-items:center; justify-content:center; min-height:44px; text-decoration:none; font-size:12px; margin-top:12px; }
.theory-mini-triangle { align-items:center; justify-content:center; }
.theory-mini-triangle canvas { display:block; width:100%; height:100%; object-fit:contain; }

@media(max-width:600px) {
  .theory-strip { flex-wrap:nowrap; gap:0; }
  .theory-swatch { flex:1 1 0; height:88px; border:0; padding:12px 1px; }
  .theory-strip:has(.theory-swatch:nth-child(5)) .theory-swatch span { display:none; }
}

/* The same lesson hierarchy and discovery control everywhere. */
article[aria-labelledby="theory-title"] { display:flex; flex-direction:column; }
#theory-title { order:0; }
#theory-description { order:1; }
#theory-toolbar { order:2; display:flex; align-items:center; gap:18px; min-height:44px; margin:0 0 20px; }
#theory-toolbar button { padding-left:0; min-height:44px; font-size:13px; }
#theory-toolbar button:disabled { opacity:.35; cursor:default; }
.theory-action-note { font-size:11px; opacity:.6; }
article #theory-visual,article.theory-experiment #theory-visual { order:3; margin:0 0 24px; }
article #theory-controls,article.theory-experiment #theory-controls { order:4; margin:0 0 8px; }
article #theory-note,article.theory-experiment #theory-note { order:5; }
#theory-controls label { position:relative; }
#theory-controls output { min-width:30px; font-size:11px; opacity:.6; text-align:right; }
#theory-controls input[type="color"] { box-sizing:border-box; flex:0 0 44px; width:44px; min-width:44px; max-width:44px; height:44px; min-height:44px; max-height:44px; padding:6px; border:0; background:none; cursor:pointer; }
#theory-controls input[type="color"]::-webkit-color-swatch-wrapper { box-sizing:border-box; width:100%; height:100%; padding:0; }
#theory-controls input[type="color"]::-webkit-color-swatch { box-sizing:border-box; width:100%; height:100%; border:1px solid #8885; border-radius:50%; }
#theory-controls input[type="color"]::-moz-color-swatch { box-sizing:border-box; width:100%; height:100%; border:1px solid #8885; border-radius:50%; }
#theory-controls select { min-width:0; width:100%; font-size:16px; min-height:44px; }
.theory-lab-subtractive { background:#fff; }
.theory-lab-subtractive .theory-light-handle { color:#000; text-shadow:0 1px 3px #fff; }
.theory-lab-subtractive .theory-light-handle::before { border-color:#0008; }
.theory-gradient-label { display:grid; grid-template-columns:1fr 52px auto; gap:12px; }
.theory-gradient-sample { width:52px; height:44px; }
.theory-type textarea { display:block; width:100%; min-height:84px; resize:vertical; border:0; background:none; color:inherit; font:inherit; font-size:28px; line-height:1.25; padding:0; margin:0 0 24px; }
.theory-temperature-pair { display:grid; grid-template-columns:1fr 1fr; height:240px; }
.theory-temperature-pair>div { display:flex; align-items:center; justify-content:center; }
.theory-temperature-pair span { width:36%; aspect-ratio:1; }
.theory-comparison-note { font-size:12px; line-height:1.7; margin:14px 0 30px; }
.theory-reference-study { display:flex; min-height:220px; }
.theory-area { position:relative; height:280px; touch-action:pan-y; margin:12px 0 20px; }
.theory-area>div { position:absolute; }
.theory-area-handle { position:absolute; z-index:1; width:44px; height:44px; padding:0; transform:translate(-50%,-50%); cursor:ew-resize; touch-action:none; }
.theory-area-handle::before { content:''; position:absolute; width:3px; height:24px; left:20px; top:10px; border-radius:2px; background:#fff; box-shadow:0 0 0 1px #0008; }
.theory-area-handle.is-horizontal { cursor:ns-resize; }
.theory-area-handle.is-horizontal::before { width:24px; height:3px; left:10px; top:20px; }
@media(max-width:600px) {
 .theory-area { height:260px; }
 .theory-temperature-pair { height:190px; }
 .theory-gradient-label { grid-template-columns:1fr 44px auto; gap:8px; }
 .theory-gradient-sample { width:44px; }
}
/* One quiet shuffle target beside every title, without a dedicated row. */
#theory-heading { order:0; display:flex; align-items:center; gap:8px; margin:0 0 18px; }
#theory-heading #theory-title { margin:0; min-width:0; }
#theory-heading #theory-toolbar { flex:0 0 44px; order:0; margin:0; min-height:44px; }
#theory-toolbar button { display:flex; width:44px; height:44px; align-items:center; justify-content:center; padding:0; opacity:.5; }
#theory-toolbar button:hover,#theory-toolbar button:focus-visible { opacity:1; }
#theory-toolbar button:disabled { opacity:.2; }
#theory-toolbar svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.4; stroke-linecap:round; stroke-linejoin:round; }
#theory-heading #theory-toolbar { order:1; }
.theory-area-editors { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); width:100%; gap:16px; }
#theory-controls .theory-area-editors label { display:flex; flex-direction:column; align-items:center; text-align:center; gap:4px; }
#theory-controls .theory-area-editors label>span { min-width:0; font-size:12px; }
#theory-controls .theory-area-editors input[type="color"] { flex-basis:auto; }
#theory-controls .theory-area-editors [data-area-value] { font-size:11px; opacity:.65; }

.theory-lab-context>svg { display:block; width:100%; height:100%; }
/* Three visibly comparable results share one position control. */
.theory-gradient-samples { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-bottom:18px; }
.theory-gradient-card { min-width:0; }
.theory-gradient-name { display:flex; align-items:center; min-height:36px; font-size:12px; }
.theory-lab-gradients .theory-gradient-sample { display:block; width:100%; height:200px; }
.theory-gradient-card>a { display:block; font-size:12px; text-decoration:none; color:inherit; cursor:pointer; }
.theory-gradient-hex { display:flex; align-items:center; justify-content:center; min-height:44px; }
.theory-gradient-rail { display:grid; grid-template-columns:70px minmax(0,1fr); gap:12px; }
.theory-gradient-names { display:flex; flex-direction:column; }
.theory-gradient-names>span { display:flex; align-items:center; height:24px; font-size:10px; }
.theory-lab-gradients .theory-gradient-track { height:72px; }
.theory-gradient-track>canvas { height:24px; }
.theory-gradient-position { min-height:32px; display:flex; align-items:center; justify-content:flex-end; font-size:11px; opacity:.65; }
@media(max-width:600px) {
 .theory-gradient-samples { gap:8px; }
 .theory-lab-gradients .theory-gradient-sample { height:155px; }
 .theory-gradient-name,.theory-gradient-card>a { font-size:11px; }
 .theory-gradient-rail { grid-template-columns:60px minmax(0,1fr); gap:8px; }
}

/* Each result is a real color link; interactive surfaces keep their own gestures. */
.theory-selected-color { text-decoration:none; margin-bottom:18px; }
.theory-combined .theory-strip { margin-bottom:0; }
.theory-combined .theory-swatch { height:64px; }
.theory-temperature-pair a { display:block; width:36%; aspect-ratio:1; }
.theory-area-editors a { display:flex; align-items:center; justify-content:center; min-height:44px; color:inherit; text-decoration:none; }
.theory-study { padding:18px; background:var(--paper); color:var(--ink); }
.theory-study-stage { position:relative; height:340px; touch-action:none; user-select:none; -webkit-user-select:none; overflow:hidden; }
.theory-study-stage.is-dragging { cursor:grabbing; }
.theory-study-transparency { background:#FFFFFF; }
.theory-plane { position:absolute; width:52%; height:60%; padding:0; transform:translate(-50%,-50%); cursor:grab; border:0; }
.theory-plane-point { position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); width:24px; height:24px; display:flex; align-items:center; justify-content:center; color:#fff; background:#1119; border:1px solid #fff9; border-radius:50%; font-size:10px; pointer-events:none; }
.theory-result-cards { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-top:18px; }
.theory-result-card { min-width:0; }
.theory-result-name { display:flex; align-items:center; min-height:36px; font-size:12px; line-height:1.5; }
.theory-result-link { display:block; color:inherit; text-decoration:none; }
.theory-result-color { display:block; width:100%; height:88px; }
.theory-result-hex { min-height:44px; display:flex; align-items:center; justify-content:center; font-size:12px; }
.theory-study-note { font-size:12px; line-height:1.7; margin:8px 0 0; }
.theory-study-perceptual { cursor:crosshair; }
.theory-study-perceptual canvas { width:100%; height:100%; display:block; }
.theory-field-marker { position:absolute; width:14px; height:14px; transform:translate(-50%,-50%); border:2px solid #fff; box-shadow:0 0 0 1px #1119; border-radius:50%; pointer-events:none; }
.theory-field-marker.is-outside { border-style:dashed; border-color:#26343D; box-shadow:0 0 0 1px #fff9; }
.theory-field-axes { display:flex; justify-content:space-between; min-height:36px; align-items:center; font-size:11px; }
.theory-field-result { display:block; margin-top:4px; }
.theory-field-result .theory-result-color { height:88px; }
@media(max-width:600px) {
 .theory-study { padding:12px; }
 .theory-study-stage { height:280px; }
 .theory-result-cards { gap:8px; }
 .theory-result-name,.theory-result-hex { font-size:11px; }
 .theory-result-color { height:78px; }
}

/* Hue relationships: keep the wheel and adjustments together, before the results. */
article.theory-harmony-layout {
 display:grid;
 grid-template-columns:224px minmax(0,1fr);
 grid-template-areas:"heading heading" "intro intro" "wheel controls" "palette palette" "composition composition" "note note";
 column-gap:28px;
 align-items:start;
}
.theory-harmony-layout #theory-heading { grid-area:heading; }
.theory-harmony-layout #theory-description { grid-area:intro; }
.theory-harmony-layout #theory-visual { display:contents; }
.theory-harmony-layout #theory-controls { grid-area:controls; margin:0; align-self:center; gap:4px 12px; }
.theory-harmony-layout .theory-wheel-disc { grid-area:wheel; align-self:center; width:224px; max-width:100%; margin:0; }
.theory-harmony-layout .theory-harmony-palette { grid-area:palette; margin:22px 0 16px; }
.theory-harmony-layout .theory-strip { margin:0; }
.theory-harmony-layout .theory-swatch { height:72px; }
.theory-harmony-layout .theory-area { grid-area:composition; height:190px; margin:0 0 16px; }
.theory-harmony-layout #theory-note { grid-area:note; margin:0; }
@media(max-width:600px) {
 article.theory-harmony-layout {
  grid-template-columns:clamp(112px,32vw,144px) minmax(0,1fr);
  grid-template-areas:"heading heading" "intro intro" "wheel base" "wheel hue" "spread spread" "saturation saturation" "lightness lightness" "palette palette" "composition composition" "note note";
  column-gap:16px;
 }
 .theory-harmony-layout .theory-wheel-disc { width:100%; }
 .theory-harmony-layout #theory-controls { display:contents; }
 .theory-harmony-layout #theory-controls label[data-control="base"] { grid-area:base; }
 .theory-harmony-layout #theory-controls label[data-control="axis-0"] { grid-area:hue; }
 .theory-harmony-layout #theory-controls label[data-control="axis-1"] { grid-area:saturation; margin-top:12px; }
 .theory-harmony-layout #theory-controls label[data-control="axis-2"] { grid-area:lightness; }
 .theory-harmony-layout #theory-controls label[data-control="spread"] { grid-area:spread; }
 .theory-harmony-layout #theory-controls label[data-control="base"],
 .theory-harmony-layout #theory-controls label[data-control="axis-0"] { display:grid; grid-template-columns:minmax(0,1fr) 44px; gap:0 4px; }
 .theory-harmony-layout #theory-controls label[data-control="base"]>span { grid-column:1/-1; }
 .theory-harmony-layout #theory-controls label>span { min-width:0; }
 .theory-harmony-layout #theory-controls label[data-control="axis-0"]>input { grid-column:1/-1; }
 .theory-harmony-layout .theory-harmony-palette { margin:18px 0 14px; }
 .theory-harmony-layout .theory-swatch { height:60px; }
 .theory-harmony-layout .theory-area { height:176px; margin-bottom:14px; }
}

@media(max-width:600px) {
 .theory-harmony-layout #theory-controls label[data-control="axis-1"]>span,
 .theory-harmony-layout #theory-controls label[data-control="axis-2"]>span,
 .theory-harmony-layout #theory-controls label[data-control="spread"]>span { min-width:74px; }
}

/* Keep each adjustment next to its experiment, ahead of secondary references. */
article[data-kind="dimension"],article[data-kind="contrast"] { display:grid; grid-template-columns:minmax(0,1fr); }
article[data-kind="dimension"] { grid-template-areas:"heading" "intro" "selected" "controls" "reference" "note"; }
article[data-kind="contrast"] { grid-template-areas:"heading" "intro" "sample" "note" "controls" "reference"; }
article:is([data-kind="dimension"],[data-kind="contrast"]) #theory-heading { grid-area:heading; }
article:is([data-kind="dimension"],[data-kind="contrast"]) #theory-description { grid-area:intro; }
article:is([data-kind="dimension"],[data-kind="contrast"]) #theory-visual { display:contents; }
article:is([data-kind="dimension"],[data-kind="contrast"]) #theory-controls { grid-area:controls; margin:0 0 18px; }
article:is([data-kind="dimension"],[data-kind="contrast"]) #theory-note { grid-area:note; }
article[data-kind="dimension"] .theory-selected-color { grid-area:selected; height:230px; margin:0 0 18px; }
article[data-kind="dimension"] #theory-visual>div { grid-area:reference; }
article[data-kind="contrast"] .theory-type { grid-area:sample; }
article[data-kind="contrast"] .theory-contrast-colors { grid-area:reference; }
article[data-kind="contrast"] .theory-swatch { height:64px; }
article[data-kind="contrast"] #theory-note { margin:14px 0 20px; }

article[data-kind="temperature"] .theory-strip { margin-bottom:18px; }
article[data-kind="temperature"] .theory-comparison-note { margin-bottom:20px; }
article[data-scheme="monochromatic"] #theory-controls { gap:4px 16px; }

/* The visual is the lesson: keep light/filter fields full width.
 * Their controls follow immediately, before secondary reference samples. */
article:is([data-kind="mix"],[data-kind="categories"],[data-kind="transparency"]) {
 display:grid; grid-template-columns:minmax(0,1fr);
 grid-template-areas:"heading" "intro" "experiment" "controls" "reference" "detail" "note";
}
article:is([data-kind="mix"],[data-kind="categories"],[data-kind="transparency"]) #theory-heading { grid-area:heading; }
article:is([data-kind="mix"],[data-kind="categories"],[data-kind="transparency"]) #theory-description { grid-area:intro; }
article:is([data-kind="mix"],[data-kind="categories"],[data-kind="transparency"]) #theory-visual { display:contents; }
article:is([data-kind="mix"],[data-kind="categories"],[data-kind="transparency"]) #theory-controls { grid-area:controls; margin:18px 0; gap:4px 16px; }
article:is([data-kind="mix"],[data-kind="categories"]) .theory-lab-frame { grid-area:experiment; min-width:0; }
article:is([data-kind="mix"],[data-kind="categories"]) :is(.theory-combined,.theory-reference) { grid-area:reference; }
article[data-kind="categories"] .theory-reference-study { grid-area:experiment; }
article[data-kind="categories"] .theory-reference-study+div { grid-area:reference; }
article:is([data-kind="mix"],[data-kind="categories"]) .theory-swatch { height:64px; }
article:is([data-kind="mix"],[data-kind="categories"],[data-kind="transparency"]) #theory-note { grid-area:note; margin:14px 0 0; }
article[data-kind="transparency"] .theory-study { display:contents; }
article[data-kind="transparency"] .theory-study-stage { grid-area:experiment; height:340px; }
article[data-kind="transparency"] .theory-result-cards { grid-area:reference; margin-top:0; }
article[data-kind="transparency"] .theory-study-note { grid-area:detail; margin:12px 0 0; }
article[data-kind="transparency"] .theory-result-color { height:72px; }
@media(max-width:600px) {
 article[data-kind="transparency"] .theory-study-stage { height:280px; }
 article[data-kind="transparency"] .theory-result-color { height:64px; }
}

/* Choose the reference system before interpreting the large light/filter field. */
article[data-kind="categories"] { grid-template-areas:"heading" "intro" "setup" "experiment" "controls" "reference" "detail" "note"; }
article[data-kind="categories"] #theory-controls { display:contents; }
.theory-system-options { grid-area:setup; display:grid; grid-template-columns:repeat(3,44px) minmax(0,1fr); align-items:center; gap:12px; margin:0 0 18px; }
#theory-controls .theory-system-options button { padding:0; min-height:44px; }
#theory-controls .theory-system-options select { font-size:14px; }
article[data-kind="categories"] #theory-controls>[data-gather] { grid-area:controls; justify-self:start; margin:12px 0; }
@media(max-width:600px) { .theory-system-options { gap:8px; } }

/* A base-color lock sits quietly after shuffle; reference systems have no base. */
#theory-heading #theory-toolbar { flex:0 0 auto; gap:4px; }
#theory-toolbar button { flex:0 0 44px; }

/* Ordered lesson navigation sits after the study, before its reading. */
#theory-pagination { display:flex; justify-content:space-between; gap:24px; margin-top:24px; }
#theory-pagination button { display:flex; align-items:center; gap:8px; max-width:calc(50% - 12px); min-height:44px; padding:0; font-size:12px; text-align:left; }
#theory-pagination button:last-child { margin-left:auto; text-align:right; }
#theory-pagination svg { width:16px; height:16px; flex:none; fill:none; stroke:currentColor; stroke-width:1.4; stroke-linecap:round; stroke-linejoin:round; }

#theory-surprise { display:flex; align-items:center; justify-content:center; flex:0 0 44px; min-height:44px; padding:0; opacity:.6; }
#theory-surprise:hover,#theory-surprise:focus-visible { opacity:1; }
#theory-surprise svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.4; pointer-events:none; }

/* The filled grid marks the overview without adding another label. */
#theory-explore[aria-current="page"] rect{fill:currentColor;}

/* Fixed comparison steps are distinct from the selected-color panel. */
.theory-dimension-reference .theory-swatch{flex-direction:column;align-items:center;justify-content:space-between;}
.theory-reference-step{font-size:11px;}
@media(max-width:600px){
  /* Keep the step labels on phones while the crowded hex captions stay hidden. */
  #theory-visual .theory-reference-step{display:block;}
}
