/* Grape Soda theme. Light = lilac daytime, dark = deep grape. The drawing sheet stays lavender in both. */
:root{
  box-sizing:border-box;
  padding-top:env(safe-area-inset-top,0px);
  padding-bottom:env(safe-area-inset-bottom,0px);
  --bg:#E8DCFF; --surface:#FFFFFF; --surface2:#F3ECFF; --line:#D4C4F2;
  --ink:#2A1950; --mute:#6D5899;
  --sheet:#FCFAFF; --grid:#ECE4FA; --grid2:#C6B5E8; --sheetInk:#2A1950;
  --accent:#FFC61A; --accentInk:#2A1950;
  --t0:#EE2F66; --t1:#FF6F0F; --t2:#1490E0; --t3:#0FAF83; --beat:#FFB800;
  --keyW:#FFFFFF; --keyB:#2A1950;
}
@media (prefers-color-scheme:dark){
  :root:not([data-theme="light"]){
    --bg:#1D1137; --surface:#2C1C52; --surface2:#382664; --line:#4A3684;
    --ink:#F7F1FF; --mute:#B5A2DD;
    --sheet:#F2ECFF; --grid:#E2D8F7; --grid2:#B8A5E0;
    --accent:#FFD23F; --accentInk:#1D1137;
  }
}
:root[data-theme="dark"]{
  --bg:#1D1137; --surface:#2C1C52; --surface2:#382664; --line:#4A3684;
  --ink:#F7F1FF; --mute:#B5A2DD;
  --sheet:#F2ECFF; --grid:#E2D8F7; --grid2:#B8A5E0;
  --accent:#FFD23F; --accentInk:#1D1137;
}
*,*::before,*::after{box-sizing:inherit}
html,body{height:100%;margin:0}
body{background:var(--bg);color:var(--ink);font-family:"Bricolage Grotesque",ui-rounded,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;-webkit-font-smoothing:antialiased;overflow:hidden}
button,select,input{font:inherit;color:inherit}
button{cursor:pointer;-webkit-tap-highlight-color:transparent}
svg{display:block}
.app{height:100%;max-width:780px;margin:0 auto;padding:10px 12px 12px;display:flex;flex-direction:column;gap:8px}

