/* ============================================================
   AudioRealm.net Design System v1.0
   Purple & Gold theme — inspired by the original 2004 AudioRealm
   Modern responsive CSS with classic radio directory aesthetics
   ============================================================ */

/* ---- Design Tokens ---- */
:root {
    /* Purple backgrounds (darkest → lightest) */
    --ar-bg:          #1a0a2e;
    --ar-bg2:         #231244;
    --ar-bg3:         #2d1054;
    --ar-card-bg:     #2d1054;
    --ar-card2:       #3a1a6a;

    /* Borders */
    --ar-border:      #3d2060;
    --ar-border2:     #4a2878;

    /* Primary accent — Gold */
    --ar-gold:        #d4a017;
    --ar-gold-light:  #ffd700;
    --ar-gold-dim:    #b8860b;
    --ar-gold-glow:   rgba(212,160,23,.18);

    /* Secondary accent — Purple highlight */
    --ar-purple-mid:  #4a1a7a;
    --ar-purple-light:#6b3fa0;
    --ar-purple-glow: rgba(107,63,160,.25);

    /* Status colors */
    --ar-green:       #22c55e;
    --ar-yellow:      #eab308;
    --ar-red:         #ef4444;
    --ar-orange:      #f97316;
    --ar-cyan:        #0891b2;

    /* Text */
    --ar-text:        #e8e0f0;
    --ar-text-dim:    #a89cc0;
    --ar-muted:       #6b5b8a;

    /* Layout */
    --ar-topbar-h:    56px;
    --ar-radius:      10px;
    --ar-radius-sm:   6px;
    --ar-radius-xs:   4px;

    /* Typography */
    --ar-font:        'Inter','Segoe UI',system-ui,-apple-system,sans-serif;
    --ar-font-mono:   'SF Mono','Fira Code','Consolas',monospace;

    /* Shadows */
    --ar-shadow:      0 4px 20px rgba(0,0,0,.5);
    --ar-shadow-lg:   0 8px 30px rgba(0,0,0,.6);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: var(--ar-font);
    font-size: 14px;
    line-height: 1.5;
    background: var(--ar-bg);
    color: var(--ar-text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Focus / Accessibility ---- */
:focus-visible {
    outline: 2px solid var(--ar-gold);
    outline-offset: 2px;
}
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
    background: var(--ar-bg2); color: var(--ar-text); border: 1px solid var(--ar-border);
    padding: 4px 10px; border-radius: var(--ar-radius-xs); font-size: 12px;
    white-space: nowrap; opacity: 0; pointer-events: none;
    transition: opacity .15s; z-index: 9000;
}
[data-tooltip]:hover::after, [data-tooltip]:focus::after { opacity: 1; }

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 { line-height: 1.2; color: var(--ar-text); font-weight: 700; }
h1 { font-size: clamp(1.4rem, 3vw, 1.8rem); margin-bottom: 1rem; }
h2 { font-size: clamp(1.2rem, 2.5vw, 1.5rem); margin-bottom: .8rem; }
h3 { font-size: clamp(1rem, 2vw, 1.25rem); margin-bottom: .6rem; }
h4 { font-size: 1rem; margin-bottom: .5rem; }
p { margin-bottom: 1rem; color: var(--ar-text-dim); line-height: 1.6; }
a { color: var(--ar-gold); text-decoration: none; transition: color .15s; }
a:hover { color: var(--ar-gold-light); }

/* ---- Container ---- */
.container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-wrapper {
    flex: 1;
    display: flex;
}

.content {
    flex: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    width: 100%;
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
    background: linear-gradient(135deg, #1a0a2e 0%, #2d1054 40%, #4a1a7a 70%, #3a1265 100%);
    border-bottom: 3px solid var(--ar-gold);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--ar-shadow);
}

.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Top banner with logo and waveform */
.header-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 8px;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    z-index: 2;
}

.header-logo-text {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--ar-text);
}

.header-logo-text span {
    color: var(--ar-gold);
}

.header-tagline {
    color: var(--ar-text-dim);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    display: block;
    margin-top: 2px;
}

