.management-menu-content {
    position: absolute;
    bottom: -10px;
    left: 50px;
    width: 250px;
    padding: 1rem;
    border: 1px solid color-mix(in srgb, var(--accent-primary) 70%, transparent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    background: rgba(15, 15, 20, 0.98);
    z-index: var(--z-menu);
}

.management-menu-content .menu-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.management-menu-content .menu-item {
    justify-content: flex-start;
    gap: 0.75rem;
    font-size: 0.75rem;
    padding: 0.6rem 0.8rem;
    width: 100%;
    height: auto;
    background: rgba(255, 255, 255, 0.03);
}

.management-menu-content .menu-item.danger {
    background: rgba(239, 68, 68, 0.05);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}

.management-menu-content .divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.25rem 0;
}

/* Data Transfer Modal */
.data-transfer-dialog {
    max-width: 500px;
    width: 90%;
    padding: 2rem;
    border: 1px solid color-mix(in srgb, var(--accent-primary) 70%, transparent);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    background: rgba(15, 15, 20, 0.98);
    color: #EAE6DF;
    overflow: visible;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

.data-transfer-dialog .close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: #EAE6DF;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.data-transfer-dialog .close-btn:hover {
    opacity: 1;
}

.data-transfer-dialog h3 {
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    font-size: 1.6rem;
    text-align: center;
    letter-spacing: 0.1em;
}

.data-transfer-dialog .transfer-desc {
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.6;
    margin-bottom: 1.5rem;
}

.data-transfer-dialog label {
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-weight: 700;
}

.data-transfer-dialog textarea {
    font-family: monospace;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #EAE6DF;
    width: 100%;
    padding: 1.25rem;
    border-radius: 12px;
    outline: none;
    transition: border-color 0.3s ease;
    resize: none;
    line-height: 1.5;
}

.data-transfer-dialog .data-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}

.data-transfer-dialog .close-btn i {
    width: 24px;
    height: 24px;
}

.data-transfer-dialog .data-actions .glass-btn {
    height: 44px;
    font-size: 0.75rem;
}

.data-transfer-dialog .data-actions .glass-btn i {
    width: 14px;
    height: 14px;
    margin-right: 0.5rem;
}

.data-transfer-dialog .export-btn {
    border-color: #f59e0b;
    color: #f59e0b;
}

.data-transfer-dialog .primary-btn {
    grid-column: span 2;
    height: 50px;
    background: var(--accent-primary);
    color: #EAE6DF;
    font-weight: 900;
    letter-spacing: 0.15em;
    font-size: 0.85rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

details.management-menu summary {
    list-style: none;
    outline: none;
    cursor: pointer;
}

details.management-menu summary::-webkit-details-marker {
    display: none;
}

/* Grid responsive overrides — moved to shared-core.css (M6 Refactor) */


/* Ensure critical menu elements are interactive on all devices */
body.on-test-page .management-menu-content button {
    pointer-events: auto;
}

#test-gallery-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0.5rem 1.5rem 1rem 1.5rem;
    flex-grow: 1;
    overflow-y: auto;
    scrollbar-width: thin;
}

/* Flex layout only applies when dialog is active */
#character-gallery-dialog[open] {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
    padding: 0;
    animation: mastery-reveal 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.gallery-header-sticky {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(30, 30, 35, 0.98);
    z-index: 10;
}

#gallery-title {
    font-size: 1.5rem;
    line-height: 1;
    margin: 0;
}

.test-gallery-card {
    position: relative;
    padding: 1.25rem;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.test-gallery-card:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.test-gallery-card.active {
    border-color: color-mix(in srgb, var(--accent-primary) 70%, transparent);
    border-width: 2px;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 20px var(--accent-glow), inset 0 0 10px rgba(255, 255, 255, 0.05);
}

.test-gallery-card.new-char {
    border-style: dashed;
    border-color: rgba(255, 255, 255, 0.2);
    justify-content: center;
    align-items: center;
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
}

.test-gallery-card.new-char .card-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.test-gallery-card.new-char:hover {
    border-style: solid;
    border-color: color-mix(in srgb, var(--accent-primary) 70%, transparent);
    background: rgba(255, 255, 255, 0.05);
}

.test-gallery-card.active .char-name {
    color: var(--accent-primary);
}

.test-gallery-card .char-name {
    font-family: var(--font-secondary);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    transition: color 0.3s ease;
}

.test-gallery-card .char-meta {
    font-size: 0.65rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.test-gallery-card .char-avatar {
    margin-bottom: 0.75rem;
    color: var(--accent-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.8;
}

.test-gallery-card .char-avatar i {
    width: 24px;
    height: 24px;
}

.char-watermark {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    filter: grayscale(0.7) contrast(1.2);
    transition: all 0.3s ease;
}

.test-gallery-card:hover .char-watermark {
    opacity: 0.4;
    filter: grayscale(0.4) contrast(1.1);
}

.test-gallery-card.active .char-watermark {
    opacity: 0.5;
    filter: grayscale(0.2) contrast(1.1);
}

.char-watermark img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: right 35%;
    position: absolute;
    top: 0;
    right: 0;
}

.test-gallery-card .card-content {
    position: relative;
    z-index: 1;
}

/* --- Shared Modal System --- */
.modal-dialog {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2.5rem;
    color: #EAE6DF;
    width: 92%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    margin: 0;
    contain: content;
}

.modal-dialog:focus {
    outline: none;
}

@media (max-width: 480px) {
    .modal-dialog {
        padding: 2rem 1.5rem;
        width: 94%;
    }
}

.modal-dialog::backdrop {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-dialog.border-danger {
    border-color: #ef4444;
}

.modal-dialog.p-xl {
    padding: 3rem;
}

.modal-dialog.u-text-center {
    text-align: center;
}

/* Hold to Delete Interaction */
#test-delete-btn {
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, background-color 0.3s ease;
}

#test-delete-btn::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: rgba(239, 68, 68, 0.25);
    z-index: 0;
    pointer-events: none;
}

#test-delete-btn.holding {
    transform: scale(0.97);
    background: rgba(239, 68, 68, 0.1);
}

#test-delete-btn.holding::before {
    width: 100%;
    transition: width 1.75s linear;
}

#test-delete-btn * {
    position: relative;
    z-index: 1;
}



.gallery-empty-msg {
    color: var(--text-secondary);
    font-size: 0.7rem;
    opacity: 0.5;
    padding: 0.5rem;
    text-align: center;
}


/* --- End H4 Refactor --- */

/* --- E5: Class Selection Dialog (from index.html inline) --- */

#class-selection-dialog {
    border: 1px solid color-mix(in srgb, var(--accent-primary) 70%, transparent);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    position: relative;
}

.class-dialog-title {
    color: var(--accent-primary);
    margin-bottom: 0.5rem;
    text-align: center;
    font-size: 1.75rem;
}

#test-class-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 0.5rem;
    scrollbar-width: thin;
    scrollbar-gutter: stable both-edges;
}

#test-class-options:focus {
    outline: none;
}

.class-option-btn-layout {
    flex-direction: column;
    padding: 1.25rem 0.5rem;
    gap: 0.5rem;
    text-align: center;
    min-height: 80px;
}

.modal-btn-confirm {
    background: var(--accent-primary);
}

/* --- E7: Gallery Dialog (from index.html inline) --- */

#character-gallery-dialog {
    max-width: 600px;
}

.gallery-close-btn {
    padding: 0.8rem 2.5rem;
    font-size: 0.9rem;
    border-radius: 50px;
    width: auto;
    min-width: 180px;
}

.gallery-footer {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}
