:root{
  --bg:#0b0e14; --bg2:#11151e; --panel:#151b26; --line:#222b3a; --text:#e7eef6;
  --muted:#7e8aa0; --accent:#5b8cff; --synth:#4fe3c1; --fx:#ffb454;
}
*{box-sizing:border-box}
html,body{margin:0;background:radial-gradient(120% 90% at 50% -10%,#16202c,#0b0e14 60%);
  color:var(--text);font-family:ui-sans-serif,-apple-system,"Segoe UI",system-ui,sans-serif}
a{color:inherit;text-decoration:none}
.muted{color:var(--muted)} .small{font-size:12px}

.bar{display:flex;align-items:center;justify-content:space-between;gap:16px;
  padding:14px 20px;border-bottom:1px solid var(--line);background:rgba(10,13,19,.7);
  backdrop-filter:blur(8px);position:sticky;top:0;z-index:5}
.bar .title{font-weight:700;letter-spacing:.04em}
.back{color:var(--muted);font-size:14px}
.badge{font-size:10px;letter-spacing:.12em;padding:2px 7px;border-radius:6px;border:1px solid var(--line);color:var(--muted)}
.badge.synth{color:var(--synth);border-color:#2c8c79}
.badge.fx{color:var(--fx);border-color:#8c6a2c}

.btn{display:inline-block;padding:7px 13px;border-radius:9px;border:1px solid var(--line);
  background:linear-gradient(180deg,#1b2230,#141a24);color:var(--text);font-size:13px;cursor:pointer}
.btn:hover{border-color:#33415a}
.btn.accent{background:linear-gradient(180deg,#3a63d6,#2b4fb0);border-color:#4f74e0}
.btn.big{font-size:16px;padding:12px 22px}

/* gallery */
.gallery{max-width:1000px;margin:0 auto;padding:22px 20px 60px}
.search{width:100%;padding:13px 16px;border-radius:12px;border:1px solid var(--line);
  background:var(--panel);color:var(--text);font-size:15px;margin-bottom:22px}
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:14px}
.card{background:linear-gradient(180deg,var(--panel),var(--bg2));border:1px solid var(--line);
  border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:8px;min-height:140px}
.card-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
.card-name{font-weight:600;font-size:15px}
.card-desc{margin:0;font-size:13px;color:var(--muted);line-height:1.45;flex:1;
  display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.card-actions{display:flex;align-items:center;gap:8px}

/* ---- gallery split-screen (list | live player) ---- */
html,body{height:100%}
.gallery-page{display:flex;flex-direction:column;min-height:100%}
.gallery-page .bar{position:static}
.split{flex:1;display:grid;grid-template-columns:minmax(270px,33%) 1fr;min-height:0}
.list-pane{overflow:auto;padding:16px 14px 28px;border-right:1px solid var(--line)}
.list-pane .search{margin-bottom:14px}
.list{display:flex;flex-direction:column;gap:9px}
.row{width:100%;text-align:left;cursor:pointer;background:linear-gradient(180deg,var(--panel),var(--bg2));
  border:1px solid var(--line);border-radius:12px;padding:11px 12px;display:flex;flex-direction:column;gap:6px;
  color:var(--text);font:inherit;transition:border-color .12s}
.row:hover{border-color:#33415a}
.row.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent) inset,0 6px 18px rgba(79,141,255,.12)}
.row-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
.row-name{font-weight:600;font-size:14px}
.row-desc{margin:0;font-size:12.5px;color:var(--muted);line-height:1.4;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.row-foot{display:flex;align-items:center;justify-content:space-between;gap:8px}
.row-dl{font-size:11.5px;color:var(--muted);border:1px solid var(--line);border-radius:7px;padding:2px 7px}
.row-dl:hover{color:var(--text);border-color:#33415a}
.player-pane{position:relative;overflow:hidden;background:#0d1016}
.player-pane iframe{display:block;width:100%;height:100%;border:0}
.player-hint{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  padding:24px;text-align:center;color:var(--muted);pointer-events:none}
@media(max-width:760px){
  .split{grid-template-columns:1fr}
  .list-pane{border-right:0;border-bottom:1px solid var(--line);max-height:42vh}
  .player-pane{height:74vh}
}

/* player */
.player{max-width:1000px;margin:0 auto;padding:24px 20px}
.start{text-align:center;padding:60px 0}
.start .muted{margin-top:12px;font-size:13px}
.inputbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:16px}
.seg-btn{padding:6px 12px;border-radius:8px;border:1px solid var(--line);background:var(--panel);
  color:var(--muted);font-size:13px;cursor:pointer}
.seg-btn.active{color:var(--text);border-color:var(--accent);background:#16203a}
.seg-sel{padding:6px 10px;border-radius:8px;border:1px solid var(--line);background:var(--panel);
  color:var(--text);font-size:13px;cursor:pointer;max-width:230px}
.guiwrap{border:1px solid var(--line);border-radius:14px;overflow:hidden;background:#000;min-height:420px}
.guiwrap iframe{display:block;width:100%;height:560px;border:0;background:#0b0e14}
.status{margin-top:12px;font-size:13px}

/* embedded mode — slim title on top, plugin fills the space, piano below.
   Lock to the frame height + overflow:hidden so a flickering scrollbar can't
   re-wrap the deck (the GUI area absorbs any slack via flex). */
body.embed{background:transparent;display:flex;flex-direction:column;height:100vh;overflow:hidden}
body.embed .bar{position:static;padding:9px 14px;background:transparent;backdrop-filter:none;flex:0 0 auto}
body.embed .bar .back{display:none}
/* Keep the "Download .vstai" button when embedded — it's the main surface once you
   click a gallery item. Sit it left of the title so it clears the top-right "Start
   audio" overlay (.start, below), and slim it to fit the compact bar. */
body.embed .bar{justify-content:flex-start;gap:12px}
body.embed #download{order:-1;padding:5px 11px;font-size:12px}
/* full width: the base .player has margin:0 auto, whose auto cross-axis margins
   suppress flex stretch and shrink it to content — reset them so the rack gets
   the whole frame width (more knob columns, shorter rack, nothing clipped). */
body.embed .player{flex:1 1 0;min-height:0;display:flex;flex-direction:column;gap:10px;padding:8px 12px 12px;max-width:none;width:100%;margin:0}
body.embed .deck{flex:0 0 auto;margin-bottom:0}
/* slimmer scopes + keys in the embed so the knob rack gets the vertical room */
body.embed .deck .scope canvas{height:56px}
body.embed .key{height:78px}
body.embed .key.black{height:50px}
body.embed .start{position:absolute;top:7px;right:12px;padding:0;text-align:right;z-index:10}
body.embed .start .muted{display:none}
body.embed .start .btn.big{font-size:13px;padding:7px 13px}
body.embed .guiwrap{flex:1 1 0;min-height:0;border-radius:12px;border:0}
body.embed .guiwrap iframe{height:100%}
body.embed .keys{margin:0;justify-content:center}
body.embed .status{flex:0 0 auto;padding:0 8px}
/* .deck/.inputbar set display:flex, which (author > UA) overrides the [hidden]
   attribute — so make hidden actually hide them (intro keeps the deck back; and
   synths no longer show the effect-only input bar). */
body.embed .deck[hidden], body.embed .inputbar[hidden]{display:none}

/* top deck: oscilloscope + spectrum + keyboard, side by side */
.deck{display:flex;gap:12px;flex-wrap:wrap;align-items:stretch;margin-bottom:14px}
.deck.deck-in{animation:deckIn .55s cubic-bezier(.2,.7,.2,1) both}
@keyframes deckIn{from{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:none}}
.deck .scope{flex:1 1 150px;min-width:138px;background:#06070a;border:1px solid var(--line);
  border-radius:10px;padding:8px 10px 6px}
.deck .scope .cap{font:600 9px ui-monospace,monospace;letter-spacing:.16em;color:var(--muted);
  text-transform:uppercase;display:flex;justify-content:space-between;margin-bottom:4px}
.deck .scope canvas{display:block;width:100%;height:72px}
.deck .kbd{flex:2 1 360px;min-width:288px;display:flex;flex-direction:column;gap:8px;justify-content:flex-end}
.kbd-bar{display:flex;align-items:center;gap:8px}
.oct-btn{width:30px;height:26px;border:1px solid var(--line);background:var(--panel);color:var(--text);
  border-radius:7px;cursor:pointer;font-size:11px;line-height:1}
.oct-btn:hover{border-color:var(--accent)}
.oct-label{font:600 12px ui-monospace,monospace;color:var(--text);min-width:36px;text-align:center}
.kbd-hint{margin-left:auto}
@media(max-width:560px){ .kbd-hint{display:none} }

/* on-screen keyboard for synths */
.keys{display:flex;gap:2px;margin:14px 0 0;user-select:none;-webkit-user-select:none;flex-wrap:wrap}
.key{width:34px;height:96px;border:1px solid var(--line);border-radius:0 0 6px 6px;
  background:linear-gradient(180deg,#e7eef6,#cfd8e6);color:#0b0e14;font-size:10px;
  display:flex;align-items:flex-end;justify-content:center;padding-bottom:6px;cursor:pointer}
.key.black{background:linear-gradient(180deg,#1b2230,#0b0e14);color:#7e8aa0;height:62px;width:24px;margin:0 -13px;z-index:2}
.key.down{background:linear-gradient(180deg,#5b8cff,#2b4fb0);color:#fff}
