*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
button,
input {
    font: inherit;
    color: inherit;
}

:root {
    --bg: hsl(210 8 16);
    --surface: hsl(210 9 18);
    --text: hsl(210 95 95);
    --text-muted: hsl(210 20 60);
    --accent: hsl(30 60 60);
    --line: hsl(210 05 30);
    --font-sans:
        -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --font-mono:
        "SF Mono", ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo,
        monospace;
    --size-base: 1rem;
    --size-sm: 0.875rem;
    --size-xs: 0.75rem;
    --ls-label: 0.1em;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--size-base);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5rem 1rem;
}

.player {
    width: 100%;
    max-width: 480px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */

.header {
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.site-title {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: 400;
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
    color: var(--text-muted);
}

.station-switch {
    display: flex;
    margin-bottom: 1.5rem;
}

.station-slot {
    flex: 1;
    display: flex;
    align-items: stretch;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-muted);
    transition:
        color 0.15s,
        background 0.15s;
}

.station-slot:first-child {
    border-radius: 3px 0 0 3px;
}
.station-slot:last-child {
    border-radius: 0 3px 3px 0;
    border-left: none;
}

.station-slot.active {
    background: var(--line);
    color: var(--text);
}

.station-slot:not(.active):hover {
    color: var(--text);
}

.station-browse-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    letter-spacing: var(--ls-label);
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    text-align: left;
    line-height: 1;
}

.station-right {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    flex-shrink: 0;
}

.station-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0;
    background: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
}

.station-play-btn svg {
    width: 12px;
    height: 12px;
    fill: currentColor;
}

.station-play-btn:hover {
    color: var(--text);
}

.station-indicator {
    display: none;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
}

.station-slot.is-playing .station-play-btn {
    display: none;
}

.station-slot.is-playing .station-indicator {
    display: inline-block;
}

.station-browse-btn:focus-visible,
.station-play-btn:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: -2px;
}

.vol-bar {
    display: flex;
    align-items: center;
    gap: 6px;
}

.vol-ticks {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 24px;
    padding: 0 5px;
    border: 1px solid var(--line);
    border-radius: 3px;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

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

.vol-mute {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 0;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}

.vol-mute svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.vol-mute:hover {
    color: var(--text);
}

.vol-mute.muted {
    opacity: 0.4;
}

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

.vol-tick {
    width: 1px;
    height: 10px;
    background: var(--line);
    transition: background 0.1s;
    flex-shrink: 0;
}

.vol-tick.filled {
    background: var(--text-muted);
}

.vol-bar:hover .vol-tick.filled {
    background: var(--text);
}

/* --- View toggle --- */

.view-live,
.view-upcoming,
.view-archive {
    flex: 1;
}

[data-view="live"] .view-upcoming,
[data-view="live"] .view-archive {
    display: none;
}

[data-view="upcoming"] .view-live,
[data-view="upcoming"] .view-archive {
    display: none;
}

[data-view="archive"] .view-live,
[data-view="archive"] .view-upcoming {
    display: none;
}

/* --- Now Playing --- */

.now-playing {
    margin-bottom: 1.5rem;
    min-height: 90px;
    display: flex;
    gap: 1rem;
}

.np-art {
    position: relative;
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    background: var(--surface);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0.25rem;
    display: none;
}

.np-art.visible {
    display: block;
}

.np-art img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.9;
    filter: saturate(60%);
}

