/* --- Main App View --- */
.sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--glass-border);
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-home-link {
    cursor: pointer;
}

.search-box {
    padding: 1rem;
}

.search-box input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 10px;
    border-radius: 8px;
    outline: none;
}

.series-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem 1rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.series-item {
    margin-bottom: 0.5rem;
}

.series-title {
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.8rem;
    color: var(--accent);
    padding: 0.6rem 0.5rem;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.series-title:hover {
    background: rgba(255, 255, 255, 0.05);
}

.series-chevron {
    font-size: 0.6rem;
    transition: transform 0.25s ease;
    display: inline-block;
}

.series-item:not(.collapsed) .series-chevron {
    transform: rotate(90deg);
}

.sets-container {
    max-height: 3000px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    opacity: 1;
}

.series-item.collapsed .sets-container {
    max-height: 0;
    opacity: 0;
}

.set-link {
    display: block;
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.2s;
    font-size: 0.9rem;
}

.set-link:hover, .set-link.active {
    background: var(--bg-panel-hover);
    color: var(--accent);
    transform: translateX(4px);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.set-header {
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.set-header-main {
    display: flex;
    gap: 1.5rem;
    flex: 1;
    align-items: flex-start;
    min-width: 0;
}

.set-header-details {
    flex: 1;
}

.set-header-control-row {
    display: flex;
    justify-content: space-between;
    gap: 1.25rem;
    align-items: flex-start;
    margin-top: 12px;
}

.set-progress-container {
    display: flex;
    gap: 2rem;
    align-items: flex-end;
    min-width: 0;
}

.progress-box {
    display: flex;
    flex-direction: column;
    width: 220px;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.9rem;
    color: var(--text-main);
}

.bold-label {
    font-weight: 700;
}

.progress-bar-bg {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #3498db;
    width: 0%;
    transition: width 0.4s ease;
}

.set-value {
    color: #2ecc71;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.set-card-controls {
    display: grid;
    grid-template-rows: minmax(42px, auto) minmax(42px, auto);
    justify-items: end;
    align-items: center;
    gap: 0.5rem;
    min-width: min(560px, 42vw);
    align-self: flex-start;
    flex: 0 1 min(560px, 42vw);
}

.card-sort-controls,
.card-view-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.card-sort-controls {
    justify-content: flex-end;
    order: 2;
}

.card-view-controls {
    justify-content: flex-end;
    order: 1;
}

.card-sort-btn,
.binder-view-toggle,
.binder-size-btn {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: var(--bg-panel);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1;
    padding: 0 0.65rem;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.card-sort-btn:hover,
.card-sort-btn:focus-visible,
.binder-view-toggle:hover,
.binder-view-toggle:focus-visible,
.binder-size-btn:hover,
.binder-size-btn:focus-visible {
    border-color: var(--accent-hover);
    color: var(--text-main);
    outline: none;
}

.card-sort-btn.active,
.binder-view-toggle.active,
.binder-size-btn.active {
    border-color: #ffe866;
    background: #ffe866;
    color: #1c2433;
}

.binder-size-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.binder-size-btn {
    min-height: 32px;
    font-size: 0.78rem;
    padding: 0 0.58rem;
}

.sort-direction {
    width: 0.85rem;
    color: currentColor;
    font-size: 1rem;
    opacity: 0.65;
    text-align: center;
}

.card-sort-btn.active .sort-direction {
    opacity: 1;
}

#set-logo {
    max-height: 50px;
    object-fit: contain;
}

.filter-dropdown {
    background: var(--bg-panel);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 10px 16px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
}

.filter-dropdown:hover, .filter-dropdown:focus {
    border-color: var(--accent-hover);
    background: var(--bg-panel-hover);
}

.filter-dropdown option {
    background: var(--bg-dark);
    color: var(--text-main);
    font-weight: 500;
}

.filter-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
    flex: 0 0 min(440px, 22vw);
}

.filter-control-full {
    width: 100%;
    box-sizing: border-box;
}

.cards-grid {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    align-content: start;
}

.cards-grid.binder-mode {
    display: block;
    padding: 1.25rem 1.75rem 2rem;
}

.binder-view {
    min-height: 100%;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 1.25rem;
}

.binder-spread {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
    gap: 0.35rem;
    min-height: min(68vh, 760px);
    padding: 0.45rem;
    border-radius: 16px;
    background:
        radial-gradient(circle at 18% 12%, rgba(255, 194, 194, 0.09), transparent 24%),
        radial-gradient(circle at 84% 82%, rgba(24, 0, 8, 0.42), transparent 38%),
        repeating-linear-gradient(118deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 7px),
        linear-gradient(135deg, #4a1424, #210711 52%, #5b192d);
    box-shadow:
        inset 0 0 0 1px rgba(255, 214, 214, 0.08),
        inset 0 0 48px rgba(0, 0, 0, 0.42),
        0 24px 60px rgba(0, 0, 0, 0.42);
}

.binder-page {
    position: relative;
    min-height: 0;
    border-radius: 12px;
    background:
        radial-gradient(circle at 22% 18%, rgba(255, 210, 210, 0.06), transparent 26%),
        repeating-linear-gradient(100deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 6px),
        linear-gradient(145deg, #2c0d18, #14050b 58%, #3b1120);
    box-shadow:
        inset 0 0 0 1px rgba(255, 225, 225, 0.055),
        inset 0 0 34px rgba(0, 0, 0, 0.38);
    overflow: hidden;
}

.binder-page-empty {
    background:
        radial-gradient(circle at 26% 20%, rgba(255, 220, 220, 0.055), transparent 30%),
        repeating-linear-gradient(108deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 7px),
        linear-gradient(145deg, #300d1a, #13050b 62%, #451326);
}

.binder-page-left::after,
.binder-page-right::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 28px;
    pointer-events: none;
}

.binder-page-left::after {
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 220, 220, 0.16), rgba(0, 0, 0, 0.48));
    filter: blur(3px);
}

.binder-page-right::before {
    left: 0;
    background: linear-gradient(270deg, transparent, rgba(255, 215, 215, 0.13), rgba(0, 0, 0, 0.52));
    filter: blur(3px);
}

.binder-pockets {
    position: absolute;
    inset: 1.15rem 1.15rem 1.15rem 2rem;
    display: grid;
    grid-template-columns: repeat(var(--binder-cols), minmax(0, 1fr));
    grid-template-rows: repeat(var(--binder-rows), minmax(0, 1fr));
    gap: clamp(0.45rem, 1.1vw, 1rem);
}

.binder-pocket {
    position: relative;
    min-width: 0;
    min-height: 0;
    border: 0;
    border-radius: 7px;
    border: 1px solid rgba(185, 225, 245, 0.18);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.11), rgba(150, 205, 235, 0.045) 44%, rgba(255, 255, 255, 0.025)),
        rgba(120, 185, 220, 0.055);
    box-shadow:
        inset 0 0 0 2px rgba(215, 245, 255, 0.08),
        inset 0 0 16px rgba(255, 255, 255, 0.08),
        inset 0 -14px 26px rgba(70, 120, 150, 0.1),
        0 10px 24px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    overflow: hidden;
    padding: 0;
}

