/* UNBG. — Material 3 Expressive.
   Colour: material-color-utilities 0.4.0, SchemeFidelity, seed #1A5CFF, spec 2025 (light default, dark via [data-theme]).
   Type: Google Sans Flex on the M3 type scale (emphasized = heavier weight). Shape: M3 corner scale + expressive shapes.
   Motion: M3 expressive springs (spatial fast 0.6/800, default 0.8/380; effects 1/1600) as CSS linear() curves. */
:root {
  --md-primary: #0045d1; --md-on-primary: #ffffff; --md-primary-container: #1a5cff; --md-on-primary-container: #edeeff;
  --md-primary-fixed: #dce1ff; --md-primary-fixed-dim: #b6c4ff;
  --md-secondary: #455aa3; --md-on-secondary: #ffffff; --md-secondary-container: #dce1ff; --md-on-secondary-container: #283e86;
  --md-tertiary: #992f00; --md-tertiary-container: #c33e00; --md-on-tertiary-container: #ffebe5;
  --md-error: #ba1a1a; --md-on-error: #ffffff; --md-error-container: #ffdad6; --md-on-error-container: #93000a;
  --md-surface: #faf8ff; --md-surface-container-lowest: #ffffff; --md-surface-container-low: #f3f2ff;
  --md-surface-container: #ededfa; --md-surface-container-high: #e7e7f4; --md-surface-container-highest: #e1e1ef;
  --md-on-surface: #191b24; --md-on-surface-variant: #434656; --md-outline: #737688; --md-outline-variant: #c3c5d9;
  --md-inverse-surface: #2e303a; --md-inverse-on-surface: #f0f0fd; --md-inverse-primary: #b6c4ff;
  --check-a: #ffffff; --check-b: #e4e6f2;

  /* shape scale */
  --shape-xs: 4px; --shape-s: 8px; --shape-m: 12px; --shape-l: 16px; --shape-l-inc: 20px;
  --shape-xl: 28px; --shape-xl-inc: 32px; --shape-xxl: 48px; --shape-full: 999px;
  /* elevation (light) */
  --elev-1: 0 1px 2px rgb(0 0 0 / .3), 0 1px 3px 1px rgb(0 0 0 / .15);
  --elev-2: 0 1px 2px rgb(0 0 0 / .3), 0 2px 6px 2px rgb(0 0 0 / .15);
  --elev-3: 0 4px 8px 3px rgb(0 0 0 / .15), 0 1px 3px rgb(0 0 0 / .3);
  /* motion */
  --spatial-fast: linear(0, 0.033, 0.119, 0.236, 0.369, 0.504, 0.634, 0.75, 0.849, 0.931, 0.993, 1.039, 1.07, 1.087, 1.094, 1.093, 1.087, 1.077, 1.064, 1.052, 1.039, 1.028, 1.018, 1.009, 1.003, 0.998, 0.994, 0.992, 0.991, 0.991, 0.991, 0.992, 0.993, 0.995, 0.996, 0.997, 1);
  --spatial-fast-ms: 350ms;
  --spatial-default: linear(0, 0.022, 0.078, 0.156, 0.246, 0.34, 0.433, 0.522, 0.604, 0.678, 0.744, 0.8, 0.848, 0.887, 0.92, 0.946, 0.967, 0.982, 0.994, 1.003, 1.008, 1.012, 1.014, 1.015, 1.015, 1.014, 1.013, 1.012, 1.011, 1.009, 1.008, 1.007, 1.005, 1.004, 1.003, 1.003, 1);
  --spatial-default-ms: 410ms;
  --effects: linear(0, 0.099, 0.286, 0.472, 0.626, 0.742, 0.826, 0.885, 0.925, 0.951, 0.969, 0.98, 0.987, 0.992, 0.995, 0.997, 1);
  --effects-ms: 210ms;
  --font: 'Google Sans Flex', 'Google Sans', 'Roboto Flex', Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Roboto Mono', 'SFMono-Regular', Consolas, monospace;
  color-scheme: light;
}
[data-theme="dark"] {
  --md-primary: #b6c4ff; --md-on-primary: #00277f; --md-primary-container: #1a5cff; --md-on-primary-container: #edeeff;
  --md-secondary: #b6c4ff; --md-on-secondary: #112a72; --md-secondary-container: #2f448c; --md-on-secondary-container: #dce1ff;
  --md-tertiary: #ffb59c; --md-tertiary-container: #c33e00; --md-on-tertiary-container: #ffebe5;
  --md-error: #ffb4ab; --md-on-error: #690005; --md-error-container: #93000a; --md-on-error-container: #ffdad6;
  --md-surface: #11131c; --md-surface-container-lowest: #0c0e17; --md-surface-container-low: #191b24;
  --md-surface-container: #1d1f29; --md-surface-container-high: #282933; --md-surface-container-highest: #32343e;
  --md-on-surface: #e1e1ef; --md-on-surface-variant: #c3c5d9; --md-outline: #8d90a2; --md-outline-variant: #434656;
  --md-inverse-surface: #e1e1ef; --md-inverse-on-surface: #2e303a; --md-inverse-primary: #004ee8;
  --check-a: #262833; --check-b: #1b1d26;
  --elev-1: 0 1px 3px 1px rgb(0 0 0 / .3), 0 1px 2px rgb(0 0 0 / .5);
  --elev-2: 0 2px 6px 2px rgb(0 0 0 / .3), 0 1px 2px rgb(0 0 0 / .5);
  --elev-3: 0 4px 8px 3px rgb(0 0 0 / .3), 0 1px 3px rgb(0 0 0 / .5);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; background: var(--md-surface); color: var(--md-on-surface);
  font: 400 16px/24px var(--font); letter-spacing: .5px; font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
body.ready { transition: background-color var(--effects-ms) var(--effects), color var(--effects-ms) var(--effects); }
img, canvas, svg { display: block; max-width: 100%; }
a { color: var(--md-primary); text-underline-offset: 3px; }
button, input { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--md-secondary); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--md-primary); color: var(--md-on-primary); padding: 10px 16px; border-radius: var(--shape-full); }
.skip:focus { left: 16px; }
kbd { font: 500 12px/16px var(--mono); padding: 1px 6px; border-radius: var(--shape-xs); background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); }

