:root {
  color-scheme: dark;
  --bg: #080d11;
  --panel: #101820;
  --panel-2: #16222b;
  --text: #eef7f6;
  --muted: #9fb0b8;
  --line: #22343f;
  --accent: #00dfc4;
  --accent-2: #f5b841;
  --danger: #ff7a6b;
  --ink: #05090c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Avenir Next, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.history-panel {
  min-height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(5, 9, 12, 0.94);
  position: sticky;
  top: 0;
}

.brand-block {
  display: grid;
  gap: 8px;
  margin-bottom: 28px;
}

.badge {
  justify-self: start;
  border: 1px solid rgba(61, 214, 198, 0.5);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.brand-block p,
.url-field span,
.status-panel span,
.status-panel p,
.confidence,
[data-testid="track-meta"],
.analysis-legend,
.history-item span,
.empty-state {
  color: var(--muted);
}

.history-head,
.input-row,
.transport,
.downloads,
.analysis-legend {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.history-item {
  min-height: 68px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 10px;
  text-align: left;
  display: grid;
  gap: 5px;
  cursor: pointer;
}

.history-item:hover {
  border-color: var(--accent);
}

.history-item.is-selected {
  border-color: #9fc7ff;
  box-shadow: 0 0 0 1px rgba(159, 199, 255, 0.45), inset 3px 0 0 var(--accent);
  background: #14212b;
}

.history-item strong,
.history-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.studio {
  padding: 24px;
  display: grid;
  gap: 16px;
  align-content: start;
}

.control-panel,
.status-panel,
.metadata-card,
.player {
  background: rgba(16, 24, 32, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.url-field {
  display: grid;
  gap: 4px;
  font-weight: 800;
}

.input-row {
  margin-top: 12px;
}

.input-row input,
.options-grid input,
.options-grid select {
  min-width: 0;
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--ink);
  color: var(--text);
}

.input-row input {
  flex: 1;
}

button,
.button-link {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: var(--ink);
  padding: 0 14px;
  font-weight: 900;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.ghost-button {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}

.button-link {
  background: var(--accent-2);
}

button svg,
.button-link svg,
.badge svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  stroke-width: 2.4;
}

.transport button,
.practice-actions button,
.downloads button,
.downloads .button-link,
.ghost-button {
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.transport button:hover,
.practice-actions button:hover,
.downloads button:hover,
.downloads .button-link:hover,
.ghost-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 223, 196, 0.14);
}

.transport button:focus-visible,
.practice-actions button:focus-visible,
.downloads button:focus-visible,
.downloads .button-link:focus-visible,
.ghost-button:focus-visible,
.history-item:focus-visible,
.karaoke-line:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.options-grid label,
.mini-control {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.toggle-row {
  align-items: center;
  grid-template-columns: 18px 1fr;
  align-content: center;
}

.status-panel {
  display: grid;
  gap: 10px;
}

progress {
  width: 100%;
  height: 12px;
  accent-color: var(--accent);
}

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

.player {
  display: grid;
  gap: 16px;
  order: -1;
}

.player[hidden],
.metadata-card[hidden] {
  display: none;
}

.player-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.transport {
  flex-wrap: wrap;
  position: sticky;
  top: 10px;
  z-index: 10;
  padding: 12px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22);
}

.transport input[type="range"] {
  flex: 1;
  min-width: 220px;
  min-height: 30px;
  cursor: pointer;
  accent-color: var(--accent-2);
}

.analysis-legend {
  flex-wrap: wrap;
  font-size: 13px;
}

.practice-panel,
.help-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 9, 12, 0.72);
  padding: 12px;
}

.practice-panel summary,
.help-panel summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 900;
}

.practice-copy,
.control-hint,
.timeline-copy,
.analysis-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.timeline-copy,
.analysis-hint {
  margin-top: -8px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.help-grid div {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(16, 24, 32, 0.75);
}

.help-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.practice-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
}

.practice-actions button {
  min-width: 0;
  justify-content: flex-start;
}

.karaoke-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #071014;
  overflow: hidden;
}

.karaoke-source {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.karaoke-lines {
  max-height: min(380px, 52vh);
  overflow: auto;
  padding: 10px;
  scroll-behavior: smooth;
  overscroll-behavior: auto;
  -webkit-overflow-scrolling: touch;
}

.karaoke-line {
  width: 100%;
  min-height: 48px;
  justify-content: flex-start;
  margin: 4px 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 800;
  line-height: 1.35;
  cursor: pointer;
  position: relative;
}

.karaoke-line::after {
  content: "Tocar daqui";
  margin-left: auto;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.karaoke-line:hover::after,
.karaoke-line:focus-visible::after {
  opacity: 1;
}

.karaoke-line.is-active {
  border-color: rgba(245, 184, 65, 0.8);
  background: rgba(245, 184, 65, 0.12);
  color: var(--text);
}

.karaoke-word.is-active {
  color: var(--ink);
  background: var(--accent-2);
  border-radius: 4px;
  padding: 0 3px;
}

.karaoke-empty {
  padding: 16px;
  color: var(--muted);
}

.tracks {
  display: grid;
  gap: 12px;
}

.track-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(220px, 1fr) minmax(280px, 1.4fr) minmax(220px, 0.9fr);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-2);
}

.track-title {
  font-weight: 900;
}

audio {
  width: 100%;
}

.analysis-stack {
  display: grid;
  gap: 6px;
}

.canvas-wrap {
  position: relative;
  line-height: 0;
}

.canvas-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--playhead-x, 0%);
  width: 2px;
  background: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(7, 16, 20, 0.7), 0 0 10px rgba(245, 184, 65, 0.9);
  pointer-events: none;
}

.audio-canvas {
  width: 100%;
  height: 76px;
  border: 1px solid #243944;
  border-radius: 6px;
  background: var(--ink);
  cursor: pointer;
  touch-action: pan-y;
}

.audio-canvas:hover,
.audio-canvas.is-seeking {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 223, 196, 0.25);
}

.audio-canvas.spectrum {
  height: 58px;
}

.track-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.track-actions .button-link,
.track-actions .mini-control,
.filter-preset {
  grid-column: span 2;
}

.track-actions input[type="range"] {
  width: 100%;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .history-panel {
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .options-grid,
  .track-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .studio,
  .history-panel {
    padding: 14px;
  }

  .input-row,
  .player-head,
  .downloads {
    align-items: stretch;
    flex-direction: column;
  }

  .transport {
    position: sticky;
    top: 0;
    border-radius: 8px;
    background: rgba(5, 9, 12, 0.98);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  }

  .transport button {
    min-width: 64px;
    min-height: 44px;
  }

  .transport input[type="range"] {
    min-width: 100%;
  }

  .practice-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .practice-actions button {
    min-width: 0;
    min-height: 44px;
  }

  .karaoke-lines {
    max-height: none;
    overflow: visible;
  }
}
