:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --surface: #111113;
  --panel: #141416;
  --panel-2: #1a1a1d;
  --line: #2a2a2e;
  --line-subtle: #1f1f22;
  --text: #fafafa;
  --muted: #a1a1a6;
  --muted-soft: #6b6b70;
  --green: #d4a855;
  --amber: #e6bb6a;
  --rose: #ff4444;
  --accent-dim: rgba(212, 168, 85, 0.15);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(212, 168, 85, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 60%, rgba(212, 168, 85, 0.04), transparent),
    linear-gradient(180deg, #1a1410, var(--bg));
  color: var(--text);
  font-family: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.transport {
  display: grid;
  grid-template-columns: minmax(15rem, 1fr) auto minmax(15rem, 1fr);
  gap: 1rem;
  align-items: center;
  min-height: 5.8rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 11, 0.86);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.brand-mark {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  background: conic-gradient(from 180deg, var(--green), var(--amber), #fafafa, var(--green));
  box-shadow: 0 0 30px rgba(212, 168, 85, 0.18);
}

.brand p,
.brand h1 {
  margin: 0;
}

.brand p {
  color: var(--muted);
  font-size: 0.78rem;
}

.brand h1 {
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.transport-controls,
.transport-readout,
.loop-range,
.session-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.transport-readout {
  justify-content: flex-end;
}

.icon-button,
.pill-button,
.small-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: transform 0.16s var(--ease-out), border-color 0.16s var(--ease-out), background 0.16s var(--ease-out);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  font-size: 1rem;
}

.icon-button:hover,
.pill-button:hover,
.small-button:hover {
  transform: translateY(-1px);
  border-color: var(--muted-soft);
}

.icon-button.primary,
.icon-button.active {
  background: var(--green);
  color: var(--bg);
}

.icon-button.record.active,
.icon-button.record:hover {
  background: var(--rose);
  color: var(--text);
}

.pill-button,
.small-button {
  min-height: 2.35rem;
  border-radius: 999px;
  padding: 0 0.9rem;
}

.pill-button[aria-pressed="true"],
.track-buttons .on,
.snap-button[aria-pressed="true"] {
  background: var(--accent-dim);
  border-color: var(--green);
  color: var(--green);
}

label span {
  display: block;
  margin-bottom: 0.22rem;
  color: var(--muted);
  font-size: 0.72rem;
}

input[type="number"] {
  width: 4.7rem;
}

input[type="number"],
select {
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: var(--surface);
  color: var(--text);
  padding: 0.54rem 0.6rem;
}

select {
  min-width: 4.7rem;
}

.time-display {
  min-width: 6.6rem;
  font-variant-numeric: tabular-nums;
  font-size: 1.45rem;
  text-align: right;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 21rem;
  gap: 1rem;
  padding: 1rem;
}

.timeline-panel,
.tools-panel {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: rgba(17, 17, 19, 0.82);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.room-notice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(212, 168, 85, 0.28);
  background: var(--accent-dim);
  color: var(--green);
}

.room-notice[hidden] {
  display: none;
}

.timeline-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.room-title span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.room-title strong {
  font-size: 1rem;
}

.timeline-wrap {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  min-height: 33rem;
}

.track-list {
  border-right: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}

.track-card {
  min-height: 10.6rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.track-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.track-color {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  flex: none;
}

.track-name {
  min-width: 0;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 700;
}

.track-type {
  flex: none;
  max-width: 6.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--green);
  font-size: 0.68rem;
}

.track-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
  margin: 0.62rem 0;
}

.track-buttons button {
  border: 1px solid var(--line);
  border-radius: 0.45rem;
  background: var(--panel-2);
  color: var(--text);
  min-height: 1.8rem;
  font-size: 0.75rem;
}

.track-buttons button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.slider-label {
  display: grid;
  grid-template-columns: 2.3rem 1fr;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.track-input-label {
  display: grid;
  grid-template-columns: 3.15rem minmax(0, 1fr);
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.36rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.track-input-label select {
  width: 100%;
  min-width: 0;
  padding: 0.42rem 0.5rem;
  border-radius: 0.45rem;
  font-size: 0.74rem;
}

.timeline-scroll {
  position: relative;
  overflow: auto;
}

.ruler {
  position: relative;
  height: 2.4rem;
  min-width: 100%;
  border-bottom: 1px solid var(--line);
  background-color: var(--surface);
  background-image:
    linear-gradient(to right, rgba(212, 168, 85, 0.26) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: var(--bar-width, 225px) 100%, var(--beat-width, 56.25px) 100%;
}

.ruler span {
  position: absolute;
  top: 0.62rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.loop-band {
  position: absolute;
  inset-block: 0.32rem;
  border: 1px solid rgba(212, 168, 85, 0.5);
  background: var(--accent-dim);
  pointer-events: none;
}

.loop-handle {
  position: absolute;
  top: -0.1rem;
  bottom: -0.1rem;
  width: 0.75rem;
  background: var(--green);
  border-radius: 999px;
  pointer-events: auto;
  cursor: ew-resize;
}

.loop-handle.left {
  left: -0.38rem;
}

.loop-handle.right {
  right: -0.38rem;
}

.timeline {
  position: relative;
  min-width: 100%;
}

.lane {
  position: relative;
  height: 10.6rem;
  border-bottom: 1px solid var(--line);
  background-image:
    linear-gradient(to right, rgba(212, 168, 85, 0.12) 1px, transparent 1px),
    linear-gradient(to right, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: var(--bar-width, 225px) 100%, var(--beat-width, 56.25px) 100%;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--rose);
  z-index: 4;
  pointer-events: none;
  box-shadow: 0 0 16px rgba(255, 68, 68, 0.55);
}

.clip {
  position: absolute;
  top: 1rem;
  height: 5.2rem;
  border: 1px solid;
  border-radius: 0.55rem;
  background: var(--panel-2);
  overflow: hidden;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
  touch-action: none;
}

.clip.selected {
  box-shadow: 0 0 0 2px rgba(212, 168, 85, 0.65), 0 12px 24px rgba(0, 0, 0, 0.2);
}

.recording-region {
  position: absolute;
  top: 1rem;
  height: 5.2rem;
  border: 1px solid rgba(255, 68, 68, 0.72);
  border-radius: 0.55rem;
  background: linear-gradient(90deg, rgba(255, 68, 68, 0.2), rgba(212, 168, 85, 0.14));
  box-shadow: 0 0 0 1px rgba(255, 68, 68, 0.18), 0 12px 24px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: recordPulse 1s ease-in-out infinite;
}

.recording-region span {
  position: absolute;
  left: 0.55rem;
  bottom: 0.45rem;
  color: var(--text);
  font-size: 0.72rem;
}

@keyframes recordPulse {
  0%, 100% { opacity: 0.68; }
  50% { opacity: 1; }
}

.selection-box {
  position: absolute;
  z-index: 3;
  border: 1px solid rgba(212, 168, 85, 0.85);
  background: rgba(212, 168, 85, 0.16);
  pointer-events: none;
}

.waveform-window,
.clip img {
  height: 100%;
}

.waveform-window {
  width: 100%;
  overflow: hidden;
}

.clip img {
  max-width: none;
  transform-origin: left center;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.clip.pending {
  border-style: dashed;
}

.clip-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.055) 0 10px, rgba(255,255,255,0.02) 10px 20px),
    rgba(212, 168, 85, 0.08);
  color: var(--muted);
  font-size: 0.76rem;
}

.clip-actions {
  position: absolute;
  right: 0.35rem;
  top: 0.35rem;
  display: flex;
  gap: 0.25rem;
}

.clip-label {
  position: absolute;
  left: 0.55rem;
  bottom: 0.45rem;
  padding: 0.18rem 0.4rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: var(--text);
  font-size: 0.72rem;
  pointer-events: none;
}

.clip-actions button {
  width: 1.55rem;
  height: 1.55rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
  color: var(--text);
  line-height: 1;
}

.trim-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0.55rem;
  z-index: 2;
}

.trim-handle.left {
  left: 0;
  cursor: ew-resize;
}

.trim-handle.right {
  right: 0;
  cursor: ew-resize;
}

.tools-panel {
  padding: 1rem;
}

.tool-section + .tool-section {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.7rem;
  font-weight: 800;
}

.hint,
.input-status,
.selected-clip {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.input-status {
  margin-top: 0.75rem;
  color: var(--green);
}

.input-picker {
  display: flex;
  justify-content: flex-start;
  gap: 0.55rem;
  align-items: end;
  margin-top: 0.85rem;
}

.add-track-controls {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

.add-track-controls select {
  min-width: 7rem;
  padding: 0.42rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
}

.input-meter {
  height: 0.5rem;
  margin-top: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.input-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 0.08s linear, background 0.12s ease;
}

.input-meter span.hot {
  background: var(--rose);
}

.input-meter span.silent {
  background: var(--muted-soft);
}

.input-meter-text {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.74rem;
}

.instrument-modes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.instrument-modes .on {
  background: var(--accent-dim);
  border-color: var(--green);
  color: var(--green);
}

.octave-controls {
  display: grid;
  grid-template-columns: 2.4rem 1fr 2.4rem;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.7rem;
}

.octave-controls span {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.input-picker select {
  width: 100%;
  max-width: 100%;
}

.selected-clip {
  margin-bottom: 0.7rem;
  color: var(--text);
}

.edit-grid {
  display: grid;
  grid-template-columns: 1fr 0.8fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.7rem;
}

.edit-grid input,
.edit-grid select,
.edit-grid button {
  width: 100%;
}

.clip-tool-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr 0.85fr;
  gap: 0.45rem;
}

.clip-tool-buttons .small-button {
  padding: 0 0.55rem;
  font-size: 0.78rem;
}

.piano {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.25rem;
  height: 7.5rem;
}

.piano button,
.drum-grid button {
  border: 1px solid var(--line);
  color: var(--text);
  transition: transform 0.1s ease, background 0.1s ease;
}

.piano button {
  align-self: stretch;
  border-radius: 0 0 0.45rem 0.45rem;
  background: linear-gradient(#fafafa, #cfd5dd);
  color: #111821;
  font-weight: 800;
  min-width: 0;
  padding: 0;
  font-size: 0.78rem;
}

.piano button.black {
  height: 68%;
  background: linear-gradient(#303036, #111113);
  color: var(--text);
  border-color: #000;
}

.drum-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.drum-grid button {
  min-height: 4.2rem;
  border-radius: 0.65rem;
  background: linear-gradient(160deg, var(--accent-dim), rgba(20, 20, 22, 0.9));
  font-weight: 800;
}

.piano button.hit,
.drum-grid button.hit {
  transform: translateY(2px) scale(0.98);
  background: var(--green);
  color: var(--bg);
}

.danger {
  color: var(--rose);
}

@media (max-width: 980px) {
  .transport,
  .workspace,
  .timeline-wrap {
    grid-template-columns: 1fr;
  }

  .transport-controls,
  .transport-readout {
    justify-content: flex-start;
  }

  .track-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .playhead {
    left: 0;
  }
}
