body {
    overflow: auto;
}

/* --------------------------------------------------
   Page layout
-------------------------------------------------- */

.pageMain--overlap {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.panel {
    border: 1px solid rgba(255, 255, 255, .10);
    background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .03));
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
    overflow: visible;
}

.panelHead {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.panelHead h2 {
    margin: 0;
    font-size: 18px;
}

.panelSub {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.panelBody {
    padding: 18px;
}

.panelBody--matrix {
    padding-top: 12px;
}

/* --------------------------------------------------
   Top layout
-------------------------------------------------- */

.overlapTopGrid {
    display: grid;
    grid-template-columns: minmax(420px, 1.35fr) minmax(280px, 0.95fr);
    gap: 16px;
    align-items: start;
}

.searchPanel,
.summaryPanel,
.matrixPanel {
    min-width: 0;
}

/* --------------------------------------------------
   Member search / actions
-------------------------------------------------- */

.memberAddRow {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.searchField {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
}

.searchField--wide {
    min-width: 320px;
    flex: 1 1 320px;
}

.searchField label {
    font-size: 14px;
    opacity: 0.75;
    color: var(--muted);
    font-weight: 600;
}

.searchWrap--field {
    width: 100%;
}

.searchActions {
    display: flex;
    gap: 10px;
    align-items: center;
}

#loadBtn,
#resetBtn {
    height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid var(--stroke);
    cursor: pointer;
}

#loadBtn {
    background: rgba(96, 165, 250, .18);
    border-color: rgba(96, 165, 250, .35);
    color: var(--text);
}

#resetBtn {
    background: rgba(255, 255, 255, .06);
    color: var(--text);
}

#loadBtn:hover {
    background: rgba(96, 165, 250, .26);
    border-color: rgba(96, 165, 250, .55);
}

#resetBtn:hover {
    background: rgba(255, 255, 255, .12);
}

#memberSearchInput {
    width: 100%;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, .10);
    background: rgba(255, 255, 255, .05);
    color: var(--text);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

#memberSearchInput::placeholder {
    color: var(--muted);
}

#memberSearchInput:hover {
    background: rgba(255, 255, 255, .06);
}

#memberSearchInput:focus {
    outline: none;
    border-color: rgba(96, 165, 250, .75);
    background: rgba(255, 255, 255, .07);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .16);
}

/* --------------------------------------------------
   Selected member chips
-------------------------------------------------- */

.selectedMembers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.memberChip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .06);
}

.memberChipName {
    font-weight: 700;
    color: var(--text);
}

.memberChipMeta {
    color: var(--muted);
    font-size: 12px;
}

.memberChipRemove {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.memberChipRemove:hover {
    color: #fca5a5;
}

/* --------------------------------------------------
   Summary cards
-------------------------------------------------- */

.summaryCards {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.summaryCard {
    border: 1px solid rgba(255, 255, 255, .08);
    background: rgba(255, 255, 255, .04);
    border-radius: 14px;
    padding: 8px 14px;
}

.summaryCardLabel {
    font-size: 12px;
    color: var(--muted);
}

.summaryCardValue {
    margin-top: 4px;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.05;
}

/* --------------------------------------------------
   Filter bar
-------------------------------------------------- */


.filterBar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: end;
    margin-bottom: 12px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 14px;
    background: rgba(255, 255, 255, .04);
}

.filterField {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 0 0 auto;
    min-width: 0;
}

.filterField--wide {
    flex: 0 1 320px;
    min-width: 220px;
}

.filterField label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}

.filterField select,
.filterField input,
#clearFiltersBtn {
    height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .10);
    background: rgba(255, 255, 255, .05);
    color: var(--text);
    font-size: 14px;
    -webkit-appearance: none;
    appearance: none;
}

.filterField input {
    height: 38px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, .10);
    background: rgba(255, 255, 255, .05);
    color: var(--text);
    font-size: 14px;
    padding: 0 12px;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.filterField input::placeholder {
    color: var(--muted);
}

.filterField input:hover {
    background: rgba(255, 255, 255, .06);
}

.filterField input:focus {
    outline: none;
    border-color: rgba(96, 165, 250, .75);
    background: rgba(255, 255, 255, .07);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .16);
}

