:root {
  --bg: #ebe8f4;
  --panel: #ffffff;
  --ink: #2a2440;
  --muted: #8a83a3;
  --line: #e4e0f0;
  --press: #d9d4ea;
  --accent: #7b5cff;
  --accent-d: #5a3ee0;
  --green: #22c070;
  --green-d: #179456;
  --orange: #ff9f1c;
  --orange-d: #d97f00;
  --red: #ff4d5e;
  --red-d: #cf2f40;
  --shadow: 0 12px 32px rgba(42, 36, 64, 0.16), 0 2px 6px rgba(42, 36, 64, 0.06);
  --checker: repeating-conic-gradient(#e6e3ef 0 25%, #fff 0 50%) 0 0 / 14px 14px;
  --font: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px);
  --sr: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 800;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
.hidden { display: none !important; }
.ic { width: 26px; height: 26px; flex: none; }

/* ---------------------------------------------------------------- stage */
#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; }
#stage[data-tool='pen'], #stage[data-tool='eraser'], #stage[data-tool='stamp'] { cursor: none; }
#stage[data-tool='fill'] { cursor: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2232%22%20height%3D%2232%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cg%20stroke%3D%22%23fff%22%20stroke-width%3D%224.2%22%3E%3Cpath%20d%3D%22M17%2011L10%204%203.3%2010.7a1.8%201.8%200%20000%202.6l4.4%204.4a1.8%201.8%200%20002.6%200z%22/%3E%3Cpath%20d%3D%22M3.4%2012.2h13.2%22/%3E%3Cpath%20d%3D%22M8%202.2l2.4%202.4%22/%3E%3Cpath%20d%3D%22M17%2011c1.7.5%202.6%201.8%202.6%203.6%22/%3E%3Cpath%20d%3D%22M19.6%2015.4c-1.2%201.5-1.8%202.6-1.8%203.4a1.8%201.8%200%20003.6%200c0-.8-.6-1.9-1.8-3.4z%22%20fill%3D%22%23fff%22/%3E%3C/g%3E%3Cg%20stroke%3D%22%232a2440%22%20stroke-width%3D%222%22%3E%3Cpath%20d%3D%22M17%2011L10%204%203.3%2010.7a1.8%201.8%200%20000%202.6l4.4%204.4a1.8%201.8%200%20002.6%200z%22/%3E%3Cpath%20d%3D%22M3.4%2012.2h13.2%22/%3E%3Cpath%20d%3D%22M8%202.2l2.4%202.4%22/%3E%3Cpath%20d%3D%22M17%2011c1.7.5%202.6%201.8%202.6%203.6%22/%3E%3Cpath%20d%3D%22M19.6%2015.4c-1.2%201.5-1.8%202.6-1.8%203.4a1.8%201.8%200%20003.6%200c0-.8-.6-1.9-1.8-3.4z%22%20fill%3D%22%232a2440%22/%3E%3C/g%3E%3C/svg%3E") 26 27, cell; }
#stage[data-tool='lasso'] { cursor: crosshair; }
#stage[data-tool='cursor'] { cursor: default; }
#stage.picking { cursor: copy; }
#stage.grab { cursor: grab; }
#stage.panning { cursor: grabbing; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 22px;
  border-radius: 18px;
  background: var(--panel);
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--press), 0 8px 20px rgba(42, 36, 64, 0.1);
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.15s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--press), 0 3px 8px rgba(42, 36, 64, 0.1); }
.btn:disabled { opacity: 0.45; }
.btn.icon-btn { width: 56px; padding: 0; }
.btn.small { min-height: 44px; width: 44px; border-radius: 14px; }
.btn.small .ic { width: 22px; height: 22px; }
.btn.big { min-height: 64px; font-size: 20px; border-radius: 22px; width: 100%; }
.btn.big .ic { width: 28px; height: 28px; }
.btn-green { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-d), 0 8px 20px rgba(34, 192, 112, 0.3); }
.btn-green:active:not(:disabled) { box-shadow: 0 1px 0 var(--green-d); }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-d), 0 8px 20px rgba(123, 92, 255, 0.3); }
.btn-accent:active:not(:disabled) { box-shadow: 0 1px 0 var(--accent-d); }
.btn-orange { background: var(--orange); color: #fff; box-shadow: 0 4px 0 var(--orange-d), 0 8px 20px rgba(255, 159, 28, 0.3); }
.btn-orange:active:not(:disabled) { box-shadow: 0 1px 0 var(--orange-d); }
.btn-red { background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-d); }
.btn.ghost { background: rgba(255, 255, 255, 0.5); box-shadow: none; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 18px 0 14px;
  border-radius: 24px;
  background: #f1eff8;
  color: var(--muted);
  font-size: 16px;
  transition: background 0.15s, color 0.15s, transform 0.08s;
}
.pill:active { transform: scale(0.96); }
.pill.on { background: var(--accent); color: #fff; }

.seg {
  display: inline-flex;
  background: #f1eff8;
  border-radius: 18px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  min-width: 48px;
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.seg button .ic { width: 20px; height: 20px; }
.seg button.on { background: #fff; color: var(--accent); box-shadow: 0 2px 0 var(--press), 0 3px 10px rgba(42, 36, 64, 0.1); }
.seg-wide { display: flex; width: 100%; }
.seg-wide button { flex: 1; padding: 0 6px; }

.switch {
  width: 64px;
  height: 38px;
  border-radius: 19px;
  background: #dcd8ea;
  position: relative;
  flex: none;
  transition: background 0.2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(42, 36, 64, 0.25);
  transition: transform 0.2s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(26px); }

/* ---------------------------------------------------------------- sliders */
.hslider, .vslider { position: relative; touch-action: none; cursor: pointer; }
.hslider { height: 46px; }
.hslider .sl-track {
  position: absolute;
  inset: 7px 0;
  border-radius: 16px;
  background: #ece9f5;
  box-shadow: inset 0 0 0 1px rgba(42, 36, 64, 0.08);
}
.sl-thumb {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 0 var(--press), 0 4px 12px rgba(42, 36, 64, 0.22);
  display: grid;
  place-items: center;
  transition: transform 0.12s;
  pointer-events: none;
}
.hslider .sl-thumb { top: 0; left: calc(var(--f, 0) * (100% - 46px)); }
.sl-thumb span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08);
}
.hslider.active .sl-thumb, .vslider.active .sl-thumb { transform: scale(1.12); }
.set-slider .sl-track { background: linear-gradient(90deg, #ece9f5, #cfc4ff); }

/* ---------------------------------------------------------------- rail */
.rail {
  position: fixed;
  left: calc(14px + var(--sl));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 10;
}
.size-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s, transform 0.25s;
}
.rail.nosize .size-wrap { opacity: 0; transform: scale(0.85); pointer-events: none; height: 0; margin-bottom: -12px; overflow: hidden; }
.size-slider {
  width: 58px;
  height: min(240px, 32vh);
  border-radius: 29px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}
.size-slider .sl-track {
  position: absolute;
  left: 50%;
  top: 14px;
  bottom: 14px;
  width: 26px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #d8cffd, #f1eff8);
  clip-path: polygon(0 0, 100% 0, 62% 100%, 38% 100%);
  border-radius: 6px;
}
.vslider .sl-thumb { left: 6px; top: calc((1 - var(--f, 0)) * (100% - 46px)); width: 46px; height: 46px; }
.size-slider .sl-thumb span { width: calc(10px + var(--f, 0) * 22px); height: calc(10px + var(--f, 0) * 22px); background: var(--ink); }
.size-slider .sl-thumb span.eraser-dot { background: #fff; box-shadow: inset 0 0 0 2.5px var(--ink); }
.size-label {
  min-width: 44px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  text-align: center;
  color: var(--muted);
}
.rail .btn.icon-btn { width: 58px; min-height: 58px; border-radius: 20px; }

/* ---------------------------------------------------------------- dock */
.dock {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--sb));
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 28px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.tool-btn {
  width: 68px;
  height: 66px;
  border-radius: 21px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, transform 0.15s cubic-bezier(0.3, 1.5, 0.5, 1), box-shadow 0.15s;
}
.tool-btn .ic { width: 30px; height: 30px; }
.tool-btn:active { transform: scale(0.94); }
.tool-btn.on { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-d); transform: translateY(-3px); }

/* ---------------------------------------------------------------- tool options */
.toolopts {
  position: fixed;
  left: 50%;
  bottom: calc(104px + var(--sb));
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  transition: opacity 0.18s, transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.toolopts.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.opts {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 7px;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 26px;
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.opts.show { display: flex; }
.opt-label { padding-left: 12px; color: var(--muted); font-size: 15px; }
.opts .xf-apply { background: var(--green); }
@media (max-width: 480px) { .opts[data-for='transform'] .pill span { display: none; } .opts[data-for='transform'] .pill { padding: 0 14px; } }

/* ---------------------------------------------------------------- pen & stamp options */
.seg button .ic + span { margin-left: 6px; }
.opts.classic .ink-only { display: none; }
.pill.icon-pill { padding: 0 13px; }
.pill.icon-pill .ic { width: 22px; height: 22px; }
.stamp-pick { padding: 0 16px 0 10px; color: var(--ink); }
.stamp-pick .stamp-ic { display: grid; place-items: center; width: 28px; height: 28px; color: var(--accent); }
.stamp-pick .stamp-ic .ic { width: 25px; height: 25px; }
.stamp-pick.on .stamp-ic { color: #fff; }

.pop-card {
  position: fixed;
  left: 50%;
  bottom: calc(176px + var(--sb));
  z-index: 12;
  transform: translate(-50%, 10px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 26px;
  box-shadow: var(--shadow);
  transition: opacity 0.16s, transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.pop-card.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.pen-tune { width: min(360px, calc(100vw - 24px)); padding: 12px 16px 14px; }
.tune-preview { display: block; width: 100%; height: 86px; border-radius: 16px; background: #faf9fd; box-shadow: inset 0 0 0 2px #f1eff8; margin-bottom: 6px; }
.tune-row { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.tune-row > span { width: 86px; flex: none; color: #4d466a; }
.tune-row .set-slider { flex: 1; }
.pen-tune:not(.is-chisel) .chisel-only { display: none; }
.tune-note { margin: 6px 2px 0; font-size: 12.5px; font-weight: 700; color: var(--muted); line-height: 1.35; }
.stamp-grid { display: grid; grid-template-columns: repeat(6, 52px); gap: 6px; padding: 10px; }
.stamp-grid button { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; color: var(--ink); background: #f6f4fb; transition: transform 0.1s, background 0.15s, color 0.15s; }
.stamp-grid button .ic { width: 30px; height: 30px; }
.stamp-grid button.on { background: var(--accent); color: #fff; }
.stamp-grid button:active { transform: scale(0.92); }
body.ws-anim .pop-card { bottom: calc(256px + var(--sb)); }

/* hidden tools (four-finger tap / Tab) */
.ui-back { position: fixed; top: calc(14px + var(--st)); right: calc(14px + var(--sr)); z-index: 11; display: none; opacity: 0.8; }
body.ui-hidden.drawing .ui-back { display: inline-flex; }
body.ui-hidden .rail, body.ui-hidden .dock, body.ui-hidden .toolopts, body.ui-hidden .topbar, body.ui-hidden .palette,
body.ui-hidden .anim-bar, body.ui-hidden .pop-card { opacity: 0 !important; pointer-events: none !important; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: fixed;
  top: calc(14px + var(--st));
  right: calc(14px + var(--sr));
  display: flex;
  gap: 10px;
  align-items: center;
  z-index: 10;
}
.done-btn { padding: 0 20px 0 16px; }
.chip {
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  font-size: 14px;
  color: var(--muted);
}

.game-chip {
  position: fixed;
  top: calc(14px + var(--st));
  left: 0;
  right: 0;
  margin: 0 auto;
  width: max-content;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(560px, calc(100vw - 340px));
  padding: 8px 8px 8px 18px;
  border-radius: 26px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 9;
}
.game-chip.pop { animation: pop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
.gc-label { color: var(--muted); font-size: 14px; flex: 0 1 auto; }
.gc-prompt { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 3em; }
.gc-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }
.gc-time {
  flex: none;
  min-width: 64px;
  height: 40px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--chip, var(--orange));
  color: #fff;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.game-chip.urgent .gc-time { background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.1); } }

/* ---------------------------------------------------------------- palette */
.palette {
  position: fixed;
  left: calc(14px + var(--sl));
  top: calc(14px + var(--st));
  z-index: 20;
  --wheel: 292px;
  transition: opacity 0.18s, transform 0.2s;
}
.palette.hidden { opacity: 0; transform: translate(-8px, -8px) scale(0.9); pointer-events: none; }
.pal-handle {
  position: relative;
  z-index: 2;
  width: 76px;
  height: 76px;
  display: block;
  filter: drop-shadow(0 4px 0 var(--press)) drop-shadow(0 8px 14px rgba(42, 36, 64, 0.2));
  transition: transform 0.15s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.pal-handle:active { transform: scale(0.93); }
@media (hover: hover) and (pointer: fine) { .pal-handle:hover { transform: rotate(-8deg) scale(1.05); } }
.pal-handle svg { width: 100%; height: 100%; overflow: visible; }
.pal-wood { fill: #fff; }
.pal-cur-ring { fill: #fff; stroke: rgba(42, 36, 64, 0.12); stroke-width: 1; }
.palette.open .pal-handle { filter: none; }
.palette.open .pal-wood { fill: #f4f2fa; }

.pal-panel {
  position: absolute;
  left: -8px;
  top: -8px;
  padding: 90px 22px 22px;
  background: #fff;
  border-radius: 34px;
  box-shadow: 0 24px 60px rgba(42, 36, 64, 0.22), 0 2px 8px rgba(42, 36, 64, 0.08);
  transform-origin: 34px 34px;
  transform: scale(0.25);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.25, 1.35, 0.45, 1), opacity 0.16s;
}
.palette.open .pal-panel { transform: none; opacity: 1; pointer-events: auto; }
.pal-main { display: flex; flex-direction: column; gap: 16px; }

/* the turnstile */
.wheel { position: relative; width: var(--wheel); height: var(--wheel); --R: calc(var(--wheel) * 0.36); --s: 64px; touch-action: none; }
.wheel-rotor { position: absolute; inset: 0; transform: rotate(var(--rot, 0deg)); }
.wheel-rotor.spin { transition: transform 0.55s cubic-bezier(0.3, 1.35, 0.45, 1); }
.wheel-ring {
  position: absolute;
  inset: calc(50% - var(--R) - 24px);
  border-radius: 50%;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 48px), #000 calc(100% - 47px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 48px), #000 calc(100% - 47px));
  opacity: 0.32;
  transition: opacity 0.2s;
}
.wheel-ticks {
  position: absolute;
  inset: calc(50% - var(--R) - 33px);
  border-radius: 50%;
  background: repeating-conic-gradient(from -1.5deg, rgba(42, 36, 64, 0.22) 0 3deg, transparent 3deg 15deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
}
.palette.sliding .wheel-ring { opacity: 1; }
.splotch {
  position: absolute;
  width: var(--s);
  height: var(--s);
  left: calc(50% + var(--x) * var(--R) - var(--s) / 2);
  top: calc(50% + var(--y) * var(--R) - var(--s) / 2);
  filter: drop-shadow(0 3px 0 rgba(42, 36, 64, 0.16));
  transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1), opacity 0.2s;
}
.splotch svg { width: 100%; height: 100%; overflow: visible; transform: rotate(calc(-1 * var(--rot, 0deg))); }
.splotch.pressed { transform: scale(1.15); }
.splotch.on { transform: scale(1.16); }
@media (hover: hover) and (pointer: fine) { .splotch:hover { transform: scale(1.1); } }
.palette.sliding .splotch { transform: scale(0.72); opacity: 0.6; }
.wheel-pointer {
  position: absolute;
  left: 50%;
  top: calc(50% - var(--R) - 46px);
  width: 30px;
  height: 22px;
  margin-left: -15px;
  background: var(--cur);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 0 0 #fff);
  pointer-events: none;
  z-index: 3;
}
.wheel-pointer::after { content: ''; position: absolute; inset: 0; }
.wheel::before {
  content: '';
  position: absolute;
  left: 50%;
  top: calc(50% - var(--R) - 50px);
  width: 40px;
  height: 30px;
  margin-left: -20px;
  background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 4px;
  z-index: 2;
  pointer-events: none;
}
.wheel-arrows { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); fill: none; stroke: rgba(42, 36, 64, 0.22); stroke-width: 1.6; stroke-linecap: round; pointer-events: none; transition: stroke 0.2s, opacity 0.2s; }
.wheel-arrows .ah { fill: rgba(42, 36, 64, 0.22); stroke: none; transition: fill 0.2s; }
.palette.sliding .wheel-arrows { stroke: var(--accent); }
.palette.sliding .wheel-arrows .ah { fill: var(--accent); }
@media (hover: hover) and (pointer: fine) { .wheel:hover .wheel-arrows { stroke: rgba(123, 92, 255, 0.55); } .wheel:hover .wheel-arrows .ah { fill: rgba(123, 92, 255, 0.55); } }
.wheel-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 92px;
  height: 92px;
  margin: -46px 0 0 -46px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 6px #fff, 0 0 0 8px var(--line), 0 6px 16px rgba(42, 36, 64, 0.18);
  z-index: 2;
}
.wheel-center span { position: absolute; inset: 0; }
.checker { background: var(--checker); }

.pal-side { display: flex; flex-direction: column; gap: 6px; width: var(--wheel); }
.pal-row { display: flex; align-items: center; gap: 8px; }
.pal-row > div { flex: 1; }
.pal-ic { width: 30px; display: grid; place-items: center; color: var(--muted); flex: none; }
.pal-alpha .sl-track { background-color: #fff; }
.pal-bottom { display: flex; gap: 10px; align-items: stretch; padding-top: 8px; }
.pal-swatches { flex: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swatch {
  aspect-ratio: 1;
  border-radius: 14px;
  background: var(--c);
  box-shadow: inset 0 0 0 2px rgba(42, 36, 64, 0.12), 0 3px 0 var(--press);
  transition: transform 0.12s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.12s;
}
.swatch.static { border-radius: 50%; }
.swatch.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px var(--accent); }
@media (hover: hover) and (pointer: fine) { .swatch:hover { transform: translateY(-2px) scale(1.06); } }
.swatch:active { transform: scale(0.9); }
.pal-dropper {
  width: 56px;
  border-radius: 18px;
  background: #f1eff8;
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 var(--press);
  transition: transform 0.12s, background 0.15s;
}
.pal-dropper .ic { width: 26px; height: 26px; }
@media (hover: hover) and (pointer: fine) { .pal-dropper:hover { background: #e6e1f7; transform: rotate(-10deg); } }
.pal-dropper:active { transform: scale(0.92); }

@media (max-height: 640px) and (min-width: 560px) {
  .palette { --wheel: 240px; }
  .pal-panel { padding: 18px 18px 18px 94px; }
  .pal-main { flex-direction: row; align-items: center; }
  .pal-side { width: 240px; }
}
@media (max-width: 480px) { .palette { --wheel: 258px; } .pal-panel { padding: 88px 16px 16px; } }

/* ---------------------------------------------------------------- popups */
.toast {
  position: fixed;
  left: 50%;
  top: calc(80px + var(--st));
  transform: translate(-50%, -12px);
  padding: 12px 20px;
  border-radius: 18px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  z-index: 90;
  max-width: min(560px, calc(100vw - 40px));
  width: max-content;
  text-align: center;
  text-wrap: balance;
  line-height: 1.35;
  transition: opacity 0.18s, transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.flash {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 12px 24px;
  border-radius: 20px;
  background: rgba(42, 36, 64, 0.82);
  color: #fff;
  font-size: 20px;
  pointer-events: none;
  opacity: 0;
  z-index: 85;
}
.flash.show { animation: flash 0.75s ease-out; }
@keyframes flash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

.menu-backdrop { position: fixed; inset: 0; z-index: 50; }
.popmenu {
  position: fixed;
  z-index: 51;
  min-width: 210px;
  padding: 8px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(42, 36, 64, 0.28), 0 2px 6px rgba(42, 36, 64, 0.08);
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* a long menu on a short screen scrolls instead of running off the edge */
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  scrollbar-width: none;
  transform: scale(0.6);
  opacity: 0;
  transition: transform 0.2s cubic-bezier(0.3, 1.5, 0.5, 1), opacity 0.12s;
}
.popmenu::-webkit-scrollbar { display: none; }
.popmenu.show { transform: none; opacity: 1; }
.popmenu .pm-item { flex: none; }
.pm-item {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 18px 0 14px;
  border-radius: 16px;
  font-size: 18px;
  text-align: left;
}
.pm-item:hover:not(:disabled) { background: #f4f2fa; }
.pm-item:active:not(:disabled) { background: #ebe7f8; transform: scale(0.98); }
.pm-item:disabled { opacity: 0.32; }
.pm-item.danger { color: var(--red-d); }
.pm-item.cancel { color: var(--muted); border-top: 2px solid #f1eff8; border-radius: 0 0 16px 16px; }
@media (max-height: 520px) { .pm-item { height: 46px; font-size: 16px; } }

/* ---------------------------------------------------------------- sheets */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(42, 36, 64, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
}
.sheet.show { opacity: 1; pointer-events: auto; }
.sheet-card {
  width: min(460px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  touch-action: pan-y;
  padding: 20px;
  border-radius: 30px;
  background: #fff;
  box-shadow: var(--shadow);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.sheet.show .sheet-card { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { margin: 0; font-size: 24px; font-weight: 900; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.btn.tile { flex-direction: column; gap: 6px; min-height: 92px; font-size: 15px; padding: 10px; }
.btn.tile .ic { width: 30px; height: 30px; color: var(--accent); }
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 2px;
  border-top: 2px solid #f4f2fa;
  font-size: 16px;
}
.set-row > span { flex: 1; }
.set-row .set-slider { flex: 1.2; }
.set-head { margin: 16px 2px 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 900; }
.set-row .seg button { min-width: 0; padding: 0 12px; }
.set-select { font: inherit; font-size: 15px; color: var(--ink); background: #f1eff8; border: 0; border-radius: 14px; height: 42px; padding: 0 12px; max-width: 55%; }
.set-note { margin: 2px 2px 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); line-height: 1.4; }
body.native-shell .web-only, body:not(.native-shell) .shell-only { display: none; }
.confirm-card { width: min(380px, 100%); text-align: center; }
.confirm-card h3 { margin: 4px 0 8px; font-size: 24px; font-weight: 900; }
.confirm-card p { margin: 0 0 20px; color: var(--muted); font-weight: 700; line-height: 1.4; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tips { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; font-weight: 700; line-height: 1.4; color: #4d466a; }
.tips b { color: var(--ink); font-weight: 900; }

/* ---------------------------------------------------------------- screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(12px + var(--st)) calc(16px + var(--sr)) calc(16px + var(--sb)) calc(16px + var(--sl));
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 159, 28, 0.28), transparent 38%),
    radial-gradient(circle at 88% 12%, rgba(43, 192, 107, 0.24), transparent 38%),
    radial-gradient(circle at 82% 88%, rgba(47, 125, 255, 0.24), transparent 42%),
    radial-gradient(circle at 12% 88%, rgba(255, 59, 79, 0.2), transparent 40%),
    #ece8f6;
  opacity: 0;
  pointer-events: none;
  transform: translateX(48px);
  transition: opacity 0.28s ease, transform 0.42s cubic-bezier(0.2, 0.9, 0.25, 1);
}
.screen[data-dir='back'] { transform: translateX(-48px); }
.screen[data-dir='fade'] { transform: scale(0.98); }
.screen.show { opacity: 1; pointer-events: auto; transform: none; }
.screen.leaving { opacity: 0; pointer-events: none; transform: translateX(-48px); }
.screen.leaving[data-dir='back'] { transform: translateX(48px); }
.screen.leaving[data-dir='fade'] { transform: scale(1.02); }
#screens .screen.leaving { z-index: 69; }
.home-card, .finish-card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  transform: translateY(16px);
  transition: transform 0.3s cubic-bezier(0.3, 1.3, 0.5, 1);
}
.screen.show .home-card, .screen.show .finish-card { transform: none; }
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; }
.logo-mark { width: 74px; height: 74px; filter: drop-shadow(0 4px 0 var(--press)) drop-shadow(0 8px 16px rgba(42, 36, 64, 0.18)); }
.logo h1 { margin: 0; font-size: clamp(40px, 11vw, 56px); font-weight: 900; letter-spacing: -1.5px; }
.logo h1 span { color: var(--accent); }
.tagline { margin: -8px 0 6px; text-align: center; color: var(--muted); font-size: 18px; }
.home-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.6);
}
.hint { margin: -2px 0 2px; text-align: center; color: var(--muted); font-size: 14px; }

.finish-card h2 { margin: 0; text-align: center; font-size: 36px; font-weight: 900; }
.finish-prompt { margin: -8px 0 0; text-align: center; color: var(--muted); font-size: 18px; min-height: 0; }
.finish-prompt:empty { display: none; }
.preview {
  border-radius: 26px;
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(42, 36, 64, 0.06);
  height: min(42vh, 360px);
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}
.preview img { max-width: 100%; max-height: calc(min(42vh, 360px) - 32px); object-fit: contain; display: block; }
.preview p { color: var(--muted); font-size: 18px; }
.export-opts { display: flex; justify-content: center; align-items: center; gap: 10px; flex-wrap: wrap; }
.export-opts .pill { background: #fff; }
.export-opts .pill.on { background: var(--accent); }
.export-opts .seg { background: #fff; }
.export-opts .seg button.on { background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-d); }
.dims { margin: -4px 0 0; text-align: center; color: var(--muted); font-size: 13px; }
.finish-actions { display: flex; gap: 12px; }
.finish-actions .btn { flex: 1; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 480px) {
  .dock { gap: 2px; padding: 6px; border-radius: 24px; }
  .tool-btn { width: 49px; height: 58px; border-radius: 17px; font-size: 9.5px; }
  .tool-btn .ic { width: 26px; height: 26px; }
  .toolopts { bottom: calc(92px + var(--sb)); }
  .opts { gap: 6px; }
  .opts .seg button { min-width: 44px; padding: 0 10px; }
  .pop-card { bottom: calc(160px + var(--sb)); }
  body.ws-anim .pop-card { bottom: calc(300px + var(--sb)); }
  .stamp-grid { grid-template-columns: repeat(6, 46px); gap: 5px; padding: 8px; }
  .stamp-grid button { width: 46px; height: 46px; }
  .rail { left: calc(10px + var(--sl)); }
  .size-slider { width: 52px; height: min(200px, 28vh); }
  .vslider .sl-thumb { left: 3px; }
  .rail .btn.icon-btn { width: 52px; min-height: 52px; }
  .done-btn span { display: none; }
  .done-btn { padding: 0; width: 56px; }
  .game-chip { top: calc(84px + var(--st)); max-width: calc(100vw - 28px); }
}
@media (max-width: 380px) {
  .tool-btn { width: 46px; }
  .tool-btn span { display: none; }
}
@media (max-width: 360px) {
  .opts .seg button span, #trailBtn span { display: none; }
}
@media (max-height: 520px) {
  .size-slider { height: min(150px, 30vh); }
  /* keep the rail clear of the palette in the top-left corner */
  .rail { gap: 8px; top: max(50%, calc(228px + var(--st))); }
  .rail .btn.icon-btn { min-height: 48px; width: 52px; }
}
@media (max-height: 520px) and (min-width: 560px) {
  /* phones on their side: pen settings spread out sideways so they fit above the tool bar */
  body .pop-card.pen-tune {
    width: min(660px, calc(100vw - 40px));
    padding: 8px 14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 2px;
  }
  .pen-tune .tune-preview, .pen-tune .tune-note { display: none; }
  .pen-tune .tune-row { gap: 8px; }
  .pen-tune .tune-row > span { width: 72px; font-size: 13.5px; }
}

/* ================================================================ app states */
body:not(.drawing) #stage, body:not(.drawing) .rail, body:not(.drawing) .dock, body:not(.drawing) .toolopts,
body:not(.drawing) .topbar, body:not(.drawing) .palette, body:not(.drawing) .game-chip { visibility: hidden; }
body.kind-solo .party-only, body.kind-party .solo-only, body.kind-skin .solo-only, body.kind-skin .party-only { display: none !important; }
body:not(.kind-skin) .skin-only { display: none !important; }
.rail.no-undo #undoBtn, .rail.no-undo #redoBtn { display: none; }
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 300; pointer-events: none; }

/* ================================================================ juicy buttons */
.fx { position: relative; overflow: hidden; isolation: isolate; -webkit-tap-highlight-color: transparent; }
.fx::after {
  /* a soft, blurred sheen that glides across, like light over glossy plastic */
  content: '';
  position: absolute;
  top: -40%;
  bottom: -40%;
  left: 0;
  width: 70%;
  background: linear-gradient(100deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.05) 22%,
    rgba(255, 255, 255, 0.22) 38%,
    rgba(255, 255, 255, 0.42) 50%,
    rgba(255, 255, 255, 0.22) 62%,
    rgba(255, 255, 255, 0.05) 78%,
    rgba(255, 255, 255, 0) 100%);
  filter: blur(10px);
  opacity: 0;
  transform: translateX(-130%) skewX(-12deg);
  pointer-events: none;
  z-index: 3;
}
.fx:not(.badge)::before {
  /* faint top-edge gloss that brightens on hover */
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 45%);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  z-index: 2;
}
.mega, .pick-card, .gal-card, .badge, .round-btn, .fx.btn {
  transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.2s, filter 0.2s;
}
@media (hover: hover) and (pointer: fine) {
  .fx:hover:not(:disabled):not(.locked) { transform: translateY(-4px) scale(1.015); filter: brightness(1.06) saturate(1.06); }
  .fx:hover:not(:disabled):not(.locked)::after { animation: glimmer 1.25s cubic-bezier(0.35, 0.1, 0.25, 1); }
  .fx:not(.badge):hover:not(:disabled):not(.locked)::before { opacity: 1; }
  .mega:hover .mega-art .art, .pick-card:hover .pick-art .art { animation: wiggle 0.6s ease-in-out; }
  .mega:hover .mega-go { transform: translateX(4px); background: rgba(255, 255, 255, 0.4); }
  .pick-card:hover:not(:disabled), .gal-card:hover { box-shadow: 0 0 0 4px rgba(123, 92, 255, 0.35), 0 6px 0 var(--press), 0 18px 34px rgba(123, 92, 255, 0.25); }
  .round-btn:hover { box-shadow: 0 0 0 4px rgba(123, 92, 255, 0.25), 0 4px 0 var(--press), 0 10px 22px rgba(42, 36, 64, 0.14); }
}
.fx:active:not(:disabled):not(.locked) {
  transform: translateY(5px) scale(0.975) !important;
  box-shadow: 0 1px 0 var(--shade, var(--press)), 0 4px 10px rgba(42, 36, 64, 0.12) !important;
  transition-duration: 0.06s;
}
.ripple {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.6) 0, rgba(255, 255, 255, 0) 62%);
  transform: scale(0);
  animation: ripple 0.6s ease-out forwards;
  pointer-events: none;
  z-index: 2;
}
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
@keyframes glimmer {
  0% { opacity: 0; transform: translateX(-130%) skewX(-12deg); }
  15% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(190%) skewX(-12deg); }
}
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-8deg) scale(1.07); } 55% { transform: rotate(6deg) scale(1.07); } 80% { transform: rotate(-2deg); } }
.shake { animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both !important; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-9px) rotate(-2deg); }
  40%, 60% { transform: translateX(9px) rotate(2deg); }
}
@keyframes breathe { 0%, 100% { box-shadow: 0 6px 0 var(--shade), 0 10px 26px var(--glow, rgba(34, 192, 112, 0.35)); } 50% { box-shadow: 0 6px 0 var(--shade), 0 10px 40px 6px var(--glow, rgba(34, 192, 112, 0.55)); } }
@media (prefers-reduced-motion: reduce) {
  .fx::after, .doodle, .logo-big .logo-mark { animation: none !important; }
  .screen { transition: opacity 0.2s; transform: none !important; }
}

/* ================================================================ menu layout */
.menu-top {
  width: 100%;
  max-width: 1100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  position: relative;
  z-index: 2;
}
.menu-title { margin: 0; font-size: 22px; font-weight: 900; text-align: center; flex: 1; }
.round-btn, .round-spacer { width: 52px; height: 52px; flex: none; }
.round-btn {
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  --shade: var(--press);
  box-shadow: 0 4px 0 var(--press), 0 8px 18px rgba(42, 36, 64, 0.12);
}
.round-btn .ic { width: 24px; height: 24px; }
.menu-body {
  flex: 1;
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 8px 0 20px;
  position: relative;
  z-index: 1;
}
.wide-body { width: min(920px, 100%); }
.menu-lead { margin: 0 0 4px; text-align: center; font-size: 18px; color: var(--muted); }
.big-title { margin: 0; text-align: center; font-family: 'Luckiest Guy', var(--font); font-weight: 400; letter-spacing: 1px; font-size: clamp(34px, 8vw, 48px); color: var(--ink); }

/* ---- title */
.title-body { align-items: stretch; }
.logo-big { flex-direction: column; gap: 4px; }
.logo-big .logo-mark { width: 96px; height: 96px; animation: bob 3.2s ease-in-out infinite; }
.logo-big h1 { font-size: clamp(50px, 14vw, 80px); line-height: 0.95; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }
.title-body .tagline { margin: 2px 0 14px; font-size: 20px; }
.doodles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.doodle { position: absolute; width: 90px; height: 90px; opacity: 0.55; animation: drift 9s ease-in-out infinite; }
.doodle.d0 { left: 4%; top: 14%; }
.doodle.d1 { right: 6%; top: 9%; animation-delay: -2s; width: 70px; }
.doodle.d2 { left: 8%; bottom: 12%; animation-delay: -4s; }
.doodle.d3 { right: 5%; bottom: 18%; animation-delay: -6s; width: 110px; }
.doodle.d4 { left: 44%; top: 4%; animation-delay: -3s; width: 70px; }
.doodle.d5 { right: 30%; bottom: 4%; animation-delay: -5s; width: 60px; }
@keyframes drift { 0%, 100% { transform: translate(0, 0) rotate(0); } 33% { transform: translate(12px, -14px) rotate(8deg); } 66% { transform: translate(-10px, 8px) rotate(-6deg); } }
@media (max-width: 600px) { .doodle { width: 60px; height: 60px; opacity: 0.4; } .doodle.d4, .doodle.d5 { display: none; } }

/* ---- home */
.studio-foot { margin: 14px 0 2px; text-align: center; color: var(--muted); font-size: 13.5px; }
.studio-foot a { color: var(--accent); font-weight: 900; text-decoration: none; }
.studio-foot a:hover { text-decoration: underline; }
@media (max-height: 800px) and (min-width: 700px) { .studio .logo-big .logo-mark { width: 60px; height: 60px; } .studio .logo-big h1 { font-size: 54px; } .studio .tagline { margin: 0 0 10px; } }

/* ---- mega buttons */
.mega-stack { display: flex; flex-direction: column; gap: 18px; }
.mega {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 116px;
  padding: 14px 18px 14px 14px;
  border-radius: 30px;
  color: #fff;
  text-align: left;
  --shade: #4b2bb8;
  background: linear-gradient(135deg, #9a63ff, #6a3df0);
  box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(106, 61, 240, 0.3);
}
.mega-art { width: 92px; height: 92px; border-radius: 24px; background: rgba(255, 255, 255, 0.92); display: grid; place-items: center; box-shadow: inset 0 -4px 0 rgba(42, 36, 64, 0.08); }
.mega-art .art { width: 80px; height: 80px; }
.mega-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mega-text b { font-family: 'Luckiest Guy', var(--font); font-weight: 400; font-size: 30px; letter-spacing: 0.8px; line-height: 1.05; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.18); }
.mega-text small { font-size: 15px; opacity: 0.92; font-weight: 800; text-wrap: balance; }
.mega-go { width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, 0.24); display: grid; place-items: center; transition: transform 0.2s, background 0.2s; }
.mega-party { --shade: #c4245e; background: linear-gradient(135deg, #ff8a3d, #ff3b8d); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(255, 59, 141, 0.3); }
.mega-draw { --shade: #14874c; background: linear-gradient(135deg, #3bd889, #18a85f); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(34, 192, 112, 0.3); }
.mega-gallery { --shade: #1d55c4; background: linear-gradient(135deg, #4f9bff, #2f6cf0); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(47, 108, 240, 0.3); }
.mega-irl { --shade: #c2580a; background: linear-gradient(135deg, #ffb13b, #ff7a1f); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(255, 122, 31, 0.3); }
.mega-online { --shade: #0b7f86; background: linear-gradient(135deg, #2fd1c5, #1497b8); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(20, 151, 184, 0.3); }
@media (max-width: 480px) {
  .mega { min-height: 100px; gap: 12px; border-radius: 26px; }
  .mega-art { width: 76px; height: 76px; border-radius: 20px; }
  .mega-art .art { width: 66px; height: 66px; }
  .mega-text b { font-size: 25px; }
  .mega-text small { font-size: 13.5px; }
  .mega-go { width: 38px; height: 38px; }
}

/* ---- pick cards */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.pick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 14px 16px;
  border-radius: 26px;
  background: #fff;
  --shade: var(--press);
  box-shadow: 0 6px 0 var(--press), 0 14px 26px rgba(42, 36, 64, 0.1);
  text-align: center;
}
.pick-card b { font-size: 21px; font-weight: 900; margin-top: 6px; }
.pick-card small { color: var(--muted); font-size: 14px; text-wrap: balance; }
.pick-art .art { width: 104px; height: 104px; }
.paper-swatch { width: 100%; aspect-ratio: 16 / 11; border-radius: 16px; overflow: hidden; box-shadow: inset 0 0 0 2px rgba(42, 36, 64, 0.08), 0 3px 8px rgba(42, 36, 64, 0.12); }
.paper-swatch canvas { width: 100%; height: 100%; display: block; }
@media (max-width: 480px) {
  .pick-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .pick-card { padding: 14px 10px 12px; border-radius: 22px; }
  .pick-art .art { width: 78px; height: 78px; }
  .pick-card b { font-size: 18px; }
  .pick-card small { font-size: 12.5px; }
}

/* ---- finish / export */
.finish-screen .menu-body { gap: 14px; }
.finish-screen .preview { background-color: #fff; }
/* Phones: everything on one screen, no scrolling to reach the buttons. */
@media (max-width: 480px) {
  .finish-screen .menu-body { gap: 11px; padding-bottom: 8px; }
  .finish-screen .preview { height: min(34vh, 300px); }
  .finish-screen .preview img { max-height: calc(min(34vh, 300px) - 32px); }
  .export-opts { gap: 8px; }
  .export-opts .pill { height: 42px; padding: 0 13px 0 10px; font-size: 14.5px; gap: 6px; }
  .export-opts .pill .ic { width: 22px; height: 22px; }
  .export-opts .seg button { height: 34px; min-width: 40px; padding: 0 10px; }
  .finish-screen .btn.big { min-height: 56px; font-size: 18px; }
  .finish-screen .row2 { gap: 10px; }
  .finish-screen .row2 .btn { padding: 0 10px; gap: 7px; font-size: 15.5px; min-height: 50px; white-space: nowrap; }
  .finish-screen .row2 .btn .ic { width: 22px; height: 22px; }
}
/* Phones on their side: the picture on the left, the choices beside it. */
@media (max-height: 520px) and (min-width: 560px) {
  .finish-screen .menu-body {
    width: min(940px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-auto-flow: row dense;
    column-gap: 22px;
    row-gap: 0;
    align-content: center;
    padding: 4px 0 8px;
  }
  .finish-screen .menu-body > * { grid-column: 2; margin-bottom: 8px; }
  .finish-screen .menu-body > p { font-size: 12.5px; line-height: 1.3; }
  .finish-screen .seg button { white-space: nowrap; padding: 0 10px; font-size: 14px; }
  .finish-screen .menu-body > .preview {
    grid-column: 1;
    grid-row: 1 / span 12;
    align-self: center;
    margin: 0;
    height: calc(100vh - 44px - var(--st) - var(--sb));
  }
  .finish-screen .preview img { max-height: calc(100vh - 76px - var(--st) - var(--sb)); }
  .finish-screen .big-title { font-size: 28px; }
  .finish-screen .btn.big { min-height: 48px; font-size: 17px; border-radius: 18px; }
  .finish-screen .btn { min-height: 46px; }
  .finish-screen .row2 .btn { white-space: nowrap; padding: 0 12px; }
  .export-opts { gap: 8px; }
  .export-opts .pill { height: 40px; padding: 0 11px 0 9px; font-size: 13.5px; gap: 6px; }
  .export-opts .pill .ic { width: 20px; height: 20px; }
  .export-opts .seg button { height: 32px; }
}
@media (max-height: 520px) and (min-width: 560px) and (max-width: 720px) {
  .finish-screen .menu-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 16px; }
  .finish-screen .menu-body > * { margin-bottom: 8px; }
  .finish-screen .big-title { font-size: 26px; }
  .finish-screen .row2 .btn { font-size: 15px; gap: 6px; padding: 0 8px; }
  .finish-screen .row2 .btn .ic { width: 22px; height: 22px; }
}
.btn.saved { background: var(--green-d); }
.btn-red-soft { background: #ffe9ec; color: var(--red-d); box-shadow: 0 4px 0 #f6c9cf; }
.btn-danger-soft { color: var(--red-d); }
.choice-col { display: flex; flex-direction: column; gap: 10px; }

/* ---- gallery */
.gallery-body { width: min(1000px, 100%); justify-content: flex-start; }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.gal-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 10px 12px;
  border-radius: 24px;
  background: #fff;
  --shade: var(--press);
  box-shadow: 0 6px 0 var(--press), 0 14px 26px rgba(42, 36, 64, 0.1);
  text-align: left;
  animation: popin 0.45s cubic-bezier(0.3, 1.5, 0.5, 1) both;
  animation-delay: calc(var(--i) * 40ms);
}
.gal-thumb { aspect-ratio: 1; border-radius: 16px; background: #f1eff8; display: grid; place-items: center; overflow: hidden; margin-bottom: 6px; }
.gal-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.gal-card b { font-size: 15px; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gal-card small { color: var(--muted); font-size: 12.5px; padding: 0 4px; }
@keyframes popin { from { opacity: 0; transform: scale(0.85) translateY(10px); } }
.gal-empty { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; color: var(--muted); font-size: 18px; margin: auto; width: min(380px, 100%); }
.gal-empty .art { width: 150px; height: 150px; }
@media (max-width: 480px) { .gal-grid { grid-template-columns: 1fr 1fr; gap: 12px; } }
.gal-thumb img { opacity: 0; transition: opacity 0.25s; }
.gal-thumb img.in { opacity: 1; }
.gal-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 2px 2px 6px; }
@media (max-width: 600px) {
  /* phones: one swipeable row that fades out at the edge */
  .gal-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; touch-action: pan-x; margin-right: -16px; padding-right: 24px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
}
.gal-filters::-webkit-scrollbar { display: none; }
.gal-filter {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 14px;
  border-radius: 21px;
  background: rgba(255, 255, 255, 0.85);
  color: #4d466a;
  font-size: 15px;
  box-shadow: 0 3px 0 var(--press);
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.gal-filter .ic { width: 20px; height: 20px; }
.gal-filter small { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #ece9f5; color: var(--muted); font-size: 12.5px; display: grid; place-items: center; }
.gal-filter.on { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-d); }
.gal-filter.on small { background: rgba(255, 255, 255, 0.25); color: #fff; }
.gal-filter:active { transform: translateY(2px); }
@media (hover: hover) and (pointer: fine) { .gal-filter:not(.on):hover { background: #fff; color: var(--ink); } }
.viewer-card { width: min(760px, 100%); }
.viewer-name { flex: 1; min-width: 0; font: inherit; font-size: 22px; font-weight: 900; color: var(--ink); border: 0; background: #f4f2fa; border-radius: 14px; padding: 8px 12px; margin-right: 10px; }
.viewer-name:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); background: #fff; }
.viewer-img { position: relative; border-radius: 20px; overflow: hidden; display: grid; place-items: center; max-height: 62vh; touch-action: pan-y; }
.viewer-img img { max-width: 100%; max-height: 62vh; display: block; }
.viewer-step {
  position: absolute;
  top: 50%;
  width: 46px;
  height: 46px;
  margin-top: -23px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 var(--press), 0 6px 16px rgba(42, 36, 64, 0.16);
  transition: opacity 0.15s, transform 0.1s;
}
.viewer-step.prev { left: 10px; }
.viewer-step.next { right: 10px; }
.viewer-step:disabled { opacity: 0; pointer-events: none; }
.viewer-step:active { transform: scale(0.92); }
.viewer-meta { margin: 10px 2px 0; text-align: center; color: var(--muted); font-size: 13.5px; }
.viewer-actions { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.viewer-actions .btn { padding: 0 14px; gap: 8px; }
@media (max-width: 600px) {
  .viewer-actions { grid-template-columns: repeat(3, 1fr); }
  .viewer-actions .btn-green { grid-column: 1 / -1; }
  .viewer-actions .btn:not(.btn-green) { flex-direction: column; gap: 3px; min-height: 64px; font-size: 14px; padding: 6px; }
  .viewer-actions .btn:not(.btn-green) .ic { width: 22px; height: 22px; }
  .viewer-step { width: 40px; height: 40px; margin-top: -20px; }
}
/* Phones on their side: picture on the left, name and buttons beside it. */
@media (max-height: 520px) and (min-width: 560px) {
  .viewer-card { width: min(880px, 100%); display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); column-gap: 16px; align-items: start; padding: 16px; }
  .viewer-card .sheet-head { grid-column: 1 / -1; margin-bottom: 10px; }
  .viewer-card .viewer-name { font-size: 19px; padding: 6px 12px; }
  .viewer-img { grid-column: 1; grid-row: 2 / span 2; max-height: calc(100vh - 120px - var(--st) - var(--sb)); }
  .viewer-img img { max-height: calc(100vh - 120px - var(--st) - var(--sb)); }
  .viewer-meta { grid-column: 2; grid-row: 2; margin: 2px 0 0; text-align: left; }
  .viewer-actions { grid-column: 2; grid-row: 3; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
  .viewer-actions .btn { min-height: 46px; font-size: 16px; justify-content: flex-start; padding: 0 16px; }
}

/* ---- canvas menu extras */
.tile-wide { grid-column: 1 / -1; min-height: 64px !important; flex-direction: row !important; }
.paper-row { flex-wrap: wrap; }
.paper-row small { display: block; color: var(--muted); font-size: 13px; }
.paper-pick { display: grid; grid-template-columns: repeat(4, 34px); gap: 9px 10px; justify-content: end; }
.paper-dot { width: 34px; height: 34px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(42, 36, 64, 0.14); transition: transform 0.15s; }
.paper-dot.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5.5px var(--accent); transform: scale(1.06); }
.p-white { background: #fff; }
.p-sketch { background: #fbf5e6; }
.p-kraft { background: #caa679; }
.p-grid { background: #fff linear-gradient(rgba(80, 110, 255, 0.35) 1px, transparent 1px) 0 0 / 8px 8px, #fff linear-gradient(90deg, rgba(80, 110, 255, 0.35) 1px, transparent 1px) 0 0 / 8px 8px; }
.p-dots { background: #fffdf8 radial-gradient(rgba(60, 60, 90, 0.5) 1.2px, transparent 1.6px) 0 0 / 8px 8px; }
.p-lined { background: #fffef7 repeating-linear-gradient(transparent 0 7px, rgba(70, 140, 230, 0.5) 7px 8px); }
.p-chalk { background: #2e3a34; }
.p-clear { background: var(--checker); }

/* ================================================================ shared keyframes and canvas extras (what is left of the party games, which moved to Baker Bash) */

@keyframes jiggle { 0%, 100% { transform: rotate(0) scale(1); } 20% { transform: rotate(-10deg) scale(1.08); } 40% { transform: rotate(8deg) scale(1.1); } 60% { transform: rotate(-5deg) scale(1.08); } 80% { transform: rotate(3deg) scale(1.04); } }

@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes stamp { from { transform: scale(2.2) rotate(-6deg); opacity: 0; } }

@keyframes grow { from { transform: scaleX(0); } }

@keyframes blink { 50% { opacity: 0.35; } }

@keyframes vhs { 0% { opacity: 1; transform: translateY(0) skewX(0); } 30% { transform: translateY(-14px) skewX(-4deg); } 60% { transform: translateY(10px) skewX(3deg); } 100% { opacity: 0; transform: none; } }

@keyframes rumble { 0% { transform: translate(0, 0) rotate(0); } 25% { transform: translate(-3px, 2px) rotate(-1deg); } 50% { transform: translate(3px, -2px) rotate(1deg); } 75% { transform: translate(-2px, -3px); } }

body.no-palette .palette { visibility: hidden; }
/* Long prompts (Draw-Off, Dirty Doodles) wrap instead of being cut off. */
body.kind-party .gc-label { max-width: 12em; }
/* Phones: who's drawing sits above the prompt, so neither gets squeezed. */
@media (max-width: 600px), (max-height: 520px) {
  body.kind-party .game-chip { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'label time' 'prompt time'; column-gap: 10px; row-gap: 0; padding: 6px 8px 6px 16px; border-radius: 22px; }
  body.kind-party .gc-label { grid-area: label; max-width: none; font-size: 12px; }
  body.kind-party .gc-prompt { grid-area: prompt; }
  body.kind-party .gc-time { grid-area: time; align-self: center; }
}
body.kind-party .gc-prompt { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-height: 1.15; overflow-wrap: break-word; padding: 2px 0; }
.game-chip.is-secret { cursor: pointer; touch-action: none; }
.game-chip.is-secret .gc-prompt { color: var(--accent); }
.game-chip.peeking { box-shadow: 0 0 0 4px var(--accent), var(--shadow); }
/* Hot Potato: the chip (and the host's kicker) jolt with every tick of the fuse. */
.game-chip.tick { animation: fuse-tick 0.22s ease-out; }
@keyframes fuse-tick { 0% { transform: scale(1.06); box-shadow: 0 0 0 5px rgba(255, 90, 79, 0.55), var(--shadow); } 100% { transform: none; } }

@keyframes fuse-kick { 0% { transform: scale(1.12); color: var(--red); } }
.game-actions {
  position: fixed; right: calc(14px + var(--sr)); top: 50%; transform: translateY(-50%); z-index: 11;
  display: flex; flex-direction: column; gap: 12px;
}
.game-actions .btn { min-width: 150px; justify-content: flex-start; }
body:not(.drawing) .game-actions { display: none; }
@media (max-width: 600px) {
  /* above the pen options row, not on top of it */
  .game-actions { top: auto; transform: none; bottom: calc(156px + var(--sb)); right: 10px; flex-direction: row; }
  .game-actions .btn { min-width: 0; min-height: 50px; padding: 0 16px; }
}

@keyframes fadein { from { opacity: 0; } }

@keyframes ring { to { stroke-dashoffset: 107; } }

@keyframes boomshake { 10%, 50%, 90% { transform: translate(-10px, 6px) rotate(-1deg); } 30%, 70% { transform: translate(10px, -6px) rotate(1deg); } }

@media (max-height: 520px) {
  
  
  
  
  
}
/* Phones held sideways have width to spare: spread out instead of scrolling. */
@media (max-height: 520px) and (min-width: 640px) {
  
  
  
  
  
  
  
  
  
  /* the word chip keeps clear of the palette and the buttons in the corner */
  body.kind-party .game-chip { left: calc(84px + var(--sl)); right: calc(272px + var(--sr)); max-width: calc(100vw - 356px - var(--sl) - var(--sr)); }
}

/* ================================================================ controls guide */
.controls-card { width: min(980px, 100%); }
.ctl-lead { margin: -6px 0 12px; color: var(--muted); font-weight: 700; font-size: 14px; }
.ctl-cols { columns: 300px 3; column-gap: 22px; }
.ctl-group { break-inside: avoid; margin-bottom: 16px; }
.ctl-group h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1.5px solid #f4f2fa; font-size: 15px; font-weight: 700; }
.ctl-keys { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.kbd { min-width: 30px; height: 30px; padding: 0 9px; border-radius: 9px; background: #f4f2fa; box-shadow: inset 0 -2px 0 #dcd6ee; font-size: 13px; font-weight: 900; color: var(--ink); display: inline-grid; place-items: center; white-space: nowrap; }
button.kbd:not(:disabled):hover { background: #ebe5ff; box-shadow: inset 0 -2px 0 #c9bdf7, 0 0 0 2px rgba(123, 92, 255, 0.35); }
.kbd.custom { background: #ece6ff; color: var(--accent-d); }
.kbd.listening { background: var(--accent); color: #fff; box-shadow: 0 0 0 3px rgba(123, 92, 255, 0.35); animation: pulse 0.8s infinite; }
.kbd.empty { color: var(--muted); font-style: italic; }
.kbd.gesture { font-weight: 800; color: #5b547a; font-size: 12px; }
.ctl-row.fixed span:first-child { color: #5b547a; }
.ctl-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; }

/* ================================================================ animation workspace */
.anim-bar {
  position: fixed; z-index: 10; left: calc(88px + var(--sl)); right: calc(14px + var(--sr)); bottom: calc(100px + var(--sb));
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 24px;
  background: rgba(255, 255, 255, 0.92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--shadow);
}
body:not(.drawing) .anim-bar { display: none; }
.ab-controls { display: flex; align-items: center; gap: 4px; flex: none; }
.ab-btn, .ab-chip, .ab-add { height: 44px; min-width: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--ink); position: relative; transition: background 0.15s, transform 0.12s; }
.ab-btn .ic, .ab-add .ic { width: 22px; height: 22px; }
.ab-btn:hover, .ab-chip:hover, .ab-add:hover { background: #f1eff8; }
.ab-btn:active, .ab-add:active { transform: scale(0.92); }
.ab-play { background: var(--accent); color: #fff; width: 52px; box-shadow: 0 3px 0 var(--accent-d); }
.ab-play:hover { background: var(--accent-d); }
.ab-play.on { background: var(--red); box-shadow: 0 3px 0 var(--red-d); }
.ab-chip { display: flex; flex-direction: column; gap: 0; line-height: 1; padding: 0 8px; background: #f1eff8; }
.ab-chip b { font-size: 16px; }
.ab-chip small { font-size: 10px; color: var(--muted); }
.ab-tog { color: var(--muted); }
.ab-tog.on { color: var(--accent); background: #efeaff; }
.ab-n { position: absolute; right: 3px; top: 2px; font-style: normal; font-size: 10px; font-weight: 900; }
.ab-tog[data-mode='pingpong'] .ic { transform: scaleX(-1); }
.ab-strip { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px; scrollbar-width: thin; touch-action: pan-x; }
.af { position: relative; flex: none; border-radius: 10px; padding: 0; background: #fff; box-shadow: 0 0 0 2px #e4e0f0; overflow: hidden; transition: box-shadow 0.15s, transform 0.15s; }
.af canvas { display: block; width: 72px; height: auto; }
.af.on { box-shadow: 0 0 0 3px var(--accent); transform: translateY(-2px); }
.af.drop { box-shadow: -5px 0 0 0 var(--green), 0 0 0 2px #e4e0f0; }
.af-n { position: absolute; left: 3px; bottom: 2px; font-size: 10px; font-weight: 900; color: var(--muted); background: rgba(255, 255, 255, 0.85); border-radius: 6px; padding: 0 4px; }
.af-hold { position: absolute; right: 3px; top: 2px; font-size: 10px; font-weight: 900; color: #fff; background: var(--orange); border-radius: 6px; padding: 0 4px; }
.af-hold:empty { display: none; }
.ab-strip.reordering .af { cursor: grabbing; }
.ab-adds { display: flex; gap: 4px; flex: none; }
.ab-add { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-d); }
.ab-add:hover { background: var(--green-d); }
.ab-dup { background: #f1eff8; color: var(--ink); box-shadow: 0 3px 0 var(--press); }
.ab-dup:hover { background: #e6e1f7; }
body.ws-anim .toolopts { bottom: calc(184px + var(--sb)); }
.anim-player { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 8; cursor: pointer; }
.anim-player.hidden { display: none; }
body.anim-playing .dock, body.anim-playing .rail, body.anim-playing .palette, body.anim-playing .toolopts { opacity: 0.35; pointer-events: none; }
@media (max-width: 600px) {
  .anim-bar { left: 8px; right: 8px; bottom: calc(84px + var(--sb)); gap: 6px; padding: 6px; border-radius: 20px; flex-wrap: wrap; }
  .ab-controls { order: 1; }
  .ab-adds { order: 2; margin-left: auto; }
  .ab-strip { order: 3; flex-basis: 100%; }
  .ab-btn, .ab-chip, .ab-add { height: 40px; min-width: 40px; }
  .af canvas { width: 56px; }
  body.ws-anim .toolopts { bottom: calc(230px + var(--sb)); }
  body.ws-anim .rail { top: 40%; }
}
/* the animation timeline itself (.anim-tl; Pixel Art shares the .ab-* pieces) */
.anim-tl .ab-strip { padding: 6px 8px; overscroll-behavior-x: contain; }
.anim-tl .af { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: pan-x; }
.anim-tl .af canvas { width: auto; }
.anim-tl .af:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(123, 92, 255, 0.45); }
.anim-tl .af.on:focus-visible { box-shadow: 0 0 0 3px var(--accent); }
.anim-tl .af.drop { box-shadow: -7px 0 0 -2px var(--green), 0 0 0 2px #e4e0f0; }
.anim-tl .af.drop-end { box-shadow: 7px 0 0 -2px var(--green), 0 0 0 2px #e4e0f0; }
.anim-tl .af.lifted { transform: translateY(-4px) scale(1.07); box-shadow: 0 0 0 3px var(--accent), 0 8px 18px rgba(42, 36, 64, 0.22); z-index: 1; }
.anim-tl .af.dragging { opacity: 0.45; }
.anim-tl .ab-strip.reordering { scroll-behavior: auto; }
.anim-tl .ab-lp { position: absolute; right: 3px; top: 1px; font-style: normal; font-size: 10px; font-weight: 900; }
.anim-tl .ab-tog[data-mode='pingpong'] .ic { transform: none; }
.anim-tl .ab-btn:disabled { opacity: 0.4; }
/* frame and fps menus fit short screens (phones on their side) */
body.ws-anim .popmenu { max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain; }
@media (max-height: 520px) { body.ws-anim .popmenu .pm-item { height: 46px; font-size: 16px; } }
/* tool options and pop-up cards ride just above the timeline (its top is measured into --ab-top) */
body.ws-anim .toolopts { bottom: calc(var(--ab-top, calc(184px + var(--sb))) + 10px); }
body.ws-anim .pop-card { bottom: calc(var(--ab-top, calc(184px + var(--sb))) + 82px); }
@media (max-height: 520px) {
  .anim-tl { padding: 5px; gap: 6px; border-radius: 20px; }
  .anim-tl .ab-btn, .anim-tl .ab-chip, .anim-tl .ab-add { height: 38px; min-width: 38px; border-radius: 12px; }
  .anim-tl .ab-play { width: 46px; }
  .anim-tl .ab-strip { padding: 5px 8px; }
}
.anim-preview canvas { max-width: 100%; max-height: calc(min(42vh, 360px) - 32px); display: block; border-radius: 8px; }
.anim-preview:not(.checker) { background: #f4f2fa; }
.anim-preview:not(.checker) canvas { box-shadow: 0 2px 12px rgba(42, 36, 64, 0.14); }
.anim-finish .ap-note { margin-top: -8px; min-height: 1.3em; }
@media (max-width: 600px), (max-height: 880px) {
  .anim-finish .anim-preview { height: min(34vh, 320px); }
  .anim-finish .anim-preview canvas { max-height: calc(min(34vh, 320px) - 32px); }
}
.anim-finish.busy .ap-fmt, .anim-finish.busy .ap-scale, .anim-finish.busy .ap-paper { pointer-events: none; opacity: 0.6; }

.mega-project { --shade: #c2580a; background: linear-gradient(135deg, #ffb13b, #ff6a3d); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(255, 106, 61, 0.3); }
.kind-grid { display: flex; flex-wrap: wrap; justify-content: center; }
.kind-grid .pick-card { flex: 0 1 calc((100% - 32px) / 3); min-width: 0; }
@media (max-width: 560px) { .kind-grid { display: grid; grid-template-columns: 1fr; } .kind-grid .pick-card { display: grid; grid-template-columns: auto 1fr; column-gap: 14px; row-gap: 0; text-align: left; align-items: center; } .kind-grid .pick-art { grid-row: span 2; } .kind-grid .pick-card b { margin-top: 0; align-self: end; } .kind-grid .pick-card small { align-self: start; } .kind-grid .pick-art .art { width: 64px; height: 64px; } }
.gal-thumb { position: relative; }
.gal-kind { position: absolute; right: 6px; bottom: 6px; width: 30px; height: 30px; border-radius: 10px; background: var(--ink); color: #fff; display: grid; place-items: center; font-style: normal; }
.gal-kind .ic { width: 18px; height: 18px; }

/* ================================================================ 3D workspace */
.ws3d { position: fixed; inset: 0; z-index: 5; background: var(--bd); }
.w3-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
body.ws3d-on .ws3d .rail, body.ws3d-on .ws3d .dock, body.ws3d-on .ws3d .toolopts, body.ws3d-on .ws3d .topbar, body.ws3d-on .ws3d .palette { visibility: visible; }
.ws3d .w3-opts { bottom: calc(104px + var(--sb)); }
.ws3d .w3-opts .pill.danger { color: var(--red-d); padding: 0 14px; }
.ws3d .w3-rail .w3-snap.on { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-d); }
.w3-viewchip { cursor: pointer; }
.w3-hint { position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%); width: max-content; max-width: min(440px, calc(100vw - 48px)); text-align: center; padding: 14px 22px; border-radius: 20px; background: rgba(255, 255, 255, 0.85); color: var(--muted); font-size: 18px; pointer-events: none; box-shadow: var(--shadow); }
.w3-panel { position: fixed; right: calc(14px + var(--sr)); top: calc(84px + var(--st)); width: 250px; max-height: calc(100vh - 230px); z-index: 10; display: flex; flex-direction: column; }
.w3-panel-tab { display: none; }
.w3-panel-body { background: rgba(255, 255, 255, 0.94); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-radius: 22px; box-shadow: var(--shadow); padding: 12px; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.w3-panel h4 { margin: 2px 4px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.w3-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.w3-list li { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 8px; border-radius: 12px; cursor: pointer; font-size: 14px; }
.w3-list li:hover { background: #f4f2fa; }
.w3-list li.on { background: #ece6ff; color: var(--accent-d); }
.w3-list .w3-empty { color: var(--muted); cursor: default; }
.w3-sw { width: 16px; height: 16px; border-radius: 5px; box-shadow: inset 0 0 0 1.5px rgba(42, 36, 64, 0.15); flex: none; }
.w3-nm { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w3-rename { flex: 1; min-width: 0; font: inherit; font-size: 14px; border: 2px solid var(--accent); border-radius: 8px; padding: 2px 6px; }
.w3-eye { width: 28px; height: 28px; border-radius: 8px; color: var(--muted); display: grid; place-items: center; }
.w3-eye .ic { width: 18px; height: 18px; }
.w3-eye.off { opacity: 0.35; }
.w3-props { border-top: 2px solid #f1eff8; padding-top: 10px; }
.w3-props:empty { display: none; }
.w3-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px; font-size: 14px; }
.w3-row > span { flex: none; width: 74px; }
.w3-row .w3-sl { flex: 1; }
.w3-row .switch { transform: scale(0.8); transform-origin: right; }
.w3-xyz { display: flex; justify-content: space-between; padding: 6px 4px; font-size: 13px; color: var(--muted); }
.w3-xyz b { color: var(--ink); font-variant-numeric: tabular-nums; }
.w3-tip { color: var(--muted); font-size: 13px; margin: 2px 4px; }
.shape-menu { display: grid; grid-template-columns: 1fr 1fr; min-width: 300px; }
.w3-bdsw { width: 24px; height: 24px; border-radius: 8px; flex: none; box-shadow: inset 0 0 0 1.5px rgba(42, 36, 64, 0.18); }
.popmenu .pm-item.w3-cur { color: var(--accent-d); background: #f1edff; }
/* the 3D menus are long: tighter rows on phones held sideways */
@media (max-height: 500px) {
  body.ws3d-on .pm-item { height: 44px; font-size: 16px; }
  body.ws3d-on .shape-menu { grid-template-columns: repeat(3, 1fr); min-width: 420px; }
  body.ws3d-on .shape-menu .pm-item { height: 44px; }
}
.shape-menu .pm-item { height: 50px; font-size: 16px; }
.bd-swatch { position: relative; display: block; }
.bd-floor { position: absolute; left: 10%; right: 10%; bottom: 14%; height: 18%; border-radius: 50%; background: rgba(42, 36, 64, 0.14); }
.bd-cube { position: absolute; left: 50%; bottom: 24%; width: 30%; aspect-ratio: 1; transform: translateX(-50%) rotate(8deg); border-radius: 8px; background: linear-gradient(135deg, #b48bff, #6a3df0); box-shadow: 0 4px 0 #4b2bb8; }
@media (max-width: 760px) {
  .w3-panel { top: auto; bottom: calc(160px + var(--sb)); right: 10px; width: min(280px, calc(100vw - 20px)); max-height: 46vh; align-items: flex-end; }
  .w3-panel-tab { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); font-size: 14px; margin-top: 8px; order: 2; }
  .w3-panel-tab .ic { width: 18px; height: 18px; }
  .w3-panel-body { display: none; width: 100%; }
  .w3-panel.open .w3-panel-body { display: block; }
  .ws3d .w3-opts .pill span { display: none; }
  .ws3d .w3-opts .pill { padding: 0 12px; }
  .ws3d .w3-opts .opts { gap: 6px; }
  .w3-viewchip { display: none; }
  .w3-hint { max-width: calc(100vw - 150px); font-size: 16px; }
}
/* phones held sideways: little height, so the Scene list folds into a tab at the top */
@media (max-height: 500px) {
  .w3-panel { top: calc(76px + var(--st)); bottom: auto; right: calc(10px + var(--sr)); width: min(270px, calc(100vw - 20px)); max-height: calc(100vh - 86px - var(--st) - var(--sb)); align-items: flex-end; }
  .w3-panel-tab { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); font-size: 14px; margin: 0 0 8px; order: 0; flex: none; }
  .w3-panel-tab .ic { width: 18px; height: 18px; }
  .w3-panel-body { display: none; width: 100%; }
  .w3-panel.open .w3-panel-body { display: block; }
  .w3-hint { top: 50%; }
}
@media (max-height: 500px) and (max-width: 1000px) {
  .ws3d .w3-opts .pill span { display: none; }
  .ws3d .w3-opts .pill { padding: 0 12px; }
  .ws3d .w3-opts .opts { gap: 6px; }
}

/* ---------------------------------------------------------------- controls mode */
body:not(.adv) .adv-only { display: none !important; }
body.adv .simple-only { display: none !important; }
.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.15s;
}
.mode-chip .ic { width: 18px; height: 18px; }
.mode-chip.is-adv { color: #fff; background: linear-gradient(135deg, #7b5cff, #b04dff); }
.mode-chip:active { transform: scale(0.95); }
body.kind-party .topbar .mode-chip { display: none; }
@media (max-width: 560px) {
  .mode-chip { padding: 0 11px; }
  .mode-chip span { display: none; }
}

/* ---------------------------------------------------------------- sound popover */
.vol-pop {
  position: fixed;
  z-index: 120;
  width: min(320px, calc(100vw - 20px));
  padding: 14px 16px 6px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(40, 20, 90, 0.25), 0 2px 0 rgba(255, 255, 255, 0.8) inset;
  opacity: 0;
  transform: translateY(-8px) scale(0.97);
  transform-origin: top right;
  transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  pointer-events: none;
}
.vol-pop.show { opacity: 1; transform: none; pointer-events: auto; }
.vol-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.vol-head b { font-size: 20px; font-weight: 900; }
.vol-mute { display: inline-flex; align-items: center; gap: 6px; }
.vol-mute .ic { width: 18px; height: 18px; }
.vp-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 2px solid #f4f2fa; font-size: 15px; }
.vp-row > span, .vol-row > span { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px; min-width: 128px; }
.vp-row > span .ic, .vol-row > span .ic { width: 18px; height: 18px; color: var(--accent); transition: color 0.15s; }
.vol-row.is-off > span .ic { color: #b9b3cc; }
.vp-row .set-slider { flex: 1; }
.vol-row .set-slider { outline: none; border-radius: 999px; }
.vol-row .set-slider:focus-visible { box-shadow: 0 0 0 3px rgba(123, 92, 255, 0.35); }

/* ---------------------------------------------------------------- 3D: lights, skins, posing */
.ws3d .w3-opts .opts { max-width: calc(100vw - 24px); overflow-x: auto; scrollbar-width: none; }
/* more pills than fit: fade the edge so it reads as scrollable */
.ws3d .w3-opts .opts.more { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 34px), transparent); }
.ws3d .w3-opts .opts::-webkit-scrollbar { display: none; }
.ws3d .w3-opts .pill { flex: none; }
.ws3d .w3-opts .pill.on { background: var(--accent); color: #fff; }
.ws3d .w3-opts .pill.hl { background: #ffe9a8; color: #6b4a00; }
.ws3d .w3-rail .w3-sunbtn { color: #ff9f1c; }
/* on the dark stage a half-faded white button turns muddy gray: keep it light */
.ws3d[data-bd='night'] .w3-rail .btn:disabled { opacity: 1; background: #b9b3cf; color: #7d7697; box-shadow: 0 4px 0 #8d86a8; }
.ws3d.dragging .w3-canvas { cursor: grabbing !important; }
.ws3d .w3-top .mode-chip { order: 0; }
.w3-tipline {
  position: fixed; left: 50%; bottom: calc(184px + var(--sb)); transform: translate(-50%, 8px);
  max-width: min(560px, calc(100vw - 32px)); padding: 9px 16px; border-radius: 16px;
  background: rgba(42, 36, 64, 0.82); color: #fff; font-size: 14px; text-align: center; line-height: 1.35;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 9;
}
.w3-tipline.show { opacity: 1; transform: translate(-50%, 0); }
.ws3d.panel-open .w3-tipline { opacity: 0; }
.w3-tipline b { color: #ffd76a; }
.w3-ic { width: 18px; height: 18px; display: grid; place-items: center; color: var(--accent); flex: none; }
.w3-ic .ic { width: 18px; height: 18px; }
.w3-tag { font-style: normal; font-size: 10.5px; padding: 1px 6px; border-radius: 6px; background: #ffe9a8; color: #6b4a00; margin-left: 4px; vertical-align: 1px; }
.w3-skinrow .pill.small { height: 34px; padding: 0 12px; font-size: 13px; gap: 6px; }
.w3-skinrow .pill .ic { width: 16px; height: 16px; }
.w3-num { display: flex; flex-direction: column; gap: 4px; padding: 6px 4px 0; }
.w3-nrow { display: grid; grid-template-columns: 66px repeat(3, 1fr); gap: 4px; align-items: center; font-size: 12px; color: var(--muted); }
.w3-nrow input { width: 100%; min-width: 0; font: inherit; font-size: 12.5px; font-weight: 800; color: var(--ink); text-align: center; border: 2px solid #ece9f5; border-radius: 8px; padding: 3px 2px; background: #fff; font-variant-numeric: tabular-nums; }
.w3-nrow input:focus { outline: none; border-color: var(--accent); }
.w3-nrow input:nth-of-type(1) { box-shadow: inset 0 -2px 0 #ff4d5e55; }
.w3-nrow input:nth-of-type(2) { box-shadow: inset 0 -2px 0 #22c07055; }
.w3-nrow input:nth-of-type(3) { box-shadow: inset 0 -2px 0 #2f7dff55; }

/* floating panels (skin + pose capture) */
.sk-panel, .pc-panel {
  position: fixed; z-index: 60; top: calc(84px + var(--st)); left: calc(14px + var(--sl));
  width: min(340px, calc(100vw - 28px)); max-height: calc(100vh - 272px - var(--st) - var(--sb)); overflow: auto; overscroll-behavior: contain;
  padding: 14px; border-radius: 24px; background: rgba(255, 255, 255, 0.97);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 18px 50px rgba(40, 20, 90, 0.22);
  opacity: 0; transform: translateX(-12px); transition: opacity 0.2s, transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.15);
  touch-action: pan-y;
}
.sk-panel.show, .pc-panel.show { opacity: 1; transform: none; }
.pc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.pc-head b { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 900; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-head b .ic { width: 20px; height: 20px; color: var(--accent); flex: none; }
.pc-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14px; border-top: 2px solid #f4f2fa; }
.pc-row > span { flex: 0 0 92px; }
.pc-row .set-slider { flex: 1; }
.pc-row .seg { flex: 1; }
.pc-row .seg button { flex: 1; }
.pc-row.pc-src { flex-wrap: wrap; border-top: 0; }
.pc-row .pill { height: 38px; padding: 0 12px; font-size: 13.5px; gap: 6px; }
.pc-row .pill .ic { width: 17px; height: 17px; }
.pc-row .switch { margin-left: auto; }
.pc-view { position: relative; border-radius: 16px; overflow: hidden; background: #f4f2fa; aspect-ratio: 16 / 11; display: grid; place-items: center; }
.pc-cv { width: 100%; height: 100%; object-fit: contain; display: none; }
.pc-view.has-src .pc-cv { display: block; }
.pc-view.has-src .pc-empty { display: none; }
.pc-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.35; }
.pc-empty .ic { width: 40px; height: 40px; color: var(--accent); }
.pc-status { margin: 8px 2px; min-height: 18px; font-size: 13px; color: #4d466a; line-height: 1.35; }
.pc-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin: 10px -14px -14px; padding: 10px 14px 14px; position: sticky; bottom: -14px; background: linear-gradient(rgba(255,255,255,0), #fff 30%); }
.pc-actions .btn { height: 48px; font-size: 15px; }
.pc-actions .btn .ic { width: 18px; height: 18px; }
.sk-top { display: flex; gap: 12px; align-items: stretch; }
.sk-thumb { width: 104px; flex: none; aspect-ratio: 1; border-radius: 16px; background: var(--checker); display: grid; place-items: center; overflow: hidden; box-shadow: inset 0 0 0 2px #ece9f5; }
.sk-thumb img { width: 100%; height: 100%; object-fit: contain; }
.sk-thumb span { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; background: rgba(255, 255, 255, 0.85); padding: 8px; border-radius: 12px; }
.sk-thumb .ic { width: 26px; height: 26px; color: var(--accent); }
.sk-actions { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.sk-actions .pill { height: 36px; padding: 0 12px; font-size: 13.5px; gap: 6px; justify-content: flex-start; }
.sk-actions .pill .ic { width: 17px; height: 17px; color: var(--accent); }
.sk-lbl { margin: 12px 2px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.sk-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sk-mode { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 10px; border-radius: 14px; background: #f6f4fc; text-align: left; transition: background 0.15s, box-shadow 0.15s; }
.sk-mode b { font-size: 14px; }
.sk-mode small { font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.sk-mode:hover { background: #efebfb; }
.sk-mode.on { background: #ece6ff; box-shadow: inset 0 0 0 2px var(--accent); }
.sk-mode.on b { color: var(--accent-d); }
.sk-fit { margin-top: 8px; transition: opacity 0.2s; }
.sk-fit.off { opacity: 0.4; pointer-events: none; }
.sk-btns { display: flex; gap: 8px; padding-top: 8px; }
.sk-btns .pill { flex: 1; height: 38px; font-size: 13.5px; gap: 6px; }
.sk-btns .pill .ic { width: 16px; height: 16px; }
.sk-btns .pill.danger { color: var(--red-d); }
.sk-tip { margin: 10px 2px 0; font-size: 12px; color: var(--muted); line-height: 1.4; }
.ws3d.capturing .w3-panel, .ws3d.capturing .w3-opts { display: none; }
@media (max-width: 760px) {
  .sk-panel, .pc-panel { top: auto; bottom: calc(10px + var(--sb)); left: 10px; right: 10px; width: auto; max-height: 52vh; transform: translateY(14px); z-index: 60; }
  .ws3d.capturing .w3-dock, .ws3d.capturing .w3-opts { display: none; }
  .pc-view { aspect-ratio: 16 / 10; max-height: 22vh; }
  .w3-tipline { bottom: calc(218px + var(--sb)); font-size: 13px; }
}
@media (max-height: 500px) {
  .sk-panel, .pc-panel { top: calc(10px + var(--st)); bottom: auto; left: calc(10px + var(--sl)); right: auto; width: min(340px, calc(100vw - 20px)); max-height: calc(100vh - 20px - var(--st) - var(--sb)); transform: translateX(-12px); }
  .pc-view { max-height: 34vh; }
  /* tips sit up under the top bar, clear of the model in the short middle band */
  .w3-tipline { top: calc(72px + var(--st)); bottom: auto; transform: translate(-50%, -8px); max-width: calc(100vw - 380px); font-size: 13px; }
}

/* ================================================================ canvas workspaces (Photo Editor, Pixel Art) */
.wsx { position: fixed; inset: 0; z-index: 5; background: radial-gradient(ellipse at 50% 35%, #f7f5fc 0%, #e9e6f3 70%, #dedaeb 100%); }
.wsx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.wsx-canvas.grab { cursor: grab !important; }
body.wsx-on .wsx .rail, body.wsx-on .wsx .dock, body.wsx-on .wsx .toolopts, body.wsx-on .wsx .topbar, body.wsx-on .wsx .palette { visibility: visible; }
body.wsx-on .wsx .anim-bar { display: flex; }
.wsx .wsx-opts { bottom: calc(104px + var(--sb)); }
.wsx .wsx-opts .opts { max-width: calc(100vw - 24px); overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
.wsx .wsx-opts .opts::-webkit-scrollbar { display: none; }
.wsx .wsx-opts .pill, .wsx .wsx-opts .seg { flex: none; }
.wsx .wsx-opts .pill.danger { color: var(--red-d); }
.wsx .wsx-opts .seg button { padding: 0 12px; gap: 6px; }
.wsx .wsx-opts .seg button span { font-size: 14px; }
.wsx .wsx-dock { max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; }
.wsx .wsx-dock::-webkit-scrollbar { display: none; }
.wsx .wsx-dock .tool-btn { flex: none; }
.wsx.empty .wsx-dock, .wsx.empty .wsx-rail, .wsx.empty .wsx-opts, .wsx.empty .wsx-pal, .wsx.empty .wsx-panel, .wsx.empty .wsx-zoom, .wsx.empty .done-btn { visibility: hidden !important; }
.wsx-zoom { cursor: pointer; font-variant-numeric: tabular-nums; min-width: 64px; }
.ph-optsl { display: flex; align-items: center; gap: 8px; padding: 0 6px 0 10px; font-size: 14px; color: var(--muted); flex: none; }
.ph-optsl .w3-sl { width: 120px; }
.ph-optsl .hslider { height: 40px; }
.ph-optsl .hslider .sl-thumb { width: 40px; height: 40px; }
.ph-optsl .hslider .sl-thumb { left: calc(var(--f, 0) * (100% - 40px)); }

/* the panel on the right (layers / adjust / looks) */
.wsx-panel { position: fixed; right: calc(14px + var(--sr)); top: calc(84px + var(--st)); width: 272px; max-height: calc(100vh - 236px - var(--st) - var(--sb)); z-index: 10; display: flex; flex-direction: column; }
.wsx-panel-tab { display: none; }
.wsx-panel-body { background: rgba(255, 255, 255, 0.95); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-radius: 22px; box-shadow: var(--shadow); padding: 10px; overflow: auto; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.ph-tabs { flex: none; }
.ph-tabs button { height: 40px; gap: 6px; font-size: 13.5px; padding: 0 6px; }
.ph-tabs button .ic { width: 17px; height: 17px; }
.ph-tab { display: none; flex-direction: column; gap: 6px; min-height: 0; }
.ph-tab.show { display: flex; }
.ph-llist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; max-height: 300px; overflow: auto; }
.ph-llist li { display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 2px; border-radius: 14px; cursor: pointer; font-size: 14px; position: relative; }
.ph-llist li:hover { background: #f4f2fa; }
.ph-llist li.on { background: #ece6ff; color: var(--accent-d); }
.ph-llist li.dragging { opacity: 0.6; }
.ph-llist li.drop { box-shadow: inset 0 3px 0 var(--green); }
.ph-grip { width: 16px; color: #c5bfd9; font-size: 12px; letter-spacing: -2px; cursor: grab; touch-action: none; text-align: center; flex: none; user-select: none; }
.ph-lthumb-wrap { position: relative; flex: none; display: grid; place-items: center; }
.ph-lthumb { width: 48px; height: auto; border-radius: 8px; background: var(--checker); box-shadow: inset 0 0 0 1.5px rgba(42, 36, 64, 0.12); display: block; }
.ph-tbadge { position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; border-radius: 6px; background: var(--accent); color: #fff; font-style: normal; font-size: 11px; font-weight: 900; display: grid; place-items: center; }
.ph-lprops { border-top: 2px solid #f1eff8; padding-top: 4px; }
.ph-lprops .w3-row b, .ph-adjrow b { flex: none; width: 34px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ph-lbtns { display: flex; gap: 6px; flex-wrap: wrap; }
.ph-lbtns .pill { height: 38px; padding: 0 11px; font-size: 13.5px; gap: 5px; }
.ph-lbtns .pill .ic { width: 17px; height: 17px; }
.ph-lbtns .pill.danger { color: var(--red-d); margin-left: auto; }
.ph-rmbg { height: 38px; font-size: 13.5px; gap: 6px; justify-content: center; }
.ph-rmbg .ic { width: 17px; height: 17px; color: var(--accent); }
.pill.small { height: 34px; padding: 0 12px; font-size: 13px; }
.ph-adj { display: flex; flex-direction: column; }
.ph-adjrow { padding: 1px 4px; }
.ph-adjrow > span { width: 80px; font-size: 13px; }
.w3-sl.bipolar .sl-track { background: linear-gradient(90deg, #ece9f5, #ece9f5 49.4%, #b9acf5 49.5%, #b9acf5 50.5%, #ece9f5 50.6%); }
.ph-target { margin: 2px 4px 0; }
.ph-target b { color: var(--ink); }
.ph-adjfoot, .ph-lookfoot { display: none; grid-template-columns: 1fr 1.3fr; gap: 8px; position: sticky; bottom: -10px; background: linear-gradient(rgba(255,255,255,0), #fff 30%); padding: 8px 0 2px; }
.ph-adjfoot.show, .ph-lookfoot.show { display: grid; }
.ph-adjfoot .btn, .ph-lookfoot .btn { height: 44px; font-size: 14px; }
.ph-adjfoot .btn .ic, .ph-lookfoot .btn .ic { width: 18px; height: 18px; }
.ph-looks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ph-look { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px; border-radius: 14px; font-size: 12.5px; font-weight: 800; color: var(--ink); transition: background 0.15s, box-shadow 0.15s, transform 0.12s; }
.ph-look canvas { width: 100%; aspect-ratio: 1; border-radius: 10px; display: block; }
.ph-look:hover { background: #f4f2fa; }
.ph-look:active { transform: scale(0.96); }
.ph-look.on { background: #ece6ff; box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent-d); }
.ph-lookk.hidden { display: none; }

/* start card, text editor, busy */
.ph-start { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; z-index: 12; }
.ph-start.hidden { display: none; }
.ph-start-card { width: min(420px, 100%); background: #fff; border-radius: 32px; box-shadow: 0 24px 60px rgba(42, 36, 64, 0.18); padding: 26px 22px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; animation: popin 0.45s cubic-bezier(0.3, 1.4, 0.5, 1); }
.ph-start-card h3 { margin: 0 0 4px; font-size: 24px; font-weight: 900; }
.ph-start-art { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #2fd1c5, #2f7dff); box-shadow: 0 6px 0 #1d5fd0; }
.ph-start-art .ic { width: 42px; height: 42px; }
.ph-start-card .btn.big { width: 100%; }
.ph-or { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.ph-blank { width: 100%; }
.ph-blank button { font-size: 13.5px; }
.ph-hint { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.ph-texted { position: absolute; z-index: 9; min-width: 8px; white-space: pre; outline: none; color: transparent; caret-color: #7b5cff; padding: 0; margin: 0; background: transparent; }
.ph-texted::selection { background: rgba(123, 92, 255, 0.28); color: transparent; }
.ph-busy { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(255, 255, 255, 0.25); cursor: progress; }
.ph-busy.hidden { display: none; }
.ph-busy span { width: 44px; height: 44px; border-radius: 50%; border: 5px solid rgba(123, 92, 255, 0.25); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ph-font span { font-size: 16px; }

/* photo editor: the options bar wraps (in groups) instead of hiding controls off screen.
   The bar spans the screen (centring its row) so it isn't squeezed to half the width. */
.ws-photo .wsx-opts { left: calc(8px + var(--sl)); right: calc(8px + var(--sr)); display: flex; justify-content: center; transform: translateY(10px); pointer-events: none; }
.ws-photo .wsx-opts.show { transform: none; pointer-events: none; }
.ws-photo .wsx-opts.show .opts { pointer-events: auto; }
.ws-photo .wsx-opts .opts { flex-wrap: wrap; justify-content: center; white-space: normal; row-gap: 6px; max-width: calc(100vw - 168px - var(--sl) - var(--sr)); }
.ws-photo .ph-grp { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 8px; flex: none; max-width: 100%; }
.ws-photo .ph-optv { flex: none; min-width: 46px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ws-photo .wsx-panel { max-height: calc(100vh - 84px - var(--ph-pfloor, 152px) - var(--st)); }
.ws-photo .ph-lbtns { flex-wrap: nowrap; gap: 5px; }
.ws-photo .ph-lbtns .pill { flex: 1 1 auto; justify-content: center; padding: 0 8px; gap: 4px; font-size: 13px; min-width: 0; }
.ws-photo .ph-lbtns .pill.danger { margin-left: 0; }
.ph-look.on canvas { box-shadow: 0 0 0 2px #fff; }
.ph-cmp { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ph-cmp.on { background: var(--accent); color: #fff; box-shadow: 0 1px 0 var(--accent-d); }
.ph-adjfoot.cmp3, .ph-lookfoot.cmp3 { grid-template-columns: auto 1fr 1.3fr; }
.ph-adjfoot .ph-cmp, .ph-lookfoot .ph-cmp { width: 44px; padding: 0; }
.ws-photo.comparing .wsx-canvas { cursor: default; }
.ph-before { position: fixed; z-index: 9; left: 50%; top: calc(80px + var(--st)); transform: translateX(-50%); padding: 7px 14px; border-radius: 14px; background: rgba(42, 36, 64, 0.82); color: #fff; font-size: 13px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; pointer-events: none; }
.ph-before.hidden { display: none; }

@media (max-width: 760px) {
  .wsx-panel { top: auto; bottom: calc(160px + var(--sb)); right: 10px; width: min(330px, calc(100vw - 20px)); max-height: 56vh; align-items: flex-end; }
  .wsx-panel-tab { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); font-size: 14px; margin-top: 8px; order: 2; }
  .wsx-panel-tab .ic { width: 18px; height: 18px; }
  .wsx-panel-body { display: none; width: 100%; }
  .wsx-panel.open .wsx-panel-body { display: flex; }
  .wsx .wsx-opts .pill:not(.txt) span { display: none; }
  .wsx .wsx-opts .pill { padding: 0 13px; }
  .wsx .wsx-opts .seg button span { display: none; }
  .wsx .wsx-opts .ph-optsl > span { display: none; }
  .wsx .wsx-opts .ph-optsl .w3-sl { width: 96px; }
  .wsx .wsx-opts .opt-label { display: none; }
  .wsx-zoom { display: none; }
  .wsx .wsx-dock .tool-btn { width: 58px; }
}
/* photo editor on phones: the panel sits just above the (wrapping) options bar; sliders keep their names */
@media (max-width: 760px) {
  .ws-photo .wsx-panel { bottom: calc(112px + var(--ph-optsh, 56px) + var(--sb)); max-height: min(60vh, calc(100vh - 196px - var(--ph-optsh, 56px) - var(--st) - var(--sb))); }
  .ws-photo .wsx-opts .ph-optsl { padding: 0 2px 0 8px; gap: 6px; }
  .ws-photo .wsx-opts .ph-optsl span { display: inline; font-size: 13px; }
  .ws-photo .wsx-opts .ph-optsl .w3-sl { width: 88px; }
  .ws-photo .wsx-opts .ph-optv { min-width: 0; }
  .ws-photo .wsx-opts .opts { gap: 6px; padding: 6px; max-width: calc(100vw - 16px); }
  .ws-photo .wsx-opts .ph-grp { gap: 6px; }
  .ws-photo .ph-start-card { padding: 22px 16px 16px; }
}
/* photo editor on a phone held sideways: tools bottom left, options beside them, layers behind a button */
@media (max-height: 500px) and (min-width: 561px) {
  .ws-photo .wsx-rail { top: calc(50% + 34px); }
  .ws-photo .wsx-rail .size-slider { height: min(150px, calc(100vh - 290px)); }
  .ws-photo .wsx-dock { left: calc(84px + var(--sl)); transform: none; gap: 3px; padding: 6px; border-radius: 24px; }
  .ws-photo .wsx-dock .tool-btn { width: 50px; height: 50px; border-radius: 17px; }
  .ws-photo .wsx-dock .tool-btn .ic { width: 27px; height: 27px; }
  .ws-photo .wsx-dock .tool-btn span { display: none; }
  .ws-photo .wsx-dock .tool-btn.on { transform: translateY(-2px); box-shadow: 0 3px 0 var(--accent-d); }
  .ws-photo .wsx-opts { left: calc(var(--ph-dockr, 420px) + 10px); right: calc(14px + var(--sr)); bottom: calc(14px + var(--sb)); }
  .ws-photo .wsx-opts .opts { max-width: 100%; padding: 5px; gap: 6px; border-radius: 22px; }
  .ws-photo .wsx-opts .ph-grp { gap: 6px; }
  .ws-photo .wsx-opts .pill { height: 42px; padding: 0 12px; font-size: 14px; }
  .ws-photo .wsx-opts .pill:not(.txt) span { display: none; }
  .ws-photo .wsx-opts .seg button { height: 36px; min-width: 40px; padding: 0 9px; font-size: 13.5px; }
  .ws-photo .wsx-opts .seg button .ic + span { display: none; }
  .ws-photo .wsx-opts .ph-optsl { padding: 0 2px 0 6px; gap: 6px; font-size: 13px; }
  .ws-photo .wsx-opts .ph-optsl .w3-sl { width: 84px; }
  .ws-photo .wsx-opts .opt-label { display: none; }
  .ws-photo .wsx-panel { top: calc(76px + var(--st)); bottom: auto; right: calc(10px + var(--sr)); width: min(300px, calc(100vw - 20px)); max-height: calc(100vh - 86px - var(--st) - var(--sb)); align-items: flex-end; }
  .ws-photo .wsx-panel-tab { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); font-size: 14px; margin: 0 0 6px; flex: none; }
  .ws-photo .wsx-panel-tab .ic { width: 18px; height: 18px; }
  .ws-photo .wsx-panel-body { display: none; width: 100%; }
  .ws-photo .wsx-panel.open .wsx-panel-body { display: flex; }
}
.pixelated img, img.pixelated, .pixelated canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
.px-size-grid { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .px-size-grid { grid-template-columns: repeat(2, 1fr); } }

.wsx-panel .hslider { height: 36px; }
.wsx-panel .hslider .sl-thumb { width: 36px; height: 36px; left: calc(var(--f, 0) * (100% - 36px)); }
.wsx-panel .hslider .sl-thumb span { transform: scale(0.8); }

/* pixel art */
.ws-pixel .wsx-opts { bottom: calc(178px + var(--sb)); }
.ws-pixel .wsx-panel { max-height: calc(100vh - 300px - var(--st) - var(--sb)); }
.ws-pixel .px-frames { left: calc(92px + var(--sl)); right: calc(300px + var(--sr)); }
.px-frames .af canvas { image-rendering: pixelated; image-rendering: crisp-edges; background: var(--checker); }
.px-show-phone { display: none !important; }
.px-cur { display: flex; align-items: center; gap: 10px; padding: 2px 2px 4px; }
.px-cursw { width: 40px; height: 40px; border-radius: 12px; box-shadow: inset 0 0 0 2px rgba(42, 36, 64, 0.15), 0 3px 0 var(--press); flex: none; }
.px-curhex { flex: 1; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted); }
.px-palname { height: 36px; font-size: 13.5px; gap: 6px; justify-content: flex-start; }
.px-palname .ic { width: 17px; height: 17px; color: var(--accent); }
.px-swatches { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.px-sw { aspect-ratio: 1; border-radius: 7px; background: var(--c); box-shadow: inset 0 0 0 1.5px rgba(42, 36, 64, 0.14); transition: transform 0.12s, box-shadow 0.12s; }
.px-sw:hover { transform: scale(1.12); }
.px-sw.on { box-shadow: 0 0 0 2.5px #fff, 0 0 0 4.5px var(--accent); transform: scale(1.06); z-index: 1; }
.ws-pixel .wsx-panel-body > * { flex-shrink: 0; } /* a short panel scrolls; its rows never squash to nothing */
.px-layers { border-top: 2px solid #f1eff8; padding-top: 6px; }
.px-layers h4 { margin: 2px 4px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.px-layers .ph-lthumb { width: 36px; height: 36px; object-fit: contain; }
.px-col { display: none; }
.px-shade button { padding: 0 12px; font-size: 13.5px; }
@media (max-width: 760px) {
  .ws-pixel .px-frames { left: 8px; right: 8px; bottom: calc(84px + var(--sb)); flex-wrap: nowrap; gap: 6px; padding: 6px; }
  .ws-pixel .px-frames .ab-strip { order: 0; flex-basis: auto; }
  .ws-pixel .px-frames .ab-controls { order: -1; }
  .ws-pixel .wsx-panel { right: calc(62px + var(--sr)); width: min(300px, calc(100vw - 80px)); }
  .ws-pixel .px-frames .ab-adds { order: 0; margin-left: 0; }
  .px-hide-phone { display: none !important; }
  .px-show-phone { display: grid !important; }
  .ws-pixel .wsx-opts { bottom: calc(170px + var(--sb)); }
  .ws-pixel .wsx-panel { bottom: calc(244px + var(--sb)); max-height: calc(100vh - 340px - var(--st) - var(--sb)); }
  .ws-pixel .wsx-panel-tab { display: none; }
  .ws-pixel .wsx-panel.open .wsx-panel-tab { display: inline-flex; }
  .px-col { display: flex; flex-direction: column; gap: 5px; position: fixed; z-index: 10; right: calc(8px + var(--sr)); top: calc(84px + var(--st)); bottom: calc(244px + var(--sb)); width: 46px; padding: 5px; overflow-y: auto; border-radius: 18px; background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); scrollbar-width: none; }
  .px-col::-webkit-scrollbar { display: none; }
  .px-col .px-sw { width: 36px; height: 36px; flex: none; }
  .wsx.empty .px-col { visibility: hidden; }
}
.px-colbtn { width: 36px; height: 36px; flex: none; border-radius: 12px; display: grid; place-items: center; color: var(--accent); background: #f1eff8; }
.px-colbtn .ic { width: 20px; height: 20px; }
.px-rot90 .ic { transform: rotate(90deg); }
/* sideways phone (and short windows): the frames bar sits beside a compact dock,
   tool options go up top between the palette and the top bar, swatches run down the right */
@media (max-height: 520px) and (orientation: landscape) {
  .ws-pixel .wsx-zoom, .ws-pixel .wsx-top [data-a=help] { display: none; }
  .ws-pixel .wsx-rail { top: calc(96px + var(--st)); transform: none; }
  .ws-pixel .wsx-dock { left: auto; right: calc(62px + var(--sr)); bottom: calc(8px + var(--sb)); transform: none; gap: 2px; padding: 5px; border-radius: 22px; }
  .ws-pixel .wsx-dock .tool-btn { width: 50px; height: 50px; border-radius: 16px; }
  .ws-pixel .wsx-dock .tool-btn span { display: none; }
  .ws-pixel .wsx-dock .tool-btn .ic { width: 26px; height: 26px; }
  .ws-pixel .wsx-dock .tool-btn.on { transform: translateY(-2px); box-shadow: 0 3px 0 var(--accent-d); }
  .ws-pixel .px-frames { left: calc(70px + var(--sl)); right: calc(70px + var(--sr) + var(--px-dockw, 320px)); bottom: calc(8px + var(--sb)); flex-wrap: nowrap; gap: 4px; padding: 5px; border-radius: 20px; }
  .ws-pixel .px-frames .ab-controls, .ws-pixel .px-frames .ab-strip, .ws-pixel .px-frames .ab-adds { order: 0; flex-basis: auto; margin-left: 0; }
  .ws-pixel .px-frames .ab-strip { padding: 2px; gap: 4px; }
  .ws-pixel .px-frames .ab-btn, .ws-pixel .px-frames .ab-add { height: 40px; min-width: 40px; }
  .ws-pixel .px-frames .ab-play { width: 44px; }
  .ws-pixel .px-frames .af canvas { width: 40px !important; height: 40px !important; object-fit: contain; }
  .ws-pixel .px-hide-phone { display: none !important; }
  .ws-pixel .px-show-phone { display: grid !important; }
  .ws-pixel .wsx-opts { left: calc(100px + var(--sl)); top: calc(14px + var(--st)); bottom: auto; transform: translateY(-8px); }
  .ws-pixel .wsx-opts.show { transform: none; }
  .ws-pixel .wsx-opts .opts { max-width: calc(100vw - 124px - var(--sl) - var(--sr) - var(--px-topw, 320px)); padding: 4px; gap: 6px; border-radius: 24px; }
  .ws-pixel .wsx-opts .pill { height: 42px; padding: 0 12px; }
  .ws-pixel .wsx-opts .pill:not(.txt) span, .ws-pixel .wsx-opts .seg button span, .ws-pixel .wsx-opts .opt-label { display: none; }
  .ws-pixel .wsx-opts .seg { padding: 3px; }
  .ws-pixel .wsx-opts .seg button { height: 36px; }
  .ws-pixel .wsx-panel { top: calc(76px + var(--st)); bottom: auto; right: calc(62px + var(--sr)); width: min(300px, calc(100vw - 160px)); max-height: calc(100vh - 160px - var(--st) - var(--sb)); }
  .ws-pixel .wsx-panel-tab { display: none !important; }
  .ws-pixel .wsx-panel-body { display: none; }
  .ws-pixel .wsx-panel.open .wsx-panel-body { display: flex; }
  .ws-pixel .px-col { display: flex; flex-direction: column; gap: 5px; position: fixed; z-index: 10; right: calc(8px + var(--sr)); top: calc(78px + var(--st)); bottom: calc(8px + var(--sb)); width: 46px; padding: 5px; overflow-y: auto; border-radius: 18px; background: rgba(255, 255, 255, 0.92); box-shadow: var(--shadow); scrollbar-width: none; }
  .ws-pixel .px-col::-webkit-scrollbar { display: none; }
  .ws-pixel .px-col .px-sw { width: 36px; height: 36px; flex: none; }
  .wsx.ws-pixel.empty .px-col { visibility: hidden; }
}

/* voxel builder */
.ws-voxel .vx-info { font-variant-numeric: tabular-nums; min-width: 92px; cursor: pointer; }
.ws-voxel .wsx-panel { max-height: calc(100vh - 250px - var(--st) - var(--sb)); }
.ws-voxel .vx-mx.on { background: #ece6ff; color: var(--accent-d); }
.ws-voxel .vx-seg button { white-space: nowrap; }
.ws-voxel .vx-swempty { grid-column: 1 / -1; margin: 4px 4px 6px; font-size: 13px; color: var(--muted); }
.ws-voxel .vx-addcol[hidden] { display: none; }
/* three sizes on a two-column phone grid: the last one sits centred under the others */
@media (max-width: 560px) { .vx-size-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 6px); } }
/* the long ⋯ menu scrolls on short screens (landscape phones couldn't reach Main menu) */
/* a short panel scrolls rather than squashing its rows (the palette button used to vanish) */
.ws-voxel .wsx-panel-body > * { flex-shrink: 0; }
@media (max-height: 500px) and (min-width: 761px) {
  .ws-voxel .wsx-opts .opt-label { display: none; }
  .ws-voxel .wsx-panel { width: 240px; max-height: calc(100vh - 250px - var(--st) - var(--sb)); }
  .ws-voxel .px-cursw { width: 32px; height: 32px; border-radius: 10px; }
}
@media (max-width: 760px) {
  .ws-voxel .wsx-panel { right: calc(62px + var(--sr)); bottom: calc(160px + var(--sb)); width: min(300px, calc(100vw - 80px)); max-height: 52vh; }
  .ws-voxel .wsx-panel-tab { display: none; }
  .ws-voxel .wsx-panel.open .wsx-panel-tab { display: inline-flex; }
  .ws-voxel .px-col { bottom: calc(160px + var(--sb)); }
  .ws-voxel .vx-info { display: none; }
  /* Box and Extrude modes and the camera views keep their words: icons alone would be guesswork */
  .ws-voxel .wsx-opts .vx-seg button span, .ws-voxel .wsx-opts .pill.vx-lbl span { display: inline; }
  .ws-voxel .wsx-opts .vx-seg button { padding: 0 11px; }
  .ws-voxel .wsx-opts .pill.vx-lbl .ic { display: none; }
}
.v-fmt button { white-space: nowrap; }
@media (max-width: 480px) { .v-fmt .v-long { display: none; } .v-fmt button { padding: 0 11px; } }
@media (max-width: 480px) {
  /* every tool fits across the phone, no hidden scrolling */
  .ws-voxel .wsx-dock { width: calc(100vw - 16px - var(--sl) - var(--sr)); }
  .ws-voxel .wsx-dock .tool-btn { flex: 1 1 0; width: auto; min-width: 0; }
  .ws-voxel .wsx-opts .vx-seg button .ic { display: none; }
}

/* pattern maker */
.pt-style-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .pt-style-grid { grid-template-columns: repeat(2, 1fr); } }
.menu-note { margin: 14px 0 0; text-align: center; font-size: 14px; color: var(--muted); }
.pt-tsize { margin: 12px auto 0; width: max-content; }
.ws-pattern .pt-chip { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 800; color: var(--ink); }
.ws-pattern .pt-chip .ic { width: 18px; height: 18px; color: var(--accent); }
.ws-pattern .pt-chip.on { background: #ece6ff; color: var(--accent-d); }
.pt-bgsw { width: 26px; height: 26px; border-radius: 9px; display: block; box-shadow: inset 0 0 0 2px rgba(42, 36, 64, 0.18); }
.pt-shapes button { padding: 0 9px; }
.pt-shapes button .ic { width: 20px; height: 20px; }
.pt-brushes button { padding: 0 14px; font-size: 14px; }
.pt-preview img { box-shadow: 0 4px 18px rgba(42, 36, 64, 0.16); border-radius: 6px; }
.pt-short { display: none; }
@media (max-width: 480px) { .pt-long { display: none; } .pt-short { display: inline; } }
.ws-pattern .ph-optsl .pt-slic { display: none; width: 20px; height: 20px; color: var(--muted); }
@media (max-width: 760px) {
  .ws-pattern .ph-optsl .pt-slic { display: block; }
  .ws-pattern .pt-chip span { display: none; }
  .ws-pattern .pt-chip { padding: 0 11px; }
  .ws-pattern .wsx-top [data-a=help], .ws-pattern .pt-bg { display: none; }
}
/* sideways phone: the rail starts under the palette (the background color is in the menu) */
@media (max-height: 520px) and (orientation: landscape) {
  .ws-pattern .wsx-rail { top: calc(96px + var(--st)); transform: none; }
  .ws-pattern .pt-bg { display: none; }
  .ws-pattern .wsx-opts .opts { max-width: calc(100vw - 2 * (78px + max(var(--sl), var(--sr)))); }
}
/* colors in Pixel Art are solid and Pattern Maker sets opacity per tool, so the wheel's opacity row would do nothing */
.ws-pixel .wsx-pal .pal-row:has(.pal-alpha), .ws-pattern .wsx-pal .pal-row:has(.pal-alpha) { display: none; }
/* long menus scroll on a phone held sideways instead of running off the screen */
.px-layers .pill:disabled { opacity: 0.4; }
/* greyed-out undo / redo stay solid, so the busy picture behind doesn't show through them */
.ws-pixel .wsx-rail .btn:disabled, .ws-pattern .wsx-rail .btn:disabled { opacity: 1; background: #f7f5fc; color: #cbc6da; box-shadow: 0 2px 0 var(--press), 0 4px 12px rgba(42, 36, 64, 0.06); }

/* ================================================================ 3D: Blender-style navigation and modal transforms */
.w3-navgiz { position: fixed; top: calc(84px + var(--st)); right: calc(278px + var(--sr)); z-index: 9; display: flex; flex-direction: column; align-items: center; gap: 6px; user-select: none; -webkit-user-select: none; }
.ng-ball { display: block; width: 92px; height: 92px; border-radius: 50%; cursor: grab; touch-action: none; }
.ng-ball:active { cursor: grabbing; }
.ng-btns { display: flex; gap: 6px; }
.ng-btn { width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, 0.78); box-shadow: 0 2px 6px rgba(42, 36, 64, 0.12); display: grid; place-items: center; color: #4d466a; cursor: grab; touch-action: none; transition: background 0.15s, color 0.15s; }
.ng-btn .ic { width: 16px; height: 16px; }
.ng-btn:hover { background: #fff; color: var(--ink); }
.ng-btn.on { background: var(--accent); color: #fff; }
.ws3d[data-bd='night'] .ng-btn:not(.on) { background: rgba(255, 255, 255, 0.16); color: #e9e4ff; }
.ws3d.panel-open .w3-navgiz { opacity: 0.35; }
@media (max-width: 760px) { .w3-navgiz { right: calc(10px + var(--sr)); } }
@media (pointer: coarse) and (max-width: 900px), (max-height: 500px) { .w3-navgiz { display: none; } }
.w3-modal-hud {
  position: fixed;
  left: 50%;
  top: calc(84px + var(--st));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 16px 7px;
  border-radius: 14px;
  background: rgba(28, 24, 44, 0.88);
  color: #fff;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(28, 24, 44, 0.25);
}
.w3-modal-hud .hud-main { display: flex; align-items: baseline; gap: 10px; }
.w3-modal-hud .op { font-weight: 900; }
.w3-modal-hud b { font-weight: 900; }
.w3-modal-hud small { opacity: 0.62; font-size: 11.5px; }
.w3-modal-hud .num { color: #ffd84d; }
.w3-modal-hud .ax-x { color: #ff7d93; }
.w3-modal-hud .ax-y { color: #84e693; }
.w3-modal-hud .ax-z { color: #7cb1ff; }
.w3-prop-ring { position: fixed; display: none; border-radius: 50%; border: 1.5px dashed rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 1px rgba(42, 36, 64, 0.35); pointer-events: none; z-index: 19; }
.ws3d.modal-on .w3-tipline, .ws3d.modal-on .w3-opts { opacity: 0; pointer-events: none; }

/* ================================================================ 3D: pro menus, menu bar, command search, Edit Mode */
.pmx-layer { position: fixed; inset: 0; z-index: 70; }
.pmx {
  position: fixed; min-width: 230px; max-width: 360px; max-height: calc(100vh - 12px); overflow-y: auto; overscroll-behavior: contain;
  padding: 5px; border-radius: 13px; background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 40px rgba(28, 22, 56, 0.26), 0 1px 3px rgba(28, 22, 56, 0.12), inset 0 0 0 1px rgba(42, 36, 64, 0.06);
  opacity: 0; transform: translateY(-3px); transition: opacity 0.09s, transform 0.12s; scrollbar-width: thin;
  font-weight: 750;
}
.pmx.show { opacity: 1; transform: none; }
.pmx-title { padding: 6px 10px 4px; font-size: 11px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--accent); }
.pmx-head { padding: 7px 10px 3px; font-size: 10.5px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--muted); }
.pmx-sep { height: 1px; margin: 4px 6px; background: #ece9f4; }
.pmx-it { display: flex; align-items: center; gap: 9px; width: 100%; height: 30px; padding: 0 9px 0 7px; border-radius: 8px; font-size: 13.5px; text-align: left; color: var(--ink); white-space: nowrap; }
.pmx-it.hi:not(:disabled), .pmx-it:focus-visible { background: var(--accent); color: #fff; outline: none; }
.pmx-it.hi .pmx-k, .pmx-it.hi .pmx-ic { color: rgba(255, 255, 255, 0.85); }
.pmx-it:disabled { opacity: 0.38; cursor: default; }
.pmx-it.danger { color: var(--red-d); }
.pmx-it.danger.hi { background: var(--red); color: #fff; }
.pmx-ic, .pmx-ck { width: 17px; height: 17px; flex: none; display: grid; place-items: center; color: #8a83a3; }
.pmx-ic .ic, .pmx-ck .ic { width: 16px; height: 16px; }
.pmx-ck { border-radius: 5px; box-shadow: inset 0 0 0 1.5px #cfc9e2; }
.pmx-ck.on { background: var(--accent); color: #fff; box-shadow: none; }
.pmx-ck.on .ic { width: 13px; height: 13px; stroke-width: 3; }
.pmx-l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pmx-k { margin-left: 14px; font-size: 12px; color: #9a94b2; font-weight: 700; letter-spacing: 0.3px; }
.pmx-arrow { display: grid; place-items: center; color: #9a94b2; }
.pmx-arrow .ic { width: 14px; height: 14px; }
.pmx-it.hi .pmx-arrow { color: #fff; }

.w3-bar { position: fixed; z-index: 11; left: calc(86px + var(--sl)); top: calc(14px + var(--st)); display: none; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; }
.ws3d.pro .w3-bar { display: flex; }
.w3-bar > * { pointer-events: auto; }
.w3-menubar, .w3-head { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 13px; background: rgba(255, 255, 255, 0.9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: 0 4px 14px rgba(42, 36, 64, 0.12); }
.mb-t { height: 32px; padding: 0 11px; border-radius: 9px; font-size: 13.5px; color: #4d466a; display: inline-flex; align-items: center; gap: 6px; font-weight: 800; }
.mb-t .ic { width: 16px; height: 16px; }
.mb-t:hover { background: #f1eef9; color: var(--ink); }
.mb-t.on { background: var(--accent); color: #fff; }
.mb-t:first-child { background: #f3f0fb; color: var(--accent-d); }
.mb-t:first-child.on { background: var(--accent); color: #fff; }
.ws3d.editing .mb-t:first-child { background: #fff0dc; color: #b35a00; }
.ws3d.editing .mb-t:first-child.on { background: #ff8a1f; color: #fff; }
.w3-head .hb { width: 32px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #6a6386; }
.w3-head .hb .ic { width: 19px; height: 19px; }
.w3-head .hb:hover { background: #f1eef9; color: var(--ink); }
.w3-head .hb.on { background: var(--accent); color: #fff; }
.ws3d.editing .w3-head .hb.on.sm { background: #ff8a1f; }
.w3-head .hsep { width: 1px; height: 20px; margin: 0 4px; background: #e4e0f0; }
.w3-head .hlbl { font-size: 11px; color: var(--muted); padding: 0 4px 0 6px; letter-spacing: 0.4px; }
.w3-stats { font-size: 11.5px; color: rgba(42, 36, 64, 0.72); padding: 2px 6px; font-weight: 800; font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6); pointer-events: none !important; white-space: pre; line-height: 1.45; }
.ws3d[data-bd='night'] .w3-stats { color: rgba(240, 236, 255, 0.8); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.w3-stats b { color: #ff8a1f; font-weight: 900; }

.cmd-layer { position: fixed; inset: 0; z-index: 80; background: rgba(28, 24, 44, 0.18); opacity: 0; transition: opacity 0.12s; }
.cmd-layer.show { opacity: 1; }
.cmd-box { position: absolute; left: 50%; top: calc(80px + var(--st)); transform: translateX(-50%); width: min(560px, calc(100vw - 24px)); border-radius: 16px; background: #fff; box-shadow: 0 24px 60px rgba(28, 22, 56, 0.3); overflow: hidden; }
.cmd-in { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid #efecf6; }
.cmd-in .ic { width: 20px; height: 20px; color: var(--accent); }
.cmd-in input { flex: 1; height: 52px; border: 0; outline: none; font: inherit; font-size: 17px; font-weight: 800; color: var(--ink); background: none; user-select: text; -webkit-user-select: text; }
.cmd-list { max-height: min(420px, 60vh); overflow-y: auto; padding: 5px; }
.cmd-it { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border-radius: 9px; text-align: left; font-size: 14px; }
.cmd-it.hi { background: var(--accent); color: #fff; }
.cmd-it.hi .cmd-p, .cmd-it.hi .pmx-k { color: rgba(255, 255, 255, 0.8); }
.cmd-it:disabled { opacity: 0.4; }
.cmd-l { white-space: nowrap; }
.cmd-p { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--muted); font-weight: 700; }
.cmd-none { padding: 16px; color: var(--muted); font-size: 14px; text-align: center; }

.w3-box { position: fixed; z-index: 15; border: 1.5px dashed rgba(42, 36, 64, 0.75); background: rgba(255, 255, 255, 0.12); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5); pointer-events: none; }
.w3-box.sub { border-color: #ff4d5e; background: rgba(255, 77, 94, 0.08); }
.ws3d.editing .w3-canvas { cursor: default; }
.ws3d.loopcut .w3-canvas { cursor: crosshair; }
.ws3d .w3-opts .pill.mode { padding: 0 12px; }
.ws3d.editing .w3-opts .pill.mode.on { background: #ff8a1f; color: #fff; }
.ws3d.editing .w3-dock .tool-btn.ed-op .ic { color: #ff8a1f; }
.ws3d.editing .w3-dock .tool-btn.ed-op:active .ic { color: #fff; }
/* the edit dock has more buttons: narrower on small screens */
@media (max-width: 900px) { .ws3d.editing .w3-dock .tool-btn span { display: none; } }
.ws3d.pro .w3-hint { top: 60%; }
.w3-shade .w3-seg { flex: 1; height: 32px; padding: 3px; border-radius: 11px; }
.w3-shade .w3-seg button { height: 26px; font-size: 12.5px; border-radius: 8px; }
.w3-asrow b { font-size: 12px; color: var(--muted); width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.w3-asrow > span { width: 74px; }
.w3-asrow.hidden { display: none; }
.ws3d.no-side .w3-panel { display: none; }
.ws3d.no-side .w3-navgiz { right: calc(14px + var(--sr)); }
.w3-nrow input:disabled { opacity: 0.45; }
.w3-shade > span { width: 56px !important; }
.w3-shade .w3-seg button { padding: 0 4px; }
.ws3d.pro .w3-viewchip { display: none; }
@media (max-width: 1180px) {
  .mb-t { padding: 0 8px; font-size: 13px; }
  .mb-t .ic { display: none; }
}
/* properties: sections (Advanced) */
.w3-sec { border-top: 2px solid #f1eff8; margin: 4px -2px 0; padding: 2px 2px 4px; }
.w3-sec > summary { list-style: none; display: flex; align-items: center; gap: 6px; padding: 6px 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.2px; color: #6a6386; cursor: pointer; }
.w3-sec > summary::-webkit-details-marker { display: none; }
.w3-sec > summary::before { content: ''; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform 0.15s; margin: 0 3px 0 2px; }
.w3-sec[open] > summary::before { transform: rotate(45deg); }
.w3-sec > summary:hover { color: var(--accent); }
.w3-cnt { font-style: normal; font-size: 10.5px; padding: 0 6px; border-radius: 6px; background: #ece6ff; color: var(--accent-d); letter-spacing: 0; }
.w3-mods { display: flex; flex-direction: column; gap: 6px; padding: 2px 0 4px; }
.w3-mod { border-radius: 12px; background: #f7f5fc; box-shadow: inset 0 0 0 1px #ece8f6; overflow: hidden; }
.w3-mod.off { opacity: 0.6; }
.w3-mh { display: flex; align-items: center; gap: 2px; padding: 4px 4px 4px 2px; font-size: 13px; }
.w3-mh b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; }
.w3-mic { width: 18px; height: 18px; display: grid; place-items: center; color: var(--accent); margin-right: 3px; }
.w3-mic .ic { width: 16px; height: 16px; }
.w3-mfold { width: 20px; height: 24px; display: grid; place-items: center; color: #8a83a3; }
.w3-mfold .ic { width: 13px; height: 13px; transform: rotate(90deg); transition: transform 0.15s; }
.w3-mod.fold .w3-mfold .ic { transform: none; }
.w3-mod.fold .w3-mbody { display: none; }
.w3-mb { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; color: #9a94b2; }
.w3-mb .ic { width: 14px; height: 14px; }
.w3-mb:hover:not(:disabled) { background: #ebe6f8; color: var(--ink); }
.w3-mb.on { color: var(--accent); }
.w3-mb.x:hover { color: var(--red-d); }
.w3-mb:disabled { opacity: 0.3; }
.w3-mb[data-ma=up] .ic { transform: rotate(90deg); }
.w3-mbody { padding: 0 8px 7px; display: flex; flex-direction: column; gap: 3px; }
.w3-mrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; color: #4d466a; min-height: 26px; }
.w3-mrow > span { flex: 1; min-width: 0; }
.w3-nf { width: 84px; flex: none; font: inherit; font-size: 12.5px; font-weight: 800; text-align: center; color: var(--ink); border: 0; border-radius: 7px; padding: 4px 4px; background: #fff; box-shadow: inset 0 0 0 1.5px #e6e1f3; cursor: ew-resize; font-variant-numeric: tabular-nums; user-select: none; -webkit-user-select: none; }
.w3-nf:focus { outline: none; cursor: text; box-shadow: inset 0 0 0 2px var(--accent); user-select: text; -webkit-user-select: text; }
.w3-nf.scrub { background: #ece6ff; }
.w3-mrow select { font: inherit; font-size: 12.5px; font-weight: 800; color: var(--ink); border: 0; border-radius: 7px; padding: 3px 6px; background: #fff; box-shadow: inset 0 0 0 1.5px #e6e1f3; max-width: 120px; }
.w3-ax { display: flex; gap: 3px; }
.w3-ax button { width: 26px; height: 24px; border-radius: 7px; font-size: 11.5px; font-weight: 900; background: #fff; box-shadow: inset 0 0 0 1.5px #e6e1f3; color: #8a83a3; }
.w3-ax button.on.ax-x { background: #ff4d5e; color: #fff; box-shadow: none; }
.w3-ax button.on.ax-y { background: #22c070; color: #fff; box-shadow: none; }
.w3-ax button.on.ax-z { background: #2f7dff; color: #fff; box-shadow: none; }
.switch.sm { transform: scale(0.72); transform-origin: right; }
.w3-merr { margin: 0 8px 6px; padding: 4px 8px; border-radius: 8px; background: #ffe8ea; color: var(--red-d); font-size: 11.5px; line-height: 1.3; }
.w3-addmod { align-self: flex-start; height: 32px; padding: 0 12px; font-size: 12.5px; gap: 6px; }
.w3-addmod .ic { width: 15px; height: 15px; }
.ws3d.pro .w3-panel { width: 272px; }
.ws3d.pro .w3-navgiz { right: calc(300px + var(--sr)); }
/* a computer's panel: compact sliders in the sections */
.ws3d.pro .w3-sec .w3-row { padding: 1px 4px; font-size: 13px; }
.ws3d.pro .w3-sec .hslider { height: 26px; }
.ws3d.pro .w3-sec .hslider .sl-track { inset: 6px 0; border-radius: 8px; }
.ws3d.pro .w3-sec .hslider .sl-thumb { width: 26px; height: 26px; left: calc(var(--f, 0) * (100% - 26px)); }
.ws3d.pro .w3-sec .hslider .sl-thumb span { transform: scale(0.62); }
.w3-head .hb.hw { width: auto; padding: 0 9px 0 7px; gap: 5px; display: inline-flex; font-size: 12.5px; font-weight: 800; }
.w3-head .hb.hw .ic { width: 16px; height: 16px; }
.w3-snapmark { position: fixed; display: none; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1.5px #ff8a1f, 0 0 10px rgba(255, 138, 31, 0.8); pointer-events: none; z-index: 19; }
/* Render Image */
.w3-render { position: fixed; inset: 0; z-index: 75; display: grid; place-items: center; background: rgba(28, 24, 44, 0.45); padding: 16px; }
.w3r-card { width: min(1100px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 22px; background: #fff; box-shadow: 0 30px 80px rgba(20, 10, 50, 0.4); }
.w3r-head { display: flex; align-items: center; gap: 10px; }
.w3r-head b { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; }
.w3r-head b .ic { width: 20px; height: 20px; color: var(--accent); }
.w3r-n { flex: 1; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.w3r-view { position: relative; min-height: 0; flex: 1; border-radius: 14px; overflow: hidden; background: #f1eff8; display: grid; place-items: center; }
.w3r-cv { display: block; max-width: 100%; max-height: calc(100vh - 170px); width: auto; height: auto; }
.w3r-wait { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 15px; background: rgba(255, 255, 255, 0.55); }
.w3r-wait .ic { width: 34px; height: 34px; color: var(--accent); animation: w3spin 2.4s linear infinite; }
@keyframes w3spin { to { transform: rotate(360deg); } }
.w3-render.busy .w3r-wait { display: flex; }
.w3r-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(123, 92, 255, 0.15); }
.w3r-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.w3r-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.w3r-foot .seg { margin-right: auto; }
.w3r-foot .seg button { padding: 0 14px; }
.ws3d.drop-on::after { content: 'Drop a .glb, .gltf, .obj or .stl to open it'; position: fixed; inset: 12px; border: 3px dashed var(--accent); border-radius: 28px; display: grid; place-items: center; font-size: 22px; color: var(--accent-d); background: rgba(255, 255, 255, 0.55); pointer-events: none; z-index: 40; }
/* Sculpt Mode */
.w3-sculpt-ring { position: fixed; display: none; transform: translate(-50%, -50%); border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.95); box-shadow: 0 0 0 1px rgba(42, 36, 64, 0.45), inset 0 0 0 1px rgba(42, 36, 64, 0.2); pointer-events: none; z-index: 19; }
.w3-sculpt-ring.adjust { background: radial-gradient(circle, rgba(123, 92, 255, calc(var(--s, 0.5) * 0.5)) 0%, transparent 70%); }
.w3-sculpt-ring.adjust::after { content: attr(data-label); position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 3px 8px; border-radius: 8px; background: rgba(28, 24, 44, 0.85); color: #fff; font-size: 13px; white-space: nowrap; }
.ws3d.sculpting .w3-canvas { cursor: crosshair; }
.ws3d.sculpting .mb-t:first-child { background: #e3f6ff; color: #0f6f9c; }
.sc-sl { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 22px; background: #fff; box-shadow: 0 2px 0 var(--press), 0 4px 12px rgba(42, 36, 64, 0.08); font-size: 13px; flex: none; }
.sc-sl .w3-sl { width: 120px; }
.sc-sl .hslider { height: 30px; }
.sc-sl .hslider .sl-track { inset: 9px 0; }
.sc-sl .hslider .sl-thumb { width: 30px; height: 30px; left: calc(var(--f, 0) * (100% - 30px)); }
.sc-sl .hslider .sl-thumb span { transform: scale(0.65); }
.sc-sl b { width: 38px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.ws3d.sculpting .w3-dock .tool-btn.sc-br .ic { color: #0f8fc9; }
.ws3d.sculpting .w3-dock .tool-btn.sc-br.on { background: #19a3e0; box-shadow: 0 4px 0 #0f6f9c; }
.ws3d.sculpting .w3-dock .tool-btn.sc-br.on .ic { color: #fff; }
@media (max-width: 1000px) { .ws3d.sculpting .w3-dock .tool-btn span { display: none; } }
.w3-m3 { flex-wrap: wrap; }
.w3-n3 { display: flex; gap: 3px; }
.w3-n3 .w3-nf { width: 52px; font-size: 11.5px; padding: 4px 2px; }
.w3-n3 .w3-nf.ax-x { box-shadow: inset 0 0 0 1.5px #e6e1f3, inset 0 -2px 0 #ff4d5e66; }
.w3-n3 .w3-nf.ax-y { box-shadow: inset 0 0 0 1.5px #e6e1f3, inset 0 -2px 0 #22c07066; }
.w3-n3 .w3-nf.ax-z { box-shadow: inset 0 0 0 1.5px #e6e1f3, inset 0 -2px 0 #2f7dff66; }

/* ================================================================ Faces and Bodies: the character studio (js/m3d-char*.js) */
.ws3d.ch-on .w3-hint { display: none; }
.ws3d.ch-loading::after { content: 'Getting the studio ready…'; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 14px 22px; border-radius: 20px; background: rgba(255, 255, 255, 0.9); color: var(--muted); font-size: 17px; box-shadow: var(--shadow); }

/* the stages, along the top */
.ch-stages { position: fixed; z-index: 11; left: calc(100px + var(--sl)); top: calc(14px + var(--st)); display: flex; gap: 4px; padding: 5px; border-radius: 22px; background: rgba(255, 255, 255, 0.92); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow); }
.ch-stage { display: inline-flex; align-items: center; gap: 7px; height: 46px; padding: 0 15px 0 12px; border-radius: 17px; color: var(--muted); font-size: 15px; font-weight: 800; transition: background 0.15s, color 0.15s, transform 0.08s; }
.ch-stage .ic { width: 22px; height: 22px; }
.ch-stage:hover { background: #f1eff8; }
.ch-stage:active { transform: scale(0.96); }
.ch-stage.on { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-d); }
/* Advanced on a computer: the menu bar keeps the top row, the stages take the second, the header row the third
   (the counts it would print are in the stage panels) */
.ws3d.pro .ch-stages { top: calc(60px + var(--st)); left: calc(86px + var(--sl)); }
.ws3d.pro.ch-on .w3-head { margin-top: 62px; }
.ws3d.pro.ch-on .w3-stats { display: none; }
/* not much room beside the top bar: only the stage you're in keeps its name */
@media (min-width: 900px) and (max-width: 1239px) { .ws3d:not(.pro) .ch-stage:not(.on) span { display: none; } .ws3d:not(.pro) .ch-stage:not(.on) { padding: 0 12px; } }

/* the panel on the left: what the stage has to offer */
.ch-side { position: fixed; z-index: 10; left: calc(86px + var(--sl)); top: calc(84px + var(--st)); width: 292px; max-height: calc(100vh - 270px - var(--st) - var(--sb)); display: flex; flex-direction: column; align-items: flex-start; }
.ws3d.pro .ch-side { top: calc(170px + var(--st)); max-height: calc(100vh - 440px - var(--st) - var(--sb)); }
.ws3d[data-ch-stage='rig'] .ch-side { max-height: calc(100vh - 200px - var(--st) - var(--sb)); }
.ws3d.pro[data-ch-stage='rig'] .ch-side, .ws3d.pro[data-ch-stage='shape'] .ch-side, .ws3d.pro[data-ch-stage='edit'] .ch-side { max-height: calc(100vh - 370px - var(--st) - var(--sb)); }
.ws3d.pro[data-ch-stage='animate'] .ch-side { max-height: calc(100vh - 460px - var(--st) - var(--sb)); }
.ws3d[data-ch-stage='animate'] .ch-side { max-height: calc(100vh - 290px - var(--st) - var(--sb)); }
.ch-side-tab { display: none; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); font-size: 14px; font-weight: 800; color: var(--ink); margin-bottom: 8px; flex: none; }
.ch-side-tab .ic { width: 18px; height: 18px; color: var(--accent); }
.ch-side-body { width: 100%; background: rgba(255, 255, 255, 0.95); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border-radius: 22px; box-shadow: var(--shadow); padding: 12px 12px 14px; overflow: auto; min-height: 0; overscroll-behavior: contain; scrollbar-width: thin; }
.ch-side h4 { margin: 14px 4px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); display: flex; align-items: baseline; gap: 6px; }
.ch-side h4:first-child { margin-top: 2px; }
.ch-side h4 small { font-size: 11px; letter-spacing: 0; color: var(--muted); font-weight: 700; }
.ch-tip { margin: 8px 4px 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.ch-tip b { color: var(--ink); }
.ch-note { display: grid; grid-template-columns: 26px 1fr; gap: 6px 10px; align-items: start; padding: 12px; border-radius: 16px; background: #fff6df; color: #6b4a00; font-size: 13px; line-height: 1.45; margin-top: 10px; }
.ch-note .ic { width: 24px; height: 24px; }
.ch-note p { margin: 0; }
.ch-note .ch-btn { grid-column: 2; justify-self: start; }
.ch-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.ch-chip { height: 36px; padding: 0 13px; border-radius: 18px; background: #f1eff8; color: var(--ink); font-size: 14px; font-weight: 700; transition: background 0.15s, color 0.15s, transform 0.08s; }
.ch-chip:hover { background: #e6e1f7; }
.ch-chip:active { transform: scale(0.95); }
.ch-chip.on { background: var(--accent); color: #fff; }
.ch-sl { display: grid; grid-template-columns: 92px 1fr 46px; align-items: center; gap: 8px; height: 38px; padding: 0 4px; font-size: 13px; }
.ch-sl > span { color: var(--ink); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sl > b { text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ch-sl .hslider { height: 30px; }
.ch-sl .hslider .sl-track { inset: 10px 0; }
.ch-sl .hslider .sl-thumb { width: 30px; height: 30px; left: calc(var(--f, 0) * (100% - 30px)); }
.ch-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 14px 0 11px; border-radius: 14px; background: #f1eff8; color: var(--ink); font-size: 14px; font-weight: 800; transition: background 0.15s, color 0.15s, transform 0.08s; }
.ch-btn .ic { width: 20px; height: 20px; flex: none; }
.ch-btn:hover { background: #e6e1f7; }
.ch-btn:active { transform: scale(0.96); }
.ch-btn.on { background: var(--accent); color: #fff; }
.ch-btn:disabled { opacity: 0.45; }
.ch-btn.wide { flex: 1; min-height: 46px; background: #fff; box-shadow: 0 3px 0 var(--press), 0 4px 12px rgba(42, 36, 64, 0.08); }
.ch-btn.wide .ic { color: var(--accent); }
.ch-pick { padding: 0 8px 0 12px; max-width: 170px; }
.ch-pick .ic { width: 16px; height: 16px; transform: rotate(90deg); color: var(--muted); }
.ch-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.ch-next { display: flex; gap: 8px; margin-top: 14px; }
.ch-poly { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.ch-poly > b { text-align: center; font-size: 17px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.ch-poly > b small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
.ch-seg { display: flex; width: 100%; }
.ch-seg button { flex: 1; height: 38px; padding: 0 6px; font-size: 14px; font-weight: 800; }
.ch-tools { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ch-tool { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: 58px; border-radius: 14px; background: #f1eff8; color: var(--ink); font-size: 11px; font-weight: 800; transition: background 0.15s, transform 0.08s; }
.ch-tool .ic { width: 24px; height: 24px; color: var(--accent); }
.ch-tool:hover { background: #e6e1f7; }
.ch-tool:active { transform: scale(0.94); }
.ch-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 232px; overflow: auto; scrollbar-width: thin; border-radius: 12px; }
.ch-list.ch-parts { max-height: 150px; }
.ch-list li { display: flex; gap: 2px; }
.ch-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 10px; border-radius: 11px; font-size: 14px; color: var(--ink); text-align: left; }
.ch-item:hover { background: #f1eff8; }
.ch-item.on { background: #ece7ff; color: var(--accent-d); font-weight: 800; }
.ch-item span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-item em { font-style: normal; font-size: 12px; color: var(--muted); white-space: nowrap; }
.ch-item .ic { width: 17px; height: 17px; color: var(--accent); flex: none; }
.ch-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 2px rgba(20, 16, 40, 0.55); }
.ch-dot.bone { background: #ff9a2e; }
.ch-dot.soft { background: #2fc3ff; }
.ch-dot.rigid { background: #b57bff; }
.ch-dot.off { background: #c9c5d8; }
.ch-x { width: 34px; height: 34px; border-radius: 11px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.ch-x:hover { background: #ffe9ec; color: var(--red-d); }
.ch-x .ic { width: 17px; height: 17px; }
.ch-field { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 8px; min-height: 40px; padding: 0 4px; font-size: 13px; }
.ch-field > span { color: var(--muted); font-weight: 700; }
.ch-field > b { font-size: 13px; font-weight: 700; }
.ch-field .ch-pick { justify-self: start; }
.ch-name { width: 100%; height: 36px; padding: 0 10px; border-radius: 11px; border: 2px solid var(--line); background: #fff; font: inherit; font-size: 14px; font-weight: 700; color: var(--ink); outline: none; }
.ch-name:focus { border-color: var(--accent); }

/* Rig and Animate work on the model itself: the scene list steps aside */
.ws3d[data-ch-stage='rig'] .w3-panel, .ws3d[data-ch-stage='animate'] .w3-panel, .ws3d[data-ch-stage='rig'] .pal3d, .ws3d[data-ch-stage='animate'] .pal3d { display: none; }
.ws3d[data-ch-stage='rig'] .w3-sunbtn, .ws3d[data-ch-stage='animate'] .w3-sunbtn { display: none; }
.ws3d.ch-on .w3-dock .tool-btn:disabled { opacity: 0.35; }

.ws3d[data-ch-stage='animate'] .w3-tipline { bottom: calc(172px + var(--sb)); }
/* the timeline (Animate) */
.ch-time { position: fixed; z-index: 10; left: 50%; bottom: calc(104px + var(--sb)); transform: translate(-50%, 10px); width: min(880px, calc(100vw - 24px)); display: none; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 24px; background: rgba(255, 255, 255, 0.93); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: var(--shadow); }
.ch-time.show { display: flex; transform: translate(-50%, 0); }
.ch-tb { height: 44px; min-width: 44px; padding: 0 10px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; color: var(--ink); background: #f1eff8; font-size: 14px; font-weight: 800; flex: none; transition: background 0.15s, color 0.15s, transform 0.08s; }
.ch-tb .ic { width: 22px; height: 22px; }
.ch-tb:active { transform: scale(0.94); }
.ch-tb:disabled { opacity: 0.4; }
.ch-tb.on { background: var(--accent); color: #fff; }
.ch-play { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-d); }
.ch-cap { background: #fff0f2; color: var(--red-d); }
.ch-capturing .ch-cap { background: var(--red); color: #fff; }
.ch-clip { display: grid; grid-template-columns: 1fr 16px; grid-template-rows: auto auto; align-items: center; column-gap: 6px; height: 44px; width: 168px; padding: 0 8px 0 12px; border-radius: 16px; background: #f1eff8; text-align: left; flex: none; }
.ch-clip b { font-size: 14px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: end; }
.ch-clip small { grid-column: 1; font-size: 11px; color: var(--muted); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: start; }
.ch-clip .ic { grid-column: 2; grid-row: 1 / 3; width: 16px; height: 16px; transform: rotate(-90deg); color: var(--muted); }
.ch-track { position: relative; flex: 1; min-width: 60px; height: 44px; cursor: pointer; touch-action: none; }
.ch-track::before { content: ''; position: absolute; left: 0; right: 0; top: 17px; height: 10px; border-radius: 5px; background: #e6e2f3; }
.ch-track.off { opacity: 0.35; pointer-events: none; }
.ch-fill { position: absolute; left: 0; top: 17px; height: 10px; border-radius: 5px; background: #b9acf5; pointer-events: none; }
.ch-keys i { position: absolute; top: 14px; width: 12px; height: 12px; margin-left: -6px; background: #ffb21f; border: 2px solid #fff; border-radius: 2px; transform: rotate(45deg) scale(1.05); box-shadow: 0 1px 3px rgba(42, 36, 64, 0.3); pointer-events: none; }
.ch-head { position: absolute; top: 6px; width: 6px; height: 32px; margin-left: -3px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(42, 36, 64, 0.3); pointer-events: none; }
.ch-clock { flex: none; min-width: 96px; text-align: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ws3d.ch-exporting .ch-time, .ws3d.ch-exporting .ch-side, .ws3d.ch-exporting .w3-dock, .ws3d.ch-exporting .ch-stages { opacity: 0.35; pointer-events: none; }

/* the capture panel */
div.ch-capbox { position: fixed; z-index: 12; right: calc(14px + var(--sr)); top: calc(84px + var(--st)); width: 286px; max-height: calc(100vh - 200px - var(--st) - var(--sb)); overflow: auto; padding: 12px; border-radius: 22px; background: rgba(255, 255, 255, 0.96); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow); color: var(--ink); display: flex; flex-direction: column; gap: 10px; }
.cc-head { display: flex; align-items: center; gap: 8px; }
.cc-head > b { font-size: 16px; }
.cc-head .seg { margin-left: auto; padding: 3px; border-radius: 14px; }
.cc-head .seg button { height: 32px; min-width: 0; padding: 0 12px; font-size: 13px; font-weight: 800; border-radius: 11px; }
.cc-more { display: none !important; }
.cc-x, .cc-more { flex: none; }
.cc-x { width: 36px !important; min-height: 36px !important; border-radius: 12px !important; box-shadow: none !important; background: #f1eff8 !important; }
.cc-x .ic, .cc-more .ic { width: 18px; height: 18px; }
.cc-view { position: relative; border-radius: 16px; overflow: hidden; background: #1c1830; aspect-ratio: 4 / 3; }
.cc-video, .cc-marks { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cc-marks { pointer-events: none; }
.cc-rec { position: absolute; left: 8px; top: 8px; display: none; align-items: center; gap: 5px; height: 26px; padding: 0 9px 0 6px; border-radius: 13px; background: rgba(0, 0, 0, 0.6); color: #fff; font-size: 12px; font-variant-numeric: tabular-nums; }
.cc-rec .ic { width: 14px; height: 14px; color: #ff4d6a; animation: cc-blink 1s steps(2) infinite; }
div.ch-capbox.recording .cc-rec { display: inline-flex; }
@keyframes cc-blink { 50% { opacity: 0.25; } }
.cc-status { margin: 0; font-size: 13px; font-weight: 700; color: var(--accent-d); min-height: 18px; }
.cc-row { display: flex; flex-wrap: wrap; gap: 6px; }
.cc-row .ch-btn { flex: 1 1 40%; min-width: 0; padding: 0 10px 0 8px; font-size: 13px; }
.cc-row .ch-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-go { min-height: 52px !important; font-size: 17px !important; border-radius: 18px !important; background: var(--red) !important; color: #fff !important; box-shadow: 0 4px 0 var(--red-d) !important; }
.cc-go.rec { background: var(--ink) !important; box-shadow: 0 4px 0 #000 !important; }
.cc-go .ic { width: 22px !important; height: 22px !important; }
.cc-tip { margin: 0; font-size: 12px; line-height: 1.45; color: var(--muted); }

/* night backdrop */
.ws3d[data-bd='night'] .ch-tip b { color: var(--ink); }

/* a long dock (Sculpt's brushes) scrolls sideways on a narrow screen instead of running off both edges */
@media (max-width: 700px) {
  .ws3d .w3-dock { max-width: calc(100vw - 12px); overflow-x: auto; scrollbar-width: none; justify-content: flex-start; overscroll-behavior-x: contain; }
  .ws3d .w3-dock::-webkit-scrollbar { display: none; }
  .ws3d .w3-dock .tool-btn { flex: none; }
}
/* phones: the panel is a sheet you open, the stages a strip under the top bar */
@media (max-width: 899px) {
  .ch-stage:not(.on) span { display: none; }
  .ch-stage:not(.on) { padding: 0 11px; }
  .ch-stages { left: 50%; transform: translateX(-50%); top: calc(76px + var(--st)); max-width: calc(100vw - 16px); overflow-x: auto; scrollbar-width: none; }
  .ch-stages::-webkit-scrollbar { display: none; }
  .ch-stage { height: 40px; padding: 0 12px 0 10px; font-size: 14px; flex: none; }
  .ch-stage .ic { width: 19px; height: 19px; }
  .ch-side { left: 10px; top: calc(132px + var(--st)); width: min(300px, calc(100vw - 20px)); max-height: calc(100vh - 330px - var(--st) - var(--sb)); }
  .ws3d[data-ch-stage='animate'] .ch-side { max-height: calc(100vh - 390px - var(--st) - var(--sb)); }
  .ch-side-tab { display: inline-flex; }
  .ch-side-body { display: none; }
  .ch-side.open .ch-side-body { display: block; }
  .ws3d.ch-on .w3-rail { top: auto; bottom: calc(170px + var(--sb)); }
  .ch-time { bottom: calc(100px + var(--sb)); gap: 5px; padding: 6px; border-radius: 20px; }
  .ch-clip { width: 112px; }
  .ch-clock { display: none; }
  .ch-cap span { display: none; }
  .ch-tb { min-width: 40px; height: 40px; padding: 0 8px; }
  .ch-clip { height: 40px; }
  div.ch-capbox { top: calc(132px + var(--st)); right: 10px; width: min(250px, calc(100vw - 20px)); max-height: calc(100vh - 330px - var(--st) - var(--sb)); }
  /* once it has pictures: a thumbnail, what it sees, and Record (the sliders button brings the rest back) */
  .cc-more { display: inline-flex !important; width: 36px !important; min-height: 36px !important; border-radius: 12px !important; box-shadow: none !important; background: #f1eff8 !important; padding: 0 !important; }
  div.ch-capbox.mini { width: min(212px, calc(100vw - 20px)); padding: 8px; gap: 6px; display: grid; grid-template-columns: 84px 1fr; align-items: center; }
  div.ch-capbox.mini .cc-head { grid-column: 1 / 3; }
  div.ch-capbox.mini .cc-head > b, div.ch-capbox.mini .cc-mode, div.ch-capbox.mini .cc-row, div.ch-capbox.mini .cc-tip { display: none; }
  div.ch-capbox.mini .cc-head { justify-content: flex-end; position: absolute; right: 6px; top: 6px; gap: 4px; }
  div.ch-capbox.mini .cc-head .btn { width: 30px !important; min-height: 30px !important; }
  div.ch-capbox.mini .cc-view { grid-column: 1; grid-row: 1 / 3; border-radius: 10px; }
  div.ch-capbox.mini .cc-status { grid-column: 2; font-size: 11.5px; line-height: 1.25; padding-right: 66px; min-height: 30px; }
  div.ch-capbox.mini .cc-go { grid-column: 2; min-height: 40px !important; font-size: 14px !important; border-radius: 14px !important; padding: 0 8px; }
  div.ch-capbox.mini .cc-go .ic { width: 16px !important; height: 16px !important; }
}
@media (max-width: 899px) and (max-height: 560px) {
  .ch-stages { top: calc(14px + var(--st)); left: calc(70px + var(--sl)); transform: none; max-width: calc(100vw - 330px); }
  .ch-side, div.ch-capbox { top: calc(70px + var(--st)); max-height: calc(100vh - 190px); }
}
.mc-thumb { width: 104px; height: 104px; border-radius: 18px; overflow: hidden; background: #f1eff8; display: block; }
.mc-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mc-mode button { min-width: 110px; }
.mc-lead { margin-top: 4px; }
@media (max-width: 640px) { .mc-thumb { width: 78px; height: 78px; } }

/* ---- Character Studio: the fourth home button, its tools' cards, the polygon budget on export ---- */
.mega-studio { --shade: #5a2bc4; background: linear-gradient(135deg, #a678ff, #6a3df0); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(106, 61, 240, 0.3); }
.title-screen .mega-stack { gap: 14px; }
@media (max-height: 760px) { .title-screen .mega { min-height: 84px; } .title-screen .mega-stack { gap: 11px; } }
.m-poly { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 2px 0 12px; font-weight: 700; }
.m-poly > span { opacity: 0.7; }
.m-poly b { font-weight: 600; opacity: 0.75; font-size: 13px; min-width: 150px; text-align: left; }
.m-poly .seg button { padding: 6px 12px; }
/* the studio's Look stage: parts, materials, effects */
.ch-kinds { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 8px; }
.ch-kinds small { flex: 0 0 100%; font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.5; }
.ch-mat i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.25); }
.ch-color { width: 44px; height: 26px; padding: 0; border: 2px solid rgba(42, 36, 64, 0.25); border-radius: 8px; background: none; cursor: pointer; }
.ch-sl .ch-color { flex: 1; max-width: 120px; }
.ch-fx { border: 2px solid rgba(42, 36, 64, 0.12); border-radius: 12px; padding: 8px 10px 4px; margin: 0 0 8px; }
.ch-fx-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ch-fx-head b { flex: 1; }
.ch-fx-head .icon-btn { width: 30px; height: 30px; min-height: 0; }
.ch-chip svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; }

/* ---- the Stage ---- */
.st-slot { border: 2px solid rgba(42, 36, 64, 0.1); border-radius: 14px; padding: 7px 8px; margin: 0 0 7px; }
.st-slot.full { border-color: rgba(140, 77, 255, 0.35); background: rgba(140, 77, 255, 0.05); }
.st-slot-head { display: flex; align-items: center; gap: 8px; }
.st-slot-head > svg { width: 22px; height: 22px; flex: none; opacity: 0.6; }
.st-slot-head > div { flex: 1; min-width: 0; line-height: 1.15; }
.st-slot-head small { display: block; font-size: 11px; font-weight: 700; opacity: 0.55; }
.st-slot-head b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-slot-head .ch-btn { padding: 0 10px; min-height: 32px; font-size: 13px; }
.st-slot-head .icon-btn { width: 30px; height: 30px; min-height: 0; }
.st-slot .ch-sl { margin-top: 6px; }
.st-opt { justify-content: space-between; align-items: center; padding: 0 4px 6px; font-weight: 700; font-size: 13.5px; }
.st-side { max-height: calc(100vh - 290px - var(--st) - var(--sb)); }
.ws3d[data-ch-stage='animate'] .st-side { top: calc(84px + var(--st)); }
.cc-extra.hidden, .cc-extra .hidden, .cc-mode.hidden { display: none; }

/* ================================================================ Game Kit: the shared workspace */
.kit { position: fixed; inset: 0; z-index: 6; display: flex; flex-direction: column; background: #f3f1f9; color: var(--ink); }
body.kit-on .topbar, body.kit-on .rail, body.kit-on .dock, body.kit-on .palette, body.kit-on .toolopts { visibility: hidden; }
body.kit-on .kit .topbar { visibility: visible; }
.kit-top { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--st)) calc(12px + var(--sr)) 8px calc(12px + var(--sl)); background: #fff; box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(42, 36, 64, 0.05); z-index: 3; min-height: 64px; }
.kit-top .btn { min-height: 44px; border-radius: 14px; font-size: 15px; padding: 0 14px; box-shadow: 0 3px 0 var(--press); }
.kit-top .btn.icon-btn { width: 44px; padding: 0; }
.kit-top .btn .ic { width: 20px; height: 20px; }
.kit-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 1 260px; }
.kit-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(135deg, #4fd1c5, #2b8cff); color: #fff; flex: none; }
.kit-ic .ic { width: 22px; height: 22px; }
.kit-title > div { min-width: 0; display: flex; flex-direction: column; }
.kit-title small { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.kit-name { font: inherit; font-weight: 800; font-size: 16px; border: 0; background: transparent; padding: 1px 4px; margin-left: -4px; border-radius: 6px; color: var(--ink); width: 100%; min-width: 0; text-overflow: ellipsis; }
.kit-name:hover { background: #f3f1f9; }
.kit-name:focus { outline: 2px solid var(--accent); background: #fff; }
.kit-tabs { display: none; margin: 0 auto; flex: none; }
.kit-tabs.show { display: inline-flex; }
.kit-tabs button { height: 38px; font-weight: 800; }
.kit-tabs button .ic + span { margin-left: 6px; }
.kit-acts { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.kit-tabs.show + .kit-acts { margin-left: 0; }
.kit-panel-btn { display: none !important; }
.kit-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 272px minmax(0, 1fr) 300px; }
.kit.no-left .kit-body { grid-template-columns: minmax(0, 1fr) 300px; }
.kit.no-right .kit-body { grid-template-columns: 272px minmax(0, 1fr); }
.kit.no-left.no-right .kit-body { grid-template-columns: minmax(0, 1fr); }
.kit.no-left .kit-left, .kit.no-right .kit-right { display: none; }
.kit-side { background: #fff; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px calc(18px + var(--sb)); scrollbar-width: thin; }
.kit-left { border-right: 1px solid var(--line); padding-left: calc(14px + var(--sl)); }
.kit-right { border-left: 1px solid var(--line); padding-right: calc(14px + var(--sr)); }
.kit-main { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.kit-cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.kit-cv.can-pan { cursor: grab; }
.kit-cv.panning { cursor: grabbing; }
.kit-scrim { display: none; }
/* tablets and phones: the side panels slide over the view */
.kit.narrow .kit-body { grid-template-columns: minmax(0, 1fr) !important; }
.kit.narrow .kit-panel-btn { display: inline-flex !important; }
.kit.narrow.no-left .kit-panel-btn[data-k=left], .kit.narrow.no-right .kit-panel-btn[data-k=right] { display: none !important; }
.kit.narrow .kit-side { display: block !important; position: fixed; top: calc(64px + var(--st)); bottom: 0; width: min(340px, 88vw); z-index: 5; box-shadow: var(--shadow); transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1); }
.kit.narrow .kit-left { left: 0; transform: translateX(-105%); }
.kit.narrow .kit-right { right: 0; transform: translateX(105%); }
.kit.narrow.open-left .kit-left, .kit.narrow.open-right .kit-right { transform: none; }
.kit.narrow.open-left .kit-scrim, .kit.narrow.open-right .kit-scrim { display: block; position: fixed; inset: 0; z-index: 4; background: rgba(42, 36, 64, 0.25); }
@media (max-width: 1180px) { .kit-tabs button span { display: none; } .kit-tabs button .ic + span { margin: 0; } .kit-title { flex-basis: 200px; } }
@media (max-width: 640px) {
  .kit-top { gap: 6px; padding-left: calc(8px + var(--sl)); padding-right: calc(8px + var(--sr)); flex-wrap: wrap; }
  .kit-title { flex: 1 1 0; }
  .kit-title small { display: none; }
  .kit-ic { display: none; }
  .kit-export span, .done-btn span { display: none; }
  .kit-export, .kit-top .done-btn { width: 44px; padding: 0 !important; }
  .kit-help-btn { display: none !important; }
  .kit-tabs.show { order: 5; flex: 1 0 100%; margin: 0; display: flex; overflow-x: auto; }
  .kit-tabs.show button { flex: 1 0 auto; }
  .kit.narrow .kit-side { top: calc(118px + var(--st)); }
  .kit:has(.kit-tabs:not(.show)).narrow .kit-side { top: calc(64px + var(--st)); }
}
/* panel rows */
.kf-h { display: flex; align-items: center; justify-content: space-between; margin: 14px 0 6px; }
.kf-h:first-child { margin-top: 2px; }
.kf-h h4 { margin: 0; font-size: 11.5px; font-weight: 900; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.kf-h .kf-hbtn { font-size: 12.5px; font-weight: 800; color: var(--accent); padding: 4px 6px; border-radius: 8px; }
.kf-h .kf-hbtn:hover { background: #f1eff8; }
.kf-note { margin: 4px 0 10px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.kf-note b { color: var(--ink); }
.kf-row { display: flex; align-items: center; gap: 10px; min-height: 38px; font-size: 14px; font-weight: 700; }
.kf-row > span:first-child { flex: 0 0 96px; color: #4b4566; line-height: 1.15; }
.kf-row.kf-col { flex-direction: column; align-items: stretch; gap: 4px; }
.kf-row.kf-col > span:first-child { flex: none; }
.kf-row input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); height: 28px; }
.kf-row output { flex: 0 0 62px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.kf-row input[type=text], .kf-row input[type=number], .kf-row select, .kf-row textarea { flex: 1; min-width: 0; font: inherit; font-weight: 700; font-size: 14px; border: 2px solid var(--line); border-radius: 10px; padding: 6px 9px; background: #fff; color: var(--ink); }
.kf-row textarea { resize: vertical; line-height: 1.35; }
.kf-row input:focus, .kf-row select:focus, .kf-row textarea:focus { outline: none; border-color: var(--accent); }
.kf-num { flex: 1; display: flex; align-items: center; gap: 6px; }
.kf-num i { font-style: normal; color: var(--muted); font-size: 12.5px; }
.kf-color { flex: 1; display: flex; align-items: center; gap: 8px; }
.kf-color input { width: 44px; height: 30px; border: 2px solid var(--line); border-radius: 9px; padding: 0; background: none; cursor: pointer; }
.kf-color code { font-size: 12.5px; color: var(--muted); }
.kf-row .switch { margin-left: auto; transform: scale(0.82); transform-origin: right center; }
.kf-segrow { flex-wrap: wrap; }
.kf-seg { flex: 1; display: flex; background: #f1eff8; border-radius: 12px; padding: 3px; gap: 3px; min-width: 0; }
.kf-seg button { flex: 1; min-width: 0; height: 32px; border-radius: 9px; font-weight: 800; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 0 6px; white-space: nowrap; }
.kf-seg button .ic { width: 17px; height: 17px; flex: none; }
.kf-seg button.on { background: #fff; color: var(--accent); box-shadow: 0 2px 6px rgba(42, 36, 64, 0.1); }
.kf-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.kf-btn { flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 12px; border-radius: 11px; background: #f1eff8; font-weight: 800; font-size: 13.5px; color: var(--ink); }
.kf-btn:hover:not(:disabled) { background: #e7e3f4; }
.kf-btn:disabled { opacity: 0.45; }
.kf-btn .ic { width: 18px; height: 18px; }
.kf-btn.primary { background: var(--accent); color: #fff; }
.kf-btn.primary:hover:not(:disabled) { background: var(--accent-d); }
.kf-btn.danger { color: var(--red-d); }
.kf-btn.on { background: #fff; color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.kf-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.kf-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px; border-radius: 10px; background: #f1eff8; font-weight: 800; font-size: 13px; color: #4b4566; }
.kf-chip:hover { background: #e7e3f4; }
.kf-chip.on { background: var(--accent); color: #fff; }
.kf-chip i { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.2); }
.kf-chip .ic { width: 16px; height: 16px; }
.kf-list { display: flex; flex-direction: column; gap: 4px; margin: 4px 0 8px; }
.kf-item { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 4px 6px 4px 10px; border-radius: 11px; background: #f7f6fb; cursor: pointer; font-weight: 700; font-size: 14px; outline: none; }
.kf-item:hover { background: #efedf7; }
.kf-item:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.kf-item.on { background: #ebe5ff; box-shadow: inset 0 0 0 2px var(--accent); }
.kf-item > .ic { width: 18px; height: 18px; color: var(--muted); flex: none; }
.kf-it { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kf-it small { font-weight: 700; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.kf-sw { width: 16px; height: 16px; border-radius: 5px; flex: none; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.15); }
.kf-ia { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--muted); flex: none; }
.kf-ia:hover { background: #fff; color: var(--ink); }
.kf-ia .ic { width: 17px; height: 17px; }
.kf-curve { width: 100%; display: block; border-radius: 10px; background: #f7f6fb; touch-action: none; margin: 2px 0 8px; cursor: crosshair; }
.kf-grad { margin: 4px 0 10px; position: relative; }
.kf-gbar { height: 26px; border-radius: 8px; cursor: copy; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.1); }
.kf-gstops { position: relative; height: 22px; }
.kf-gstop { position: absolute; top: 2px; width: 16px; height: 16px; margin-left: -8px; border-radius: 5px; border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px rgba(42, 36, 64, 0.35); cursor: grab; touch-action: none; }
.kf-gstop.on { box-shadow: 0 0 0 2.5px var(--accent); }
.kf-gpick { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.kf-galpha { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.kf-galpha input { flex: 1; accent-color: var(--accent); }
/* export and help sheets */
.kit-xcard { width: min(480px, 94vw); max-height: 86vh; display: flex; flex-direction: column; gap: 12px; }
.kit-xcard h3, .kit-help h3 { margin: 0; }
.kit-xlist { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.kit-x { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; text-align: left; gap: 2px 12px; padding: 12px 14px; border-radius: 14px; background: #f5f3fb; }
.kit-x:hover { background: #ece8f8; }
.kit-x b { font-size: 15.5px; }
.kit-x small { grid-row: 2; color: var(--muted); font-weight: 700; font-size: 12.5px; line-height: 1.35; }
.kit-x .ic { grid-row: span 2; align-self: center; color: var(--accent); width: 22px; height: 22px; }
.kit-x.busy { opacity: 0.6; pointer-events: none; }
.kit-x.busy .ic { animation: kitspin 0.9s linear infinite; }
@keyframes kitspin { to { transform: rotate(360deg); } }
.kit-help { width: min(560px, 94vw); max-height: 86vh; overflow-y: auto; text-align: left; }
.kit-help p, .kit-help li { font-size: 14.5px; line-height: 1.5; }
.kit-help ul { padding-left: 20px; }
.kit-help kbd { font: inherit; font-size: 12.5px; font-weight: 800; background: #f1eff8; border-radius: 6px; padding: 1px 6px; box-shadow: 0 2px 0 var(--press); }
.kit-help .btn { margin-top: 12px; width: 100%; }
/* a floating toolbar over a main view */
.kit-float { position: absolute; z-index: 2; display: flex; gap: 6px; padding: 6px; background: rgba(255, 255, 255, 0.94); border-radius: 16px; box-shadow: var(--shadow); align-items: center; }
.kit-float button { min-width: 40px; height: 40px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 10px; font-weight: 800; font-size: 13.5px; color: #4b4566; }
.kit-float button:hover { background: #f1eff8; }
.kit-float button.on { background: var(--accent); color: #fff; }
.kit-float button .ic { width: 20px; height: 20px; }
.kit-float .sep { width: 1px; align-self: stretch; background: var(--line); margin: 4px 2px; }
.kit-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); font-weight: 700; }
.kit-empty b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.kit-empty .kf-btns { justify-content: center; }
.mega-kit { --shade: #1563c4; background: linear-gradient(135deg, #4fd1c5, #2b8cff); box-shadow: 0 7px 0 var(--shade), 0 18px 34px rgba(43, 140, 255, 0.3); }
.kit-group { margin: 18px 0 8px; font-size: 13px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); text-align: left; }
.kit-group:first-of-type { margin-top: 4px; }
.kit-art { width: 76px; height: 76px; border-radius: 22px; background: linear-gradient(135deg, #4fd1c5, #2b8cff); color: #fff; display: grid; place-items: center; margin: 4px auto 2px; box-shadow: 0 5px 0 #1563c4; }
.kit-art .ic { width: 40px; height: 40px; }
@media (max-width: 560px) { .kit-art { width: 56px; height: 56px; border-radius: 16px; } .kit-art .ic { width: 30px; height: 30px; } }
/* Game Kit: Sound Effects */
.sx-main { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px; padding: 18px; }
.sx-kinds { display: flex; flex-wrap: wrap; gap: 8px; }
.sx-kind { height: 44px; padding: 0 16px; border-radius: 14px; background: #fff; font-weight: 900; font-size: 15px; box-shadow: 0 3px 0 var(--press); color: var(--ink); }
.sx-kind:hover { background: #f7f4ff; color: var(--accent); }
.sx-kind:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--press); }
.sx-gen-acts { display: flex; gap: 8px; margin-top: 10px; }
.sx-gen-acts .kf-btn { flex: 0 0 auto; background: #fff; box-shadow: 0 2px 0 var(--press); }
.sx-wave { position: relative; flex: 1; min-height: 140px; background: #fff; border-radius: 20px; box-shadow: var(--shadow); }
.sx-wave canvas { position: absolute; inset: 12px 0; width: 100%; height: calc(100% - 24px); }
.sx-handles { position: absolute; inset: 0; display: none; }
.sx-handles.show { display: block; }
.sx-h { position: absolute; top: 0; bottom: 0; width: 22px; margin-left: -11px; cursor: ew-resize; touch-action: none; }
.sx-h::before { content: ''; position: absolute; left: 10px; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: #ff6a3d; }
.sx-h::after { content: ''; position: absolute; left: 3px; top: 50%; width: 17px; height: 30px; margin-top: -15px; border-radius: 7px; background: #ff6a3d; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); }
.sx-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.sx-play { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 0 var(--accent-d); flex: none; }
.sx-play .ic { width: 30px; height: 30px; }
.sx-play:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-d); }
.sx-info { flex: 1; min-width: 120px; display: flex; flex-direction: column; }
.sx-info b { font-size: 18px; }
.sx-info small { color: var(--muted); font-weight: 700; }
.sx-rec { display: flex; gap: 8px; }
.sx-recbtn { background: #ff4d5e !important; }
.sx-recbtn.recording { animation: sxpulse 1s ease-in-out infinite; }
@keyframes sxpulse { 50% { box-shadow: 0 0 0 8px rgba(255, 77, 94, 0.25); } }
@media (max-width: 640px) { .sx-main { padding: 12px; gap: 10px; } .sx-kind { height: 38px; padding: 0 12px; font-size: 14px; } }
/* Game Kit: Music Loops */
.mu { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.mu-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mu-play { width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 0 var(--accent-d); flex: none; }
.mu-play.on { background: var(--red); box-shadow: 0 4px 0 var(--red-d); }
.mu-play .ic { width: 26px; height: 26px; }
.mu-mode { flex: 0 0 auto; }
.mu-pats { display: flex; gap: 6px; flex-wrap: wrap; }
.mu-pat { width: 42px; height: 42px; border-radius: 12px; background: #fff; font-weight: 900; font-size: 16px; box-shadow: 0 3px 0 var(--press); }
.mu-pat.on { background: var(--ink); color: #fff; box-shadow: 0 3px 0 #000; }
.mu-pat.add { color: var(--accent); display: grid; place-items: center; }
.mu-pat .ic { width: 20px; height: 20px; }
.mu-song { display: flex; align-items: center; gap: 8px; }
.mu-song > span { font-size: 11.5px; font-weight: 900; letter-spacing: 0.07em; text-transform: uppercase; color: var(--muted); }
.mu-chain { flex: 1; display: flex; gap: 3px; min-width: 0; overflow-x: auto; }
.mu-ch { flex: 1 0 34px; height: 30px; border-radius: 8px; background: #e7e3f4; font-weight: 900; font-size: 13px; color: #4b4566; }
.mu-ch.cur { background: #d7cdfd; color: var(--accent-d); }
.mu-ch.playing { background: #ffd21f; color: var(--ink); }
.mu-add { width: 30px; height: 30px; border-radius: 8px; background: #fff; display: grid; place-items: center; color: var(--accent); box-shadow: 0 2px 0 var(--press); }
.mu-add .ic { width: 18px; height: 18px; }
.mu-grid { flex: 1; min-height: 0; display: flex; background: #fff; border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.mu-labels { flex: 0 0 64px; overflow: hidden; border-right: 1px solid var(--line); background: #faf9fd; }
.mu-lab { display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; font-size: 11.5px; font-weight: 800; color: var(--muted); border-top: 1px solid rgba(42, 36, 64, 0.05); box-sizing: border-box; }
.mu-lab.root { color: var(--accent); }
.mu-scroll { flex: 1; overflow: auto; overscroll-behavior: contain; }
.mu-scroll canvas { display: block; touch-action: pan-x pan-y; cursor: pointer; }
.kf-item.muted .kf-it { opacity: 0.45; text-decoration: line-through; }
.kf-ia.lit { color: #fff; background: var(--orange); }
@media (max-width: 640px) { .mu { padding: 10px; gap: 8px; } .mu-mode button { font-size: 12px; } }
/* Game Kit: VFX */
.vx { position: absolute; inset: 0; display: flex; flex-direction: column; }
.vx-view { position: relative; flex: 1; min-height: 0; }
.vx-bar { left: 50%; transform: translateX(-50%); bottom: 92px; width: min(560px, calc(100% - 24px)); }
.vx-scrub { flex: 1; min-width: 60px; accent-color: var(--accent); }
.vx-time { font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 800; color: var(--muted); min-width: 74px; }
.vx-strip { height: 76px; flex: none; overflow-x: auto; padding: 10px 14px; background: #fff; border-top: 1px solid var(--line); }
.vx-stripc { height: 56px; border-radius: 8px; display: block; }
/* Game Kit: Tilemaps */
.tm-tools { left: 50%; transform: translateX(-50%); bottom: 18px; }
.tm-status { position: absolute; left: 14px; bottom: 14px; z-index: 2; font-size: 12px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; pointer-events: none; }
.tm-ts { max-height: 46vh; overflow: auto; border-radius: 10px; background: var(--checker); box-shadow: inset 0 0 0 1px var(--line); margin: 4px 0 8px; }
.tm-ts canvas { display: block; image-rendering: pixelated; cursor: pointer; touch-action: none; }
.tm-prop { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
.tm-prop input { flex: 1; min-width: 0; font: inherit; font-weight: 700; font-size: 13.5px; border: 2px solid var(--line); border-radius: 9px; padding: 5px 8px; }
.tm-prop input:focus { outline: none; border-color: var(--accent); }
/* Game Kit: Data Sheets */
.ds { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 14px; gap: 10px; }
.ds-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ds-search { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 150px; max-width: 320px; background: #fff; border: 2px solid var(--line); border-radius: 11px; padding: 0 10px; }
.ds-search:focus-within { border-color: var(--accent); }
.ds-search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.ds-search input { border: 0; outline: 0; font: inherit; font-weight: 700; font-size: 14px; padding: 8px 0; flex: 1; min-width: 0; background: none; }
.ds-count { font-size: 12.5px; font-weight: 800; color: var(--muted); margin-right: auto; font-variant-numeric: tabular-nums; }
.ds-wrap { flex: 1; min-height: 0; overflow: auto; background: #fff; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); outline: none; -webkit-overflow-scrolling: touch; }
.ds-wrap:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.ds-t { border-collapse: separate; border-spacing: 0; font-size: 13.5px; font-weight: 700; min-width: 100%; }
.ds-t th { position: sticky; top: 0; z-index: 2; background: #f7f6fb; color: var(--ink); text-align: left; padding: 9px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); cursor: pointer; user-select: none; font-weight: 800; }
.ds-t th:hover, .ds-t th.sel { background: #efebfb; }
.ds-t th.sel { box-shadow: inset 0 -2px 0 var(--accent); }
.ds-ty { display: inline-grid; place-items: center; min-width: 22px; height: 18px; padding: 0 4px; margin-right: 6px; border-radius: 6px; font-size: 10.5px; font-weight: 900; background: #fff; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.ds-ty.ty-formula { color: var(--accent); }
.ds-ty.ty-ref { color: #1f9bd7; }
.ds-key { font-style: normal; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); background: #efebff; padding: 1px 5px; border-radius: 5px; margin-left: 4px; }
.ds-t td { padding: 0 12px; height: 34px; white-space: nowrap; border-bottom: 1px solid #f0eef6; border-right: 1px solid #f0eef6; max-width: 280px; overflow: hidden; text-overflow: ellipsis; cursor: cell; font-variant-numeric: tabular-nums; }
.ds-t td.int, .ds-t td.number, .ds-t td.formula { text-align: right; }
.ds-t td.bool { text-align: center; color: var(--green-d); font-size: 15px; }
.ds-t td.formula { color: var(--accent-d); background: #fbfaff; }
.ds-t td.ref { color: #1878a8; }
.ds-t td.sel { background: #efebff; }
.ds-t td.cur { box-shadow: inset 0 0 0 2px var(--accent); background: #f6f3ff; }
.ds-t td.bad { background: #fff0f1; color: var(--red-d); box-shadow: inset 0 -2px 0 var(--red); }
.ds-t td.bad.cur { box-shadow: inset 0 0 0 2px var(--red); }
.ds-t .ds-rn { position: sticky; left: 0; z-index: 1; background: #f7f6fb; color: var(--muted); font-size: 11.5px; text-align: center; padding: 0 8px; min-width: 38px; cursor: default; }
.ds-t th.ds-rn { z-index: 3; }
.ds-sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 7px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.ds-in { width: 100%; min-width: 90px; border: 0; outline: 0; font: inherit; font-weight: 700; background: transparent; padding: 0; height: 32px; text-align: inherit; }
.ds-t td:has(.ds-in) { box-shadow: inset 0 0 0 2px var(--accent); background: #fff; }
.ds-issues { display: none; font-size: 13px; font-weight: 700; color: var(--red-d); align-items: center; gap: 6px; }
.ds-issues.show { display: flex; }
.ds-issues svg { width: 16px; height: 16px; }
.ds-formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
@media (max-width: 640px) { .ds { padding: 10px; gap: 8px; } .ds-top .kf-btn span { display: none; } .ds-t td { height: 40px; } }
/* Game Kit: node graph (Dialogue, Animation Graph) */
.ng { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; background-color: #f4f2fa; background-image: radial-gradient(circle, #d6d0e8 1.2px, transparent 1.4px); user-select: none; -webkit-user-select: none; }
.ng:active { cursor: grabbing; }
.ng-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.ng-wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.ng-w { pointer-events: visiblePainted; cursor: pointer; }
.ng-w .hit { fill: none; stroke: transparent; stroke-width: 16px; pointer-events: stroke; }
.ng-w .ln { fill: none; stroke: #a99fd0; stroke-width: 2.4px; }
.ng-w .ah { fill: #a99fd0; }
.ng-w:hover .ln { stroke: var(--accent); }
.ng-w:hover .ah { fill: var(--accent); }
.ng-w.sel .ln { stroke: var(--accent); stroke-width: 3.6px; }
.ng-w.sel .ah { fill: var(--accent); }
.ng-w.yes .ln { stroke: #4fc488; } .ng-w.yes .ah { fill: #4fc488; }
.ng-w.no .ln { stroke: #f08a95; } .ng-w.no .ah { fill: #f08a95; }
.ng-w text { font: 800 11px var(--font); fill: var(--muted); text-anchor: middle; }
.ng-temp { fill: none; stroke: var(--accent); stroke-width: 2.4px; stroke-dasharray: 6 5; }
.ng-node { position: absolute; min-width: 200px; max-width: 280px; background: #fff; border-radius: 14px; box-shadow: 0 2px 0 var(--press), 0 6px 18px rgba(42, 36, 64, 0.1); cursor: pointer; font-size: 13.5px; font-weight: 700; color: var(--ink); transition: box-shadow 0.15s; }
.ng.dragging .ng-node { transition: none; }
.ng-node:hover { box-shadow: 0 2px 0 var(--press), 0 8px 24px rgba(42, 36, 64, 0.16); }
.ng-node.sel { box-shadow: 0 0 0 3px var(--accent), 0 8px 24px rgba(123, 92, 255, 0.25); }
.ng-node.drop { box-shadow: 0 0 0 3px var(--green), 0 8px 24px rgba(34, 192, 112, 0.25); }
.ng-node::before { content: ''; position: absolute; left: -7px; top: 15px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2.5px #c9c1e6; }
.ng-port { position: absolute; right: -8px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 3px #b9b0d8; cursor: crosshair; touch-action: none; z-index: 1; }
.ng-port::after { content: ''; position: absolute; inset: -10px; border-radius: 50%; }
.ng-port.linked { background: #b9b0d8; }
.ng-port:hover { box-shadow: inset 0 0 0 3px var(--accent); background: var(--accent); }
.ng.linking { cursor: crosshair; }
@media (pointer: coarse) { .ng-port { width: 20px; height: 20px; margin-top: -10px; right: -10px; } }
/* Game Kit: Dialogue */
.dl { position: absolute; inset: 0; }
.dl-board { position: absolute; inset: 0; }
.dl-add { left: 50%; transform: translateX(-50%); bottom: 18px; max-width: calc(100% - 24px); overflow-x: auto; }
.dl-add button { flex: none; }
.dl-n.k-start, .dl-n.k-end { min-width: 0; }
.dl-h { display: flex; align-items: center; gap: 8px; padding: 9px 12px 0; }
.dl-k { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.dl-k .ic { width: 15px; height: 15px; }
.dl-sp { font-size: 12.5px; font-weight: 900; color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); padding: 2px 8px; border-radius: 7px; }
.dl-here { margin-left: auto; font-size: 10.5px; font-weight: 900; color: #fff; background: var(--green); padding: 2px 7px; border-radius: 6px; }
.dl-b { padding: 6px 12px 10px; line-height: 1.38; white-space: pre-wrap; overflow-wrap: anywhere; }
.dl-b.empty, .dl-opt .empty { color: #b8b2cc; font-style: italic; }
.dl-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: #4b4566; }
.dl-code i { color: var(--muted); font-style: normal; }
.dl-var { color: var(--accent); font-weight: 900; }
.dl-r { position: relative; }
.dl-out { height: 10px; margin-top: -18px; }
.k-start .dl-out { height: 18px; margin-top: -10px; }
.k-start .dl-h { padding-bottom: 6px; }
.k-start { background: #effbf4; }
.k-start .dl-k { color: var(--green-d); }
.k-end { background: #f2f1f6; padding-bottom: 8px; }
.k-end::before { top: 13px; }
.k-start::before { display: none; }
.k-note { background: #fff8d9; box-shadow: 0 2px 0 #eadfa8; }
.k-note::before { display: none; }
.k-note .dl-b { padding-top: 10px; font-weight: 600; color: #6a5d2a; }
.k-branch .dl-k { color: #1f8bc4; }
.k-set .dl-k { color: #d48a00; }
.k-event .dl-k { color: #e0397a; }
.dl-opts { padding: 2px 0 8px; }
.dl-opt { display: flex; align-items: baseline; gap: 6px; padding: 6px 18px 6px 12px; border-top: 1px dashed #ece8f6; }
.dl-opt:first-child { border-top: 0; }
.dl-if { flex: none; font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700; color: #1f8bc4; background: #e9f5fc; padding: 1px 5px; border-radius: 5px; }
.dl-yes, .dl-no { text-align: right; padding: 3px 18px 3px 12px; font-size: 12px; font-weight: 900; }
.dl-yes { color: var(--green-d); }
.dl-no { color: var(--red-d); padding-bottom: 9px; }
.dl-yes .ng-port { box-shadow: inset 0 0 0 3px #4fc488; } .dl-yes .ng-port.linked { background: #4fc488; }
.dl-no .ng-port { box-shadow: inset 0 0 0 3px #f08a95; } .dl-no .ng-port.linked { background: #f08a95; }
.dl-n.warn { box-shadow: 0 0 0 2px #ffb8be, 0 6px 18px rgba(42, 36, 64, 0.1); }
.dl-n.warn.sel { box-shadow: 0 0 0 3px var(--accent), 0 8px 24px rgba(123, 92, 255, 0.25); }
.dl-cast, .dl-vars { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.dl-ch, .dl-vr { display: flex; gap: 6px; align-items: center; }
.dl-ch input[type=color] { width: 34px; height: 34px; border: 0; padding: 0; background: none; border-radius: 9px; flex: none; cursor: pointer; }
.dl-ch input[type=text], .dl-vr input { flex: 1; min-width: 0; font: inherit; font-weight: 700; font-size: 13.5px; border: 2px solid var(--line); border-radius: 9px; padding: 6px 8px; }
.dl-vr input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.dl-vr span { color: var(--muted); font-weight: 900; }
.dl-ch input:focus, .dl-vr input:focus { outline: none; border-color: var(--accent); }
.dl-checks { display: flex; flex-direction: column; gap: 4px; }
.dl-issue { display: flex; gap: 8px; align-items: flex-start; text-align: left; font-size: 12.5px; font-weight: 700; color: var(--red-d); background: #fff4f5; border-radius: 9px; padding: 7px 9px; line-height: 1.3; }
.dl-issue:hover { background: #ffe9eb; }
.dl-issue .ic { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.dl-issue b { color: var(--ink); }
.dl-ok { display: flex; gap: 6px; align-items: center; color: var(--green-d); }
.dl-ok .ic, .dl-warn .ic { width: 16px; height: 16px; flex: none; }
.dl-warn { display: flex; gap: 6px; color: var(--red-d); background: #fff4f5; padding: 8px 10px; border-radius: 9px; }
.dl-ob { display: flex; flex-direction: column; gap: 5px; padding: 8px; margin-bottom: 8px; background: #f7f6fb; border-radius: 11px; }
.dl-obh { display: flex; align-items: center; gap: 4px; }
.dl-obh b { margin-right: auto; font-size: 12px; color: var(--muted); }
.dl-ob textarea, .dl-ob input { font: inherit; font-weight: 700; font-size: 13.5px; border: 2px solid var(--line); border-radius: 9px; padding: 6px 8px; resize: vertical; background: #fff; }
.dl-ob input { font-size: 12.5px; }
.dl-ob textarea:focus, .dl-ob input:focus { outline: none; border-color: var(--accent); }
.dl-play { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; background: linear-gradient(#f4f2fa, #ebe8f4); }
.dl-play[hidden] { display: none; }
.dl-log { flex: 1; min-height: 0; overflow-y: auto; padding: 24px max(16px, calc(50% - 320px)) 12px; display: flex; flex-direction: column; gap: 10px; }
.dl-msg { align-self: flex-start; max-width: min(520px, 88%); background: #fff; border-radius: 16px 16px 16px 6px; padding: 10px 14px; box-shadow: 0 2px 0 var(--press); font-size: 15px; font-weight: 700; line-height: 1.4; animation: dlIn 0.28s cubic-bezier(.2, .8, .2, 1) both; }
.dl-msg.dl-me { align-self: flex-end; background: var(--accent); color: #fff; border-radius: 16px 16px 6px 16px; box-shadow: 0 2px 0 var(--accent-d); }
.dl-msg.dl-me .dl-who { color: #fff; opacity: 0.8; }
.dl-msg.dl-narr { font-style: italic; color: #4b4566; background: transparent; box-shadow: none; }
.dl-who { display: block; font-size: 12px; font-weight: 900; color: var(--c); margin-bottom: 2px; }
.dl-sys, .dl-ck, .dl-ev { align-self: center; font-size: 12.5px; font-weight: 800; color: var(--muted); background: rgba(255, 255, 255, 0.6); box-shadow: none; padding: 5px 12px; border-radius: 99px; display: inline-flex; gap: 6px; align-items: center; }
.dl-sys.bad { color: var(--red-d); background: #fff0f1; }
.dl-ck { font-family: ui-monospace, monospace; font-size: 12px; }
.dl-ev { color: #e0397a; }
.dl-ev .ic { width: 15px; height: 15px; }
@keyframes dlIn { from { opacity: 0; transform: translateY(8px); } }
.dl-acts { flex: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 14px max(16px, calc(50% - 320px)) calc(18px + var(--sb)); }
.dl-acts kbd { font: inherit; font-size: 11px; opacity: 0.7; border: 1.5px solid currentColor; border-radius: 5px; padding: 0 4px; margin-left: 6px; }
.dl-pick { flex: 1 1 100%; display: flex; gap: 10px; align-items: center; text-align: left; background: #fff; border-radius: 13px; padding: 12px 14px; font-size: 15px; font-weight: 800; color: var(--ink); box-shadow: 0 2px 0 var(--press); }
.dl-pick:hover, .dl-pick:focus-visible { box-shadow: 0 0 0 2.5px var(--accent), 0 2px 0 var(--press); outline: none; }
.dl-pick kbd { margin: 0; flex: none; color: var(--accent); }
.dl-vlive { display: flex; flex-direction: column; gap: 4px; }
.dl-vlive div { display: flex; justify-content: space-between; padding: 6px 10px; background: #f7f6fb; border-radius: 9px; font-family: ui-monospace, monospace; font-size: 12.5px; }
.dl-vlive div.flash { animation: dlFlash 0.8s; }
@keyframes dlFlash { from { background: #fff2c4; } }
@media (pointer: coarse) { .dl-acts kbd:not(.dl-pick kbd) { display: none; } }
@media (max-width: 640px) { .dl-log { padding-top: 70px; } .dl-add span { display: none; } .dl-add button { min-width: 38px; padding: 0 8px; } .dl-msg { font-size: 14.5px; } }
/* Game Kit: UI Kit */
.uk { position: absolute; inset: 0; }
.uk-game { position: absolute; inset: 0; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 72px 16px 28px; }
.uk-game > * { flex: none; }
.uk-game[hidden], .uk-sheet[hidden] { display: none; }
.uk-hud { display: flex; gap: 10px 18px; flex-wrap: wrap; justify-content: center; }
.uk-barrow { display: flex; align-items: center; gap: 8px; }
.uk-barrow > span { min-width: 26px; text-align: right; }
.uk-bar { width: 150px; position: relative; }
.uk-9 { position: absolute; inset: 0; box-sizing: border-box; }
.uk-anim { animation: ukHp 4s ease-in-out infinite alternate; }
@keyframes ukHp { to { width: 30% !important; } }
.uk-win { position: relative; width: min(440px, 100%); box-sizing: border-box; display: flex; flex-direction: column; }
.uk-title { position: absolute; text-align: center; letter-spacing: 0.02em; pointer-events: none; }
.uk-tabs { display: flex; gap: 4px; margin: 6px 0 -6px 8px; position: relative; z-index: 1; }
.uk-tab { cursor: pointer; min-width: 56px; text-align: center; line-height: 1.2; }
.uk-body { display: flex; flex-direction: column; gap: 12px; line-height: 1.2; }
.uk-row { display: flex; align-items: center; gap: 10px; }
.uk-l { min-width: 64px; }
.uk-sp { flex: 1; }
.uk-field { flex: 1; min-width: 0; width: 0; background: none; outline: none; padding: 0; box-sizing: border-box; line-height: 1.2; }
.uk-slider { flex: 1; position: relative; cursor: pointer; touch-action: none; }
.uk-knob { position: absolute; top: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.uk-ck { cursor: pointer; flex: none; display: block; }
.uk-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.uk-btn { background: none; padding: 0 4px; cursor: pointer; flex: 1 0 auto; line-height: 1.2; white-space: nowrap; }
.uk-btn:disabled { cursor: default; }
.uk-inv { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.uk-slot { width: 24px; height: 24px; box-sizing: content-box; cursor: pointer; display: grid; place-items: center; }
.uk-slot i { width: 24px; height: 24px; border-radius: 6px; transform: rotate(45deg) scale(0.68); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2); }
.uk-tip { white-space: nowrap; line-height: 1.2; }
.uk-sheet { position: absolute; inset: 0; overflow: auto; padding: 70px 20px 24px; background: var(--checker); }
.uk-grid { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; }
.uk-grid figure { margin: 0; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.uk-cell { position: relative; }
.uk-cell img { display: block; }
.uk-cell i { position: absolute; pointer-events: none; }
.uk-cell .v { top: -4px; bottom: -4px; border-left: 1px dashed rgba(255, 60, 140, 0.85); }
.uk-cell .h { left: -4px; right: -4px; border-top: 1px dashed rgba(255, 60, 140, 0.85); }
.uk-grid figcaption { font-size: 11.5px; font-weight: 800; color: var(--ink); background: rgba(255, 255, 255, 0.9); padding: 2px 6px; border-radius: 6px; display: flex; gap: 6px; }
.uk-grid figcaption small { color: var(--muted); font-weight: 700; }
.uk-styles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 4px; }
.uk-style { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 6px 8px; border-radius: 12px; background: linear-gradient(160deg, var(--a), var(--b)); color: #fff; font-size: 13px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); box-shadow: 0 0 0 2px transparent; }
.uk-style.on { box-shadow: 0 0 0 3px var(--accent), 0 4px 12px rgba(123, 92, 255, 0.3); }
.uk-sw { width: 54px; height: 22px; display: block; }
.uk-bgs { display: flex; gap: 6px; }
.uk-bgs input { width: 36px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; }
@media (max-width: 640px) { .uk-game { padding: 64px 10px 18px; } .uk-bar { width: 110px; } }
/* Game Kit: preparing a model, sending from the 3D finish screen */
.kit-busy { position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; background: rgba(235, 232, 244, 0.92); backdrop-filter: blur(6px); }
.kit-busy > div { display: flex; align-items: center; gap: 12px; background: #fff; padding: 16px 22px; border-radius: 16px; box-shadow: var(--shadow); font-size: 15px; }
.kit-spin, .kit-busy .spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #e4e0f0; border-top-color: var(--accent); animation: kitSpin 0.8s linear infinite; display: inline-block; flex: none; }
@keyframes kitSpin { to { transform: rotate(360deg); } }
.m-kit { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 2px; }
.m-kit > span { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-right: 4px; }
.m-kit .btn { padding: 8px 14px; font-size: 14px; }
/* Game Kit: Sprite Sheets */
.sp { position: absolute; inset: 0; }
.sp-pre { position: absolute; inset: 0; display: grid; place-items: center; background: var(--checker); }
.sp-pre[hidden], .sp-sheet[hidden] { display: none; }
.sp-stage { position: relative; display: grid; place-items: center; margin-bottom: 60px; }
.sp-cv { display: block; background: rgba(255, 255, 255, 0.35); border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(42, 36, 64, 0.08); }
.sp-cv.px, .sp-sheetcv.px { image-rendering: pixelated; }
.sp-compass { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.sp-compass button { position: absolute; left: calc(var(--x) * var(--r)); top: calc(var(--y) * var(--r)); transform: translate(-50%, -50%); min-width: 34px; height: 28px; padding: 0 6px; border-radius: 9px; background: #fff; color: #4b4566; font-size: 11.5px; font-weight: 900; box-shadow: 0 2px 0 var(--press); }
.sp-compass button:hover { color: var(--accent); }
.sp-compass button.on { background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-d); }
.sp-bar { left: 50%; transform: translateX(-50%); bottom: 18px; max-width: calc(100% - 24px); }
.sp-clips { display: flex; gap: 4px; overflow-x: auto; }
.sp-clips button { padding: 0 12px; flex: none; }
.sp-clips button.off { opacity: 0.45; text-decoration: line-through; }
.sp-none { font-size: 12.5px; font-weight: 700; color: var(--muted); padding: 0 8px; white-space: nowrap; }
.sp-info { font-size: 12px; font-weight: 800; color: var(--muted); padding: 0 8px; white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 110px; }
.sp-msg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; gap: 10px; align-items: center; background: #fff; padding: 14px 18px; border-radius: 14px; box-shadow: var(--shadow); font-weight: 800; font-size: 14px; max-width: calc(100% - 40px); }
.sp-msg[hidden] { display: none; }
.sp-msg .ic { width: 18px; height: 18px; color: var(--red-d); flex: none; }
.sp-sheet { position: absolute; inset: 0; overflow: auto; padding: 70px 18px 24px; background: var(--checker); }
.sp-prog { position: sticky; top: 0; height: 4px; border-radius: 2px; background: rgba(123, 92, 255, 0.15); opacity: 0; transition: opacity 0.2s; margin-bottom: 10px; z-index: 1; }
.sp-prog.on { opacity: 1; }
.sp-prog span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; }
.sp-sheetin { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: flex-start; }
.sp-rows { display: flex; flex-direction: column; flex: none; }
.sp-rows span { display: flex; align-items: center; justify-content: flex-end; gap: 4px; font-size: 11px; font-weight: 800; color: #4b4566; white-space: nowrap; }
.sp-rows b { color: var(--accent); }
.sp-img { position: relative; background-image: linear-gradient(to right, rgba(123, 92, 255, 0.25) 1px, transparent 1px), linear-gradient(to bottom, rgba(123, 92, 255, 0.25) 1px, transparent 1px); background-size: var(--w) var(--h); box-shadow: inset 0 0 0 1px rgba(123, 92, 255, 0.3); }
.sp-sheetcv { display: block; }
.sp-meta { flex-basis: 100%; margin-top: 10px; }
.sp-src { display: flex; align-items: center; gap: 10px; padding: 10px; background: #f7f6fb; border-radius: 12px; margin-bottom: 8px; }
.sp-src .ic { width: 26px; height: 26px; color: var(--accent); flex: none; }
.sp-src span { display: flex; flex-direction: column; min-width: 0; }
.sp-src b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-src small { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.sp-clip { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.sp-clip > span { flex: 1; display: flex; flex-direction: column; font-weight: 800; font-size: 13.5px; }
.sp-clip small { font-size: 11px; color: var(--muted); }
.sp-clip.off > span { opacity: 0.5; }
.sp-clip .kf-num input { width: 52px; }
@media (max-width: 640px) { .sp-stage { margin-bottom: 70px; } .sp-info { display: none; } }
/* Game Kit: Icon Maker */
.icm { position: absolute; inset: 0; display: flex; flex-direction: column; }
.ic-big { flex: 1; min-height: 180px; display: grid; place-items: center; position: relative; background: var(--checker); }
.ic-big canvas { cursor: grab; touch-action: none; filter: drop-shadow(0 10px 24px rgba(42, 36, 64, 0.25)); }
.ic-big canvas:active { cursor: grabbing; }
.ic-hint { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 800; color: var(--muted); background: rgba(255, 255, 255, 0.8); padding: 3px 10px; border-radius: 99px; pointer-events: none; }
.ic-grid { flex: none; display: flex; gap: 10px; overflow-x: auto; padding: 12px 14px calc(12px + var(--sb)); background: #fff; border-top: 1px solid var(--line); }
.ic-cell { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border-radius: 12px; width: 92px; }
.ic-cell canvas { width: 72px; height: 72px; }
.ic-cell span { font-size: 11.5px; font-weight: 800; color: #4b4566; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ic-cell:hover { background: #f4f2fa; }
.ic-cell.on { background: #efebff; box-shadow: inset 0 0 0 2px var(--accent); }
.ic-add > svg { width: 30px; height: 30px; margin: 21px 0; color: var(--accent); }
.ic-rar { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 8px; }
.ic-rar button { padding: 5px 9px; border-radius: 8px; font-size: 12px; font-weight: 900; color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); }
.ic-rar button.on { background: var(--c); color: #fff; }
.ic-sizes .kf-chip { min-width: 0; }
/* Game Kit: Level & Terrain */
.lv { position: absolute; inset: 0; }
.lv-cv { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.lv-tools { left: 50%; transform: translateX(-50%); bottom: 16px; max-width: calc(100% - 20px); overflow-x: auto; }
.lv-tools[hidden], .lv-hud[hidden], .lv-stick[hidden], .lv-jump[hidden] { display: none; }
.lv-tools button { flex: none; flex-direction: column; gap: 2px; height: 50px; min-width: 52px; font-size: 11px; padding: 0 6px; }
.lv-tools button .ic { width: 19px; height: 19px; }
.lv-tools .lv-play { background: var(--green); color: #fff; }
.lv-tools .lv-play:hover { background: var(--green-d); }
.lv-hud { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 3; display: flex; align-items: center; gap: 12px; background: rgba(255, 255, 255, 0.92); padding: 6px 6px 6px 16px; border-radius: 16px; box-shadow: var(--shadow); font-weight: 800; font-size: 13px; white-space: nowrap; }
.lv-help { color: var(--muted); font-size: 12px; }
.lv-coins { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.lv-coin { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe9a0, #ffc83d 55%, #c98a00); display: inline-block; }
.lv-stop { padding: 8px 14px; }
.lv-stick { position: absolute; left: 28px; bottom: calc(28px + var(--sb)); width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, 0.28); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6); touch-action: none; z-index: 3; display: grid; place-items: center; }
.lv-stick i { width: 52px; height: 52px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); pointer-events: none; }
.lv-jump { position: absolute; right: 30px; bottom: calc(40px + var(--sb)); width: 76px; height: 76px; border-radius: 50%; background: rgba(255, 255, 255, 0.85); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); z-index: 3; display: grid; place-items: center; touch-action: none; }
.lv-jump .ic { transform: rotate(-90deg); width: 30px; height: 30px; color: var(--accent); }
.lv-cols { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.lv-cols button { width: 28px; height: 28px; border-radius: 8px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.lv-cols button.on { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--accent); }
@media (max-width: 640px) { .lv-tools .lv-play { order: -2; } .lv-tools .sep { order: -1; } .lv-tools button span { display: none; } .lv-tools button { height: 42px; min-width: 40px; } .lv-help { display: none; } }
/* Game Kit: Animation Graph */
.ag { position: absolute; inset: 0; }
.ag-board { position: absolute; inset: 0; }
.ag-pv { position: absolute; right: 14px; top: 14px; width: 250px; height: 270px; z-index: 2; background: linear-gradient(#fff, #efecf8); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.ag-pv canvas { display: block; width: 100%; height: 100%; }
.ag-now { position: absolute; left: 10px; top: 8px; font-size: 12px; font-weight: 900; color: var(--accent); pointer-events: none; }
.ag-drive { position: absolute; right: 8px; bottom: 8px; display: flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 10px; background: #fff; font-size: 12px; font-weight: 800; color: #4b4566; box-shadow: 0 2px 0 var(--press); }
.ag-drive .ic { width: 17px; height: 17px; }
.ag-drive.on { background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-d); }
.ag-add { left: 50%; transform: translateX(-50%); bottom: 18px; }
.ag-n { min-width: 190px; }
.ag-h { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px; }
.ag-k { font-size: 10.5px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.ag-h b { font-size: 14px; }
.ag-live { margin-left: auto; font-size: 10.5px; font-weight: 900; color: #fff; background: var(--green); padding: 2px 7px; border-radius: 6px; animation: agPulse 1.2s ease-in-out infinite; }
@keyframes agPulse { 50% { opacity: 0.55; } }
.ag-n.live { box-shadow: 0 0 0 3px var(--green), 0 8px 24px rgba(34, 192, 112, 0.25); }
.ag-n.live.sel { box-shadow: 0 0 0 3px var(--accent), 0 0 0 6px rgba(34, 192, 112, 0.5); }
.k-entry { background: #effbf4; } .k-entry .ag-k { color: var(--green-d); }
.k-any { background: #fff6e6; } .k-any .ag-k { color: var(--orange-d); }
.k-blend .ag-k { color: #1f8bc4; }
.k-entry::before, .k-any::before { display: none; }
.ag-clip { display: flex; align-items: center; gap: 6px; padding: 0 12px 8px; font-size: 12.5px; color: #4b4566; }
.ag-clip .ic { width: 15px; height: 15px; color: var(--muted); }
.ag-clip i, .ag-bl i { font-style: normal; color: var(--muted); font-size: 11px; }
.ag-clip.miss, .ag-bl .miss { color: var(--red-d); }
.ag-bl { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 12px 8px; align-items: center; }
.ag-bl small { width: 100%; font-size: 11px; color: var(--muted); }
.ag-bl span { font-size: 12px; background: #eaf5fc; color: #1878a8; padding: 2px 7px; border-radius: 6px; }
.ag-t { position: relative; display: flex; flex-direction: column; padding: 6px 18px 6px 12px; border-top: 1px dashed #ece8f6; font-size: 12.5px; }
.ag-t small { font-family: ui-monospace, monospace; font-size: 11px; color: #1f8bc4; }
.ag-new { color: var(--muted); font-weight: 800; }
.ag-new .ng-port { box-shadow: inset 0 0 0 3px var(--accent); }
.ng-w.fired .ln { stroke: var(--green); stroke-width: 4px; }
.ng-w.fired .ah { fill: var(--green); }
.ag-params { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.ag-p { display: flex; align-items: center; gap: 6px; }
.ag-pn { width: 84px; flex: none; font: inherit; font-family: ui-monospace, monospace; font-size: 12.5px; font-weight: 700; border: 2px solid var(--line); border-radius: 8px; padding: 5px 6px; }
.ag-pn:focus { outline: none; border-color: var(--accent); }
.ag-p input[type=range] { flex: 1; min-width: 40px; accent-color: var(--accent); }
.ag-p output { width: 30px; font-size: 12px; font-weight: 800; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.ag-p .switch, .ag-fire { margin-left: auto; }
.ag-fire { padding: 5px 12px; }
.ag-fire.on { background: var(--orange); color: #fff; }
.ag-bp { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.ag-bp select { flex: 1; min-width: 0; font: inherit; font-weight: 700; font-size: 13px; border: 2px solid var(--line); border-radius: 8px; padding: 5px; }
.ag-bp input { width: 60px; font: inherit; font-weight: 700; border: 2px solid var(--line); border-radius: 8px; padding: 5px; }
.ag-bp span { font-size: 12px; color: var(--muted); font-weight: 800; }
@media (max-width: 640px) { .ag-pv { width: 140px; height: 160px; right: 8px; top: 64px; } .ag-add span { display: none; } }
/* Game Kit: Game-Ready Model */
.pp { position: absolute; inset: 0; }
.pp-cv { display: block; width: 100%; height: 100%; touch-action: none; }
.pp-cv[hidden], .pp-uv[hidden], .pp-view[hidden], .pp-prog[hidden] { display: none; }
.pp-uv { position: absolute; left: 50%; top: calc(50% + 24px); transform: translate(-50%, -50%); border-radius: 8px; box-shadow: var(--shadow); background: #fff; }
.pp-view { left: 50%; transform: translateX(-50%); bottom: 18px; }
.pp-stats { position: absolute; left: 14px; bottom: 16px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; font-weight: 700; color: var(--muted); pointer-events: none; }
.pp-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pp-prog { position: absolute; left: 50%; top: 72px; transform: translateX(-50%); width: min(360px, calc(100% - 40px)); background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 10px 14px; overflow: hidden; z-index: 3; }
.pp-prog span { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); width: 0; transition: width 0.2s; }
.pp-prog b { font-size: 13px; }
.kf-btn.primary { background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-d); }
.kf-btn.primary:hover { background: var(--accent-d); }
@media (max-width: 640px) { .pp-stats { bottom: 76px; } }
/* Animate: clean-up for captured takes */
.ch-fix { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.ch-fix .ch-btn { justify-content: flex-start; min-width: 0; }
.ch-fix .ch-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Character Studio: Voice lines */
div.vo-box { position: fixed; z-index: 12; right: calc(14px + var(--sr)); top: calc(84px + var(--st)); width: 300px; max-height: calc(100vh - 290px - var(--st) - var(--sb)); overflow: auto; padding: 12px; border-radius: 22px; background: rgba(255, 255, 255, 0.96); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--shadow); color: var(--ink); display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
div.vo-box.hidden { display: none; }
.vo-box .cc-head .vo-x { margin-left: auto; width: 36px !important; min-height: 36px !important; border-radius: 12px !important; box-shadow: none !important; background: #f1eff8 !important; }
.vo-add { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vo-add .ch-btn { flex-direction: column; gap: 3px; height: auto; min-height: 58px; padding: 8px 4px; font-size: 12.5px; }
.vo-add .ch-btn .ic { width: 20px; height: 20px; }
.vo-box.recording .vo-rec { background: var(--red); color: #fff; }
.vo-recbox { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 14px; background: #fff0f2; }
.vo-recbox[hidden] { display: none; }
.vo-meter { flex: 1; min-width: 0; height: 32px; }
.vo-clock { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--red-d); }
.vo-stop { min-height: 34px !important; padding: 0 10px !important; font-size: 13px !important; background: var(--red) !important; color: #fff !important; }
.vo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 210px; overflow-y: auto; }
.vo-line { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 7px 8px; border-radius: 12px; background: #f7f6fb; color: var(--ink); }
.vo-line:hover { background: #efebfb; }
.vo-line.on { background: #efebff; box-shadow: inset 0 0 0 2px var(--accent); }
.vo-play { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; }
.vo-play .ic { width: 15px; height: 15px; }
.vo-txt { display: flex; flex-direction: column; min-width: 0; }
.vo-txt b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vo-txt small { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.vo-txt small .ic { width: 12px; height: 12px; flex: none; }
.vo-empty { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 12px; background: #f7f6fb; }
.vo-empty .ic { width: 22px; height: 22px; color: var(--accent); flex: none; }
.vo-empty p { margin: 0; font-size: 13px; line-height: 1.35; color: #4b4566; }
.vo-sel { display: flex; flex-direction: column; gap: 8px; }
.vo-sel h4 { margin: 6px 0 0; }
.vo-sel .ch-row .ch-btn { flex: 1; }
.vo-script textarea { width: 100%; resize: vertical; font: inherit; font-weight: 700; font-size: 13.5px; border: 2px solid var(--line); border-radius: 10px; padding: 6px 8px; min-height: 52px; }
.vo-script textarea:focus { outline: none; border-color: var(--accent); }
.vo-script { flex-direction: column; align-items: stretch !important; }
.vo-src { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 12px; font-weight: 800; color: var(--muted); }
.vo-src .ic { width: 15px; height: 15px; }
.vo-sl input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
.vo-sl b { min-width: 52px; text-align: right; }
.vo-moods .ch-chip { padding: 6px 10px; }
.vo-wide { width: 100%; }
.vo-toggles .ch-btn { padding: 0 6px; }
.vo-del { color: var(--red-d); }
.vo-tip, .vo-wait { margin: 0; font-size: 13px; color: var(--muted); font-weight: 700; display: flex; gap: 8px; align-items: center; }
.vo-box.busy .vo-add { opacity: 0.5; pointer-events: none; }
.vo-sub { position: fixed; z-index: 11; left: 50%; bottom: calc(196px + var(--sb)); transform: translateX(-50%) translateY(6px); max-width: min(680px, calc(100vw - 40px)); padding: 8px 16px; border-radius: 12px; background: rgba(20, 16, 34, 0.78); color: #fff; font-size: 18px; font-weight: 800; line-height: 1.3; text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; }
.vo-sub.on { opacity: 1; transform: translateX(-50%); }
.ch-voicebtn { width: 100%; margin-top: 6px; }
.vo-more { display: none !important; }
@media (max-width: 760px) {
  div.vo-box { top: auto; bottom: calc(162px + var(--sb)); right: 8px; left: 8px; width: auto; max-height: calc(100vh - 300px - var(--sb)); border-radius: 20px; padding: 10px; gap: 8px; }
  .vo-box .cc-head .vo-more { display: inline-flex !important; margin-left: auto; width: 36px !important; min-height: 36px !important; border-radius: 12px !important; box-shadow: none !important; background: #f1eff8 !important; padding: 0 !important; }
  .vo-box .cc-head .vo-more ~ .vo-x { margin-left: 0; }
  .vo-box .vo-more .ic { transform: rotate(90deg); transition: transform 0.2s; }
  .vo-box.mini .vo-more .ic { transform: rotate(-90deg); }
  .vo-box.mini .vo-sel { display: none; }
  .vo-box.mini .vo-list { max-height: 50px; }
  .vo-box.mini .vo-add .ch-btn { min-height: 44px; flex-direction: row; gap: 5px; font-size: 12px; }
  .vo-sub { bottom: calc(100vh - 150px); top: auto; font-size: 15px; }
  .vo-box.mini ~ .vo-sub { bottom: auto; top: calc(130px + var(--st)); }
}

/* ================================================================ Apple Pencil & touch (pencil.js) */
.set-wide { width: 100%; justify-content: center; gap: 8px; margin: 6px 0 4px; }
.ctl-pencil { width: 100%; justify-content: center; gap: 8px; margin-top: 8px; }
.ctl-row .set-select { height: 34px; font-size: 14px; max-width: 200px; }
.pz-sheet { z-index: 260; }
.pz-card { width: min(860px, 100%); }
.pz-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 26px; }
.pz-sec h4 { margin: 10px 2px 2px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--accent); }
.pz-sec .set-row { padding: 9px 2px; font-size: 15px; }
.pz-sec .set-select { max-width: 190px; }
.pz-note { min-height: 2.8em; }
.pz-pad { display: block; width: 100%; height: 170px; border-radius: 18px; background: #fff; box-shadow: inset 0 0 0 2px #ebe7f6; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.pz-read { margin: 6px 2px 0; min-height: 2.8em; font-size: 12.5px; font-weight: 700; color: var(--muted); line-height: 1.4; font-variant-numeric: tabular-nums; }
.pz-read b { color: var(--ink); }
.pz-read i { color: #d4485f; font-style: normal; }
@media (max-width: 720px) { .pz-cols { grid-template-columns: 1fr; } }
.kit-pen-note { color: var(--muted); font-weight: 700; font-size: 13px !important; }
.kit-help-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ================================================================ Layers (layers.js) and Shade */
.layers-btn { position: relative; }
.layers-btn.on { background: var(--accent); color: #fff; }
.layers-btn.warn:not(.on) { color: #d4485f; }
.layers-count { position: absolute; right: -4px; top: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: #fff; font: 800 12px/20px Nunito, sans-serif; font-style: normal; text-align: center; box-shadow: 0 0 0 2px #fff; }
.layers-btn.on .layers-count { background: #fff; color: var(--accent); }
.layers-panel {
  position: fixed; z-index: 13; top: calc(78px + var(--st)); right: calc(14px + var(--sr));
  width: min(330px, calc(100vw - 28px)); max-height: calc(100vh - 110px - var(--st) - var(--sb));
  display: flex; flex-direction: column; padding: 12px 12px 10px;
  background: rgba(255, 255, 255, 0.97); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-radius: 26px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transform: translateY(-8px) scale(0.98); transform-origin: top right;
  transition: opacity 0.16s, transform 0.2s cubic-bezier(0.3, 1.4, 0.5, 1);
  -webkit-user-select: none; user-select: none;
}
.layers-panel.show { opacity: 1; pointer-events: auto; transform: none; }
body.ui-hidden .layers-panel, body:not(.drawing) .layers-panel { opacity: 0 !important; pointer-events: none !important; }
body.ws-anim .layers-panel { max-height: calc(100vh - 110px - var(--st) - var(--ab-top, 200px)); }
.ly-head { display: flex; align-items: center; gap: 6px; padding: 0 2px 8px; }
.ly-head h3 { margin: 0 auto 0 4px; font-size: 19px; color: var(--ink); }
.ly-head .pill { height: 36px; padding: 0 12px; font-size: 13px; gap: 5px; }
.ly-head .pill .ic { width: 17px; height: 17px; }
.ly-head .pill:disabled, .ly-act:disabled { opacity: 0.38; pointer-events: none; }
.ly-add { background: var(--accent); color: #fff; }
.ly-list { overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 5px; padding: 2px; margin: 0 -2px; }
.ly-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 2px; border-radius: 16px; background: #f6f4fb; cursor: pointer; position: relative; transition: background 0.15s; }
.ly-row.on { background: #ebe5ff; box-shadow: inset 0 0 0 2.5px var(--accent); }
.ly-row.off .ly-thumb, .ly-row.off .ly-name { opacity: 0.45; }
.ly-row.dragging { z-index: 2; box-shadow: var(--shadow); opacity: 0.95; }
.ly-row.drop-above::before, .ly-row.drop-below::after { content: ''; position: absolute; left: 8px; right: 8px; height: 4px; border-radius: 2px; background: var(--accent); }
.ly-row.drop-above::before { top: -5px; }
.ly-row.drop-below::after { bottom: -5px; }
.ly-grip { flex: none; width: 26px; height: 44px; display: grid; place-items: center; color: #b3adc8; cursor: grab; touch-action: none; }
.ly-grip .ic { width: 17px; height: 17px; }
.ly-thumb { flex: none; width: 56px; height: 42px; border-radius: 9px; box-shadow: inset 0 0 0 1.5px #dcd7ec;
  background: #fff conic-gradient(#eeebf6 25%, #fff 0 50%, #eeebf6 0 75%, #fff 0) 0 0 / 12px 12px; }
.ly-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.ly-name b { font-size: 15px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ly-name i { font-style: normal; font-size: 11.5px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 14px; }
.ly-rename { width: 100%; height: 34px; border: 2px solid var(--accent); border-radius: 10px; padding: 0 8px; font: 800 15px Nunito, sans-serif; color: var(--ink); background: #fff; -webkit-user-select: text; user-select: text; }
.ly-eye { flex: none; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: #b3adc8; background: #fff; }
.ly-eye.on { color: var(--accent); }
.ly-eye .ic { width: 22px; height: 22px; }
.ly-detail { padding: 4px 6px 8px; border-radius: 16px; background: #faf9fd; box-shadow: inset 0 0 0 2px #f0edf8; }
.ly-line { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #4d466a; }
.ly-line > span { width: 58px; flex: none; }
.ly-line .set-slider { flex: 1; }
.ly-line .set-select { flex: 1; height: 36px; font-size: 14px; }
.ly-pct { width: 42px; text-align: right; font-style: normal; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.ly-toggles { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 6px; }
.ly-toggles .pill { height: 34px; padding: 0 11px; font-size: 13px; gap: 5px; }
.ly-toggles .pill .ic { width: 16px; height: 16px; }
.ly-acts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.ly-act { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 48px; padding: 4px 2px; border-radius: 12px; background: #fff; color: var(--ink); font: 800 10.5px/1.1 Nunito, sans-serif; box-shadow: inset 0 0 0 1.5px #ebe7f6; }
.ly-act .ic { width: 19px; height: 19px; color: var(--accent); }
.ly-act.danger, .ly-act.danger .ic { color: #d4485f; }
.ly-act:active { transform: scale(0.95); }
.ly-up { transform: rotate(-90deg); }
.ly-dn { transform: rotate(90deg); }
.ly-foot { margin: 8px 4px 0; font-size: 12px; font-weight: 700; color: var(--muted); line-height: 1.35; }
@media (max-width: 720px) {
  .layers-panel { top: calc(70px + var(--st)); right: calc(8px + var(--sr)); width: min(310px, calc(100vw - 16px)); padding: 10px 10px 8px; }
  .ly-foot { display: none; }
}
@media (max-height: 520px) {
  .layers-panel { top: calc(8px + var(--st)); max-height: calc(100vh - 16px - var(--st) - var(--sb)); z-index: 30; }
  body.ws-anim .layers-panel { max-height: calc(100vh - 16px - var(--st) - var(--sb)); }
}
/* eight tools (Advanced, with Shade) on a phone: narrower buttons, icons only */
@media (max-width: 450px) {
  body.adv .dock .tool-btn { width: 43px; }
  body.adv .dock .tool-btn span { display: none; }
}
@media (max-width: 380px) {
  body.adv .dock .tool-btn { width: 39px; }
}
#stage[data-tool='shade'] { cursor: none; }

/* ================================================================ Simple vs Advanced drawing, brushes, pixel tools */
body.adv .simple-only { display: none !important; }
#stage[data-tool='smudge'], #stage[data-tool='liquify'] { cursor: none; }
.brush-pick { padding: 0 14px 0 6px; gap: 8px; color: var(--ink); }
.brush-pick .brush-ic { width: 44px; height: 34px; border-radius: 10px; background: #fff; box-shadow: inset 0 0 0 1.5px #e7e3f3; }
.brush-pick.on { color: #fff; }
.brush-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; padding: 10px; width: min(340px, calc(100vw - 24px)); }
.brush-grid button { display: flex; flex-direction: column; align-items: stretch; gap: 2px; padding: 6px 8px 7px; border-radius: 16px; background: #f6f4fb; color: var(--ink); text-align: left; transition: transform 0.1s, background 0.15s; }
.brush-grid button canvas { width: 100%; height: 46px; border-radius: 10px; background: #fff; }
.brush-grid button b { font-size: 13.5px; padding-left: 2px; }
.brush-grid button.on { background: #ebe5ff; box-shadow: inset 0 0 0 2.5px var(--accent); }
.brush-grid button:active { transform: scale(0.97); }
.adjust-panel { width: min(380px, calc(100vw - 24px)); padding: 12px 16px 12px; }
.adj-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.adj-head h3 { margin: 0; font-size: 17px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adj-head .pill, .adj-foot .pill { height: 36px; padding: 0 13px; font-size: 13.5px; gap: 5px; }
.adj-head .pill .ic, .adj-foot .pill .ic { width: 17px; height: 17px; }
.adjust-panel .tune-row { font-size: 14px; }
.adjust-panel .tune-row > span { width: 78px; }
.adjust-panel .tune-row em { width: 34px; text-align: right; font-style: normal; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.adjust-panel .hslider { height: 38px; }
.adjust-panel .hslider .sl-thumb { transform: scale(0.82); }
.adjust-panel .set-slider.mid .sl-track { background: linear-gradient(90deg, #cfc4ff, #ece9f5 50%, #cfc4ff); }
.adj-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
body.adjusting .dock, body.adjusting .toolopts, body.adjusting .rail .size-wrap { opacity: 0.35; pointer-events: none; }
@media (max-height: 620px) { .adjust-panel .hslider { height: 30px; } .adjust-panel .hslider .sl-thumb { transform: scale(0.66); } }
/* layer groups and clipping masks in the panel */
.ly-group { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 2px; border-radius: 14px; background: #efecf8; cursor: pointer; }
.ly-group.on { box-shadow: inset 0 0 0 2.5px var(--accent); background: #ebe5ff; }
.ly-group.off .ly-name, .ly-group.off .ly-gic { opacity: 0.45; }
.ly-fold { flex: none; width: 28px; height: 36px; display: grid; place-items: center; color: var(--muted); }
.ly-fold .ic { width: 16px; height: 16px; transition: transform 0.15s; }
.ly-fold.open .ic { transform: rotate(90deg); }
.ly-gic { flex: none; width: 22px; height: 22px; color: var(--accent); }
.ly-group .ly-eye { width: 36px; height: 36px; }
.ly-row.in-group, .ly-row.in-group + .ly-detail { margin-left: 16px; }
.ly-row.clipped { margin-left: 22px; }
.ly-row.clipped.in-group { margin-left: 34px; }
.ly-row.clipped .ly-grip { color: var(--accent); }
.ly-toggles .pill:disabled { opacity: 0.38; pointer-events: none; }
.ly-acts { grid-template-columns: repeat(5, 1fr); }
/* nine tools (Advanced) on a phone */
@media (max-width: 450px) {
  body.adv .dock .tool-btn { width: 38px; }
  body.adv .dock { gap: 1px; padding: 5px; }
}
@media (max-width: 380px) {
  body.adv .dock .tool-btn { width: 35px; }
}
/* the Adjustments panel sits to the side on a wide screen, so the drawing stays in view */
@media (min-width: 721px) {
  .pop-card.adjust-panel, body.ws-anim .pop-card.adjust-panel { left: auto; right: calc(14px + var(--sr)); top: calc(84px + var(--st)); bottom: auto; transform: none; }
}

/* ================================================================ Layers panel, tidied: a list that shows its hierarchy */
.layers-panel { width: min(318px, calc(100vw - 28px)); padding: 12px 10px 10px; }
.ly-head { padding: 0 4px 8px; }
.ly-list { gap: 4px; padding: 2px 2px 4px; }
.ly-item { position: relative; display: flex; flex-direction: column; gap: 4px; border-radius: 16px; }
.ly-item.on { background: #f1edff; box-shadow: inset 0 0 0 2.5px var(--accent); }
.ly-item.on .ly-row, .ly-item.on .ly-row.on { background: none; box-shadow: none; }
.ly-row { padding: 5px 5px 5px 0; gap: 7px; min-height: 54px; }
.ly-grip { width: 24px; color: #c3bdd8; }
.ly-thumb { width: 52px; height: 39px; }
.ly-name { justify-content: center; }
.ly-name i:empty { display: none; }
.ly-more, .ly-eye { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: #fff; }
.ly-more { color: var(--ink); }
.ly-more .ic { width: 22px; height: 22px; }
.ly-more:active, .ly-eye:active, .ly-chip:active { transform: scale(0.93); }
.ly-detail { padding: 0 8px 6px 10px; background: none; box-shadow: none; border-radius: 0; }
.ly-line { gap: 8px; font-size: 13.5px; }
.ly-line > span { width: 52px; }
.ly-line .hslider { height: 38px; }
.ly-line .hslider .sl-thumb { transform: scale(0.8); }
.ly-line .set-select { height: 36px; min-width: 0; }
.ly-chip { flex: none; width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: #fff; color: #9c95b6; }
.ly-chip .ic { width: 18px; height: 18px; }
.ly-chip.on { background: var(--accent); color: #fff; }
.ly-chip:disabled { opacity: 0.35; pointer-events: none; }
/* the hierarchy: a group's layers hang off its name, a clipping mask off the layer under it */
.ly-group { padding: 4px 5px 4px 8px; gap: 8px; background: none; border-radius: 12px; cursor: pointer; margin-top: 2px; }
.ly-group .ly-name b { font-size: 14px; }
.ly-group .ly-more, .ly-group .ly-eye { width: 34px; height: 34px; background: #f6f4fb; }
.ly-item.in-group { margin-left: 20px; }
.ly-item.in-group::before { content: ''; position: absolute; left: -11px; top: -4px; bottom: 50%; width: 9px; border-left: 2px solid #d9d3ec; border-bottom: 2px solid #d9d3ec; border-bottom-left-radius: 8px; pointer-events: none; }
.ly-item.in-group::after { content: ''; position: absolute; left: -11px; top: 0; bottom: -4px; border-left: 2px solid #d9d3ec; pointer-events: none; }
.ly-item.in-group:has(+ :not(.ly-item.in-group))::after, .ly-item.in-group:last-child::after { display: none; }
.ly-item.clipped { margin-left: 26px; }
.ly-item.clipped.in-group { margin-left: 46px; }
.ly-item.clipped.in-group::before, .ly-item.clipped.in-group::after { left: -37px; }
.ly-item.clipped.in-group::before { width: 35px; }
.ly-row.in-group, .ly-row.clipped, .ly-row.clipped.in-group, .ly-row.in-group + .ly-detail { margin-left: 0; }
.ly-item.clipped .ly-grip { color: var(--accent); }
.popmenu { max-height: calc(100vh - 16px); overflow-y: auto; overscroll-behavior: contain; }
.ly-line2 { gap: 6px; padding-top: 2px; }
.ly-line2 .set-select { flex: 1; padding-left: 12px; }
.ly-item.clipped { margin-left: 16px; }
.ly-item.clipped.in-group { margin-left: 36px; }
.ly-item.clipped.in-group::before, .ly-item.clipped.in-group::after { left: -27px; }
.ly-item.clipped.in-group::before { width: 25px; }

/* ---------------------------------------------------------------- every menu fits its screen
   (screens.js draws a menu's content smaller when it is taller than the screen; these help it along) */
.screen.fitted .menu-body { padding-bottom: 8px; }
/* a wide, short screen (a phone on its side): Home's five buttons sit in two columns */
@media (max-height: 560px) and (min-width: 640px) {
  .title-screen .title-body { width: min(900px, 100%); gap: 8px; }
  .title-screen .mega-stack { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
  .title-screen .mega-stack .mega:last-child:nth-child(odd) { grid-column: 1 / -1; justify-self: center; width: calc(50% - 7px); }
  .title-screen .logo-big { flex-direction: row; justify-content: center; gap: 12px; }
  .title-screen .logo-big .logo-mark { width: 48px; height: 48px; }
  .title-screen .logo-big h1 { font-size: 44px; }
  .title-screen .tagline { display: none; }
  .title-screen .studio-foot { margin: 4px 0 0; }
}
.screen[data-cols] .wide-body { width: 100%; max-width: 1500px; }
.screen[data-cols] .kind-grid .pick-card { flex: 0 1 calc((100% - 16px * (var(--cols) - 1)) / var(--cols)); }
