/* =========================================
   GLOBAL REPLACERS
   ========================================= */
.label-text {
    font-size: var(--text-sm);
    font-weight: var(--font-weight-heavy);
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    color: var(--text-muted);
}
/* =========================================
   CARDS & SURFACES
   ========================================= */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}

@media screen and (max-width: 909px) {
    .card {
        padding: var(--space-md);
    }
}

/* Used for small inline alerts or user badges */
.badge-surface {
    display: inline-flex;
    align-items: center;
    background-color: var(--bg-surface-raised);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-default);
    font-size: var(--text-md);
}

    .badge-surface strong {
        /*margin-left: var(--space-tn);*/
        color: var(--brand-secondary);
    }

.box-surface {
    display: inline-flex;
    align-items: center;
    background-color: var(--bg-surface-raised);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-btn);
    border: 1px solid var(--border-default);
    font-size: var(--text-md);
}

    .box-surface strong {
        /*margin-left: var(--space-tn);*/
        color: var(--brand-secondary);
    }

.status-badge {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 var(--space-md);
    border-radius: var(--radius-pill);
    border: 1px solid; /* color set by modifier */
    font-size: var(--text-base);
}

.status-badge--success {
    border-color: var(--status-success);
    background-color: var(--status-success-bg);
    color: var(--brand-dark);
}

.status-badge--warning {
    border-color: var(--status-warning);
    background-color: var(--status-warning-bg);
    color: var(--brand-dark);
}

.status-badge__text {
    margin-left: var(--space-sm);
    font-size: var(--text-base);
}

.status-badge__text--heavy {
    font-weight: var(--font-weight-heavy);
}

/* =========================================
   INSTRUCTION PANELS
   ========================================= */
.instruction-panel {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    padding: var(--space-md) var(--space-lg);
    margin-bottom: var(--space-xl);
    box-shadow: var(--shadow-sm);
}

.instruction-header {
    display: flex;
    align-items: center;
    margin-bottom: var(--space-sm);
}

    .instruction-header h2 {
        font-size: var(--text-xl);
        font-weight: var(--font-weight-heavy);
        color: var(--text-main);
        margin: 0;
    }

.instruction-icon {
    font-size: var(--text-2xl);
    margin-right: var(--space-sm);
    /* Maps to your text-main or secondary depending on how you want it to pop */
    color: var(--text-main);
}

.instruction-list {
    margin: 0;
    padding-left: var(--space-xl);
    color: var(--text-muted);
    font-size: var(--text-base);
    line-height: 1.6;
}

    .instruction-list li {
        margin-bottom: var(--space-xs);
    }

    .instruction-list a {
        color: var(--brand-secondary);
        text-decoration: none;
        font-weight: var(--font-weight-medium);
        transition: opacity 0.2s ease;
    }

        .instruction-list a:hover {
            text-decoration: underline;
            opacity: 0.8;
        }

    .instruction-list strong {
        color: var(--text-main);
    }

/* Highlight for current step in the Match-Fix tool */
.current-nav {
    background-color: var(--bg-surface-raised) !important;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    transition: all 0.3s ease;
}
/* =========================================
   BUTTONS
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-btn);
    font-weight: var(--font-weight-heavy);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-size: var(--text-lg);
}

.btn-lg {
    padding: var(--space-md) var(--space-xl);
    font-size: var(--text-xl);
    border-radius: 8px; /* Slightly rounder for big calls to action */
}

/* Vibrant green button */
.btn-primary {
    background-color: var(--primary-base);
    color: var(--text-on-primary);
}

    .btn-primary:hover {
        background-color: var(--primary-hover);
        transform: translateY(-2px); /* Subtle lift */
    }

/* Subtle, dark-mode friendly button */
.btn-surface {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-default);
}

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

/* Subtle, dark-mode friendly button */
.btn-surface-raised {
    background-color: var(--bg-surface-raised);
    color: var(--text-main);
    border-color: var(--border-default);
}

    .btn-surface-raised:hover {
        background-color: var(--border-hover);
        border-color: var(--text-muted);
    }

.btn-compact {
    padding: var(--space-tn) var(--space-md);
    font-size: var(--text-sm);
    height: 28px;
}

@media screen and (max-width: 909px) {
    .btn-compact {
        padding: var(--space-xs) var(--space-sm);
    }

}

/* =========================================
   CUSTOM NATIVE SELECT
   ========================================= */
select.btn-surface {
    appearance: none;
    -webkit-appearance: none;
    /* Custom SVG arrow matching your text-muted color */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%238f9e95' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px !important; /* Make room for the arrow */
    cursor: pointer;
}

.filter-group {
    margin-bottom: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-header {
    margin-bottom: var(--space-tn);
}

/*.filter-label {
    font-size: var(--text-sm);
    font-weight: var(--font-weight-heavy);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05rem;
}*/

.multi-input-box {
    border: 1px solid var(--border-default);
    border-radius: var(--radius-btn);
    padding: 4px var(--space-sm);
    background: var(--bg-base);
    gap: 6px;
    position: relative;
    transition: border-color 0.2s ease;
    min-height: 36px;
}

    .multi-input-box:focus-within {
        border-color: var(--border-focus);
    }

    .multi-input-box input {
        flex-grow: 1;
        min-width: 120px;
        background: transparent;
        border: none;
        outline: none;
        color: var(--text-main);
        font-size: var(--text-base);
        padding: 2px 0;
    }

/* The Selected Item "Chip" */
.filter-chip {
    display: inline-flex;
    align-items: center;
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-subtle);
    padding: 2px 8px;
    border-radius: var(--radius-badge);
    font-size: var(--text-sm);
    color: var(--text-main);
}

.filter-chip-remove {
    margin-left: 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: var(--text-base);
}

    .filter-chip-remove:hover {
        color: var(--status-error);
    }

/* Autocomplete Dropdown */
.autocomplete-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    z-index: 1070;
    max-height: 200px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow-md);
}

.autocomplete-item {
    padding: 8px var(--space-md);
    font-size: var(--text-base);
    cursor: pointer;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-subtle);
}

    .autocomplete-item:last-child {
        border-bottom: none;
    }

    .autocomplete-item:hover,
    .autocomplete-item.highlight {
        background: var(--overlay-light);
        color: var(--brand-white);
    }

/* AND/OR Logic Toggles */
.filter-logic-toggle {
    display: flex;
    gap: var(--space-md);
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-top: 6px;
    padding-left: 4px;
}

    .filter-logic-toggle label {
        display: flex;
        align-items: center;
        gap: 4px;
        cursor: pointer;
    }

    .filter-logic-toggle input[type="radio"],
    .filter-logic-toggle input[type="checkbox"] {
        accent-color: var(--brand-secondary); /* Colors the native checkbox/radio */
        cursor: pointer;
    }

