/* Truescale Wallpaper — tokens from truescale.pen (V3). */
@font-face { font-family: 'Space Grotesk'; font-weight: 400; font-display: swap; src: url('fonts/space-grotesk-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 500; font-display: swap; src: url('fonts/space-grotesk-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 600; font-display: swap; src: url('fonts/space-grotesk-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 700; font-display: swap; src: url('fonts/space-grotesk-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Mono'; font-weight: 400; font-display: swap; src: url('fonts/space-mono-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Space Mono'; font-weight: 700; font-display: swap; src: url('fonts/space-mono-latin-700-normal.woff2') format('woff2'); }

:root {
  --bg: #F3F0E9;
  --ink: #1F1B16;
  --accent: #B5442A;
  --panel: #FBFAF7;
  --line: #E2DCCF;
  --muted: #7A7166;
  --ok-bg: #E6F0E4;
  --ok: #2E6B3A;
  --frame: #D9D2C3;
  --chip: #EFEAE0;
  --accent-soft: #F7E0D6;
  --field: #FFFFFF;
  --swatch-line: #00000022;
  --shadow: #5A402026;
  --scrim: #1F1B1666;
  --warn: #9A5B00;
  --warn-bg: #FBEFD9;
  --on-ink: #FBFAF7;
  --sim-bar: #1F1B1612;
  --sans: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, Menlo, monospace;
  --r: 10px;
  color-scheme: light;
}
:root[data-theme='dark'] {
  --bg: #141210;
  --ink: #F2EDE4;
  --accent: #FF8A65;
  --panel: #1E1B18;
  --line: #2E2925;
  --muted: #9A9085;
  --ok-bg: #1C2B1F;
  --ok: #8FD39A;
  --frame: #3A332D;
  --chip: #2A2622;
  --accent-soft: #3A2219;
  --field: #171513;
  --swatch-line: #FFFFFF26;
  --shadow: #00000099;
  --scrim: #000000A6;
  --warn: #F2C76C;
  --warn-bg: #2E2410;
  --on-ink: #1E1B18;
  --sim-bar: #00000070;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.icon { flex: none; display: block; }
.mono { font-family: var(--mono); }
.dim { color: var(--muted); }
.xs { font-size: 10.5px; }
.sm-text { font-size: 12px; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.mono-label {
  font: 400 10px/1 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.vsep { width: 1px; height: 22px; background: var(--line); flex: none; }
.times { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------------ app shell */
.app.is-desktop { height: 100vh; height: 100dvh; min-height: 640px; overflow: hidden; }
.app.is-desktop .shell {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  transform-origin: 50% 35%;
  transition: filter 0.35s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
/* Behind the device picker: the app blurs and zooms out slightly. Desktop only, since on mobile the picker is fullscreen. */
.app.is-desktop.backdrop .shell { filter: blur(6px) saturate(0.9); transform: scale(0.965); }
.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 22px 32px;
  gap: 16px;
}
.brand { margin: 0; font: 700 22px/1 var(--sans); letter-spacing: -0.6px; white-space: nowrap; }
.nav-actions { display: flex; align-items: center; gap: 8px; justify-self: end; }

.device-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 14px;
  border-radius: 99px;
  background: var(--panel);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.device-pill:hover { border-color: var(--frame); }
.dp-name { font-weight: 600; font-size: 13px; }
.device-pill .mono { font-size: 11px; }
.status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 500;
  background: var(--chip); color: var(--muted);
}
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.warn { background: var(--warn-bg); color: var(--warn); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 19px;
  display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line);
}
.icon-btn:hover { border-color: var(--frame); }
.icon-btn.ghost { background: transparent; border-color: transparent; }
/* Reset: leans back on hover, spins a full turn counter-clockwise after a confirmed reset. */
.reset-btn .icon { transform: rotate(var(--spin, 0deg)); transition: transform 0.8s cubic-bezier(0.34, 1.25, 0.5, 1); }
.reset-btn:hover .icon { transform: rotate(calc(var(--spin, 0deg) - 40deg)); }
.reset-btn:active { transform: scale(0.92); }
.reset-btn { transition: transform 0.15s ease, border-color 0.15s ease; }
.icon-btn.sm { width: 28px; height: 28px; }
/* Copy link: icon swap with a self-drawing check, a pulse ring, and a label that slides open. */
.share-btn {
  position: relative; width: auto; min-width: 38px; padding: 0 10px; display: inline-flex; align-items: center;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.15s ease;
}
.share-btn:active { transform: scale(0.94); }
.share-btn.done { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.share-btn.fail { background: var(--warn-bg); color: var(--warn); border-color: transparent; animation: sh-shake 0.42s ease; }
.sh-icons { position: relative; width: 16px; height: 16px; flex: none; }
.sh-icon { position: absolute; inset: 0; display: grid; place-items: center; transition: transform 0.45s cubic-bezier(0.34, 1.45, 0.5, 1), opacity 0.22s ease; }
.sh-status { opacity: 0; transform: scale(0.3) rotate(-45deg); }
.share-btn.wide .sh-link { opacity: 0; transform: scale(0.3) rotate(45deg); }
.share-btn.wide .sh-status { opacity: 1; transform: none; }
.share-btn:hover:not(.wide) .sh-link { transform: rotate(-30deg) scale(1.08); }
.share-btn.done .sh-status path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: sh-draw 0.42s 0.12s ease-out forwards; }
/* 0fr → 1fr animates to the label's real width (max-width would finish too early). */
.share-label {
  display: inline-grid; grid-template-columns: 0fr; margin-left: 0; opacity: 0;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  transition: grid-template-columns 0.45s cubic-bezier(0.22, 1, 0.36, 1), margin-left 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
}
.share-label > span { min-width: 0; overflow: hidden; }
.share-btn.wide .share-label { grid-template-columns: 1fr; margin-left: 6px; opacity: 1; transition-delay: 0s, 0s, 0.1s; }
.sh-glyph { display: grid; place-items: center; }
.sh-ring { position: absolute; inset: -1px; border-radius: inherit; border: 2px solid var(--ok); pointer-events: none; animation: sh-ring 0.65s ease-out forwards; }
@keyframes sh-draw { to { stroke-dashoffset: 0; } }
@keyframes sh-ring { from { opacity: 0.7; transform: scale(1); } to { opacity: 0; transform: scale(1.35, 1.6); } }
@keyframes sh-shake { 20% { transform: translateX(-3px); } 40% { transform: translateX(3px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(1px); } }

/* Theme switch: the thumb slides with a slight spring, the active icon rotates in. */
.mode-switch { position: relative; display: flex; gap: 2px; padding: 3px; border-radius: 19px; background: var(--chip); border: 1px solid var(--line); }
.ms-thumb {
  position: absolute; top: 3px; left: 3px; width: 30px; height: 30px; border-radius: 15px;
  background: var(--panel); box-shadow: 0 1px 3px var(--shadow);
  transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.5, 1), background-color 0.4s ease;
}
.mode-switch.dark .ms-thumb { transform: translateX(32px); background: var(--frame); }
.ms-btn { position: relative; width: 30px; height: 30px; border-radius: 15px; display: grid; place-items: center; color: var(--muted); transition: color 0.3s ease; }
.ms-btn.on { color: var(--ink); }
.ms-btn .icon { transition: transform 0.5s cubic-bezier(0.34, 1.4, 0.5, 1); }
.ms-btn.sun:not(.on) .icon { transform: rotate(-60deg) scale(0.82); }
.ms-btn.moon:not(.on) .icon { transform: rotate(40deg) scale(0.82); }
.ms-btn:hover:not(.on) { color: var(--ink); }

.theme-toggle { position: relative; overflow: hidden; }
.tt-icon { position: absolute; inset: 0; display: grid; place-items: center; transition: transform 0.55s cubic-bezier(0.34, 1.3, 0.5, 1), opacity 0.3s ease; }
.theme-toggle.dark .tt-moon, .theme-toggle.light .tt-sun { opacity: 0; transform: rotate(-90deg) scale(0.4); }
.theme-toggle.dark .tt-sun, .theme-toggle.light .tt-moon { opacity: 1; transform: none; }

/* Soft theme transition. */
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.45s; animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); }
.theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after {
  transition: background-color 0.45s ease, color 0.45s ease, border-color 0.45s ease, box-shadow 0.45s ease, fill 0.45s ease, stroke 0.45s ease,
    transform 0.5s cubic-bezier(0.34, 1.4, 0.5, 1), opacity 0.3s ease !important;
}

.dl-split { display: flex; height: 38px; border-radius: 19px; background: var(--ink); color: var(--on-ink); overflow: hidden; }
.dl-split button { color: var(--on-ink); }
.dl-main { display: flex; align-items: center; gap: 8px; padding: 0 14px 0 18px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.dl-more { width: 38px; display: grid; place-items: center; border-left: 1px solid color-mix(in srgb, var(--on-ink) 18%, transparent); }
.dl-split button:hover { background: color-mix(in srgb, var(--on-ink) 10%, transparent); }

/* ------------------------------------------------------------------ stage + preview */
.stage { position: relative; min-height: 0; display: flex; flex-direction: column; padding: 4px 32px 18px 28px; }
.stage-nudge { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); z-index: 3; width: min(620px, calc(100% - 64px)); }
.preview-wrap { flex: 1; min-height: 0; display: grid; place-items: center; }
.preview-frame {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--frame), 0 18px 40px -18px var(--shadow);
  background: var(--frame);
}
.preview-canvas { display: block; width: 100%; height: 100%; }

/* Laptop mockup (MacBook style) around the preview. --sw = screen width; everything scales from it. */
.laptop-mockup { display: flex; flex-direction: column; align-items: center; filter: drop-shadow(0 calc(var(--sw) * 0.03) calc(var(--sw) * 0.035) rgba(0, 0, 0, 0.28)); }
.laptop-mockup .lid {
  position: relative;
  padding: calc(var(--sw) * 0.021) calc(var(--sw) * 0.021) calc(var(--sw) * 0.03);
  background: #0c0c0e;
  border-radius: calc(var(--sw) * 0.032) calc(var(--sw) * 0.032) calc(var(--sw) * 0.006) calc(var(--sw) * 0.006);
  /* Aluminium rim around the black glass. */
  box-shadow: 0 0 0 calc(var(--sw) * 0.0028) #b4b7bd, 0 0 0 calc(var(--sw) * 0.0042) #8c9097, inset 0 0 0 1px #26272b;
}
.laptop-mockup .preview-frame.in-laptop { box-shadow: none; background: #000; }
.laptop-mockup .cam {
  position: absolute; top: calc(var(--sw) * 0.0105); left: 50%; transform: translate(-50%, -50%);
  width: calc(var(--sw) * 0.006); height: calc(var(--sw) * 0.006); border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3a4a5e, #08090b 70%);
}
.laptop-mockup .base {
  position: relative;
  width: calc(100% * 1.11);
  height: calc(var(--sw) * 0.024);
  margin-top: -1px;
  border-radius: 0 0 calc(var(--sw) * 0.05) calc(var(--sw) * 0.05) / 0 0 calc(var(--sw) * 0.022) calc(var(--sw) * 0.022);
  background: linear-gradient(to bottom, #eceef1 0%, #d3d6db 30%, #b7bbc2 70%, #8e939b 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
/* Opening scoop in the front edge. */
.laptop-mockup .base::after {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 14%; height: 42%;
  border-radius: 0 0 calc(var(--sw) * 0.012) calc(var(--sw) * 0.012);
  background: linear-gradient(to bottom, #9ea2a9, #c6c9ce);
}
/* Hinge shadow where the lid meets the base. */
.laptop-mockup .base::before {
  content: ''; position: absolute; top: 0; left: 4.5%; right: 4.5%; height: 1px; background: rgba(0, 0, 0, 0.35);
}
/* Windows laptops: graphite instead of silver. */
.laptop-mockup.windows .lid { box-shadow: 0 0 0 calc(var(--sw) * 0.0028) #3b3d42, 0 0 0 calc(var(--sw) * 0.0042) #24262a, inset 0 0 0 1px #26272b; }
.laptop-mockup.windows .base { background: linear-gradient(to bottom, #5b5e64 0%, #46494e 35%, #34363a 75%, #1f2023 100%); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25); }
.laptop-mockup.windows .base::after { background: linear-gradient(to bottom, #2a2c30, #3c3f44); }
.m-preview .laptop-mockup { margin: 0 auto; }
.sim { position: absolute; inset: 0; pointer-events: none; }
.sim-notch { position: absolute; top: 0; left: 50%; transform: translateX(-50%); background: #000; border-radius: 0 0 7px 7px; }
.sim-notch-svg { position: absolute; top: 0; left: 50%; transform: translateX(-50%); display: block; }
.sim-island { position: absolute; left: 50%; transform: translateX(-50%); background: #000; border-radius: 999px; }
.preview-frame.phone { box-shadow: 0 0 0 1px var(--frame), 0 0 0 5px #0b0b0c, 0 0 0 6px var(--frame), 0 18px 40px -18px var(--shadow); }
/* iPhone home-screen dock: wide glass slab, four icons spread evenly. */
.sim-dock.phone { justify-content: space-evenly; padding: 0; border-radius: calc(var(--dk) * 0.42); }
.sim-dock.phone .dk-icon { width: calc(var(--dk) * 0.66); border-radius: 24%; }
/* Simulated Dock: Liquid Glass (clear glass, blur + saturation, rim light, specular highlight). */
.sim-dock {
  --dk: 24px;
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  gap: calc(var(--dk) * 0.14);
  padding: 0 calc(var(--dk) * 0.18);
  border-radius: calc(var(--dk) * 0.4);
  background:
    radial-gradient(120% 90% at 18% 0%, rgba(255, 255, 255, 0.34), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.06));
  -webkit-backdrop-filter: blur(calc(var(--dk) * 0.22)) saturate(1.9) brightness(1.08);
  backdrop-filter: blur(calc(var(--dk) * 0.22)) saturate(1.9) brightness(1.08);
  box-shadow:
    inset 0 calc(var(--dk) * 0.03) calc(var(--dk) * 0.06) rgba(255, 255, 255, 0.55),
    inset 0 calc(var(--dk) * -0.04) calc(var(--dk) * 0.1) rgba(255, 255, 255, 0.12),
    0 0 0 max(0.5px, calc(var(--dk) * 0.02)) rgba(0, 0, 0, 0.1),
    0 calc(var(--dk) * 0.1) calc(var(--dk) * 0.45) rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.sim-dock::after {
  /* Rim light: bright edges top-left and bottom-right, dim in between. */
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: max(1px, calc(var(--dk) * 0.035));
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.18) 35%, rgba(255, 255, 255, 0.06) 62%, rgba(255, 255, 255, 0.7));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}
.sim-dock.vertical { flex-direction: column; padding: calc(var(--dk) * 0.18) 0; }
.dk-icon {
  flex: none;
  width: calc(var(--dk) * 0.74);
  aspect-ratio: 1;
  border-radius: 26%;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 48%),
    var(--ic, #D9D5CC);
  box-shadow: inset 0 0 0 max(0.5px, calc(var(--dk) * 0.012)) rgba(255, 255, 255, 0.45), 0 calc(var(--dk) * 0.03) calc(var(--dk) * 0.08) rgba(0, 0, 0, 0.18);
  opacity: 0.92;
}
.dk-icon.trash { background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(200, 200, 200, 0.3)); box-shadow: inset 0 0 0 max(0.5px, calc(var(--dk) * 0.012)) rgba(0, 0, 0, 0.1), 0 calc(var(--dk) * 0.03) calc(var(--dk) * 0.08) rgba(0, 0, 0, 0.18); }
.dk-sep { flex: none; width: max(1px, calc(var(--dk) * 0.03)); height: calc(var(--dk) * 0.56); background: rgba(255, 255, 255, 0.45); box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.08); border-radius: 1px; }
.sim-dock.vertical .dk-sep { width: calc(var(--dk) * 0.56); height: max(1px, calc(var(--dk) * 0.03)); }
.sim-taskbar { position: absolute; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, #202225 80%, transparent); backdrop-filter: blur(8px); }

/* ------------------------------------------------------------------ controls */
/* Left side panel with the controls (desktop). */
.workspace { display: grid; grid-template-columns: 296px minmax(0, 1fr); min-height: 0; padding-left: 24px; }
/* Right column: preview on top, simulation toggles + stats underneath, beside the full-height panel. */
.workspace-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.workspace-main .stage { flex: 1; }
.workspace-main .footer-bar { padding-left: 28px; }
.side-panel {
  display: flex; flex-direction: column; min-height: 0;
  margin: 4px 0 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 30px -14px var(--shadow);
  overflow: hidden;
}
.side-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; padding: 4px 0; }
.dock-group { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; }
.side-scroll > * + * { border-top: 1px solid var(--line); }
.dock-ctl { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-height: 30px; }
.side-trio { display: grid; grid-template-columns: auto auto auto; justify-content: space-between; }
.side-trio .dock-group { padding-right: 8px; }
.side-trio .dock-group + .dock-group { padding-left: 8px; }
.side-panel .chips { flex-wrap: wrap; }
.side-panel .style-cards { width: 100%; gap: 6px; }
.side-panel .style-card { height: 38px; font-size: 12.5px; padding: 0 10px; gap: 8px; }
.side-panel .swatches { gap: 8px; }
.side-more {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--line);
  font-size: 13px; font-weight: 600; text-align: left;
}
.side-more span { flex: 1; }
.side-more .side-more-chev { transform: rotate(-90deg); color: var(--muted); }
.side-more:hover { background: var(--chip); }

.seg { display: inline-flex; padding: 2px; gap: 2px; background: var(--chip); border-radius: 8px; flex: none; }
.seg-btn {
  min-width: 36px; height: 26px; padding: 0 10px;
  border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--muted);
  white-space: nowrap;
}
.seg-btn.on { background: var(--field); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px var(--shadow); }
:root[data-theme='dark'] .seg-btn.on { background: var(--frame); }
.seg.icon-seg { background: transparent; gap: 4px; }
.seg.icon-seg .seg-btn { width: 32px; min-width: 32px; height: 30px; padding: 0; color: var(--ink); border-radius: 8px; }
.seg.icon-seg .seg-btn:hover { background: var(--chip); }
.seg.icon-seg .seg-btn.on { background: var(--ink); color: var(--on-ink); }
.dock-group .seg:not(.icon-seg) .seg-btn { height: 26px; }
.seg.sm .seg-btn { height: 26px; font-size: 11.5px; }
.seg.wide { display: flex; width: 100%; }
.seg.wide .seg-btn { flex: 1; height: 32px; font-size: 13px; }
.seg.pill-tabs { background: transparent; gap: 4px; padding: 0; }
.seg.pill-tabs .seg-btn { height: 30px; padding: 0 14px; border-radius: 99px; font-size: 13px; }
.seg.pill-tabs .seg-btn.on { background: var(--ink); color: var(--on-ink); box-shadow: none; }

.swatches { display: flex; align-items: center; gap: 6px; }
.swatch {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--sw-bg, var(--panel));
  box-shadow: inset 0 0 0 1px var(--swatch-line);
  display: grid; place-items: center; position: relative; flex: none;
}
.swatch .sw-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sw-dot); }
.swatch.on::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ink); }
.swatch.add { background: var(--sw-bg, transparent); box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.swatch.add.on::after { border-color: var(--accent); }

.chips { display: flex; gap: 4px; }
.chip {
  height: 30px; padding: 0 10px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--line); color: var(--muted); background: transparent;
}
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.sq { min-width: 30px; padding: 0 8px; }

.corner-picker { --cp: 30px; width: var(--cp); height: var(--cp); padding: 3px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px; border-radius: 6px; background: var(--field); border: 1px solid var(--line); flex: none; }
.cp-dot { display: grid; place-items: center; border-radius: 3px; }
.cp-dot span { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.cp-dot.on span { background: var(--accent); }
.cp-dot:hover span { background: var(--muted); }
.cp-dot.on:hover span { background: var(--accent); }

.slider-field { display: grid; grid-template-columns: auto 1fr 30px; align-items: center; gap: 8px; min-width: 0; }
.slider-field.grow { flex: 1; max-width: 260px; }
.sf-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; }
.sf-val { font-size: 11px; font-weight: 700; text-align: right; }
.slider-field input[type='range'] { height: 14px; min-width: 0; }
.border-sliders { display: flex; flex-direction: column; gap: 1px; width: 150px; }
.border-sliders .slider-field { gap: 6px; grid-template-columns: 12px 1fr 26px; }
.border-sliders .slider-field input[type='range'] { height: 12px; }
.border-sliders .slider-field input[type='range']::-webkit-slider-thumb { width: 11px; height: 11px; margin-top: -4.5px; border-width: 2px; }
.dg-border .dock-ctl { height: auto; min-height: 30px; }
.pattern-seg .seg-btn .icon { opacity: 0.9; }
.border-sliders.wide { width: 100%; gap: 10px; }
.border-sliders.wide .slider-field { grid-template-columns: 74px 1fr 34px; gap: 10px; }
.border-sliders.wide input[type='range'] { height: 22px; }
.m-border { display: flex; flex-direction: column; gap: 10px; }
.numfield {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 8px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--field);
  min-width: 0;
}
.numfield:focus-within { border-color: var(--accent); }
.numfield input { width: 100%; min-width: 2ch; border: 0; outline: 0; background: transparent; font: 700 12px var(--mono); padding: 0; }
.numfield .nf-icon { color: var(--muted); }
.nf-suffix { font: 400 10px var(--mono); color: var(--muted); white-space: nowrap; }
.numfield.center input { text-align: center; }

/* ------------------------------------------------------------------ footer */
.footer-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 32px 18px; flex-wrap: wrap; }
.sim-toggles { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sim-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; margin-right: 2px; }
.sim-chip { height: 26px; padding: 0 10px; border-radius: 99px; font-size: 11.5px; font-weight: 500; border: 1px solid var(--line); color: var(--muted); }
.sim-chip.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.stats { display: flex; gap: 16px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }

/* ------------------------------------------------------------------ popovers, drawer, modal */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; animation: fade 0.15s ease-out; }
.scrim.clear { background: transparent; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.popover, .modal, .drawer {
  position: fixed; z-index: 50;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px -20px var(--shadow), 0 2px 6px var(--shadow);
}
.popover { border-radius: 16px; animation: rise 0.16s ease-out; }

.device-pop {
  top: 70px; left: 50%; transform: translateX(-50%); width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 90px);
  display: flex; flex-direction: column;
  /* Drops down from the device pill and grows into place. */
  transform-origin: 50% 0;
  animation: dp-in 0.38s cubic-bezier(0.34, 1.3, 0.5, 1) both;
}
.device-pop.closing { animation: dp-out 0.17s ease-in both; }
.device-pop .dp-item, .device-pop .dp-group { animation: dp-item 0.32s cubic-bezier(0.22, 1, 0.36, 1) both; }
.device-pop .dp-list > :nth-child(2) { animation-delay: 0.03s; }
.device-pop .dp-list > :nth-child(3) { animation-delay: 0.05s; }
.device-pop .dp-list > :nth-child(4) { animation-delay: 0.07s; }
.device-pop .dp-list > :nth-child(5) { animation-delay: 0.09s; }
.device-pop .dp-list > :nth-child(6) { animation-delay: 0.11s; }
.device-pop .dp-list > :nth-child(n + 7) { animation-delay: 0.13s; }
.scrim.closing { animation: fade-out 0.17s ease-in both; }
@keyframes dp-in { from { opacity: 0; transform: translateX(-50%) translateY(-14px) scale(0.9); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@keyframes dp-out { to { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(0.94); } }
@keyframes dp-item { from { opacity: 0; transform: translateY(-6px); } }
@keyframes fade-out { to { opacity: 0; } }
.dp-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--field); width: 180px; color: var(--muted); }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 12.5px; color: var(--ink); }
.search:focus-within { border-color: var(--accent); }
.dp-body { display: grid; grid-template-columns: 220px 1fr; min-height: 0; overflow: hidden; flex: 1; }
.dp-list { background: var(--chip); padding: 8px 10px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; }
:root[data-theme='dark'] .dp-list { background: var(--field); }
.dp-group { padding: 10px 2px 6px; font-size: 9.5px; }
.dp-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 8px; border-radius: 7px; text-align: left; font-size: 12.5px; }
.dp-item .mono { font-size: 9.5px; }
.dp-item:hover { background: var(--panel); }
.dp-item.on { background: var(--panel); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.dp-item.custom { justify-content: flex-start; margin-top: 8px; color: var(--accent); font-weight: 600; background: var(--accent-soft); }
.dp-empty { padding: 8px; color: var(--muted); font-size: 12px; }
.dp-detail { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; }
.self-start { align-self: flex-start; }
.dp-custom, .dp-preset { display: flex; flex-direction: column; gap: 10px; }
.dp-title { font-size: 16px; font-weight: 600; }
.field-head { display: flex; justify-content: space-between; align-items: center; }
.field-label { font-size: 12px; color: var(--muted); }
.pair { display: flex; align-items: center; gap: 8px; }
.pair .numfield { flex: 1; height: 38px; padding: 0 10px; }
.pair .numfield input { font-weight: 400; font-size: 13px; }
.help { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.help.center { text-align: center; }
.readout { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; background: var(--chip); font-size: 11.5px; }
.readout .mono:last-child { margin-left: 6px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.link-btn { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.link-btn.warn { color: var(--warn); text-decoration: none; }
.dp-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 19px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn.lg { height: 44px; font-size: 14px; }
.btn.block { width: 100%; }
.btn-ink { background: var(--ink); color: var(--on-ink); }
.btn-ink:hover:not(:disabled) { opacity: 0.9; }
.btn-ghost { border: 1px solid var(--line); background: var(--panel); }
.btn-ghost.bare { border-color: transparent; background: transparent; padding: 0 8px; font-weight: 500; }
.btn-ghost.bare.on { color: var(--accent); }
.btn-warn { background: var(--warn); color: var(--on-ink); }
:root[data-theme='dark'] .btn-warn { color: #1E1B18; }

.nudge { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-size: 12px; line-height: 1.45; }
.nudge p { flex: 1; }
.nudge .icon-btn { color: var(--warn); }
.nudge.compact { box-shadow: 0 8px 24px -12px var(--shadow); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); }
.note { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 8px; font-size: 12px; line-height: 1.45; }
.note .icon { margin-top: 1px; }
.note.sm { padding: 8px 10px; font-size: 11.5px; }
.note.ok { background: var(--ok-bg); color: var(--ok); align-items: center; flex-wrap: wrap; }
.note.ok .link-btn { color: var(--ok); margin-left: auto; }
.note.warn { background: var(--warn-bg); color: var(--warn); }

/* drawer */
.drawer { top: 0; right: 0; bottom: 0; width: min(460px, 100vw); display: flex; flex-direction: column; border-radius: 0; border-width: 0 0 0 1px; animation: slide 0.3s cubic-bezier(0.22, 1, 0.36, 1); }
.drawer.closing { animation: slide-out 0.22s cubic-bezier(0.4, 0, 1, 1) both; }
@keyframes slide { from { transform: translateX(32px); opacity: 0; } }
@keyframes slide-out { to { transform: translateX(48px); opacity: 0; } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 18px; font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 0 24px; }
.drawer-foot { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line); }
.adv-sec { padding: 20px 0 18px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.adv-sec:last-child { border-bottom: 0; }
.adv-sec > h3 { margin-bottom: 4px; }
.mono-label.flush { margin: 0; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 30px; }
.row-label { font-size: 13px; }
.row-ctl { display: flex; align-items: center; gap: 8px; }
.row-ctl.grow { flex: 1; justify-content: flex-end; max-width: 300px; }
.row-ctl .val { font-size: 12px; width: 28px; text-align: right; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 28px; }
.switch { width: 30px; height: 18px; border-radius: 9px; background: var(--line); position: relative; flex: none; transition: background 0.15s; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--field); box-shadow: 0 1px 2px var(--shadow); transition: transform 0.15s; }
.switch.on { background: var(--accent); }
.switch.on .knob { transform: translateX(12px); background: #FBFAF7; }
fieldset.plain { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
fieldset.plain:disabled { opacity: 0.5; }
.corner-arrows { display: flex; gap: 4px; }
.sq-btn { width: 28px; height: 28px; border-radius: 6px; background: var(--chip); display: grid; place-items: center; color: var(--muted); }
.sq-btn.on { background: var(--ink); color: var(--on-ink); }

input[type='range'] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; }
input[type='range']::-webkit-slider-runnable-track { height: 2px; border-radius: 1px; background: linear-gradient(to right, var(--accent) var(--p), var(--line) var(--p)); }
input[type='range']::-moz-range-track { height: 2px; background: var(--line); }
input[type='range']::-moz-range-progress { height: 2px; background: var(--accent); }
input[type='range']::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -6px; border-radius: 50%; background: var(--field); border: 2px solid var(--accent); }
input[type='range']::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--field); border: 2px solid var(--accent); }

/* color editor */
.color-pop { width: min(440px, calc(100vw - 340px)); max-height: calc(100vh - 32px); overflow: visible; display: flex; flex-direction: column; animation: cp-in 0.22s cubic-bezier(0.22, 1, 0.36, 1); }
.color-pop .caret { position: absolute; left: -7px; width: 14px; height: 14px; background: var(--panel); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg); }
@keyframes cp-in { from { opacity: 0; transform: translateX(-8px); } }
.color-editor { display: flex; flex-direction: column; min-height: 0; }
.col-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 14px 10px; }
.col-roles, .col-quick, .col-saved { padding: 4px 14px 10px; overflow-y: auto; min-height: 0; }
.color-pop .col-roles { max-height: 360px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 10px; padding: 6px 0 4px; }
.col-quick .tiles { grid-template-columns: repeat(2, 88px); }
.role-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.role-tile .role-sw { width: 100%; max-width: 72px; height: 44px; border-radius: 10px; }
.hex-under { width: 100%; max-width: 76px; height: 22px; border: 1px solid transparent; border-radius: 5px; background: transparent; text-align: center; font-size: 11px; text-transform: uppercase; color: var(--ink); padding: 0; }
.hex-under:hover { border-color: var(--line); }
.hex-under:focus { outline: none; border-color: var(--accent); background: var(--field); }
.role-label { font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.25; }
.role-sw { position: relative; width: 26px; height: 26px; border-radius: 6px; background: var(--c); box-shadow: inset 0 0 0 1px var(--swatch-line); flex: none; cursor: pointer; }
.role-sw input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.role-sw:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.contrast { display: flex; align-items: center; gap: 8px; padding: 9px 14px; font-size: 11.5px; }
.contrast.ok { background: var(--ok-bg); color: var(--ok); }
.contrast.bad { background: var(--warn-bg); color: var(--warn); }
.col-foot { display: flex; gap: 8px; padding: 10px 14px 14px; }
.text-in { flex: 1; min-width: 0; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--field); font-size: 13px; }
.text-in:focus { outline: none; border-color: var(--accent); }
.preview-strip { display: flex; height: 22px; border-radius: 6px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--swatch-line); }
.preview-strip span { flex: 1; }
.preview-strip.mini { width: 70px; height: 16px; flex: none; }
.saved-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.saved-row:first-child { border-top: 0; }
.saved-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* export */
.export-pop { top: 70px; right: 32px; width: 380px; max-width: calc(100vw - 32px); }
.exp-head { padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.exp-head h2 { font-size: 14px; font-weight: 600; }
.exp-head p { font-size: 11px; color: var(--muted); margin-top: 2px; }
.exp-list { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.exp-row { display: grid; grid-template-columns: 18px 64px 1fr auto; align-items: center; gap: 10px; padding: 10px 10px; border-radius: 8px; cursor: pointer; min-height: 40px; }
.exp-row:hover { background: var(--chip); }
.exp-row.on { background: var(--accent-soft); }
.exp-row.on .exp-name { color: var(--accent); }
.radio { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--frame); }
.exp-row.on .radio { border: 5px solid var(--accent); background: var(--field); }
.exp-name { font-weight: 600; font-size: 13px; }
.exp-dims { font-size: 11px; display: flex; align-items: center; gap: 8px; }
.exp-dims .numfield { height: 28px; }
.exp-size { font-size: 10px; text-align: right; }
.export-pop > .note { margin: 0 16px 10px; }
.exp-file { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--chip); font-size: 10.5px; color: var(--ink); overflow: hidden; }
.exp-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp-cta { padding: 12px 16px 16px; }

