.document-email-dialog {
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    box-sizing: border-box;
    overflow: hidden;
    border: 1px solid #dce3e9;
    border-radius: 20px;
    padding: 24px;
    color: inherit;
    background: #fff;
    box-shadow: 0 24px 80px #14223133;
}
.document-email-dialog[open] { display: flex; flex-direction: column; }
.document-email-dialog::backdrop { background: #14223180; }
.document-email-dialog__toolbar {
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
    background: #fff;
    padding-bottom: 12px;
}
.document-email-dialog [data-email-content] {
    display: grid;
    align-content: start;
    gap: 16px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
}
.document-email-dialog [data-email-content] > .section-heading { margin-bottom: 0; }
[data-document-send-form] { display: grid; gap: 12px; }
.document-menu { display: flex; flex-wrap: wrap; gap: 8px; max-height: 210px; overflow-y: auto; padding: 4px 2px; animation: document-menu-in .22s ease-out; }
.space-document-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; padding-top: 4px; }
.space-document-actions .document-chip { box-sizing: border-box; }
.document-menu[hidden], [data-custom-editor][hidden], [data-custom-confirmation][hidden] { display: none !important; }
.object-plan-popup.has-document-menu { width: min(380px, calc(100% - 24px)); max-width: calc(100% - 24px); }
.document-chip { display: inline-flex; align-items: center; justify-content: center; padding: 9px 13px; border-radius: 9px; border: 1px solid color-mix(in srgb, var(--document-color, #fff2f2) 65%, #555); background: var(--document-color, #fff2f2); color: var(--document-ink, #b8322b) !important; font-weight: 700; text-decoration: none; font-size: 14px; max-width: 100%; overflow-wrap: anywhere; transition: transform .15s, box-shadow .15s; }
.document-chip:hover { transform: translateY(-2px); box-shadow: 0 4px 10px #14223120; }
@keyframes document-menu-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.custom-document-dialog { transition: width .2s; }
.custom-document-dialog.is-editing { width: min(1100px, calc(100vw - 24px)); }
.custom-document-dialog.is-editing [data-email-content] { display: block; }
.custom-document-dialog [data-email-content], .custom-document-dialog form, [data-custom-editor], .docx-toolbar, .docx-workspace { min-width: 0; max-width: 100%; box-sizing: border-box; }
.custom-template-settings { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 12px 0; }
.custom-template-settings label:first-of-type { flex: 1; min-width: 160px; }
.custom-template-settings label { display: grid; gap: 6px; }
.custom-template-settings input[type=color], input[data-edit-color] { width: 44px; height: 38px; padding: 3px; }
.docx-editor-heading, .docx-editor-footer { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.docx-editor-heading h2 { margin: 0; font-size: 24px; line-height: 1.3; }
.docx-editor-heading [data-editor-save-state], .docx-editor-footer span { font-size: 13px; color: #627184; }
.docx-toolbar { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; border: 1px solid #dbe1e7; border-radius: 10px 10px 0 0; padding: 10px; background: #f8fafc; }
.docx-toolbar button { min-width: 34px; min-height: 36px; border: 1px solid #dce3e9; background: white; color: #17212b; border-radius: 6px; cursor: pointer; }
.docx-toolbar button:hover { background: #eaf2ff; }
.docx-toolbar select { width: auto; max-width: 155px; min-height: 36px; padding: 4px 8px; }
.docx-toolbar input[type=color][data-edit-color] { width: 38px; min-width: 38px; max-width: 38px; flex: 0 0 38px; height: 36px; padding: 3px; }
.docx-toolbar select[data-edit-font] { width: 175px; max-width: 175px; min-width: 0; }
.docx-toolbar select[data-edit-size] { width: 60px; max-width: 60px; min-width: 0; }
.docx-workspace { overflow: auto; max-height: 55dvh; padding: 24px; background: #e9edf2; border: 1px solid #dbe1e7; }
.docx-paper { box-sizing: border-box; width: 794px; max-width: 100%; min-height: 500px; margin: auto; padding: 55px 60px; color: #17212b; background: #fff; box-shadow: 0 2px 12px #14223118; font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 1.5; outline: none; overflow-wrap: anywhere; white-space: pre-wrap; }
.docx-paper p { min-height: 1.5em; margin: 0 0 8pt; font: inherit; color: inherit; }
.docx-paper table { border-collapse: collapse; width: 100%; min-width: 0; table-layout: fixed; }
.docx-paper td { border: 1px solid #bfc7d0; padding: 6px; min-width: 24px; vertical-align: top; }
.docx-paper tr, .docx-paper tr:hover { background: transparent; }
.docx-paper tr:last-child td { border-bottom: 1px solid #bfc7d0; }
.docx-paper [data-numbered]::before { content: '• '; color: #7c8794; }
.docx-protected { display: inline-block; padding: 3px 6px; background: #f1f4f8; border: 1px dashed #adb8c5; border-radius: 4px; color: #5d6c7e; font: 12px/1.5 sans-serif; user-select: none; }
.docx-editor-footer { margin-top: 14px; }
.docx-paper table, .docx-paper tbody, .docx-paper tr, .docx-paper td { max-height: none; height: auto; overflow: visible; }
@media (prefers-reduced-motion: reduce) { .document-menu, .custom-document-dialog, .document-chip { animation: none; transition: none; } }
.document-email-dialog form { display: grid; gap: 16px; }
@media (max-width: 600px) {
    .document-email-dialog { padding: 16px; }
    .document-email-dialog .form-grid, .document-email-dialog .definition-grid { grid-template-columns: 1fr; }
    .docx-workspace { padding: 8px; }
    .docx-paper { padding: 24px 16px; min-height: 360px; }
    .docx-editor-heading, .docx-editor-footer { align-items: flex-start; flex-direction: column; }
    .docx-editor-footer .btn { width: 100%; }
    .custom-document-dialog form { min-width: 0; }
    .docx-editor-heading { gap: 8px; }
    .docx-toolbar { gap: 4px; padding: 7px; }
    .docx-toolbar button { padding: 4px 8px; min-height: 32px; min-width: 32px; }
    .docx-editor-footer { position: sticky; bottom: 0; padding: 10px 0; background: #fff; z-index: 3; }
}