/* =========================================
   BADGES, PILLS, & MORE, OH MY!
   ========================================= */
/* --- Badges & Tags --- */
.badge-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-pill);

    background-color: var(--bg-base);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    flex-shrink: 0;
}

.badge-box {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-badge);

    background-color: var(--bg-base);
    color: var(--text-main);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-heavy);
    white-space: nowrap;
    flex-shrink: 0;
}

/* =========================================
   TEXT
   ========================================= */
.simple-credit {
    font-size: var(--text-sm);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.inline-bullet {
    color: var(--text-muted);
    opacity: 0.5;
    font-size: var(--text-sm);
    flex-shrink: 0;
}

.inline-flag {
    font-size: var(--text-base);
    flex-shrink: 0;
}

/* Flag Hover Effect */
.country-link .fi,
.country-link .custom-flag {
    transition: transform 0.2s ease, filter 0.2s ease;
    display: inline-block; /* Required for transform to work correctly */
}

.country-link:hover .fi,
.country-link:hover .custom-flag {
    transform: scale(1.2);
    filter: brightness(1.1);
    z-index: 10; /* Ensures the scaled flag sits above others nearby */
}

/* =========================================
   ICONS
   ========================================= */
.app-avatar-img {
    object-fit: cover;
    flex-shrink: 0;
    background-color: var(--bg-surface-raised);
}

/* The Text Avatar (Artists - Circle) */
.app-avatar-text {
    font-weight: var(--font-weight-heavy);
    flex-shrink: 0;
}

.avatar-base {
    background-color: var(--bg-base);
    color: var(--text-muted);
}

.avatar-raised {
    background-color: var(--bg-surface-raised);
    color: var(--text-muted);
}

.avatar-primary {
    background-color: var(--primary-base);
    color: var(--text-on-primary);
}

.avatar-secondary {
    background-color: var(--secondary-base);
    color: var(--text-on-primary);
}

/* Avatar Size Modifiers */
.avatar-sm {
    width: 32px;
    height: 32px;
}

.avatar-md {
    width: 64px;
    height: 64px;
}

.avatar-lg {
    width: 128px;
    height: 128px;
}

.avatar-xl {
    width: 80px;
    height: 80px;
}

.avatar-text-xl {
    font-size: 2rem;
}

/* =========================================
   COMPLEX DROPDOWN PANEL (Click-to-open)
   ========================================= */
.dropdown-panel {
    position: absolute;
    top: calc(100% + var(--space-tn)); /* Positions it just below the button */
    right: 0;
    z-index: 1060;
    display: none; /* Hidden by default */
    min-width: 250px;
    padding: var(--space-md);
    background-color: var(--bg-surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-lg);
    cursor: default; /* Prevents text cursor issues */
}

    /* Toggled via JavaScript */
    .dropdown-panel.show {
        display: block;
    }

/* --- Preset Grid --- */
.preset-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-tn);
    margin-bottom: var(--space-sm);
}

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

    /* Vertical divider between the two columns */
    .preset-col:nth-child(2) {
        border-left: 1px solid var(--border-subtle);
        padding-left: var(--space-sm);
    }

.dropdown-item-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: var(--space-tn) var(--space-tn);
    text-align: left;
    font-size: var(--text-base);
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-badge);
    cursor: pointer;
    transition: all 0.2s ease;
}

    .dropdown-item-btn:hover {
        background-color: var(--overlay-light);
        color: var(--text-main);
    }

/* --- Custom Range Inputs --- */
.form-group-inline {
    margin-bottom: var(--space-sm);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-btn);
    overflow: hidden;
    background: var(--bg-base);
    transition: border-color 0.2s ease;
}

    .form-group-inline:focus-within {
        border-color: var(--border-focus);
    }

    .form-group-inline label {
        padding: 6px var(--space-sm);
        background-color: var(--bg-surface);
        color: var(--text-muted);
        font-size: var(--text-sm);
        font-weight: var(--font-weight-heavy);
        border-right: 1px solid var(--border-default);
        width: 60px; /* Fixed width so both inputs align perfectly */
        text-align: center;
    }

.form-control-sm {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 4px var(--space-sm);
    font-size: var(--text-base);
    outline: none;
    color-scheme: dark; /* Tells the browser to render a dark-mode calendar icon! */
}

/* Revert calendar icon color in light mode */
.light-theme .form-control-sm {
    color-scheme: light;
}

/* =========================================
   DASHBOARD GRID SYSTEM
   ========================================= */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md); /* Spacing between rows */
    width: 100%;
}

/* Base grid row that stacks on mobile */
.grid-row {
    display: grid;
    gap: var(--space-md);
    width: 100%;
}

