@import url('https://fonts.googleapis.com/css2?family=Circular+Std:wght@400;700&family=DM+Mono:wght@400;500&display=swap');
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --green: #1db954;
    --green-dim: #158a3e;
    --bg: #0a0a0a;
    --surface: #141414;
    --surface2: #1c1c1c;
    --surface3: #242424;
    --border: #2a2a2a;
    --text: #ffffff;
    --text-muted: #888;
    --text-dim: #555;
    --font: 'DM Sans', sans-serif;
    --mono: 'DM Mono', monospace;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 40px 20px 80px;
}

/* ── Header ── */
header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

header svg {
    flex-shrink: 0;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

h1 span {
    color: var(--green);
}

/* ── Controls ── */
.controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.file-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: var(--font);
    transition: border-color 0.2s, color 0.2s;
}

.file-label:hover {
    border-color: var(--green);
    color: var(--text);
}

.file-label svg {
    color: var(--green);
    flex-shrink: 0;
}

#fileInput {
    display: none;
}

#fileStatus {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--mono);
}

/* ── Date Nav ── */
.date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.nav-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    font-size: 1rem;
}

.nav-btn:hover:not(:disabled) {
    border-color: var(--green);
    color: var(--green);
    background: rgba(29,185,84,0.08);
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#datePicker {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.85rem;
    padding: 8px 12px;
    cursor: pointer;
    transition: border-color 0.2s;
    color-scheme: dark;
}

#datePicker:focus {
    outline: none;
    border-color: var(--green);
}

/* ── Stats Bar ── */
#statsBar {
    display: none;
    gap: 12px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

#statsBar.visible {
    display: flex;
}

.stat-card {
    flex: 1;
    min-width: 130px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
}

.stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 6px;
    font-weight: 600;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--green);
    letter-spacing: -0.02em;
    line-height: 1;
}

.stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Timeline ── */
#timelineContainer {
    margin-bottom: 28px;
    display: none;
}

#timelineContainer.visible {
    display: block;
}

.timeline-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    padding: 0 2px;
}

.timeline-labels span {
    font-size: 0.65rem;
    color: var(--text-dim);
    font-family: var(--mono);
}

#timeline {
    position: relative;
    height: 48px;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: visible;
}

/* Hour gridlines */
.hour-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border);
    opacity: 0.5;
}

.dot {
    position: absolute;
    width: 3px;
    border-radius: 2px 2px 0 0;
    background: var(--green);
    bottom: 0;
    height: 32px;
    opacity: 0.85;
    cursor: pointer;
    transition: opacity 0.15s, height 0.15s;
}

.dot:hover {
    opacity: 1;
    height: 44px;
    background: #fff;
    z-index: 10;
}

/* Tooltip */
.tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 100;
    max-width: 220px;
    white-space: normal;
}

.tooltip .tt-time {
    font-family: var(--mono);
    color: var(--green);
    font-size: 0.7rem;
    margin-bottom: 2px;
}

.tooltip .tt-track {
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--text);
}

.tooltip .tt-artist {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.dot:hover .tooltip {
    opacity: 1;
}

/* ── Results ── */
#results {
    list-style: none;
    padding: 0;
}

#results li {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    transition: background 0.12s;
    border-radius: 6px;
}

#results li:hover {
    background: var(--surface);
}

#results li.empty-msg {
    color: var(--text-muted);
    justify-content: center;
    padding: 40px;
    border: none;
}

.time {
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--green);
    min-width: 68px;
    font-weight: 500;
}

.track-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.track-name {
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.artist-name {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.duration {
    margin-left: auto;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--text-dim);
    flex-shrink: 0;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Responsive ── */
@media (max-width: 520px) {
    .date-nav { margin-left: 0; width: 100%; }
    .stat-value { font-size: 1.1rem; }
}