/* type scale (emphasized where marked) */
.display { font-size: 57px; line-height: 64px; font-weight: 600; letter-spacing: -.25px; font-variation-settings: 'ROND' 30; }
.headline { font-size: 28px; line-height: 36px; font-weight: 500; letter-spacing: 0; }
.headline-s { font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: 0; margin: 0; }
.title-m { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: .15px; }
.title-s { font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: .1px; }
.label-l { font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: .1px; }

.ic { width: 24px; height: 24px; fill: currentColor; flex: none; }
.only-dark { display: none; }
[data-theme="dark"] .only-dark { display: block; }
[data-theme="dark"] .only-light { display: none; }

/* expressive shapes (masks set from js/ui.js as --shape-*) */
.s-cookie { -webkit-mask: var(--shape-cookie9) center / 100% 100% no-repeat; mask: var(--shape-cookie9) center / 100% 100% no-repeat; }
.s-sunny { -webkit-mask: var(--shape-sunny) center / 100% 100% no-repeat; mask: var(--shape-sunny) center / 100% 100% no-repeat; }
.s-clover { -webkit-mask: var(--shape-clover4) center / 100% 100% no-repeat; mask: var(--shape-clover4) center / 100% 100% no-repeat; }
.s-burst { -webkit-mask: var(--shape-softBurst) center / 100% 100% no-repeat; mask: var(--shape-softBurst) center / 100% 100% no-repeat; }

/* ---------- state layer helper ---------- */
.ibtn, .btn, .fab, .chip, .sw, .sample, .q-btn, .bgroup > *, .switch-row { position: relative; isolation: isolate; }
.ibtn::after, .btn::after, .fab::after, .chip::after, .bgroup > *::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; background: currentColor; opacity: 0; z-index: -1;
  transition: opacity var(--effects-ms) var(--effects); pointer-events: none;
}
.ibtn:hover::after, .btn:hover::after, .fab:hover::after, .chip:hover::after, .bgroup > *:hover::after { opacity: .08; }
.ibtn:active::after, .btn:active::after, .fab:active::after, .chip:active::after, .bgroup > *:active::after { opacity: .1; }

/* ---------- icon buttons (M: 56; S: 40 in app bar) ---------- */
.ibtn {
  width: 48px; height: 48px; border: 0; border-radius: var(--shape-full); background: transparent; color: var(--md-on-surface-variant);
  display: inline-grid; place-items: center; flex: none;
  transition: border-radius var(--spatial-fast-ms) var(--spatial-fast), background-color var(--effects-ms) var(--effects), color var(--effects-ms) var(--effects);
}
.ibtn:active { border-radius: var(--shape-m); }
.ibtn.toggle[aria-pressed="true"] { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-radius: var(--shape-l); }
.ibtn:disabled { opacity: .38; cursor: default; }
.ibtn:disabled::after { display: none; }

