/* ─────────────────────────────────────────────────────────────
   Music → Suno  ·  design system
   ───────────────────────────────────────────────────────────── */
:root {
  --bg: #0a0b10;
  --bg-2: #0e1018;
  --panel: #14171f;
  --panel-2: #1a1d26;
  --line: #242833;
  --line-strong: #2e3340;
  --text: #ebedf2;
  --text-dim: #a4abba;
  --muted: #6d7484;
  --accent: #b794ff;
  --accent-soft: rgba(183, 148, 255, 0.12);
  --accent-2: #7be0c8;
  --warn: #ff7a86;
  --gold: #ffc266;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

/* `[hidden]` must beat author rules like `.variant-row { display: grid; }`.
   Without this, conditional sub-rows stay visible even with the hidden attr. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

/* ── Top bar ────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 11, 16, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1024px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand { display: flex; align-items: baseline; gap: 8px; font-weight: 600; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #1a1024;
  font-size: 17px;
  font-weight: 700;
}
.brand-name { font-size: 15px; letter-spacing: -0.01em; }
.brand-sub  { font-size: 12px; color: var(--muted); font-weight: 400; }

.topnav { display: flex; gap: 4px; }
.topnav a {
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.topnav a:hover { background: var(--panel); color: var(--text); }
.topnav a.disabled { opacity: 0.4; pointer-events: none; }
.topnav a.active { background: var(--accent-soft); color: var(--accent); }

/* ── Main layout ────────────────────────────────────────────── */
main {
  max-width: 1024px;
  margin: 0 auto;
  padding: 40px 24px 120px;
}

/* ── Step header ────────────────────────────────────────────── */
.step + .step { margin-top: 56px; }

.step-head {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}
.step-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(183, 148, 255, 0.25);
  border-radius: 10px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}
.step-head h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
}
.step-sub {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
  max-width: 640px;
}
.step-actions {
  display: flex;
  gap: 8px;
  align-self: center;
  flex-shrink: 0;
}

/* ── Card primitive ─────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}
.card-head .hint {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  opacity: 0.7;
}

/* ── Uploader ──────────────────────────────────────────────── */
.uploader { padding: 28px; }

.drop-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 36px 16px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop-label:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop-icon {
  font-size: 28px;
  color: var(--accent);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}
.drop-label strong { font-size: 15px; font-weight: 600; }
.drop-hint { color: var(--muted); font-size: 12px; }

#dropzone.drag .drop-label {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.filename {
  margin-top: 14px;
  color: var(--accent-2);
  font-size: 13px;
  min-height: 1.2em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.uploader-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

