/* ── COLOR THEMES ───────────────────────────────────────────────── */
:root {
  --bg: #08121e; --bg2: #0e1e34; --bg3: #122444;
  --surface: #173060; --border: #1e3d72; --border2: #2a52a0;
  --text: #eaf2ff; --text2: #a8c8f0; --text3: #7aa0d0;
  --accent: #4aacff; --accent2: #80c8ff;
  --gold1: #f0aa30; --gold2: #fcd34d;
  --rose: #fb7185; --green: #34d399;
}
body.navy-light {
  --bg: #ddeeff; --bg2: #eef6ff; --bg3: #d4e8ff;
  --surface: #c0d8f5; --border: #90b8e0; --border2: #5a90cc;
  --text: #040e1c; --text2: #0a2a50; --text3: #2a5888;
  --accent: #0852a8; --accent2: #0c5ab8;
  --gold1: #78380e; --gold2: #c07818;
  --rose: #881337; --green: #14532d;
}
body.purple {
  --bg: #0a0812; --bg2: #110f1e; --bg3: #181528;
  --surface: #201c38; --border: #2c2850; --border2: #3d3870;
  --text: #f0eeff; --text2: #b8b0e0; --text3: #9080c8;
  --accent: #8878ff; --accent2: #a898ff;
  --gold1: #f59e0b; --gold2: #fcd34d;
  --rose: #fb7185; --green: #34d399;
}
body.purple-light {
  --bg: #e8e2ff; --bg2: #f5f2ff; --bg3: #ddd5ff;
  --surface: #ccc0f8; --border: #a898e8; --border2: #8068d0;
  --text: #0e0820; --text2: #2a1860; --text3: #5040a0;
  --accent: #4430c0; --accent2: #3628b0;
  --gold1: #78380e; --gold2: #b05c00;
  --rose: #881337; --green: #14532d;
}
body.red {
  --bg: #120608; --bg2: #1e0a0c; --bg3: #280e10;
  --surface: #3a1014; --border: #5a1820; --border2: #7a2030;
  --text: #fff0f0; --text2: #f0b0b8; --text3: #d08090;
  --accent: #ff6070; --accent2: #ff9090;
  --gold1: #f59e0b; --gold2: #fcd34d;
  --rose: #fb7185; --green: #34d399;
}
body.red-light {
  --bg: #ffeaec; --bg2: #fff5f5; --bg3: #ffd8dc;
  --surface: #ffc0c8; --border: #ff9090; --border2: #ee6070;
  --text: #200408; --text2: #500a10; --text3: #881020;
  --accent: #bb0818; --accent2: #990010;
  --gold1: #78380e; --gold2: #b05c00;
  --rose: #881337; --green: #14532d;
}
body.pink {
  --bg: #120810; --bg2: #1e101c; --bg3: #281828;
  --surface: #381838; --border: #582050; --border2: #782868;
  --text: #fff0ff; --text2: #f0b0e0; --text3: #d088b8;
  --accent: #ff60c0; --accent2: #ff90d8;
  --gold1: #f59e0b; --gold2: #fcd34d;
  --rose: #fb7185; --green: #34d399;
}
body.pink-light {
  --bg: #ffeaff; --bg2: #fff5ff; --bg3: #ffd8ff;
  --surface: #ffc0f8; --border: #ff90e8; --border2: #ee60c0;
  --text: #200020; --text2: #500050; --text3: #881060;
  --accent: #bb0890; --accent2: #990070;
  --gold1: #78380e; --gold2: #b05c00;
  --rose: #881337; --green: #14532d;
}
body.yellow {
  --bg: #0e0c02; --bg2: #1a1800; --bg3: #222000;
  --surface: #302c00; --border: #4a4400; --border2: #6a6000;
  --text: #fffff0; --text2: #e0d890; --text3: #b0a840;
  --accent: #e0b800; --accent2: #f0d040;
  --gold1: #f59e0b; --gold2: #fcd34d;
  --rose: #fb7185; --green: #34d399;
}
body.yellow-light {
  --bg: #fffde8; --bg2: #fffff0; --bg3: #fff8c0;
  --surface: #fff0a0; --border: #e8d840; --border2: #c8b800;
  --text: #1a1800; --text2: #3a3200; --text3: #6a5800;
  --accent: #8a6800; --accent2: #6a5000;
  --gold1: #78380e; --gold2: #b05c00;
  --rose: #881337; --green: #14532d;
}

/* ── BASE ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── MASTHEAD ───────────────────────────────────────────────────── */
.masthead {
  text-align: center;
  padding: 28px 20px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: relative;
}