/* ---------- buttons: S 40 / M 56 / L 96, round → pressed square morph ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; white-space: nowrap;
  height: 56px; padding: 0 24px; border-radius: var(--shape-full); font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: .15px;
  transition: border-radius var(--spatial-fast-ms) var(--spatial-fast), background-color var(--effects-ms) var(--effects), box-shadow var(--effects-ms) var(--effects);
}
.btn:active { border-radius: var(--shape-m); }
.btn .ic { width: 24px; height: 24px; }
.btn.s { height: 40px; padding: 0 16px; font-size: 14px; line-height: 20px; letter-spacing: .1px; }
.btn.s .ic { width: 20px; height: 20px; }
.btn.s:active { border-radius: var(--shape-s); }
.btn.l { height: 96px; padding: 0 48px; gap: 12px; font-size: 24px; line-height: 32px; font-weight: 500; letter-spacing: 0; }
.btn.l .ic { width: 32px; height: 32px; }
.btn.l:active { border-radius: var(--shape-l); }
.btn.filled { background: var(--md-primary-container); color: var(--md-on-primary-container); }
[data-theme="dark"] .btn.filled { background: var(--md-primary-container); }
.btn.filled:hover { box-shadow: var(--elev-1); }
.btn.tonal { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }
.btn.outlined { background: transparent; color: var(--md-on-surface-variant); box-shadow: inset 0 0 0 1px var(--md-outline-variant); }
.btn.text { background: transparent; color: var(--md-primary); padding: 0 12px; }

/* ---------- top app bar ---------- */
.appbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 72px; padding: 0 16px 0 24px; max-width: 1680px; margin: 0 auto; }
.brand { text-decoration: none; color: inherit; display: flex; flex-direction: column; }
.wordmark { font-size: 32px; line-height: 36px; font-weight: 900; letter-spacing: -1px; font-variation-settings: 'ROND' 100; }
.wordmark .dot { color: var(--md-primary-container); }
.status { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--md-on-surface-variant); }
.appbar-actions { display: flex; gap: 4px; }

/* ---------- hero / empty state ---------- */
.tool { max-width: 1440px; margin: 0 auto; padding: 0 24px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 24px 56px; align-items: center; padding: 16px 0 48px; }
.hero-copy { padding: 8px 0; border-radius: var(--shape-xxl); transition: background-color var(--effects-ms) var(--effects), box-shadow var(--effects-ms) var(--effects); }
.hero-copy.over { background: var(--md-surface-container-low); box-shadow: 0 0 0 16px var(--md-surface-container-low); }
.hero h1 { margin: 0 0 20px; font-size: clamp(44px, 5.6vw, 84px); line-height: 1.02; letter-spacing: -2px; font-weight: 700; font-variation-settings: 'ROND' 40; }
.lede { font-size: 22px; line-height: 32px; letter-spacing: 0; color: var(--md-on-surface-variant); max-width: 560px; margin: 0 0 32px; }
.lede strong { color: var(--md-on-surface); font-weight: 600; }
.hero-cta { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.drop-hint { margin: 0; color: var(--md-on-surface-variant); font-size: 14px; line-height: 20px; letter-spacing: .25px; }
.samples { display: flex; align-items: center; gap: 12px; margin-top: 32px; color: var(--md-on-surface-variant); font-size: 14px; letter-spacing: .25px; flex-wrap: wrap; }
.sample { width: 60px; height: 60px; padding: 0; border: 0; background: var(--md-surface-container-high); transition: transform var(--spatial-fast-ms) var(--spatial-fast); }
.sample:hover { transform: rotate(-14deg) scale(1.1); }
.sample:active { transform: scale(.92); }
.sample img { width: 60px; height: 60px; object-fit: cover; }
.model-hint { font-size: 14px; line-height: 20px; letter-spacing: .25px; color: var(--md-on-surface-variant); margin: 20px 0 0; min-height: 20px; }

/* before / after */
.hero-demo { margin: 0; display: grid; gap: 12px; }
.ba { position: relative; --x: 50%; aspect-ratio: 4 / 5; width: min(100%, calc(min(74vh, 760px) * .8)); margin-left: auto; border-radius: var(--shape-xxl); overflow: hidden;
  background-color: var(--check-a);
  background-image: linear-gradient(45deg, var(--check-b) 25%, transparent 25%), linear-gradient(-45deg, var(--check-b) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--check-b) 75%), linear-gradient(-45deg, transparent 75%, var(--check-b) 75%);
  background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; box-shadow: var(--elev-2); }
