* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

:root {
  color-scheme: dark;
  --bg: #161616;
  --panel: #202020;
  --panel-2: #262626;
  --line: #3a3a3a;
  --text: #eeeeee;
  --muted: #a6a6a6;
  --accent: #f5b642;
  --danger: #f05a4f;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, auto);
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #1b1b1b;
}

.brand-block h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0;
}

.brand-block p,
.status-block span {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

button,
select {
  height: 34px;
  border: 1px solid #464646;
  background: #2b2b2b;
  color: var(--text);
  padding: 0 12px;
  border-radius: 6px;
}

button {
  cursor: pointer;
  white-space: nowrap;
}

select {
  min-width: 126px;
  cursor: pointer;
}

.mode-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: #343434;
  border-color: #5a5a5a;
}

button:disabled {
  color: #6f6f6f;
  cursor: not-allowed;
}

#playButton {
  min-width: 68px;
  border-color: #6f5a2c;
  background: #3a301b;
}

#drawModeButton[aria-pressed="true"] {
  border-color: #b99134;
  background: #4a3917;
  color: #fff3c4;
}

.status-block {
  display: grid;
  justify-items: end;
  gap: 4px;
  min-width: 260px;
}

#statusText {
  --status-progress: 0%;
  position: relative;
  display: inline-block;
  max-width: min(420px, 34vw);
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #d4d4d4;
  background: transparent;
}

#statusText.status-in-progress {
  color: #f5e2ad;
  border-color: rgba(245, 182, 66, 0.34);
  background:
    linear-gradient(90deg, rgba(245, 182, 66, 0.26) var(--status-progress), rgba(45, 45, 45, 0.68) var(--status-progress));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22);
}

.workspace {
  min-height: 0;
  padding: 14px 18px 10px;
}

.viewport-stack {
  position: relative;
  display: grid;
  grid-template-rows: 32px 18px minmax(230px, 43vh) 22px minmax(260px, 1fr);
  gap: 8px;
  height: 100%;
  min-height: 0;
}

.output-mode-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.output-mode-bar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid #3d3d3d;
  border-radius: 6px;
  background: #202020;
  color: #d7d7d7;
  font-size: 12px;
  white-space: nowrap;
}

.output-mode-bar input {
  margin: 0;
  accent-color: var(--accent);
}

.output-mode-bar label:has(input:checked) {
  border-color: #7a622e;
  background: #312816;
  color: #f5e2ad;
}

.output-mode-bar label:has(input:disabled) {
  opacity: 0.48;
}

.affect-control {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  min-width: 320px;
  color: #d7d7d7;
}

.affect-control span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.affect-control input[type="range"] {
  width: min(190px, 18vw);
  accent-color: var(--accent);
}

.affect-control output {
  min-width: 44px;
  color: #f5e2ad;
  font-size: 12px;
  text-align: right;
}

.affect-control:has(input:disabled) {
  opacity: 0.48;
}

.selection-bar {
  position: relative;
  height: 18px;
  border: 1px solid #3d3d3d;
  background: #222;
  cursor: crosshair;
  overflow: hidden;
}

.selection-bar::before {
  content: "";
  position: absolute;
  inset: 8px 0 auto;
  height: 1px;
  background: #555;
}

.selection-region {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  background: rgba(245, 182, 66, 0.22);
}

.spectrogram-frame,
.lane-frame {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  background: #101010;
  overflow: hidden;
}

#spectrogramCanvas,
#lanesCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.lane-labels {
  position: absolute;
  inset: 0;
  display: grid;
  pointer-events: none;
  z-index: 2;
}

.lane-frame.draw-active {
  cursor: crosshair;
}


.edit-region-button {
  position: absolute;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  background: rgba(12, 12, 12, 0.88);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.edit-region-button:hover {
  border-color: #fff;
}

.edit-delete-button:hover {
  background: #f05a4f;
}

.edit-bypass-button:hover,
.edit-bypass-button.is-active {
  border-color: #fff;
  background: #f5b642;
  color: #141414;
}

.edit-clip-slider {
  position: absolute;
  z-index: 6;
  width: 16px;
  height: 58px;
  margin: 0;
  padding: 0;
  writing-mode: vertical-lr;
  direction: rtl;
  accent-color: #f5b642;
  cursor: ns-resize;
}

.edit-clip-slider::-webkit-slider-runnable-track {
  width: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
}

.edit-clip-slider::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f5b642;
  border: 1px solid rgba(0, 0, 0, 0.65);
}

.edit-clip-slider::-moz-range-track {
  width: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.35);
}

.edit-clip-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #f5b642;
  border: 1px solid rgba(0, 0, 0, 0.65);
}

.lane-label {
  align-self: start;
  justify-self: start;
  margin: 6px 0 0 8px;
  pointer-events: auto;
  color: var(--lane-color);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 650;
  text-shadow: 0 1px 2px #000, 0 0 5px #000;
  white-space: nowrap;
}

.lane-label-select {
  max-width: min(260px, 42vw);
  height: 24px;
  padding: 2px 24px 2px 8px;
  border: 1px solid color-mix(in srgb, var(--lane-color) 58%, #ffffff 18%);
  border-radius: 4px;
  background: rgba(10, 10, 10, 0.78);
  color: var(--lane-color);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-shadow: inherit;
  outline: none;
  cursor: pointer;
}

.lane-label-select:focus-visible {
  border-color: #fff;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--lane-color) 45%, transparent);
}

.lane-label-select:disabled {
  opacity: 0.62;
  cursor: progress;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #777;
  font-size: 13px;
  pointer-events: none;
}

.scrollbar {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.scrollbar:disabled {
  opacity: 0.35;
}

.transport-line {
  position: absolute;
  top: 66px;
  bottom: 0;
  width: 2px;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 0 14px rgba(255, 255, 255, 0.45);
  pointer-events: none;
  z-index: 5;
}


.hover-tooltip {
  position: absolute;
  z-index: 8;
  min-width: 190px;
  max-width: 280px;
  padding: 7px 9px;
  border: 1px solid #505050;
  border-radius: 6px;
  background: rgba(18, 18, 18, 0.94);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.38);
  color: #f1f1f1;
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
  white-space: nowrap;
}

.hover-tooltip strong {
  display: block;
  margin-bottom: 2px;
  font-weight: 650;
}

.hover-tooltip span {
  color: #bdbdbd;
}

.inspector {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, auto)) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  padding: 10px 18px 14px;
  border-top: 1px solid var(--line);
  background: #1b1b1b;
}

.metric {
  display: grid;
  gap: 2px;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric strong {
  font-size: 13px;
  font-weight: 600;
}

.legend {
  display: flex;
  gap: 10px 16px;
  flex-wrap: wrap;
  justify-content: end;
  align-items: center;
  min-width: 0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #d7d7d7;
  font-size: 12px;
  white-space: nowrap;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-width: 0;
    min-height: 100%;
    height: auto;
  }

  .topbar,
  .inspector {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .controls,
  .legend,
  .output-mode-bar {
    justify-content: start;
    flex-wrap: wrap;
  }

  button,
  select {
    padding-inline: 10px;
    font-size: 13px;
  }

  .affect-control {
    margin-left: 0;
    min-width: min(100%, 320px);
  }

  .status-block {
    justify-items: start;
  }

  .viewport-stack {
    height: 78vh;
    min-height: 620px;
  }
}

@media (max-width: 640px) {
  .controls {
    gap: 6px;
  }

  button,
  select {
    padding-inline: 8px;
    font-size: 12px;
  }
}
