:root {
  --bg: #14120f;
  --surface: #1e1b17;
  --surface-raised: #262219;
  --text: #f3eee3;
  --text-muted: #a79e8e;
  --accent: #e8a33d;
  --accent-soft: rgba(232, 163, 61, 0.14);
  --accent-2: #7c9070;
  --line: #38332b;
  --danger: #e2604f;
  --danger-soft: rgba(226, 96, 79, 0.14);
  --radius: 14px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
}

* {
  box-sizing: border-box;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Faint vinyl-groove rings anchored behind the header, purely decorative */
.groove-field {
  position: fixed;
  top: -220px;
  right: -220px;
  width: 620px;
  height: 620px;
  border-radius: 50%;
  pointer-events: none;
  background: repeating-radial-gradient(
    circle,
    transparent 0,
    transparent 9px,
    rgba(243, 238, 227, 0.025) 10px,
    transparent 11px
  );
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ---------- Header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 40px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 14px;
}

.wordmark-disc {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  background: radial-gradient(circle at 35% 30%, #3a352c 0%, #14120f 72%);
  border: 1px solid var(--line);
  position: relative;
}

.wordmark-disc::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.wordmark-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: -0.01em;
}

.wordmark-sub {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a1508;
  flex-shrink: 0;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--line);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

/* ---------- Layout helpers ---------- */

.hidden {
  display: none !important;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
}

.alert {
  background: var(--danger-soft);
  border: 1px solid rgba(226, 96, 79, 0.4);
  color: #f3d3cc;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

/* ---------- Hero / logged-out ---------- */

.hero {
  text-align: left;
  padding: 44px 32px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 14px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.15;
  margin: 0 0 16px;
  max-width: 26ch;
}

.hero-copy {
  color: var(--text-muted);
  max-width: 46ch;
  margin: 0 0 28px;
}

/* ---------- Profile card ---------- */

.profile-card {
  display: flex;
  align-items: center;
  gap: 20px;
}

.profile-loading {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
  flex-shrink: 0;
  background: var(--surface-raised);
}

.profile-name {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0 0 4px;
}

.profile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  margin: 0;
}

.profile-meta a {
  color: var(--accent-2);
  text-decoration: none;
}

.profile-meta a:hover {
  text-decoration: underline;
}

/* ---------- Top items panel ---------- */

.top-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 22px;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-raised);
  border-radius: 999px;
  padding: 4px;
}

.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.tab {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.tab.is-active {
  background: var(--accent);
  color: #1a1508;
}

.range-select {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.range-select select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.top-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.top-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 6px;
  border-top: 1px solid var(--line);
}

.top-item:first-child {
  border-top: none;
}

.top-rank {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}

.top-art {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-raised);
  flex-shrink: 0;
}

.top-art.is-round {
  border-radius: 50%;
}

.top-info {
  min-width: 0;
  flex: 1;
}

.top-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-popularity {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 0 4px;
}

/* ---------- Sync panel ---------- */

.sync-panel:empty {
  display: none;
  margin-bottom: 0;
  padding: 0;
  border: none;
}

.sync-copy {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 16px;
}

.sync-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.sync-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.sync-playlist-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.sync-warning {
  background: var(--accent-soft);
  border: 1px solid rgba(232, 163, 61, 0.35);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.82rem;
  margin: 0 0 16px;
}

.generate-field {
  display: block;
  margin-bottom: 14px;
}

.generate-field .sync-label {
  margin-bottom: 6px;
}

.generate-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.sync-limit-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.sync-limit-field input {
  width: 72px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: right;
}

.sync-search {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.sync-results {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}

.sync-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 8px;
  border-top: 1px solid var(--line);
  cursor: pointer;
  font-size: 0.9rem;
}

.sync-result-item:first-child {
  border-top: none;
}

.sync-result-item:hover {
  background: var(--surface-raised);
}

.sync-result-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.sync-result-status {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 10px 8px;
}

.sync-result {
  margin: 12px 0 0;
}

.report-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}

.report-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 6px;
  border-top: 1px solid var(--line);
  font-size: 0.87rem;
}

.report-row:first-child {
  border-top: none;
}

.report-pos {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 22px;
  text-align: right;
  flex-shrink: 0;
}

.report-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.report-row.is-removed .report-title {
  color: var(--text-muted);
  text-decoration: line-through;
}

.report-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.report-badge.is-new {
  background: var(--accent-soft);
  color: var(--accent);
}

.report-badge.is-up {
  background: rgba(124, 144, 112, 0.16);
  color: var(--accent-2);
}

.report-badge.is-down {
  background: var(--danger-soft);
  color: var(--danger);
}

.report-badge.is-stay {
  color: var(--text-muted);
  background: transparent;
}

.report-badge.is-out {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- App shell / sidebar ---------- */

.app-shell {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 176px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}

.sidebar-link {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--surface-raised);
}

.sidebar-link.is-active {
  color: #1a1508;
  background: var(--accent);
}

.content {
  flex: 1;
  min-width: 0;
}

.view.hidden {
  display: none;
}

/* ---------- Playlists panel / track list ---------- */

.playlist-add {
  margin-bottom: 18px;
}

.track-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.track-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 6px;
  border-top: 1px solid var(--line);
  cursor: grab;
}

.track-row:first-child {
  border-top: none;
}

.track-row.is-dragging {
  opacity: 0.4;
}

.track-row.is-drag-over {
  background: var(--accent-soft);
  border-radius: 8px;
}

.track-drag-handle {
  color: var(--text-muted);
  font-size: 1rem;
  flex-shrink: 0;
  line-height: 1;
}

.track-pos {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 20px;
  text-align: right;
  flex-shrink: 0;
}

.track-info {
  flex: 1;
  min-width: 0;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-icon:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

.btn-icon:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ---------- Footer ---------- */

.site-footer {
  margin-top: 40px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-align: center;
}

.dot-sep {
  margin: 0 8px;
}

@media (max-width: 520px) {
  .hero h1 {
    font-size: 1.6rem;
  }

  .profile-card {
    flex-direction: column;
    text-align: center;
  }

  .top-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    flex-direction: row;
    width: 100%;
    overflow-x: auto;
  }

  .sidebar-link {
    flex-shrink: 0;
  }
}
