:root {
  color-scheme: dark;
  --bg: #101211;
  --panel: #171a1a;
  --line: #303635;
  --line-strong: #515b58;
  --text: #f3f6f2;
  --muted: #a1aaa4;
  --soft: #d5ddd7;
  --accent: #40d7b5;
  --accent-2: #ffbc5f;
  --danger: #ff6f61;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="text"],
input[type="number"] {
  border: 1px solid var(--line);
  background: #121615;
  color: var(--text);
}

button {
  cursor: pointer;
}

button:disabled,
a.is-disabled {
  cursor: not-allowed;
  opacity: 0.48;
  pointer-events: none;
}

.app-shell {
  display: grid;
  grid-template-rows: 72px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  min-width: 960px;
}

body.is-embedded .topbar {
  display: none;
}

body.is-embedded .app-shell {
  grid-template-rows: minmax(0, 1fr);
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 18px 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 18, 17, 0.96);
}

.brand,
.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.suite-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101414;
}

.brand {
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid #63706d;
  border-radius: 8px;
  background: #151b1a;
  color: var(--accent);
  font-size: 13px;
  font-weight: 850;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-button,
.primary-button,
.secondary-button,
.secondary-link,
.download-link,
.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
}

.suite-tabs .secondary-link {
  min-height: 30px;
  padding: 0 10px;
  border-color: transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.suite-tabs .secondary-link.is-active {
  border-color: rgba(64, 215, 181, 0.48);
  background: #16302d;
  color: #dcfff7;
}

.icon-button {
  width: 40px;
  padding: 0;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.primary-button {
  padding: 0 18px;
  border-color: rgba(64, 215, 181, 0.55);
  background: #15362f;
  color: #eafff8;
  font-weight: 800;
}

.primary-button.is-recording {
  border-color: rgba(255, 111, 97, 0.7);
  background: #3a1b1a;
  color: #ffe4df;
}

.secondary-button,
.secondary-link,
.download-link,
.mini-button {
  padding: 0 14px;
  background: #121615;
  color: var(--soft);
  font-weight: 750;
}

.mini-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.download-link:not(.is-disabled) {
  border-color: rgba(255, 188, 95, 0.58);
  color: #ffe1ad;
}

.secondary-button.is-active {
  border-color: rgba(64, 215, 181, 0.68);
  background: #15362f;
  color: #eafff8;
}

button:hover,
.secondary-link:hover,
.download-link:hover {
  border-color: var(--line-strong);
  background: #1d2220;
}

.workspace {
  display: grid;
  grid-template-columns: 296px minmax(520px, 1fr) 336px;
  min-height: 0;
}

.panel {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  background: var(--panel);
}

.panel-left {
  border-right: 1px solid var(--line);
}

.panel-right {
  border-left: 1px solid var(--line);
}

.control-group {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.group-header h2 {
  margin: 0;
  color: var(--soft);
  font-size: 13px;
  text-transform: uppercase;
}

.control-group.is-collapsible .group-header {
  cursor: pointer;
  margin-bottom: 0;
}

.control-group.is-collapsible:not(.is-collapsed) .group-header {
  margin-bottom: 14px;
}

.control-group.is-collapsed > :not(.group-header) {
  display: none !important;
}

.accordion-toggle {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #121615;
  color: var(--soft);
  font-size: 17px;
  font-weight: 850;
  line-height: 1;
}

.group-header span {
  color: var(--muted);
  font-size: 12px;
}

.drop-zone {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 136px;
  padding: 18px;
  border: 1px dashed #596360;
  border-radius: 8px;
  background: #121615;
  color: var(--soft);
  cursor: pointer;
  text-align: center;
}

.drop-zone.is-dragging {
  border-color: rgba(64, 215, 181, 0.82);
  background: #14201d;
  color: #eafff8;
}

.drop-zone input {
  display: none;
}

.drop-zone strong {
  font-size: 14px;
}

.drop-zone small {
  max-width: 220px;
  color: var(--muted);
  font-size: 12px;
}

.drop-symbol svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.track-list {
  display: grid;
  gap: 8px;
}

.track-empty {
  padding: 12px;
  border: 1px dashed #3b4542;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
}

.track-item {
  position: relative;
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 9px;
  width: 100%;
  padding: 10px 34px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111514;
  color: var(--soft);
  text-align: left;
  cursor: pointer;
}

.track-item.is-active {
  border-color: rgba(64, 215, 181, 0.7);
  background: #16231f;
}

.track-swatch {
  width: 10px;
  min-height: 42px;
  border-radius: 999px;
}

.track-title {
  min-width: 0;
}

.track-title strong,
.track-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-title span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.track-delete-button {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  min-height: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(10, 12, 12, 0.36);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}

.track-delete-button:hover,
.track-delete-button:focus-visible {
  border-color: rgba(255, 111, 97, 0.72);
  background: rgba(255, 111, 97, 0.16);
  color: #ffd7d2;
}

.stage-area {
  position: relative;
  display: block;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  background: #0b0d0c;
}

.stage-area.is-audio-dragging {
  outline: 2px solid var(--accent);
  outline-offset: -8px;
}

#stageCanvas {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

.stage-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

.stage-hud span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 999px;
  background: rgba(10, 12, 11, 0.72);
  color: var(--soft);
  font-size: 12px;
  font-weight: 750;
}

.mobile-preview-transport {
  display: none;
}

.field,
.slider-field {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.field span,
.slider-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.field input,
.field select,
.field output {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
}

.field output {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: #101414;
  color: var(--soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.field.two-up {
  display: inline-grid;
  width: calc(50% - 6px);
}

.field.two-up + .field.two-up {
  margin-left: 8px;
}

.slider-field {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.slider-field input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--accent);
}

.slider-field output {
  color: var(--soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 750;
}

.switch-row input {
  accent-color: var(--accent);
}

.meter-readout {
  min-height: 36px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.control-group-master {
  padding-bottom: 20px;
}

.master-meter-panel {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 16px;
  min-height: 238px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: #111514;
}

.master-meter-shell {
  display: grid;
  grid-template-columns: 34px 30px;
  gap: 8px;
  min-height: 210px;
}

.master-meter-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding: 5px 0;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.master-meter {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  border: 1px solid #3a4240;
  border-radius: 7px;
  background:
    linear-gradient(to top, rgba(64, 215, 181, 0.1) 0 58%, rgba(255, 188, 95, 0.14) 58% 80%, rgba(255, 111, 97, 0.18) 80% 100%),
    #090c0b;
}

#masterMeterFill {
  position: absolute;
  right: 4px;
  bottom: 4px;
  left: 4px;
  height: 0%;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(to top, var(--accent) 0%, #a6f3c6 58%, var(--accent-2) 78%, var(--danger) 100%);
  transition: height 90ms linear;
}

#masterPeakMarker {
  position: absolute;
  right: 2px;
  bottom: 4px;
  left: 2px;
  height: 2px;
  border-radius: 999px;
  background: #ffffff;
  opacity: 0.86;
  transition: bottom 90ms linear;
}

.master-meter-controls {
  min-width: 0;
}

.master-meter-readout {
  display: grid;
  gap: 3px;
  margin-bottom: 12px;
}

.master-meter-readout strong {
  display: grid;
  grid-template-columns: 94px auto;
  align-items: baseline;
  gap: 8px;
  width: max-content;
  color: #f8fffb;
  font-size: 30px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  white-space: nowrap;
}

#masterMeterValue {
  min-width: 94px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.master-meter-unit {
  color: var(--muted);
  font-size: 15px;
  font-weight: 850;
  letter-spacing: 0;
}

.master-meter-readout > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.master-meter-panel .field,
.master-meter-panel .slider-field {
  margin-top: 10px;
}

.master-meter-panel .slider-field {
  grid-template-columns: minmax(112px, 1fr) 52px;
}

.master-meter-panel .slider-field span,
.master-meter-panel .slider-field output {
  white-space: nowrap;
}

.master-meter-panel .slider-field output {
  min-width: 52px;
  text-align: right;
}

@media (max-width: 1020px) {
  body {
    overflow: auto;
    overflow-x: hidden;
    min-height: 100dvh;
  }

  .app-shell {
    min-width: 0;
    min-height: 100dvh;
    height: auto;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    position: sticky;
    top: max(env(safe-area-inset-top, 0px), 0px);
    z-index: 6;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    gap: 10px;
    padding: 12px;
  }

  .brand {
    flex: 1 1 180px;
  }

  .brand p {
    max-width: 68vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions {
    flex: 1 1 100%;
    min-width: 0;
    max-width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .top-actions::-webkit-scrollbar {
    display: none;
  }

  .suite-tabs {
    flex: 0 0 auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100vw;
    min-width: 0;
  }

  .panel {
    width: 100%;
    max-width: 100vw;
    min-height: 0;
    min-width: 0;
    overflow: visible;
    border-right: 0;
    border-left: 0;
  }

  .stage-area {
    width: 100%;
    max-width: 100vw;
    height: min(68vh, 620px);
    min-height: 420px;
    min-width: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }

  #stageCanvas {
    min-height: 420px;
  }

  .mobile-preview-transport {
    position: absolute;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 5;
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 44px;
    padding: 7px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(9, 12, 12, 0.84);
    backdrop-filter: blur(10px);
  }

  .mobile-preview-transport button {
    min-height: 32px;
    border-radius: 8px;
    background: #121615;
    color: var(--soft);
    font-size: 12px;
    font-weight: 800;
  }

  .mobile-preview-transport button.is-playing {
    border-color: rgba(64, 215, 181, 0.62);
    background: #15362f;
    color: #dcfff7;
  }

  .mobile-preview-transport span {
    color: var(--soft);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .button-row {
    grid-template-columns: 1fr;
  }

  .field.two-up {
    display: grid;
    width: 100%;
    margin-left: 0 !important;
  }

  .stage-area {
    height: 58vh;
    min-height: 380px;
  }

  #stageCanvas {
    min-height: 380px;
  }

  .master-meter-panel {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
  }

  .master-meter-shell {
    grid-template-columns: 26px 22px;
  }

  .master-meter-readout strong {
    grid-template-columns: 76px auto;
    font-size: 24px;
  }

  #masterMeterValue {
    min-width: 76px;
  }
}