.binder-pocket::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 27%),
        linear-gradient(315deg, rgba(160, 220, 255, 0.08), transparent 30%),
        linear-gradient(90deg, rgba(255, 255, 255, 0.055), transparent 15%, transparent 82%, rgba(255, 255, 255, 0.045));
    pointer-events: none;
    z-index: 3;
}

.binder-pocket img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    opacity: 0.92;
    position: relative;
    z-index: 1;
}

.binder-pocket.unowned img {
    opacity: 0.54;
    filter: none;
}

.binder-pocket.unowned::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.06), transparent 28%),
        linear-gradient(180deg, rgba(30, 55, 48, 0.28), rgba(88, 112, 72, 0.2));
    box-shadow:
        inset 0 0 0 999px rgba(42, 72, 58, 0.13),
        inset 0 0 26px rgba(0, 0, 0, 0.16);
}

.binder-pocket.empty {
    cursor: default;
    opacity: 0.38;
}

.binder-slot-label {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 0.1rem;
    color: #fff;
    text-align: center;
    text-shadow: 0 2px 7px rgba(0, 0, 0, 0.9);
    pointer-events: none;
    z-index: 4;
}

.binder-slot-label span {
    font-size: clamp(0.55rem, 1vw, 0.9rem);
    font-weight: 800;
    opacity: 0.8;
}

.binder-slot-label strong {
    font-size: clamp(1rem, 2.4vw, 2.1rem);
    line-height: 0.9;
}

.binder-nav {
    display: grid;
    grid-template-columns: minmax(100px, 1fr) auto minmax(100px, 1fr);
    align-items: center;
    gap: 1rem;
}

.binder-nav span {
    color: var(--text-muted);
    font-weight: 900;
    text-align: center;
}

.binder-nav button {
    min-height: 44px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: var(--bg-panel);
    color: var(--text-main);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
    padding: 0 1rem;
}

.binder-nav button:first-child {
    justify-self: start;
}

.binder-nav button:last-child {
    justify-self: end;
}

.binder-nav button:disabled {
    cursor: default;
    opacity: 0.45;
}