.ba img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.ba-before { clip-path: inset(0 calc(100% - var(--x)) 0 0); }
.ba-line { position: absolute; top: 0; bottom: 0; left: var(--x); width: 3px; margin-left: -1.5px; background: #fff; box-shadow: 0 0 12px rgb(0 0 0 / .35); pointer-events: none; }
.ba-knob { position: absolute; top: 50%; left: 50%; width: 56px; height: 56px; transform: translate(-50%, -50%); display: grid; place-items: center;
  background: var(--md-primary-container); color: var(--md-on-primary-container); -webkit-mask: var(--shape-cookie9) center / 100% 100% no-repeat; mask: var(--shape-cookie9) center / 100% 100% no-repeat;
  transition: transform var(--spatial-fast-ms) var(--spatial-fast); }
.ba:hover .ba-knob { transform: translate(-50%, -50%) rotate(40deg) scale(1.1); }
.ba-tag { position: absolute; top: 16px; height: 32px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: var(--shape-full); font-size: 14px; font-weight: 600; letter-spacing: .1px; pointer-events: none; }
.ba-tag.before { left: 16px; background: rgb(0 0 0 / .55); color: #fff; backdrop-filter: blur(6px); }
.ba-tag.after { right: 16px; background: var(--md-primary-container); color: var(--md-on-primary-container); }
.ba-range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: ew-resize; -webkit-appearance: none; appearance: none; touch-action: pan-y; }
.ba:has(.ba-range:focus-visible) { outline: 3px solid var(--md-secondary); outline-offset: 3px; }
@property --x { syntax: '<percentage>'; inherits: true; initial-value: 50%; }
.ba.intro { animation: ba-sweep 3.2s var(--spatial-default) .6s both; }
@keyframes ba-sweep { 0% { --x: 50%; } 30% { --x: 84%; } 65% { --x: 16%; } 100% { --x: 50%; } }
.hero-demo figcaption { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--md-on-surface-variant); padding: 0 8px; }
.hero-demo figcaption a { color: inherit; }

.usps { grid-column: 1 / -1; list-style: none; padding: 0; margin: 16px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.usps li { display: flex; gap: 16px; align-items: center; padding: 16px 20px; border-radius: var(--shape-xl); background: var(--md-surface-container-low); font-size: 14px; line-height: 20px; letter-spacing: .25px; color: var(--md-on-surface-variant); }
.usps li strong { color: var(--md-on-surface); display: block; font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: .15px; }
.usp-shape { width: 48px; height: 48px; flex: none; display: grid; place-items: center; background: var(--md-primary-container); color: var(--md-on-primary-container); }

/* ---------- loading indicator + wavy progress ---------- */
.li-host { display: inline-grid; width: 48px; height: 48px; flex: none; }
.li { width: 48px; height: 48px; }
.li-bg { fill: var(--md-primary-container); }
.li-fg { fill: var(--md-on-primary-container); }
.li:not(.contained) .li-fg { fill: var(--md-primary); }
.wavy-host { width: 100%; height: 10px; margin: 16px 0 4px; }
.wavy { display: block; overflow: visible; }
.wavy-active { fill: none; stroke: var(--md-primary); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.wavy-track { fill: none; stroke: var(--md-secondary-container); stroke-width: 4; stroke-linecap: round; }
.wavy-stop { fill: var(--md-primary); }

/* ---------- workspace ---------- */
.work { display: grid; grid-template-columns: 400px minmax(0, 1fr); gap: 24px; padding: 8px 0 40px; align-items: start; }
body.has-work .hero { display: none; }
.side { display: flex; flex-direction: column; gap: 12px; }
.side-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--md-on-surface-variant); min-height: 48px; }
.side-actions { display: flex; gap: 8px; align-items: center; }
.queue { list-style: none; margin: 0; padding: 8px 4px 12px; display: flex; gap: 12px; overflow-x: auto; scrollbar-width: thin; }
.q { position: relative; flex: none; }
.q-btn { width: 72px; height: 72px; padding: 0; border: 0; background: var(--md-surface-container-high); border-radius: var(--shape-l-inc);
  overflow: hidden; display: block; transition: border-radius var(--spatial-default-ms) var(--spatial-default), transform var(--spatial-fast-ms) var(--spatial-fast); }
.q-btn img { width: 72px; height: 72px; object-fit: cover; }
.q-btn:active { transform: scale(.94); }
.q.sel .q-btn { -webkit-mask: var(--shape-cookie9) center / 100% 100% no-repeat; mask: var(--shape-cookie9) center / 100% 100% no-repeat; border-radius: 0; }
.q.sel::before { content: ''; position: absolute; inset: -6px; background: var(--md-primary-container); -webkit-mask: var(--shape-cookie9) center / 100% 100% no-repeat; mask: var(--shape-cookie9) center / 100% 100% no-repeat; z-index: -1; }
.q.sel { z-index: 0; }
.q-badge { position: absolute; right: -4px; bottom: -4px; width: 24px; height: 24px; border-radius: var(--shape-full); display: none; place-items: center; box-shadow: 0 0 0 2px var(--md-surface); }
.q-badge .ic { width: 16px; height: 16px; }
.q-badge.ok { background: var(--md-primary-container); color: var(--md-on-primary-container); }
.q-badge.bad { background: var(--md-error); color: var(--md-on-error); }
.q.done .q-badge.ok, .q.error .q-badge.bad { display: grid; }
.q-li { position: absolute; inset: 0; display: none; place-items: center; pointer-events: none; }
.q.working .q-li, .q.waiting .q-li { display: grid; }
.q.working .q-btn img, .q.waiting .q-btn img { opacity: .45; }