/* Specific Row Layouts for Desktop (>910px) */
@media screen and (min-width: 910px) {
    /* 3 equal columns (for Artists, Albums, Tracks) */
    .grid-cols-3 {
        grid-template-columns: repeat(3, 1fr);
    }

    /* 2 columns, left is wider (e.g., Progress Bar left, Toolbench right) */
    .grid-cols-2-wide {
        grid-template-columns: 2fr 1fr;
    }

    .grid-cols-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Default mobile behavior: stack everything as 1 column */
@media screen and (max-width: 909px) {
    .grid-cols-3,
    .grid-cols-2-wide,
    .grid-cols-2 {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   USER PROFILE LAYOUT
   ========================================= */
.profile-card {
    flex-direction: row;
    align-items: center;
    gap: var(--space-lg);
}

.profile-info {
    flex-grow: 1;
    min-width: 0; /* Prevents text overflow blowouts on mobile */
}

.profile-username {
    margin-bottom: 0;
    font-weight: var(--font-weight-heavy);
}

.profile-stats-container {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-tn);
    font-size: var(--text-base);
}

.profile-stat-group {
    gap: var(--space-md);
    white-space: nowrap; /* Forces items INSIDE the group to stay on the same line */
}

/* Mobile specific profile adjustments */
@media screen and (max-width: 768px) {
    .profile-card {
        flex-direction: column; /* Stacks the avatar on top */
        align-items: flex-start; /* Keeps everything left-aligned */
        gap: var(--space-md); /* Slightly tighter spacing on mobile */
    }
}

/* =========================================
   CAROUSEL CONTAINER
   ========================================= */
/* A horizontal scrolling container that hides the scrollbar */
.carousel-horizontal {
    display: flex;
    gap: var(--space-md);
    overflow-x: auto;
    padding-bottom: var(--space-sm); /* Room for focus rings/shadows */
    scrollbar-width: none; /* Firefox */
    -webkit-overflow-scrolling: touch; /* Smooth mobile scrolling */
}

    .carousel-horizontal::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

/* The items inside the carousel */
.carousel-item {
    flex: 0 0 auto; /* Don't shrink, determine width naturally or by set width */
    width: 250px; /* Standard width for a track card */
}

/* Carousel Wrapper needed to position buttons relative to the scroll area */
.carousel-wrapper {
    position: relative;
    width: 100%;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-default);
    color: var(--text-main);
    padding: var(--space-sm);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.2s ease;
}

    .nav-btn:hover {
        background: var(--bg-surface);
        border-color: var(--brand-secondary);
        color: var(--brand-secondary);
    }

    .nav-btn:disabled {
        opacity: 0.4;
        cursor: default;
        pointer-events: none;
        background: var(--bg-surface);
        border-color: var(--border-subtle);
    }

.nav-btn-left {
    left: -20px;
}

.nav-btn-right {
    right: -20px;
}

/* Only show buttons on desktop */
@media screen and (max-width: 910px) {
    .nav-btn {
        display: none;
    }
}

/* New "See All" Card */
.see-all-card {
    min-width: 150px;
    background: var(--bg-surface-raised);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    text-decoration: none;
    color: var(--text-main);
    transition: background 0.2s ease;
    font-weight: var(--font-weight-heavy);
}

    .see-all-card:hover {
        background: var(--bg-base);
        color: var(--brand-secondary);
    }

/* =========================================
   PROGRESS BARS
   ========================================= */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--bg-base);
    border-radius: var(--radius-pill);
    overflow: hidden;
    display: flex
}

    .progress-bar-container.progress-lg {
        height: 12px;
    }

    .progress-bar-container.progress-sm {
        height: 4px;
    }

.progress-bar-fill {
    height: 100%;
    background-color: var(--brand-secondary); /* Default Green */
    transition: width 0.4s ease;
}

/* Progress Bar Color Modifiers */
.fill-info {
    background-color: var(--status-info);
}

.fill-warning {
    background-color: var(--status-warning);
}

.fill-success {
    background-color: var(--status-success);
}

/* Progress Bar Stripe Overlay */
.progress-striped {
    background-image: linear-gradient( 45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent );
    background-size: 1rem 1rem;
}

/* Progress Bar Animation */
.progress-animated {
    animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
    from {
        background-position: 1rem 0;
    }

    to {
        background-position: 0 0;
    }
}

/* =========================================
   MAIN PROGRESS LAYOUT (Row 5)
   ========================================= */
.main-progress-layout {
    gap: var(--space-lg);
}

.main-progress-bar-wrapper {
    flex-grow: 1;
    min-width: 250px; /* Forces wrap on very small screens */
}

.main-progress-action {
    flex-shrink: 0;
}

@media screen and (max-width: 768px) {
    .main-progress-action {
        width: 100%; /* Button takes full width on mobile */
    }

        .main-progress-action .btn {
            width: 100%;
        }
}

/* =========================================
   TOOL CARDS GRID (Row 6)
   ========================================= */
/* Auto-fills available space with cards minimum 280px wide */
.grid-auto-fill {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-md);
    width: 100%;
}

.tool-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    transition: all 0.2s ease;
    text-align: left; /* Resets button text alignment */
    color: var(--text-main);
    text-decoration: none;
    font-family: inherit;
}

    /*.tool-card:hover {
        background-color: var(--bg-surface-raised);
        border-color: var(--border-focus);
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }*/

/* ONLY apply hover/click states if the card is an actual link or button */
a.tool-card, button.tool-card {
    cursor: pointer;
    transition: all 0.2s ease;
}

    a.tool-card:hover, button.tool-card:hover {
        background-color: var(--bg-surface-raised);
        border-color: var(--border-focus);
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

.tool-card-header {
    gap: var(--space-sm);
    font-weight: var(--font-weight-heavy);
    font-size: var(--text-mxl);
}

.tool-card-icon {
    font-size: var(--text-2xl);
    color: var(--brand-secondary);
}

.tool-card-blurb {
    font-size: var(--text-base);
    color: var(--text-muted);
    flex-grow: 1; /* Pushes the mini progress bar to the absolute bottom */
    margin-bottom: var(--space-sm);
}

.tool-card-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.resync-action-row {
    position: relative; /* Anchors the absolute positioned warning text */
    width: 100%;
    margin-top: auto;
    padding-top: 1px;
}

.resync-warning {
    position: absolute;
    top: -10px; /* Floats perfectly in the 16px gap between the blurb and the controls */
    left: 0;
    font-size: 0.55rem;
    color: var(--status-error);
    white-space: nowrap; /* Forces it to stay on one clean line */
    pointer-events: none; /* Ensures it doesn't accidentally block clicks */
}

.wipe-toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-sm);
    cursor: pointer;
    color: var(--text-muted);
}

    .wipe-toggle-label input {
        accent-color: var(--status-error);
        cursor: pointer;
    }

.resync-btn {
    padding: 4px var(--space-md);
    font-size: var(--text-base);
}

/* =========================================
   SEMANTIC TEXT & LINK COMPONENTS
   ========================================= */
/* Artist Credit Grouping */
.credit-wrapper {
    display: inline-flex;
    align-items: center;
    min-width: 0px;
    max-width: 100%;
}

.artist-link {
    display: inline-block;
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    color: var(--text-main);
    transition: color 0.2s ease;
}

    .artist-link:hover {
        color: var(--brand-secondary);
        text-decoration: underline;
    }

.credit-join {
    color: var(--text-muted);
    opacity: 0.75;
}

/* Flag Wrappers */
.flag-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    margin-right: var(--space-tn);
    line-height: 1;
}

.flag-custom {
    border-radius: 0px; /* switched to 0px from 2px to avoid white corners on some flags */
    box-shadow: var(--shadow-sm);
    /* Forces the flag to ignore text baselines so it aligns perfectly centered */
    display: block !important;
    line-height: 1;
}

.custom-flag {
    width: auto;
    display: inline-block;
    vertical-align: middle;
    object-fit: contain;
}


/* =========================================
   LOADING STATES & ANIMATIONS
   ========================================= */
/* Custom inline spinner */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-default);
    border-top-color: var(--brand-secondary);
    border-radius: 50%;
    animation: custom-spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

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

.spinner-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

