.editor-container {
    --editor-accent: var(--room-switch-accent, #4678f9);
    --editor-toolbar-surface: rgba(18, 18, 21, 0.88);
    --editor-control-surface: rgba(255, 255, 255, 0.06);
    z-index: 5;
    position: absolute;
    container-type: inline-size;
    container-name: editor;
    padding: 10px;
    width: var(--editor-container-width);
    height: var(--editor-container-height);
    border: var(--border);
    border-radius: 10px;
    background: var(--body-bg);
    box-shadow: var(--box-shadow);
    overflow-x: hidden;
    overflow-y: auto;
    transition: max-width 0.5s ease-in-out;
}

.editor-header {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-sizing: border-box;
    text-align: left;
    min-height: 48px;
    padding: 5px 6px;
    margin-bottom: 6px;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    background: var(--editor-toolbar-surface);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(14px);
    color: #ffffff;
    cursor: move;
}

.editor-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 0 4px;
}

.editor-title-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 7px;
    background: color-mix(in srgb, var(--editor-accent) 14%, transparent);
    color: var(--editor-accent);
}

.editor-title-text {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0;
    white-space: nowrap;
}

.editor-header-btns {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    margin-left: auto;
}

.editor-tool-group {
    display: flex;
    align-items: center;
    gap: 2px;
    min-height: 36px;
    padding: 2px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 8px;
    background: var(--editor-control-surface);
}

.editor-header-btns button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
    border: none !important;
    border-radius: 6px;
    background: transparent;
    color: #ffffff;
    font-size: 0.88rem;
    cursor: pointer;
    transition:
        background 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease;
}

.editor-header-btns button.hidden {
    display: none;
}

.editor-header-btns button:hover {
    background: rgba(255, 255, 255, 0.11);
}

.editor-header-btns button:focus-visible {
    outline: 2px solid var(--editor-accent);
    outline-offset: 2px;
}

.editor-header-btns button.is-active,
.editor-header-btns button[aria-pressed='true'] {
    background: color-mix(in srgb, var(--editor-accent) 18%, transparent);
    color: var(--editor-accent) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--editor-accent) 40%, transparent);
}

.editor-compact-menu {
    display: none;
}

.editor-compact-menu .dropdown-menu {
    width: 190px;
    max-width: calc(100vw - 16px);
    padding: 8px;
    box-sizing: border-box;
}

.editor-compact-menu .dropdown-menu button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 38px;
    padding: 9px 10px;
    gap: 8px;
    white-space: nowrap;
}

.editor-compact-menu .dropdown-menu .editor-narrow-action {
    display: none;
}

@media (max-width: 560px) {
    .editor-container {
        padding: 5px;
        border-radius: 8px;
    }
}

@container editor (max-width: 560px) {
    .editor-header {
        gap: 4px;
        min-height: 38px;
        padding: 2px;
    }

    .editor-title-text {
        display: none;
    }

    .editor-title-mark {
        width: 28px;
        height: 28px;
        flex-basis: 28px;
    }

    .editor-header-title {
        gap: 2px;
        padding: 0;
    }

    .editor-header-btns {
        gap: 3px;
    }

    .editor-tool-group {
        min-height: 30px;
        padding: 0;
        border: none;
        background: transparent;
    }

    .editor-session-tools {
        order: 1;
    }

    .editor-history-tools {
        order: 2;
    }

    .editor-document-tools {
        order: 3;
    }

    .editor-compact-menu {
        order: 4;
    }

    #editorCloseBtn {
        order: 5;
    }

    .editor-header-btns button {
        width: 28px;
        min-width: 28px;
        height: 28px;
        padding: 5px;
        font-size: 0.75rem;
    }

    .editor-document-tools > #editorCopyBtn,
    .editor-document-tools > #editorSaveBtn,
    .editor-document-tools > #editorCleanBtn {
        display: none !important;
    }

    .editor-compact-menu {
        display: inline-flex;
    }
}

@container editor (max-width: 340px) {
    .editor-history-tools > #editorUndoBtn,
    .editor-history-tools > #editorRedoBtn {
        display: none !important;
    }

    .editor-compact-menu .dropdown-menu .editor-narrow-action {
        display: flex;
    }
}

.editor {
    height: var(--editor-height) !important;
    color: white !important;
    border-radius: 0px 0px 10px 10px; /* Top-left, top-right, bottom-right, bottom-left */
    border: var(--border) !important;
    box-shadow: var(--box-shadow) !important;
}

.ql-toolbar {
    background: rgba(0, 0, 0, 0.4) !important;
    color: white !important;
    border-radius: 10px 10px 0px 0px; /* Top-left, top-right, bottom-right, bottom-left */
    border: var(--border) !important;
    margin-top: 6px;
}

/* Optional: Customize code block appearance */
.ql-snow .ql-code-block-container {
    padding: 4px !important;
    font-family: monospace;
    margin-bottom: 20px !important;
    border-radius: 4px !important;
    /* border: var(--border) !important; */
    background: var(--select-bg) !important;
    box-shadow: var(--box-shadow) !important;
}

.ql-snow .ql-code-block {
    font-family: monospace;
}

/* Private Note mode visual indicator (local-only editor, not broadcasted) */
.editor-container.editor-private-mode {
    box-shadow:
        inset 3px 0 0 0 #ffb300,
        var(--box-shadow);
}
.editor-container.editor-private-mode .editor-title-mark {
    background: rgba(255, 179, 0, 0.14);
    color: #ffb300;
}
.editor-container.editor-private-mode .editor-title-text::after {
    content: ' · Private note';
    color: #ffb300;
}
.editor-container.editor-private-mode #editorPrivateBtn {
    color: #ffb300 !important;
}
/* In private mode hide media/embed toolbar buttons to keep notes light (text-only) */
.editor-container.editor-private-mode .ql-toolbar .ql-image,
.editor-container.editor-private-mode .ql-toolbar .ql-video,
.editor-container.editor-private-mode .ql-toolbar .ql-formula,
.editor-container.editor-private-mode .ql-toolbar .ql-code-block {
    display: none !important;
}

.ql-toolbar button:hover {
    background: var(--body-bg) !important;
}

.ql-picker-options {
    color: white;
    border: none !important;
    border-radius: 14px;
    background: var(--body-bg);
    box-shadow: var(--box-shadow) !important;
}

select.ql-ui {
    padding: 5px 10px !important;
    color: #fff !important;
    height: 30px;
    border: var(--border);
    border-radius: var(--select-border-radius);
    background-color: var(--select-bg) !important;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

select.ql-ui:focus,
select.ql-ui:focus-visible {
    outline: none;
    border-color: var(--select-focus-color);
    box-shadow: 0 0 0 2px var(--select-focus-color);
}
