@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  color-scheme: dark;
  --canvas: #151514;
  --panel: #1e1e1c;
  --edge: #35342f;
  --text: #f5f2eb;
  --muted: #b4b0a5;
  --accent: #f1bc70;
  --red: #ff9386;
  --mono: 'IBM Plex Mono', Consolas, monospace;
  font-family: Geist, system-ui, sans-serif;
  background: var(--canvas);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .38; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }

.studio { width: min(100% - 48px, 1024px); margin: 0 auto; padding: 46px 0 24px; }
.masthead, .panel-head, .studio-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.masthead { margin-bottom: 26px; }
.brand { display: flex; align-items: center; gap: 16px; }
.brand-mark { display: flex; align-items: center; justify-content: center; gap: 3px; width: 49px; height: 49px; flex: none; border-radius: 14px; background: var(--accent); color: #251c10; }
.brand-mark i { width: 3px; height: 9px; border-radius: 4px; background: currentColor; }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(4) { height: 15px; }
.brand-mark i:nth-child(3) { height: 23px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(26px, 4vw, 36px); font-weight: 650; line-height: 1; letter-spacing: -.055em; }
.brand p { color: var(--muted); font-size: 13px; margin-top: 7px; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -.02em; }

.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 15px; }
.instrument { padding: 15px 17px 17px; margin-bottom: 16px; }
.panel-head { min-height: 38px; }
.keyboard-controls, .stepper, .volume, .transport, .track-name, .track-actions, .inspector { display: flex; align-items: center; gap: 9px; }
.keyboard-controls { gap: 16px; }
.stepper { gap: 0; background: #171715; border: 1px solid var(--edge); border-radius: 8px; }
.stepper span { text-align: center; width: 72px; font: 11px var(--mono); color: var(--muted); }
.stepper button { width: 29px; height: 29px; border: 0; background: transparent; color: var(--text); border-radius: 7px; font-size: 17px; }
.stepper button:hover:not(:disabled) { background: #35332e; }
.volume { color: var(--muted); gap: 8px; }
.speaker { font-size: 13px; letter-spacing: -2px; padding-right: 2px; }
.volume input { width: 76px; height: 18px; margin: 0; accent-color: var(--accent); }

.piano { position: relative; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 3px; height: clamp(132px, 20vw, 177px); margin-top: 12px; border-radius: 8px; user-select: none; touch-action: none; }
.key { display: flex; flex-direction: column; align-items: center; justify-content: end; gap: 7px; min-width: 0; padding: 0 0 13px; border: 0; border-radius: 3px 3px 7px 7px; background: #f0ede4; color: #3c392f; box-shadow: inset 0 -5px #c9c4b7; }
.key:hover { background: #fffaeb; }
.key.active { background: var(--accent); box-shadow: inset 0 -3px #ad7735; }
.key.black { position: absolute; top: 0; bottom: 38%; width: 7.4%; z-index: 1; transform: translateX(-50%); padding-bottom: 10px; background: #272724; color: #eee9da; border: 1px solid #121211; box-shadow: inset 0 -4px #11110f, 0 3px 4px #100f0f49; }
.key.black:hover { background: #3b3933; }
.key.black.active { color: #1f180e; background: #dba456; box-shadow: inset 0 -3px #99682e; }
.key kbd { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 3px; border: 1px solid #39322928; border-radius: 5px; font: 500 11px var(--mono); background: #ffffff4a; }
.key.black kbd { background: #ffffff12; border-color: #ffffff24; }
.key-name { font-size: 10px; font-weight: 550; opacity: .85; }

.track { overflow: hidden; }
.track-head { display: grid; grid-template-columns: 1fr auto 1fr; padding: 12px 17px; }
.track-head > :last-child { justify-self: end; }
.note-count, .timecode { font: 11px var(--mono); color: var(--muted); white-space: nowrap; }
.timecode { min-width: 63px; margin-left: 5px; font-size: 12px; color: var(--text); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 34px; padding: 0 12px; border: 1px solid var(--edge); border-radius: 8px; background: #272623; color: var(--text); white-space: nowrap; font-size: 12px; font-weight: 600; }
.button:hover:not(:disabled) { background: #38362f; }
.button.square { width: 34px; padding: 0; }
.export { min-height: 38px; }
.record { color: #20160d; border-color: var(--accent); background: var(--accent); min-width: 91px; }
.record:hover:not(:disabled) { background: #ffcc86; }
.record[aria-pressed='true'] { background: #f5a093; border-color: #f5a093; }
.icon { display: inline-block; flex: none; position: relative; }
.record-dot { width: 8px; height: 8px; background: currentColor; border-radius: 50%; }
.record[aria-pressed='true'] .record-dot { border-radius: 2px; }
.play { width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 8px solid currentColor; margin-left: 2px; }
.stop { width: 9px; height: 9px; border-radius: 1px; background: currentColor; }
.rewind { width: 10px; height: 11px; border-left: 2px solid currentColor; }
.rewind::after { content: ''; position: absolute; top: 0; right: 0; border-top: 5.5px solid transparent; border-bottom: 5.5px solid transparent; border-right: 7px solid currentColor; }
.download { width: 12px; height: 12px; border-bottom: 1.5px solid currentColor; }
.download::before { content: ''; position: absolute; width: 1.5px; height: 7px; left: 5px; top: 0; background: currentColor; }
.download::after { content: ''; position: absolute; width: 5px; height: 5px; top: 4px; left: 3.5px; border-right: 1.5px solid; border-bottom: 1.5px solid; transform: rotate(45deg); }
.undo-icon { font-size: 23px; font-weight: 400; line-height: 1; }
.trash { width: 9px; height: 9px; margin-top: 3px; border: 1px solid currentColor; border-radius: 0 0 2px 2px; }
.trash::before { content: ''; position: absolute; width: 13px; height: 1px; background: currentColor; left: -3px; top: -3px; }
.trash::after { content: ''; position: absolute; width: 5px; height: 2px; border: 1px solid currentColor; border-bottom: 0; left: 1px; top: -5px; }

.timeline { --lane-height: 16px; --ruler-height: 27px; --label-width: 51px; position: relative; max-height: 292px; overflow: auto; background: #181816; border-block: 1px solid var(--edge); scrollbar-color: #555148 #22211e; }
.timeline-surface { display: grid; grid-template-columns: var(--label-width) auto; width: max-content; min-width: 100%; }
.pitch-labels { position: sticky; left: 0; z-index: 4; padding-top: var(--ruler-height); color: var(--muted); background: #1c1c19; border-right: 1px solid var(--edge); font: 9px var(--mono); }
.pitch-labels::before { content: ''; display: block; position: sticky; top: 0; height: var(--ruler-height); margin-top: calc(-1 * var(--ruler-height)); background: #1c1c19; border-bottom: 1px solid var(--edge); }
.pitch-labels div { display: flex; height: var(--lane-height); align-items: center; justify-content: center; border-bottom: 1px solid #2d2c27; }
.pitch-labels div:nth-last-child(1) { border-bottom: 0; }
.pitch-labels div.accidental { color: #89857a; }
.timeline-body { position: relative; min-width: 0; }
.ruler { position: sticky; top: 0; height: var(--ruler-height); z-index: 2; background: #1c1c19; border-bottom: 1px solid var(--edge); cursor: crosshair; }
.tick { position: absolute; top: 6px; padding-left: 6px; height: 20px; border-left: 1px solid #49463d; color: var(--muted); font: 10px var(--mono); pointer-events: none; }
.roll { position: relative; min-height: 0; cursor: crosshair; background-color: #191917; }
.lanes { background-image: repeating-linear-gradient(to right, #c7baa52e 0 1px, transparent 1px var(--second)), repeating-linear-gradient(to right, #c7baa510 0 1px, transparent 1px calc(var(--second) / 4)); }
.lane { height: var(--lane-height); border-bottom: 1px solid #39362b70; }
.lane.accidental { background: #12121144; }
.lane:last-child { border: 0; }
.notes { position: absolute; inset: 0; pointer-events: none; }
.note { position: absolute; display: block; height: calc(var(--lane-height) - 3px); padding: 0; border: 1px solid #e1ac66; border-radius: 3px; background: #c88d45; pointer-events: auto; cursor: grab; touch-action: none; }
.note:hover, .note.selected { background: var(--accent); }
.note.selected { border-color: #ffe2b6; box-shadow: 0 0 0 1px #ffe2b6; z-index: 1; }
.note:active { cursor: grabbing; }
.note .resize { position: absolute; inset: 0 0 0 auto; width: min(8px, 35%); cursor: ew-resize; }
.note.selected .resize { border-right: 2px solid #815b30; }
.playhead { position: absolute; z-index: 3; inset: 0 auto 0 0; width: 1px; background: var(--accent); pointer-events: none; }
.playhead::before { content: ''; position: sticky; top: 0; display: block; width: 9px; height: 10px; margin-left: -4px; border-radius: 1px; background: var(--accent); clip-path: polygon(0 0,100% 0,100% 55%,50% 100%,0 55%); }
.empty { position: absolute; top: 50%; left: var(--viewport-center); transform: translate(-50%, -50%); width: max-content; max-width: 85%; padding: 10px 15px; border: 1px solid #423e33; border-radius: 8px; background: #24221d; color: var(--muted); font-size: 12px; text-align: center; pointer-events: none; }
.empty strong { color: var(--text); font-weight: 600; }
.track-footer { display: flex; align-items: center; min-height: 56px; padding: 9px 17px; color: var(--muted); font-size: 12px; }
.inspector { flex-wrap: wrap; gap: 8px 14px; }
.inspector label { display: flex; align-items: center; gap: 6px; }
.inspector input, .inspector select { min-height: 29px; padding: 3px 6px; border: 1px solid var(--edge); border-radius: 6px; background: #171715; color: var(--text); font: 11px var(--mono); }
.inspector input { width: 68px; }
.delete { min-height: 29px; color: var(--red); }
.studio-footer { margin-top: 15px; color: var(--muted); font-size: 11px; }
.studio-footer a { color: inherit; text-underline-offset: 3px; }

@media (max-width: 620px) {
  .studio { width: calc(100% - 24px); padding-top: 24px; }
  .masthead { margin-bottom: 19px; }
  .brand { gap: 10px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
  .brand p { font-size: 11px; line-height: 1.35; }
  .export { gap: 5px; padding: 0 8px; font-size: 11px; }
  .instrument { padding: 11px; }
  .keyboard-controls { gap: 10px; }
  .volume input { width: 48px; }
  .key-name { font-size: 9px; }
  .track-head { grid-template-columns: 1fr auto; gap: 8px; padding: 10px 11px; }
  .transport { grid-row: 2; grid-column: 1 / -1; }
  .track-head > :last-child { grid-row: 1; grid-column: 2; }
  .track-footer { padding-inline: 11px; }
}

@media (prefers-reduced-motion: no-preference) {
  .record[aria-pressed='true'] .record-dot { animation: pulse 1.2s ease-in-out infinite alternate; }
  @keyframes pulse { to { opacity: .44; } }
}
