[hidden] { display: none !important; }
:root {
  color-scheme: light;
  --theta: 0rad;
  --bg: #f4f3f1;
  --surface: #ffffff;
  --ink: #17171a;
  --ink-2: #3d3d44;
  --muted: #86868f;
  --line: #ebeae7;
  --line-2: #dedcd8;
  --fill: #f4f3f0;
  --fill-2: #eceae6;
  --accent: #2f6bf2;
  --font: "Nunito", ui-rounded, "SF Pro Rounded", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --display: "Comfortaa", "Nunito", ui-rounded, ui-sans-serif, system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
html { -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--font); font-size: 13.5px; font-weight: 500; line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
svg { flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------------------------------------------------------- shell */
.shell {
  height: 100vh; height: 100dvh; display: grid;
  grid-template-columns: minmax(0, 1fr) 388px;
  grid-template-rows: 64px minmax(0, 1fr);
  grid-template-areas: "top top" "stage inspector";
}
.topbar {
  grid-area: top; position: relative; z-index: 25; display: flex; align-items: center; justify-content: space-between;
  padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.7); backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.logo { width: 30px; height: 30px; }
.brand-text { display: flex; align-items: baseline; gap: 8px; }
.wordmark { font-family: var(--display); font-size: 20px; font-weight: 400; letter-spacing: -0.02em; }
.wordmark b { font-weight: 700; }
.tagline { font-size: 10.5px; font-weight: 800; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); }
.actions { display: flex; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px 0 11px; white-space: nowrap;
  border-radius: 999px; font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn:active { transform: scale(.97); }
.btn-quiet { background: var(--surface); border: 1px solid var(--line-2); }
.btn { padding: 0 16px 0 13px; }
.btn-quiet:hover { background: var(--fill); }
.btn-solid { background: var(--ink); border: 1px solid var(--ink); color: #fff; }
.btn-solid:hover { background: #2b2b31; }

/* ---------------------------------------------------------- stage */
.stage {
  grid-area: stage; position: relative; min-height: 0; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 24px 64px;
  background:
    radial-gradient(60% 55% at 50% 42%, #ffffff 0%, rgba(255,255,255,0) 100%),
    linear-gradient(#f7f6f4, #efeeeb);
}
.scope {
  position: relative; width: min(100%, calc(100vh - 140px), 880px); min-width: 260px; aspect-ratio: 1;
  touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
  opacity: 0; transform: scale(.985); transition: opacity .7s var(--ease), transform .7s var(--ease);
}
body.ready .scope { opacity: 1; transform: none; }
.scope.twisting, .scope.grabbing { cursor: grabbing; }
.scope.over-piece { cursor: pointer; }
.frame, .frame-shadow { position: absolute; inset: 0; pointer-events: none; }
.frame svg, .frame-shadow svg { width: 100%; height: 100%; display: block; overflow: visible; }
.frame svg { transform: rotate(var(--theta)); }
.frame-shadow { transform: translateY(14px) scale(.97); filter: blur(22px); opacity: .26; }
.frame-shadow svg { transform: rotate(var(--theta)); fill: #3a2f25; stroke: #3a2f25; }
.viewport { position: absolute; overflow: hidden; background: #111; }
.scope.is-round .viewport { inset: 5%; border-radius: 50%; }
.scope.is-prism .viewport { inset: 0; background: transparent; }
#gl { display: block; width: 100%; height: 100%; }
.lens { position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background:
    radial-gradient(ellipse 40% 16% at 32% 13%, rgba(255,255,255,.28), rgba(255,255,255,0) 70%),
    radial-gradient(circle at 50% 50%, rgba(0,0,0,0) 72%, rgba(0,0,0,.28) 100%); }
.scope.is-prism .lens { display: none; }
.glerr { position: absolute; inset: 0; display: grid; place-items: center; padding: 18%; text-align: center; color: #f4f4f5; font-size: 14px; background: #17171a; }
.glerr small { display: block; margin-top: 8px; color: #a1a1aa; font-size: 12px; word-break: break-word; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 14px; color: #a7a6ae; font-size: 12.5px; background: #f4f3f1; }
.scope.is-round .loading { background: #17171a; border-radius: 50%; }
.loading span { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(128,128,128,.2); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.controlbar {
  display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(20,20,30,.04), 0 10px 30px -14px rgba(20,20,30,.25);
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; min-width: 28px; padding: 0 6px;
  border: 0; border-radius: 999px; background: transparent; cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 700;
  transition: background .15s var(--ease);
}
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--fill); color: var(--ink); }
.icon-btn.wide { padding: 0 12px 0 10px; }
.cb-sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; }
.dial {
  position: relative; width: 168px; height: 20px; border-radius: 999px; margin: 0 4px; overflow: hidden; cursor: ew-resize; touch-action: none;
  background: linear-gradient(90deg, #e7e4df, #fbfaf8 50%, #e7e4df); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06);
}
.dial-ribs {
  position: absolute; inset: 4px 0;
  background: repeating-linear-gradient(90deg, rgba(40,35,30,.28) 0 1px, transparent 1px 7px);
  background-position-x: calc(var(--theta) / 1rad * 90px);
  -webkit-mask: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
  mask: linear-gradient(90deg, transparent, #000 25%, #000 75%, transparent);
}
.dial-mark { position: absolute; left: 50%; top: 3px; bottom: 3px; width: 2px; margin-left: -1px; border-radius: 2px; background: var(--accent); }
.dial.active { box-shadow: inset 0 0 0 1px rgba(47,107,242,.4); }

/* ---------------------------------------------------------- inspector */
.inspector { grid-area: inspector; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 14px 16px 4px; padding: 3px; background: var(--fill); border-radius: 10px; }
.tab { border: 0; background: transparent; border-radius: 8px; height: 32px; cursor: pointer; font-family: var(--display); font-size: 13px; font-weight: 700; color: var(--muted); transition: background .15s, color .15s; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 .5px rgba(0,0,0,.04); }
.tabpanel { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 0 16px; scrollbar-width: thin; }
.group { padding: 16px 20px; }
.group + .group { border-top: 1px solid var(--line); }
.group-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.group h3 { margin: 0; font-family: var(--display); font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.hint-sm { font-size: 12px; color: var(--muted); }
.hint-sm b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; }
.tiny { font-size: 11px; }
.note { margin: 10px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

.bodies { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.body {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0 7px; border-radius: 10px; cursor: pointer;
  background: var(--fill); border: 1px solid transparent; font-size: 11.5px; font-weight: 700; color: var(--ink-2);
  transition: background .15s, border-color .15s;
}
.body svg { width: 28px; height: 28px; fill: #fff; stroke: #8b8a92; stroke-width: 2.4; stroke-linejoin: round; }
.body:hover { background: var(--fill-2); }
.body[aria-checked="true"] { background: var(--surface); border-color: var(--ink); box-shadow: 0 0 0 .5px var(--ink); color: var(--ink); }
.body[aria-checked="true"] svg { stroke: var(--ink); fill: #eef2fe; }

.systems { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.system {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px 8px; border-radius: 10px; cursor: pointer;
  background: var(--fill); border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.system svg { margin-bottom: 4px; }
.system .sname { font-size: 12.5px; font-weight: 700; }
.system .ssub { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.system:hover { background: var(--fill-2); }
.system[aria-checked="true"] { background: var(--surface); border-color: var(--ink); box-shadow: 0 0 0 .5px var(--ink); }

.d-body { fill: #fff; stroke: #d6d4cf; stroke-width: 1.5; }
.d-fill { fill: #eef1f6; }
.d-mirror { stroke: #5b6b80; stroke-width: 2.6; stroke-linecap: round; }
.d-black { stroke: #17171a; stroke-width: 2.6; stroke-linecap: round; }
.d-far { fill: none; stroke: #93a0b1; stroke-width: .9; stroke-dasharray: 2 2; }
.d-arc { fill: none; stroke: var(--accent); stroke-width: 1.4; }
.d-label { font: 800 9px var(--font); fill: var(--ink); text-anchor: middle; }
.d-eye { fill: var(--accent); stroke: #fff; stroke-width: 1.2; }

.explain { display: grid; grid-template-columns: 104px 1fr; gap: 14px; align-items: center; margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--fill); }
.diagram svg { display: block; }
.explain h4 { margin: 0 0 4px; font-family: var(--display); font-size: 13px; font-weight: 700; }
.explain p { margin: 0; font-size: 12px; line-height: 1.5; color: var(--ink-2); }
.legend { margin-top: 8px !important; display: flex; align-items: center; gap: 5px; font-size: 11px !important; color: var(--muted) !important; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-left: 6px; }
.legend i:first-child { margin-left: 0; }
.lg-m { background: #5b6b80; } .lg-b { background: #17171a; } .lg-e { width: 7px !important; height: 7px !important; border-radius: 50% !important; background: var(--accent); }

.block { display: grid; gap: 8px; margin-top: 16px; }
.angles { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.angle { display: flex; flex-direction: column; align-items: center; padding: 6px 0 5px; border-radius: 8px; border: 0; cursor: pointer; background: var(--fill); transition: background .15s; }
.angle b { font-size: 11.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.angle span { font-size: 10px; color: var(--muted); }
.angle:hover { background: var(--fill-2); }
.angle[aria-checked="true"], .angle[aria-checked="true"]:hover { background: var(--ink); color: #fff; }
.angle[aria-checked="true"] span { color: rgba(255,255,255,.65); }

.slider { display: grid; grid-template-columns: 92px 1fr 52px; align-items: center; gap: 12px; margin-top: 14px; }
.slider output { text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
input[type="range"] { --p: 50%; -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--ink) 0 var(--p), #e3e1dd var(--p) 100%); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: #e3e1dd; }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.14), 0 2px 5px rgba(0,0,0,.18); }
input[type="range"]::-moz-range-thumb { width: 15px; height: 15px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.14), 0 2px 5px rgba(0,0,0,.18); }

.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.theme { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 9px 0 8px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; transition: background .15s, border-color .15s; }
.lens-chip { width: 34px; height: 34px; border-radius: 50%; position: relative; box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.12); }
.lens-chip::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 34% 28%, rgba(255,255,255,.75), rgba(255,255,255,0) 46%); }
.tname { font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.theme:hover { background: var(--fill); }
.theme[aria-checked="true"] { background: var(--fill); }
.theme[aria-checked="true"] .lens-chip { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ink); }
.theme[aria-checked="true"] .tname { color: var(--ink); font-weight: 600; }

.shapes { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.shape { position: relative; aspect-ratio: 1; padding: 0; overflow: hidden; border-radius: 10px; cursor: pointer; background: #fff; border: 1px solid var(--line); transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s; }
.shape canvas { width: 100%; height: 100%; display: block; }
.shape:hover { transform: translateY(-1px); border-color: var(--line-2); box-shadow: 0 8px 16px -10px rgba(0,0,0,.35); }
.slabel { position: absolute; inset: auto 0 2px; font-size: 9.5px; font-weight: 500; color: var(--muted); text-align: center; opacity: 0; transition: opacity .15s; pointer-events: none; }
.shape:hover .slabel, .shape:focus-visible .slabel { opacity: 1; }
.shape.pop { animation: pop .35s var(--ease); }
@keyframes pop { 40% { transform: scale(.9); } 100% { transform: none; } }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.group-head + .row { margin-top: 0; }
.colors { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.swatch { width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; background: radial-gradient(circle at 34% 30%, rgba(255,255,255,.75), rgba(255,255,255,0) 44%), var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .12s; }
.swatch.mix { background: radial-gradient(circle at 34% 30%, rgba(255,255,255,.75), rgba(255,255,255,0) 44%), conic-gradient(#2f6bf2, #14b8a6, #f5b52e, #f97350, #e8508a, #8b5cf6, #2f6bf2); }
.swatch:hover { transform: scale(1.1); }
.swatch[aria-checked="true"] { box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), 0 0 0 2px #fff, 0 0 0 3.5px var(--ink); }

.seg { display: inline-grid; grid-auto-flow: column; gap: 2px; padding: 3px; background: var(--fill); border-radius: 9px; }
.seg button { border: 0; background: transparent; border-radius: 7px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--muted); transition: background .15s, color .15s; }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }

.toolbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 16px; }
.tbtn { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 7px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; font-size: 12px; font-weight: 700; color: var(--ink-2); transition: background .15s, border-color .15s; }
.tbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tbtn:hover { background: var(--fill); color: var(--ink); }
.tbtn:active { transform: scale(.97); }

.summary:not(:has(.install:not([hidden]))) { display: none !important; }
.summary { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-2); }
.summary .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.15); }

kbd { font: inherit; font-size: 11px; padding: 0 4px; border: 1px solid var(--line-2); border-radius: 4px; }

/* ---------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .shell { height: auto; grid-template-columns: 1fr; grid-template-rows: 60px auto auto; grid-template-areas: "top" "stage" "inspector"; }
  .stage { padding: 20px 14px; }
  .scope { width: min(100%, 92vw, 600px); }
  .inspector { border-left: 0; border-top: 1px solid var(--line); }
  .tabpanel { overflow: visible; }
}
@media (max-width: 480px) {
  .topbar { padding: 0 12px 0 14px; }
  .tagline { display: none; }
  .btn-quiet .btn-label { display: none; }
  .btn-quiet { padding: 0 9px; }
  .dial { width: 150px; }
  .icon-btn.wide { padding: 0 8px; }
  .group { padding: 14px 16px; }
  .themes { grid-template-columns: repeat(5, 1fr); }
  .angles { grid-template-columns: repeat(5, 1fr); }
  .explain { grid-template-columns: 80px 1fr; }
  .diagram svg { width: 80px; height: 80px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

#auto .i-pause { display: none; }
#auto[aria-pressed="true"] .i-play { display: none; }
#auto[aria-pressed="true"] .i-pause { display: block; }
#auto[aria-pressed="true"] { background: var(--ink); color: #fff; }
#auto .i-play path { fill: currentColor; stroke: none; }
.seg-wide { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
.seg-wide button { padding: 7px 0; }
.backlights { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.bl { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 7px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-size: 11.5px; font-weight: 600; color: var(--ink-2); transition: background .15s; }
.bl:hover { background: var(--fill); }
.bl-dot { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 50% 50%, #fff 0 30%, var(--c) 75%); box-shadow: 0 0 0 1px rgba(0,0,0,.1), 0 0 14px var(--c); }
.bl[aria-checked="true"] { background: var(--fill); color: var(--ink); }
.bl[aria-checked="true"] .bl-dot { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ink), 0 0 14px var(--c); }
@media (max-width: 1000px) {
  .stage { padding: 12px 12px 64px; }
  .scope { width: min(100%, 94vw, 640px); }
}

.system { position: relative; }
.sig { position: absolute; top: 5px; right: 5px; font-size: 9px; font-weight: 800; letter-spacing: .04em; color: var(--accent); background: #e9efff; border-radius: 999px; padding: 1px 6px; }

/* -------------------------------------------------------- app shell (installed) */
.install { margin-left: auto; border: 0; border-radius: 999px; padding: 5px 12px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; cursor: pointer; }
.summary { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
@media (display-mode: standalone), (display-mode: window-controls-overlay) {
  .topbar { -webkit-app-region: drag; app-region: drag; }
  .topbar button, .topbar a { -webkit-app-region: no-drag; app-region: no-drag; }
}
@media (max-width: 1000px) {
  .shell { grid-template-rows: calc(60px + env(safe-area-inset-top)) auto auto; }
  .controlbar { bottom: max(14px, env(safe-area-inset-bottom)); }
}

/* -------------------------------------------------------- save panel */
.save-wrap { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 320px; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 24px 48px -16px rgba(20,20,30,.28), 0 2px 6px rgba(20,20,30,.06);
  -webkit-app-region: no-drag; app-region: no-drag;
}
.pop-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.pop-head h3 { margin: 0; font-family: var(--display); font-size: 14px; font-weight: 700; }
.pop-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.pop-note { margin: 12px 0 14px; font-size: 11.5px; color: var(--muted); line-height: 1.45; }
.seg button:disabled { opacity: .35; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: progress; }
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 30; transform: translate(-50%, 12px); opacity: 0;
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.4); transition: opacity .2s var(--ease), transform .2s var(--ease); pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 1001px) { .toast { left: calc((100% - 388px) / 2); bottom: 96px; } }   /* over the stage, above its bar */
@media (max-width: 480px) { .popover { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; } }

/* -------------------------------------------------------- kaleidoscope picker */
.kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.kind {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 4px 10px; border-radius: 12px; cursor: pointer;
  background: var(--fill); border: 1px solid transparent; transition: background .15s, border-color .15s;
}
.kind svg { width: 34px; height: 34px; margin-bottom: 4px; fill: #fff; stroke: #8b8a92; stroke-width: 2.2; stroke-linejoin: round; }
.kind .kname { font-family: var(--display); font-size: 13px; font-weight: 700; }
.kind .ksub { font-size: 11px; color: var(--muted); }
.kind:hover { background: var(--fill-2); }
.kind[aria-checked="true"] { background: var(--surface); border-color: var(--ink); box-shadow: 0 0 0 .5px var(--ink); }
.kind[aria-checked="true"] svg { stroke: var(--ink); fill: #eef2fe; }

/* -------------------------------------------------------- stage bar, modes, zoom, selection */
.stage { padding-bottom: 76px; }
.scope { transition: opacity .7s var(--ease), transform .7s var(--ease), scale .25s var(--ease); }
.stagebar {
  position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; pointer-events: none;
}
.stagebar > * { pointer-events: auto; }
.modebar, .zoombar, .controlbar { box-shadow: 0 1px 2px rgba(20,20,30,.04), 0 10px 30px -14px rgba(20,20,30,.25); }
.modebar { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.modebar .mode { display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 6px 11px; }
.modebar .mode svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.modebar .mode[aria-checked="true"] { background: var(--ink); color: #fff; box-shadow: none; }
.zoombar { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.zoom-val { border: 0; background: transparent; font-size: 12px; font-weight: 700; color: var(--ink-2); min-width: 46px; height: 28px; border-radius: 999px; cursor: pointer; font-variant-numeric: tabular-nums; }
.zoom-val:hover { background: var(--fill); }
.scope[data-mode="place"] { cursor: copy; }
.scope[data-mode="move"] { cursor: default; }

.selbar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 13px; box-shadow: 0 12px 30px -10px rgba(0,0,0,.45);
}
.sel-dot { width: 8px; height: 8px; border-radius: 50%; background: #7aa7ff; box-shadow: 0 0 0 4px rgba(122,167,255,.25); }
.sel-btn { border: 0; border-radius: 999px; padding: 5px 12px; background: rgba(255,255,255,.14); color: #fff; font-weight: 700; font-size: 12.5px; cursor: pointer; }
.sel-btn:hover { background: rgba(255,255,255,.24); }
.sel-x { width: 28px; height: 28px; border: 0; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.14); color: #fff; cursor: pointer; }
.sel-x svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sel-x:hover { background: rgba(255,255,255,.24); }

.shape[aria-checked="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.scratch { margin-bottom: 12px; }
.scratch svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.seg-wide2 { display: grid; grid-template-columns: 1fr 1fr; width: 100%; margin-bottom: 6px; }
.pop-row.check input { width: 18px; height: 18px; accent-color: var(--ink); }
#saveGo.recording { background: #d93a3a; border-color: #d93a3a; }

@media (max-width: 1000px) {
  .stage { padding-bottom: 120px; }
  .stagebar { justify-content: center; }
  .controlbar { order: -1; flex-basis: auto; }
}

/* -------------------------------------------------------- colour per shape */
.colour-head { display: flex; align-items: baseline; justify-content: space-between; margin: 16px 0 8px; }
.colors-wrap { justify-content: flex-start; flex-wrap: wrap; gap: 7px; }
.swatch.add { display: grid; place-items: center; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-2); color: var(--ink-2); }
.swatch.add svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.swatch.add:hover { box-shadow: inset 0 0 0 1.5px var(--ink); }
.sw-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.colour-actions { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; }
.link-btn { border: 0; background: none; padding: 0; font-size: 12px; font-weight: 700; color: var(--accent); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { color: var(--muted); cursor: default; text-decoration: none; }
.add-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 14px; }
.add-row .btn { justify-content: center; }
.add-row .btn:disabled { opacity: .55; cursor: default; }
.sr-only { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.toolbar { grid-template-columns: repeat(3, 1fr); }
.lens-chip.free { box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.12); filter: saturate(1.1); }
#cellNote { margin-top: 8px; }

.bl-dot.plain { background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.14); }
.lights { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.lt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 0 7px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.lt:hover { background: var(--fill); }
.lt-dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle, #fff 0 22%, var(--c) 60%, transparent 72%); }
.lt-dot svg { width: 22px; height: 22px; fill: none; stroke: color-mix(in srgb, var(--c) 70%, #555); stroke-width: 1.4; stroke-linecap: round; }
.lt[aria-checked="true"] { background: var(--fill); color: var(--ink); }
.lt[aria-checked="true"] .lt-dot { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--ink); }

/* -------------------------------------------------------- start from / batch edits */
.templates { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 9px 12px; border-radius: 12px; cursor: pointer; text-align: left;
  background: var(--fill); border: 1px solid transparent; transition: background .15s, border-color .15s; }
.tpl:hover { background: var(--fill-2); }
.tpl[aria-checked="true"] { background: var(--surface); border-color: var(--ink); box-shadow: 0 0 0 .5px var(--ink); }
.tpl-name { font-family: var(--display); font-size: 13px; font-weight: 700; }
.tpl-sub { font-size: 11px; color: var(--muted); }
.tpl[data-id="empty"] { background: #fff; border: 1px dashed var(--line-2); }
.qty-row { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.add-row { grid-template-columns: 1fr 1fr; }
.handful { margin-top: 10px; }
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding-right: 8px; }
.toast-act { border: 0; border-radius: 999px; padding: 5px 12px; background: rgba(255,255,255,.18); color: #fff; font-weight: 800; font-size: 12.5px; cursor: pointer; }
.toast-act:hover { background: rgba(255,255,255,.3); }

/* -------------------------------------------------------- frameless canvas & recording */
.scope.is-bare .frame, .scope.is-bare .frame-shadow { display: none; }
.scope.is-bare .viewport { inset: 0; border-radius: 0; background: transparent; }
.scope.is-bare .loading { border-radius: 0; }
.frame-btn { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px; border: 0; border-radius: 999px; background: transparent; cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.frame-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.frame-btn:hover { background: var(--fill); }
.frame-btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.frame-btn[aria-pressed="true"] .slash { display: none; }
.recbar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 999px;
  background: #d93a3a; color: #fff; font-size: 13px; font-weight: 700; box-shadow: 0 12px 30px -10px rgba(160,20,20,.55);
}
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
.rec-time { font-variant-numeric: tabular-nums; opacity: .9; }
.recbar:not([hidden]) ~ .selbar { top: 62px; }

/* -------------------------------------------------------- kaleidoscope / canvas switch */
.viewbar { position: absolute; top: 14px; right: 16px; z-index: 6; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px;
  box-shadow: 0 1px 2px rgba(20,20,30,.04), 0 10px 30px -14px rgba(20,20,30,.25); }
.viewbar .viewsw { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 12px; }
.viewbar .viewsw svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.viewbar .viewsw[aria-checked="true"] { background: var(--ink); color: #fff; box-shadow: none; }
.scope.is-bare::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: 0 0 0 1px var(--line-2); }
@media (max-width: 600px) {
  /* on a phone the switch is one round button that shows the other view, so it never meets the toolbar */
  .viewbar { top: 10px; right: 10px; }
  .viewbar .viewsw { padding: 7px; font-size: 0; gap: 0; }
  .viewbar .viewsw[aria-checked="true"] { display: none; }
  .viewbar .viewsw svg { width: 17px; height: 17px; }
}

/* -------------------------------------------------------- sound switch */
.btn-icon { width: 36px; padding: 0 !important; justify-content: center; }
.btn-icon svg { width: 18px; height: 18px; }
#soundBtn svg { fill: none; }
#soundBtn .mute { display: none; }
#soundBtn[aria-pressed="false"] .wave { display: none; }
#soundBtn[aria-pressed="false"] .mute { display: inline; }
#soundBtn[aria-pressed="false"] { color: var(--muted); }

/* -------------------------------------------------------- sound panel */
.sound-pop { width: 300px; }
.snd-styles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.snd-style {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 11px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font: inherit; transition: border-color .15s, box-shadow .15s;
}
.snd-style b { font-size: 12.5px; font-weight: 800; }
.snd-style span { font-size: 11px; color: var(--muted); line-height: 1.3; }
.snd-style:hover { border-color: var(--line-2); }
.snd-style[aria-checked="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.sound-pop .slider { grid-template-columns: 64px 1fr 40px; }
.sound-pop.is-off .snd-styles, .sound-pop.is-off .slider, .sound-pop.is-off .check { opacity: .45; }

/* -------------------------------------------------------- tapered tube side view */
.sideview { margin: 10px 0 0; padding: 12px 12px 10px; border-radius: 12px; background: var(--fill); }
.sideview svg { display: block; width: 100%; height: auto; }
.sideview figcaption { margin-top: 6px; font-size: 11.5px; line-height: 1.45; color: var(--muted); }
.sv-tube { fill: #fff; stroke: #5b6475; stroke-width: 2.4; stroke-linejoin: round; }
.sv-cell { fill: #eef3f8; stroke: #9aa3b2; stroke-width: 1.2; }
.sv-ray { fill: none; stroke-width: 1.4; stroke-linejoin: round; opacity: .9; }
.sv-eye { fill: #2f6fec; }
.sv-t { font-size: 9.5px; fill: var(--muted); text-anchor: middle; font-weight: 700; }

/* -------------------------------------------------------- stage hint: tiny, under the bar, never over the kaleidoscope */
.hint {
  position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%); z-index: 4; margin: 0;
  font-size: 10.5px; line-height: 1.4; letter-spacing: .01em; color: var(--muted); opacity: .55;
  white-space: nowrap; pointer-events: none; transition: opacity .6s;
}
.hint.done { opacity: 0; }
.stagebar { bottom: 18px; }
@media (max-width: 1000px) { .hint { bottom: 1px; } }
@media (max-width: 600px) { .hint { white-space: normal; width: calc(100% - 32px); text-align: center; } }

/* -------------------------------------------------------- sound, in the bar under the kaleidoscope */
.sound-wrap { position: static; display: inline-flex; }   /* the panel is placed against the whole bar */
.sound-wrap .sound-pop { top: auto; bottom: calc(100% + 12px); right: auto; left: 50%; transform: translateX(-50%); max-width: 100%; }
@media (max-width: 480px) { .sound-wrap .sound-pop { position: fixed; left: 12px; right: 12px; bottom: 76px; transform: none; width: auto; } }

/* -------------------------------------------------------- the special Glitter tunnel */
.system.is-special { position: relative; border: 1.5px solid transparent;
  background: linear-gradient(#fff, #fff) padding-box, linear-gradient(120deg, #e8508a, #8b5cf6 45%, #2bb5c8) border-box; }
.system .badge { position: absolute; top: 6px; right: 6px; font-size: 8.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 999px; background: #8b5cf6; color: #fff; }
.seg-wide3 { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }

/* -------------------------------------------------------- empty kaleidoscope */
.emptynote {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 6; max-width: min(440px, calc(100% - 200px));
  padding: 9px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  font-size: 12.5px; line-height: 1.45; color: var(--ink-2); text-align: center; box-shadow: 0 10px 30px -14px rgba(20,20,30,.25); pointer-events: none;
}
@media (max-width: 700px) { .emptynote { top: 56px; max-width: calc(100% - 32px); } }

/* ======================================================== two parts of the app */
.appswitch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--fill); }
.appsw { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 14px 0 11px; border: 0; border-radius: 999px; background: transparent;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.appsw svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.appsw:hover { color: var(--ink); }
.appsw[aria-checked="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.appsw .short { display: none; }
@media (max-width: 1180px) { .appsw .long { display: none; } .appsw .short { display: inline; } }
@media (max-width: 560px) { .brand-text { display: none; } .appsw { padding: 0 10px; } }

.image-only { display: none !important; }
body.app-image .image-only { display: flex !important; }
body.app-image #imageUI { display: block !important; }
body.app-image .scope, body.app-image .viewbar, body.app-image #emptyNote,
body.app-image #selbar, body.app-image .tabs, body.app-image .tabpanel, body.app-image .summary,
body.app-image #surprise, body.app-image .mode[data-v="place"], body.app-image #shake2 { display: none !important; }
body.app-image .sv-glass, body:not(.app-image) .sv-img { display: none; }

/* ---- the image stage */
.mstage { position: absolute; inset: 0; z-index: 1; flex-direction: column; align-items: center; justify-content: center; padding: 16px 104px 76px 24px; pointer-events: none; }
.mstage > * { pointer-events: auto; }
.mboard { position: relative; width: min(100%, calc(100vh - 190px), 900px); aspect-ratio: 1; min-width: 240px; border-radius: 0; overflow: hidden;
  background: #fff; box-shadow: 0 0 0 1px var(--line), 0 30px 60px -30px rgba(20,20,30,.35); }
#mcanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: default; }
#mcanvas.over { cursor: grab; } #mcanvas.grabbing { cursor: grabbing; }
.mempty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 30px; text-align: center; pointer-events: none; }
.mempty[hidden] { display: none; }
.mempty h3 { margin: 0; font-family: var(--display); font-size: 20px; }
.mempty p { margin: 0; max-width: 380px; font-size: 13.5px; line-height: 1.5; color: var(--muted); }
.mempty-row { display: flex; gap: 8px; margin-top: 6px; pointer-events: auto; }
.mdrop { position: absolute; inset: 10px; display: none; place-items: center; border: 2px dashed var(--accent); border-radius: 14px; background: rgba(47,107,242,.06);
  font-weight: 800; color: var(--accent); pointer-events: none; }
.mboard.dropping .mdrop { display: grid; }
.mbar { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(20,20,30,.04), 0 10px 30px -14px rgba(20,20,30,.25); }
.mbar .icon-btn[aria-pressed="false"] { color: var(--muted); }
.mbar .icon-btn:disabled { opacity: .35; cursor: default; }

/* ---- the image panel */
.image-ui { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 0 16px; scrollbar-width: thin; }
.image-ui .btn-block { margin-top: 2px; }
.samples { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.sample { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 6px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; cursor: pointer; font: inherit; font-size: 10.5px; font-weight: 700; color: var(--ink-2); }
.sample:hover { background: var(--fill); }
.sample img { width: 38px; height: 38px; object-fit: contain; }
.sample i { position: absolute; top: 3px; right: 3px; font-style: normal; font-size: 8px; font-weight: 800; padding: 1px 4px; border-radius: 99px; background: var(--ink); color: #fff; }
.library { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.lib { position: relative; }
.lib-add { width: 100%; aspect-ratio: 1; display: grid; place-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
  background: repeating-conic-gradient(#f1f1f3 0 25%, #fff 0 50%) 0 0 / 12px 12px; }
.lib-add:hover { border-color: var(--ink); }
.lib-add img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lib-x { position: absolute; top: -5px; right: -5px; width: 20px; height: 20px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: #fff; cursor: pointer; color: var(--muted); }
.lib-x svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.lib-x:hover { color: #d93a3a; border-color: #d93a3a; }
.syms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sym { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px 8px; border: 1px solid transparent; border-radius: 12px; background: var(--fill);
  cursor: pointer; font: inherit; color: var(--ink); text-align: center; }
.sym svg { width: 30px; height: 30px; fill: none; stroke: #5b6b80; stroke-width: 1.5; stroke-linejoin: round; margin-bottom: 3px; }
.sym .sname { font-size: 12px; font-weight: 700; } .sym .ssub { font-size: 10.5px; line-height: 1.3; color: var(--muted); }
.sym:hover { background: var(--fill-2); }
.sym[aria-checked="true"] { background: #eef3ff; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.sym[aria-checked="true"] .sname { color: var(--accent); }
.sym[aria-checked="true"] svg { stroke: var(--accent); }
.bgs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px 4px; }
.bgc { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; font-size: 11px; color: var(--ink-2); }
.bgc-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); display: grid; place-items: center; }
.bgc-dot.none { background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.bgc-dot.plus { background: #fff; color: var(--ink-2); } .bgc-dot.plus svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.bgc[aria-checked="true"] .bgc-dot { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.ly-tools { grid-template-columns: repeat(3, 1fr); }
#selGroup { background: #f7f9ff; }

/* ---- the cut-out editor */
.cutout { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(20,20,30,.38); backdrop-filter: blur(4px); }
.co-box { width: min(1180px, 100%); height: min(820px, 100%); display: flex; flex-direction: column; border-radius: 20px; background: var(--surface); overflow: hidden;
  box-shadow: 0 40px 80px -30px rgba(0,0,0,.5); }
.co-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.co-head h2 { margin: 0; font-family: var(--display); font-size: 17px; } .co-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.co-actions { display: flex; gap: 8px; }
.co-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 280px; }
.co-stage { position: relative; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 12px; background: #f4f4f6; }
.co-cv { border-radius: 6px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); touch-action: none; cursor: crosshair; }
.co-cv[data-tool="wand"] { cursor: pointer; }
.co-tip { margin: 0; font-size: 12.5px; color: var(--ink-2); text-align: center; }
.co-tools { padding: 16px; border-left: 1px solid var(--line); overflow-y: auto; }
.co-big { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 0; border-radius: 14px; background: var(--ink); color: #fff; cursor: pointer; text-align: left; font: inherit; }
.co-big svg { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.co-big b { display: block; font-size: 13.5px; } .co-big small { display: block; font-size: 11.5px; color: rgba(255,255,255,.7); }
.co-big:hover { background: #2b2b31; }
.co-big + .co-big { margin-top: 8px; }
.co-big.co-quiet { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.co-big.co-quiet small { color: var(--muted); }
.co-big.co-quiet:hover { background: var(--fill); }
.co-ai { background: linear-gradient(120deg, #6d28d9, #2f6bf2); }
.co-ai:hover { background: linear-gradient(120deg, #5b21b6, #2558d6); }
.co-big.busy { cursor: progress; opacity: .85; }
.co-big.busy svg { animation: spin 1.4s linear infinite; }
.co-label { margin: 18px 0 8px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.co-toolgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.co-tool { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font: inherit; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.co-tool svg, .co-row svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.co-tool[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--accent); background: #eef3ff; }
.co-tools .slider { grid-template-columns: 74px 1fr 50px; }
.co-tools .slider[hidden] { display: none; }
.co-check { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 12.5px; color: var(--ink-2); }
.co-check input { width: 16px; height: 16px; accent-color: var(--ink); }
.co-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 16px; }
.co-row .tbtn:disabled { opacity: .4; cursor: default; }
.co-toast { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); padding: 8px 14px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 700;
  opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; }
.co-toast.show { opacity: 1; }
@media (max-width: 760px) {
  .cutout { padding: 0; } .co-box { border-radius: 0; height: 100%; }
  .co-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .co-tools { border-left: 0; border-top: 1px solid var(--line); max-height: 42vh; }
  .co-head p { display: none; }
}
@media (max-width: 1000px) { .mboard { width: min(100%, calc(100vw - 32px), 640px); } .mstage { position: static; width: 100%; box-sizing: border-box; padding: 60px 16px 120px; } }
@media (max-width: 600px) { .mbar .wide { padding: 0 8px; } }
#mcanvas.twisting { cursor: grabbing; }
.linesets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.lineset { padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font: inherit; font-size: 12px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.lineset:hover { background: var(--fill); color: var(--ink); }
#freeRow .add-row { margin-top: 0; }

/* ---- how many mirror lines: numbers with a little picture */
.ncounts { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.ncount { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0 6px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; cursor: pointer; font: inherit; color: var(--ink-2); transition: border-color .15s, background .15s, color .15s; }
.ncount svg { width: 18px; height: 18px; fill: none; stroke-linecap: round; }
.ncount svg .ring { stroke: #e2e6ed; stroke-width: 1.2; }
.ncount svg .spokes { stroke: #a7b0be; stroke-width: .8; }
.ncount b { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.ncount:hover { border-color: var(--line-2); background: var(--fill); color: var(--ink); }
.ncount[aria-checked="true"], .ncount[aria-checked="true"]:hover { border-color: var(--accent); background: #eef3ff; color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.ncount[aria-checked="true"] svg .ring { stroke: #c7d6fb; }
.ncount[aria-checked="true"] svg .spokes { stroke: var(--accent); }
.centre-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; }
.centre-row .note { margin: 0; }
.recentre { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px 6px 9px; white-space: nowrap; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font: inherit; font-size: 12px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.recentre svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.recentre:hover { background: var(--fill); color: var(--ink); }
.recentre:disabled { opacity: .4; cursor: default; }
.desel { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px 5px 7px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
  font: inherit; font-size: 12px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.desel svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.desel:hover { background: var(--fill); color: var(--ink); }
.msel { z-index: 7; }
@media (max-width: 760px) { .msel { top: 56px; } }

/* ---- the glass selection pill lives in the bar, in place of Move/Place */
.stagebar .selbar { position: static; transform: none; padding: 5px 5px 5px 14px; }
body.glass-sel .modebar { display: none; }
body.app-image .selbar { display: none !important; }
body.app-image .modebar { display: none !important; }
.toolbar.two { grid-template-columns: repeat(2, 1fr); }

/* ---- "Any" colour: the tap lands on a real colour input (works on phones too) */
.bgc-any, .swatch.add { position: relative; overflow: hidden; }
.pick-input, .swatch.add input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer;
  clip: auto !important; clip-path: none !important; pointer-events: auto; }

/* ---- My cut-outs */
.lib-empty { margin: 0 0 4px; }
.lib-re { position: absolute; bottom: -5px; right: -5px; width: 20px; height: 20px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: #fff; cursor: pointer; color: var(--muted); }
.lib-re svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lib-re:hover { color: var(--accent); border-color: var(--accent); }
#samplesRow { margin-top: 6px; }

/* ---- cut-out editor: area tools, brush options */
.co-seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; margin-bottom: 8px; }
.co-seg button { padding: 6px 4px; font-size: 12px; white-space: nowrap; }
.co-area-mode.dim { opacity: .55; }
.co-grid4 { grid-template-columns: 1fr 1fr; }
.co-grid3 { grid-template-columns: repeat(3, 1fr); }
.co-grid3 .co-tool span { font-size: 11px; }
.co-brush[hidden] { display: none; }
.co-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.co-opts .co-seg { margin: 0; }
.co-cv[data-tool="poly"], .co-cv[data-tool="rect"], .co-cv[data-tool="ellipse"], .co-cv[data-tool="lasso"] { cursor: crosshair; }
.co-cv[data-tool="erase"], .co-cv[data-tool="restore"] { cursor: none; }

/* ---- the image toolbar: upright, beside the canvas */
.mbar { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); flex-direction: column; align-items: stretch; gap: 2px; padding: 6px 4px; border-radius: 16px; }
.vbtn { display: flex; flex-direction: column; align-items: center; gap: 3px; width: 64px; padding: 7px 2px 6px; border: 0; border-radius: 10px; background: transparent;
  font: inherit; font-size: 10.5px; font-weight: 700; color: var(--ink-2); cursor: pointer; line-height: 1.15; text-align: center; }
.vbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.vbtn:hover { background: var(--fill); color: var(--ink); }
.vbtn:disabled { opacity: .35; cursor: default; background: none; }
.vbtn[aria-pressed="true"] { color: var(--accent); background: #eef3ff; }
.vsep { height: 1px; margin: 4px 8px; background: var(--line); }
@media (max-width: 1000px) {
  .mstage { padding: 70px 16px 120px; }
  .mbar { top: 10px; right: 50%; transform: translateX(50%); flex-direction: row; padding: 3px; border-radius: 14px; }
  .vbtn { width: auto; min-width: 46px; padding: 5px 6px; }
  .vsep { width: 1px; height: auto; margin: 6px 2px; }
}
@media (max-width: 480px) { .vbtn span { display: none; } .vbtn { min-width: 34px; } }

/* ---- pictures: add, Folder, first-time tips */
.pic-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.pic-actions .btn { justify-content: center; }
.count-pill { min-width: 18px; padding: 1px 6px; border-radius: 999px; background: var(--fill-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.count-pill:empty { display: none; }
.onboarded .onboard-only { display: none; }
#trayRow { margin-top: 4px; }

/* ---- the Folder */
.folder { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 20px; background: rgba(20,20,30,.38); backdrop-filter: blur(4px); }
.folder-box { width: min(760px, 100%); max-height: min(720px, 100%); display: flex; flex-direction: column; border-radius: 20px; background: var(--surface); overflow: hidden; box-shadow: 0 40px 80px -30px rgba(0,0,0,.5); }
.folder-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.folder-head h2 { margin: 0; font-family: var(--display); font-size: 17px; } .folder-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.folder-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; padding: 16px 18px 20px; }
.folder-empty { margin: 0; padding: 30px 18px 40px; text-align: center; color: var(--muted); font-size: 13px; }
.fitem { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.fthumb { aspect-ratio: 1; display: grid; place-items: center; padding: 8px; border-radius: 10px; background: repeating-conic-gradient(#f1f1f3 0 25%, #fff 0 50%) 0 0 / 12px 12px; }
.fthumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.fname { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.factions { display: grid; grid-template-columns: 1fr auto auto; gap: 4px; }
.factions .btn { height: 30px; padding: 0 10px; font-size: 12px; justify-content: center; }
.ficon { height: 30px; min-width: 30px; display: grid; place-items: center; padding: 0 6px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink-2); cursor: pointer; font: inherit; font-size: 11px; font-weight: 800; }
.ficon svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ficon:hover { background: var(--fill); }
.fdel.sure { color: #fff; background: #d93a3a; border-color: #d93a3a; }
body.app-image .stagebar::before { content: ""; width: 150px; }   /* keeps the turning controls centred */
@media (max-width: 1000px) { body.app-image .stagebar::before { display: none; } }

/* ---- other number: a small stepper */
.nstep { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.nstep .label { flex: 1; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; background: #fff; overflow: hidden; }
.stepper button { width: 32px; height: 30px; border: 0; background: none; font: inherit; font-size: 16px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.stepper button:hover { background: var(--fill); color: var(--ink); }
.stepper button:disabled { opacity: .3; cursor: default; background: none; }
.stepper output { min-width: 30px; text-align: center; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---- symmetry and picture tools: even, calmer cards */
.syms { gap: 8px; }
.sym { min-height: 104px; justify-content: flex-start; padding: 12px 6px 10px; }
.sym .ssub { max-width: 120px; }
.ly-tools { gap: 8px; }
.ly-tools .tbtn { padding: 10px 0 9px; }
#symNRow .colour-head { margin-top: 18px; }

/* ======================================================== one selected style everywhere: soft blue */
.body[aria-checked="true"], .system[aria-checked="true"], .kind[aria-checked="true"], .tpl[aria-checked="true"], .snd-style[aria-checked="true"] {
  background: #eef3ff; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--accent); }
.body[aria-checked="true"] svg, .kind[aria-checked="true"] svg { stroke: var(--accent); fill: #dfe8fd; }
.system[aria-checked="true"] .sname, .tpl[aria-checked="true"] .tpl-name, .snd-style[aria-checked="true"] b { color: var(--accent); }
.shape[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: #eef3ff; }
.theme[aria-checked="true"], .bl[aria-checked="true"], .lt[aria-checked="true"] { background: #eef3ff; color: var(--accent); }
.theme[aria-checked="true"] .tname { color: var(--accent); }
.theme[aria-checked="true"] .lens-chip, .lt[aria-checked="true"] .lt-dot { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--accent); }
.bl[aria-checked="true"] .bl-dot { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--accent), 0 0 14px var(--c); }
.swatch[aria-checked="true"] { box-shadow: inset 0 0 0 1px rgba(0,0,0,.12), 0 0 0 2px #fff, 0 0 0 3.5px var(--accent); }
.bgc[aria-checked="true"] .bgc-dot { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
.bgc[aria-checked="true"] { color: var(--accent); }
.angle[aria-checked="true"], .angle[aria-checked="true"]:hover { background: #eef3ff; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.angle[aria-checked="true"] span { color: var(--accent); opacity: .75; }
.bl-any { position: relative; overflow: hidden; }
.bl-dot.plus { display: grid; place-items: center; background: #fff; box-shadow: inset 0 0 0 1px var(--line-2); }
.bl-dot.plus svg { width: 12px; height: 12px; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; }

/* ---- glass: the upright pieces toolbar beside the kaleidoscope */
.gbar { z-index: 6; }
body.app-image .gbar, body.fill-glitter .gbar { display: none; }
.vstep { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0 2px; }
.vlab { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.vval { font-size: 13px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; min-height: 18px; }
.vmini { width: 44px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); cursor: pointer; }
.vmini svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.vmini:hover { background: var(--fill); color: var(--ink); }
.vmini:disabled { opacity: .3; cursor: default; background: none; }
@media (max-width: 1000px) { .vstep { flex-direction: row; gap: 4px; padding: 0 4px; } .vlab { display: none; } .vmini { width: 30px; } }
@media (max-width: 1000px) { .gbar { right: auto; left: 10px; transform: none; } }
.lights + .slider { margin-top: 14px; }
.mempty p b { color: var(--ink-2); font-weight: 600; }
