.color-lab { padding-block: .5rem 1rem; scroll-margin-top: 4rem; }
.lab-heading { display: flex; align-items: baseline; gap: 1.3rem; margin-bottom: .5rem; }
.lab-heading p { margin: 0; color: var(--muted); font-size: .9rem; }
.color-lab button, .color-lab input, .color-lab select, .color-lab textarea { font: inherit; }
.color-lab button { cursor: pointer; }
.color-lab button:disabled { cursor: default; opacity: .6; }
.color-lab :is(input, select, textarea, summary):focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.tool-panel { padding: 1.1rem; border: 1px solid var(--line); border-radius: .8rem; background: rgb(23 27 49 / .96); box-shadow: var(--shadow); }
.tool-panel[hidden] { display: none; }
.tool-panel h2 { font-family: inherit; font-size: 1.35rem; font-weight: 900; }
.tool-intro { color: var(--muted); margin: .35rem 0 .7rem; font-size: .88rem; }
.filter-layout { display: grid; grid-template-columns: minmax(230px, .85fr) minmax(0, 1.8fr); gap: 1rem; }
.lab-controls { min-width: 0; }
.filter-layout > .lab-controls { grid-row: span 2; }
.color-field { min-width: 0; --input-accent: var(--purple); }
.secondary-input { --input-accent: var(--orange); }
.color-field label { color: var(--input-accent); }
.color-lab label, .output-heading label { display: block; font-size: .82rem; font-weight: 900; }
.color-input { display: flex; gap: .6rem; align-items: center; margin-top: .3rem; padding: .25rem .45rem; border: 2px solid var(--input-accent); border-radius: .5rem; background: var(--surface-deep); }
.color-input:focus-within { box-shadow: 0 0 0 3px rgb(188 145 255 / .15); }
.color-input input[type="color"] { flex: 0 0 32px; width: 32px; height: 32px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.color-input input[type="text"] { width: 100%; min-width: 0; padding: .3rem; color: var(--ink); border: 0; background: transparent; font: 600 .95rem ui-monospace, monospace; }
.input-error { min-height: 0; margin: .15rem 0; color: var(--rose); font-size: .75rem; }
.input-error:empty { display: none; }
.presets { display: flex; flex-wrap: wrap; gap: .4rem; margin: .75rem 0; }
.presets button { display: flex; align-items: center; gap: .35rem; min-height: 32px; padding: .25rem .5rem; border: 1px solid var(--line); border-radius: 2rem; color: var(--muted); background: transparent; font-size: .75rem; font-weight: 700; }
.presets button:hover { color: var(--ink); border-color: var(--purple); }
.presets i { width: .7rem; height: .7rem; border-radius: 50%; background: var(--swatch); border: 1px solid rgb(255 255 255 / .3); }
.lab-button { padding: .45rem .8rem; min-height: 34px; border: 1px solid var(--green); border-radius: .4rem; color: var(--surface-deep); background: var(--green); font-weight: 900 !important; font-size: .8rem !important; white-space: nowrap; }
.lab-button:hover:not(:disabled) { background: #a0efd1; }
.lab-button.secondary { color: var(--ink); background: var(--surface-raised); border-color: var(--line); }
.lab-button.secondary:hover:not(:disabled) { border-color: var(--purple); background: var(--surface-raised); }
.small-note { color: var(--muted); font-size: .76rem; line-height: 1.5; margin-block: .45rem; }
.code-output { min-width: 0; padding: .8rem; background: var(--surface-deep); border: 1px solid var(--line); border-radius: .55rem; }
.output-heading { display: flex; gap: .7rem; align-items: center; justify-content: space-between; margin-bottom: .45rem; }
.color-lab textarea { display: block; width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: .35rem; padding: .55rem; min-height: 5rem; color: #cfb0ff; background: #14192e; font: .8rem/1.6 ui-monospace, monospace; overflow-wrap: anywhere; }
.lab-status { min-height: 1.2rem; margin: .4rem 0 0; color: var(--muted); font-size: .72rem; }
.filter-workbench { display: flex; align-items: center; gap: 1.25rem; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: .55rem; background: var(--surface-deep); }
.filter-preview { display: grid; grid-template-columns: 1fr auto 1fr 1fr; align-items: center; gap: .6rem; }
.filter-preview figure { margin: 0; text-align: center; }
.icon-stage, .target-stage { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto .25rem; border-radius: .4rem; background: #edf0f7; }
.icon-stage img { width: 58px; height: 58px; }
.target-stage { border: 1px solid rgb(255 255 255 / .2); }
.filter-preview figcaption { color: var(--muted); font-size: .75rem; }
.filter-preview figcaption span { display: block; color: var(--ink); font: .7rem ui-monospace, monospace; }
.pipeline-arrow { margin-top: -1.4rem; color: var(--purple); }
.filter-readout { flex: 1; min-width: 0; }
#match-label { color: var(--green); font-size: .72rem; margin: 0 0 .25rem; }
.filter-metrics { margin: 0; }
.filter-metrics > div { display: flex; gap: .5rem; justify-content: space-between; font-size: .67rem; }
.filter-metrics dt { color: var(--muted); }
.filter-metrics dd { margin: 0; font-family: ui-monospace, monospace; }
.lab-details { margin-top: .85rem; padding-top: .7rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
.lab-details summary { color: var(--ink); cursor: pointer; font-weight: 800; }
.lab-details a { color: var(--orange); }
.lab-details p { max-width: 100ch; }
.lab-footnote { text-align: center; color: var(--muted); font-size: .72rem; margin: .8rem 0 0; }
/* Match the three suggestion columns: sample, inputs, then contrast results. */
.contrast-top { display: grid; grid-template-columns: repeat(3, minmax(0, 300px)); justify-content: space-between; gap: clamp(1rem, 3vw, 3rem); }
.contrast-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .7rem; align-content: start; }
.contrast-inputs > button { justify-self: start; }
.contrast-workbench { display: grid; grid-template-areas: "score" "criteria"; grid-template-columns: minmax(0, 1fr); gap: .3rem; }
.text-preview { display: flex; flex-direction: column; justify-content: center; padding: .5rem .75rem; border-radius: .5rem; }
.large-sample { font-size: 20px; font-weight: 700; line-height: 1.3; }
.normal-sample { font-size: 14px; font-weight: 400; }
.contrast-score { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding-block: .3rem; }
#contrast-ratio { font-size: 1.5rem; font-weight: 900; line-height: 1; }
.ratio-unit { color: var(--muted); font-size: .8rem; }
#contrast-verdict { margin: 0; font-size: .73rem; color: var(--orange); }
.criteria-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: .3rem; padding: 0; margin: 0; list-style: none; }
.criteria-list li { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: .2rem; 
  font-size: .64rem; 
  background: var(--surface-deep); 
  border-radius: .3rem; 
  padding: .25rem .4rem; 
}
.criteria-list strong[data-pass="true"] { color: var(--green); }
.criteria-list strong[data-pass="false"] { color: var(--rose); }
.suggestions-heading { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem .8rem; align-items: baseline; padding-top: .5rem; margin-top: .5rem; border-top: 1px solid var(--line); }
.suggestions-heading h2 { font-family: inherit; font-weight: 900; font-size: .95rem; line-height: 1.3; }
.suggestions-heading { margin-bottom: .4rem; }
.row-guide { color: var(--muted); font-size: .7rem; font-weight: 600; margin-left: .5rem; }
.suggestions { display: grid; grid-template-columns: repeat(3, minmax(0, 300px)); justify-content: space-between; gap: clamp(1rem, 3vw, 3rem); }
.suggestion { min-width: 0; border: 1px solid var(--line); border-radius: .5rem; overflow: hidden; background: var(--surface-deep); }
.suggestion-sample { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; min-height: 0; padding: .45rem .7rem; line-height: 1.35; }
.suggestion-sample strong { font-size: .78rem; }
.suggestion-body { padding: .25rem .7rem .4rem; }
.suggestion h4 { margin: 0 0 .35rem; font-size: .85rem; line-height: 1.3; color: var(--green); }
.suggestion-color { display: flex; align-items: center; gap: .35rem; min-height: 23px; }
.color-role { width: 2rem; color: var(--muted); font-size: .68rem; }
.mini-swatch { flex: 0 0 12px; width: 12px; height: 12px; border: 1px solid rgb(255 255 255 / .4); border-radius: 3px; }
.hex-copy { padding: .15rem 0; border: 0; color: var(--ink); background: transparent; font: .78rem ui-monospace, monospace !important; text-decoration: underline dotted; text-underline-offset: 3px; }
.hex-copy:hover { color: var(--green); }
.change-indicator { margin-left: auto; color: var(--muted); font-size: .63rem; }
.change-indicator > span { font-size: .9rem; color: var(--purple); }
.change-indicator[data-change="unchanged"] > span { color: var(--orange); }
.suggestion-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; margin-top: .3rem; }
.suggestion-actions button { min-height: 29px; padding: .25rem .55rem; font-size: .7rem !important; }
.gradient-colors { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: .8rem; }
.number-input { width: 110px; margin-top: .3rem; padding: .35rem .5rem; border: 2px solid var(--purple); border-radius: .4rem; color: var(--ink); background: var(--surface-deep); }
.lab-note { padding: .7rem; border: 1px solid var(--orange); border-radius: .5rem; }
.copy-status { position: fixed; z-index: 15; bottom: 1rem; left: 50%; transform: translateX(-50%); max-width: calc(100% - 2rem); margin: 0; padding: .65rem 1rem; background: var(--ink); color: var(--surface-deep); border-radius: .5rem; box-shadow: var(--shadow); font-size: .85rem; }
.copy-status:empty { display: none; }
@media (max-width: 900px) {
  .suggestions { gap: 1rem; }
  .filter-workbench { flex-wrap: wrap; }
  .filter-readout { min-width: 160px; }
  .criteria-list { grid-template-columns: repeat(2, 1fr); }
  .criteria-list li { flex-direction: row; justify-content: space-between; }
}

.secondary-section { margin-top: 1.25rem; }
.secondary-section > summary { cursor: pointer; font-weight: 900; }
.secondary-section > summary + h2 { margin-top: 1rem; }
.suggestion-column { display: grid; grid-template-rows: auto repeat(var(--suggestion-rows, 3), 1fr); gap: .55rem; min-width: 0; }
.suggestion-column > h3 { font: 900 .92rem/1.4 "Nunito Sans", sans-serif; color: var(--purple); margin: 0; }
.suggestion { display: flex; flex-direction: column; }
.suggestion-body { display: flex; flex-direction: column; flex: 1; }
.sample-large { font-size: 20px; font-weight: 700; }
.sample-small { font-size: 14px; }
.suggestion-actions { margin-top: .25rem; }
.unavailable { padding: 1rem; justify-content: center; border-style: dashed; }
.animation-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 1rem; }
.animation-preview { display: flex; align-items: center; justify-content: center; gap: 1.5rem; padding: 1rem; margin-block: .5rem; border: 1px solid var(--line); border-radius: .5rem; }
.animated-icon-stage { background: #edf0f7; border-radius: .5rem; padding: .6rem; }
.endpoint-swatch { width: 24px; height: 24px; border: 1px solid var(--muted); border-radius: 50%; }
#animation-code { min-height: 220px; }

.ratio-badge { display: inline-flex; align-items: baseline; gap: .15rem; border: 1px solid var(--green); border-radius: .35rem; padding: .3rem .45rem; color: var(--green); background: var(--surface-deep); white-space: nowrap; }
.ratio-badge[data-pass="false"] { color: var(--orange); }
.ratio-badge .ratio-unit { color: inherit; }
.card-ratio { margin-left: auto; font: 800 .82rem/1.2 "Nunito Sans", sans-serif; }
.sample-line { display: flex; align-items: baseline; justify-content: space-between; gap: .4rem; width: 100%; }
.sample-line .sample-rating { font-size: .72rem; font-weight: 800; }
.sample-large { line-height: 1.3; }
.sample-small { line-height: 1.4; }
.sweep-toggle { display: flex !important; width: fit-content; max-width: 100%; justify-self: start; align-items: center; gap: .5rem; margin-block: .6rem; cursor: pointer; }
.sweep-toggle input { accent-color: var(--purple); width: 18px; height: 18px; }
.sweep-controls { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.sweep-controls[hidden], .sweep-icon[hidden], #animated-icon[hidden] { display: none; }
.sweep-controls select { display: block; width: 100%; margin-top: .3rem; padding: .45rem; border: 2px solid var(--purple); border-radius: .4rem; background: var(--surface-deep); color: var(--ink); font-size: .8rem; }
.sweep-controls .number-input { width: 100%; }
.sweep-icon { display: block; width: 96px; height: 96px; }
.suggestion[hidden] { display: none; }
.aaa-toggle { display: inline-flex !important; align-items: center; gap: .4rem; }
.aaa-toggle input { accent-color: var(--purple); width: 16px; height: 16px; }
.text-preview { align-items: center; text-align: center; min-height: 110px; }
.contrast-score { grid-area: score; flex-direction: column; justify-content: center; gap: .25rem; padding-block: 0; }
.criteria-list li { line-height: 1.3; border: 1px solid var(--green); }
.criteria-list { grid-area: criteria; }
#contrast-ratio { font-size: 2.2rem; }
#main-ratio { padding: .4rem .6rem; width: 100%; justify-content: center; }
.angle-inputs { display: flex; align-items: center; gap: .65rem; margin-top: .4rem; }
.angle-inputs .number-input { width: 75px; }
.angle-dial { position: relative; flex: 0 0 76px; width: 76px; height: 76px; border: 2px solid var(--purple); border-radius: 50%; background: var(--surface-deep); cursor: crosshair; touch-action: none; }
.angle-dial:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.angle-dial::before { content: ""; position: absolute; inset: 8px; border: 1px dashed var(--line); border-radius: 50%; }
.angle-needle { position: absolute; left: 50%; top: calc(50% - 2px); width: 30px; height: 4px; background: var(--orange); transform-origin: 0 50%; transform: rotate(var(--angle, 0deg)); border-radius: 3px; pointer-events: none; }
.angle-needle::after { content: ""; position: absolute; right: -1px; top: -3px; width: 10px; height: 10px; background: var(--orange); border-radius: 50%; }
.stream-toggle { grid-column: 1 / -1; }
.sweep-icon { position: relative; overflow: hidden; }
.sweep-stream { display: block; position: absolute; left: 50%; top: 50%; height: 200%; }
.sweep-stream[hidden] { display: none; }
.suggestion.duplicate { visibility: hidden; }
.animation-timing { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.animation-timing .number-input { width: 100%; }
.gradient-position, .gradient-motion { grid-column: 1 / -1; }
.gradient-position input { width: 100%; accent-color: var(--purple); }
.gradient-motion { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.gradient-motion .sweep-toggle { margin: 0; }
.extra-color-controls[hidden], .extra-color-row[hidden] { display: none; }
.snippet-select { display: block; max-width: 100%; margin-block: .75rem; padding: .5rem; 
  background: var(--surface-deep); color: var(--ink); border: 2px solid var(--purple); border-radius: .4rem; }
.inactive-controls { opacity: .5; }
.color-lab input:disabled, .angle-dial[aria-disabled="true"] { cursor: default; }
#animation-help { min-height: 3em; }
.extra-color-controls { margin-top: .85rem; padding-top: .75rem; border-top: 1px solid var(--line); }
.extra-color-controls .output-heading { font-size: .82rem; font-weight: 900; }
.extra-color-list { display: grid; gap: .6rem; }
.extra-color-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem; align-items: start; }
.extra-color-row > button { margin-top: 1.65rem; }
.animation-results { min-width: 0; align-self: start; }
.animation-results .animation-preview { margin-top: 0; }
.animation-results > .code-output { margin-top: .75rem; }
#extra-color-controls { max-width: 560px; }
.interaction-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; margin-top: .75rem; }
.interaction-layout > div { min-width: 0; }
.interaction-layout .snippet-select { width: 100%; min-width: 0; }
.interaction-preview { display: grid; place-items: center; min-height: 170px; border: 1px solid var(--line); border-radius: .5rem; background: var(--surface-deep); }
.interaction-demo-button { display: grid; place-items: center; padding: 1rem; background: #edf0f7; border: 2px solid transparent; border-radius: .5rem; }
.interaction-demo-button:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
@media (max-width: 900px) {
  .contrast-top { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .contrast-workbench { grid-column: 1 / -1; width: 100%; max-width: 420px; justify-self: center; }
}

@media (max-width: 760px) {
  .suggestions { 
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 1.5rem;
    grid-template-columns: repeat(2, minmax(0, 300px));
  }
  .suggestion-column { width: 100%; max-width: 420px; grid-template-rows: auto; }
  .animation-layout { grid-template-columns: 1fr; }
  .suggestion-column > h3 { font-size: 1rem; }
  .sample-large { font-size: 20px; }
}

@media (max-width: 620px) {
  .contrast-top { grid-template-columns: minmax(0, 1fr); }
  .interaction-layout { grid-template-columns: 1fr; }
  .icon-stage, .target-stage { width: 64px; height: 64px; }
  .icon-stage img { width: 48px; height: 48px; }
  .text-preview { margin-top: .3rem; }
  .angle-inputs { flex-wrap: wrap; }
  .filter-preview { gap: .45rem; }
}
@media (max-width: 620px) {
  .color-lab { width: calc(100% - 1.5rem); padding-top: .8rem; }
  .lab-heading { display: block; }
  .lab-heading h1 { font-size: 1.9rem; }
  .lab-heading p { font-size: .8rem; margin-top: .3rem; }
  .tool-panel { padding: .8rem; }
  .tool-panel h2 { font-size: 1.15rem; }
  .tool-intro { font-size: .8rem; }
  .filter-layout { grid-template-columns: 1fr; gap: .7rem; }
  .filter-layout > .lab-controls { grid-row: auto; }
  .filter-workbench { justify-content: center; }
  .filter-preview { gap: .8rem; }
  .filter-readout { min-width: 190px; }
  .contrast-inputs { grid-template-columns: 1fr 1fr; }
  .contrast-inputs .color-field { grid-row: auto; }
  .contrast-inputs #reset-colors { grid-column: auto; }
  .contrast-inputs button { padding-inline: .45rem; font-size: .72rem !important; }
  .color-input { gap: .15rem; padding: .2rem; }
  .color-input input[type="color"] { width: 25px; flex-basis: 25px; }
  .color-input input[type="text"] { font-size: .8rem; padding-inline: .1rem; }
  .contrast-workbench { display: grid; }
  .criteria-list { grid-template-columns: repeat(4, 1fr); }
  .criteria-list li { flex-direction: column; }
  .suggestion h4 { font-size: .8rem; }
  .suggestion-color { min-height: 26px; }
  .change-indicator { font-size: .72rem; }
  .suggestion-actions button { min-height: 34px; }
  .hex-copy { font-size: .88rem !important; }
}

@media (max-width: 544px) {
  .suggestions { grid-template-columns: 1fr; }
}