/* install modal */
.modal { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; border-radius: 16px; animation: fade 0.15s ease-out; }
.ins-top { padding: 24px 28px 18px; display: flex; flex-direction: column; gap: 10px; }
.ok-badge { width: 40px; height: 40px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; }
.ins-top h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.tabs { display: flex; gap: 20px; padding: 0 28px; border-bottom: 1px solid var(--line); }
.tab { padding: 8px 0 10px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--ink); font-weight: 600; border-color: var(--ink); }
.steps { list-style: none; margin: 0; padding: 16px 28px; display: flex; flex-direction: column; gap: 12px; }
.steps li { display: flex; align-items: center; gap: 12px; font-size: 13.5px; }
.steps .num { width: 24px; height: 24px; border-radius: 50%; background: var(--chip); display: grid; place-items: center; font: 700 10.5px var(--mono); flex: none; }
.steps li.key { font-weight: 600; }
.steps li.key .num { background: var(--accent); color: #FBFAF7; }
.ins-warn { display: flex; align-items: center; gap: 10px; padding: 12px 28px; background: var(--warn-bg); color: var(--warn); font-size: 12.5px; }
.ins-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 28px 20px; }
.ins-foot .sm-text { display: inline-flex; align-items: center; gap: 6px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 10px 16px; border-radius: 99px; background: var(--ink); color: var(--on-ink); font-size: 12.5px; font-weight: 500; opacity: 0; pointer-events: none; transition: 0.2s; z-index: 80; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------------ calibration */
.calib { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: grid; grid-template-rows: auto 1fr auto; overflow: auto; }
.calib-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 22px 32px; gap: 12px; }
.calib-nav .seg { background: var(--chip); padding: 3px; border-radius: 99px; }
.calib-nav .seg.pill-tabs .seg-btn.on { background: var(--field); color: var(--ink); box-shadow: 0 1px 2px var(--shadow); }
:root[data-theme="dark"] .calib-nav .seg.pill-tabs .seg-btn.on { background: var(--frame); }
.calib-dev { justify-self: end; font-size: 11px; }
.calib-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px 16px; }
.calib-title { font-size: 30px; font-weight: 700; letter-spacing: -0.8px; text-align: center; }
.calib-sub { font-size: 14px; color: var(--muted); text-align: center; }
.card-zone { padding: 36px 70px; display: grid; place-items: center; }
.card-box {
  position: relative; border: 2px solid var(--accent); border-radius: 12px;
  background: var(--accent-soft); display: grid; place-items: center;
  touch-action: none; user-select: none;
}
.card-box:focus-visible { outline: 2px dashed var(--accent); outline-offset: 5px; border-radius: 12px; }
.card-tag { position: absolute; top: 16px; left: 18px; font-size: 11px; color: var(--accent); letter-spacing: 0.08em; }
.card-icon { color: var(--accent); opacity: 0.4; }
.handle { position: absolute; width: 14px; height: 14px; border-radius: 4px; background: var(--field); border: 2px solid var(--accent); touch-action: none; }
.handle.tl { top: -8px; left: -8px; cursor: nwse-resize; }
.handle.br { bottom: -8px; right: -8px; cursor: nwse-resize; }
.handle.tr { top: -8px; right: -8px; cursor: nesw-resize; }
.handle.bl { bottom: -8px; left: -8px; cursor: nesw-resize; }
.handle.edge-r { right: -5px; top: 50%; width: 8px; height: 34px; margin-top: -17px; border: 0; background: var(--accent); border-radius: 3px; cursor: ew-resize; }
.handle.edge-b { bottom: -5px; left: 50%; height: 8px; width: 34px; margin-left: -17px; border: 0; background: var(--accent); border-radius: 3px; cursor: ns-resize; }
.dim-h { position: absolute; left: calc(100% + 14px); top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.dim-w { position: absolute; top: calc(100% + 14px); left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.calib-bar { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-radius: 26px; border: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; justify-content: center; }
.calib-bar .lbl { font-size: 13px; color: var(--muted); margin: 0 2px 0 6px; }
.step { width: 28px; height: 28px; border-radius: 7px; background: var(--chip); display: grid; place-items: center; }
.calib-bar .numfield { height: 32px; }
.calib-bar .numfield input { font-weight: 400; font-size: 13px; }
.calib-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 32px; flex-wrap: wrap; }
.keys { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.keys span { margin-right: 10px; }
kbd { font: 400 10px var(--mono); padding: 3px 7px; border-radius: 5px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.calib-warn { display: flex; gap: 18px; flex-wrap: wrap; font-size: 11.5px; color: var(--warn); }
.calib-warn span { display: inline-flex; align-items: center; gap: 6px; }
.confirm-card { width: min(520px, 100%); padding: 28px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.confirm-card h1 { font-size: 22px; letter-spacing: -0.4px; }
.confirm-card p { color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.ruler-zone { padding: 48px 16px 32px; max-width: 100%; overflow-x: auto; }
.ruler-line { position: relative; height: 40px; border-bottom: 2px solid var(--accent); }
.rt { position: absolute; bottom: 0; width: 1px; height: 8px; background: var(--accent); transform: translateX(-0.5px); }
.rt.half { height: 13px; }
.rt.cm { height: 20px; width: 2px; transform: translateX(-1px); }
.rl-0, .rl-10 { position: absolute; top: calc(100% + 8px); font-size: 11px; color: var(--accent); }
.ruler-line.vertical { width: 44px; border-bottom: 0; border-left: 2px solid var(--accent); }
.ruler-line.vertical .rt { left: 0; bottom: auto; height: 1px; width: 8px; transform: translateY(-0.5px); }
.ruler-line.vertical .rt.half { width: 13px; }
.ruler-line.vertical .rt.cm { width: 20px; height: 2px; transform: translateY(-1px); }
.ruler-line.vertical .rl-0 { top: 0; left: 28px; transform: translateY(-50%); }
.ruler-line.vertical .rl-10 { top: auto; bottom: 0; right: auto; left: 28px; transform: translateY(50%); }
.rl-0 { left: 0; transform: translateX(-50%); }
.rl-10 { right: 0; transform: translateX(50%); white-space: nowrap; }

/* ------------------------------------------------------------------ mobile (TEC-05) */
.app.is-mobile { max-width: 640px; margin: 0 auto; padding: 0 16px 104px; display: flex; flex-direction: column; gap: 12px; }
.m-nav { display: flex; justify-content: space-between; align-items: center; padding: 16px 0 4px; }
.m-nav .brand { font-size: 18px; }
.m-device { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); text-align: left; width: 100%; }
.m-dev-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.m-dev-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-nudge:empty { display: none; }
.m-preview { padding: 10px; border-radius: 6px; background: var(--chip); border: 1px solid var(--line); }
.m-preview .preview-wrap { display: block; }
.m-preview .preview-frame { margin: 0 auto; }
.m-preview .preview-frame { box-shadow: 0 0 0 1px var(--frame); }
.m-caption { font-size: 11px; color: var(--muted); }
.m-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.m-tab { height: 32px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; font-weight: 500; flex: none; }
.m-tab.on { background: var(--ink); color: var(--on-ink); border-color: var(--ink); font-weight: 600; }
.m-sheet { display: flex; flex-direction: column; gap: 12px; }
.m-sheet .adv-sec { padding: 12px 0; }
.m-sheet .swatches { flex-wrap: wrap; gap: 12px; padding: 6px 4px; }
.m-sheet .swatch { width: 34px; height: 34px; }
.m-sheet .color-editor { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.m-stats { padding-top: 4px; }
.style-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-card { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-size: 13.5px; font-weight: 500; text-align: left; }
.style-card.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.m-cta { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); z-index: 30; display: flex; justify-content: center; }
.m-cta .dl-split { width: 100%; max-width: 608px; height: 50px; border-radius: 25px; }
.m-cta .dl-main { flex: 1; justify-content: center; font-size: 15px; }
.m-cta .dl-more { width: 50px; }
.is-mobile .grid2 { grid-template-columns: 1fr; }

@media (max-width: 860px) {
  .device-pop { inset: 0; transform: none; width: 100%; max-height: none; border-radius: 0; animation-name: dp-in-m; }
  .device-pop.closing { animation-name: dp-out-m; }
  @keyframes dp-in-m { from { opacity: 0; transform: translateY(-24px) scale(0.96); } to { opacity: 1; transform: none; } }
  @keyframes dp-out-m { to { opacity: 0; transform: translateY(-16px) scale(0.97); } }
  .dp-head { flex-wrap: wrap; }
  .search { width: 100%; }
  .dp-body { grid-template-columns: 1fr; overflow-y: auto; }
  .dp-list { overflow: visible; }
  .dp-detail { overflow: visible; }
  .export-pop { top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-width: none; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .export-pop + .scrim, .scrim.clear { background: var(--scrim); }
  .drawer { width: 100vw; }
  .calib-nav { grid-template-columns: 1fr; justify-items: center; padding: 16px; }
  .calib-dev { justify-self: center; }
  .calib-nav > .btn { justify-self: start; }
  .card-zone { padding: 28px 8px; }
  .dim-h { display: none; }
  .calib-title { font-size: 24px; }
  .calib-foot { padding: 14px 16px; }
  .stage-nudge { position: static; transform: none; width: auto; }
}
@media (max-width: 1180px) and (min-width: 861px) {
  .nav { grid-template-columns: auto 1fr auto; }
  .device-pill { justify-self: center; }
  .device-pill .status { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------------ support (pay what you want) */
.support-btn { width: auto; padding: 0 14px 0 12px; display: inline-flex; gap: 7px; font-size: 13px; font-weight: 600; }
.support-btn.compact { width: 38px; padding: 0; justify-content: center; }
.support-btn .icon { color: var(--accent); }
.support { display: flex; flex-direction: column; gap: 12px; }
.sup-head { display: flex; gap: 12px; align-items: flex-start; }
.sup-head strong, .support.done strong { font-size: 15px; font-weight: 700; display: block; }
.sup-head p, .support.done p { font-size: 12.5px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.sup-cup, .sup-heart { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.sup-heart { background: var(--ok-bg); color: var(--ok); }
.sup-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sup-chips .chip { height: 34px; padding: 0 14px; font-family: var(--mono); font-size: 12.5px; }
.sup-other { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--field); }
.sup-other:focus-within { border-color: var(--accent); }
.sup-other span { font: 700 13px var(--mono); color: var(--muted); }
.sup-other input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font: 700 15px var(--mono); }
.sup-note { font-size: 12px; }
.sup-go { align-self: flex-start; }
.sup-fine { font-size: 11px; color: var(--muted); line-height: 1.45; }
.support.done { flex-direction: row; align-items: center; gap: 12px; }
.qr-step { flex-direction: row; align-items: center; gap: 18px; flex-wrap: wrap; }
.sup-qr { width: 200px; height: 200px; padding: 10px; border-radius: 14px; background: #fff; box-shadow: 0 0 0 1px var(--line); flex: none; }
.sup-qr img { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.sup-qr-missing { width: 100%; height: 100%; display: grid; place-items: center; color: #888; }
.sup-qr-side { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 180px; flex: 1; }
.sup-qr-side strong { font: 700 20px var(--mono); }
.sup-qr-side p { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.sup-wait { display: inline-flex; align-items: center; gap: 6px; color: var(--ink) !important; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ins-support { padding: 16px 28px; border-top: 1px solid var(--line); }
.support-modal { padding: 24px; width: min(480px, calc(100vw - 32px)); }
.support-modal.closing, .modal.closing { animation: fade-out 0.17s ease-in both; }
.sup-close { position: absolute; top: 12px; right: 12px; }
@media (max-width: 860px) {
  .support-modal { top: auto; bottom: 0; left: 0; transform: none; width: 100%; border-radius: 16px 16px 0 0; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .sup-qr { width: 180px; height: 180px; }
}