.card { background: var(--md-surface-container-low); border-radius: var(--shape-xl); padding: 20px 24px; }
.card h3 { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }
.card h3 .ic { color: var(--md-primary); }
.model-card { background: var(--md-surface-container-high); }
.model-row { display: flex; gap: 16px; align-items: center; }
.model-row p { margin: 0; font-size: 14px; line-height: 20px; letter-spacing: .25px; color: var(--md-on-surface-variant); font-variant-numeric: tabular-nums; }
.model-err { margin: 8px 0 0; padding: 12px 16px; border-radius: var(--shape-l); background: var(--md-error-container); color: var(--md-on-error-container); font-size: 14px; line-height: 20px; overflow-wrap: anywhere; }
.model-card .btn { margin-top: 12px; }

.result-card { background: var(--md-primary-container); color: var(--md-on-primary-container); border-radius: var(--shape-xl-inc); padding: 24px; }
.result-top { display: flex; align-items: center; justify-content: space-between; }
.result-top .label-l { text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px 0 10px; border-radius: var(--shape-full); background: var(--md-surface-container-lowest); color: var(--md-primary); font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: .1px; }
.badge .ic { width: 18px; height: 18px; }
.badge.soft { background: var(--md-secondary-container); color: var(--md-on-secondary-container); padding: 0 14px; }
.result-big { font-size: 80px; line-height: 80px; font-weight: 700; letter-spacing: -2px; margin: 20px 0 4px; font-variant-numeric: tabular-nums; font-variation-settings: 'ROND' 60; }
.result-sub { margin: 0 0 20px; font-size: 22px; line-height: 28px; letter-spacing: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; padding-top: 16px; border-top: 1px solid color-mix(in srgb, currentColor 30%, transparent); }
.stats dt { font-size: 11px; line-height: 16px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; opacity: .85; }
.stats dd { margin: 2px 0 0; font: 500 13px/18px var(--mono); overflow-wrap: anywhere; }
.result-note { margin: 12px 0 0; font-size: 14px; line-height: 20px; }
.result-card.err { background: var(--md-error-container); color: var(--md-on-error-container); }
.result-card.err .badge { background: var(--md-error); color: var(--md-on-error); }

/* swatches: round → cookie shape when selected */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.sw { width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--shape-full); display: grid; place-items: center; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--md-on-surface) 14%, transparent);
  transition: border-radius var(--spatial-fast-ms) var(--spatial-fast), transform var(--spatial-fast-ms) var(--spatial-fast); }
