/* ===== Reset & base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0a0e1a;
  color: #e8ebf5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

:root {
  --accent: #1db954;
  --accent-hover: #1ed760;
  --accent-glow: rgba(29, 185, 84, 0.35);
  --bg: #0a0e1a;
  --bg-card: rgba(22, 28, 45, 0.75);
  --bg-card-solid: #161c2d;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #e8ebf5;
  --text-dim: #9ba3b8;
  --text-muted: #6b7280;
  --danger: #ef4444;
  --warn: #f59e0b;
  --success: #10b981;
  --purple: #8b5cf6;
  --pink: #ec4899;
  --blue: #3b82f6;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 40px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 60px rgba(29, 185, 84, 0.15);
}

/* ===== Background blobs ===== */
.bg-blobs { position: fixed; inset: 0; overflow: hidden; z-index: -1; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.35; }
.blob-1 { top: -15%; left: -10%; width: 600px; height: 600px; background: #1db954; animation: float1 20s ease-in-out infinite; }
.blob-2 { bottom: -15%; right: -10%; width: 550px; height: 550px; background: #8b5cf6; animation: float2 25s ease-in-out infinite; }
.blob-3 { top: 40%; left: 50%; width: 400px; height: 400px; background: #ec4899; opacity: 0.2; animation: float3 30s ease-in-out infinite; }
@keyframes float1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(80px,60px) scale(1.1); } }
@keyframes float2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-60px,-80px) scale(1.15); } }
@keyframes float3 { 0%,100% { transform: translate(-50%,-50%) scale(1); } 50% { transform: translate(-30%,-70%) scale(1.2); } }

/* ===== Layout ===== */
.app-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 40px;
  max-width: 1200px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 48px; height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1db954, #1ed760);
  display: grid; place-items: center;
  font-size: 26px; color: #000;
  box-shadow: 0 8px 24px var(--accent-glow);
  font-weight: 800;
}
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 13px; color: var(--text-dim); }

.user-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 100px; padding: 6px 8px 6px 16px;
}
.user-info { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--pink));
  background-size: cover; background-position: center;
}
.user-name { font-size: 14px; font-weight: 600; }
.user-status { font-size: 11px; color: var(--accent); }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-dim); cursor: pointer; font-size: 16px;
  transition: all 0.2s;
}
.icon-btn:hover { background: rgba(239,68,68,0.1); border-color: var(--danger); color: var(--danger); }

/* ===== Stepper ===== */
.stepper {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 40px 30px;
  max-width: 900px; margin: 0 auto;
}
.step { display: flex; align-items: center; gap: 10px; opacity: 0.45; transition: opacity 0.3s; }
.step.active, .step.done { opacity: 1; }
.step-num {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
  background: rgba(255,255,255,0.06); border: 2px solid var(--border-strong);
  font-size: 13px;
}
.step.active .step-num { background: var(--accent); border-color: var(--accent); color: #000; box-shadow: 0 0 20px var(--accent-glow); }
.step.done .step-num { background: rgba(29,185,84,0.2); border-color: var(--accent); color: var(--accent); }
.step.done .step-num::before { content: "✓"; }
.step.done .step-num span { display: none; }
.step-label { font-size: 13px; font-weight: 500; color: var(--text-dim); }
.step.active .step-label { color: var(--text); }
.step-line { flex: 1; height: 2px; background: var(--border); max-width: 50px; border-radius: 2px; }

/* ===== Main ===== */
.app-main {
  max-width: 1200px; margin: 0 auto;
  padding: 0 40px 120px;
}
.view { animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card-wide { max-width: 900px; margin-left: auto; margin-right: auto; }
.card-center { text-align: center; max-width: 600px; margin: 60px auto; padding: 48px 32px; }
.card-header { margin-bottom: 20px; }
.card-header h2, .card-header h3 { margin: 0 0 4px; letter-spacing: -0.02em; }
.card-header h2 { font-size: 24px; font-weight: 700; }
.card-header h3 { font-size: 17px; font-weight: 600; }
.card-header p { margin: 0; }
.muted { color: var(--text-dim); font-size: 14px; }
.small { font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }
.row { display: flex; align-items: center; }
.row.gap { gap: 12px; }
.row.center { justify-content: center; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }

/* ===== Form fields ===== */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-dim); margin-bottom: 8px;
}
.field-label small { color: var(--text-muted); font-weight: 400; }
input[type="text"], input[type="password"], input[type="number"],
select, textarea {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  padding: 12px 14px;
  transition: all 0.2s;
  font-size: 14px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3e%3cpath fill='%239ba3b8' d='M6 8 0 0h12z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; background: rgba(255,255,255,0.1);
  border-radius: 3px; outline: none; padding: 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  box-shadow: 0 0 0 4px rgba(29,185,84,0.2), 0 4px 12px rgba(0,0,0,0.4);
  transition: transform 0.15s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: none;
  box-shadow: 0 0 0 4px rgba(29,185,84,0.2);
}
.range-ticks {
  display: flex; justify-content: space-between;
  margin-top: 8px; font-size: 11px; color: var(--text-muted);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14px;
  transition: all 0.2s; text-decoration: none;
}
.btn-lg { padding: 14px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary {
  background: var(--accent); color: #000;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 24px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: rgba(255,255,255,0.05); color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); border-color: var(--border-strong); }
.btn-copy {
  background: var(--accent); color: #000;
  border: none; padding: 6px 14px; border-radius: 6px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn-copy:hover { background: var(--accent-hover); }

.spotify-icon {
  display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: #000; color: var(--accent); font-size: 12px;
}
.btn-primary .spotify-icon { background: #000; color: var(--accent); }

/* ===== Tabs ===== */
.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 20px;
  max-width: 420px;
}
.tab {
  flex: 1; background: transparent; border: none;
  color: var(--text-dim); padding: 10px 16px;
  border-radius: 8px; cursor: pointer; font: inherit;
  font-weight: 500; font-size: 14px; transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--accent); color: #000;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ===== Chips ===== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  padding: 8px 14px; border-radius: 100px;
  cursor: pointer; font: inherit; font-size: 13px; font-weight: 500;
  transition: all 0.15s;
}
.chip:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
  box-shadow: 0 2px 10px var(--accent-glow);
}

/* ===== Switch ===== */
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 16px 0; }
.switch input { display: none; }
.switch-track {
  width: 44px; height: 24px; border-radius: 100px;
  background: rgba(255,255,255,0.15); position: relative;
  transition: background 0.2s;
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; transition: transform 0.2s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(20px); }

