.studio-header-tools {
  grid-template-columns: minmax(190px, 230px) auto;
}

.studio-utilities {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.focus-button {
  color: var(--text);
}

.focus-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent), var(--surface-2) 78%);
  box-shadow: inset 0 -2px var(--accent);
}

.tuner-launch {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  margin-top: 9px;
  padding: 7px 9px;
  border: 1px solid color-mix(in srgb, var(--accent), transparent 45%);
  border-radius: 2px;
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--accent), transparent 88%), transparent);
  color: var(--text);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .06em;
  cursor: pointer;
  transition: border-color .5s, background-color .5s, transform .5s, box-shadow .5s;
}

.tuner-launch:hover,
.tuner-launch:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 7px 20px var(--shadow);
}

.tuner-launch span:last-child {
  color: var(--accent);
  font-size: 7px;
}

.studio-panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: clamp(12px, 1.3vw, 24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background-color: var(--surface);
  background-image: var(--panel-pattern);
  box-shadow: 0 12px 36px var(--shadow);
  transition: border-color .5s, background-color .5s, box-shadow .5s;
}

.studio-panel::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
  opacity: .55;
}

.studio-panel.attention {
  border-color: var(--accent);
  box-shadow: 0 12px 42px var(--shadow), 0 0 0 1px color-mix(in srgb, var(--accent), transparent 55%);
}

.studio-heading,
.deck-heading,
.duel-scoreline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.studio-heading {
  padding: 0 2px 13px;
  border-bottom: 1px solid var(--border);
}

.studio-heading h2,
.deck-heading h3 {
  margin: 0;
  color: var(--text);
  line-height: 1;
}

.studio-heading h2 {
  font-size: 16px;
}

.studio-heading-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.studio-mode,
.mixer-reset {
  font-size: 7px;
  font-weight: 900;
  letter-spacing: .07em;
}

.studio-mode {
  color: var(--accent);
}

.mixer-reset {
  min-height: 29px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  transition: color .5s, border-color .5s, transform .5s;
}

.mixer-reset:hover,
.mixer-reset:focus-visible {
  border-color: var(--accent);
  color: var(--text);
  transform: translateY(-1px);
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(310px, .82fr) minmax(520px, 1.18fr);
  gap: clamp(12px, 1.15vw, 22px);
  align-items: start;
  padding-top: 15px;
}

.mixer-deck,
.duel-deck {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: color-mix(in srgb, var(--surface-2), transparent 15%);
}

.deck-heading {
  min-height: 34px;
  margin-bottom: 11px;
}

.deck-heading > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.deck-index {
  color: var(--accent);
  font-size: 8px;
  font-weight: 900;
}

.deck-heading h3 {
  font-size: 12px;
}

.deck-hint {
  color: var(--quiet);
  font-size: 7px;
  font-weight: 780;
  text-transform: uppercase;
}

.mixer-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 6px;
}

.weight-row {
  --weight-percent: 20%;
  display: grid;
  grid-template-columns: minmax(84px, 1fr) minmax(90px, 1.3fr) 45px;
  gap: 9px;
  align-items: center;
  min-height: 43px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--surface);
  transition: border-color .5s, background-color .5s, transform .5s;
}

.weight-row:hover,
.weight-row:focus-within {
  border-color: color-mix(in srgb, var(--accent), transparent 35%);
  background: color-mix(in srgb, var(--accent), var(--surface) 96%);
  transform: translateY(-1px);
}

.weight-copy {
  min-width: 0;
}

.weight-copy strong,
.weight-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weight-copy strong {
  color: var(--text);
  font-size: 9px;
}

.weight-copy small {
  margin-top: 3px;
  color: var(--quiet);
  font-size: 6px;
  font-weight: 800;
  letter-spacing: .06em;
}

.weight-slider {
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
}

.weight-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 1px;
  background: linear-gradient(90deg, var(--accent) 0 var(--weight-percent),
    var(--surface-3) var(--weight-percent) 100%);
}

.weight-slider::-moz-range-track {
  height: 4px;
  border-radius: 1px;
  background: var(--surface-3);
}

.weight-slider::-moz-range-progress {
  height: 4px;
  background: var(--accent);
}

.weight-slider::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
  appearance: none;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 10px color-mix(in srgb, var(--accent), transparent 45%);
}

.weight-slider::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
}

.weight-output {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-size: 9px;
  font-weight: 900;
  text-align: right;
}