.art-placeholder {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.art-placeholder .art-ring {
    fill: none;
    stroke: var(--line);
}
.art-placeholder .art-ring.dim {
    opacity: 0.5;
}
.art-placeholder .art-dot {
    fill: var(--line);
}
.np-art img:not([src]),
.history-art img:not([src]),
.archive-art img:not([src]) {
    display: none;
}

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

.np-label {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    letter-spacing: var(--ls-label);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.np-line1 {
    font-size: var(--size-base);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.np-line3 {
    opacity: 0.6;
}

.np-line2,
.np-line3,
.np-line4 {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.show-title {
    color: var(--accent);
}

.live-badge,
.archive-badge,
.ready-badge {
    display: none;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
    background: var(--text-muted);
    color: var(--bg);
    padding: 0.1rem 0.3rem;
    border-radius: 2px;
    line-height: 1;
}

.live-badge.visible,
.archive-badge.visible,
.ready-badge.visible {
    display: inline-block;
}

/* --- On Air banner --- */

.on-air-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

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

.on-air-label {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.on-air-title {
    font-size: var(--size-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.on-air-host {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--accent);
}

.on-air-listeners {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.on-air-listeners:empty {
    display: none;
}

.on-air-tune-in {
    display: none;
    flex-shrink: 0;
    margin-left: 1rem;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
    padding: 0.25rem 0.5rem;
    border-radius: 2px;
    line-height: 1;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--text-muted);
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s,
        border-color 0.15s;
}

.on-air-tune-in.visible {
    display: inline-block;
}

.on-air-tune-in:hover {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

.on-air-tune-in:focus-visible {
    outline: 2px solid var(--text);
    outline-offset: 2px;
}

/* --- Live indicator --- */

.live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    vertical-align: middle;
    flex-shrink: 0;
}

.live-dot.on {
    background: var(--accent);
    animation: pulse 2s ease-in-out infinite;
}

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

@media (prefers-reduced-motion: reduce) {
    .live-dot.on {
        animation: none;
    }
}

/* --- Controls --- */

.controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.play-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: var(--bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

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

.play-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.seek-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.seek-time {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    flex-shrink: 0;
}

.seek-bar {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 24px;
    background: transparent;
    outline: none;
    cursor: pointer;
    min-width: 0;
}

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

.seek-bar::-webkit-slider-runnable-track {
    height: 3px;
    background: var(--line);
    border-radius: 1.5px;
}

.seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    margin-top: -3.5px;
    cursor: pointer;
}

.seek-bar::-moz-range-track {
    height: 3px;
    background: var(--line);
    border: none;
    border-radius: 1.5px;
}

.seek-bar::-moz-range-thumb {
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

/* When live, show a simple line instead of seekable bar */
.seek-wrap.live .seek-bar {
    pointer-events: none;
    opacity: 0.3;
}
.seek-wrap.live .seek-time {
    display: none;
}

#status {
    display: none;
    text-transform: uppercase;
}
.np-label.status-active .status-hidden {
    display: none;
}
.np-label.status-active #status {
    display: inline;
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    letter-spacing: var(--ls-label);
}

/* --- View tabs --- */

.view-tabs {
    display: flex;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.5rem;
}

.view-tab {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
    padding: 0.6rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.view-tab:hover {
    color: var(--text);
}

.view-tab.active {
    color: var(--text);
    border-bottom-color: var(--accent);
}

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

/* --- History --- */

.history {
    display: none;
}

.history.visible {
    display: block;
}

.history-list {
    display: flex;
    flex-direction: column;
}

.history-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
    align-items: center;
}

.history-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.history-art {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    background: var(--surface);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0.25rem;
}

.history-art img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.9;
    filter: saturate(60%);
}

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

.history-track {
    font-size: var(--size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-artist,
.history-album {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-album {
    opacity: 0.6;
}

.history-time {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    flex-shrink: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* --- Archive --- */

.archive-search {
    margin-bottom: 1rem;
}

.archive-search input {
    width: 100%;
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--line);
    padding: 6px 10px;
    outline: none;
    letter-spacing: 0.04em;
    transition:
        color 0.15s,
        border-color 0.15s;
    border-radius: 0.5rem;
}

.archive-search input:focus {
    color: var(--text);
    border-color: var(--text-muted);
}

.archive-search input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.archive-list {
    display: flex;
    flex-direction: column;
}

.archive-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
    align-items: center;
    cursor: pointer;
    transition: opacity 0.15s;
}

.archive-item[hidden] {
    display: none;
}

.archive-item:not(:has(~ .archive-item:not([hidden]))) {
    border-bottom: none;
    padding-bottom: 0;
}
.archive-item:hover {
    opacity: 0.8;
}

.archive-art {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    background: var(--surface);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 0.25rem;
}

.archive-art img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0.9;
    filter: saturate(60%);
}

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

.archive-title {
    font-size: var(--size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.archive-host {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
}

.archive-meta {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    opacity: 0.6;
}

.archive-play {
    flex-shrink: 0;
    line-height: 0;
}

.archive-play svg {
    width: 24px;
    height: 24px;
    fill: var(--accent);
    overflow: visible;
}

.progress-track,
.progress-arc {
    fill: none;
    stroke-width: 2;
}

.progress-track {
    stroke: var(--accent);
}

.progress-arc {
    stroke: var(--line);
    transform: rotate(-90deg);
    transform-origin: center;
}

.archive-play svg > path {
    transform: scale(0.7);
    transform-origin: center;
}

/* --- Upcoming --- */

.upcoming-list {
    display: flex;
    flex-direction: column;
}

.upcoming-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--line);
    align-items: baseline;
}

.upcoming-item:first-child {
    padding-top: 0;
}

.upcoming-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.upcoming-time {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 5.5em;
}

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

.upcoming-title {
    font-size: var(--size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upcoming-meta {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
}

/* --- Footer --- */

.footer {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.footer-disclaimer {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    opacity: 0.6;
}

.footer-links {
    display: flex;
    gap: 3rem;
    margin-top: 0.5rem;
}

.footer-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-heading {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    font-weight: normal;
    color: var(--text);
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
}

.footer-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.footer a {
    font-size: var(--size-sm);
    color: var(--text-muted);
    text-decoration: none;
}

.footer a:hover {
    color: var(--text);
}
.footer a:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 2px;
}

.empty-msg {
    font-family: var(--font-mono);
    font-size: var(--size-xs);
    color: var(--text-muted);
    padding: 1rem 0;
}

/* --- Mobile --- */

@media (max-width: calc(480px + 2rem)) {
    body {
        padding: 2rem 1rem;
    }
}