.filterField select {
    width: auto;
    min-width: 120px;
    max-width: 320px;
    padding: 0 32px 0 12px;
}

.filterField select option {
    background: #0f172a;
    color: var(--text);
}

.filterField select:focus,
#clearFiltersBtn:focus {
    outline: none;
    border-color: rgba(96, 165, 250, .75);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, .16);
}

.filterField select:disabled {
    opacity: .65;
    cursor: not-allowed;
}

.filterActions {
    display: flex;
    align-items: end;
    flex: 0 0 auto;
}

#clearFiltersBtn {
    padding: 0 14px;
    font-weight: 600;
    cursor: pointer;
}

#clearFiltersBtn:hover {
    background: rgba(255, 255, 255, .09);
}

.filterSummary {
    margin-bottom: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(96, 165, 250, .20);
    background: rgba(96, 165, 250, .08);
    color: #dbeafe;
    font-size: 13px;
    line-height: 1.45;
}

/* --------------------------------------------------
   Matrix / table
-------------------------------------------------- */

.matrixWrap {
    overflow: auto;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .08);
}

.overlapTable {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    background: rgba(255, 255, 255, .03);
}

.overlapTable th,
.overlapTable td {
    padding: 5px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    vertical-align: middle;
    line-height: 1.15;
}

.overlapTable th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: rgba(11, 15, 20, .96);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.overlapTable th.tuneCol,
.overlapTable td:first-child {
    text-align: left;
}

.overlapTable th.overlapCol,
.overlapTable td:nth-child(2) {
    width: 96px;
    min-width: 96px;
    text-align: left;
}

.overlapTable th.tuneCol {
    width: auto;
    min-width: 320px;
}

.overlapTable th:not(.tuneCol):not(.overlapCol),
.overlapTable td.memberCell {
    width: 1%;
    white-space: nowrap;
    text-align: center;
    padding-left: 12px;
    padding-right: 12px;
}

.overlapTuneRow {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.overlapTuneName {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
}

.overlapTuneName:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.overlapCountBadge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(96, 165, 250, .14);
    border: 1px solid rgba(96, 165, 250, .22);
    color: #bfdbfe;
    font-weight: 700;
    font-size: 11px;
    line-height: 1;
}

.memberCell {
    text-align: center;
}

.memberHit,
.memberMiss {
    width: 18px;
    height: 18px;
    display: inline-block;
    border-radius: 50%;
}

.memberHit {
    background: #60a5fa;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .18) inset;
}

.memberMiss {
    background: rgba(255, 255, 255, .08);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, .10) inset;
}

/* --------------------------------------------------
   Tune action links
-------------------------------------------------- */

.sessionIconLink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    transition: all 0.15s ease;
    flex: 0 0 auto;
}

.sessionIconLink:hover {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.3);
    transform: translateY(-1px);
}

.sessionIconLink img {
    width: 22px;
    height: 22px;
    display: block;
    object-fit: contain;
}

.trackOverviewLink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    flex: 0 0 auto;
}

.trackOverviewDot {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 30%, #fde68a, #f59e0b);
    box-shadow:
        0 0 0 1px rgba(245, 158, 11, 0.5),
        0 0 6px rgba(245, 158, 11, 0.6);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.trackOverviewLink:hover .trackOverviewDot {
    transform: scale(1.2);
    box-shadow:
        0 0 0 1px rgba(245, 158, 11, 0.7),
        0 0 10px rgba(245, 158, 11, 0.9);
}

/* --------------------------------------------------
   States
-------------------------------------------------- */

.emptyState,
.errorState,
.loadingState {
    padding: 10px 0;
}

.sourceBadge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 22px;
    padding: 0 8px;
    margin-left: 6px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    vertical-align: middle;
}

.sourceBadge--sets {
    background: rgba(96, 165, 250, 0.18);
    border: 1px solid rgba(96, 165, 250, 0.35);
    color: #bfdbfe;
}

.sourceBadge--tunebook {
    background: rgba(34, 197, 94, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.35);
    color: #bbf7d0;
}