.mixer-empty,
.duel-empty {
  padding: 20px;
  border: 1px dashed var(--border);
  color: var(--quiet);
  font-size: 9px;
  text-align: center;
}

.duel-heading {
  align-items: center;
}

.duel-selectors {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto minmax(100px, 1fr);
  gap: 6px;
  align-items: end;
  width: min(430px, 62%);
}

.duel-selectors label {
  display: grid;
  gap: 3px;
}

.duel-selectors label > span {
  color: var(--quiet);
  font-size: 6px;
  font-weight: 900;
  letter-spacing: .08em;
}

.duel-selectors select {
  min-width: 0;
  width: 100%;
  height: 30px;
  padding: 3px 24px 3px 7px;
  border: 1px solid var(--border);
  border-radius: 2px;
  outline: none;
  background: var(--surface);
  color: var(--text);
  font-size: 8px;
  font-weight: 760;
}

.duel-versus {
  padding-bottom: 8px;
  color: var(--accent);
  font-size: 7px;
  font-weight: 950;
}

.duel-scoreline {
  min-height: 43px;
  margin-top: 3px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.duel-score {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 7px;
}

.duel-score:last-child {
  flex-direction: row-reverse;
  text-align: right;
}

.duel-score strong {
  color: var(--car-color);
  font-size: 13px;
}

.duel-score span {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.duel-split {
  flex: 0 0 auto;
  color: var(--quiet);
  font-size: 7px;
  font-weight: 850;
  letter-spacing: .05em;
}

.duel-summary {
  display: grid;
  grid-template-columns: minmax(180px, .75fr) minmax(220px, 1.25fr);
  gap: 12px;
  align-items: baseline;
  padding: 10px 2px 8px;
}

.duel-summary strong {
  color: var(--text);
  font-size: 10px;
}

.duel-summary p {
  margin: 0;
  color: var(--quiet);
  font-size: 8px;
  line-height: 1.45;
}

.ledger-key {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 7px;
  align-items: center;
  margin: 1px 104px 5px min(32%, 155px);
  color: var(--quiet);
  font-size: 6px;
  font-weight: 850;
  letter-spacing: .08em;
}

.ledger-key i {
  height: 1px;
  background: linear-gradient(90deg, var(--quiet), var(--border), var(--quiet));
}

.duel-evidence {
  display: grid;
  gap: 4px;
  max-height: 420px;
  overflow: hidden auto;
  padding-right: 2px;
  scrollbar-color: var(--surface-3) transparent;
}

.evidence-row {
  --first-position: 50%;
  --second-position: 50%;
  --segment-start: 50%;
  --segment-size: 0%;
  display: grid;
  grid-template-columns: minmax(102px, .68fr) minmax(200px, 1.4fr) 92px;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .5s, background-color .5s, transform .5s;
}

.evidence-row:hover,
.evidence-row:focus-visible {
  border-color: var(--leader-color, var(--border));
  background: color-mix(in srgb, var(--leader-color, var(--accent)), var(--surface) 95%);
  transform: translateX(2px);
}

.evidence-label strong,
.evidence-label small {
  display: block;
}

.evidence-label strong {
  font-size: 8px;
}

.evidence-label small {
  margin-top: 3px;
  color: var(--quiet);
  font-size: 6px;
  font-weight: 800;
  text-transform: uppercase;
}

.evidence-track-wrap {
  display: grid;
  gap: 3px;
}

.evidence-values {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 7px;
  font-weight: 820;
  font-variant-numeric: tabular-nums;
}

.evidence-track {
  position: relative;
  height: 17px;
}

.evidence-track::before {
  content: '';
  position: absolute;
  inset: 8px 0 auto;
  height: 1px;
  background: var(--border);
}

.evidence-segment {
  position: absolute;
  top: 6px;
  left: var(--segment-start);
  width: var(--segment-size);
  height: 5px;
  background: linear-gradient(90deg, var(--first-color), var(--second-color));
  opacity: .44;
}

.evidence-marker {
  position: absolute;
  z-index: 1;
  top: 3px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 1px currentColor;
  transform: translateX(-50%);
  transition: left .5s ease-out;
}

.evidence-marker.first {
  left: var(--first-position);
  color: var(--first-color);
}

.evidence-marker.second {
  left: var(--second-position);
  color: var(--second-color);
}

.evidence-row.tie .evidence-marker.first {
  top: 0;
  width: 17px;
  height: 17px;
  background: transparent;
}

.evidence-outcome {
  min-width: 0;
  text-align: right;
}

.evidence-outcome strong,
.evidence-outcome small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.evidence-outcome strong {
  color: var(--leader-color, var(--quiet));
  font-size: 8px;
}

.evidence-outcome small {
  margin-top: 3px;
  color: var(--quiet);
  font-size: 6px;
}

.studio-decision .decision-heading h2 {
  margin: 0;
  font-size: 16px;
}

.studio-decision .rank-card {
  transition: border-color .5s, background-color .5s, transform .5s, box-shadow .5s;
}

body.chart-focus .studio-workspace {
  grid-template-columns: minmax(0, 1fr);
}

body.chart-focus .control-panel,
body.chart-focus .studio-panel,
body.chart-focus .studio-decision {
  display: none;
}

body.chart-focus .chart-panel {
  min-height: calc(100vh - 130px);
}

body.chart-focus .brand-block p {
  color: var(--accent);
}

html[data-theme="racing-department"] .studio-panel::before {
  width: 5px;
  background: repeating-linear-gradient(0deg, var(--accent) 0 14px, #fff 14px 20px);
}

html[data-theme="racing-department"] .deck-index {
  padding: 2px 4px;
  background: var(--accent);
  color: #fff;
}

html[data-theme="vaporwave-1996"] .studio-panel {
  box-shadow: 9px 9px 0 rgba(246, 1, 157, .08), -6px -6px 0 rgba(45, 226, 230, .05);
}

html[data-theme="vaporwave-1996"] .evidence-segment {
  box-shadow: 0 0 10px var(--leader-color);
}

html[data-theme="manga-ink"] .studio-panel,
html[data-theme="manga-ink"] .mixer-deck,
html[data-theme="manga-ink"] .duel-deck {
  border-width: 2px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, .12);
}

html[data-theme="manga-ink"] .control-panel,
html[data-theme="manga-ink"] .chart-panel,
html[data-theme="manga-ink"] .studio-panel,
html[data-theme="manga-ink"] .decision-panel {
  background-size: 6px 6px;
}

html[data-theme="manga-ink"] .studio-panel::before {
  width: 7px;
  background: var(--accent);
}

html[data-theme="grand-tourer"] .studio-panel::before {
  background: linear-gradient(180deg, transparent, var(--accent), transparent);
}

html[data-theme="grand-tourer"] .mixer-deck,
html[data-theme="grand-tourer"] .duel-deck {
  box-shadow: inset 0 1px rgba(255,255,255,.025);
}

@media (min-width: 2300px) {
  .studio-header-tools {
    grid-template-columns: 290px auto;
  }

  .studio-workspace {
    grid-template-columns: 350px minmax(0, 1fr);
  }

  .studio-grid {
    grid-template-columns: minmax(570px, .86fr) minmax(760px, 1.14fr);
  }

  .mixer-list {
    grid-template-columns: repeat(2, minmax(250px, 1fr));
  }

  .weight-row,
  .evidence-row {
    min-height: 49px;
  }

  .duel-evidence {
    max-height: 510px;
  }
}

@media (max-width: 1380px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }

  .mixer-list {
    grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  }
}

@media (max-width: 900px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }

  .mixer-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.chart-focus .chart-panel {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .studio-utilities {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .studio-heading {
    align-items: start;
  }

  .studio-heading-actions {
    display: grid;
    justify-items: end;
  }

  .studio-grid {
    padding-top: 10px;
  }

  .mixer-deck,
  .duel-deck {
    padding: 9px;
  }

  .mixer-list {
    grid-template-columns: 1fr;
  }

  .weight-row {
    grid-template-columns: minmax(92px, 1fr) minmax(100px, 1.25fr) 44px;
    min-height: 48px;
  }

  .duel-heading {
    display: grid;
  }

  .duel-selectors {
    width: 100%;
  }

  .duel-scoreline {
    gap: 7px;
  }

  .duel-score {
    display: grid;
    gap: 2px;
  }

  .duel-score:last-child {
    display: grid;
  }

  .duel-summary {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .ledger-key {
    margin-left: 0;
    margin-right: 0;
  }

  .evidence-row {
    grid-template-columns: minmax(78px, .55fr) minmax(138px, 1fr);
    grid-template-areas:
      "label outcome"
      "track track";
    gap: 4px 8px;
    min-height: 61px;
  }

  .evidence-label {
    grid-area: label;
  }

  .evidence-track-wrap {
    grid-area: track;
  }

  .evidence-outcome {
    grid-area: outcome;
  }

  .duel-evidence {
    max-height: none;
  }
}
