: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;
  --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; }
.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; display: block; }
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 19px; letter-spacing: .04em; line-height: 1.05; }
.brand-block p { margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.transport { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.btn {
  border: 1px solid #35547c;
  background: #101b32;
  color: var(--text);
  border-radius: 12px;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .01em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 7px 16px rgba(0,0,0,.20);
  transition: transform .12s ease, border-color .12s ease, filter .12s ease, background .12s ease;
}
.btn:hover { transform: translateY(-1px); border-color: #5d84b8; filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn.primary { color: #061018; border-color: #76ffe8; 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.good { color: #061018; border-color: #86ffb0; background: linear-gradient(180deg, #86ffb0, #45c46f); }
.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(420px, 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; }
.center-stack { min-height: 0; display: grid; grid-template-rows: 142px 154px 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; }
.panel-title-row h3 { font-size: 13px; }
.compact-title { margin-bottom: 5px; }
.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)); }
label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
select, input[type="text"], 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; }
.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;
}
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.check-row { display: flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 11px; line-height: 1.15; }
.check-row input { width: auto; accent-color: var(--cyan); }
.form-actions, .arrange-controls { display: flex; flex-wrap: wrap; gap: 7px; }
.form-actions { display: grid; grid-template-columns: 1fr 1fr; margin-top: 8px; }
.small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.phase-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.32; }
.timeline { display: flex; gap: 8px; overflow-x: auto; padding: 3px 2px 9px; scrollbar-color: #46699a #0d162a; }
.section-card {
  position: relative;
  display: grid;
  align-content: start;
  min-width: 138px;
  height: 78px;
  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;
}
.section-card:hover { border-color: var(--cyan); }
.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 { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-card .role { color: var(--cyan); font-size: 10px; font-weight: 1000; text-transform: uppercase; letter-spacing: .06em; }
.section-card .meta { color: var(--muted); font-size: 11px; }
.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; }
.arrangement-lanes { display: grid; gap: 6px; overflow: auto; max-height: 102px; padding-right: 4px; }
.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 24px 1fr; }
.meter-strip { display: grid; grid-template-columns: 118px repeat(16, minmax(23px, 1fr)); gap: 4px; align-items: center; min-height: 22px; }
.meter-cell { text-align: center; color: var(--muted); font-size: 10px; font-weight: 1000; }
.meter-cell.beat { color: var(--gold2); }
.pattern-grid { display: grid; grid-template-columns: 118px 1fr; gap: 6px; min-height: 0; overflow: hidden; }
.track-labels, .steps { display: grid; gap: 6px; align-content: start; overflow: auto; }
.track-label { height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid #283f62; background: #0d172d; border-radius: 12px; padding: 0 8px; color: var(--muted); font-size: 12px; font-weight: 1000; }
.track-label span:last-child { color: var(--cyan); font-size: 10px; }
.step-row { display: grid; grid-template-columns: repeat(16, minmax(23px, 1fr)); gap: 4px; height: 38px; }
.step-cell {
  border: 1px solid #263d64;
  background: #091226;
  border-radius: 9px;
  min-width: 0;
  position: relative;
}
.step-cell.bar-start { border-color: #55739f; }
.step-cell:hover { border-color: var(--cyan); }
.step-cell.on { background: linear-gradient(180deg, #75ffe8, #1b8f87); border-color: #9cfff1; box-shadow: 0 0 10px rgba(118,255,232,.25); }
.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: .72; }
.step-cell.playing { outline: 2px solid var(--gold2); filter: brightness(1.32); }
.step-cell .prob-dot { position: absolute; right: 3px; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,.56); }
.section-inspector { display: grid; gap: 8px; }
.inspector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.metric { border: 1px solid #2d456d; background: rgba(5,12,26,.64); border-radius: 13px; padding: 8px; min-height: 53px; }
.metric strong { display: block; color: var(--cyan); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
.metric span { display: block; margin-top: 3px; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
.ai-notes { display: grid; gap: 7px; max-height: 156px; overflow: auto; color: var(--muted); font-size: 12px; line-height: 1.35; }
.ai-note { border-left: 3px solid var(--cyan); padding: 5px 7px; background: rgba(118,255,232,.05); border-radius: 0 10px 10px 0; }
.meter-readout { border: 1px solid #2d456d; border-radius: 12px; padding: 8px; background: #071020; 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; }
.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 { 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; color: var(--muted); font-size: 11px; overflow: auto; max-height: 42px; }
.event-log div { margin-bottom: 4px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(0,0,0,.70); backdrop-filter: blur(5px); }
.modal-backdrop.active { display: flex; }
.modal-card { width: min(760px, 96vw); max-height: 92vh; overflow: auto; border: 1px solid #3e5c88; border-radius: 24px; background: linear-gradient(180deg, #172741, #0a1326); box-shadow: 0 34px 90px rgba(0,0,0,.56); padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin-bottom: 16px; }
.modal-head h2 { font-size: 24px; }
.modal-head p { margin-top: 5px; color: var(--muted); font-size: 13px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; }
.notes-card { width: min(900px, 96vw); }
.dev-notes-pre { white-space: pre-wrap; border: 1px solid var(--line); background: #050b18; border-radius: 18px; color: #d9e7ff; padding: 14px; font-size: 12px; line-height: 1.55; overflow: auto; }
::-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; }
  .center-stack { grid-template-rows: auto auto minmax(390px, auto); }
  .composer-panel, .inspector-panel { overflow: visible; }
}
@media (max-width: 640px) {
  .app-root { padding: 6px; }
  .stage { border-radius: 18px; padding: 7px; }
  .transport { justify-content: start; }
  .split-row, .checkbox-grid, .modal-grid, .footer-panel { grid-template-columns: 1fr; }
  .pattern-grid { grid-template-columns: 94px 1fr; }
  .meter-strip { grid-template-columns: 94px repeat(16, minmax(20px, 1fr)); }
  .track-label { font-size: 10px; padding: 0 5px; }
  .step-row { grid-template-columns: repeat(16, minmax(20px, 1fr)); }
}

.inline-note {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
}