/* Shimmering Skeleton Loader */
.skeleton-box {
    background: linear-gradient(90deg, var(--bg-base) 25%, var(--bg-surface) 50%, var(--bg-base) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: var(--radius-badge);
}

@keyframes shimmer {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

/* =========================================
   SCROBBLE CARDS (Recent Plays & Lists)
   ========================================= */
.scrobble-card {
    padding: var(--space-sm);
    flex-direction: row;
    gap: var(--space-md);
    min-width: 280px;
    max-width: 320px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

    .scrobble-card:hover {
        /*transform: translateY(-2px);*/ /* didn't like the movement as it made it hard to click the links */
        box-shadow: var(--shadow-md);
        background: var(--bg-base);
        border-color: var(--border-hover);
    }

/* Art & Image Placeholders */
.scrobble-art-link {
    flex-shrink: 0;
    display: block;
    transition: opacity 0.2s ease;
}

    .scrobble-art-link:hover {
        opacity: 0.8;
    }

.scrobble-art,
.scrobble-art-placeholder {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-badge);
    flex-shrink: 0;
}

.scrobble-art {
    object-fit: cover;
    background-color: var(--bg-surface-raised);
}

/*.scrobble-art-placeholder {
    background-color: var(--bg-base);
    display: flex;
    align-items: center;
    justify-content: center;
}

    .scrobble-art-placeholder i {
        font-size: var(--text-3xl);
        color: var(--text-muted);
    }*/

/* Typography & Layout */
.scrobble-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    gap: 2px;
}

.scrobble-track-title {
    font-weight: var(--font-weight-heavy);
    font-size: var(--text-lg);
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    transition: color 0.2s ease;
}

/* Only apply hover colors if it's actually an <a> tag */
a.scrobble-track-title:hover {
    color: var(--brand-secondary);
}

.scrobble-artist-info {
    font-size: var(--text-base);
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.scrobble-timestamp {
    font-size: var(--text-sm);
    color: var(--text-muted);
    opacity: 0.8;
    margin-top: 2px;
}

/* Status Icons */
.icon-unmapped {
    color: var(--status-warning);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-size: var(--text-sm);
    margin-right: 4px;
}

/* --- Mobile View for Scrobble Cards --- */
@media screen and (max-width: 909px) {
    .scrobble-card {
        flex-direction: column; /* Switch from horizontal to vertical stack */
        align-items: flex-start; /* Left-align text */
        min-width: 120px; /* Slightly slimmer cards for mobile screens */
        max-width: 160px;
        padding: var(--space-md-sm); /* Even out padding for the new shape */
    }

    /* Force the link wrapper to allow the image to grow */
    .scrobble-art-link {
        width: 100%;
    }

    /* Grow the art to the full width of the card and keep it a perfect square */
    .scrobble-art,
    .scrobble-art-placeholder {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1;
        border-radius: var(--radius-card); /* Give the big art slightly softer corners */
        margin-bottom: var(--space-tn);
    }
}

/* =========================================
   CHART WIDGETS (Flexbox & Last.fm Style Bars)
   ========================================= */
.chart-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.chart-list {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.chart-row {
    display: flex;
    align-items: center;
    /* TIGHTENED: Reduced top/bottom padding to var(--space-tn) */
    padding: var(--space-tn) 0;
    color: var(--text-main);
    transition: background-color 0.2s ease;
}

    /*.chart-row:hover {
        background-color: var(--overlay-light);
    }*/

.chart-rank {
    width: var(--space-xl);
    text-align: center;
    margin-right: var(--space-md);
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-weight: var(--font-weight-heavy);
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .chart-rank {
        width: calc(var(--space-xl) * 0.75);
        margin-right: 10px;
        font-size: var(--text-xs);
    }
}

.chart-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-btn);
    margin-right: var(--space-md);
    flex-shrink: 0;
    background-color: var(--bg-surface-primary);
    overflow: hidden;
    color: var(--text-muted);
    box-shadow: var(--shadow-sm);
}

    .chart-icon-wrap.is-circle {
        border-radius: 50%;
    }

    .chart-icon-wrap img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.chart-details {
    flex-grow: 1;
    min-width: 0;
    justify-content: center;
    gap: 2px; 
}

a.chart-title {
    font-size: var(--text-md);
    font-weight: var(--font-weight-heavy);
    color: var(--text-main);
    text-decoration: none;
    transition: color 0.2s ease;
    line-height: 1.2;
}

    a.chart-title:hover {
        color: var(--brand-secondary);
    }

.chart-subtitle {
    gap: var(--space-xs);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* Disable subtitle link clicks on mobile to prevent accidental taps */
@media screen and (max-width: 910px) {
    .chart-subtitle a {
        pointer-events: none;
        text-decoration: none;
    }
}

.chart-empty {
    padding: var(--space-xl);
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-base);
    height: 450px;
}

/* --- Detached Row Components --- */
.chart-header-flex {
    align-items: flex-start;
    gap: var(--space-sm);
}

.chart-text-stack {
    /* Allows the .text-truncate utility on children to work */
    min-width: 0;
    flex-grow: 1;
}

.chart-bar-link {
    display: block; /* Let the wrapper dictate the width */
    text-decoration: none;
    transition: opacity 0.2s ease;
    width: 100%;
}

    .chart-bar-link:hover {
        opacity: 0.8;
    }

.chart-bar-wrapper {
    position: relative; /* Anchors the absolute positioned stat text */
    width: 100%;
    height: 18px; /* Thickened slightly to hold the stat */
    background-color: var(--bg-surface-raised);
    border-radius: var(--radius-badge);
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background-color: var(--primary-base);
    border-radius: var(--radius-badge);
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.chart-stat {
    position: absolute;
    right: var(--space-tn);
    top: 50%;
    transform: translateY(-50%);
    font-size: var(--text-sm); 
    font-weight: var(--font-weight-heavy);
    color: var(--brand-white);
    /* Shadow guarantees it can be read over both the green bar and dark background */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    pointer-events: none; /* Lets clicks pass through to the parent link */
    z-index: 2;
}

/* --- Triple Dot Menu Button --- */
.btn-action-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 2px 6px;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: all 0.2s ease;
}

    .btn-action-icon:hover {
        color: var(--text-main);
        background-color: var(--bg-surface-raised);
    }

/* Adjusting the flag sizes for the subtitle */
/*.chart-subtitle .inline-flag {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}*/

/* =========================================
   CHART WIDGET WRAPPERS
   ========================================= */
.chart-box-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--space-sm);
}

    .chart-box-header h3 {
        font-size: var(--text-xl);
        margin-bottom: 0;
    }

