:root {
  --bg: #140e1f;
  --bg2: #1d1530;
  --panel: #221a37;
  --panel2: #2c2245;
  --line: rgba(255, 226, 190, 0.12);
  --ink: #fbeedd;
  --muted: #bfaecd;
  --orange: #ff7a1a;
  --orange2: #ffa23a;
  --glow: #ffd36b;
  --purple: #8d6bff;
  --radius: 16px;
  --top-h: 56px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 500 15px/1.45 Fredoka, "Trebuchet MS", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: 0.4; }
:focus-visible { outline: 3px solid var(--glow); outline-offset: 2px; }
svg.vpc-i { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Header */
.vpc-top {
  height: var(--top-h); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px 0 124px; background: linear-gradient(180deg, #1c1430, #140e1f); border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
}
.vpc-top h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap; color: #ffe2c0; text-shadow: 0 0 18px rgba(255, 140, 40, 0.45); }
.vpc-top-actions { display: flex; gap: 8px; align-items: center; }

.vpc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel2); font-weight: 600; white-space: nowrap;
  transition: transform 0.12s, background 0.2s, box-shadow 0.2s;
}
.vpc-btn:hover:not(:disabled) { transform: translateY(-1px); background: #3a2e58; }
.vpc-btn:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
.vpc-btn.hot { background: linear-gradient(180deg, #ff8f2e, #f0650c); border-color: #ffb066; color: #2a1000; box-shadow: 0 4px 18px rgba(255, 110, 20, 0.35); }
.vpc-btn.hot:hover:not(:disabled) { background: linear-gradient(180deg, #ffa04a, #ff7418); }
.vpc-btn.ghosty { background: rgba(255, 255, 255, 0.05); }
.vpc-btn.wide { width: 100%; }
.vpc-btn.sparkle { background: linear-gradient(120deg, #4a2d7a, #7a3d8f 50%, #a6461e); border-color: rgba(255, 200, 140, 0.35); }
.vpc-icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center; padding: 0;
  border: 1px solid var(--line); background: rgba(34, 26, 55, 0.88); backdrop-filter: blur(6px);
  transition: transform 0.12s, background 0.2s;
}
.vpc-icon-btn:hover:not(:disabled) { background: #3a2e58; transform: translateY(-1px); }
.vpc-icon-btn[aria-pressed="true"] { background: #4a3a70; }
#vpc-sound[aria-pressed="false"] { opacity: 0.6; }
.vpc-chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(255, 220, 170, 0.3); background: rgba(255, 255, 255, 0.08); font-weight: 600; }
.vpc-chip:hover { background: rgba(255, 255, 255, 0.16); }
.vpc-chip.quiet { background: transparent; border-color: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.vpc-chip.wide { grid-column: 1 / -1; }

/* Studio layout */
.vpc-studio { display: grid; grid-template-columns: minmax(0, 1fr) 360px; height: calc(100vh - var(--top-h)); height: calc(100dvh - var(--top-h)); min-height: 520px; }
.vpc-stage { position: relative; overflow: hidden; background: #0b0814; }
#vpc-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#vpc-canvas.carving { cursor: none; }
#vpc-canvas.turning { cursor: grab; }
#vpc-canvas.grabbing { cursor: grabbing; }
.vpc-trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.vpc-trail polyline { fill: rgba(255, 200, 120, 0.12); stroke: #ffe7b8; stroke-width: 2.5; stroke-dasharray: 7 6; stroke-linejoin: round; filter: drop-shadow(0 0 4px rgba(255, 170, 60, 0.9)); }

.vpc-coach {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: min(440px, calc(100% - 120px));
  display: grid; gap: 4px; justify-items: center; text-align: center; padding: 12px 16px 12px;
  background: rgba(22, 15, 36, 0.82); border: 1px solid rgba(255, 200, 140, 0.22); border-radius: 18px; backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35); transition: opacity 0.3s, transform 0.3s;
}
.vpc-coach.hide { opacity: 0; pointer-events: none; transform: translate(-50%, -12px); }
.vpc-coach strong { font-size: 18px; color: #ffe0b8; }
.vpc-coach span { color: var(--muted); font-size: 14px; }
.vpc-coach-steps { display: flex; gap: 6px; }
.vpc-coach-steps i { width: 26px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.15); }
.vpc-coach-steps i.done { background: var(--orange); }
.vpc-coach-steps i.now { background: var(--glow); box-shadow: 0 0 8px var(--glow); }
.vpc-coach-bar { width: 100%; height: 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-top: 4px; }
.vpc-coach-bar b { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff7a1a, #ffd36b); transition: width 0.25s; }
.vpc-coach-actions { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; justify-content: center; }
.vpc-coach.carve .vpc-coach-bar, .vpc-coach.carve #vpc-prep-step, .vpc-coach.carve #vpc-skip { display: none; }

.vpc-history { position: absolute; left: 12px; top: 14px; display: grid; gap: 8px; }
.vpc-light-btn {
  position: absolute; right: 16px; bottom: 18px; display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 22px 0 14px;
  border-radius: 999px; border: 1px solid #ffbf73; font-weight: 700; font-size: 17px; color: #2a1000;
  background: linear-gradient(180deg, #ffc35a, #ff7a1a); box-shadow: 0 6px 26px rgba(255, 130, 30, 0.5);
  transition: transform 0.15s, box-shadow 0.3s, background 0.3s;
}
.vpc-light-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 34px rgba(255, 150, 40, 0.7); }
.vpc-light-btn[aria-pressed="true"] { background: linear-gradient(180deg, #4a3a70, #2c2245); color: var(--ink); border-color: rgba(255, 220, 170, 0.3); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4); }
.vpc-flame { width: 28px; height: 28px; border-radius: 50%; background: #2a1000; position: relative; display: grid; place-items: center; }
.vpc-flame::after { content: ""; width: 10px; height: 15px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(circle at 50% 70%, #fff7d0, #ffbf40 45%, #ff6a00); animation: vpc-flick 0.9s infinite alternate; }
.vpc-light-btn[aria-pressed="true"] .vpc-flame { background: rgba(255, 255, 255, 0.1); }
.vpc-light-btn[aria-pressed="true"] .vpc-flame::after { background: #776a90; animation: none; }
@keyframes vpc-flick { 0% { transform: scale(1, 1) rotate(-3deg); } 100% { transform: scale(0.9, 1.1) rotate(4deg); } }
.vpc-light-btn.beckon { animation: vpc-beckon 1.6s ease-in-out infinite; }
@keyframes vpc-beckon { 0%, 100% { box-shadow: 0 6px 26px rgba(255, 130, 30, 0.5); } 50% { box-shadow: 0 0 0 10px rgba(255, 160, 40, 0.18), 0 6px 40px rgba(255, 150, 40, 0.9); } }

.vpc-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); margin: 0; padding: 6px 14px; border-radius: 999px; background: rgba(10, 6, 18, 0.55); color: #e8d8c8; font-size: 13px; white-space: nowrap; pointer-events: none; }
.vpc-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 18px; background: #0b0814; transition: opacity 0.5s; }
.vpc-loading.gone { opacity: 0; pointer-events: none; }
.vpc-toast { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.9); padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 20px; color: #2a1000; background: linear-gradient(180deg, #ffd36b, #ff9a2a); box-shadow: 0 8px 40px rgba(255, 140, 30, 0.6); opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; white-space: nowrap; }
.vpc-toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* Dock */
.vpc-dock { background: linear-gradient(180deg, #1f1733, #171026); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.vpc-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 8px; border-bottom: 1px solid var(--line); }
.vpc-tabs button { display: grid; justify-items: center; gap: 2px; padding: 7px 2px 6px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.vpc-tabs button:hover { background: rgba(255, 255, 255, 0.05); color: var(--ink); }
.vpc-tabs button[aria-selected="true"] { background: rgba(255, 122, 26, 0.16); color: #ffc98c; }
.vpc-pane { padding: 14px; overflow-y: auto; display: grid; grid-auto-rows: max-content; gap: 14px; align-content: start; flex: 1; min-height: 0; }
.vpc-pane[hidden] { display: none; }
.vpc-h { margin: 2px 0 -6px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.vpc-note { margin: 0; color: var(--muted); font-size: 13px; }
.vpc-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.vpc-row.end { justify-content: flex-end; }

.vpc-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vpc-tools button { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); }
.vpc-tools button svg { grid-row: 1 / 3; width: 26px; height: 26px; color: #ffb36b; }
.vpc-tools button b { font-weight: 600; }
.vpc-tools button small { color: var(--muted); font-size: 11.5px; line-height: 1.2; }
.vpc-tools button:last-child { grid-column: 1 / -1; }
.vpc-tools button[aria-pressed="true"] { border-color: #ff9a3c; background: linear-gradient(180deg, rgba(255, 122, 26, 0.28), rgba(255, 122, 26, 0.1)); box-shadow: inset 0 0 0 1px rgba(255, 154, 60, 0.5); }

.vpc-range { display: grid; gap: 6px; font-weight: 600; }
.vpc-range > span { display: flex; justify-content: space-between; }
.vpc-range output { color: #ffc98c; }
input[type="range"] { width: 100%; accent-color: var(--orange); height: 28px; }
input[type="color"] { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 3px; }

.vpc-cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.vpc-cats button { flex: none; min-height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; font-size: 14px; }
.vpc-cats button[aria-pressed="true"] { background: var(--orange); color: #2a1000; border-color: var(--orange2); }
.vpc-stencils { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.vpc-stencils button { display: grid; justify-items: center; gap: 2px; padding: 6px 4px 6px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--muted); text-transform: capitalize; }
.vpc-stencils button canvas { width: 60px; height: 60px; }
.vpc-stencils button:hover { background: var(--panel2); color: var(--ink); }
.vpc-stencils button[aria-selected="true"] { border-color: var(--glow); background: rgba(255, 211, 107, 0.14); color: #ffe7b8; box-shadow: 0 0 0 2px rgba(255, 211, 107, 0.25); }
.vpc-stencil-ctl { display: grid; gap: 10px; padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.vpc-stencil-ctl.off { display: none; }
.vpc-seg { display: inline-flex; margin-left: auto; border-radius: 999px; border: 1px solid var(--line); overflow: hidden; }
.vpc-seg button { border: 0; padding: 8px 12px; background: transparent; font-weight: 600; font-size: 14px; }
.vpc-seg button[aria-pressed="true"] { background: var(--orange); color: #2a1000; }
.vpc-upload { cursor: pointer; }

.vpc-shapes, .vpc-skins, .vpc-modes, .vpc-scenes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.vpc-shapes button, .vpc-skins button, .vpc-modes button, .vpc-scenes button { display: grid; justify-items: center; gap: 4px; padding: 8px 4px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; font-weight: 600; }
.vpc-shapes canvas { width: 64px; height: 52px; }
.vpc-skins i { width: 34px; height: 34px; border-radius: 50%; box-shadow: inset -4px -5px 8px rgba(0, 0, 0, 0.3), inset 3px 3px 6px rgba(255, 255, 255, 0.25); }
.vpc-modes i { width: 26px; height: 26px; border-radius: 50%; }
.vpc-scenes i { width: 100%; height: 46px; border-radius: 10px; }
.vpc-shapes button[aria-pressed="true"], .vpc-skins button[aria-pressed="true"], .vpc-modes button[aria-pressed="true"], .vpc-scenes button[aria-pressed="true"] { border-color: var(--orange2); background: rgba(255, 122, 26, 0.16); color: #ffd4a0; }
.vpc-cam { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Dialogs */
.vpc-dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); padding: 20px; border: 1px solid rgba(255, 210, 160, 0.2); border-radius: 22px; background: linear-gradient(180deg, #261c3d, #1a1229); color: var(--ink); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6); z-index: 2100; }
.vpc-dialog::backdrop { background: rgba(6, 3, 12, 0.7); backdrop-filter: blur(3px); }
.vpc-dialog h2 { margin: 0 0 8px; font-size: 22px; color: #ffe0b8; }
.vpc-dialog p { color: var(--muted); }
.vpc-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.vpc-dialog-head h2 { margin: 0; }
.vpc-choice { display: grid; text-align: left; width: 100%; margin: 8px 0; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel2); }
.vpc-choice:hover { border-color: var(--orange2); }
.vpc-choice span { color: var(--muted); font-size: 13px; }
.vpc-field { display: grid; gap: 6px; margin: 10px 0 16px; }
.vpc-field input { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: #120c1d; font-size: 16px; }
.vpc-patch { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.vpc-card { border-radius: 16px; border: 1px solid var(--line); background: var(--panel); overflow: hidden; display: grid; }
.vpc-card.active { border-color: var(--orange2); box-shadow: 0 0 0 2px rgba(255, 162, 58, 0.25); }
.vpc-card .thumb { aspect-ratio: 4 / 3; background: #0b0814 center / cover no-repeat; border: 0; padding: 0; width: 100%; display: grid; place-items: center; color: var(--muted); }
.vpc-card .meta { padding: 8px 10px 4px; }
.vpc-card .meta b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vpc-card .meta small { color: var(--muted); }
.vpc-card .acts { display: flex; gap: 2px; padding: 0 6px 8px; flex-wrap: wrap; }
.vpc-card .acts button { border: 0; background: transparent; color: #ffc98c; font-size: 13px; padding: 4px 6px; border-radius: 8px; }
.vpc-card .acts button:hover { background: rgba(255, 255, 255, 0.08); }
.vpc-help-steps { padding-left: 22px; display: grid; gap: 8px; }
.vpc-help-steps b { color: #ffd4a0; }
.vpc-nogl { position: fixed; inset: auto 16px 16px; padding: 16px; border-radius: 16px; background: #3a1a1a; z-index: 2200; }

/* Guide copy */
.vpc-guide { max-width: 1040px; margin: 0 auto; padding: 48px 20px 64px; color: #e9dccd; }
.vpc-guide h2 { color: #ffd9ac; font-size: 26px; margin: 28px 0 10px; }
.vpc-guide .lead { font-size: 18px; color: #f3e6d6; }
.vpc-guide .how-to { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; padding: 0; list-style: none; counter-reset: s; }
.vpc-guide .how-to li { counter-increment: s; padding: 16px; border-radius: 16px; background: var(--bg2); border: 1px solid var(--line); }
.vpc-guide .how-to li strong::before { content: counter(s) ". "; color: var(--orange2); }
.vpc-guide .how-to p { margin: 6px 0 0; color: var(--muted); }
.vpc-guide .copy-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 28px; }
.vpc-guide p { color: #d8c8ba; }
.vpc-guide details { border-bottom: 1px solid var(--line); padding: 12px 0; }
.vpc-guide summary { cursor: pointer; font-weight: 600; color: #ffe7cc; }
.vpc-guide a { color: var(--orange2); }

/* Phones and narrow tablets: stage on top, settings drawer below. */
@media (max-width: 820px) {
  :root { --top-h: 52px; }
  .vpc-top { padding-left: 118px; padding-right: 10px; }
  .vpc-top h1 { font-size: 18px; }
  .vpc-top h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .vpc-top { justify-content: flex-end; }
  .vpc-top .vpc-btn span { display: none; }
  .vpc-top .vpc-btn { width: 42px; padding: 0; }
  .vpc-studio { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; min-height: 0; }
  .vpc-dock { border-left: 0; border-top: 1px solid var(--line); max-height: 44dvh; }
  .vpc-tabs { order: 2; border-bottom: 0; border-top: 1px solid var(--line); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); }
  .vpc-pane { padding: 10px 12px; gap: 10px; }
  .vpc-tools { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .vpc-tools button { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 8px 2px; row-gap: 2px; }
  .vpc-tools button svg { grid-row: auto; }
  .vpc-tools button b { font-size: 12px; }
  .vpc-tools button small { display: none; }
  .vpc-tools button:last-child { grid-column: auto; }
  .vpc-stencils { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 74px; overflow-x: auto; padding-bottom: 4px; }
  .vpc-pane[data-pane="tools"] .vpc-note, .vpc-pane[data-pane="stencils"] .vpc-note { display: none; }
  .vpc-coach { top: 10px; width: calc(100% - 128px); padding: 8px 10px; }
  .vpc-coach strong { font-size: 15px; }
  .vpc-coach span { font-size: 12.5px; }
  .vpc-light-btn { right: 10px; bottom: 10px; min-height: 48px; font-size: 15px; padding: 0 16px 0 10px; }
  .vpc-hint { display: none; }
  .vpc-history { left: 8px; top: 10px; }
  .vpc-icon-btn { width: 40px; height: 40px; }
  .vpc-shapes, .vpc-skins, .vpc-modes, .vpc-scenes { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .vpc-skins { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 820px) and (max-height: 560px) and (orientation: landscape) {
  .vpc-studio { grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: none; }
  .vpc-dock { max-height: none; border-top: 0; border-left: 1px solid var(--line); }
  .vpc-tabs { order: 0; }
  .vpc-tools { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Keep the supplied editor usable at the repository's minimum touch size. */
.vpc-btn,.vpc-chip { min-height:44px; }
.vpc-icon-btn { width:44px; height:44px; flex-shrink:0; }
.vpc-tabs button { min-width:44px; min-height:44px; }
@media(max-width:820px){
 :root { --top-h:84px; }
 .vpc-top { flex-direction:column; align-items:flex-end; justify-content:center; gap:2px; }
 .vpc-top h1 { position:static; width:auto; height:auto; overflow:visible; clip:auto; white-space:nowrap; font-size:18px; }
 .vpc-title-prefix { display:none; }
 .vpc-top .vpc-btn { width:44px; }
 .vpc-icon-btn { width:44px; height:44px; }
 .vpc-coach { width:calc(100% - 120px); }
 .vpc-coach-actions { flex-wrap:wrap; }
}

@media(max-width:820px) and (max-height:560px) and (orientation:landscape){
 .vpc-studio{height:auto;grid-template-columns:1fr;grid-template-rows:minmax(260px,1fr) auto;}
 .vpc-dock{max-height:none;overflow:visible;border-top:1px solid var(--line);border-left:0;}
 .vpc-pane{overflow:visible;}
 .vpc-tools{grid-template-columns:repeat(auto-fit,minmax(100px,1fr));}
}
