.rich-text-editor {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-surface);
    color: var(--text-primary);
}

.rte-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
}

.rte-toolbar-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
}

.rte-toolbar-button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.rte-toolbar-button.active {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-border);
}

.rte-editor-container {
    position: relative;
    flex: 1;
    min-height: 200px;
    overflow-y: auto;
}

.rte-editor {
    width: 100%;
    height: 100%;
    padding: 12px;
    outline: none;
    min-height: inherit;
}

.rte-editor[contenteditable="true"]:empty:before {
    content: attr(data-placeholder);
    color: var(--text-tertiary);
    pointer-events: none;
}

.rte-markdown {
    width: 100%;
    height: 100%;
    padding: 12px;
    border: none;
    resize: none;
    outline: none;
    font-family: monospace;
    background: var(--bg-surface);
    color: var(--text-primary);
}

.rte-editor.is-hidden,
.rte-markdown.is-hidden {
    display: none;
}

@layer components {
    .rich-text-editor {
        --bg-surface: #ffffff;
        --bg-secondary: #f9fafb;
        --bg-hover: #f3f4f6;
        --text-primary: #111827;
        --text-secondary: #4b5563;
        --text-tertiary: #9ca3af;
        --border-primary: #e5e7eb;
        --primary: #3b82f6;
        --primary-light: #eff6ff;
        --primary-border: #bfdbfe;
        --radius-sm: 4px;
        --radius-md: 6px;
    }

    :is(.jsgui-dark-mode, [data-theme="dark"]) .rich-text-editor {
        --bg-surface: #1f2937;
        --bg-secondary: #374151;
        --bg-hover: #4b5563;
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --text-tertiary: #6b7280;
        --border-primary: #374151;
        --primary: #60a5fa;
        --primary-light: #1e3a8a;
        --primary-border: #2563eb;
    }
}