.inventory-page {
    position: relative;
    z-index: 2;
}

.inventory-shell {
    max-width: 1180px;
    margin: 0 auto;
    background: rgba(30, 30, 34, 0.94);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.inventory-summary {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 18px;
}

.inventory-summary h2 {
    margin: 0;
    color: #fff;
    font-size: 1.35rem;
    line-height: 1.2;
}

.summary-counts {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.summary-counts span {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 7px 10px;
    background: #26262a;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    font-size: 0.9rem;
}

.summary-counts strong {
    color: var(--color-accent);
}

.checker-panel,
.capture-panel {
    min-width: 0;
}

.checker-tabs {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 0;
    padding-left: 10px;
    border-bottom: 1px solid #444;
}

.tab-buttons {
    display: flex;
    align-items: flex-end;
    min-width: 0;
}

.checker-tabs .chrome-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    margin-bottom: -1px;
    padding: 10px 20px;
    background: #2a2a2e;
    border: 1px solid #444;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    color: #888;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: normal;
    transition: all 0.2s;
}

.checker-tabs .chrome-tab:hover:not(.active) {
    background: #333338;
    color: #ccc;
}

.checker-tabs .chrome-tab.active {
    z-index: 2;
    background: #38383e;
    border-color: #444;
    border-bottom: 1px solid #38383e;
    color: var(--color-accent);
    font-weight: bold;
}

.checker-controls {
    display: grid;
    grid-template-columns: minmax(180px, 1fr);
    gap: 12px;
    padding: 16px 0;
}

.bulk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    margin-left: auto;
    white-space: nowrap;
}

.inventory-grid {
    display: grid;
    gap: 12px;
}

.character-inventory-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.relems-section {
    min-width: 0;
}

.relems-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: #eee;
    font-size: 0.95rem;
    font-weight: bold;
}

.relems-section-title::before {
    content: "";
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--color-accent);
}

.relems-section.chaos .relems-section-title::before {
    background: var(--color-chaos);
}

.relems-section.aequor .relems-section-title::before {
    background: var(--color-aequor);
}

.relems-section.caro .relems-section-title::before {
    background: var(--color-caro);
}

.relems-section.ultra .relems-section-title::before {
    background: var(--color-ultra);
}

.relems-character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
    align-items: start;
    gap: 12px;
}

.wheel-inventory-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}

.inventory-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    min-width: 0;
    padding: 9px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-card);
    color: var(--color-text-primary);
    cursor: pointer;
    overflow: hidden;
}

.inventory-card:hover {
    background: var(--color-bg-elevated);
    border-color: var(--color-border-light);
}

.inventory-card.selected {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 1px rgba(255, 193, 7, 0.28);
}

.inventory-card img {
    display: block;
    width: 100%;
    object-fit: cover;
    background: #111;
    border: 1px solid #3f3f3f;
    border-radius: var(--radius-sm);
}

.character-inventory-card img {
    aspect-ratio: 1 / 1.08;
}

.breakthrough-stepper {
    display: grid;
    grid-template-columns: 24px minmax(42px, auto) 24px;
    align-items: center;
    max-width: 100%;
    min-height: 30px;
    margin-top: -2px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 999px;
    background: rgba(10, 10, 10, 0.78);
    color: #fff;
    overflow: hidden;
}

.breakthrough-stepper-btn {
    display: grid;
    place-items: center;
    width: 24px;
    height: 30px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 0.88rem;
    font-weight: 900;
    line-height: 1;
    cursor: pointer;
}

.breakthrough-stepper-btn:hover,
.breakthrough-stepper-btn:focus {
    background: rgba(255, 255, 255, 0.12);
    outline: none;
}

.breakthrough-stepper-label {
    min-width: 42px;
    padding: 0 4px;
    color: #fff;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 30px;
    text-align: center;
    white-space: nowrap;
}

.wheel-inventory-card .breakthrough-stepper {
    margin-top: -2px;
    margin-bottom: 0;
}

.character-inventory-card .breakthrough-stepper {
    margin-top: 8px;
    margin-bottom: 8px;
}

