.tunelab-page {
  --tune-canvas: var(--background, #101114);
  --tune-panel: var(--surface, #17181d);
  --tune-text: var(--text, #eeeef0);
  --tune-muted: var(--muted, #a5a6ae);
  --tune-border: var(--border, #373941);
  --tune-accent: var(--accent, #e5f178);
  --tune-raised: #22242a;
  --tune-well: #111216;
  color: var(--tune-text);
  padding-bottom: clamp(42px, 7vw, 88px);
}

.tunelab-intro { padding-block: clamp(42px, 5vw, 66px) clamp(23px, 3.2vw, 37px); }
.tunelab-intro h1 {
  font-size: clamp(3.25rem, 7.2vw, 5.75rem);
  font-weight: 640;
  line-height: .94;
  letter-spacing: -.075em;
  margin: 0;
}
.tunelab-intro p {
  margin: 15px 0 0;
  max-width: 54ch;
  color: var(--tune-muted);
  font-size: clamp(1rem, 1.65vw, 1.2rem);
  line-height: 1.5;
}

.tune-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(330px, 1fr);
  grid-template-areas: 'editor library';
  align-items: start;
  gap: clamp(14px, 2.1vw, 26px);
}
.tune-panel {
  min-width: 0;
  padding: clamp(15px, 2.05vw, 25px);
  border: 1px solid var(--tune-border);
  border-radius: 12px;
  background: var(--tune-panel);
}
.tune-panel h2 {
  margin: 0 0 16px;
  color: var(--tune-text);
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -.02em;
}
.tune-library { grid-area: library; }
.tune-editor { grid-area: editor; }
.tunelab-page :where(button, a, input, select, iframe):focus-visible {
  outline: 2px solid var(--tune-accent);
  outline-offset: 3px;
}

.tune-display {
  overflow: hidden;
  background: radial-gradient(ellipse at 48% 50%, #1e2522 0%, #121714 63%, #101315 100%);
  border: 1px solid #363c37;
  border-radius: 7px;
}
.tune-wave {
  display: block;
  width: 100%;
  height: clamp(119px, 17vw, 203px);
}
.tune-display.tune-unavailable { opacity: .58; }

.tunelab-controls { display: grid; gap: 14px; margin-top: 12px; }
.tune-source-note, .tune-announcement {
  margin: 0;
  color: var(--tune-muted);
  font-size: .86rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.tune-source-note[hidden] { display: none; }
.tune-announcement:not(.visually-hidden) {
  border-top: 1px solid var(--tune-border);
  padding-top: 9px;
}

.tune-timeline {
  display: grid;
  align-items: center;
  grid-template-columns: 3.05rem minmax(0, 1fr) 3.05rem;
  gap: 7px;
  color: var(--tune-muted);
  font-size: .79rem;
  font-variant-numeric: tabular-nums;
}
.tune-duration { text-align: right; }

.tunelab-page input[type='range'] {
  --tune-progress: 0%;
  width: 100%;
  min-width: 0;
  height: 26px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.tunelab-page input[type='range']:disabled { opacity: .45; cursor: default; }
.tunelab-page input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 20px;
  background: linear-gradient(to right, var(--tune-accent) var(--tune-progress), #40434b var(--tune-progress));
}
.tunelab-page input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 20px;
  background: linear-gradient(to right, var(--tune-accent) var(--tune-progress), #40434b var(--tune-progress));
}
.tunelab-page input[type='range']::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -4.5px;
  border: 0;
  border-radius: 50%;
  background: var(--tune-accent);
}
.tunelab-page input[type='range']::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 0;
  border-radius: 50%;
  background: var(--tune-accent);
}
.tunelab-page input[type='range']:disabled::-webkit-slider-thumb { background: #92949c; }
.tunelab-page input[type='range']:disabled::-moz-range-thumb { background: #92949c; }

.tune-transport-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.tune-transport, .studio-apple-transport { display: flex; align-items: center; gap: 7px; }
.tune-key, .studio-button, .studio-source, .studio-track-control {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.tune-key, .studio-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 39px;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--tune-border);
  border-radius: 6px;
  background: var(--tune-raised);
  font-size: .86rem;
  font-weight: 620;
  line-height: 1.16;
  text-decoration: none;
}
.tune-key[data-action='previous'], .tune-key[data-action='next'], .studio-apple-transport .tune-key {
  min-width: 39px;
  padding-inline: 7px;
}
.tune-key svg, .studio-button svg { flex: none; width: 18px; height: 18px; }
.tune-key:not(:disabled):hover, .studio-button:not(:disabled):hover { border-color: var(--tune-accent); }
.tune-play:not(:disabled), .studio-upload:not(:disabled) {
  color: #161910;
  border-color: var(--tune-accent);
  background: var(--tune-accent);
}
.tune-play:not(:disabled):hover, .studio-upload:not(:disabled):hover {
  background: color-mix(in srgb, var(--tune-accent) 80%, #fff);
}
.tune-key:disabled, .studio-button:disabled, .studio-track-control:disabled { opacity: .46; cursor: default; }

.tune-effects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
  padding-top: 2px;
  border-top: 1px solid var(--tune-border);
}
.tune-fader { display: grid; min-width: 0; margin-top: 12px; gap: 4px; }
.tune-fader-label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  font-size: .82rem;
  font-weight: 550;
}
.tune-fader-label svg { flex: none; width: 15px; height: 15px; color: var(--tune-muted); }
.tune-value {
  margin-left: auto;
  color: var(--tune-muted);
  flex: none;
  font-size: .77rem;
  font-variant-numeric: tabular-nums;
}

.studio-rack { display: grid; gap: 12px; min-width: 0; }
.studio-sources {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}
.studio-source {
  min-width: 0;
  min-height: 39px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border: 1px solid var(--tune-border);
  border-radius: 6px;
  background: var(--tune-well);
  color: var(--tune-muted);
  font-size: .79rem;
  font-weight: 600;
  line-height: 1.18;
  text-align: left;
}
.studio-source .studio-symbol { flex: none; width: 16px; height: 16px; }
.studio-source:hover, .studio-source[aria-pressed='true'] { border-color: var(--tune-accent); color: var(--tune-text); }
.studio-source[aria-pressed='true'] { background: color-mix(in srgb, var(--tune-accent) 9%, var(--tune-well)); }
.studio-source[aria-pressed='true'] .studio-symbol { color: var(--tune-accent); }

.studio-actions, .studio-url { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 0; }
.studio-actions:empty, .studio-player:empty, .studio-tracks:empty { display: none; }
.studio-quiet { background: transparent; color: var(--tune-muted); }
.studio-url { width: 100%; flex-wrap: nowrap; }
.studio-url input {
  flex: 1 1 0;
  min-width: 0;
  min-height: 39px;
  padding: 6px 9px;
  color: var(--tune-text);
  border: 1px solid var(--tune-border);
  border-radius: 6px;
  background: var(--tune-well);
  font: inherit;
  font-size: .86rem;
}
.studio-url input::placeholder { color: var(--tune-muted); }
.studio-youtube-links { width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; }
.studio-terms { color: var(--tune-muted); font-size: .76rem; text-underline-offset: 2px; }
.studio-terms:hover { color: var(--tune-text); }

.studio-content { display: grid; gap: 10px; min-width: 0; }
.studio-content:has(.studio-player:empty):has(.studio-tracks:empty) { display: none; }
.studio-player { min-width: 0; }
.studio-player iframe {
  display: block;
  width: 100%;
  min-width: 200px;
  min-height: 200px;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #08090b;
}
.youtube-import-title[hidden], .youtube-import-status[hidden] { display: none; }
.youtube-import-title { margin-bottom: 10px; }
.youtube-import-status { margin: 0 0 13px; color: var(--tune-muted); font-size: .85rem; line-height: 1.6; }
.studio-now { margin: 0 0 7px; font-size: .92rem; font-weight: 630; overflow-wrap: anywhere; }
.studio-tracks {
  max-height: 360px;
  margin: 0;
  padding: 0;
  overflow: auto;
  border: 1px solid var(--tune-border);
  border-radius: 6px;
  background: var(--tune-well);
  list-style: none;
  scrollbar-color: var(--tune-border) var(--tune-well);
}
.studio-track + .studio-track { border-top: 1px solid var(--tune-border); }
.studio-track-control {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 47px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  text-align: left;
  text-decoration: none;
}
.studio-track-control:is(:hover, [aria-current='true']) {
  background: color-mix(in srgb, var(--tune-accent) 8%, var(--tune-well));
}
.studio-track-control[aria-current='true'] { box-shadow: inset 2px 0 var(--tune-accent); }
.tunelab-page .studio-track-control:focus-visible { outline-offset: -2px; }
.studio-track-copy { display: grid; gap: 3px; flex: 1; min-width: 0; }
.studio-track-copy strong { font-size: .88rem; font-weight: 630; overflow-wrap: anywhere; }
.studio-track-copy small, .studio-track-arrow { color: var(--tune-muted); font-size: .75rem; }
.studio-empty, .studio-more { padding: 7px 10px; color: var(--tune-muted); font-size: .82rem; }
.studio-status { margin: 0; color: var(--tune-muted); font-size: .82rem; line-height: 1.4; overflow-wrap: anywhere; }
.tunelab-page .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 810px) {
  .tune-workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: 'library' 'editor';
  }
}
@media (max-width: 390px) {
  .tune-effects { column-gap: 9px; }
  .tune-fader-label { flex-wrap: wrap; align-content: center; gap: 3px 4px; }
  .tune-fader-label svg { display: none; }
  .tune-timeline { grid-template-columns: 2.6rem minmax(0, 1fr) 2.6rem; }
}
