:root {
  --bg: #FFF6E8; --card: #FFFFFF; --ink: #2B2350; --soft: #6E6890; --line: #EDE3D2; --cell: #FBF1E0; --beat: #F4E7D0;
  --pink: #FF5DA2; --orange: #FF6B4A; --yellow: #FFB627; --green: #3DDC97; --blue: #4D9DE0; --purple: #9B5DE5;
  --r: 18px; --ease: cubic-bezier(.34, 1.56, .64, 1);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 500 16px/1.4 Fredoka, system-ui, sans-serif; min-height: 100vh; overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.grow { flex: 1; }
.bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* top bar */
.tbar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; max-width: 1440px; margin: 0 auto; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 24px; display: flex; align-items: center; gap: 10px; margin-right: 6px; }
.blob { width: 30px; height: 30px; border-radius: 50%; background: conic-gradient(var(--pink), var(--yellow), var(--green), var(--blue), var(--purple), var(--pink)); }
.play { display: flex; align-items: center; gap: 8px; background: var(--green); color: #fff; font-weight: 700; font-size: 20px; padding: 10px 24px; border-radius: 999px; box-shadow: 0 5px 0 #23a873; transition: transform .2s var(--ease); }
.play:active { transform: translateY(3px); box-shadow: 0 2px 0 #23a873; }
.play svg { fill: currentColor; stroke: none; width: 22px; height: 22px; }
.play .i-stop, .play.on .i-play { display: none; }
.play.on .i-stop { display: block; }
.play.on { background: var(--orange); box-shadow: 0 5px 0 #c94a2d; }
.seg { display: flex; background: var(--card); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { padding: 7px 14px; border-radius: 999px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.seg button.on { background: var(--ink); color: #fff; }
.seg button svg { width: 14px; height: 14px; }
.pick { position: relative; }
.patbtn { background: var(--card); border-radius: 999px; padding: 9px 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; max-width: 220px; }
.patbtn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.patbtn i, .menu i { width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--orange)); flex: none; }
.menu { position: absolute; top: calc(100% + 6px); left: 0; background: var(--card); border-radius: 16px; padding: 6px; min-width: 210px; box-shadow: 0 10px 30px rgba(43, 35, 80, .18); z-index: 20; display: grid; gap: 2px; }
.menu[hidden] { display: none; }
.menu button { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; font-weight: 600; text-align: left; }
.menu button:hover, .menu button.on { background: var(--bg); }
.tempo { display: flex; align-items: center; gap: 6px; background: var(--card); border-radius: 999px; padding: 4px; }
.tempo div { text-align: center; min-width: 44px; line-height: 1; }
.tempo b { font-size: 19px; display: block; } .tempo small { color: var(--soft); font-size: 12px; }
.round { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--card); flex: none; }
.tempo .round { background: var(--bg); width: 36px; height: 36px; }
.vol { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 999px; padding: 8px 14px; }
.vol input { width: 90px; accent-color: var(--green); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 600; transition: transform .2s var(--ease); }
.pill:hover { transform: scale(1.04); }
.pill.ghost { background: var(--bg); color: var(--ink); }
.wplay { background: var(--green); }
.wplay.on { background: var(--orange); }
.tbar .pill.ghost { background: var(--card); }
.pill svg { width: 18px; height: 18px; }
.locked { opacity: .55; }
.lock { width: 14px; height: 14px; }

/* studio grid */
.studio { display: grid; grid-template-columns: var(--bw, 220px) minmax(0, 1fr) var(--mw, 270px); grid-template-areas: "browser rack mixer" "browser playlist mixer"; gap: 14px; padding: 4px 20px 30px; max-width: 1800px; margin: 0 auto; align-items: start; }
.browser { grid-area: browser; } .rack { grid-area: rack; } .playlist { grid-area: playlist; } .mixer { grid-area: mixer; }
.grip { position: absolute; top: 0; bottom: 0; width: 14px; cursor: col-resize; touch-action: none; display: grid; place-items: center; z-index: 2; }
.grip::after { content: ''; width: 5px; height: 48px; border-radius: 9px; background: var(--line); transition: background .15s, height .2s var(--ease); }
.grip:hover::after, .grip:focus-visible::after, .grip.on::after { background: var(--soft); height: 80px; }
.mixer .grip { left: -14px; } .browser .grip { right: -14px; }
.win { position: relative; background: var(--card); border-radius: var(--r); box-shadow: 0 6px 0 var(--line); padding: 14px; min-width: 0; }
.win h4 { margin: 0 0 10px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.win h4 small { color: var(--soft); font-weight: 500; font-size: 13px; margin-left: auto; text-align: right; }
.q { width: 22px; height: 22px; border-radius: 50%; background: var(--bg); font-size: 13px; font-weight: 700; color: var(--soft); flex: none; }
.ptabs { display: none; }

/* browser */
.draw { width: 100%; justify-content: center; background: var(--pink); margin-bottom: 4px; }
.grp { color: var(--soft); font-size: 13px; font-weight: 600; margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 6px; }
.snd { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border-radius: 12px; font-weight: 600; user-select: none; }
body.dragok .snd .nm, body.dragok .chip, body.dragok .blk { touch-action: none; }
.snd:hover { background: var(--bg); }
.snd i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.snd .nm { flex: 1; text-align: left; padding: 4px 0; }
.snd .hear { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: var(--soft); }
.snd .hear svg { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.snd.locked { pointer-events: none; }
.gate { font-size: 13px; color: var(--soft); background: var(--bg); border-radius: 12px; padding: 8px 10px; margin-top: 6px; display: flex; gap: 6px; align-items: flex-start; }
.gate svg { width: 14px; height: 14px; margin-top: 2px; }

/* channel rack */
.rack.over { outline: 3px dashed var(--green); outline-offset: 2px; }
.rrow { display: grid; grid-template-columns: 22px 118px minmax(0, 1fr) 26px; gap: 8px; align-items: center; margin-bottom: 6px; }
.led { width: 16px; height: 16px; border-radius: 50%; background: var(--green); margin: auto; }
.led.off { background: var(--line); }
.cname { background: var(--bg); border-radius: 999px; padding: 6px 12px; font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.cname span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cname i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.cname svg { width: 14px; height: 14px; margin-left: auto; color: var(--soft); }
.st { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 4px; }
.st button { aspect-ratio: 1.15; border-radius: 7px; background: var(--cell); min-width: 0; transition: transform .15s var(--ease); }
.st button.b { background: var(--beat); }
.st button.on { background: var(--c); transform: scale(1.06); }
.st button.now { outline: 3px solid var(--ink); outline-offset: -3px; }
.mini { height: 32px; border-radius: 8px; background: var(--cell); position: relative; overflow: hidden; text-align: left; }
.mini em { position: absolute; height: 5px; border-radius: 3px; background: var(--c); }
.mini b { position: absolute; inset: 0; display: grid; place-items: center; color: var(--soft); font-size: 13px; font-weight: 500; }
.mini .ph { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); }
.del { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: var(--soft); }
.del svg { width: 14px; height: 14px; }
.rack .bar { margin-top: 10px; }

/* playlist */
.shelf { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--bg); font-weight: 600; border: 3px solid transparent; user-select: none; }
.chip i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.chip.on { border-color: var(--c); }
.pl { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 8px; }
.ruler { display: grid; grid-template-columns: repeat(var(--bars), 1fr); color: var(--soft); font-size: 12px; font-weight: 600; height: 18px; }
.tname { height: 40px; display: flex; align-items: center; font-weight: 600; margin-bottom: 6px; color: var(--soft); }
.lanes { position: relative; }
.lane { height: 40px; border-radius: 10px; background: var(--cell); position: relative; margin-bottom: 6px; display: grid; grid-template-columns: repeat(var(--bars), 1fr); }
.lane.over { outline: 3px dashed var(--green); }
.lane .cellb { border-right: 1px solid var(--line); }
.blk { position: absolute; top: 4px; bottom: 4px; border-radius: 9px; background: var(--c); color: #fff; font-weight: 600; font-size: 13px; padding: 0 8px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }
.head { position: absolute; top: 18px; bottom: 6px; width: 3px; background: var(--ink); border-radius: 2px; pointer-events: none; }

/* mixer */
.chs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.ch { display: grid; justify-items: center; gap: 8px; background: var(--bg); border-radius: 14px; padding: 10px 6px; min-width: 56px; }
.ch b { font-size: 12px; white-space: nowrap; max-width: 60px; overflow: hidden; text-overflow: ellipsis; }
.ch .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.ch input[type=range].fader { writing-mode: vertical-lr; direction: rtl; height: 110px; width: 26px; accent-color: var(--c); }
.ch input[type=range].pan { width: 50px; accent-color: var(--c); }
.ch small { font-size: 11px; color: var(--soft); margin-top: -6px; }
.tog { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--card); }
.tog.on { background: var(--purple); color: #fff; }
.tog.mute.on { background: var(--orange); }

/* locked panel */
.lockbox { text-align: center; padding: 24px 12px; color: var(--soft); display: grid; justify-items: center; gap: 8px; }
.lockbox .big { width: 54px; height: 54px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; }
.lockbox .big svg { width: 26px; height: 26px; }
.lockbox b { color: var(--ink); font-size: 17px; }
.meter { width: 160px; height: 10px; border-radius: 9px; background: var(--bg); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--green); border-radius: 9px; }

/* windows + coach */
.overlay { position: fixed; inset: 0; background: rgba(43, 35, 80, .45); display: grid; place-items: center; padding: 16px; z-index: 30; }
.overlay[hidden] { display: none; }
.wbox { background: var(--card); border-radius: 24px; padding: 16px; width: min(1100px, 100%); max-height: calc(100vh - 32px); overflow: auto; animation: pop .3s var(--ease); }
.whead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.whead h3 { margin: 0; font-size: 22px; }
.wcanvas { background: var(--bg); border-radius: 14px; padding: 8px; }
canvas { display: block; width: 100%; touch-action: none; border-radius: 10px; }
.hint { color: var(--soft); margin: 10px 4px 0; }
.pens { display: flex; gap: 6px; flex-wrap: wrap; }
.pen { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--bg); font-weight: 600; border: 3px solid transparent; }
.pen i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); }
.pen.on { border-color: var(--c); }
.coach .card, #coach .card { background: var(--card); border-radius: 24px; padding: 24px; max-width: 440px; width: 100%; animation: pop .35s var(--ease); max-height: calc(100vh - 32px); overflow: auto; }
#coach h3 { margin: 0 0 8px; font-size: 24px; }
#coach ol { padding-left: 22px; margin: 0 0 16px; display: grid; gap: 8px; font-size: 17px; }
#coach ol:empty { display: none; }
.tag { display: inline-block; background: var(--yellow); color: var(--ink); font-weight: 700; font-size: 13px; padding: 3px 10px; border-radius: 999px; margin-bottom: 8px; }
.tag:empty { display: none; }
.opt { margin-bottom: 14px; } .opt p { margin: 0 0 6px; font-weight: 600; }
.opt .seg { background: var(--bg); display: inline-flex; flex-wrap: wrap; }
#coachBody .pill.warn { background: var(--orange); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 90px); background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px; transition: transform .3s var(--ease); pointer-events: none; z-index: 40; max-width: calc(100vw - 32px); text-align: center; }
.toast.on { transform: translate(-50%, 0); }
.dragghost { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: #fff; padding: 6px 12px; border-radius: 999px; font-weight: 600; transform: translate(-50%, -120%); }
.dragghost[hidden] { display: none; }

@media (max-width: 1100px) {
  .grip { display: none; }
  .studio { grid-template-columns: 200px minmax(0, 1fr); grid-template-areas: "browser rack" "browser playlist" "mixer mixer"; }
}
@media (max-width: 760px) {
  .tbar { padding: 10px 16px; gap: 8px; }
  .brand { font-size: 21px; flex: 1 0 50%; }
  #gear { order: 1; }
  .tbar > :not(.brand):not(#gear) { order: 2; }
  .play { padding: 8px 18px; font-size: 18px; }
  #wav span, .vol { display: none; }
  .tbar .grow { display: none; }
  .patbtn { max-width: 160px; }
  .ptabs { display: flex; gap: 6px; padding: 4px 16px 10px; overflow-x: auto; }
  .ptabs button { padding: 8px 14px; border-radius: 999px; background: var(--card); font-weight: 600; white-space: nowrap; }
  .ptabs button.on { background: var(--ink); color: #fff; }
  .studio { display: block; padding: 0 16px 30px; }
  .studio > [data-panel] { display: none; }
  .studio > [data-panel].show { display: block; }
  .rrow { grid-template-columns: 18px 84px minmax(0, 1fr) 22px; gap: 5px; }
  .cname { padding: 5px 8px; font-size: 14px; }
  .st { gap: 4px; grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .st button { border-radius: 6px; aspect-ratio: 1; }
  .rrow { align-items: start; }
  .pl { grid-template-columns: 54px minmax(0, 1fr); }
  .tname { white-space: nowrap; font-size: 14px; }
  .win h4 { flex-wrap: wrap; }
  .win h4 small { width: 100%; margin-left: 0; text-align: left; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
