.scene-selector {
    max-width: 360px;
}

.scene-savebar {
    position: sticky;
    top: 76px;
    z-index: 10;
    background: var(--bs-body-bg, #111827);
    padding: 12px;
    border: 1px solid var(--bs-border-color, #394255);
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.scene-admin {
    max-width: 1120px;
}

.scene-edit-section {
    margin: 14px 0;
    border: 1px solid var(--bs-border-color, #394255);
    border-radius: 16px;
    background: var(--bs-body-bg);
}

.scene-admin details > summary {
    list-style: none;
    cursor: pointer;
}

    .scene-admin details > summary::-webkit-details-marker {
        display: none;
    }

    .scene-admin details > summary::after {
        content: "";
        width: 8px;
        height: 8px;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        margin: 0 4px 4px auto;
        flex: 0 0 8px;
        opacity: .6;
    }

.scene-admin details[open] > summary::after {
    transform: rotate(225deg);
    margin-bottom: -4px;
}

.scene-admin details > summary:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 3px;
    border-radius: 10px;
}

.scene-edit-section > summary {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 20px 24px;
}

    .scene-edit-section > summary strong {
        display: block;
        font-size: 1.1rem;
    }

    .scene-edit-section > summary small, .scene-item-heading small {
        display: block;
        margin-top: 4px;
        color: var(--bs-secondary-color, #788397);
        font-weight: normal;
    }

.scene-section-body {
    padding: 4px 24px 24px;
}

.scene-field-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 8px;
}

    .scene-field-heading strong {
        font-size: .9rem;
        font-weight: 600;
    }

    .scene-field-heading button {
        flex-shrink: 0;
    }

.scene-markdown-field {
    margin-top: 18px;
}

.scene-text-preview {
    padding: 12px 16px;
    border-radius: 10px;
    background: var(--bs-tertiary-bg, rgba(128,128,128,.08));
}

.scene-text-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-line;
    overflow-wrap: anywhere;
    margin: 0;
    color: var(--bs-secondary-color, #788397);
    line-height: 1.6;
    max-height: 4.8em;
}

    .scene-text-excerpt.is-empty {
        font-style: italic;
    }

.scene-settings-group {
    margin-top: 18px;
}

    .scene-settings-group > summary, .scene-translation > summary {
        display: flex;
        align-items: center;
        gap: 12px;
        font-size: .9rem;
        color: var(--bs-secondary-color, #788397);
        padding: 10px 0;
    }

.scene-translation {
    margin-top: 10px;
}

    .scene-translation[hidden] {
        display: none;
    }

.scene-card-editor {
    border: 1px solid var(--bs-border-color, #394255);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
}

.scene-item-summary {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
}

.scene-item-heading {
    min-width: 0;
    flex: 1;
}

    .scene-item-heading strong {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-weight: 600;
        font-size: .95rem;
    }

.scene-item-thumbnail, .scene-image-thumbnail {
    width: 76px;
    height: 50px;
    border-radius: 6px;
    background: var(--bs-tertiary-bg, rgba(128,128,128,.08));
    flex-shrink: 0;
    object-fit: contain;
}

.scene-item-thumbnail {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

    .scene-item-thumbnail img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

.scene-item-body {
    padding: 6px 18px 18px;
}

.scene-card-gallery {
    margin-top: 24px;
}

    .scene-card-gallery > h3 {
        font-size: .95rem;
        font-weight: 600;
        margin-bottom: 12px;
    }

.scene-image-editor {
    border: 1px solid var(--bs-border-color, #394255);
    border-radius: 10px;
    margin: 8px 0;
}

.scene-item-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    border-top: 1px solid var(--bs-border-color, #394255);
    margin-top: 20px;
    padding-top: 16px;
}

#sceneStatus:empty {
    display: none;
}

.scene-media-library {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

    .scene-media-library img {
        width: 100%;
        aspect-ratio: 16/10;
        object-fit: contain;
    }

.scene-markdown-form {
    display: flex;
    flex-direction: column;
}

#wikiArticleModal, #sceneMediaModal, #scenePreviewModal {
    z-index: 10050;
}

#wikiArticleModal {
    scroll-padding-top: calc(var(--scene-toolbar-height, 60px) + 12px);
    scroll-padding-bottom: calc(var(--scene-footer-height, 74px) + 12px);
}

    #wikiArticleModal .modal-content, #sceneMediaModal .modal-content, #scenePreviewModal .modal-content {
        background: var(--bs-body-bg, #fff);
        color: var(--bs-body-color, #17243c);
    }

    #wikiArticleModal .modal-header, #wikiArticleModal .modal-footer {
        flex-shrink: 0;
    }

    #wikiArticleModal .modal-header {
        flex-wrap: wrap;
        gap: .75rem;
    }

    #wikiArticleModal .modal-title {
        flex: 1 1 12rem;
        min-width: 0;
    }

    #wikiArticleModal .modal-header .btn-close {
        margin: 0;
    }

    #wikiArticleModal .modal-footer {
        position: sticky;
        bottom: 0;
        z-index: 20;
        background: var(--bs-body-bg, #fff);
        box-shadow: 0 -6px 16px rgba(0,0,0,.08);
    }

.scene-editor-modes {
    flex-shrink: 0;
}

.scene-markdown-form > .modal-body {
    overflow: visible;
    flex: 0 0 auto;
}

.scene-markdown-form .wiki-editor-toolbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--bs-secondary-bg, #e9ecef);
    box-shadow: 0 6px 16px rgba(0,0,0,.08);
}

.scene-markdown-form .wiki-editor-grid {
    overflow: visible;
}

.scene-markdown-form .wiki-visual-editor,
.scene-markdown-form #wikiArticleBody,
.scene-markdown-form .wiki-preview {
    height: auto;
    min-height: 320px;
    max-height: none;
}

.scene-markdown-form .wiki-visual-editor,
.scene-markdown-form .wiki-preview {
    overflow: visible;
}

.scene-markdown-form #wikiArticleBody {
    overflow-y: hidden;
}