/* ===== Setup page ===== */
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
@media (max-width: 800px) { .setup-grid { grid-template-columns: 1fr; } }
.setup-steps { padding-left: 22px; margin: 0; line-height: 1.8; }
.setup-steps li { margin-bottom: 14px; color: var(--text-dim); font-size: 14px; }
.setup-steps li b { color: var(--text); }
.setup-steps a { color: var(--accent); text-decoration: none; }
.setup-steps a:hover { text-decoration: underline; }
.connect-box {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.hint { font-size: 12px; color: var(--text-muted); margin-top: 10px; line-height: 1.5; }
.copybox {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.4); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 6px 6px 14px; margin-top: 8px;
}
.copybox code {
  flex: 1; font-size: 13px; color: var(--accent);
  font-family: 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 20px;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(29,185,84,0.05);
}
.dropzone-icon { font-size: 40px; margin-bottom: 10px; }
.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0; color: var(--text-muted); font-size: 12px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* ===== Table ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; font-size: 14px; }
th {
  background: rgba(0,0,0,0.3); color: var(--text-dim);
  font-weight: 600; font-size: 12px; text-transform: uppercase;
  letter-spacing: 0.05em;
}
tbody tr { border-top: 1px solid var(--border); transition: background 0.15s; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
.status-ok { color: var(--success); }
.status-miss { color: var(--warn); }
.status-err { color: var(--danger); }
.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 100px; font-size: 12px; font-weight: 500;
}
.status-badge.ok { background: rgba(16,185,129,0.15); color: var(--success); }
.status-badge.miss { background: rgba(245,158,11,0.15); color: var(--warn); }
.status-badge.err { background: rgba(239,68,68,0.15); color: var(--danger); }
.remove-row {
  background: transparent; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; transition: color 0.15s;
}
.remove-row:hover { color: var(--danger); }

/* ===== Done ===== */
.big-check {
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--accent); color: #000;
  display: grid; place-items: center;
  font-size: 40px; font-weight: 800;
  margin: 0 auto 20px;
  box-shadow: 0 0 60px var(--accent-glow);
  animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }

/* ===== Loading overlay ===== */
.loading {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10,14,26,0.85); backdrop-filter: blur(8px);
  display: grid; place-items: center;
  animation: fadeIn 0.2s;
}
.loading > div:last-child {
  margin-top: 20px; font-size: 15px; font-weight: 500;
}
.spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card-solid);
  border: 1px solid var(--border-strong);
  padding: 12px 20px; border-radius: 100px;
  box-shadow: var(--shadow);
  z-index: 200; font-size: 14px; font-weight: 500;
  animation: toastIn 0.3s;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--accent); color: var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== Settings Modal ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(10,14,26,0.8); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s;
}
.modal {
  background: var(--bg-card-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow);
  animation: fadeIn 0.25s;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { margin: 0; font-size: 18px; font-weight: 700; }

/* ===== Player Bar ===== */
.player-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 250;
  background: rgba(16, 22, 38, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-strong);
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
}
.player-play-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); border: none;
  color: #000; font-size: 14px; cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 0 16px var(--accent-glow);
}
.player-play-btn:hover { background: var(--accent-hover); transform: scale(1.08); }
.player-info { flex-shrink: 0; min-width: 140px; }
.player-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.player-artist { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.player-progress-wrap { flex: 1; display: flex; align-items: center; gap: 10px; }
.player-progress-track { flex: 1; height: 4px; background: rgba(255,255,255,0.12); border-radius: 2px; overflow: hidden; }
.player-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; width: 0%; transition: width 0.5s linear; }
.player-time { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.player-preview-label { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* play button in table */
.play-preview-btn {
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--accent); width: 28px; height: 28px;
  border-radius: 50%; cursor: pointer; font-size: 10px;
  display: grid; place-items: center; transition: all 0.15s;
}
.play-preview-btn:hover { background: var(--accent); color: #000; border-color: var(--accent); }
.play-preview-btn.playing { background: var(--accent); color: #000; border-color: var(--accent); }
.no-preview-dot { color: var(--text-muted); font-size: 18px; }

/* ===== Footer ===== */
.app-footer {
  text-align: center; padding: 30px 40px;
  color: var(--text-muted); font-size: 12px;
}

/* ===== Util ===== */
.hidden { display: none !important; }
code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px; border-radius: 4px;
  font-size: 0.9em;
  font-family: 'SF Mono', 'Monaco', monospace;
}
a { color: var(--accent); }
