/* ═══════════════════════════════════════════════════════════════
   StudioRef — Apple-inspired Premium Design
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[x-cloak] { display: none !important; }

:root {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface2: #2c2c2e;
  --surface3: #3a3a3c;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --accent: #0A84FF;
  --accent-hover: #409CFF;
  --accent-dim: rgba(10, 132, 255, 0.12);
  --accent-glow: rgba(10, 132, 255, 0.06);
  --text: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #636366;
  --green: #30d158;
  --green-dim: rgba(48, 209, 88, 0.12);
  --red: #ff453a;
  --red-dim: rgba(255, 69, 58, 0.12);
  --yellow: #ffd60a;
  --yellow-dim: rgba(255, 214, 10, 0.12);
  --orange: #ff9f0a;
  --radius: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Base ──────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ────────────────────────────────────────────────── */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px 80px;
  animation: fadeIn 0.6s var(--ease) both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Header ────────────────────────────────────────────────── */
header {
  padding: 36px 0 24px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

header h1 span {
  font-weight: 300;
  color: var(--text-secondary);
}

/* ── Steps indicator ───────────────────────────────────────── */
.steps {
  display: flex;
  gap: 2px;
  margin-bottom: 36px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.step-indicator {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  border-radius: var(--radius-xs);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
  transition: all 0.3s var(--ease);
  cursor: default;
}

.step-indicator.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px rgba(10, 132, 255, 0.3);
}

.step-indicator.done {
  color: var(--green);
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 14px;
  transition: border-color 0.2s var(--ease);
}

.card:hover {
  border-color: var(--border-hover);
}

.card-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

/* ── Album grid ────────────────────────────────────────────── */
.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 14px;
}

.album-card {
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px;
  cursor: pointer;
  transition: all 0.25s var(--ease);
}

.album-card:hover {
  border-color: var(--accent);
  background: var(--surface2);
  transform: scale(1.02);
}

.album-card.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 1px var(--accent);
}

.album-card img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-xs);
  object-fit: cover;
  background: var(--surface2);
  display: block;
  margin-bottom: 10px;
}

.album-card .album-title {
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.album-card .album-artist {
  font-size: 0.74rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.album-card .album-meta {
  display: flex;
  gap: 5px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-flac {
  background: var(--green-dim);
  color: var(--green);
}

.badge-hires {
  background: var(--accent-dim);
  color: var(--accent);
}

.badge-tracks {
  background: var(--surface2);
  color: var(--text-secondary);
}

.badge-digital {
  background: rgba(100, 210, 255, 0.1);
  color: #64d2ff;
}

.badge-explicit {
  background: var(--red-dim);
  color: var(--red);
}

.ep-badge {
  background: var(--yellow-dim);
  color: var(--orange);
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 140px;
}

label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input[type="text"], input[type="url"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.88rem;
  padding: 11px 14px;
  outline: none;
  width: 100%;
  transition: all 0.2s var(--ease);
}

input[type="text"]:focus, input[type="url"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder {
  color: var(--text-tertiary);
}

/* ── Buttons ─────────────────────────────────────────────────── */
button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-xs);
  font-family: var(--font);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 11px 22px;
  transition: all 0.2s var(--ease);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(10, 132, 255, 0.3);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--surface3);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 4px 0;
  font-size: 0.82rem;
}

.btn-ghost:hover { text-decoration: underline; }

/* ── Search tabs ────────────────────────────────────────────── */
.search-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-xs);
  padding: 3px;
}

.tab-btn {
  padding: 7px 18px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ── Track selection list ────────────────────────────────────── */
.track-selection-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.track-select-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.15s var(--ease);
  user-select: none;
}

.track-select-row:last-child { border-bottom: none; }

.track-select-row:hover { background: var(--surface2); }

.track-select-row.selected {
  background: var(--accent-dim);
}

