:root{
  --bg:#0b0f1a; --panel:rgba(255,255,255,.06); --panel2:rgba(255,255,255,.08);
  --border:rgba(255,255,255,.10); --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.70); --muted2:rgba(255,255,255,.55);
  --err:#ff6b6b; --accent:#7aa7ff; --shadow:0 12px 40px rgba(0,0,0,.45);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color:var(--text);
  /* Prevent wide renderers (e.g., drum grid) from forcing page-level horizontal scroll */
  overflow-x:hidden;
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(122,167,255,.20), transparent 55%),
    radial-gradient(900px 600px at 80% 30%, rgba(155,255,209,.12), transparent 60%),
    var(--bg);
  background-repeat:no-repeat;
}
.topbar{
  position:sticky; top:0; z-index:5;
  display:flex; justify-content:space-between; align-items:center;
  padding:14px 16px;
  background: linear-gradient(180deg, rgba(10,14,25,.95), rgba(10,14,25,.70));
  border-bottom:1px solid var(--border);
  backdrop-filter: blur(10px);
}
.brand{display:flex; gap:12px; align-items:center}
.logo{
  width:34px;height:34px;border-radius:12px; display:grid;place-items:center;
  background: linear-gradient(135deg, rgba(122,167,255,.35), rgba(155,255,209,.20));
  border:1px solid rgba(255,255,255,.18);
}
.title{font-weight:800}
.subtitle{font-size:12px;color:var(--muted2);margin-top:2px}
.actions{display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end}

.layout{
  max-width: none;
  width: 100%;
  margin:18px auto 30px;
  padding:0 14px;
  display:grid; grid-template-columns:420px 1fr; gap:14px;
}
@media (max-width:980px){ .layout{grid-template-columns:1fr} }

.card{
  background:var(--panel); border:1px solid var(--border);
  border-radius:18px; box-shadow:var(--shadow); padding:14px;
}
.card h2{margin:2px 2px 12px; font-size:16px}

.panel{
  background:var(--panel2); border:1px solid var(--border);
  border-radius:16px; padding:12px; margin-bottom:12px;
}
.panel h3{margin:0 0 8px; font-size:14px}

.row{display:flex; gap:10px; align-items:center; margin:8px 0}
.row label{min-width:130px; color:var(--muted)}
.row input[type="number"], .row select{
  width:100%; padding:10px 10px; border-radius:12px;
  border:1px solid rgba(255,255,255,.16);
  background:rgba(0,0,0,.25); color:var(--text); outline:none;
}
textarea{
  width:100%; min-height:120px; resize:vertical; padding:10px;
  border-radius:14px; border:1px solid rgba(255,255,255,.16);
  background:rgba(0,0,0,.25); color:var(--text);
}
.btn{
  padding:10px 12px; border-radius:999px; cursor:pointer;
  border:1px solid rgba(255,255,255,.18); background:rgba(0,0,0,.20);
  color:var(--text); font-weight:650;
}
.btn:hover{background:rgba(255,255,255,.09); border-color:rgba(255,255,255,.26)}
.btn:active{transform:translateY(1px)}
.btn.primary{
  background: linear-gradient(135deg, rgba(122,167,255,.30), rgba(155,255,209,.16));
  border-color: rgba(122,167,255,.40);
}
.btn.danger{background:rgba(255,107,107,.12); border-color:rgba(255,107,107,.35)}
.btn.ghost{background:rgba(255,255,255,.06)}
.btnrow{display:flex; gap:8px; flex-wrap:wrap; margin-top:10px}

.muted{color:var(--muted)}
.small{font-size:12px}
.err{color:var(--err); margin-top:6px; font-size:12px}

.tracklist{margin-top:10px; border:1px solid rgba(255,255,255,.12); border-radius:14px; overflow:hidden}
.trackRow{
  display:grid; grid-template-columns:24px 1fr 110px; gap:10px; align-items:center;
  padding:10px; border-bottom:1px solid rgba(255,255,255,.08); background:rgba(0,0,0,.14);
}
.trackRow:last-child{border-bottom:none}
.trackRow .name{font-weight:650}
.trackRow .meta{color:var(--muted2); font-size:12px; margin-top:2px}
.trackRow select{padding:8px 10px; border-radius:12px; width:110px}

