@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700;900&display=swap');

:root {
  --bg: #0a0b0f;
  --bg2: #0f1117;
  --bg3: #141720;
  --accent: #F4DD44;
  --accent2: #F9EE8A;
  --text: #e8eaf0;
  --muted: #7a7f94;
  --border: rgba(255, 255, 255, 0.07);
  --glass: rgba(255, 255, 255, 0.04);
  --radius: 16px;
  --transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  --font-head: 'DM Sans', sans-serif;
  --font-body: 'DM Sans', sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; font-size: 16px; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

::selection { background: var(--accent); color: #111; }

a { color: var(--accent); }

.wrap {
  width: 100%;
  max-width: 720px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}
.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 16px rgba(244, 221, 68, 0.6);
}

.panel {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  padding: 28px;
}

.track-title {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.4rem;
  margin: 0 0 4px;
}

.track-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 24px;
}

.cover {
  width: 100%;
  aspect-ratio: 16 / 5;
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(244, 221, 68, 0.18) 0%, transparent 60%),
    var(--bg3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  overflow: hidden;
}
.cover svg { opacity: 0.5; width: 64px; height: 64px; }

.controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-play {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  color: #111;
}
.btn-play:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(244, 221, 68, 0.35); }
.btn-play svg { width: 22px; height: 22px; }

.progress-area { flex: 1; }

.progress-bar {
  position: relative;
  height: 6px;
  border-radius: 100px;
  background: var(--bg3);
  cursor: pointer;
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.progress-times {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

.volume {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.volume input[type="range"] {
  width: 80px;
  accent-color: var(--accent);
}

.tracklist {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  max-height: 260px;
  overflow-y: auto;
}
.tracklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background var(--transition);
  color: var(--text);
}
.tracklist-item:hover { background: var(--glass); }
.tracklist-item.active { background: rgba(244, 221, 68, 0.12); color: var(--accent2); }
.tracklist-item .idx { color: var(--muted); font-size: 0.8rem; width: 20px; text-align: right; }
.tracklist-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 0;
}

footer.meta {
  margin-top: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ---------- Analytics page ---------- */

body.analytics {
  display: block;
  padding: 32px 24px 64px;
}

.analytics-wrap {
  max-width: 1080px;
  margin: 0 auto;
}

.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.analytics-header .updated {
  color: var(--muted);
  font-size: 0.82rem;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-tile .label {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 6px;
}
.stat-tile .value {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.8rem;
}

.section {
  margin-bottom: 28px;
}
.section h2 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
  padding: 0 4px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}
.chart-bar {
  width: 100%;
  max-width: 24px;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  border-radius: 4px 4px 0 0;
  transition: opacity var(--transition);
}
.chart-bar-col:hover .chart-bar { opacity: 0.75; }
.chart-bar-col .tip {
  position: absolute;
  bottom: 100%;
  margin-bottom: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.chart-bar-col:hover .tip { opacity: 1; }
.chart-labels {
  display: flex;
  gap: 2px;
  padding: 6px 4px 0;
}
.chart-labels span {
  flex: 1;
  text-align: center;
  font-size: 0.68rem;
  color: var(--muted);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
table.data-table th, table.data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
table.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
}
table.data-table th:hover { color: var(--accent2); }
table.data-table td { font-variant-numeric: tabular-nums; }
table.data-table tbody tr:hover { background: var(--glass); }

.auth-note {
  color: var(--muted);
  font-size: 0.8rem;
}

.hint {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}

table.data-table tbody tr[data-id] { cursor: pointer; }

/* ---------- Detail modal ---------- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-overlay.open { display: flex; }

.modal-panel {
  position: relative;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: rgba(244, 221, 68, 0.15); color: var(--accent2); }

.detail-title {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 1.3rem;
  margin: 0 0 4px;
  padding-right: 40px;
  word-break: break-all;
}
.detail-sub {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 0 0 20px;
}
.detail-sub.missing { color: #e05252; }

.detail-section {
  margin-top: 24px;
}
.detail-section h3 {
  font-family: var(--font-head);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}

.detail-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 100px;
  border-bottom: 1px solid var(--border);
}
.detail-chart .chart-bar-col { height: 100%; }

/* ---------- Listening timeline (per-session scatter) ---------- */

.timeline-strip {
  position: relative;
  height: 90px;
  margin-top: 8px;
  border-bottom: 1px solid var(--border);
}
.timeline-point {
  position: absolute;
  bottom: 0;
  width: 8px;
  margin-left: -4px;
  min-height: 4px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  cursor: pointer;
  transition: opacity var(--transition), width var(--transition);
}
.timeline-point:hover {
  opacity: 0.8;
  width: 12px;
  margin-left: -6px;
}
.timeline-point .tip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 0.72rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 5;
}
.timeline-point:hover .tip { opacity: 1; }
.timeline-point .pause-mark {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bg2);
}
.timeline-axis-labels {
  display: flex;
  justify-content: space-between;
  padding: 6px 0 0;
  font-size: 0.7rem;
  color: var(--muted);
}
.timeline-empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 16px 0;
  text-align: center;
}