/* Waveform animation in header */
.header-waveform {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 40px;
    z-index: 2;
}

.header-waveform .bar {
    width: 3px;
    border-radius: 2px 2px 0 0;
    animation: waveform-pulse 1.2s ease-in-out infinite;
}

.header-waveform .bar:nth-child(1)  { height: 60%; animation-delay: 0s;    background: #22c55e; }
.header-waveform .bar:nth-child(2)  { height: 80%; animation-delay: .1s;   background: #4ade80; }
.header-waveform .bar:nth-child(3)  { height: 45%; animation-delay: .2s;   background: #22c55e; }
.header-waveform .bar:nth-child(4)  { height: 95%; animation-delay: .05s;  background: #86efac; }
.header-waveform .bar:nth-child(5)  { height: 55%; animation-delay: .15s;  background: #22c55e; }
.header-waveform .bar:nth-child(6)  { height: 70%; animation-delay: .25s;  background: #4ade80; }
.header-waveform .bar:nth-child(7)  { height: 40%; animation-delay: .3s;   background: #22c55e; }
.header-waveform .bar:nth-child(8)  { height: 85%; animation-delay: .08s;  background: #86efac; }
.header-waveform .bar:nth-child(9)  { height: 50%; animation-delay: .18s;  background: #4ade80; }
.header-waveform .bar:nth-child(10) { height: 75%; animation-delay: .12s;  background: #22c55e; }
.header-waveform .bar:nth-child(11) { height: 90%; animation-delay: .22s;  background: #86efac; }
.header-waveform .bar:nth-child(12) { height: 35%; animation-delay: .28s;  background: #22c55e; }
.header-waveform .bar:nth-child(13) { height: 65%; animation-delay: .06s;  background: #4ade80; }
.header-waveform .bar:nth-child(14) { height: 50%; animation-delay: .16s;  background: #22c55e; }
.header-waveform .bar:nth-child(15) { height: 80%; animation-delay: .09s;  background: #86efac; }
.header-waveform .bar:nth-child(16) { height: 55%; animation-delay: .2s;   background: #4ade80; }

@keyframes waveform-pulse {
    0%, 100% { transform: scaleY(0.4); opacity: 0.6; }
    50%      { transform: scaleY(1);   opacity: 1;   }
}

/* Navigation tabs */
.header-nav {
    display: flex;
    gap: 0;
    border-top: 1px solid rgba(255,255,255,.08);
    margin-top: 4px;
}

.nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    color: var(--ar-text-dim);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s, background .15s;
    position: relative;
}

.nav-tab:hover {
    color: var(--ar-gold-light);
    background: rgba(212,160,23,.06);
}

.nav-tab.active {
    color: var(--ar-gold);
    border-bottom-color: var(--ar-gold);
    background: rgba(212,160,23,.08);
}

.nav-tab svg { opacity: 0.7; }
.nav-tab.active svg, .nav-tab:hover svg { opacity: 1; }

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    z-index: 2;
}

.mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--ar-text);
    margin: 5px 0;
    transition: transform .2s, opacity .2s;
    border-radius: 1px;
}

.mobile-menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.mobile-menu-toggle.active span:nth-child(2) { opacity: 0; }
.mobile-menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Mobile menu overlay */
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 998;
    backdrop-filter: blur(2px);
}
.mobile-menu-overlay.active { display: block; }

/* Mobile slide-out menu */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    background: var(--ar-bg2);
    z-index: 999;
    padding: 60px 20px 20px;
    transition: right .25s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    border-left: 2px solid var(--ar-gold-dim);
}
.mobile-menu.active { right: 0; }

.mobile-menu-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--ar-text);
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
}

.mobile-menu h3 {
    color: var(--ar-gold);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--ar-border);
}

.mobile-menu .menu-list {
    list-style: none;
    padding: 0;
}

.mobile-menu .menu-list li a {
    display: block;
    padding: 10px 12px;
    color: var(--ar-text-dim);
    text-decoration: none;
    border-radius: var(--ar-radius-xs);
    transition: background .15s, color .15s;
    font-size: 0.9rem;
}

.mobile-menu .menu-list li a:hover,
.mobile-menu .menu-list li a.active {
    background: var(--ar-purple-glow);
    color: var(--ar-gold);
}

@media (max-width: 860px) {
    .mobile-menu-toggle { display: block; }
    .header-nav { display: none; }
    .header-waveform { display: none; }
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loadingOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26,10,46,.8);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    backdrop-filter: blur(3px);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(212,160,23,.2);
    border-top-color: var(--ar-gold);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.loading-text {
    color: var(--ar-gold);
    font-size: 0.9rem;
    font-weight: 600;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--ar-card-bg);
    border: 1px solid var(--ar-border);
    border-radius: var(--ar-radius);
    padding: 1.25rem;
    box-shadow: var(--ar-shadow);
    transition: border-color .15s;
}

.card:hover {
    border-color: var(--ar-border2);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

/* ============================================================
   HERO SECTION (index.php)
   ============================================================ */
.hero {
    text-align: center;
    padding: 3rem 1rem;
    background: linear-gradient(180deg, rgba(45,16,84,.6) 0%, rgba(26,10,46,0) 100%);
    border-bottom: 1px solid var(--ar-border);
    margin: -1.5rem -1rem 2rem;
}

.hero h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    color: var(--ar-text);
    margin-bottom: 0.5rem;
}

.hero h1 span { color: var(--ar-gold); }

.hero p {
    font-size: 1.1rem;
    color: var(--ar-text-dim);
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--ar-gold-dim), var(--ar-gold));
    color: #1a0a2e;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: var(--ar-radius-sm);
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 4px 16px rgba(212,160,23,.3);
}

.hero-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(212,160,23,.5);
    color: #1a0a2e;
}

/* ============================================================
   TOP STATIONS TABLE (index.php)
   ============================================================ */
.top-stations {
    margin: 2rem 0;
}

.top-stations-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--ar-gold-dim);
}

.top-stations-header h2 {
    color: var(--ar-gold);
    margin: 0;
}

.top-stations-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: var(--ar-card-bg);
    border: 1px solid var(--ar-border);
    border-radius: var(--ar-radius);
    overflow: hidden;
}

