* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Accessibility helpers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #00ff00;
    color: #000;
    padding: 2px;
    text-decoration: none;
    z-index: 100;
    font-weight: bold;
    border: none;
    outline: none;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid #00ff00;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

body {
    font-family: 'Courier New', Courier, monospace;
    background: #000;
    color: #d0d0d0;
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    margin-bottom: 20px;
    border: 1px solid #333;
    padding: 15px;
    background: #0f0f0f;
}

h1 {
    font-size: 1.2rem;
    color: #fff;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.subtitle {
    color: #666;
    font-size: 0.8rem;
}

.stats {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    border: 1px solid #333;
    padding: 10px;
    background: #0f0f0f;
}

.stat-card {
    flex: 1;
    padding: 0;
    border-right: 1px solid #222;
}

#artist-info-text {
    display: none;
}

.stat-card:last-child {
    border-right: none;
}

.stat-card h3 {
    color: #666;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    font-weight: normal;
}

.stat-value {
    font-size: 1.5rem;
    color: #fff;
    font-weight: normal;
}

.controls {
    background: #0f0f0f;
    padding: 10px;
    border: 1px solid #333;
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    align-items: center;
}

input[type="text"] {
    background: #0a0a0a;
    border: 1px solid #333;
    padding: 6px 10px;
    color: #c0c0c0;
    flex: 1;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
}

input[type="text"]:focus {
    outline: none;
    border-color: #666;
}

select {
    background: #0a0a0a;
    border: 1px solid #333;
    padding: 6px 10px;
    color: #c0c0c0;
    cursor: pointer;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85rem;
}

select:focus {
    outline: none;
    border-color: #666;
}

.table-container {
    background: #0f0f0f;
    overflow: hidden;
    border: 1px solid #333;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #0a0a0a;
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 10px;
    text-align: left;
    font-weight: normal;
    color: #666;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 1px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th:hover {
    color: #999;
}

th.sortable::after {
    content: ' ↕';
    color: #444;
}

th.sorted-asc::after {
    content: ' ↑';
    color: #888;
}

th.sorted-desc::after {
    content: ' ↓';
    color: #888;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid #222;
    font-size: 0.9rem;
}

tr:hover {
    background: #0a0a0a;
}

.album-cell {
    font-weight: normal;
    color: #fff;
    font-size: 1rem;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.artist-cell {
    color: #00ff00;
    font-style: normal;
}

.artist-cell.missing {
    color: #555;
}

.completion-header {
    width: 100px;
}

.completion-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 140px;
}

.completion-bar {
    flex: 1;
    height: 4px;
    background: #222;
    overflow: hidden;
}

.completion-fill {
    height: 100%;
    background: #666;
}

.completion-text {
    min-width: 40px;
    text-align: right;
    color: #888;
    font-weight: normal;
}

.date-cell {
    color: #666;
    white-space: nowrap;
}

.pace-cell {
    color: #888;
    white-space: nowrap;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.distance-cell {
    color: #888;
    white-space: nowrap;
    text-align: center;
    font-variant-numeric: tabular-nums;
}


.run-details {
    background: #0a0a0a;
}

.run-details.hidden {
    display: none;
}

.run-details-content {
    padding: 15px !important;
}

.run-info {
    color: #ddd;
    font-size: 0.85rem;
}

.run-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #222;
}

.run-header-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.no-run-data {
    color: #ff4444;
    font-size: 0.9rem;
}

.close-dropdown {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #888;
    width: 28px;
    height: 28px;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    line-height: 1;
    transition: all 0.2s;
    flex-shrink: 0;
}

.close-dropdown:hover {
    background: #222;
    border-color: #ff4444;
    color: #ff4444;
}

.run-header strong {
    color: #fff;
    font-size: 0.95rem;
}

.strava-link {
    color: #fff;
    text-decoration: none;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.strava-link:hover {
    color: #00ff00;
}

.strava-link:visited {
    color: #fff;
}

.strava-link:hover:visited {
    color: #00ff00;
}

.external-link {
    font-size: 0.8rem;
    opacity: 0.6;
}

.multi-album-badge {
    background: #1a1a1a;
    border: 1px solid #00ff00;
    color: #00ff00;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: normal;
}

.genre-badge {
    background: #0f0f0f;
    border: 1px solid #444;
    color: #888;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: normal;
    font-style: italic;
}

.run-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    color: #666;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    color: #00ff00;
    font-size: 0.9rem;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

.same-run-albums {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #222;
}

.same-run-label {
    color: #888;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.same-run-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.same-run-album {
    padding: 6px 10px;
    background: #111;
    border-left: 2px solid #333;
    font-size: 0.85rem;
}


.same-run-artist {
    color: #666;
    font-size: 0.75rem;
    margin-left: 8px;
}

.grouped-album {
    position: relative;
}

.group-indent {
    color: #666;
    margin-right: 6px;
    font-family: monospace;
}

.grouped-indicator {
    font-size: 1.2rem;
    line-height: 1;
}

.group-expanded {
    background: #111 !important;
}

.row-hidden {
    display: none;
}

.clickable-row:hover {
    background: #0f0f0f;
}

.same-run-album-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.same-run-album-title {
    flex: 1;
}

.same-run-star {
    color: #00ff00;
    font-size: 1rem;
    margin-left: 10px;
}

.same-run-album-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 6px;
}

.same-run-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.same-run-meta-label {
    color: #666;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.same-run-meta-value {
    color: #bbb;
    font-size: 0.8rem;
}

.count-cell {
    text-align: center;
    font-weight: normal;
    color: #bbb;
}



.clickable-border {
    transition: all 0.2s;
    position: relative;
}

.clickable-row:hover .clickable-border::after {
    content: 'view run details';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    pointer-events: none;
    opacity: 0.8;
}