.wheel-inventory-card img {
    width: min(100%, 72px);
    aspect-ratio: 225 / 456;
}

.inventory-card-name {
    width: 100%;
    color: #eee;
    font-size: 0.83rem;
    font-weight: bold;
    line-height: 1.35;
    text-align: center;
    overflow-wrap: anywhere;
}

.wheel-inventory-card .inventory-card-name {
    min-height: 2.7em;
}

.check-mark {
    position: absolute;
    top: 7px;
    right: 7px;
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    background: rgba(10, 10, 10, 0.78);
    border: 1px solid var(--color-border-light);
    border-radius: 50%;
    color: transparent;
    font-size: 0.9rem;
    font-weight: bold;
}

.inventory-card.selected .check-mark {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #111;
}

.capture-panel {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.capture-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 0 8px;
}

.primary-action,
.ghost-action {
    min-height: 42px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-weight: bold;
}

.primary-action {
    min-width: 112px;
    background: var(--color-link-blue);
    color: #fff;
}

.primary-action:hover {
    background: var(--color-link-blue-hover);
}

.ghost-action {
    border: 1px solid var(--color-border);
    background: #2b2b2f;
    color: var(--color-text-secondary);
}

.ghost-action:hover {
    border-color: var(--color-accent);
    color: #fff;
}

.copy-status {
    min-height: 22px;
    margin-bottom: 8px;
    color: var(--color-text-muted);
    font-size: 0.82rem;
}

.copy-status.success {
    color: var(--color-success);
}

.copy-status.error {
    color: var(--color-danger);
}

.inventory-toast {
    position: fixed;
    left: 50%;
    bottom: 34px;
    z-index: 9999;
    transform: translateX(-50%) translateY(10px);
    max-width: min(88vw, 520px);
    padding: 10px 24px;
    border: 1px solid #555;
    border-radius: 999px;
    background: rgba(50, 50, 55, 0.96);
    color: #eee;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    animation: inventoryToastFade 2.6s ease forwards;
}

.inventory-toast.success {
    border-color: rgba(46, 204, 113, 0.65);
    color: #dfffea;
}

.inventory-toast.error {
    border-color: rgba(231, 76, 60, 0.7);
    color: #ffe1dd;
}

@keyframes inventoryToastFade {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(12px);
    }
    14% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    72% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-8px);
    }
}

.empty-selection {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 54px;
    border: 1px dashed #444;
    border-radius: var(--radius-sm);
    color: #777;
    font-size: 0.82rem;
}

.preview-modal-content {
    width: min(94vw, 980px);
    max-width: 980px;
    max-height: 92vh;
}

.preview-image-frame {
    overflow: auto;
    max-height: 78vh;
    padding: 10px;
    background: #161616;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

#preview-image {
    display: block;
    width: 100%;
    max-width: none;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
}

@media (max-width: 600px) {
    .inventory-shell {
        padding: 14px;
    }

    .inventory-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .summary-counts {
        justify-content: flex-start;
    }

    .checker-tabs {
        align-items: stretch;
        flex-direction: column;
        padding-left: 0;
        border-bottom: none;
    }

    .tab-buttons {
        padding-left: 10px;
        border-bottom: 1px solid #444;
    }

    .capture-actions {
        justify-content: flex-start;
    }

    .bulk-actions {
        justify-content: flex-start;
        margin-left: 0;
    }

    .wheel-inventory-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .wheel-inventory-card {
        padding: 7px 5px;
    }

    .wheel-inventory-card .breakthrough-stepper {
        grid-template-columns: 18px minmax(26px, 1fr) 18px;
        width: 100%;
        max-width: 62px;
        min-height: 28px;
    }

    .wheel-inventory-card .breakthrough-stepper-btn {
        width: 18px;
        height: 28px;
        font-size: 0.78rem;
    }

    .wheel-inventory-card .breakthrough-stepper-label {
        min-width: 26px;
        padding: 0 2px;
        font-size: 0.78rem;
        line-height: 28px;
    }

    .relems-character-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .preview-modal-content {
        width: 94vw;
        padding: 14px;
    }
}
