.markdown-editor {
    display: flex;
    flex-direction: column;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--control-radius);
    background: var(--input-bg);
    color: var(--text-primary);
    overflow: hidden;
    resize: both;
}

.markdown-editor:focus-within {
    border-color: var(--accent-blue);
}

.markdown-editor-ribbon {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0;
    height: var(--markdown-ribbon-height);
    box-sizing: border-box;
    padding: 3px 4px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    user-select: none;
}

.markdown-editor-separator {
    width: 1px;
    height: 16px;
    background: var(--border-color);
    flex-shrink: 0;
    margin: 0 1px;
}

.markdown-editor-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 3px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

.markdown-editor-button svg {
    width: 15px;
    height: 15px;
    display: block;
}

.markdown-editor-text-button {
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.markdown-editor-text-button.italic {
    font-style: italic;
    font-weight: 600;
}

.markdown-editor-text-button.underline {
    text-decoration: underline;
}

.markdown-editor-text-button.strike {
    text-decoration: line-through;
}

.markdown-editor-text-button.heading {
    font-size: 11px;
    letter-spacing: -0.03em;
}

.markdown-editor-button:hover:not(:disabled) {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.markdown-editor-button[aria-pressed="true"] {
    background: var(--bg-primary);
    color: var(--accent-blue);
}

.markdown-editor-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.markdown-editor-surface {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: var(--control-padding);
    outline: none;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.markdown-editor-surface div {
    min-height: 1.4em;
}

.markdown-editor-surface h1,
.markdown-editor-surface h2,
.markdown-editor-surface h3 {
    font-weight: 700;
    margin: 0.1rem 0;
    min-height: 1.2em;
}

.markdown-editor-surface h1 { font-size: 1.3rem; }
.markdown-editor-surface h2 { font-size: 1.12rem; }
.markdown-editor-surface h3 { font-size: 1rem; }

.markdown-editor-surface ul,
.markdown-editor-surface ol {
    margin: 0.15rem 0 0.15rem 1.4rem;
    padding: 0;
}

.markdown-editor-surface li {
    margin: 0;
}

.markdown-editor-surface blockquote {
    margin: 0.15rem 0;
    padding-left: 0.6rem;
    border-left: 3px solid var(--accent-blue);
    color: var(--text-secondary);
}

.markdown-editor-surface pre {
    margin: 0.2rem 0;
    padding: 0.35rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-family: Consolas, monospace;
    white-space: pre-wrap;
}

.markdown-editor-surface code {
    font-family: Consolas, monospace;
    background: var(--bg-tertiary);
    padding: 0 0.2rem;
    border-radius: 3px;
}

.markdown-editor-surface pre code {
    background: transparent;
    padding: 0;
}

.markdown-editor-surface a {
    color: var(--accent-blue);
    text-decoration: underline;
}

.markdown-editor-surface hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0.4rem 0;
}

.modal.read-only .markdown-editor,
.markdown-editor.is-disabled {
    resize: none;
}

.markdown-editor.is-disabled .markdown-editor-surface {
    cursor: default;
    opacity: 0.8;
}