/* top bar */
.top{display:flex;align-items:center;justify-content:space-between;gap:10px}
.brand{position:relative;padding-bottom:7px}
.brand .word{font-size:1.6rem;font-weight:800;letter-spacing:-.04em;line-height:1}
.brand svg{position:absolute;left:0;bottom:0;width:100%;height:9px;overflow:visible}
.topact{display:flex;gap:8px;align-items:center}
.icon{width:42px;height:42px;display:grid;place-items:center;border-radius:14px;border:1px solid var(--line);background:var(--surface);padding:0}
.icon svg{width:21px;height:21px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.icon[aria-pressed="true"]{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.pill{min-height:42px;padding:0 16px;border-radius:999px;border:1px solid var(--line);background:var(--surface);display:inline-flex;align-items:center;gap:7px;font-weight:600}
.pill svg{width:18px;height:18px;fill:none;stroke:currentColor;stroke-width:2.2;stroke-linecap:round;stroke-linejoin:round}
.pill.accent{background:var(--accent);color:var(--accentInk);border-color:transparent}

/* mode tabs */
.modes{display:flex;gap:6px;padding:4px;border-radius:999px;background:var(--surface);border:1px solid var(--line)}
.modes button{flex:1;min-height:38px;border:0;border-radius:999px;background:transparent;font-weight:600;font-size:.95rem}
.modes button[aria-pressed="true"]{background:var(--ink);color:var(--bg)}
.fxrow{display:flex;gap:6px;overflow-x:auto;scrollbar-width:none;padding:1px}
.fxrow::-webkit-scrollbar{display:none}
.fxrow[hidden]{display:none}
.fxrow button{flex:none;min-height:34px;padding:0 14px;border-radius:999px;border:1px solid var(--line);background:var(--surface2);font-size:.88rem;font-weight:600}
.fxrow button[aria-pressed="true"]{background:var(--accent);color:var(--accentInk);border-color:transparent}

/* canvas */
.stage{flex:1;min-height:220px;position:relative;background:var(--sheet);border-radius:22px;overflow:hidden;box-shadow:0 0 0 1px var(--line)}
canvas#cv{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;cursor:crosshair}
.gridbtn{position:absolute;top:8px;right:8px;z-index:2;min-height:32px;padding:0 12px;border-radius:999px;border:1.5px solid var(--grid2);background:rgba(255,255,255,.88);color:#2A1950;font-weight:700;font-size:.82rem}
.gridbtn[aria-pressed="true"]{background:#2A1950;color:#FFFFFF;border-color:#2A1950}
.gridbtn[hidden]{display:none}
.ruler{position:relative;display:flex;height:26px;border-radius:10px;background:var(--surface);border:1px solid var(--line);overflow:hidden;touch-action:none;cursor:pointer}
.ruler[hidden]{display:none}
.ruler span{flex:1;display:grid;place-items:center;font-size:.72rem;color:var(--mute);border-left:1px solid var(--line);position:relative;z-index:1;pointer-events:none}
.ruler span:first-child{border-left:0}
.ruler .win{position:absolute;top:2px;bottom:2px;border-radius:7px;background:var(--accent);opacity:.55}
.hint{margin:0;font-size:.82rem;color:var(--mute);min-height:1.2em;line-height:1.35}

/* tracks */
.tracks{display:flex;gap:7px;overflow-x:auto;scrollbar-width:none;padding:2px 1px}
.tracks::-webkit-scrollbar{display:none}
.chip{flex:none;display:flex;align-items:stretch;border-radius:16px;background:var(--surface);border:1.5px solid var(--line);overflow:hidden}
.chip.on{border-color:var(--c);box-shadow:inset 0 0 0 1.5px var(--c)}
.chip .pick{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;gap:1px;padding:6px 10px 6px 9px;border:0;background:transparent;text-align:left;min-height:48px}
.chip .nm{display:flex;align-items:center;gap:7px;font-weight:700;font-size:.95rem}
.chip .dot{width:13px;height:13px;border-radius:50%;background:var(--c);flex:none}
.chip .sub{font-size:.7rem;color:var(--mute);white-space:nowrap}
.chip .mute{width:32px;border:0;border-left:1px solid var(--line);background:transparent;color:var(--mute);font-size:.75rem;font-weight:700}
.chip .mute[aria-pressed="true"]{background:var(--ink);color:var(--bg)}
.chip.muted .pick{opacity:.45}
.chip.beat .pick{min-width:84px}

/* dock */
.dock{display:grid;grid-template-columns:1fr 1fr auto 1fr 1fr;align-items:center;justify-items:center;gap:6px}
.play{width:64px;height:64px;border-radius:50%;border:0;background:var(--accent);color:var(--accentInk);display:grid;place-items:center;box-shadow:0 6px 0 -1px color-mix(in srgb,var(--accent) 55%,#000 45%)}
.play:active{transform:translateY(3px);box-shadow:0 3px 0 -1px color-mix(in srgb,var(--accent) 55%,#000 45%)}
.play svg{width:26px;height:26px;fill:currentColor}

/* sheets */
.scrim{position:fixed;inset:0;background:rgba(14,6,30,.5);z-index:20}
.scrim[hidden]{display:none}
.sheet{position:fixed;left:0;right:0;bottom:0;z-index:21;max-width:640px;margin:0 auto;max-height:84vh;overflow:auto;background:var(--surface);color:var(--ink);border-radius:26px 26px 0 0;padding:14px 18px calc(22px + env(safe-area-inset-bottom,0px));animation:up .22s ease-out}
.sheet[hidden]{display:none}
@keyframes up{from{transform:translateY(40px);opacity:0}}
@media (prefers-reduced-motion:reduce){.sheet{animation:none}}
.sheet .grab{width:42px;height:5px;border-radius:9px;background:var(--line);margin:0 auto 10px}
.sheet header{display:flex;align-items:center;justify-content:space-between;margin-bottom:8px}
.sheet h2{margin:0;font-size:1.35rem;font-weight:800;letter-spacing:-.03em}
.sheet h3{margin:18px 0 8px;font-size:.95rem;font-weight:700;color:var(--mute)}
.set{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;border-top:1px solid var(--line)}
.set:first-of-type{border-top:0}
.set > span{font-weight:600}
.set small{display:block;color:var(--mute);font-weight:400;font-size:.78rem}
.seg{display:inline-flex;padding:3px;border-radius:999px;background:var(--surface2);border:1px solid var(--line)}
.seg button{min-height:34px;min-width:40px;padding:0 11px;border:0;border-radius:999px;background:transparent;font-size:.88rem;font-weight:600}
.seg button[aria-pressed="true"]{background:var(--ink);color:var(--surface)}
.stepper{display:inline-flex;align-items:center;border-radius:999px;background:var(--surface2);border:1px solid var(--line)}
.stepper button{width:40px;height:38px;border:0;background:transparent;font-size:1.2rem}
.stepper output{min-width:70px;text-align:center;font-weight:700;font-variant-numeric:tabular-nums}
.sel{min-height:38px;padding:0 10px;border-radius:12px;border:1px solid var(--line);background:var(--surface2)}
.switch{width:52px;height:30px;border-radius:99px;border:0;background:var(--line);position:relative;padding:0}
.switch::after{content:"";position:absolute;top:3px;left:3px;width:24px;height:24px;border-radius:50%;background:#fff;transition:transform .15s}
.switch[aria-pressed="true"]{background:var(--t3)}
.switch[aria-pressed="true"]::after{transform:translateX(22px)}
.danger{width:100%;margin-top:14px;min-height:46px;border-radius:14px;border:1.5px solid var(--t0);background:transparent;color:var(--t0);font-weight:700}
.vibes{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.vibes button{min-height:70px;border-radius:18px;border:1.5px solid var(--line);background:var(--surface2);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;font-weight:700}
.vibes button .em{font-size:1.5rem;line-height:1}
.vibes button[aria-pressed="true"]{background:var(--beat);color:#2A1950;border-color:transparent}
.big{width:100%;min-height:52px;border-radius:16px;border:0;background:var(--ink);color:var(--surface);font-weight:800;font-size:1.05rem;display:flex;align-items:center;justify-content:center;gap:9px;margin-top:12px}
.big svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.big.accent{background:var(--accent);color:var(--accentInk)}
input[type=range]{width:100%;accent-color:var(--t0);height:30px}
.rangewrap{padding:4px 0}
.rangewrap .ends{display:flex;justify-content:space-between;font-size:.78rem;color:var(--mute)}
.actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.act{min-height:64px;border-radius:16px;border:1.5px solid var(--line);background:var(--surface2);display:flex;align-items:center;gap:10px;padding:0 14px;font-weight:700;text-align:left}
.act .em{font-size:1.35rem}
.act small{display:block;font-weight:400;font-size:.74rem;color:var(--mute)}
.act.hero{grid-column:1 / -1;background:var(--accent);color:var(--accentInk);border-color:transparent;min-height:72px}
.act.hero small{color:inherit;opacity:.75}
.act:disabled{opacity:.5;cursor:default}
.status{min-height:1.3em;margin:10px 0 0;font-size:.88rem;color:var(--mute)}
.qrbox{margin-top:12px;text-align:center}
.qrbox[hidden]{display:none}
.qrbox canvas{width:min(280px,80vw);height:auto;border-radius:18px}
.linkbox{width:100%;margin-top:8px;min-height:40px;padding:0 10px;border-radius:10px;border:1px solid var(--line);background:var(--surface2);font-size:.8rem}
.linkbox[hidden]{display:none}

.toast{position:fixed;left:50%;bottom:calc(110px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);z-index:40;background:var(--ink);color:var(--bg);padding:10px 16px;border-radius:999px;font-weight:600;font-size:.9rem;max-width:90vw;text-align:center}
.toast[hidden]{display:none}

.notice{position:fixed;inset:0;z-index:50;display:grid;place-items:center;padding:24px;background:rgba(14,6,30,.6)}
.notice[hidden]{display:none}
.notice .card{max-width:340px;width:100%;padding:26px 22px 20px;border-radius:26px;background:var(--surface);text-align:center}
.notice .em{font-size:2.4rem;line-height:1;margin-bottom:10px}
.notice h2{margin:0 0 8px;font-size:1.3rem;font-weight:800;letter-spacing:-.02em}
.notice p{margin:0 0 18px;color:var(--mute);font-size:.95rem;line-height:1.45}

.pv{position:sticky;top:-14px;z-index:2;background:var(--surface);display:flex;justify-content:center;align-items:flex-end;gap:12px;padding:4px 0 10px;margin:0 -18px;}
.pv canvas{width:min(170px,40vw);aspect-ratio:9/16;border-radius:16px;background:#120827;display:block}
.pv .play{width:52px;height:52px;margin-bottom:6px}
.chips{display:flex;flex-wrap:wrap;gap:6px}
.chips button{min-height:36px;padding:0 12px;border-radius:999px;border:1.5px solid var(--line);background:var(--surface2);font-weight:600;font-size:.9rem}
.chips button[aria-pressed="true"]{background:var(--ink);color:var(--surface);border-color:var(--ink)}
.chips.emo button{font-size:1.35rem;min-width:46px;padding:0 6px}
.swatches{display:flex;flex-wrap:wrap;gap:9px}
.swatches button{width:36px;height:36px;border-radius:50%;border:2px solid var(--line);padding:0;background:var(--sw)}
.swatches button[aria-pressed="true"]{outline:3px solid var(--ink);outline-offset:2px}
.swatches button.classic{background:#2B1559;box-shadow:inset 0 0 0 4px #fff}
.namefield{display:block;margin:4px 0 6px}
.namefield span{display:block;font-weight:600;margin-bottom:6px}
.namefield small{display:block;color:var(--mute);font-weight:400;font-size:.78rem}
.namefield input{width:100%;min-height:44px;padding:0 14px;border-radius:12px;border:1.5px solid var(--line);background:var(--surface2);font-size:1rem}
.linkbtn{margin-top:8px;border:0;background:none;color:var(--t2);font-weight:700;padding:6px 0;text-decoration:underline;text-underline-offset:3px}
button:focus-visible,select:focus-visible,input:focus-visible{outline:2.5px solid var(--t2);outline-offset:2px}
@media (min-width:640px){.brand .word{font-size:1.9rem}}
@media (max-width:420px){.brand .word{font-size:1.32rem}.topact{gap:6px}.pill{padding:0 12px}.icon{width:40px;height:40px}}