.top-stations-table thead tr {
    background: linear-gradient(90deg, #1a0a2e 0%, #2d1054 100%);
    border-bottom: 2px solid var(--ar-gold);
}

.top-stations-table thead th {
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ar-gold);
    white-space: nowrap;
}

.top-stations-table tbody tr {
    border-bottom: 1px solid rgba(61,32,96,.6);
    transition: background .15s;
}

.top-stations-table tbody tr:hover {
    background: rgba(212,160,23,.04);
}

.top-stations-table tbody td {
    padding: 0.6rem 0.75rem;
    vertical-align: middle;
}

/* Rank medals */
.rank-medal { font-weight: 700; text-align: center; }
.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }
.rank-other { color: var(--ar-muted); }

/* Genre pills */
.genre-pill {
    display: inline-block;
    background: rgba(212,160,23,.12);
    border: 1px solid rgba(212,160,23,.3);
    color: var(--ar-gold);
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 10px;
    white-space: nowrap;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s;
}

.genre-pill:hover {
    background: rgba(212,160,23,.22);
    color: var(--ar-gold-light);
}

/* Play button */
.btn-play-sm {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity .15s, transform .15s;
    white-space: nowrap;
    background: linear-gradient(135deg, var(--ar-purple-mid), var(--ar-gold-dim));
    color: #fff;
}

.btn-play-sm:hover {
    opacity: 0.85;
    transform: translateY(-1px);
    color: #fff;
}

/* ============================================================
   DIRECTORY STYLES (directory.php)
   ============================================================ */

/* Directory CSS custom properties */
.dir-wrap {
    --dir-bg:       #1a0a2e;
    --dir-bg2:      #231244;
    --dir-border:   #3d2060;
    --dir-accent:   #d4a017;
    --dir-accent2:  #ffd700;
    --dir-green:    #22c55e;
    --dir-text:     #e8e0f0;
    --dir-muted:    #6b5b8a;
    --dir-radius:   8px;
    --dir-transition: 0.18s ease;
}

