/* Structure only. Keep colors, font, spacing unit and radius in theme.css. */
* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); font: 1rem/1.7 var(--font); }
button, input, select { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; touch-action: manipulation; }
a { color: inherit; text-underline-offset: 3px; }
button:disabled, input:disabled, select:disabled { opacity: .5; cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
h1 { font-size: 1.4rem; font-weight: 600; line-height: 1.5; margin: 0 0 var(--space); }
h2 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 var(--space); }
.site-header, main, .site-footer { max-width: var(--content-width); margin: auto; padding: var(--space); }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space); border-bottom: 1px solid var(--border); }
.brand { font-weight: 600; text-decoration: none; }
.site-header { flex-wrap: wrap; }
.header-actions, .app-nav { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space); }
.app-nav a { display: inline-flex; align-items: center; min-height: 44px; font-size: .875rem; text-decoration: none; color: var(--muted); }
.app-nav a[aria-current="page"] { color: var(--text); text-decoration: underline; text-underline-offset: 7px; }
.button { border: 1px solid var(--border); border-radius: var(--radius); background: var(--button); min-height: 44px; padding: .55rem .85rem; }
.button.primary { background: var(--selected); color: var(--selected-text); }
.button:hover { filter: brightness(1.1); }
.intro, .reflection { max-width: 680px; padding: calc(var(--space) * 2) 0; }
.intro-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin: 1.5rem 0 1rem; }
.privacy, .microcopy, .experience-note, .site-footer { font-size: .875rem; color: var(--muted); }
.intro-options { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: var(--space); }
.intro-options dt { font-weight: 600; margin-top: var(--space); }
.intro-options dd { margin: .3rem 0 0; color: var(--muted); }
.experience-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--space); margin-bottom: var(--space); }
.experience-heading h1 { margin: 0; }
.workbench { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: var(--space); align-items: start; }
.viewer { position: sticky; top: var(--space); height: min(65vh,650px); min-height: 300px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #101112; isolation: isolate; }
.viewer canvas { width: 100%; height: 100%; display: block; }
.viewer video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.viewer-top { position: absolute; top: .65rem; left: .65rem; right: .65rem; display: flex; justify-content: space-between; gap: .5rem; pointer-events: none; }
.source-pill, .effect-pill { font-size: .75rem; color: #fff; background: #101112df; padding: .2rem .5rem; border-radius: var(--radius); }
.viewer-hint { position: absolute; bottom: .65rem; left: .65rem; right: .65rem; width: fit-content; max-width: calc(100% - 1.3rem); margin: auto; color: #fff; background: #101112df; padding: .3rem .6rem; font-size: .75rem; text-align: center; border-radius: var(--radius); pointer-events: none; }
.controls { min-width: 0; padding: var(--space); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.controls > label, .control-section > label { display: block; font-size: .875rem; margin-bottom: .35rem; }
select { width: 100%; min-height: 44px; background: var(--background); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem; font-size: .875rem; }
.mode-switch { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); margin-top: 1rem; }
.mode-switch button { min-height: 44px; background: var(--button); border: 1px solid var(--border); font-size: .875rem; }
.mode-switch button:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.mode-switch button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.mode-switch button[aria-pressed="true"] { background: var(--selected); color: var(--selected-text); font-weight: 600; }
.control-help { color: var(--muted); font-size: .875rem; margin: .75rem 0 1rem; }
.strength-control, .control-section { padding: var(--space) 0; border-top: 1px solid var(--border); }
.label-line, .editor-body label { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: .875rem; }
output { color: var(--muted); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; height: 32px; accent-color: var(--selected); margin: .5rem 0 0; cursor: pointer; }
.range-scale { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); }
.strength-control .microcopy { margin: .75rem 0 0; }
.source-button { width: 100%; font-size: .875rem; }
details { margin-top: var(--space); padding-top: var(--space); border-top: 1px solid var(--border); font-size: .875rem; }
summary { min-height: 36px; }
.editor-body label { margin-top: var(--space); }
.editor-body .button { margin-top: var(--space); font-size: .875rem; }
.evidence p { color: var(--muted); margin-top: .5rem; }
.evidence a { overflow-wrap: anywhere; }
.experience-note { margin-top: var(--space); }
.viewer-cover { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .5rem; padding: var(--space); background: var(--surface); overflow-y: auto; }
.viewer-cover p { font-size: .875rem; max-width: 430px; margin-bottom: .5rem; }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.reflection ul { padding-left: 1.3rem; }
.site-footer { border-top: 1px solid var(--border); }
dialog { max-width: 460px; width: calc(100% - 2rem); color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
dialog::backdrop { background: #000b; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: var(--space); }
.dialog-header h2 { margin: 0; }
dialog p { font-size: .875rem; }
dialog label { display: block; margin-top: var(--space); font-size: .875rem; }
dialog input { width: 100%; padding: .6rem; margin-top: .5rem; background: var(--background); border: 1px solid var(--border); font-size: .875rem; }
dialog .primary { width: 100%; margin: 1rem 0; }
#qr-code { background: #fff; max-width: 250px; margin: var(--space) auto; }
#qr-code:empty { display: none; }
#qr-code svg { display: block; width: 100%; height: auto; padding: 12px; }
.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; }
@media(max-width:760px) {
  .workbench { display: flex; flex-direction: column; }
  .viewer { position: relative; top: auto; width: 100%; height: min(34svh,340px); min-height: 220px; }
  .controls { width: 100%; }
  .intro, .reflection { padding: var(--space) 0; }
  .intro-actions { flex-direction: column; }
  .viewer-cover h2 { font-size: 1rem; margin: 0; }
  .viewer-cover .button { font-size: .875rem; }
}

/* Comparison changes the revealed area, never the source crop or effect amount. */
.viewer.is-comparing { touch-action: none; cursor: ew-resize; }
.comparison { position: absolute; inset: 0; pointer-events: none; }
.comparison-label { position: absolute; top: 3rem; padding: .2rem .5rem; font-size: .75rem; color: #fff; background: #101112df; border-radius: var(--radius); max-width: 46%; }
.comparison-before { left: .65rem; }
.comparison-after { right: .65rem; text-align: right; }
.compare-handle { position: absolute; top: 0; bottom: 0; left: var(--split,50%); width: 44px; transform: translateX(-50%); pointer-events: auto; }
.compare-handle::before { content: ''; position: absolute; left: 21px; width: 2px; top: 0; bottom: 0; background: #fff; box-shadow: 0 0 2px #000; }
.compare-handle > span { position: absolute; top: 50%; left: 0; transform: translateY(-50%); display: grid; place-items: center; width: 44px; height: 44px; background: var(--selected); color: var(--selected-text); border: 1px solid var(--border); border-radius: var(--radius); font-size: 1.3rem; }
.compare-handle:focus-visible { outline-offset: -4px; }

/* Keep the example's whole sign visible at every viewport width. */
.viewer.is-example { aspect-ratio: 800 / 680; height: auto; min-height: 0; }
.color-example { border-bottom: 1px solid var(--border); padding-bottom: var(--space); margin-bottom: var(--space); }
.color-example h2 { margin: 0 0 .5rem; }
.color-example p { font-size: .875rem; }
.example-toggle { display: flex; align-items: center; gap: .6rem; min-height: 44px; margin-bottom: .5rem; cursor: pointer; }
.example-toggle input { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--selected); }
