:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07111f;
  color: #e5edf7;
  --bg: #07111f;
  --panel: #0b1728;
  --panel-strong: #0e1e33;
  --line: rgba(125, 160, 204, 0.28);
  --line-strong: rgba(133, 178, 236, 0.48);
  --text: #e5edf7;
  --muted: #8fa3bd;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.18);
  --danger: #f87171;
  --success: #6ee7b7;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; }
body {
  background:
    radial-gradient(circle at top left, rgba(79, 140, 255, 0.13), transparent 32%),
    linear-gradient(180deg, #07111f, #050b14);
}
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.52; }

.app-shell { min-height: 100vh; padding: 18px; display: grid; gap: 14px; align-content: start; }
.control-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; background: rgba(11, 23, 40, 0.92); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.app-title { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 260px; }
.app-title__icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: var(--accent-soft); border: 1px solid var(--line-strong); }
h1 { margin: 0; font-size: 18px; }
p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.field { display: grid; gap: 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.field select,
.field input { min-width: 118px; color: var(--text); background: #0d1b2f; border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; outline: none; }
.layout-field select { min-width: 170px; }
.timeline-checkbox { display: inline-flex; align-items: center; gap: 8px; color: var(--text); background: #0d1b2f; border: 1px solid var(--line); border-radius: 999px; padding: 9px 12px; user-select: none; }
.timeline-checkbox input { accent-color: var(--accent); }

.primary-button, .ghost-button, .icon-button { border: 1px solid var(--line); border-radius: 12px; min-height: 38px; padding: 0 14px; color: var(--text); background: #0d1b2f; }
.primary-button { background: linear-gradient(135deg, #2563eb, #4f8cff); border-color: rgba(147, 197, 253, 0.55); color: #f8fbff; font-weight: 700; }
.primary-button--send { background: linear-gradient(135deg, #1d4ed8, #2563eb); }
.ghost-button--small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.ghost-button--danger { color: #fecaca; border-color: rgba(248, 113, 113, 0.45); }
.icon-button { width: 38px; padding: 0; display: grid; place-items: center; }
.ghost-button.is-dirty::after { content: ' •'; color: var(--success); }
.ghost-button:hover, .primary-button:hover:not(:disabled), .icon-button:hover { filter: brightness(1.08); }

.mix-panel { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: rgba(11, 23, 40, 0.92); box-shadow: var(--shadow); }
.range-field { display: grid; gap: 6px; min-width: 220px; color: var(--muted); font-size: 12px; }
.range-field input { accent-color: var(--accent); }

.keyboard-stage, .edit-panel, .timeline-panel { background: rgba(11, 23, 40, 0.86); border: 1px solid var(--line); border-radius: 22px; padding: 16px; box-shadow: var(--shadow); }
.keyboard-help { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; color: var(--muted); font-size: 13px; }
.keyboard-help strong { color: var(--text); }
.key-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.key-pad { position: relative; min-height: 112px; border: 1px solid var(--line); border-radius: 18px; color: var(--text); background: linear-gradient(180deg, #10213a, #0b1728); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 10px 28px rgba(0, 0, 0, 0.26); transition: transform 90ms ease, border-color 90ms ease, background 90ms ease; user-select: none; touch-action: none; }
.key-pad:hover { border-color: var(--line-strong); }
.key-pad.is-active { transform: translateY(2px); border-color: rgba(147, 197, 253, 0.88); background: linear-gradient(180deg, #1d4ed8, #0f2b55); }
.key-pad.is-editing { outline: 2px solid rgba(110, 231, 183, 0.46); outline-offset: 2px; }
.key-pad__computer { position: absolute; top: 10px; left: 10px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: #cfe1ff; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1); font-weight: 800; }
.key-pad__edit { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; color: var(--muted); background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.09); }
.key-pad__edit:hover { color: var(--text); border-color: var(--line-strong); }
.key-pad__label { display: grid; place-items: center; min-height: 112px; font-size: 22px; font-weight: 800; }
.key-pad__notes { position: absolute; bottom: 10px; left: 10px; right: 10px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-transform: capitalize; }

.edit-panel__header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.edit-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: 10px; }
.edit-label-field { grid-column: span 2; }
.edit-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.timeline-panel { min-height: 220px; padding: 14px; }
.timeline-panel__header { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.timeline { position: relative; min-height: 178px; overflow: hidden; border-radius: 16px; background: #07111f; border: 1px solid rgba(125, 160, 204, 0.2); }
.timeline__grid { position: absolute; inset: 0; background-image: linear-gradient(to right, rgba(125,160,204,0.12) 1px, transparent 1px), linear-gradient(to bottom, rgba(125,160,204,0.08) 1px, transparent 1px); background-size: 48px 100%, 100% 44px; }
.timeline__empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; pointer-events: none; }
.timeline__block { position: absolute; height: 28px; border-radius: 9px; background: linear-gradient(135deg, rgba(79, 140, 255, 0.9), rgba(96, 165, 250, 0.65)); border: 1px solid rgba(191, 219, 254, 0.55); color: #f8fbff; display: flex; align-items: center; padding: 0 8px; font-size: 11px; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.timeline__playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #93c5fd; box-shadow: 0 0 14px rgba(147, 197, 253, 0.85); transform: translateX(-1px); z-index: 5; }
.is-recording #recordButton { background: linear-gradient(135deg, #b91c1c, #ef4444); border-color: rgba(252, 165, 165, 0.72); }
.is-playing #playButton { background: #102f55; border-color: rgba(147, 197, 253, 0.55); }

@media (max-width: 920px) {
  .control-bar { align-items: stretch; }
  .app-title { min-width: 100%; }
  .edit-label-field { grid-column: auto; }
}