.dir-wrap {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
    font-family: inherit;
    color: var(--dir-text);
}

.dir-title {
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 700;
    color: var(--dir-accent);
    margin: 0 0 0.25rem;
    letter-spacing: -0.02em;
}

.dir-subtitle {
    color: var(--dir-muted);
    font-size: 0.875rem;
    margin: 0 0 1.5rem;
}

/* Filter bar */
.dir-filters {
    background: var(--dir-bg2);
    border: 1px solid var(--dir-border);
    border-radius: var(--dir-radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.dir-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1 1 160px;
    min-width: 130px;
}

.dir-filter-group label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--dir-accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dir-filter-group input,
.dir-filter-group select {
    background: #1a0a2e;
    border: 1px solid var(--dir-border);
    color: var(--dir-text);
    border-radius: 5px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--dir-transition);
    width: 100%;
    box-sizing: border-box;
}

.dir-filter-group input:focus,
.dir-filter-group select:focus {
    border-color: var(--dir-accent);
    box-shadow: 0 0 0 2px rgba(212,160,23,.15);
}

.dir-filter-group select option {
    background: #231244;
}

.dir-toggle-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.15rem;
}

.dir-toggle-group input[type="checkbox"] {
    accent-color: var(--dir-accent);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.dir-toggle-group label {
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--dir-text);
    user-select: none;
}

.dir-btn {
    padding: 0.45rem 1.1rem;
    border-radius: 5px;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity var(--dir-transition), transform var(--dir-transition);
}

.dir-btn:hover { opacity: 0.85; transform: translateY(-1px); }

.dir-btn-primary {
    background: linear-gradient(135deg, var(--ar-purple-mid), var(--ar-gold));
    color: #fff;
}