/* Hide "view details" for albums with no run data */
.clickable-row.no-run-data:hover .clickable-border::after {
    display: none;
}

.star-header {
    width: 40px;
    text-align: center;
}

.star-cell {
    text-align: center;
    width: 40px;
    padding: 10px 5px;
}

.star {
    font-size: 1.2rem;
    line-height: 1;
    color: #00ff00;
}

.loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.error {
    background: #0f0f0f;
    border: 1px solid #333;
    padding: 15px;
    color: #888;
    margin: 15px 0;
}

.info-box {
    background: #0f0f0f;
    border: 1px solid #333;
    padding: 15px;
    margin-bottom: 15px;
    color: #ddd;
    font-size: 0.8rem;
}

.info-intro {
    margin-bottom: 15px;
    line-height: 1.5;
    font-size: calc(0.8rem + 2px);
}

.info-legend {
    display: flex;
    gap: 20px;
    padding: 10px 0;
    margin-bottom: 10px;
    border-top: 1px solid #222;
    border-bottom: 1px solid #222;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-symbol {
    color: #00ff00;
    font-size: 1rem;
    line-height: 1;
}

.legend-sample.colored-border {
    width: 30px;
    height: 18px;
    border-left: 3px solid #00ff00;
    background: #0a0a0a;
    border-radius: 2px;
}

.legend-text {
    color: #aaa;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-note {
    color: #888;
    font-size: 0.75rem;
    font-style: italic;
}

.info-note {
    color: #888;
    font-size: 0.75rem;
}

.year-display {
    color: #666;
}

.year-filter-label {
    color: #666;
    font-size: 0.8rem;
    margin-right: 5px;
}


@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1rem;
        letter-spacing: 1px;
        word-break: break-word;
    }

    .year-display {
        display: block;
        margin-top: 5px;
        font-size: 0.75rem;
    }

    header {
        padding: 12px;
    }

    .stats {
        flex-direction: column;
    }

    .stat-card {
        border-right: none;
        border-bottom: 1px solid #222;
        padding-bottom: 8px;
        margin-bottom: 8px;
    }

    .stat-card:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    /* Info box improvements */
    .info-box {
        padding: 12px;
    }

    .info-intro {
        font-size: 0.85rem;
        line-height: 1.6;
    }

    .info-legend {
        flex-direction: column;
        gap: 10px;
    }

    .legend-text,
    .legend-note {
        font-size: 0.7rem;
    }

    /* Stack controls on mobile */
    .controls {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .year-filter-label {
        display: none;
    }

    input[type="text"] {
        width: 100%;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Hide "view details" on mobile */
    .clickable-row:hover .clickable-border::after {
        display: none;
    }

    select {
        width: 100%;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Stack table on mobile */
    .table-container {
        border: none;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 1px solid #333;
        margin-bottom: 10px;
        background: #0f0f0f;
        position: relative;
    }

    tr.clickable-row {
        padding-top: 25px; /* Space for TAP indicator */
    }

    tr.clickable-row::after {
        content: 'TAP FOR RUN DETAILS';
        position: absolute;
        right: 10px;
        top: 10px;
        color: #666;
        font-size: 0.7rem;
        font-weight: bold;
        letter-spacing: 1px;
        opacity: 0.5;
    }

    /* Hide "TAP FOR DETAILS" for albums with no run data on mobile */
    tr.clickable-row.no-run-data::after {
        display: none;
    }

    tr.clickable-row.no-run-data {
        padding-top: 0; /* Remove extra spacing when no indicator */
    }

    tr.run-details {
        border: none;
        margin-bottom: 0;
        padding-top: 0;
    }

    td {
        border: none;
        border-bottom: 1px solid #222;
        position: relative;
        padding: 8px 10px 8px 40%;
        text-align: left !important;
        min-height: 35px;
        display: flex;
        align-items: center;
    }

    td:last-child {
        border-bottom: none;
    }

    td:before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 35%;
        padding-right: 10px;
        white-space: nowrap;
        color: #666;
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    .album-cell {
        max-width: none;
        white-space: normal;
        word-break: break-word;
        font-size: 0.95rem;
    }

    .artist-cell {
        font-size: 0.9rem;
    }

    .completion-cell {
        display: flex;
        flex-direction: row;
        gap: 8px;
        width: 100%;
    }

    .completion-bar {
        flex: 1;
        min-width: 60px;
    }

    .completion-text {
        min-width: 35px;
    }

    .date-cell,
    .distance-cell {
        font-size: 0.85rem;
    }

    .star-cell {
        width: auto;
        justify-content: flex-start;
    }

    /* Dropdown details improvements */
    .run-details-content {
        padding: 12px !important;
        padding-left: 12px !important; /* Override the 40% padding */
    }

    .run-details-content::before {
        display: none; /* Remove the data-label */
    }

    .run-info {
        width: 100%;
        max-width: 100%;
    }

    .run-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .run-header-content {
        width: 100%;
        flex-wrap: wrap;
    }

    .close-dropdown {
        position: absolute;
        right: 10px;
        top: 10px;
    }

    .run-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-label {
        font-size: 0.65rem;
    }

    .stat-value {
        font-size: 0.85rem;
    }

    .multi-album-badge,
    .genre-badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }

    .same-run-album {
        padding: 8px;
        font-size: 0.8rem;
    }

    .same-run-artist {
        font-size: 0.7rem;
    }

    .same-run-meta-item {
        min-width: 80px;
    }

    .same-run-meta-label {
        font-size: 0.6rem;
    }

    .same-run-meta-value {
        font-size: 0.75rem;
    }

    .strava-link {
        font-size: 0.85rem;
    }

    .run-info {
        font-size: 0.8rem;
    }
}
