:root {
    --scrollbar-size: 7px;
    --scrollbar-track: #1e1e1e;
    --scrollbar-thumb: #4a4a4a;
    --scrollbar-thumb-hover: #5a5a5a;
    --scrollbar-thumb-border: 2px;
}

.hidden {
    display: none !important;
}

html {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

html::-webkit-scrollbar {
    width: var(--scrollbar-size);
}

html::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

html::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: var(--scrollbar-thumb-border) solid var(--scrollbar-track);
}

html::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #121212;
    color: #e0e0e0;
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

body.modal-open {
    overflow: hidden;
}

.container {
    width: 100%;
    padding: 0px;
}

#status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 10px 14px;
    background-color: #1e1e1e;
    font-size: 0.8em;
}

#user-session {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-right: auto;
}

#user-session a {
    color: #f3a0bc;
    text-decoration: none;
}

#user-session a:hover {
    color: #ffd5e4;
}

header {
    text-align: center;
    margin-bottom: 0px;
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;    
}

h1 {
    color: #ff0055;
    margin-bottom: 0px;
    margin-top: 0px;
    margin-right: 30px;
}

#category-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
}

button {
    padding: 10px 20px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #333;
    color: white;
    transition: background 0.3s;
}

button:hover {
    background-color: #444;
}

button.active {
    background-color: #ff0055;
}

main {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 20px;
    padding: 20px;
}

@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }

    #status-bar,
    header {
        justify-content: center;
    }
}

#player-section {
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

#video-container {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    border-radius: 5px;
}

#video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#track-info {
    display: grid;
    margin-top: 20px;
}

#current-track-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

#track-info h2 {
    margin: 0;
    font-size: 1.5rem;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#track-info p {
    color: #aaa;
    word-break: break-all;
}

#btn-edit-track,
.icon-button {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
}

#btn-edit-track:disabled {
    opacity: 0.45;
    cursor: default;
}

#btn-edit-track:disabled:hover {
    background-color: #333;
}

#player-controls, #action-controls {
    margin-top: 20px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

#player-controls a, #player-controls button {
    font-size: 0.8em;
}

.purchase-link {
    text-decoration: none;
    padding: 10px 20px;
    background-color: #3b5746;
    color: white;
    border-radius: 5px;
    font-weight: bold;
}

.purchase-link:hover {
    background-color: #4a6f59;
}

#playlist-section {
    background-color: #1e1e1e;
    padding: 20px;
    border-radius: 10px;
    max-height: 600px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

#playlist-section::-webkit-scrollbar {
    width: var(--scrollbar-size);
}

#playlist-section::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

#playlist-section::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 999px;
    border: var(--scrollbar-thumb-border) solid var(--scrollbar-track);
}

#playlist-section::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

#playlist-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

#playlist-section h3 {
    margin: 0;
}

#playlist-pagination {
    display: flex;
    align-items: center;
    gap: 6px;
}

#playlist-pagination button {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
}

#playlist-pagination button:disabled {
    opacity: 0.45;
    cursor: default;
}

#playlist-pagination button:disabled:hover {
    background-color: #333;
}

#playlist {
    list-style: none;
    padding: 0;
}

#playlist li {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 8px;
    border-bottom: 1px solid #333;
    transition: background 0.2s;
}

#playlist li:hover {
    background-color: #333;
}

#playlist .playlist-track-button {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
}

#playlist .playlist-track-button:hover {
    background: transparent;
    color: inherit;
}

#playlist .playlist-track-label {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.2s ease, color 0.2s ease;
}

#playlist li.listened .playlist-track-button {
    color: #a89aa3;
}

#playlist li.listened .playlist-track-label {
    opacity: 0.68;
}

#playlist .playlist-listened-indicator {
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background-color: rgba(255, 255, 255, 0.28);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

#playlist .playlist-archive-btn {
    flex: 0 0 auto;
    padding: 0px;
    background-color: transparent;
    color: #d6d6d6;
    line-height: 1;
}

#playlist .playlist-archive-btn:hover {
    background-color: #3a262d;
    color: #ffd0dd;
}