.dir-btn-secondary {
    background: #231244;
    color: var(--dir-text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

/* Stats row */
.dir-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.82rem;
    color: var(--dir-muted);
}

.dir-stat-pill {
    background: var(--dir-bg2);
    border: 1px solid var(--dir-border);
    border-radius: 20px;
    padding: 0.2rem 0.65rem;
    font-size: 0.78rem;
}

.dir-stat-pill strong {
    color: var(--dir-accent);
}

/* Station table */
.dir-table-wrap {
    overflow-x: auto;
    border-radius: var(--dir-radius);
    border: 1px solid var(--dir-border);
    background: var(--dir-bg2);
}

.dir-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.dir-table thead tr {
    background: linear-gradient(90deg, #1a0a2e 0%, #2d1054 100%);
    border-bottom: 2px solid var(--dir-accent);
}

.dir-table thead th {
    padding: 0.65rem 0.6rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--dir-accent);
    white-space: nowrap;
}

.dir-table thead th a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dir-table thead th a:hover { color: var(--dir-accent2); }

.sort-arrow { font-size: 0.7em; opacity: 0.6; }
.sort-arrow.active { opacity: 1; color: var(--dir-accent2); }

.dir-table tbody tr {
    border-bottom: 1px solid rgba(61,32,96,.6);
    transition: background var(--dir-transition);
    animation: rowFadeIn 0.35s ease both;
}

.dir-table tbody tr:hover {
    background: rgba(212,160,23,.04);
}

@keyframes rowFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dir-table tbody td {
    padding: 0.6rem 0.6rem;
    vertical-align: middle;
}

/* Column sizes */
.col-rank { width: 36px; text-align: right; color: var(--dir-muted); font-size: 0.75rem; }
.col-codec { width: 70px; }
.col-name { min-width: 180px; max-width: 260px; }
.col-genre { min-width: 110px; max-width: 200px; }
.col-bitrate { width: 72px; text-align: right; font-family: var(--ar-font-mono); color: var(--dir-accent); }
.col-listeners { width: 90px; text-align: right; font-family: var(--ar-font-mono); }
.col-actions { width: 120px; }

/* Station name */
.stn-name {
    font-weight: 700;
    color: var(--dir-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
    display: block;
}

.stn-detail-link {
    color: inherit;
    text-decoration: none;
}
.stn-detail-link:hover { color: var(--dir-accent2); }

.stn-status-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.stn-status-online { background: #166534; color: #86efac; }
.stn-status-offline { background: #3f1212; color: #fca5a5; }

.stn-spotlight {
    display: inline-block;
    color: #f59e0b;
    font-size: 0.75rem;
    margin-left: 3px;
    vertical-align: middle;
}

/* Genre pills in directory */
.genre-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

/* Listeners */
.listeners-count {
    color: var(--dir-green);
    font-weight: 600;
}

.listeners-peak {
    color: var(--dir-muted);
    font-size: 0.75rem;
}

/* Now playing */
.now-playing {
    color: var(--dir-muted);
    font-size: 0.75rem;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

.now-playing.has-song {
    color: #d8b4fe;
    font-style: normal;
}

/* Action buttons */
.action-btns {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.btn-play, .btn-site {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity var(--dir-transition), transform var(--dir-transition);
    white-space: nowrap;
}

.btn-play:hover, .btn-site:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

.btn-play {
    background: linear-gradient(135deg, var(--ar-purple-mid), var(--ar-gold-dim));
    color: #fff;
}

.btn-site {
    background: rgba(61,32,96,.8);
    color: var(--dir-text);
    border: 1px solid var(--dir-border);
}

/* Pagination */
.dir-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 1.5rem;
}

.dir-pagination a,
.dir-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 5px;
    font-size: 0.82rem;
    text-decoration: none;
    border: 1px solid var(--dir-border);
    color: var(--dir-text);
    background: var(--dir-bg2);
    transition: background var(--dir-transition), border-color var(--dir-transition);
}

.dir-pagination a:hover {
    background: rgba(212,160,23,.12);
    border-color: var(--dir-accent);
    color: var(--dir-accent);
}

.dir-pagination .pag-active {
    background: var(--dir-accent);
    border-color: var(--dir-accent);
    color: #1a0a2e;
    font-weight: 700;
    cursor: default;
}

.dir-pagination .pag-disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

.dir-pagination .pag-ellipsis {
    border: none;
    background: transparent;
    color: var(--dir-muted);
    cursor: default;
}

/* Performance footer */
.dir-perf-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 0.65rem 1rem;
    background: var(--dir-bg2);
    border: 1px solid var(--dir-border);
    border-radius: var(--dir-radius);
    font-size: 0.73rem;
    color: var(--dir-muted);
}

.dir-perf-bar span strong { color: var(--dir-accent); }

/* Directory loading overlay */
#dirLoadingOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26,10,46,.75);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    backdrop-filter: blur(3px);
}

#dirLoadingOverlay.active { display: flex; }

.dir-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(212,160,23,.2);
    border-top-color: var(--dir-accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.dir-loading-text {
    color: var(--dir-accent);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Empty state */
.dir-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--dir-muted);
}

.dir-empty-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.dir-empty h3 {
    color: var(--dir-text);
    margin-bottom: 0.5rem;
}

/* Station row drawer */
.stn-row { cursor: pointer; }
.stn-row:hover td { background: rgba(212,160,23,.03); }
.stn-row.drawer-open td { background: rgba(212,160,23,.06); }

.stn-drawer-row td { padding: 0; }
.stn-drawer-row td > .drawer-inner {
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s cubic-bezier(.4,0,.2,1), padding .2s ease;
    padding: 0 16px;
    background: linear-gradient(180deg, rgba(35,18,68,.98) 0%, rgba(26,10,46,.99) 100%);
    border-bottom: 2px solid rgba(212,160,23,.25);
}
.stn-drawer-row.open td > .drawer-inner {
    max-height: 600px;
    padding: 16px;
}

.drawer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px 20px;
    margin-bottom: 12px;
}

.drw-kv { display: flex; flex-direction: column; gap: 2px; }
.drw-lbl { font-size: 9px; color: var(--dir-muted); text-transform: uppercase; letter-spacing: .05em; }
.drw-val { font-size: 12px; color: var(--dir-text); word-break: break-word; }

.drawer-title {
    font-size: 14px; font-weight: 700; color: var(--dir-accent);
    margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}

.drawer-actions {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    padding-top: 10px; border-top: 1px solid rgba(255,255,255,.06);
}

.drw-btn-detail {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 14px; border-radius: 5px; font-size: 12px; font-weight: 700;
    background: linear-gradient(135deg, var(--dir-accent), var(--ar-gold-dim)); color: #1a0a2e;
    text-decoration: none; transition: opacity .15s;
}
.drw-btn-detail:hover { opacity: .85; color: #1a0a2e; text-decoration: none; }

.drw-btn-play {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px; border-radius: 5px; font-size: 12px; font-weight: 600;
    background: rgba(212,160,23,.14); border: 1px solid rgba(212,160,23,.4);
    color: var(--dir-accent); cursor: pointer; transition: background .15s;
    text-decoration: none;
}
.drw-btn-play:hover { background: rgba(212,160,23,.25); color: var(--dir-accent); }

.drw-now-playing {
    font-size: 11px; color: var(--ar-text-dim); margin-bottom: 10px;
    display: flex; align-items: center; gap: 5px;
}
.drw-now-playing .note { color: var(--dir-accent); font-size: 13px; }

.drw-url {
    font-size: 10px; color: var(--ar-muted); font-family: var(--ar-font-mono);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
    display: block; margin-bottom: 2px;
}

.drw-https-badge {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 9px; padding: 1px 6px; border-radius: 999px;
    background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.3);
    color: var(--ar-green); white-space: nowrap;
}

/* ============================================================
   ABOUT PAGE (about.php)
   ============================================================ */
.about-section {
    margin-bottom: 2.5rem;
}

.about-block {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}

.about-icon {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(212,160,23,.08);
    border: 1px solid rgba(212,160,23,.2);
    border-radius: var(--ar-radius);
}

.about-section h2 {
    margin-bottom: 0.75rem;
}

.about-section p {
    color: var(--ar-text-dim);
    line-height: 1.75;
    max-width: 720px;
}

@media (max-width: 600px) {
    .about-block {
        flex-direction: column;
    }
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    background: linear-gradient(180deg, #231244 0%, #1a0a2e 100%);
    border-top: 2px solid var(--ar-gold-dim);
    padding: 2rem 1rem 0;
    margin-top: auto;
}

.footer-content {
    max-width: 1440px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    padding-bottom: 1.5rem;
}

.footer-section h4 {
    color: var(--ar-gold);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--ar-border);
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 6px;
}

.footer-section ul li a {
    color: var(--ar-text-dim);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color .15s;
}

.footer-section ul li a:hover {
    color: var(--ar-gold);
}

.footer-bottom {
    border-top: 1px solid var(--ar-border);
    padding: 1rem 0;
    font-size: 0.75rem;
    color: var(--ar-muted);
    max-width: 1440px;
    margin: 0 auto;
}

/* Social links in footer */
.social-links {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.social-links a {
    color: var(--ar-text-dim);
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    transition: color .15s;
}

.social-links a:hover {
    color: var(--ar-gold);
}

/* ============================================================
   RESPONSIVE — Mobile-first progressive enhancement
   ============================================================ */

/* -- Safe area insets for notched phones (iPhone X+) -- */
.container {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}
.footer-bottom {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

/* -- Touch targets: minimum 44×44px for all interactive elements -- */
@media (pointer: coarse) {
    button, .btn-play-sm, .hero-cta, .nav-tab,
    .mobile-menu .menu-list li a,
    .footer-section ul li a,
    .social-links a,
    select, input[type="text"], input[type="search"] {
        min-height: 44px;
        min-width: 44px;
    }
    .nav-tab { padding: 10px 14px; }
    .genre-pill { padding: 4px 10px; font-size: 0.78rem; }
    .btn-play-sm { padding: 8px 14px; font-size: 0.82rem; }
}

/* -- Smooth tap highlight for mobile -- */
a, button, select, input {
    -webkit-tap-highlight-color: rgba(212,160,23,.15);
}

/* ---- Tablet landscape (1024px) ---- */
@media (max-width: 1024px) {
    .container { max-width: 100%; padding: 0 1rem; }
    .top-stations-table th:nth-child(5),
    .top-stations-table td:nth-child(5) { display: none; } /* hide kbps on tablet */
    .card-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}

/* ---- Tablet portrait / large phone (900px) ---- */
@media (max-width: 900px) {
    .col-reliability { display: none; }
    .hero h1 { font-size: 1.8rem; }
    .hero p { font-size: 0.95rem; }
}

/* ---- Phone landscape / small tablet (780px) ---- */
@media (max-width: 780px) {
    .drawer-grid { grid-template-columns: 1fr 1fr; }
    .top-stations-table th:nth-child(6),
    .top-stations-table td:nth-child(6) { font-size: 0.78rem; } /* listeners smaller */
    .card-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; }
}

/* ---- Standard phone (620px) ---- */
@media (max-width: 620px) {
    .col-genre { display: none; }
    .dir-filters { flex-direction: column; }
    .dir-filter-group { flex: 1 1 100%; }
    .hero { padding: 2rem 1rem; margin: -1rem -1rem 1.5rem; }
    .hero h1 { font-size: 1.5rem; }
    .hero p { font-size: 0.9rem; max-width: 90vw; }
    .hero-cta { font-size: 0.9rem; padding: 10px 20px; }

    /* Stack top-stations table for mobile readability */
    .top-stations-table th:nth-child(2),
    .top-stations-table td:nth-child(2) { display: none; } /* hide codec column */
    .top-stations-table th:nth-child(5),
    .top-stations-table td:nth-child(5) { display: none; } /* hide kbps column */
    .top-stations-table th:nth-child(6),
    .top-stations-table td:nth-child(6) { display: none; } /* hide listeners column */
    .top-stations-table th:nth-child(7),
    .top-stations-table td:nth-child(7) { width: 60px; }

    /* Station name wrapping */
    .top-stations-table td:nth-child(3) span {
        max-width: 55vw !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
    }

    /* About page cards */
    .card-grid { grid-template-columns: 1fr; }
    .card { padding: 1rem; }

    /* About section layout */
    .about-block { flex-direction: column; gap: 0.75rem; }
    .about-icon { align-self: flex-start; }

    /* Footer single column */
    .footer-content { grid-template-columns: 1fr; gap: 1.25rem; }
    .footer-bottom > div { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* ---- Small phone (420px) ---- */
@media (max-width: 420px) {
    html { font-size: 13px; }
    .header-logo-text { font-size: 1.2rem; }
    .header-tagline { font-size: 0.6rem; }
    .hero h1 { font-size: 1.3rem; }
    .hero p { font-size: 0.85rem; }
    .top-stations-header h2 { font-size: 1.1rem; }

    .top-stations-table { font-size: 0.8rem; }
    .top-stations-table th,
    .top-stations-table td { padding: 8px 6px; }
    .rank-medal { font-size: 1rem; }

    .card h3 { font-size: 0.95rem; }
    .card p { font-size: 0.82rem; }

    .dir-filters input,
    .dir-filters select {
        font-size: 16px; /* prevents iOS zoom on focus */
    }
}

/* ---- Drawer (expandable row) responsive ---- */
@media (max-width: 520px) {
    .drawer-grid { grid-template-columns: 1fr; }
}

/* ---- Print styles ---- */
@media print {
    .header, .footer, .hero-cta, .btn-play-sm,
    .mobile-menu, .mobile-menu-overlay, .mobile-menu-toggle,
    #loadingOverlay, .header-waveform { display: none !important; }
    body { background: #fff; color: #000; }
    .container { max-width: 100%; }
    .top-stations-table { border: 1px solid #ccc; }
    .top-stations-table th { background: #f0f0f0; color: #000; }
    .top-stations-table td { color: #333; border-bottom: 1px solid #eee; }
    a { color: #000; text-decoration: underline; }
}

/* ---- Reduced motion preference ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .header-waveform .bar { animation: none; }
}
