.cmr-dialog {
    --cmr-surface: #ffffff;
    --cmr-subtle: #f5f5f4;
    --cmr-ink: #1c1917;
    --cmr-ink-2: #57534e;
    --cmr-line: #d6d3d1;
    --cmr-accent: #2563eb;
    --cmr-send: #1f5f3b;
    --cmr-send-hover: #174a2e;
    --cmr-added-bg: #dcfce7;
    --cmr-added-ink: #166534;
    --cmr-removed-bg: #fee2e2;
    --cmr-removed-ink: #991b1b;
    width: min(640px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    padding: 0;
    border: 1px solid var(--cmr-line);
    border-radius: 12px;
    background: var(--cmr-surface);
    color: var(--cmr-ink);
    font-size: 14px;
}

:root[data-theme="dark"] .cmr-dialog {
    --cmr-surface: #1f1f1d;
    --cmr-subtle: #2a2a27;
    --cmr-ink: #f5f5f4;
    --cmr-ink-2: #a8a29e;
    --cmr-line: #44403c;
    --cmr-accent: #60a5fa;
    --cmr-send: #2f8a57;
    --cmr-send-hover: #38a165;
    --cmr-added-bg: #14532d;
    --cmr-added-ink: #bbf7d0;
    --cmr-removed-bg: #7f1d1d;
    --cmr-removed-ink: #fecaca;
}

.cmr-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.cmr-panel { display: flex; flex-direction: column; gap: 12px; padding: 16px 20px; }
.cmr-head { display: flex; align-items: center; justify-content: space-between; }
.cmr-title { margin: 0; font-size: 16px; font-weight: 600; }
.cmr-close { border: 0; background: none; color: var(--cmr-ink-2); font-size: 22px; line-height: 1; cursor: pointer; }
.cmr-label { display: block; margin: 0 0 6px; font-size: 12px; color: var(--cmr-ink-2); }
.cmr-loading { margin: 24px 0; text-align: center; color: var(--cmr-ink-2); }
.cmr-error { margin: 0; color: var(--cmr-removed-ink); background: var(--cmr-removed-bg); border-radius: 8px; padding: 8px 12px; }
.cmr-diff { max-height: 180px; overflow-y: auto; margin-bottom: 12px; padding: 10px 12px; border-radius: 8px; background: var(--cmr-subtle); line-height: 1.8; white-space: pre-wrap; }
.cmr-diff ins { background: var(--cmr-added-bg); color: var(--cmr-added-ink); text-decoration: none; border-radius: 3px; padding: 0 2px; }
.cmr-diff del { background: var(--cmr-removed-bg); color: var(--cmr-removed-ink); border-radius: 3px; padding: 0 2px; }
.cmr-choices { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 12px; }
.cmr-choice { display: block; text-align: left; padding: 10px 12px; border: 1px solid var(--cmr-line); border-radius: 8px; background: var(--cmr-surface); color: var(--cmr-ink); cursor: pointer; }
.cmr-choice[aria-pressed="true"] { border-color: var(--cmr-accent); box-shadow: 0 0 0 1px var(--cmr-accent); }
.cmr-choice-text { display: block; max-height: 120px; overflow-y: auto; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.cmr-final { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--cmr-line); border-radius: 8px; background: var(--cmr-surface); color: var(--cmr-ink); font: inherit; resize: vertical; }
.cmr-foot { display: flex; justify-content: flex-end; gap: 8px; }
.cmr-secondary, .cmr-send { padding: 6px 14px; border-radius: 6px; font: inherit; font-weight: 500; cursor: pointer; }
.cmr-secondary { border: 1px solid var(--cmr-line); background: var(--cmr-surface); color: var(--cmr-ink); }
.cmr-send { border: 0; background: var(--cmr-send); color: #ffffff; }
.cmr-send:hover { background: var(--cmr-send-hover); }

@media (max-width: 520px) {
    .cmr-choices { grid-template-columns: minmax(0, 1fr); }
}

/* Rich composer (static/js/rich-composer.js): a Markdown message shown formatted,
   in the thread composer, the review dialog and its Original / AI rewrite choices. */
.rc-editor { overflow-wrap: anywhere; cursor: text; }
.rc-editor:focus { outline: none; }
.rc-editor ul, .cmr-choice-text ul { list-style: disc; margin: 2px 0; padding-left: 22px; }
.rc-editor ol, .cmr-choice-text ol { list-style: decimal; margin: 2px 0; padding-left: 22px; }
.rc-editor blockquote, .cmr-choice-text blockquote { margin: 2px 0; padding-left: 10px; border-left: 3px solid var(--line, #d6d3d1); color: var(--ink-3, #57534e); }
.rc-editor a, .cmr-choice-text a { text-decoration: underline; }
.rc-editor .rc-image, .cmr-choice-text .rc-image { display: block; max-width: min(100%, 320px); max-height: 200px; margin: 4px 0; border: 1px solid var(--line, #d6d3d1); border-radius: 6px; object-fit: contain; }
.rc-editor .rc-image:hover { outline: 2px solid var(--accent, #2563eb); outline-offset: 1px; }
.rc-editor .rc-token, .cmr-choice-text .rc-token { color: var(--accent, #2563eb); font-weight: 600; }
.rc-editor .rc-file, .cmr-choice-text .rc-file { display: inline-block; margin: 2px 0; padding: 1px 8px; border: 1px solid var(--line, #d6d3d1); border-radius: 6px; font-size: 12px; font-weight: 600; }
.cmr-choice-text { white-space: normal; }
.cmr-final.rc-editor { min-height: 96px; max-height: 280px; overflow-y: auto; resize: none; }
.cmr-final.rc-editor:focus { border-color: var(--cmr-accent); box-shadow: 0 0 0 1px var(--cmr-accent); }
