:root {
  --bg: #050814;
  --bg2: #080d1c;
  --panel: rgba(13, 21, 39, .92);
  --panel2: rgba(16, 29, 54, .84);
  --line: #294064;
  --line2: #385a87;
  --text: #e8f2ff;
  --muted: #91a6c5;
  --faint: #62789c;
  --cyan: #76ffe8;
  --cyan2: #31bcae;
  --gold: #d8aa48;
  --gold2: #ffdb86;
  --red: #ff5f7d;
  --green: #75ffa8;
  --shadow: rgba(0, 0, 0, .48);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 14% 4%, rgba(118,255,232,.17), transparent 29%),
    radial-gradient(circle at 92% 0%, rgba(216,170,72,.13), transparent 26%),
    radial-gradient(circle at 50% 105%, rgba(255,95,125,.08), transparent 35%),
    linear-gradient(135deg, #040713 0%, #091022 48%, #03050d 100%);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
.app-root { height: 100%; padding: 12px; }
.stage {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  border: 1px solid rgba(118,255,232,.17);
  border-radius: 26px;
  background: rgba(2,5,13,.54);
  box-shadow: 0 28px 80px var(--shadow), inset 0 0 0 1px rgba(255,255,255,.04);
  overflow: hidden;
  padding: 10px;
}
.topbar, .footer-panel, .panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18,30,56,.92), rgba(9,15,30,.90));
  border-radius: var(--radius);
  box-shadow: 0 14px 34px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.06);
}
.topbar {
  min-height: 74px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: minmax(260px, auto) 1fr;
  gap: 12px;
  align-items: center;
}
.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(118,255,232,.09), rgba(216,170,72,.12));
  border: 1px solid rgba(118,255,232,.25);
  box-shadow: 0 0 28px rgba(118,255,232,.12);
  flex: 0 0 auto;
}
.brand-mark svg { width: 42px; height: 42px; }
.brand-block h1 { font-size: 20px; letter-spacing: -.035em; line-height: 1.05; }
.brand-block p {
  margin-top: 5px;
  color: #a8bff0;
  text-transform: uppercase;
  letter-spacing: .11em;
  font-size: 12px;
  font-weight: 900;
}
.transport { display: flex; flex-wrap: wrap; justify-content: end; gap: 7px; }
.btn, button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line2);
  color: var(--text);
  border-radius: 12px;
  background: linear-gradient(180deg, #182b4e, #0d182e);
  font-weight: 900;
  font-size: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.btn:hover, button:hover { border-color: var(--cyan); transform: translateY(-1px); }
.btn.primary { color: #061018; border-color: #8ffff2; background: linear-gradient(180deg, #8ffff2, #31bcae); }
.btn.gold { color: #151006; border-color: #ffe4a0; background: linear-gradient(180deg, #ffe4a0, #d8aa48); }
.btn.danger { border-color: #ff7b93; background: linear-gradient(180deg, #8c223d, #3a101d); }
.btn.danger.soft { background: #291525; }
.btn.secondary { background: linear-gradient(180deg, #182b4e, #0d182e); }
.btn.ghost { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.14); color: var(--muted); }
.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(430px, 1fr) 320px;
  gap: 10px;
}
.panel { padding: 12px; min-height: 0; overflow: hidden; }
.composer-panel, .inspector-panel { display: grid; align-content: start; gap: 10px; overflow: auto; padding-right: 10px; scrollbar-color: #314d78 rgba(4,8,18,.45); }
.center-stack { min-height: 0; display: grid; grid-template-rows: 188px 154px minmax(0, 1fr); gap: 10px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.panel-title-row h2 { font-size: 16px; letter-spacing: -.02em; }
.panel-title-row h3 { font-size: 13px; letter-spacing: -.01em; }
.compact-title { margin-bottom: 5px; }
.arranger-head { align-items: start; }
.project-meta { color: var(--muted); margin-top: 5px; font-size: 12px; line-height: 1.35; }
.pill-stack { display: flex; flex-wrap: wrap; gap: 7px; justify-content: end; max-width: 330px; }
.pill, .now-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  border-radius: 999px;
  color: #08111f;
  background: linear-gradient(90deg, var(--gold2), var(--gold));
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 1000;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.pill.cyan { background: linear-gradient(90deg, var(--cyan), #9db7ff); }
.pill.gold { background: linear-gradient(90deg, #ffe6a8, var(--gold)); }
.now-pill { color: var(--green); background: rgba(6,13,25,.78); border: 1px solid #2d456d; text-transform: none; font-size: 12px; letter-spacing: 0; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
select, input[type="text"], input[type="number"], textarea {
  min-height: 34px;
  width: 100%;
  color: var(--text);
  background: rgba(4,10,22,.95);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  outline: none;
}
select:focus, input:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(118,255,232,.12); }
input[type="range"] { width: 100%; accent-color: var(--cyan); }
output { color: var(--gold2); font-weight: 1000; font-size: 12px; }
.split-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.slider-cluster label { min-width: 0; }
.mini-card {
  border: 1px solid #2e4770;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(7,14,30,.78), rgba(5,10,22,.56));
  padding: 10px;
}
.small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.compact-list { margin: 0; padding-left: 17px; color: var(--muted); font-size: 11px; line-height: 1.42; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 8px 0; }
.kit-mapper { display: grid; gap: 6px; margin-top: 8px; max-height: 190px; overflow: auto; padding-right: 2px; scrollbar-color: #314d78 rgba(4,8,18,.45); }
.kit-row { display: grid; grid-template-columns: 74px 1fr auto; gap: 6px; align-items: center; border: 1px solid #2d456d; border-radius: 12px; padding: 6px; background: rgba(5,12,26,.64); }
.kit-row strong { font-size: 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kit-row span { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kit-row.sampled { border-color: rgba(118,255,232,.55); box-shadow: inset 3px 0 0 rgba(118,255,232,.75); }
.kit-row button { min-height: 26px; padding: 4px 7px; font-size: 10px; }
.kit-note { margin-top: 8px; }
.arranger-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding-bottom: 8px; }
.timeline {
  display: flex;
  gap: 8px;
  min-height: 104px;
  overflow-x: scroll;
  overflow-y: hidden;
  padding: 4px 4px 18px;
  margin: 0 -2px;
  scrollbar-width: thin;
  scrollbar-color: var(--cyan) rgba(4,8,18,.72);
  scrollbar-gutter: stable both-edges;
  overscroll-behavior-x: contain;
  border-radius: 16px;
}
.timeline:focus { outline: 2px solid rgba(118,255,232,.52); outline-offset: 2px; }
.timeline::-webkit-scrollbar { height: 13px; }
.timeline::-webkit-scrollbar-track {
  background: linear-gradient(90deg, rgba(4,8,18,.78), rgba(15,30,56,.95));
  border: 1px solid rgba(118,255,232,.18);
  border-radius: 999px;
}
.timeline::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, var(--cyan), var(--gold), var(--red));
  border: 2px solid rgba(4,8,18,.80);
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(118,255,232,.24);
}
.timeline::-webkit-scrollbar-thumb:hover { background: linear-gradient(90deg, #a9fff4, #ffe1a0, #ff8ba1); }
.x-scroll-hint { margin: 2px 4px 0; color: var(--faint); font-size: 10px; font-weight: 800; letter-spacing: .03em; }
.section-card {
  position: relative;
  display: grid;
  align-content: start;
  min-width: 148px;
  flex: 0 0 148px;
  height: 82px;
  gap: 3px;
  border: 1px solid #30486f;
  background: linear-gradient(180deg, #172844, #0b1428);
  border-radius: 16px;
  padding: 9px 9px 12px;
  color: var(--text);
  text-align: left;
  overflow: hidden;
  cursor: pointer;
}
.section-card:hover { border-color: var(--cyan); }
.section-card.selected, .section-card.active { outline: 2px solid rgba(118,255,232,.9); background: linear-gradient(180deg, #1e3a5a, #10203c); }
.section-card.playing { box-shadow: 0 0 0 3px rgba(216,170,72,.55), 0 0 28px rgba(216,170,72,.25); }
.section-card h4 { margin: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-card p, .section-card .meta { color: var(--muted); font-size: 11px; }
.section-card .role { color: var(--cyan); font-size: 10px; font-weight: 1000; text-transform: uppercase; letter-spacing: .06em; }
.section-energy { position: absolute; left: 0; bottom: 0; height: 5px; width: var(--energyWidth, 50%); background: linear-gradient(90deg, var(--cyan), var(--gold), var(--red)); border-radius: 0 8px 8px 0; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.badge, .tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 2px 7px;
  font-size: 10px;
  color: var(--muted);
  background: rgba(255,255,255,.04);
}
.tag.hot { color: #071018; border-color: var(--gold2); background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.arrangement-lanes { display: grid; gap: 6px; overflow: auto; max-height: 104px; padding-right: 4px; scrollbar-color: #314d78 rgba(4,8,18,.45); }
.lane-section { display: grid; grid-template-columns: 130px 1fr; gap: 8px; align-items: center; }
.lane-label { padding: 7px 8px; border-radius: 12px; background: #0c172e; border: 1px solid #2b4268; color: var(--text); font-size: 12px; font-weight: 1000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane-bars { display: grid; grid-template-columns: repeat(8, minmax(24px, 1fr)); gap: 4px; }
.lane-bar { height: 25px; border: 1px solid #263b5e; border-radius: 9px; background: #0a1326; position: relative; overflow: hidden; }
.lane-bar::before { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--energy, 55%); background: linear-gradient(90deg, rgba(118,255,232,.70), rgba(216,170,72,.78)); opacity: .8; }
.lane-bar.fill::after { content: 'F'; position: absolute; right: 6px; top: 3px; color: #081018; background: var(--gold2); border-radius: 6px; padding: 1px 4px; font-size: 10px; font-weight: 1000; }
.lane-bar.texture::after { content: 'T'; position: absolute; left: 6px; top: 3px; color: #081018; background: var(--cyan); border-radius: 6px; padding: 1px 4px; font-size: 10px; font-weight: 1000; }
.grid-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.grid-hint { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.step-grid {
  min-height: 0;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid #2d456d;
  background: rgba(4,10,22,.48);
  padding: 10px;
  scrollbar-color: #314d78 rgba(4,8,18,.45);
}
.grid-row { display: grid; grid-template-columns: 118px repeat(16, minmax(32px, 1fr)); min-width: 760px; gap: 4px; margin-bottom: 6px; }
.grid-row.header { position: sticky; top: -10px; z-index: 4; background: rgba(8,15,30,.98); padding-bottom: 3px; backdrop-filter: blur(6px); }
.track-label, .step-cell {
  min-height: 38px;
  border: 1px solid #263d64;
  border-radius: 9px;
  display: grid;
  place-items: center;
}
.track-label {
  position: sticky;
  left: -10px;
  z-index: 3;
  justify-items: start;
  padding: 0 8px;
  background: #0d172d;
  color: var(--muted);
  font-size: 12px;
  font-weight: 1000;
}
.header .track-label { z-index: 5; }
.header .step-cell { color: var(--muted); font-size: 11px; font-weight: 1000; border-color: transparent; background: transparent; }
.header .step-cell.downbeat { color: var(--gold2); }
.step-cell { min-width: 0; position: relative; background: #091226; color: #071018; font-size: 12px; font-weight: 1000; user-select: none; }
.step-cell.downbeat { border-color: #55739f; }
.step-cell:hover { border-color: var(--cyan); }
.step-cell.active { background: linear-gradient(180deg, #75ffe8, #1b8f87); border-color: #9cfff1; box-shadow: 0 0 10px rgba(118,255,232,.25); }
.step-cell.active.accent, .step-cell.accent { background: linear-gradient(180deg, #ffe7a3, #be812a); border-color: #ffe8aa; }
.step-cell.ghost { background: linear-gradient(180deg, rgba(118,255,232,.5), rgba(28,105,100,.7)); opacity: .78; }
.step-cell.playhead::after { content: ''; position: absolute; inset: -3px; border: 2px solid var(--gold2); border-radius: 12px; pointer-events: none; filter: drop-shadow(0 0 7px rgba(216,170,72,.45)); }
.step-cell .note { font-size: 10px; line-height: 1; }
.inspector { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.info-line { border: 1px solid #2d456d; background: rgba(5,12,26,.64); border-radius: 13px; padding: 8px; min-height: 53px; }
.info-line span { display: block; color: var(--cyan); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; font-weight: 1000; }
.info-line strong { display: block; margin-top: 3px; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
.inspector > div:not(.info-line) { grid-column: 1 / -1; }
.ai-list { margin: 7px 0 0; padding-left: 17px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.producer-notes { white-space: pre-wrap; color: var(--muted); line-height: 1.4; max-height: 132px; overflow: auto; margin: 0; font-family: inherit; font-size: 12px; scrollbar-color: #314d78 rgba(4,8,18,.45); }
.mixer { display: grid; gap: 8px; }
.mix-row { display: grid; grid-template-columns: 66px 1fr 46px; align-items: center; gap: 8px; padding: 7px; border: 1px solid #2d456d; border-radius: 13px; background: rgba(5,12,26,.64); }
.mix-row button { min-height: 30px; padding: 5px 7px; font-size: 11px; }
.mix-row label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 700; }
.mix-row span:last-child { color: var(--text); font-size: 12px; font-weight: 900; text-align: right; }
.mix-row.muted { opacity: .52; }
.footer-panel { min-height: 62px; padding: 10px 12px; display: grid; grid-template-columns: 1fr 1fr 1.35fr; gap: 12px; align-items: start; overflow: hidden; }
.status-line, .playhead-line, .event-log { color: var(--muted); font-size: 12px; line-height: 1.4; }
.status-line strong, .playhead-line strong { color: var(--text); }
.event-log { border-left: 1px solid var(--line); padding-left: 10px; overflow: auto; max-height: 42px; scrollbar-color: #314d78 rgba(4,8,18,.45); }
.docs-dialog {
  max-width: 720px;
  color: var(--text);
  background: linear-gradient(180deg, #172741, #0a1326);
  border: 1px solid #3e5c88;
  border-radius: 24px;
  box-shadow: 0 34px 90px rgba(0,0,0,.56);
  padding: 20px;
}
.docs-dialog::backdrop { background: rgba(0,0,0,.70); backdrop-filter: blur(5px); }
.docs-dialog h2 { margin-bottom: 8px; }
.docs-dialog p, .docs-dialog li { color: var(--muted); line-height: 1.45; }
.dialog-close { float: right; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(4,8,18,.45); border-radius: 999px; }
::-webkit-scrollbar-thumb { background: #314d78; border-radius: 999px; border: 2px solid rgba(4,8,18,.45); }
::-webkit-scrollbar-thumb:hover { background: #4a6fa4; }
@media (max-width: 1180px) {
  body { overflow: auto; }
  .app-root { min-height: 100%; height: auto; }
  .stage { min-height: 100vh; height: auto; overflow: visible; }
  .topbar, .workspace, .footer-panel { grid-template-columns: 1fr; }
  .transport { justify-content: start; }
  .center-stack { grid-template-rows: auto auto minmax(440px, auto); }
  .composer-panel, .inspector-panel { overflow: visible; }
}
@media (max-width: 640px) {
  .app-root { padding: 6px; }
  .stage { border-radius: 18px; padding: 7px; }
  .split-row, .footer-panel { grid-template-columns: 1fr; }
  .grid-row { grid-template-columns: 92px repeat(16, minmax(28px, 1fr)); }
  .track-label { font-size: 10px; padding: 0 5px; }
  .inspector { grid-template-columns: 1fr; }
  .lane-section { grid-template-columns: 94px 1fr; }
}
