.character-editor {
    display: grid;
    gap: 1rem;
}

.editor-banner-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 1rem;
}

.app-banner-shell {
    margin-bottom: 1rem;
}

.editor-banner-grid.single-banner {
    grid-template-columns: 1fr;
}

.editor-banner {
    display: flex;
    min-height: 90px;
    align-items: center;
    justify-content: center;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    padding: 0.6rem;
    box-shadow: var(--shadow);
}

.editor-banner a {
    display: block;
    width: 100%;
}

.editor-banner img {
    display: block;
    width: 100%;
    max-width: 100%;
    max-height: 190px;
    height: auto;
    object-fit: contain;
}

.sticky-save-bar {
    position: sticky;
    top: 4.5rem;
    z-index: 15;
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.96);
    padding: 0.75rem;
    box-shadow: var(--shadow);
}

.sticky-save-bar [data-save-status] {
    color: var(--muted);
    font-weight: 750;
}

.sticky-save-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: flex-end;
}

.sticky-save-bar [data-state="dirty"],
.sticky-save-bar [data-state="saving"] {
    color: #8b5e34;
}

.sticky-save-bar [data-state="error"] {
    color: var(--danger);
}

.editor-section {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 0;
    box-shadow: var(--shadow);
}

.editor-section > summary {
    min-height: 3.25rem;
    padding: 0.9rem 1rem;
    list-style-position: inside;
}

.editor-section > .form-grid,
.editor-section > .ability-grid,
.editor-section > .spellcasting-panel,
.editor-section > label {
    padding: 0 1rem 1rem;
}

.form-grid {
    display: grid;
    gap: 1rem;
}

.form-grid > .repeater,
.form-grid > .image-upload,
.form-grid > .radio-fieldset {
    min-width: 0;
}

.ability-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
}

fieldset {
    display: grid;
    gap: 0.75rem;
    min-width: 0;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.85rem;
}

legend {
    color: var(--accent-strong);
    font-weight: 800;
}

.radio-fieldset {
    align-content: start;
}

.radio-fieldset label {
    display: inline-flex;
    width: max-content;
    gap: 0.45rem;
    align-items: center;
    font-weight: 650;
}

.radio-fieldset input {
    width: auto;
}

.rich-source {
    display: none;
}

.rich-editor-wrap {
    display: grid;
    gap: 0;
    min-width: 0;
}

.rich-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    border: 1px solid #bec3bd;
    border-bottom: 0;
    border-radius: 6px 6px 0 0;
    background: #f8f9f6;
    padding: 0.4rem;
}

.rich-toolbar button {
    min-height: 2rem;
    border-color: var(--line);
    background: #fff;
    padding: 0.25rem 0.55rem;
}

.rich-editor {
    min-height: 7rem;
    overflow: auto;
    border: 1px solid #bec3bd;
    border-radius: 0 0 6px 6px;
    background: #fff;
    padding: 0.72rem 0.8rem;
    font-weight: 400;
}

.rich-editor:focus {
    outline: 2px solid rgba(31, 111, 104, 0.24);
    outline-offset: 2px;
}

.rich-editor p,
.rich-editor ul,
.rich-editor ol,
.rich-editor blockquote,
.long-text p,
.long-text ul,
.long-text ol,
.long-text blockquote,
.data-text p,
.data-text ul,
.data-text ol,
.data-text blockquote {
    margin-top: 0;
}

.repeater {
    display: grid;
    gap: 0.85rem;
    padding: 1rem;
}

.repeater-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.repeater-header h3 {
    margin: 0;
}

.repeater-list {
    display: grid;
    gap: 0.85rem;
}

.repeater-item {
    display: grid;
    gap: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf9;
    padding: 0.85rem;
}

.repeater-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    justify-content: flex-end;
}

.repeater-remove {
    justify-self: end;
}

.spellcasting-panel {
    display: grid;
    gap: 1rem;
}

.spellcasting-panel[hidden] {
    display: none;
}

.spellcasting-panel > .form-grid {
    padding: 0;
}

.spell-slot-panel {
    display: grid;
    gap: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf9;
    padding: 1rem;
}

.spell-slot-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
}

.image-upload {
    display: grid;
    gap: 0.75rem;
    margin: 1rem;
}

.image-preview {
    max-width: min(100%, 320px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 0.5rem;
}

.image-preview img {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: contain;
}

@media (min-width: 780px) {
    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid label:has(textarea),
    .form-grid > .repeater,
    .form-grid > .image-upload {
        grid-column: span 2;
    }
}

@media (max-width: 700px) {
    .editor-banner-grid {
        grid-template-columns: 1fr;
    }

    .editor-banner {
        min-height: 70px;
    }

    .editor-banner img {
        max-height: 160px;
    }
}