.sw:hover { transform: scale(1.08); }
.sw:active { transform: scale(.92); }
.sw.on { border-radius: var(--shape-m); transform: rotate(0); }
.sw .sw-check { width: 22px; height: 22px; opacity: 0; transform: scale(.4); transition: opacity var(--effects-ms) var(--effects), transform var(--spatial-fast-ms) var(--spatial-fast); fill: #fff; filter: drop-shadow(0 0 2px rgb(0 0 0 / .5)); }
.sw.on .sw-check { opacity: 1; transform: none; }
.sw[data-bg="#ffffff"] { background: #ffffff; } .sw[data-bg="#000000"] { background: #000000; }
.sw[data-bg="#f1f3f6"] { background: #f1f3f6; } .sw[data-bg="#1a5cff"] { background: #1a5cff; }
.sw[data-bg="#ffd6e7"] { background: #ffd6e7; } .sw[data-bg="#ffe58a"] { background: #ffe58a; }
.sw[data-bg="#c9f2d4"] { background: #c9f2d4; }
.sw[data-bg="#ffffff"] .sw-check, .sw[data-bg="#f1f3f6"] .sw-check, .sw[data-bg="#ffd6e7"] .sw-check, .sw[data-bg="#ffe58a"] .sw-check, .sw[data-bg="#c9f2d4"] .sw-check, .sw-transparent .sw-check { fill: #1a1c24; filter: none; }
.sw-transparent, .stage canvas.checker {
  background-color: var(--check-a);
  background-image: linear-gradient(45deg, var(--check-b) 25%, transparent 25%), linear-gradient(-45deg, var(--check-b) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--check-b) 75%), linear-gradient(-45deg, transparent 75%, var(--check-b) 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.sw-pick { cursor: pointer; overflow: hidden; background: conic-gradient(#ff3b30, #ffcc00, #34c759, #00c7be, #1a5cff, #af52de, #ff3b30); }
.sw-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* filter chips: 32dp, radius 8 */
.chips { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 16px 0 8px; border-radius: var(--shape-s); border: 0;
  box-shadow: inset 0 0 0 1px var(--md-outline-variant); background: transparent; color: var(--md-on-surface-variant); font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: .1px;
  transition: background-color var(--effects-ms) var(--effects), border-radius var(--spatial-fast-ms) var(--spatial-fast); }
.chip .ic { width: 18px; height: 18px; }
.chip .chip-check { display: none; }
.chip.on { background: var(--md-secondary-container); color: var(--md-on-secondary-container); box-shadow: none; }
.chip.on .chip-check { display: block; } .chip.on .chip-ic { display: none; }

/* connected button group: gap 2, outer full, inner 8, selected → full */
.bgroup.connected { display: flex; gap: 2px; }
.bgroup.connected > * { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 12px; border: 0; cursor: pointer;
  background: var(--md-surface-container-highest); color: var(--md-on-surface-variant); font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: .1px;
  border-radius: var(--shape-s); transition: border-radius var(--spatial-fast-ms) var(--spatial-fast), background-color var(--effects-ms) var(--effects), flex-grow var(--spatial-fast-ms) var(--spatial-fast); }
.bgroup.connected > *:first-child { border-radius: var(--shape-full) var(--shape-s) var(--shape-s) var(--shape-full); }
.bgroup.connected > *:last-child { border-radius: var(--shape-s) var(--shape-full) var(--shape-full) var(--shape-s); }
.bgroup.connected > *:active { flex-grow: 1.15; }
.bgroup.connected > .on, .bgroup.connected > label:has(input:checked) { background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-radius: var(--shape-full); }
.bgroup .ic { width: 20px; height: 20px; }
.bgroup label input { position: absolute; opacity: 0; pointer-events: none; }
.bgroup label:has(input:focus-visible) { outline: 3px solid var(--md-secondary); outline-offset: 2px; }

.range { display: flex; align-items: center; gap: 16px; margin-top: 16px; }
.range input { flex: 1; accent-color: var(--md-primary); height: 24px; }
.hint { font-size: 12px; line-height: 16px; letter-spacing: .4px; color: var(--md-on-surface-variant); margin: 12px 0 0; }

/* ---------- stage ---------- */
.stage-wrap { position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stage-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; min-height: 48px; }
.stage-head h2 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage {
  position: relative; border-radius: var(--shape-xl-inc); background: var(--md-surface-container); min-height: 420px;
  height: calc(100vh - 200px); max-height: 1100px; display: grid; place-items: center; overflow: hidden; padding: 24px 24px 112px;
}
.stage.brushing { touch-action: none; }
.stage.comparing { touch-action: pan-y; }   /* slider drags sideways; the page still scrolls */
.stage canvas { max-width: 100%; max-height: 100%; border-radius: var(--shape-xs); }
.stage.brushing canvas { cursor: none; }
.split { position: absolute; top: 0; width: 0; border-left: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / .2); cursor: ew-resize; touch-action: none; }
.split .knob { position: absolute; top: 50%; left: -25px; width: 48px; height: 48px; margin-top: -24px; display: grid; place-items: center;
  background: var(--md-primary-container); color: var(--md-on-primary-container); -webkit-mask: var(--shape-cookie9) center / 100% 100% no-repeat; mask: var(--shape-cookie9) center / 100% 100% no-repeat; }
.busy { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 16px; background: color-mix(in srgb, var(--md-surface-container) 72%, transparent); backdrop-filter: blur(3px); text-align: center; padding: 0 24px; }
.cursor { position: absolute; pointer-events: none; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgb(0 0 0 / .5), inset 0 0 0 1px rgb(0 0 0 / .5); transform: translate(-50%, -50%); }
.cursor.erase { background: rgb(186 26 26 / .18); }
.cursor.restore { background: rgb(26 92 255 / .2); }

/* floating toolbar (standard colours) + FAB (primary container) */
.dock { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; z-index: 5; max-width: calc(100% - 32px); }
.toolbar { display: flex; align-items: center; gap: 4px; height: 64px; padding: 8px; border-radius: var(--shape-full); background: var(--md-surface-container-lowest); box-shadow: var(--elev-3); overflow-x: auto; scrollbar-width: none; }
[data-theme="dark"] .toolbar { background: var(--md-surface-container-high); }
.fab { display: inline-flex; align-items: center; gap: 12px; height: 64px; padding: 0 24px 0 20px; border: 0; border-radius: var(--shape-l-inc);
  background: var(--md-primary-container); color: var(--md-on-primary-container); box-shadow: var(--elev-3); font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: .15px; white-space: nowrap; flex: none;
  transition: border-radius var(--spatial-fast-ms) var(--spatial-fast), box-shadow var(--effects-ms) var(--effects), transform var(--spatial-fast-ms) var(--spatial-fast); }
.fab:hover { box-shadow: var(--elev-3), var(--elev-1); }
.fab:active { border-radius: var(--shape-l); transform: scale(.97); }
.fab:disabled { opacity: .38; box-shadow: none; cursor: default; }
.fab .ic { width: 24px; height: 24px; }

/* drop overlay */
.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: color-mix(in srgb, var(--md-primary-container) 28%, transparent); backdrop-filter: blur(6px); }
.overlay > div { display: grid; justify-items: center; gap: 16px; background: var(--md-surface-container-lowest); padding: 40px 48px; border-radius: var(--shape-xxl); box-shadow: var(--elev-3); }
.overlay p { margin: 0; }

/* dialog */
.dialog { border: 0; border-radius: var(--shape-xl); padding: 24px; width: min(480px, calc(100vw - 32px)); background: var(--md-surface-container-high); color: var(--md-on-surface); box-shadow: var(--elev-3); }
.dialog::backdrop { background: rgb(0 0 0 / .32); }
.dialog[open] { animation: dlg-in var(--spatial-default-ms) var(--spatial-default); }
@keyframes dlg-in { from { transform: scale(.9); opacity: 0; } }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.switch-row { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--md-outline-variant); cursor: pointer; }
.switch-row small, .radio-row small { display: block; color: var(--md-on-surface-variant); font-size: 14px; line-height: 20px; letter-spacing: .25px; margin-top: 2px; }
.radio-row { border: 0; padding: 16px 0; margin: 0; border-bottom: 1px solid var(--md-outline-variant); display: grid; gap: 12px; }
.radio-row legend { padding: 0; margin-bottom: 12px; }
.engine { font-size: 14px; line-height: 20px; color: var(--md-on-surface-variant); margin: 16px 0; }

/* M3 switch: track 52×32, handle 16 → 24 (28 pressed), icon in handle */
.switch { position: relative; flex: none; width: 52px; height: 32px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-track { position: absolute; inset: 0; border-radius: var(--shape-full); background: var(--md-surface-container-highest); box-shadow: inset 0 0 0 2px var(--md-outline); transition: background-color var(--effects-ms) var(--effects); }
.switch-handle { position: absolute; top: 50%; left: 16px; width: 24px; height: 24px; margin: -12px 0 0 -12px; border-radius: var(--shape-full); background: var(--md-outline);
  display: grid; place-items: center; transform: scale(.667); transition: left var(--spatial-fast-ms) var(--spatial-fast), transform var(--spatial-fast-ms) var(--spatial-fast), background-color var(--effects-ms) var(--effects); }
.switch-handle .ic { width: 16px; height: 16px; position: absolute; }
.switch-handle .on { display: none; fill: var(--md-on-primary-container); }
.switch-handle .off { fill: var(--md-surface-container-highest); }
.switch input:checked + .switch-track { background: var(--md-primary); box-shadow: none; }
.switch input:checked + .switch-track .switch-handle { left: 36px; transform: scale(1); background: var(--md-on-primary); }
.switch input:checked + .switch-track .switch-handle .on { display: block; fill: var(--md-primary); }
.switch input:checked + .switch-track .switch-handle .off { display: none; }
.switch input:active + .switch-track .switch-handle { transform: scale(1.167); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--md-secondary); outline-offset: 2px; }

/* snackbar */
.snackbar { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 160%); min-height: 48px; display: flex; align-items: center; padding: 14px 16px; border-radius: var(--shape-xs);
  background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); font-size: 14px; line-height: 20px; letter-spacing: .25px; box-shadow: var(--elev-3); z-index: 60; max-width: calc(100vw - 32px);
  transition: transform var(--spatial-default-ms) var(--spatial-default); }
.snackbar.show { transform: translate(-50%, 0); }
body.has-work .snackbar.show { transform: translate(-50%, -88px); }

/* ---------- content ---------- */
.content { max-width: 1040px; margin: 0 auto; padding: 32px 24px 48px; }
.content section { margin: 0 0 56px; }
.content h2 { font-size: clamp(32px, 4vw, 45px); line-height: 1.15; letter-spacing: -.5px; margin: 0 0 20px; font-weight: 600; }
.content h3 { font-size: 22px; line-height: 28px; margin: 24px 0 8px; font-weight: 600; letter-spacing: 0; }
.content p, .content li { color: var(--md-on-surface-variant); font-size: 18px; line-height: 28px; letter-spacing: .25px; }
.content strong { color: var(--md-on-surface); font-weight: 600; }
.steps { list-style: none; counter-reset: s; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.steps li { counter-increment: s; background: var(--md-surface-container-low); border-radius: var(--shape-xl); padding: 24px; font-size: 16px; line-height: 24px; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 56px; height: 56px; background: var(--md-primary-container); color: var(--md-on-primary-container); font-size: 24px; font-weight: 700; margin-bottom: 16px;
  -webkit-mask: var(--shape-cookie9) center / 100% 100% no-repeat; mask: var(--shape-cookie9) center / 100% 100% no-repeat; }
.steps li:nth-child(2)::before { -webkit-mask-image: var(--shape-sunny); mask-image: var(--shape-sunny); }
.steps li:nth-child(3)::before { -webkit-mask-image: var(--shape-clover4); mask-image: var(--shape-clover4); }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile { background: var(--md-surface-container-low); border-radius: var(--shape-xl); padding: 24px; }
.tile h3 { margin-top: 0; }
.tile p { margin: 0; font-size: 16px; line-height: 24px; }
.table-wrap { overflow-x: auto; border-radius: var(--shape-xl); background: var(--md-surface-container-low); }
table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 16px; line-height: 24px; }
th, td { text-align: left; padding: 14px 20px; border-bottom: 1px solid var(--md-outline-variant); }
thead th { font-weight: 600; background: var(--md-surface-container); }
td.yes { color: var(--md-primary); font-weight: 600; }
tr:last-child th, tr:last-child td { border-bottom: 0; }
.faq details { border-radius: var(--shape-l); background: var(--md-surface-container-low); margin: 0 0 4px; padding: 0 24px; transition: border-radius var(--spatial-default-ms) var(--spatial-default); }
.faq details:first-of-type { border-top-left-radius: var(--shape-xl); border-top-right-radius: var(--shape-xl); }
.faq details:last-of-type { border-bottom-left-radius: var(--shape-xl); border-bottom-right-radius: var(--shape-xl); }
.faq details[open] { border-radius: var(--shape-xl); background: var(--md-surface-container); margin: 8px 0; }
.faq summary { cursor: pointer; padding: 20px 0; font-weight: 600; font-size: 18px; line-height: 26px; list-style: none; display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.faq summary::after { content: ''; flex: none; width: 24px; height: 24px; background: var(--md-on-surface-variant); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z'/%3E%3C/svg%3E") center/24px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z'/%3E%3C/svg%3E") center/24px no-repeat; transition: transform var(--spatial-fast-ms) var(--spatial-fast); }
.faq details[open] summary::after { transform: rotate(180deg); }
.faq summary::-webkit-details-marker { display: none; }
.faq .ans { padding: 0 0 20px; }
.faq .ans p { margin: 0 0 8px; font-size: 16px; line-height: 24px; }
.more .links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.more .links a { display: inline-flex; align-items: center; height: 40px; padding: 0 16px; border-radius: var(--shape-s); box-shadow: inset 0 0 0 1px var(--md-outline-variant); text-decoration: none; font-size: 14px; font-weight: 600; letter-spacing: .1px; color: var(--md-on-surface-variant); }
.more .links a:hover { background: var(--md-secondary-container); color: var(--md-on-secondary-container); box-shadow: none; }
.note { font-size: 14px !important; line-height: 20px !important; }

.foot { max-width: 1040px; margin: 0 auto; padding: 24px 24px 48px; border-top: 1px solid var(--md-outline-variant); font-size: 14px; line-height: 20px; letter-spacing: .25px; color: var(--md-on-surface-variant); }
.priv { display: flex; gap: 12px; align-items: flex-start; }
.priv .ic { color: var(--md-primary); }
.credits { margin: 8px 0 0; }

.debug-log { position: fixed; left: 8px; right: 8px; bottom: 8px; max-height: 30vh; overflow: auto; z-index: 99; margin: 0; padding: 8px 12px; border-radius: var(--shape-m);
  background: rgb(0 0 0 / .85); color: #9f9; font: 12px/16px var(--mono); white-space: pre-wrap; pointer-events: auto; }

/* ---------- window size classes ---------- */
@media (max-width: 1199px) { .work { grid-template-columns: 340px minmax(0, 1fr); } .hero { gap: 24px 32px; } }
@media (max-width: 839px) {
  .appbar { height: 64px; padding: 0 8px 0 16px; }
  .wordmark { font-size: 28px; line-height: 32px; }
  .tool, .content, .foot { padding-left: 16px; padding-right: 16px; }
  .hero { grid-template-columns: 1fr; gap: 24px; padding-top: 8px; }
  .hero h1 { letter-spacing: -1px; }
  .lede { font-size: 18px; line-height: 26px; margin-bottom: 24px; }
  .ba { width: min(100%, calc(70vh * .8)); margin: 0 auto; border-radius: var(--shape-xl-inc); }
  .samples { margin-top: 24px; }
  .btn.l { height: 56px; padding: 0 24px; gap: 8px; font-size: 16px; line-height: 24px; font-weight: 600; }
  .btn.l .ic { width: 24px; height: 24px; }
  .btn.l:active { border-radius: var(--shape-m); }
  .usps, .steps, .grid2 { grid-template-columns: 1fr; }
  .work { grid-template-columns: 1fr; padding-bottom: 112px; }
  .stage-wrap { order: -1; }
  .stage { height: 60vh; min-height: 300px; padding: 12px; border-radius: var(--shape-xl); }
  .dock { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); }
  .fab span { display: none; }
  .fab { width: 64px; padding: 0; justify-content: center; }
  .result-big { font-size: 57px; line-height: 64px; }
}
@media (max-width: 480px) {
  .toolbar { gap: 0; padding: 8px 4px; }
  .ibtn { width: 44px; }
  .toolbar #copy, .toolbar #dl-all { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; scroll-behavior: auto !important; }
}
