:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d8dee6;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --teal: #0f766e;
  --gold: #b45309;
  --rose: #be123c;
  --violet: #7c3aed;
  --danger: #b42318;
  --success: #067647;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.app-header h1,
.panel-title h2,
.player-top h2 {
  margin: 0;
}

.app-header h1 {
  font-size: 22px;
}

.app-header p,
.panel-title p,
#song-meta,
.status {
  margin: 4px 0 0;
  color: var(--muted);
}

main {
  padding: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-panel {
  max-width: 440px;
  margin: 44px auto;
  padding: 22px;
}

.panel-title,
.player-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.app-shell {
  display: grid;
  gap: 14px;
  max-width: 1100px;
  margin: 0 auto;
}

.tab-panel,
.player {
  padding: 18px;
}

.tab-panel {
  min-height: calc(100vh - 118px);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e9eef5;
}

.tab-button {
  min-height: 42px;
  color: #344054;
  background: transparent;
}

.tab-button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  box-shadow: 0 6px 14px rgba(15, 118, 110, 0.16);
}

.auth-status,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #f9fafb;
  font-size: 13px;
}

.badge.success {
  color: var(--success);
  border-color: #abefc6;
  background: #ecfdf3;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

input[type="email"],
input[type="password"],
input[type="url"],
select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.email-form,
.server-field,
.server-form {
  display: grid;
  gap: 12px;
}

.server-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
  color: var(--muted);
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  color: #fff;
  background: var(--accent);
}

.primary-button:not(:disabled):hover {
  background: var(--accent-dark);
}

.secondary-button,
.icon-button {
  color: var(--ink);
  background: #fff;
  border-color: var(--line);
}

.button-row,
.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.play-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #c7d2fe;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.song-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.song-item {
  width: 100%;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
}

.song-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.song-item h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.song-item p,
.stem-row p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.song-server-id {
  font-size: 11px;
  text-transform: lowercase;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 22px 0;
}

.control-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.control-card span {
  color: var(--accent);
  font-size: 18px;
}

input[type="range"] {
  width: 100%;
  min-height: 28px;
  accent-color: var(--teal);
}

.stem-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 25%));
  gap: 0;
  margin-top: 18px;
  overflow: hidden;
}

.stem-row {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  justify-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 310px;
  padding: 12px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
}

.stem-row[data-stem="drums"] {
  border-color: rgba(190, 18, 60, 0.35);
}

.stem-row[data-stem="bass"] {
  border-color: rgba(180, 83, 9, 0.38);
}

.stem-row[data-stem="instrumental"] {
  border-color: rgba(37, 99, 235, 0.35);
}

.stem-row[data-stem="other"] {
  border-color: rgba(124, 58, 237, 0.35);
}

.stem-row h3 {
  margin: 0;
  color: #101828;
  font-size: 12px;
  letter-spacing: 0;
  line-height: 1;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.stem-row.unavailable {
  opacity: 0.55;
}

.stem-toggle {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.vertical-volume {
  width: min(228px, calc(100vw - 64px));
  height: 190px;
  transform: rotate(-90deg);
  transform-origin: center;
}

.stem-value {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.server-list {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.user-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px);
  align-items: end;
  gap: 12px;
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.user-section h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.user-section p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.setup-refresh {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 14px;
}

.server-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.server-address {
  overflow-wrap: anywhere;
  font-weight: 650;
}

.server-actions {
  display: flex;
  gap: 8px;
}

.setup-badges,
.setup-actions {
  margin-top: 18px;
}

.setup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .controls-grid,
  .server-form,
  .setup-refresh,
  .user-section {
    grid-template-columns: 1fr;
  }

  .stem-list {
    grid-template-columns: repeat(4, minmax(0, 25%));
  }
}

@media (max-width: 560px) {
  main {
    padding: 12px;
  }

  .app-header,
  .player-top,
  .panel-title {
    display: block;
  }

  .stem-row {
    min-height: 270px;
    padding-inline: 2px;
  }

  .stem-row h3 {
    writing-mode: vertical-rl;
    text-orientation: mixed;
  }

  .vertical-volume {
    width: 164px;
    height: 154px;
  }
}