.masthead-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.wordmark {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: clamp(2rem, 6vw, 3.2rem);
  letter-spacing: -0.01em;
  line-height: 1;
}
.wordmark-dank   { color: var(--accent); }
.wordmark-charts { color: var(--text); }
.wordmark-fm     { color: var(--text3); font-style: italic; }

.tagline {
  font-size: 0.8rem;
  color: var(--text3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 6px;
}

/* ── CTRL GROUPS (theme/lang) ───────────────────────────────────── */
.ctrl-group { position: relative; }

.ctrl-group-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.ctrl-group-btn:hover { border-color: var(--border2); color: var(--text); }

.ctrl-theme-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.ctrl-group-panel {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 8px;
  gap: 4px;
  flex-wrap: wrap;
  z-index: 100;
  min-width: 160px;
  align-items: center;
}
.ctrl-group-panel.open { display: flex; }

.theme-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 50%;
  width: 22px; height: 22px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s;
}
.theme-btn.active { border-color: var(--accent); }

#themeLabel {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--text3);
  margin-left: 2px;
}

.lang-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  white-space: nowrap;
}
.lang-btn.active, .lang-btn:hover { border-color: var(--accent); color: var(--text); }

/* ── LANDING ────────────────────────────────────────────────────── */
#landing {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 140px);
  padding: 40px 20px;
}

.landing-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
  max-width: 440px;
  width: 100%;
  text-align: center;
}

.landing-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  color: var(--accent);
}

.landing-card h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.6rem;
  color: var(--text);
  margin-bottom: 10px;
}

.landing-card p {
  color: var(--text2);
  font-size: 0.9rem;
  margin-bottom: 24px;
  line-height: 1.6;
}

.landing-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.landing-input-row input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 0.9rem;
  outline: none;
}
.landing-input-row input:focus { border-color: var(--accent); }
.landing-input-row input::placeholder { color: var(--text3); }

.landing-input-row button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.landing-input-row button:hover { opacity: 0.9; }
.landing-input-row button:disabled { opacity: 0.5; cursor: default; }

.landing-error {
  color: var(--rose);
  font-size: 0.82rem;
  min-height: 18px;
  margin-bottom: 16px;
}

.landing-services {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.service-badge {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  color: var(--text2);
}
.lastfm-badge { border-color: var(--rose); color: var(--rose); }
.coming-soon { opacity: 0.5; }

.landing-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 16px;
  color: var(--text3);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}
.landing-divider::before,
.landing-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.landing-import-btn {
  width: 100%;
  padding: 11px 20px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.landing-import-btn:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.landing-import-hint {
  margin: 8px 0 0;
  color: var(--text3);
  font-size: 0.75rem;
  line-height: 1.4;
  text-align: center;
}

/* ── USER BAR ───────────────────────────────────────────────────── */
.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  object-fit: cover;
}

.user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.user-name {
  font-family: 'DM Serif Display', serif;
  font-size: 1rem;
  color: var(--text);
}

.user-playcount {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--text3);
  letter-spacing: 0.04em;
}

.change-user-btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text3);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
}
.change-user-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── PERIOD NAV ─────────────────────────────────────────────────── */
.period-nav {
  display: flex;
  gap: 4px;
  padding: 10px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.period-nav button {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.period-nav button:hover { border-color: var(--border2); }
.period-nav button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

/* ── DATE NAV ───────────────────────────────────────────────────── */
.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.date-nav button {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--text2);
  padding: 5px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  transition: border-color 0.15s, color 0.15s;
}
.date-nav button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.date-nav button:disabled { opacity: 0.3; cursor: default; }

.period-label {
  font-family: 'DM Serif Display', serif;
  font-size: 1.05rem;
  color: var(--text);
  min-width: 220px;
  text-align: center;
}

/* ── STATS STRIP ────────────────────────────────────────────────── */
.stats-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 7px 20px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  color: var(--text3);
  flex-wrap: wrap;
}
.stat-val { color: var(--accent); font-weight: 500; }
.stat-dot { color: var(--border2); }

/* ── LIMIT BAR ──────────────────────────────────────────────────── */
.chart-limit-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.chart-limit-bar label {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--text3);
  letter-spacing: 0.06em;
}

.limit-btns { display: flex; gap: 4px; }

.limit-btns button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text3);
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
}
.limit-btns button.active { border-color: var(--accent2); color: var(--accent2); }
.limit-btns button:hover:not(.active) { border-color: var(--border2); color: var(--text2); }