.track-select-header {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.track-select-header:hover { background: var(--surface3); }

.track-checkbox {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.track-select-num {
  min-width: 28px;
  font-size: 0.74rem;
  font-weight: 500;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}

.track-select-label {
  flex: 1;
  font-size: 0.86rem;
  letter-spacing: -0.01em;
}

/* ── Progress ───────────────────────────────────────────────── */
.progress-list { display: flex; flex-direction: column; gap: 6px; }

.progress-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  border: 1px solid var(--border);
  transition: all 0.3s var(--ease);
}

.progress-row--downloading {
  border-color: rgba(10, 132, 255, 0.2);
  background: rgba(10, 132, 255, 0.03);
}

.progress-row--done {
  border-color: rgba(48, 209, 88, 0.15);
}

.progress-row--error {
  border-color: rgba(255, 69, 58, 0.2);
}

.progress-row-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-row .track-num {
  min-width: 24px;
  font-size: 0.72rem;
  color: var(--text-tertiary);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.progress-row .track-title {
  flex: 1;
  letter-spacing: -0.01em;
}

.track-status-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.status-queued { color: var(--text-tertiary); }
.status-downloading { color: var(--accent); }
.status-tagging { color: var(--yellow); }
.status-done { color: var(--green); }
.status-error { color: var(--red); }
.status-starting { color: var(--text-secondary); }

/* Progress bar */
.progress-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar-track {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.progress-percent {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s var(--ease-out);
  width: 0%;
}

.progress-bar--queued {
  background: transparent;
}

.progress-bar--starting {
  background: var(--text-tertiary);
}

.progress-bar--downloading {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(10, 132, 255, 0.4);
  animation: barPulse 1.5s ease-in-out infinite;
}

.progress-bar--tagging {
  background: var(--yellow);
  box-shadow: 0 0 8px rgba(255, 214, 10, 0.3);
}

.progress-bar--done {
  background: var(--green);
}

.progress-bar--error {
  background: var(--red);
}

@keyframes barPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.track-error-msg {
  font-size: 0.76rem;
  color: var(--red);
  padding-left: 36px;
}

/* ── Summary ────────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.summary-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  transition: border-color 0.2s;
}

.summary-block:hover {
  border-color: var(--border-hover);
}

.summary-block .summary-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  font-weight: 700;
}

.summary-block .summary-value {
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.summary-block .summary-sub {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ── Section header ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ── Misc ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--surface3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-xs);
  font-size: 0.84rem;
  margin-bottom: 14px;
  font-weight: 500;
}

.alert-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(255, 69, 58, 0.2);
}

.alert-success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(48, 209, 88, 0.2);
}

.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.78rem; }

/* ── Complete banner ─────────────────────────────────────────── */
.complete-banner {
  text-align: center;
  padding: 40px;
  background: var(--green-dim);
  border: 1px solid rgba(48, 209, 88, 0.15);
  border-radius: var(--radius);
  margin-top: 24px;
}

.complete-banner .complete-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  color: var(--green);
}

.complete-banner h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--green);
  letter-spacing: -0.02em;
}

.complete-banner p {
  color: var(--text-secondary);
  font-size: 0.86rem;
}

/* ── Divider ─────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Release list ──────────────────────────────────────────── */
.release-list { display: flex; flex-direction: column; gap: 8px; }

.release-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.release-row:hover { border-color: var(--accent); }
.release-row.selected { border-color: var(--accent); background: var(--accent-dim); }
.release-row .release-title { font-weight: 600; font-size: 0.9rem; }
.release-row .release-meta { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }
.release-row .release-badges { margin-left: auto; display: flex; gap: 5px; flex-shrink: 0; }

/* ── Folder list ─────────────────────────────────────────────── */
.folder-list { display: flex; flex-direction: column; gap: 6px; }

.folder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.folder-row:hover { border-color: var(--accent); }
.folder-row.selected { border-color: var(--accent); background: var(--accent-dim); }
.folder-row .folder-name { font-size: 0.88rem; font-weight: 500; }
.folder-row .folder-score { font-size: 0.75rem; color: var(--text-secondary); flex-shrink: 0; }

.folder-new { border-style: dashed !important; border-color: var(--border) !important; color: var(--text-secondary); }
.folder-new.selected { border-color: var(--accent) !important; color: var(--text); }

/* ── Overwrite modal ─────────────────────────────────────────── */
.overwrite-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overwrite-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 480px;
  width: calc(100% - 40px);
}

.overwrite-title { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.overwrite-path {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  word-break: break-all;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 560px) {
  .container { padding: 0 16px 60px; }
  header h1 { font-size: 1.35rem; }
  .summary-grid { grid-template-columns: 1fr; }
  .album-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .card { padding: 18px; }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ── Selection ───────────────────────────────────────────────── */
::selection {
  background: rgba(10, 132, 255, 0.3);
  color: var(--text);
}