#playlist li.active {
    border-left: 4px solid #ff0055;
    background-color: #2a2a2a;
}

#playlist li.active.listened .playlist-track-button {
    color: #c9bac1;
}

#playlist li.listened .playlist-listened-indicator {
    opacity: 1;
}

#playlist li.active.listened .playlist-listened-indicator {
    background-color: rgba(255, 255, 255, 0.48);
}

#scraper-indicator {
    color: #ff0055;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

#scraper-indicator.hidden {
    display: none;
}

#scraper-last-run-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#btn-trigger-scraper {
    padding: 5px 10px;
    font-size: 1em;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ff0055;
    border-radius: 50%;
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-dialog {
    position: relative;
    width: min(100%, 520px);
    padding: 24px;
    border: 1px solid #303030;
    border-radius: 12px;
    background: #191919;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.modal-header h3 {
    margin: 0;
}

#edit-track-form {
    display: grid;
    gap: 14px;
}

.form-field {
    display: grid;
    gap: 6px;
}

.form-field span,
.form-checkbox span {
    font-size: 0.92rem;
}

.form-field input[type="text"],
.form-field input[type="url"],
.form-field input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    background: #101010;
    color: #f1f1f1;
    box-sizing: border-box;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-checkbox input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

body.auth-page,
body.admin-page {
    display: block;
}

body.admin-page main {
    display: table;
}

body.auth-page main {
    grid-template-columns: auto;
}

.flash-stack {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 2000;
    display: grid;
    gap: 10px;
    width: min(92vw, 360px);
}

.flash-message {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #363636;
    background: rgba(20, 20, 20, 0.96);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
}

.flash-success {
    border-color: #2c7048;
}

.flash-error {
    border-color: #7d334a;
}

.eyebrow {
    margin: 0 0 10px;
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #f08db0;
}

.auth-shell {
    padding: 64px 18px;
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(100%, 420px);
    padding: 28px;
    border: 1px solid #2b2b2b;
    border-radius: 18px;
    background: linear-gradient(180deg, #1f1f1f 0%, #171717 100%);
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.42);
}

.auth-copy h1 {
    margin: 0 0 10px;
}

.auth-copy p:last-child {
    margin-top: 0;
    color: #b9b9b9;
}

.auth-form {
    display: grid;
    gap: 14px;
    margin-top: 24px;
}

.auth-switch {
    margin: 20px 0 0;
    color: #bdbdbd;
}

.auth-switch a {
    color: #ff7ca8;
}

.admin-shell {
    width: min(100%, 1200px);
    margin: 0 auto;
    padding: 28px 20px 48px;
    box-sizing: border-box;
}

.admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.admin-header h1 {
    margin: 0 0 10px;
}

.admin-header p:last-child {
    margin-top: 0;
    color: #b9b9b9;
}

.admin-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 8px;
    background: #ff0055;
    color: white;
    text-decoration: none;
}

.button-link:hover {
    background: #ff2d74;
}

.button-link-secondary {
    background: #333;
}

.button-link-secondary:hover {
    background: #444;
}

.admin-panel {
    margin-top: 20px;
    padding: 22px;
    border-radius: 16px;
    background: #1b1b1b;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
}

.panel-heading h2 {
    margin: 0 0 18px;
}

.admin-form {
    display: grid;
    gap: 14px;
}

.admin-create-form {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.user-admin-list {
    display: grid;
    gap: 16px;
}

.user-admin-card {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border: 1px solid #2e2e2e;
    border-radius: 14px;
    background: #151515;
}

.user-edit-form {
    flex: 1 1 auto;
}

.user-admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    align-items: end;
}

.user-admin-meta {
    display: grid;
    gap: 6px;
    font-size: 0.86rem;
    color: #aaaaaa;
}

.user-admin-actions {
    margin-top: 6px;
}

.danger-button {
    background: #5a2536;
}

.danger-button:hover {
    background: #723146;
}

@media (max-width: 768px) {
    .admin-header,
    .user-admin-card {
        flex-direction: column;
        align-items: stretch;
    }
}