/* ── Reference lyrics (collapsible) ─────────────────────────── */
.reflyrics-details {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.reflyrics-details summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.reflyrics-details summary::-webkit-details-marker { display: none; }
.reflyrics-details .ref-label {
  font-size: 12px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.reflyrics-details .ref-label::before {
  content: "▸ ";
  display: inline-block;
  color: var(--muted);
  transition: transform 0.15s;
  margin-right: 4px;
}
.reflyrics-details[open] .ref-label::before { transform: rotate(90deg); }
.reflyrics-details .opt {
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}
.reflyrics-details .ref-hint {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.reflyrics-details textarea {
  width: 100%;
  margin-top: 12px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.55;
  resize: vertical;
  min-height: 120px;
  transition: border-color 0.15s, background 0.15s;
}
.reflyrics-details textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, button {
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s, background 0.15s, transform 0.05s, border-color 0.15s;
  font-family: inherit;
}
.btn-primary {
  background: var(--accent);
  color: #1a1024;
}
.btn-primary:hover:not(:disabled) { opacity: 0.9; }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-secondary {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--line);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 7px 13px; font-size: 13px; }

/* ── Status panel ───────────────────────────────────────────── */
.status {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13px;
}
.status.error { border-color: var(--warn); color: var(--warn); background: rgba(255, 122, 134, 0.05); }

/* ── Progress (stage list) ──────────────────────────────────── */
.progress {
  margin-top: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stage {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
}
.stage .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line-strong);
  grid-row: 1; grid-column: 1;
  transition: background 0.2s;
}
.stage .label {
  grid-row: 1; grid-column: 2;
  color: var(--text-dim);
  font-size: 13px;
  transition: color 0.2s;
}
.stage .timer {
  grid-row: 1; grid-column: 3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.stage .detail {
  grid-row: 2; grid-column: 2 / 4;
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  min-height: 0;
  line-height: 1.4;
}
.stage.active .dot {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(183, 148, 255, 0.6);
  animation: pulse 1.4s infinite;
}
.stage.active .label { color: var(--text); font-weight: 500; }
.stage.active .timer { color: var(--accent); }
.stage.done .dot { background: var(--accent-2); }
.stage.done .label { color: var(--text); }
.stage.done .timer { color: var(--accent-2); }
.stage.error .dot { background: var(--warn); }
.stage.error .label, .stage.error .timer { color: var(--warn); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(183, 148, 255, 0.5); }
  70%  { box-shadow: 0 0 0 10px rgba(183, 148, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(183, 148, 255, 0); }
}

/* ── Facts row (tempo / key / duration) ─────────────────────── */
.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.facts > div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.facts .k {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}
.facts .v {
  display: block;
  font-size: 22px;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* ── Timbre card (collapsible) ──────────────────────────────── */
.timbre-card { padding: 0; }
.timbre-card summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 22px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.timbre-card summary::-webkit-details-marker { display: none; }
.timbre-card summary h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}
.timbre-card summary h3::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 4px;
  transition: transform 0.15s;
}
.timbre-card[open] summary h3::before { transform: rotate(90deg); }
.timbre-card summary .hint { font-size: 11px; color: var(--muted); font-style: italic; }
.timbre-grid {
  padding: 0 22px 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px 18px;
}
.timbre-grid > div { display: flex; justify-content: space-between; align-items: baseline; }
.timbre-grid .tk {
  font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.timbre-grid .tv {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.timbre-grid .tv.accent { color: var(--accent); font-size: 12px; text-align: right; }
.timbre-grid .hint-row {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 6px;
}

/* ── Form fields ────────────────────────────────────────────── */
.field {
  width: 100%;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.15s, background 0.15s;
}
.field:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Select with custom arrow */
select.field {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23a4abba' d='M6 8 0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}
select.field option { background: var(--panel-2); color: var(--text); font-weight: 400; }
select.field optgroup {
  background: var(--panel);
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field.tags { font-size: 13px; line-height: 1.55; color: var(--accent-2); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.field.tags.neg { color: var(--text); }

.lyrics {
  width: 100%;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  min-height: 300px;
  max-height: 640px;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.lyrics:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.syntax-hint {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.5;
}
.syntax-hint code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  color: var(--accent-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.count {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.count.warn { color: var(--gold); }
.count.over { color: var(--warn); font-weight: 700; }

/* ── Variant card ───────────────────────────────────────────── */
.variant-card {
  border-color: rgba(183, 148, 255, 0.3);
  background: linear-gradient(180deg, rgba(183, 148, 255, 0.04), var(--bg-2));
}
.variant-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}
.variant-row label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.variant-row:has(textarea.field) { align-items: start; }
.variant-row:has(textarea.field) label { margin-top: 12px; }

.v-sub {
  margin-left: 16px;
  padding-left: 14px;
  border-left: 2px solid rgba(183, 148, 255, 0.3);
}
.v-sub label { color: var(--accent); }

.variant-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ── History list ──────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-empty {
  padding: 16px;
  color: var(--text-dim);
  text-align: center;
  font-size: 14px;
}
.history-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
}
.history-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}
.history-main {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0;
}
.history-title {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.history-meta {
  font-size: 12px;
  color: var(--text-dim);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.history-meta .pill {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}
.history-actions { display: flex; gap: 6px; }
.history-actions .btn-secondary,
.history-actions .btn-primary { padding: 6px 11px; font-size: 12px; }
.history-actions .btn-danger {
  background: transparent;
  color: var(--warn);
  border: 1px solid transparent;
  padding: 6px 9px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.history-actions .btn-danger:hover { border-color: var(--warn); }
.history-variants {
  grid-column: 1 / -1;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  display: flex; flex-direction: column; gap: 6px;
}
.history-variant {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  background: var(--panel);
  border-radius: var(--radius-sm);
}
.history-variant .vtitle {
  font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.history-variant .vmeta {
  font-size: 11px;
  color: var(--muted);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 700px) {
  main { padding: 24px 16px 80px; }
  .step-head { grid-template-columns: 44px 1fr; }
  .step-num { width: 38px; height: 38px; font-size: 12px; }
  .step-head h2 { font-size: 18px; }
  .step-actions { grid-column: 1 / -1; justify-content: flex-end; margin-top: 4px; }
  .facts { grid-template-columns: 1fr; }
  .topnav { display: none; }
  .variant-row { grid-template-columns: 1fr; align-items: stretch; gap: 6px; }
  .variant-row label { margin: 0 !important; }
  .v-sub { margin-left: 8px; padding-left: 10px; }
}

/* ── Upload: "or paste a link" alternative ─────────────────────── */
.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 14px;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.yt-row { display: flex; flex-direction: column; gap: 6px; }
.yt-label { font-size: 0.9rem; color: var(--text-dim); font-weight: 600; }
.yt-row .field { width: 100%; }
.yt-row .drop-hint { color: var(--muted); }