/* ── CHARTS GRID ────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 0;
  padding: 0;
}

.chart-section {
  border-right: 1px solid var(--border);
  padding: 20px;
}
.chart-section:last-child { border-right: none; }

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: var(--accent);
  white-space: nowrap;
}

.section-rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── CHART TABLE ────────────────────────────────────────────────── */
.chart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.chart-table thead th {
  font-family: 'DM Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text3);
  text-transform: uppercase;
  padding: 0 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.chart-table tbody tr {
  border-bottom: 1px solid var(--border);
}
.chart-table tbody tr:last-child { border-bottom: none; }
.chart-table tbody tr:hover { background: var(--bg3); }

.chart-table td {
  padding: 7px 6px;
  vertical-align: middle;
}

.rank-cell {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--text3);
  width: 28px;
  text-align: right;
  padding-right: 10px;
}
.rank-cell.gold { color: var(--gold1); font-weight: 600; }

.img-cell img {
  width: 36px; height: 36px;
  object-fit: cover;
  border-radius: 3px;
  display: block;
  background: var(--bg3);
}

.name-cell { color: var(--text); font-weight: 500; line-height: 1.3; }
.name-cell .sub { color: var(--text3); font-size: 0.75rem; font-weight: 400; }

.plays-cell {
  text-align: right;
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  color: var(--accent2);
  white-space: nowrap;
}

/* ── LOADING ────────────────────────────────────────────────────── */
.loading {
  color: var(--text3);
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  padding: 24px 0;
  text-align: center;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ── IMPORT BTN ─────────────────────────────────────────────────── */
.import-btn {
  background: var(--surface);
  border: 1px solid var(--border2);
  color: var(--accent);
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  transition: border-color 0.15s, background 0.15s;
}
.import-btn:hover { border-color: var(--accent); background: var(--bg3); }

/* ── MODAL ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.1rem;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: var(--bg3); }

.modal-user-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 22px 0;
  border-top: 1px solid var(--border);
}
.modal-user-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
}
.modal-user-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  outline: none;
}
.modal-user-input:focus { border-color: var(--accent); }
.modal-user-input::placeholder { color: var(--text3); }

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 22px;
}

.modal-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text3);
  padding: 10px 14px;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  margin-bottom: -1px;
}
.modal-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.modal-tab:hover:not(.active) { color: var(--text2); }

.modal-body {
  padding: 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  min-height: 42px;
}

.tab-pane { display: flex; flex-direction: column; gap: 14px; }

.tab-desc {
  color: var(--text2);
  font-size: 0.84rem;
  line-height: 1.6;
}

.format-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.format-list li {
  font-size: 0.8rem;
  color: var(--text3);
  padding-left: 12px;
  position: relative;
}
.format-list li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--accent);
}
.format-list li strong { color: var(--text2); }

.action-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 10px 22px;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  align-self: flex-start;
}
.action-btn:hover { opacity: 0.88; }
.action-btn:disabled { opacity: 0.4; cursor: default; }

.sync-info {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--text3);
  min-height: 18px;
}

.progress-wrap { display: flex; flex-direction: column; gap: 6px; }

.progress-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.72rem;
  color: var(--text3);
}

.import-result {
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  min-height: 20px;
}
.import-result.ok  { color: var(--green); }
.import-result.err { color: var(--rose); }

/* ── DROP ZONE ───────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: 10px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: var(--bg3);
}
.drop-icon { font-size: 2rem; }
.drop-label { color: var(--text2); font-size: 0.9rem; }
.drop-sub { color: var(--text3); font-family: 'DM Mono', monospace; font-size: 0.68rem; letter-spacing: 0.06em; }

/* ── SHEETS INPUT ────────────────────────────────────────────────── */
.sheets-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 0.78rem;
  outline: none;
}
.sheets-input:focus { border-color: var(--accent); }
.sheets-input::placeholder { color: var(--text3); }

.sync-stats {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  color: var(--text3);
}

/* ── FOOTER ─────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 24px;
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  color: var(--text3);
  letter-spacing: 0.06em;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}

/* ── RESPONSIVE ─────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .masthead-controls { position: static; justify-content: flex-end; margin-bottom: 10px; }
  .masthead { padding-top: 14px; }
  .charts-grid { grid-template-columns: 1fr; }
  .chart-section { border-right: none; border-bottom: 1px solid var(--border); padding: 16px; }
  .chart-section:last-child { border-bottom: none; }
  .landing-card { padding: 28px 20px; }
  .landing-input-row { flex-direction: column; }
}