/* TYPE COLUMN */
.overlapTable th.typeCol,
.overlapTable td.typeColCell {
    width: 120px;
    min-width: 120px;
    text-align: center;
}

/* MODE COLUMN */
.overlapTable th.modeCol,
.overlapTable td.modeColCell {
    width: 150px;
    min-width: 150px;
    text-align: center;
}

/* OVERLAP COLUMN */
.overlapTable th.overlapCol,
.overlapTable td.overlapColCell {
    width: 140px;
    min-width: 140px;
    text-align: center;
}

.typePill,
.modePill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    border: 1px solid rgba(255, 255, 255, .10);
    background: rgba(255, 255, 255, .05);
    color: var(--text);
}

.typePill {
    background: rgba(245, 158, 11, .14);
    border-color: rgba(245, 158, 11, .28);
    color: #fde68a;
}

.modePill {
    background: rgba(167, 139, 250, .14);
    border-color: rgba(167, 139, 250, .28);
    color: #ddd6fe;
}

.tableMuted {
    color: var(--muted);
    font-size: 12px;
}

.tableSortBtn {
    appearance: none;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.tableSortBtn:hover {
    color: #93c5fd;
}

/* --------------------------------------------------
   Responsive
-------------------------------------------------- */

@media (max-width: 1200px) {
    .filterBar {
        gap: 10px;
    }
}

@media (max-width: 1100px) {
    .overlapTopGrid {
        grid-template-columns: 1fr;
    }
}

/* Compact table layout sooner, so member columns stay visible */
@media (max-width: 980px),
(max-height: 520px) {

    .summaryPanel {
        display: none;
    }

    /* Hide Type / Mode / Overlap / Popularity on smaller screens */
    .overlapTable th.popCol,
    .overlapTable td.popColCell,
    .overlapTable th.typeCol,
    .overlapTable td.typeColCell,
    .overlapTable th.modeCol,
    .overlapTable td.modeColCell,
    .overlapTable th.overlapCol,
    .overlapTable td.overlapColCell {
        display: none;
    }

    /* Let the tune column shrink */
    .overlapTable th.tuneCol {
        min-width: 220px;
    }

    /* Keep member columns compact */
    .overlapTable th:not(.tuneCol):not(.typeCol):not(.modeCol):not(.overlapCol),
    .overlapTable td.memberCell {
        width: 1%;
        min-width: 52px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .overlapTuneRow {
        gap: 4px;
    }

    .overlapTuneName {
        font-size: 14px;
    }

    .sourceBadge {
        min-width: 30px;
        height: 20px;
        padding: 0 6px;
        margin-left: 4px;
        font-size: 11px;
    }

    .sessionIconLink,
    .sessionIconLink img,
    .trackOverviewDot {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 900px) {
    .summaryCards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .memberAddRow {
        align-items: stretch;
    }

    .searchActions {
        margin-left: 0;
    }
}

@media (max-width: 700px) {
    .searchField--wide {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .searchActions {
        flex: 1 1 100%;
    }

    .summaryCards {
        grid-template-columns: 1fr;
    }

    .filterBar {
        flex-direction: column;
        align-items: stretch;
    }

    .filterField,
    .filterField--wide,
    .filterActions {
        flex: 1 1 100%;
    }

    .filterField select,
    #clearFiltersBtn {
        width: 100%;
        max-width: none;
    }

    .panelHead {
        padding-left: 14px;
        padding-right: 14px;
    }

    .panelBody {
        padding-left: 14px;
        padding-right: 14px;
    }
}

.popCol {
    width: 90px;
    text-align: center;
}

.popColCell {
    text-align: center;
    font-size: 30px;
}

.starRating {
    color: #f5c518;
    letter-spacing: 1px;
}

.starRating--unknown {
    color: #666;
    opacity: 0.5;
}

.star {
    letter-spacing: 1px;
}

.star--filled {
    color: #f5c518;
    /* gold */
}

.star--empty {
    color: rgba(255, 255, 255, 0.2);
    /* dimmed */
}

/* optional tweak */
.starRating {
    display: inline-block;
}

.starRating--unknown {
    color: rgba(255, 255, 255, 0.3);
}