.chart-box-inner {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 250px;
    background: var(--bg-base);
    border-radius: var(--radius-btn);
    padding: var(--space-sm);
}

@media (max-width: 768px) {
    .chart-box-inner {
        padding: var(--space-xs);
    }
}

.chart-btn-bottom {
    width: 100%;
    margin-top: var(--space-md);
}

/* =========================================
   FORM ELEMENTS
   ========================================= */
.create-form-card {
    padding: var(--space-xl); /* Overrides the default card padding for a roomier form */
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.form-label {
    font-size: var(--text-base);
    font-weight: var(--font-weight-heavy);
    color: var(--text-main);
}

.form-input, .form-textarea {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-btn);
    background-color: var(--bg-base);
    color: var(--text-main);
    transition: all 0.2s ease-in-out;
    font-family: inherit;
    font-size: var(--text-base);
}

    .form-input:focus, .form-textarea:focus {
        background-color: var(--bg-surface-raised);
        box-shadow: var(--shadow-sm);
        border-color: var(--border-focus);
        outline: none;
    }

/* =========================================
   ACCORDION (Expandable Panels)
   ========================================= */
.accordion {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.accordion-item {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

    .accordion-item:focus-within {
        border-color: var(--border-focus);
        box-shadow: var(--shadow-sm);
    }

.accordion-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: var(--text-md);
    font-weight: var(--font-weight-heavy);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

    .accordion-header:hover {
        background-color: var(--bg-surface-raised);
    }

.accordion-icon {
    color: var(--text-muted);
    font-size: var(--text-lg);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Rotates the chevron when active */
.accordion-header.active .accordion-icon {
    transform: rotate(180deg);
}

.accordion-collapse {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-body {
    /*padding: 0 var(--space-md) var(--space-md) var(--space-md);*/
    padding: var(--space-md);
    /* The Recessed Well effect */
    background-color: var(--bg-base);
    border-top: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: var(--text-base);
    line-height: 1.6;
}

    /* Inherited Link Styles for text blocks inside the accordion */
    .accordion-body a {
        color: var(--brand-secondary);
        text-decoration: none;
        font-weight: var(--font-weight-medium);
        transition: opacity 0.2s ease;
    }

        .accordion-body a:hover {
            text-decoration: underline;
            opacity: 0.8;
        }

    .accordion-body strong {
        color: var(--text-main);
    }

    .accordion-body ul {
        margin-bottom: var(--space-md);
        padding-left: var(--space-lg);
    }

    .accordion-body li {
        margin-bottom: var(--space-sm);
        padding-left: var(--space-xs);
    }

    .accordion-body ul ul {
        margin-top: var(--space-sm);
        margin-bottom: var(--space-sm);
    }

/* =========================================
   GUILD CARD COMPONENT
   ========================================= */
.guild-card-wrap {
    padding: 0;
    overflow: hidden;
    gap: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

    .guild-card-wrap:hover {
        transform: translateY(-2px);
        box-shadow: var(--shadow-md);
    }

.guild-card-img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    flex-shrink: 0;
}

.guild-card-img-placeholder {
    background-color: var(--bg-surface);
}

.guild-card-img-icon {
    font-size: 3rem;
    opacity: 0.25;
}

.guild-card-body {
    padding: var(--space-md);
    gap: var(--space-sm);
    flex-grow: 1;
    background-color: var(--bg-surface-raised);
}

.guild-card-header {
    align-items: flex-start;
}

.guild-title-wrapper {
    max-width: 75%;
}

.guild-card-title-link {
    text-decoration: none;
    color: var(--text-main);
    font-size: var(--text-2xl);
    font-weight: var(--font-weight-heavy);
}

.guild-card-desc {
    margin: 0;
    min-height: 40px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.guild-card-stats {
    margin-top: auto;
}

.guild-card-btn {
    margin-top: var(--space-sm);
    width: 100%;
}

/* Shared Guild Badges */
.badge-banned {
    color: var(--status-error);
    border-color: var(--status-error);
}

.badge-member {
    height: 24px;
    padding: 0 var(--space-sm);
    font-size: var(--text-xs);
}

/* =========================================
   DATA TABLES
   ========================================= */
.table-card-wrap {
    padding: 0;
    /*overflow: visible;*/ /* Prevents dropdowns inside tables from getting clipped */
    overflow: hidden; /* Prevents clipping of curved corners */
    margin-bottom: var(--space-xl);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.app-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

    .app-table th {
        padding: var(--space-md);
        color: var(--text-muted);
        font-size: var(--text-sm);
        text-transform: uppercase;
        letter-spacing: 0.05rem;
        font-weight: var(--font-weight-heavy);
        border-bottom: 2px solid var(--border-default);
        background-color: var(--bg-surface-raised);
        white-space: nowrap;
    }

    .app-table td {
        padding: var(--space-md);
        border-bottom: 1px solid var(--border-subtle);
        color: var(--text-main);
        font-size: var(--text-md);
        vertical-align: middle;
    }

        /* Outer padding for the table to breathe inside the card */
        .app-table th:first-child,
        .app-table td:first-child {
            padding-left: var(--space-lg);
        }

        .app-table th:last-child,
        .app-table td:last-child {
            padding-right: var(--space-lg);
        }

    .app-table tbody tr {
        transition: background-color 0.2s ease;
    }

        .app-table tbody tr:hover {
            background-color: var(--overlay-light);
        }

        .app-table tbody tr:last-child td {
            border-bottom: none;
        }

/* Table JS States */
.table-empty-state {
    padding: var(--space-xl) 0;
    height: 150px;
}

.table-loading-state {
    padding: var(--space-xl) 0;
    gap: var(--space-sm);
}

/* --- Mobile View for Data Tables --- */
@media screen and (max-width: 909px) {
    .app-table th,
    .app-table td {
        /* Compress top/bottom padding slightly, and heavily compress left/right */
        padding: var(--space-sm) var(--space-tn);
        font-size: var(--text-sm);
    }

        /* Bring the outer breathing room way in */
        .app-table th:first-child,
        .app-table td:first-child {
            padding-left: var(--space-sm);
        }

        .app-table th:last-child,
        .app-table td:last-child {
            padding-right: var(--space-sm);
        }

    /* Ensure action buttons don't blow out the row height */
    .app-table .btn-compact {
        padding: var(--space-tn) var(--space-sm);
        font-size: var(--text-xs);
        height: 24px;
    }
}

/* =========================================
   PAGINATION WIDGET
   ========================================= */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-top: 1px solid var(--border-subtle);
    background-color: var(--bg-base);
}

.pagination-disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Hide native spin buttons on number inputs */
.no-spinners::-webkit-outer-spin-button,
.no-spinners::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.no-spinners {
    -moz-appearance: textfield; /* Firefox */
}

/* Specific sizing for the jump-to-page input */
.pagination-jump-input {
    width: 60px;
    height: 28px;
    padding: 2px 8px;
    text-align: center;
    border-radius: var(--radius-btn);
}

.pagination-label {
    padding: 0 var(--space-sm);
    white-space: nowrap;
}

.pagination-jump-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-left: var(--space-sm);
}

/* Update pagination container for mobile responsiveness */
@media screen and (max-width: 600px) {
    .pagination-container {
        gap: var(--space-tn); /* Tighter gap on mobile */
        padding: var(--space-sm);
    }

    .pagination-label {
        padding: 0 var(--space-tn);
    }
    .pagination-jump-wrapper {
        gap: var(--space-tn);
    }
}

/* =========================================
   PAGE LAYOUT WRAPPERS (Tools & Admin)
   ========================================= */
.page-container {
    padding: var(--space-xl) 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.page-title-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.page-title {
    font-size: var(--text-3xl);
    font-weight: var(--font-weight-heavy);
    margin: 0;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: var(--text-md);
    margin: 0;
}

.header-controls {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.badge-large {
    height: 38px; /* Matches standard button/dropdown heights */
}

.badge-medium {
    height: 24px; 
}

.filter-group-header {
    display: flex;
    flex-direction: column;
    text-align: center;
}

    .filter-group-header .filter-label {
        margin-bottom: var(--space-tn);
    }

.accordion-spacing {
    margin-bottom: var(--space-xl);
}

/* Notification Container */
.notification-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Form Divider */
.form-divider {
    margin: var(--space-md) 0 var(--space-sm) 0;
    border-top: 1px solid var(--border-subtle);
}

/* Selection State for the List Items */
.search-list-item.active-item {
    background-color: var(--bg-surface-raised);
    border-left: 4px solid var(--brand-secondary);
}

.bypass-icon-wrapper {
    width: 48px;
    height: 48px;
    background-color: var(--bg-base);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-btn);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.header-step-1 {
    background-color: var(--brand-dark);
    color: var(--text-main);
    border-bottom: 2px solid var(--border-subtle);
}

.header-step-2 {
    background-color: var(--brand-primary);
    color: var(--text-on-primary);
    border-bottom: 2px solid rgba(0, 0, 0, 0.2);
}

.border-left-step-1 {
    border-left: 4px solid var(--brand-primary);
}

.border-left-step-2 {
    border-left: 4px solid var(--brand-secondary);
}

.border-left-step-3 {
    border-left: 4px solid var(--chart-3);
}

.max-h-80vh {
    max-height: 80vh;
    overflow-y: auto;
    scrollbar-width: thin;
}

.sticky-thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--bg-surface-raised);
    box-shadow: 0 2px 4px -2px rgba(0,0,0,0.2);
}

.custom-checkbox {
    accent-color: var(--brand-secondary);
    cursor: pointer;
    width: 18px;
    height: 18px;
}

    .custom-checkbox:disabled {
        cursor: not-allowed;
    }

/* =========================================
   UTILITIES (Additions)
   ========================================= */
.border-primary {
    border-color: var(--brand-primary) !important;
}

.border-secondary {
    border-color: var(--brand-secondary) !important;
}

.cursor-default {
    cursor: default !important;
}

/* =========================================
   TABS NAVIGATION
   ========================================= */
.nav-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-default);
    gap: var(--space-md);
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
    /* --- The Dynamic Scrolling Shadows Trick --- */
    background-image:
    /* 1 & 2: Solid background covers that scroll WITH the content */
    linear-gradient(var(--bg-surface), var(--bg-surface)), linear-gradient(var(--bg-surface), var(--bg-surface)),
    /* 3 & 4: The gradient shadows fixed to the edges */
    linear-gradient(to right, rgba(0,0,0,0.4), transparent), linear-gradient(to left, rgba(0,0,0,0.4), transparent);
    background-repeat: no-repeat;
    /* Position the covers and shadows at the left and right edges */
    background-position: left center, right center, left center, right center;
    /* Make the covers slightly wider (25px) than the shadows (12px) to ensure complete hiding */
    background-size: 25px 100%, 25px 100%, 12px 100%, 12px 100%;
    /* The Magic: Covers use 'local' (they scroll), Shadows use 'scroll' (they stay fixed) */
    background-attachment: local, local, scroll, scroll;
}

    .nav-tabs::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

/* Tone down the shadow intensity for light mode */
.light-theme .nav-tabs {
    background-image: linear-gradient(var(--bg-surface), var(--bg-surface)), linear-gradient(var(--bg-surface), var(--bg-surface)), linear-gradient(to right, rgba(0,0,0,0.08), transparent), linear-gradient(to left, rgba(0,0,0,0.08), transparent);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: var(--text-md);
    font-weight: var(--font-weight-heavy);
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
    white-space: nowrap;
}

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

    .tab-btn.active {
        color: var(--text-main); /* Active text is bright */
    }

        .tab-btn.active::after {
            content: '';
            position: absolute;
            bottom: -2px; /* Pull it down to cover the border-bottom of the container */
            left: 0;
            width: 100%;
            height: 2px;
            background-color: var(--brand-secondary);
            border-radius: 2px 2px 0 0;
        }

@media screen and (max-width: 500px) {
    .tab-btn {
        font-size: var(--text-sm);
    }
}

/* =========================================
   DISCOVERY HORIZONTAL SCROLL GALLERY
   ========================================= */
.tab-pane-discovery {
    background-color: var(--bg-base);
    border-radius: var(--radius-card);
}

/* =========================================
   DISCOVERY COVER FLOW GALLERY
   ========================================= */
.discovery-carousel-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.discovery-scroller {
    display: flex;
    gap: 0;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    /* padding must always equal half the step size above */
    padding: var(--space-xl) calc(50% - 35px) 60px calc(50% - 35px);
    /*scrollbar-width: none;*/
    scrollbar-width: thin;
    scrollbar-color: var(--bg-surface-raised) transparent;
    flex-grow: 1;
    outline: none;
}

@media screen and (min-width: 768px) {
    .discovery-scroller {
        padding: var(--space-xl) calc(50% - 75px) 70px calc(50% - 75px);
    }
}

/*.discovery-scroller::-webkit-scrollbar {
    display: none;
}*/

/* Custom Scrollbar for Chrome, Safari, and Edge */
.discovery-scroller::-webkit-scrollbar {
    height: 10px; /* Sleek horizontal scrollbar */
}

.discovery-scroller::-webkit-scrollbar-track {
    background: transparent; /* Keeps the area around it clean */
    border-radius: 8px;
}

.discovery-scroller::-webkit-scrollbar-thumb {
    background-color: var(--bg-surface-raised); /* Blends with your UI cards */
    border-radius: 8px;
    border: 3px solid var(--bg-base); /* Creates a nice "padded" gap around the thumb */
}

    .discovery-scroller::-webkit-scrollbar-thumb:hover {
        background-color: rgba(255, 255, 255, 0.3); /* Brightens up when hovered */
    }

/* 
  The Invisible Tracking Wrapper.
  This is extremely narrow (just the step size). 
  Because it has no negative margins, its 50% mark is mathematically flawless.
*/
.discovery-card {
    position: relative;
    scroll-snap-align: center;
    flex: 0 0 70px; /* Mobile step size */
    height: 160px; /* Match mobile inner height */
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    /* This forces the browser to respect z-index during GPU scrolling */
    z-index: 1;
    will-change: z-index;
}

@media screen and (min-width: 768px) {
    .discovery-card {
        flex: 0 0 150px; /* size is 150 to account for no translation of X direction for image in the animation */
        height: 380px; /* Match desktop inner height */
    }
}

/* 
  The Visual Card.
  Positioned absolute so it perfectly overlaps the narrow wrapper without distorting the DOM.
*/
.discovery-card-inner {
    position: absolute;
    width: 160px;
    height: 160px;
    border-radius: var(--radius-card);
    /*overflow: hidden;*/
    background-color: var(--bg-surface-raised);
    user-select: none;
    -webkit-box-reflect: below 4px linear-gradient(transparent 60%, rgba(0,0,0,0.3));
    /* Anti-blur hardware rendering fixes */
    backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-font-smoothing: antialiased;
}

@media screen and (min-width: 768px) {
    .discovery-card-inner {
        width: 380px;
        height: 380px;
    }
}

.discovery-card-art {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.discovery-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--space-xl) var(--space-sm) var(--space-sm) var(--space-sm);
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.5) 50%, transparent 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.discovery-card-title {
    color: #ffffff !important;
    font-weight: var(--font-weight-heavy);
    font-size: var(--text-lg);
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    line-height: 1.2;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.discovery-card-artist {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: var(--text-sm);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

    .discovery-card-artist a {
        color: inherit !important;
        text-decoration: none;
    }

        .discovery-card-artist a:hover {
            text-decoration: underline;
        }

.discovery-card-stat {
    color: var(--brand-secondary) !important;
    font-size: var(--text-xs);
    font-weight: var(--font-weight-heavy);
}

/* --- Navigation Buttons --- */
.discovery-nav-btn {
    position: absolute;
    z-index: 110;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    color: var(--text-main);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: opacity 0.2s, background-color 0.2s;
}

    .discovery-nav-btn:hover {
        background-color: var(--bg-surface-raised);
    }

    .discovery-nav-btn:disabled {
        filter: grayscale(100%);
        opacity: 0.4;
        pointer-events: none;
    }

.discovery-nav-left {
    left: -16px;
}

.discovery-nav-right {
    right: -16px;
}

/* =========================================
   SCROLL-DRIVEN ANIMATIONS 
   ========================================= */
@supports (animation-timeline: view()) {
    @keyframes adjust-z-index {
        0% {
            z-index: 1;
        }

        50% {
            z-index: 100;
        }

        100% {
            z-index: 1;
        }
    }
    /* 
       Expanded Keyframes:
       Creates 5 explicit, visible, distinct angles on each side of the center card.
    */
    @keyframes rotate-cover {
        0% {
            transform: rotateY(-35deg) scale(0.833);
        }

        35% {
            transform: rotateY(-35deg) scale(0.833);
        }
        /* The center card renders at its true, crisp 1:1 scale */
        50% {
            transform: rotateY(0deg);/* translateZ(1em);*/
        }
        /* Side cards shrink again */
        65% {
            transform: rotateY(35deg) scale(0.833);
        }

        100% {
            transform: rotateY(35deg) scale(0.833);
        }
    }

    .discovery-card {
        view-timeline-name: --li-in-and-out-of-view;
        view-timeline-axis: inline;
        animation: adjust-z-index linear both;
        animation-timeline: --li-in-and-out-of-view;
        perspective: 40em;
    }

    .discovery-card-inner {
        animation: rotate-cover linear both;
        animation-timeline: --li-in-and-out-of-view;
        transform-style: preserve-3d;
        will-change: transform;
    }
}

/* Disable subtitle link clicks on mobile to prevent accidental taps */
@media screen and (max-width: 910px) {
    .no-link-mobile {
        pointer-events: none;
        text-decoration: none;
    }
}

.hero-title {
    /*font-size: clamp(0.95rem, 5.5vw - 0.2rem, 5rem);*/
    font-size: clamp(2rem, 8vw + 0.5rem, 5rem);
}

@media (min-width: 768px) and (max-width: 1024px) {
    /*.hero-title {
        font-size: clamp(2rem, 4vw + 0.5rem, 3.5rem);
    }*/
}

/* =========================================
   GLOBAL ASYNC ART LOADER
   ========================================= */
.async-art-container {
    position: relative;
    /* Ensure the container establishes a stacking context for the absolute spinner */
    z-index: 1;
}

    /* The Spinner */
    .async-art-container::before {
        content: "";
        position: absolute;
        /* Center it perfectly */
        top: 50%;
        left: 50%;
        width: 40px;
        height: 40px;
        margin-top: -20px;
        margin-left: -20px;
        border: 3px solid rgba(255, 255, 255, 0.1);
        border-top: 3px solid var(--brand-secondary);
        border-radius: 50%;
        animation: custom-spin 1s linear infinite;
        z-index: 1;
        pointer-events: none; /* Let clicks pass through to the image link below */
    }

    /* Hide the spinner once the JS attaches the .loaded class */
    .async-art-container.loaded::before {
        display: none;
    }

    /* Standardized fade-in for the images inside the async container */
    .async-art-container img {
        transition: opacity 0.4s ease-in, transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    }

/* =========================================
   ARTIST DISCOVERY CAROUSEL
   ========================================= */
.artist-carousel-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.artist-carousel-horizontal {
    display: flex;
    flex: 1;
    gap: var(--space-md); /* Spread them out comfortably */
    /*padding: var(--space-md) 0 var(--space-lg) 0;*/
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -webkit-overflow-scrolling: touch;
}

    .artist-carousel-horizontal::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }

.artist-carousel-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 0 0 128px; /* Fix the width explicitly to the md avatar size */
    gap: var(--space-sm);
    overflow: hidden;
}

.artist-avatar-link {
    display: block;
    width: 128px;
    height: 128px;
    flex-shrink: 0;
    text-decoration: none;
    border-radius: 50%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

    .artist-avatar-link:hover {
        transform: scale(1.01);
        box-shadow: var(--shadow-sm);
    }

.artist-text-stack {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 2px;
}

.artist-title-link {
    font-size: var(--text-base);
    font-weight: var(--font-weight-heavy);
    color: var(--text-main);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color 0.2s ease;
}

    .artist-title-link:hover {
        color: var(--brand-secondary);
    }

.artist-stat-link {
    font-size: var(--text-base);
    color: var(--brand-secondary);
    font-weight: var(--font-weight-heavy);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .artist-stat-link:hover {
        text-decoration: underline;
    }

@media screen and (max-width: 910px) {
    /* Disable link hovers inside the text stack on mobile to prevent accidental navigation */
    .artist-text-stack a {
        pointer-events: none;
        text-decoration: none;
    }
}

.global-rank-badge {
    display: inline-flex;
    align-items: center;
    background-color: var(--primary-hover);
    color: var(--text-on-primary);
    font-size: var(--text-xs);
    font-weight: var(--font-weight-heavy);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 6px;
    border: 2px solid var(--primary-base);
    border-radius: 4px;
    box-shadow: var(--shadow-sm);
}

/* =========================================
    GLOBAL STATS RIBBON
    ========================================= */
.global-stats-ribbon {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: var(--space-lg);
    background-color: rgba(42, 46, 42, 0.5);
}

.global-stat-block {
    display: flex;
    flex-direction: column;
    padding: var(--space-md) var(--space-lg);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

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

.global-stat-label {
    font-size: var(--text-lg);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.global-stat-value {
    font-size: var(--text-4xl);
    font-weight: 900;
    color: var(--text-main);
    line-height: 1.1;
}

/* Responsive adjustments for the ribbon */
@media screen and (max-width: 992px) {
    .global-stats-ribbon {
        grid-template-columns: repeat(3, 1fr);
    }

    .global-stat-block:nth-child(3n) {
        border-right: none;
    }

    .global-stat-block:nth-child(n+4) {
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
}

@media screen and (max-width: 576px) {
    .global-stats-ribbon {
        grid-template-columns: repeat(2, 1fr);
    }

    .global-stat-block:nth-child(3n) {
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }
    /* Reset from tablet */
    .global-stat-block:nth-child(2n) {
        border-right: none;
    }

    .global-stat-block:nth-child(n+3) {
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .global-stat-block {
        padding: var(--space-md) var(--space-sm);
    }
}

/* ==========================================
    USER-SPECIFIC STATS RIBBON OVERRIDES (4 Cols)
    ========================================== */
.user-stats-ribbon {
    display: grid;
    grid-template-columns: repeat(4, 1fr) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: var(--space-lg);
    background-color: rgba(42, 46, 42, 0.5);
}

    /* Reset global borders to ensure clean 4-col layout */
    .user-stats-ribbon .global-stat-block {
        border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-top: none !important;
    }

        .user-stats-ribbon .global-stat-block:last-child {
            border-right: none !important;
        }

/* Mobile / Tablet: 2x2 grid */
@media screen and (max-width: 909px) {
    .user-stats-ribbon {
        grid-template-columns: repeat(2, 1fr) !important;
    }

        /* Plays (Left) & Time (Right) - Top Row */
        .user-stats-ribbon .global-stat-block:nth-child(1) {
            border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
        }

        .user-stats-ribbon .global-stat-block:nth-child(2) {
            border-right: none !important;
        }

        /* Releases (Left) & Tracks (Right) - Bottom Row */
        .user-stats-ribbon .global-stat-block:nth-child(3) {
            border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
            border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        }

        .user-stats-ribbon .global-stat-block:nth-child(4) {
            border-right: none !important;
            border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        }
}

/* =========================================
   CUSTOM CENTERED ADMIN MODAL
   ========================================= */
.custom-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--overlay-dark);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

    .custom-modal-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

.custom-modal-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90%;
    max-width: 450px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-lg);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .custom-modal-box.open {
        opacity: 1;
        pointer-events: auto;
        transform: translate(-50%, -50%) scale(1);
    }

.custom-modal-header {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-modal-body {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    max-height: 70vh;
    overflow-y: auto;
}

.custom-modal-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-subtle);
    background-color: var(--bg-surface-raised);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    border-bottom-left-radius: var(--radius-card);
    border-bottom-right-radius: var(--radius-card);
}

.admin-action-group {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: var(--space-xs);
    z-index: 5;
}

a.badge-link {
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

    a.badge-link:hover {
        border-color: var(--brand-secondary);
        color: var(--brand-secondary);
        background-color: var(--bg-surface-raised);
    }

.name-heading {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    word-break: break-word; /* Prevents long unbroken words from bleeding horizontally */
}
/* =========================================
   CUSTOM SLIDE TOGGLE
   ========================================= */
.custom-slide-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
}

    .custom-slide-toggle .toggle-input {
        display: none; /* Hides native checkbox */
    }

    .custom-slide-toggle .toggle-slider {
        position: relative;
        width: 44px;
        height: 24px;
        background-color: var(--bg-surface-raised);
        border: 2px solid var(--border-default);
        border-radius: var(--radius-pill);
        transition: all 0.3s ease;
    }

        /* The circle inside the slider */
        .custom-slide-toggle .toggle-slider::before {
            content: "";
            position: absolute;
            height: 14px;
            width: 14px;
            left: 3px;
            bottom: 3px;
            background-color: var(--text-muted);
            border-radius: 50%;
            transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        }

    /* Active State */
    .custom-slide-toggle .toggle-input:checked + .toggle-slider {
        background-color: var(--primary-base);
        border-color: var(--primary-base);
    }

        .custom-slide-toggle .toggle-input:checked + .toggle-slider::before {
            transform: translateX(20px);
            background-color: var(--text-on-primary);
        }

    .custom-slide-toggle .toggle-label {
        font-size: var(--text-sm);
        font-weight: var(--font-weight-heavy);
        color: var(--text-muted);
        letter-spacing: 0.05rem;
        text-transform: uppercase;
        user-select: none;
        transition: color 0.3s ease;
    }

    /* Optional: Highlight text when active */
    .custom-slide-toggle .toggle-input:checked ~ .toggle-label {
        color: var(--text-main);
    }