/* Inspired by [1] and [2] */
:root {
    --color-bg: #121212;
    --color-surface: #1e1e1e;
    --color-primary: #1DB954;
    --color-text: #FFFFFF;
    --color-text-secondary: #b3b3b3;
    --color-border: #282828;
    --player-height: 90px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    padding-bottom: var(--player-height);
    /* Space for the player bar */
}

.site-footer {
    text-align: center;
    padding: 1rem;
    color: #555;
    font-size: 0.8rem;
    margin-top: 2rem;
    padding-bottom: 2rem;
    /* Extra space so it's not right up against the player bar */
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.main-nav {
    background-color: var(--color-surface);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--color-border);
}

.main-nav a {
    color: var(--color-text);
    font-size: 1.2rem;
    font-weight: bold;
    margin-right: 1.5rem;
    text-decoration: none;
}

.main-nav a:hover {
    color: var(--color-primary);
}

.content {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2.5rem;
    font-weight: bold;
}

.page-header h3 {
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--color-text-secondary);
}

/* Grid for index page */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.5rem;
}

.grid-item-link {
    text-decoration: none;
}

.grid-item {
    background-color: var(--color-surface);
    border-radius: 8px;
    overflow: hidden;
    transition: background-color 0.2s ease;
}

.grid-item:hover {
    background-color: #282828;
}

.grid-item-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: var(--color-border);
}

.grid-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: var(--color-text-secondary);
}

.grid-item-title {
    color: var(--color-text);
    font-weight: bold;
    padding: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Entity Page (Composer/Performer) */
.entity-header {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 3rem;
}



.entity-image {
    width: 250px;
    height: 250px;
    flex-shrink: 0;
    background-color: var(--color-border);
    border-radius: 50%;
    /* Circular images */
    overflow: hidden;
}

.entity-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-image-large {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8rem;
    color: var(--color-text-secondary);
}

.entity-info {
    display: flex;
    flex-direction: column;
}

.entity-info h1 {
    font-size: 3rem;
    font-weight: bold;
}

.entity-summary {
    color: var(--color-text-secondary);
    margin-top: 1rem;
    line-height: 1.6;
    /* This fix is preserved */
}

.entity-controls {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

.action-button {
    background-color: var(--color-primary);
    color: var(--color-text);
    border: none;
    border-radius: 500px;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.2s ease;
}

.action-button:hover {
    transform: scale(1.05);
    background-color: #1ed760;
}

@media (min-width: 768px) {
    .entity-header {
        display: block;
    }

    .entity-header::after {
        content: "";
        display: table;
        clear: both;
    }

    .entity-image {
        float: left;
        margin-right: 2.5rem;
        margin-bottom: 1rem;
        shape-outside: circle(50%);
    }

    .entity-info {
        display: block;
    }
}

/* Track List */
.track-list-container {
    margin-top: 2rem;
}

.track-list {
    list-style: none;
    margin-top: 1rem;
}

.track-item {
    display: flex;
    align-items: center;
    /* Vertically align items */
    padding: 0.8rem;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.track-item:hover {
    background-color: var(--color-surface);
}

.track-title {
    font-size: 1.1rem;
    font-weight: 500;
}

.track-performer {
    font-style: italic;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-top: 0.2rem;
}

.track-controls {
    display: flex;
    gap: 0.5rem;
    margin-right: 1rem;
    /* Space between buttons and text */
    min-width: 80px;
    /* Ensure buttons align nicely */
    justify-content: flex-start;
}

.minimal-btn {
    background: none;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    /* Reset padding */
}

.minimal-btn:hover {
    background-color: var(--color-text);
    color: var(--color-bg);
    border-color: var(--color-text);
}

.track-link {
    color: var(--color-text-secondary);
    font-size: 1.2rem;
    margin-left: 1rem;
}

.track-link:hover {
    color: var(--color-text);
}

/* --- NEW 2-COLUMN LAYOUT --- */
.page-grid-container {
    display: grid;
    grid-template-columns: 1fr;
    /* Default to 1 column on mobile */
    gap: 2rem;
}

@media (min-width: 900px) {
    .page-grid-container {
        /* On wide screens, 2 columns. 2 parts info, 1 part tracklist */
        grid-template-columns: 2fr 1fr;
    }

    /* Keep the "Works" title aligned with the top of the composer info */
    .track-list-container {
        margin-top: 0;
    }
}

/* --- END NEW 2-COLUMN LAYOUT --- */


/* Player Bar */
.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--player-height);
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    padding: 0 2rem;
}

.player-controls {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.5rem;
}

.player-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: color 0.2s ease, background-color 0.2s;
}

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

.player-btn.play-btn {
    font-size: 2rem;
    color: var(--color-text);
}

.player-btn.play-btn:hover {
    transform: scale(1.1);
}

.player-btn.active {
    color: var(--color-primary);
    /* For shuffle button */
}

.now-playing {
    text-align: center;
    color: var(--color-text);
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.midi-settings {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-secondary);
}

#midi-output-device {
    background-color: var(--color-border);
    color: var(--color-text);
    border: none;
    border-radius: 4px;
    padding: 0.5rem;
    max-width: 150px;
}

.midi-settings select {
    background-color: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 0.3rem;
    border-radius: 4px;
    font-size: 0.9rem;
    max-width: 200px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1rem;
}

#midi-volume {
    width: 80px;
    cursor: pointer;
}

/*... all your other styles... */

/* NEW RULE: Add a pointer cursor to clickable tracks */
.track-item-clickable {
    cursor: pointer;
}

/* Playlist Modal */
.playlist-modal {
    position: fixed;
    bottom: var(--player-height);
    right: 20px;
    width: 350px;
    max-height: 60vh;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.playlist-modal.hidden {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.playlist-header {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #282828;
    border-radius: 8px 8px 0 0;
}

.playlist-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.close-btn {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
}

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

.playlist-items {
    list-style: none;
    overflow-y: auto;
    padding: 0;
    margin: 0;
}

.playlist-track {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background-color 0.2s;
}

.playlist-track:hover {
    background-color: #2a2a2a;
}

.playlist-track.active {
    background-color: #2a2a2a;
    color: var(--color-primary);
}

.playlist-track.active .playlist-track-title {
    font-weight: bold;
}

.playlist-track-index {
    width: 25px;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.playlist-track-title {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Next Up Display */
.next-up {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-top: 4px;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: auto;
    margin-right: auto;
}

/* Test Mode */
#build-number-display {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

.test-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.test-modal.hidden {
    display: none;
}

.test-modal-content {
    background-color: var(--color-surface);
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    border: 1px solid var(--color-border);
}

.test-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.test-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.test-buttons .action-button {
    width: 100%;
    text-align: center;
}

.test-log {
    margin-top: 1.5rem;
    background-color: #121212;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 0.5rem;
    height: 150px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 0.9rem;
    color: #00ff00;
    /* Hacker green for logs */
}

.log-entry {
    margin-bottom: 2px;
}

/* Remote Control Modal */
#remote-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

#remote-modal.hidden {
    display: none;
}

#remote-modal .modal-content {
    background-color: var(--color-surface);
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    border: 1px solid var(--color-border);
    text-align: center;
    position: relative;
}

.qrcode-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    padding: 10px;
    background: white;
    /* QR code needs white background */
    border-radius: 8px;
}

.remote-link-text {
    font-size: 0.8rem;
    word-break: break-all;
    margin-top: 10px;
}

.remote-link-text a {
    color: var(--color-accent);
}

#remote-status {
    margin-top: 15px;
    font-weight: bold;
    color: #888;
}