.tabs{display:flex; gap:8px; margin:6px 0 10px}
.tab{padding:8px 10px; border-radius:999px; border:1px solid rgba(255,255,255,.16);
  background:rgba(0,0,0,.20); color:var(--text); cursor:pointer; font-weight:650;}
.tab.active{border-color:rgba(122,167,255,.55); background:rgba(122,167,255,.14)}

.output{
  margin:0; padding:10px; border-radius:14px; border:1px solid rgba(255,255,255,.14);
  background:rgba(0,0,0,.25); max-height:280px; overflow:auto; font-size:12px; line-height:1.35;
}
.pane{display:none}
.pane.active{display:block}

.toolbar{display:flex; gap:12px; align-items:center; flex-wrap:wrap; margin-bottom:10px}
.toolbar label{color:var(--muted); font-size:12px; display:flex; gap:8px; align-items:center}
.toolbar input[type="number"]{width:72px; padding:8px 10px; border-radius:12px;
  border:1px solid rgba(255,255,255,.16); background:rgba(0,0,0,.25); color:var(--text);}

.scrub{display:flex; align-items:center; gap:10px; flex:1 1 360px; min-width:280px}
.scrubLabel{gap:6px}
.scrub select{
  padding:8px 10px; border-radius:12px; border:1px solid rgba(255,255,255,.16);
  background:rgba(0,0,0,.25); color:var(--text);
}
.scrub input[type="range"]{flex:1 1 auto; min-width:160px}

.renderWrap{
  height: clamp(320px, 46vh, 620px);

  border-radius:16px;
  border:1px solid rgba(255,255,255,.14);
  /* Scroll inside the renderer panel (not the whole page) */
  overflow:auto;
  min-height:280px;
  max-width:100%;
}

/*
  The renderer can be wider than the viewport (lots of measures).
  Keep horizontal scroll inside the renderer instead of the whole page.
*/
.renderScroller{
  /* Keep as a simple inner wrapper; the panel itself is the scroll container */
  min-width:max-content;
  -webkit-overflow-scrolling: touch;
}
.renderWrap.paper{
  background:
    radial-gradient(1200px 800px at 20% 0%, rgba(0,0,0,.04), transparent 60%),
    radial-gradient(1000px 700px at 80% 40%, rgba(0,0,0,.06), transparent 55%),
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,248,250,.95));
  color: rgba(0,0,0,.88);
}
.renderWrap:not(.paper){background:rgba(0,0,0,.30)}
.gridWrap, .staffWrap{padding:14px}
.staffWrap{border-top:1px dashed rgba(0,0,0,.18)}
.renderWrap:not(.paper) .staffWrap{border-top-color:rgba(255,255,255,.12)}
.footer{max-width:1280px; margin:0 auto; padding:0 14px 22px}

.grid{
  /* Grow to content width so it can scroll inside the renderer */
  width:max-content;
  min-width:100%;
  border-collapse:collapse;
  font-size:12px;
}
.grid th,.grid td{border:1px solid rgba(0,0,0,.12); padding:4px 6px; text-align:center; white-space:nowrap}
.renderWrap:not(.paper) .grid th, .renderWrap:not(.paper) .grid td{border-color:rgba(255,255,255,.12)}
.grid th.lane,.grid td.lane{text-align:left; font-weight:750; position:sticky; left:0; background:rgba(255,255,255,.90)}
.renderWrap:not(.paper) .grid th.lane,.renderWrap:not(.paper) .grid td.lane{background:rgba(0,0,0,.28)}
.grid td.hit{font-weight:900}
.grid td.beat{background:rgba(122,167,255,.10)}


/* Sidebar toggle: maximize space for notation/grids */
.hideSidebar .layout{grid-template-columns:1fr;}
.hideSidebar .layout > section.card:first-child{display:none;}
.hideSidebar .layout{max-width: min(2200px, calc(100vw - 28px));}