.scene-article .wiki-markdown {
    margin-top: 28px;
}

.scene-article .wiki-markdown a[href]:not(.btn) {
    color: #78a9ff;
    text-decoration-line: underline;
    text-decoration-thickness: .08em;
    text-underline-offset: .2em;
}

.scene-article .wiki-markdown a[href]:not(.btn):is(:hover, :focus-visible) {
    color: #9fc3ff;
}

html[data-bs-theme="light"] .scene-article .wiki-markdown a[href]:not(.btn) {
    color: #1d65c1;
}

html[data-bs-theme="light"] .scene-article .wiki-markdown a[href]:not(.btn):is(:hover, :focus-visible) {
    color: #154b91;
}

.scene-article {
    overflow-wrap: anywhere;
}

    .scene-article [data-scene-back] {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .scene-article .wiki-markdown :is(h1,h2,h3,h4,h5,h6) {
        scroll-margin-top: 120px;
    }

    .scene-article .wiki-markdown table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }

    .scene-article .case-toc {
        max-height: calc(100vh - 150px);
        overflow: auto;
    }

    .scene-article .scene-article-contents {
        display: block;
    }

        .scene-article .scene-article-contents[hidden] {
            display: none;
        }

.scene-article-contents > summary.toc-title {
    display: list-item;
    padding: 10px 8px;
    min-height: 44px;
    cursor: pointer;
    font-size: .95rem;
}

.scene-article-contents > summary:focus-visible {
    outline: 2px solid #4d8dff;
    outline-offset: 2px;
    border-radius: 8px;
}

.scene-toc-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.scene-article .case-toc a {
    display: flex;
    align-items: center;
    min-height: 44px;
}

    .scene-article .case-toc a[aria-current] {
        border-color: #4d8dff;
        color: #8ab6ff;
    }

html[data-bs-theme="light"] .scene-article .case-toc a[aria-current] {
    color: #1858b5;
}

@media (max-width: 992px) {
    .scene-article .case-side {
        position: static;
        grid-row: 1;
        min-width: 0;
    }

    .scene-article .case-toc {
        max-height: none;
    }
}

@media (max-width: 767px) {
    .scene-savebar {
        top: auto;
        position: static;
    }

    .scene-edit-section > summary {
        padding: 16px;
    }

    .scene-section-body {
        padding: 0 16px 16px;
    }

    .scene-item-body {
        padding: 4px 12px 12px;
    }

    .scene-item-summary {
        padding: 12px;
        gap: 10px;
    }

    .scene-item-thumbnail, .scene-image-thumbnail {
        width: 56px;
        height: 42px;
    }

    .scene-savebar {
        gap: 10px;
    }

    .scene-field-heading {
        gap: 8px;
    }

    .scene-article {
        grid-template-columns: 1fr;
    }

        .scene-article .case-side {
            position: static;
            grid-row: 1;
        }
}

@media (max-width: 575px) {
    .scene-editor-modes {
        order: 1;
        width: 100%;
    }

    .scene-markdown-form .wiki-editor-toolbar__group {
        flex-wrap: wrap;
    }
}
