/* Canonical dialog tokens. Load after module styles. See docs/DIALOG_DESIGN.md. */
:root {
    --dialog-radius: 8px;
    --dialog-space: 24px;
    --dialog-line: var(--pk-legacy-color-cbd3da);
    --dialog-chrome: var(--pk-legacy-color-f4f6f8);
    --dialog-shadow: 0 16px 48px rgb(24 39 51 / 20%), 0 2px 8px rgb(24 39 51 / 8%);
}
body :is(dialog, .pk-dialog, .ws-modal, .ava-dialog).pk-modal-frame {
    box-sizing: border-box;
    border: 1px solid var(--dialog-line);
    border-radius: var(--dialog-radius);
    background: var(--pk-legacy-color-fff);
    color: var(--pk-legacy-color-202b35);
    box-shadow: var(--dialog-shadow);
    font-family: var(--font, "DINOT", sans-serif);
    font-size: 14px;
    line-height: 1.5;
    max-width: calc(100vw - 32px);
    max-height: calc(100dvh - 32px);
    overscroll-behavior: contain;
}
body dialog.pk-modal-frame { position: fixed; inset: 0; margin: auto; }
body .pk-modal-frame.pk-modal-padded { padding: var(--dialog-space); overflow: auto; }
body .pk-modal-frame:not(.pk-modal-padded) { padding: 0; }
/* Compact destination pickers keep their actions outside the scrolling content. */
body dialog.pk-modal-frame.pk-modal-compact { width:620px; padding:0; overflow:hidden; }
body .pk-modal-compact>:is(form,.pk-modal-layout) { display:flex; flex-direction:column; max-height:calc(100dvh - 34px); margin:0; }
body .pk-modal-compact .pk-modal-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; position:static; margin:0; padding:14px var(--dialog-space); }
body .pk-modal-compact .pk-modal-content { flex:1 1 auto; min-height:0; overflow:auto; padding:16px var(--dialog-space); }
body .pk-modal-compact .pk-modal-actions { position:static; margin:0; padding:14px var(--dialog-space); }
body .pp-create.pk-modal-frame { height: min(800px, calc(100dvh - 32px)); }
body .pk-modal-frame::backdrop { background: rgb(22 33 43 / 36%); }
body :is(.pk-dialog-back, .ws-modal-overlay, .ava-dialog-backdrop) { background: rgb(22 33 43 / 36%); padding: 16px; }
body .pk-modal-frame .pk-modal-heading {
    position: sticky; top: 0; z-index: 3;
    box-sizing: border-box; flex-shrink: 0;
    padding: 16px var(--dialog-space);
    margin: 0;
    border-bottom: 1px solid var(--pk-legacy-color-e1e6eb);
    background: var(--dialog-chrome);
    color: var(--pk-legacy-color-202b35);
    font: 600 18px/1.4 var(--font, "DINOT", sans-serif);
}
body .pk-modal-padded .pk-modal-heading {
    top: -24px; margin: -24px -24px 24px; padding-right: 60px;
}
body .pk-modal-frame .pk-modal-heading :is(h1,h2,h3) { margin: 0; font: inherit; }
body .pk-modal-frame .pk-modal-actions {
    position: sticky; bottom: 0; z-index: 2;
    display: flex; flex: 0 0 auto; flex-wrap: wrap; align-items: center; justify-content: flex-end;
    gap: 8px; padding: 16px var(--dialog-space); margin: 0;
    border-top: 1px solid var(--pk-legacy-color-e1e6eb); background: var(--dialog-chrome);
    grid-column: 1 / -1;
}
body .pk-modal-padded .pk-modal-actions {
    bottom: -24px; margin: 24px -24px -24px;
}
body .pk-modal-frame :is(.crm-dialog-body, .pc-body, .emp-p-body, .task-create-fields, .pp-complete-body) { padding: var(--dialog-space); min-height: 0; }
body .ava-gaeb-dialog.pk-modal-frame form { padding: 0; }
body .task-dialog.pk-modal-frame .task-dialog-header { display: flex; }
body .task-dialog.pk-modal-frame .task-dialog-header h2 { flex: 1; text-align: left; }
body .task-dialog.pk-modal-frame .task-cancel { background: transparent; color: var(--pk-legacy-color-52616d); }
body .pk-modal-frame :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]):not([type=range]):not([type=color]), select, textarea) {
    box-sizing: border-box; min-height: 40px; border: 1px solid var(--dialog-line); border-radius: 4px;
    background: var(--pk-legacy-color-fff); color: inherit; font-family: inherit; font-size: 14px;
}
body .pk-modal-frame :is(input, select, textarea, button, a):focus-visible {
    outline: 2px solid var(--accent, var(--pk-legacy-color-087e8b)); outline-offset: 2px;
}
body .pk-modal-frame :is(button, .btn, .ava-dialog-button) {
    min-height: 40px; height: auto; border-radius: 4px; font-family: inherit; font-size: 14px;
}
body .pk-modal-frame .pk-modal-actions :is(button, .btn, .ava-dialog-button) { padding: 8px 18px; margin: 0; }
body .pk-modal-frame .pk-modal-actions :is(.muted, small) { margin-right: auto; }
body .pk-modal-frame :is(.secondary, .ws-btn-sec, .pc-cancel, .pk-btn:not(.is-primary):not(.is-danger), .ava-dialog-button) {
    border: 1px solid var(--dialog-line); background: var(--pk-legacy-color-fff); color: var(--pk-legacy-color-263642); box-shadow: none;
}
body .pk-modal-frame :is(.pk-modal-primary, .is-primary, .ws-btn-primary) { background: var(--accent, var(--pk-legacy-color-087e8b)); border-color: var(--accent, var(--pk-legacy-color-087e8b)); color: var(--pk-legacy-color-fff); }
body .pk-modal-frame :is(.is-danger, .danger, .btn-danger) { background: var(--pk-legacy-color-c42b32); border-color: var(--pk-legacy-color-c42b32); color: var(--pk-legacy-color-fff); }
body .pk-modal-frame :is(.dialog-close, .pc-close, .ws-modal-close, .ws-doc-close, .emp-x, .ava-dialog-x, .task-cancel) {
    width: 32px; min-height: 32px; padding: 0; border: 0; background: transparent; color: var(--pk-legacy-color-52616d); box-shadow: none; z-index: 4;
}
body .pk-modal-frame :is(.dialog-close, .pc-close) { top: 12px; right: 12px; }
body .pk-modal-frame :is(.dialog-close, .pc-close, .ws-modal-close, .ws-doc-close, .emp-x, .ava-dialog-x, .task-cancel):hover { background: var(--pk-legacy-color-e4e9ee); }
body .pk-modal-frame :is(button, .btn):disabled { opacity: .5; }
body .pk-modal-frame input[type=file] { font: inherit; max-width: 100%; }
@media (max-width: 600px) {
    body .pk-modal-frame { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); }
    body .pk-modal-frame .pk-dialog-fields { grid-template-columns: 1fr; }
    body .pk-modal-frame .pk-field { grid-column: 1 / -1; }
    body .pk-modal-frame .task-create-fields { grid-template-columns: 1fr; }
    body .pk-modal-frame .ava-settings-body { grid-template-columns: 1fr; overflow: auto; }
    body .pk-modal-frame .ava-settings-tree { max-height: 140px; }
    body .pk-modal-frame .pk-modal-actions { gap: 8px; }
}
@media (prefers-reduced-motion: reduce) { body .pk-modal-frame { animation: none; } }

/* Compact upload layout, using the shared dialog frame and actions. */
body dialog.dpr-upload.pk-modal-frame { width: min(540px, calc(100vw - 32px)); height: fit-content; }
body dialog.dpr-upload.has-send.pk-modal-frame { width: min(540px, calc(100vw - 32px)); }
body dialog.dpr-upload.has-send.is-mail-open.pk-modal-frame { width: min(980px, calc(100vw - 32px)); }
body .dpr-upload.has-send:not(.is-mail-open) .dpr-upload-cols { display: block; }
body .dpr-upload .dpr-dropzone { min-height: 0; padding: 16px; gap: 8px; }
body .dpr-upload .dpr-drop-icon { display: none; }
body .dpr-upload .dpr-dropzone strong { font-size: 14px; }
body .dpr-upload.is-transferring .dpr-dropzone,
body .dpr-upload.is-transferring .dpr-upload-cols > [data-dpr-send],
body .dpr-upload.is-transferring .dpr-upload-send,
body .dpr-upload.is-transferring [data-dpr-submit] { display: none; }
body dialog.dpr-upload.is-transferring.pk-modal-frame { width: min(540px, calc(100vw - 32px)); }
body .dpr-upload.is-transferring .dpr-upload-cols { display: block; }
body .dpr-transfer[hidden], body [data-dpr-upload-cancel][hidden] { display: none; }
body .dpr-transfer > strong { display: block; overflow-wrap: anywhere; margin-bottom: 16px; }
body .dpr-transfer-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
body .dpr-transfer progress { display: block; width: 100%; height: 10px; margin: 8px 0; accent-color: var(--accent); }
body .dpr-transfer-steps { display: flex; justify-content: space-between; gap: 12px; padding-left: 20px; margin: 18px 0 8px; color: var(--muted); }
body .dpr-transfer-steps .is-active { color: var(--accent); font-weight: 600; }
body .dpr-upload .pk-modal-actions { gap: 8px; }

/* Upload composer keeps the optional mail editor beside the file selection. */
body dialog.dpr-upload.is-mail-open.pk-modal-frame { width: min(1060px, calc(100vw - 32px)); }
body .dpr-upload.is-mail-open .dpr-upload-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 24px; align-items: start; }
body .dpr-upload-toolbar { display: flex; justify-content: flex-end; margin: -8px 0 12px; }
body .dpr-text-button { border: 0; background: transparent; color: var(--accent); padding: 4px; font: inherit; cursor: pointer; box-shadow: none; }
body .dpr-upload-target { margin-bottom: 16px; }
body .dpr-upload-target > label { display: block; margin-bottom: 4px; font-weight: 600; }
body .dpr-upload-target > div { display: flex; align-items: center; gap: 8px; border: 1px solid var(--dialog-line); border-radius: 4px; padding: 4px 8px; }
body .dpr-upload-target [data-dpr-target-label] { flex: 1; min-width: 0; overflow-wrap: anywhere; }
body .dpr-file-selection > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
body .dpr-file-selection ul { list-style: none; padding: 0; margin: 8px 0; max-height: 240px; overflow: auto; }
body .dpr-file-selection li { display: flex; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--dialog-line); }
body .dpr-file-selection li > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body .dpr-file-selection li > small { flex: none; color: var(--muted); }
body .dpr-file-selection li > .pk-icon { width: 24px; height: 24px; flex: none; }
body .dpr-file-selection li button { border: 0; background: transparent; color: var(--ink); padding: 4px 8px; }
body .dpr-upload.has-files .dpr-dropzone { padding: 8px; gap: 4px; }
body .dpr-upload.has-files .dpr-dropzone > p:not(.dpr-drop-status), body .dpr-upload.has-files .dpr-dropzone > small { display: none; }
body .dpr-mail-panel { padding: 0 0 0 20px; border: 0; border-left: 1px solid var(--dialog-line); border-radius: 0; background: transparent; }
body .dpr-mail-panel header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
body .dpr-mail-panel h3 { font-size: 16px; margin: 0; }
body .dpr-mail-panel .dpr-send-field { margin: 10px 0; }
body .dpr-mail-panel textarea { min-height: 0; }
body .dpr-mail-panel [name=send_message] { min-height: 120px; }
body .dpr-mail-panel [name=send_external] { min-height: 64px; }
body .dpr-mail-panel .dpr-send-opts { display: flex; flex-wrap: wrap; gap: 8px 16px; }
body .dpr-mail-panel > small { display: block; margin-top: 8px; }
body .dpr-recipient-field { display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: start; gap: 8px; margin: 10px 0; }
body .dpr-recipient-field select { width: 100%; }
body .dpr-recipient-field > div { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
body .dpr-recipient-field [data-dpr-recipient-chips] { display: contents; }
body .dpr-recipient-field select { flex: 1; min-width: 140px; width: auto; max-width: 100%; }
body .dpr-mail-panel [data-dpr-mail-status]:empty { display: none; }
body .dpr-mail-panel [data-ki-slot] { float: right; }
body .dpr-mail-panel [data-ki-slot] .ki-tools { margin: 0; }
body .dpr-recipient-chip { display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; background: var(--dialog-chrome); padding: 2px 4px; margin: 0 4px 4px 0; max-width: 100%; }
body .dpr-recipient-chip > span { overflow: hidden; text-overflow: ellipsis; }
body .dpr-recipient-chip button { border: 0; background: transparent; padding: 0 4px; }
body .dpr-folder-picker { border: 1px solid var(--dialog-line); border-radius: 4px; padding: 8px; margin-bottom: 12px; }
body .dpr-folder-picker > input { width: 100%; }
body [data-dpr-folder-tree] { max-height: 240px; overflow: auto; margin: 8px 0; }
body .dpr-folder-choice { display: flex; align-items: center; gap: 4px; }
body .dpr-folder-choice button { border: 0; background: transparent; color: inherit; text-align: left; padding: 4px; }
body .dpr-folder-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
body .dpr-folder-choice[aria-selected=true] { background: var(--dialog-chrome); color: var(--accent); font-weight: 600; }
body .dpr-folder-picker-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
body .dpr-mail-panel[hidden], body .dpr-file-selection[hidden], body .dpr-folder-picker[hidden] { display: none; }
body .dpr-upload.is-transferring :is(.dpr-mail-panel, .dpr-upload-target, .dpr-upload-toolbar, .dpr-file-selection, .dpr-folder-picker) { display: none; }
@media (max-width: 900px) {
    body .dpr-upload.is-mail-open .dpr-upload-cols { display: block; }
    body .dpr-mail-panel { border-left: 0; border-top: 1px solid var(--dialog-line); padding: 16px 0 0; margin-top: 16px; }
}

/* CDE composer: compact body scrolling, aligned recipient/action columns and shared controls. */
body dialog.dpr-upload.pk-modal-frame { padding:0; overflow:hidden; }
body dialog.dpr-upload.has-send.is-mail-open.pk-modal-frame { width:min(1120px,calc(100vw - 32px)); }
body .dpr-upload > form { display:flex; flex-direction:column; max-height:calc(100dvh - 34px); margin:0; }
body .dpr-upload .dpr-upload-head, body .dpr-upload .dpr-upload-actions { position:static; margin:0; padding:12px 24px; flex-shrink:0; }
body .dpr-upload-body { padding:16px 24px; overflow:auto; min-height:0; }
body .dpr-upload.is-mail-open .dpr-upload-cols { grid-template-columns:minmax(0,.85fr) minmax(0,1.3fr); gap:20px; }
body .dpr-upload.is-mail-open .dpr-upload-toolbar { display:none; }
body .dpr-upload-toolbar { margin:0 0 8px; }
body .dpr-upload .dpr-icon-button { width:40px; height:40px; min-width:40px; padding:0; display:inline-flex; align-items:center; justify-content:center; flex:none; }
body .dpr-icon-button .pk-icon { width:18px; height:18px; }
body .dpr-mail-panel .dpr-send-field { display:block; margin:6px 0; }
body .dpr-mail-panel header { margin-bottom:8px; }
body .dpr-mail-panel .dpr-recipient-field { display:block; margin:6px 0; }
body .dpr-recipient-field > label { display:block; margin-bottom:3px; }
body .dpr-recipient-field .dpr-recipient-row { display:grid; grid-template-columns:minmax(0,1fr) 40px; gap:8px; align-items:start; }
body .dpr-recipient-control { min-width:0; display:flex; flex-wrap:wrap; gap:3px; align-items:center; border:1px solid var(--dialog-line); border-radius:4px; padding:0 5px; min-height:40px; }
body .dpr-recipient-control select { border:0; flex:1; min-width:120px; width:100%; min-height:38px; padding:4px; }
body .dpr-recipient-control [data-dpr-recipient-chips] { display:contents; }
body .dpr-recipient-chip { margin:2px 0; font-size:12px; }
body .dpr-recipient-chip .dpr-icon-button { width:24px; min-width:24px; height:24px; min-height:24px; }
body .dpr-external-control { position:relative; min-width:0; }
body .dpr-mail-panel [name=send_external] { min-height:40px; width:100%; }
body .dpr-template-row { display:grid; grid-template-columns:minmax(0,1fr) repeat(3,40px); gap:6px; }
body .dpr-template-row select { width:100%; min-width:0; }
body .dpr-template-row button[hidden] { display:none; }
body .dpr-rich-box { border:1px solid var(--dialog-line); border-radius:4px; overflow:hidden; }
body [data-dpr-rich-toolbar] { background:var(--dialog-chrome); border-bottom:1px solid var(--dialog-line); padding:3px; }
body .dpr-rich-row { display:flex; flex-wrap:wrap; gap:1px; align-items:center; }
body .dpr-upload .dpr-rich-row button { min-height:28px; height:28px; min-width:28px; padding:3px; border:0; background:transparent; color:inherit; }
body .dpr-rich-row button:hover { background:var(--dialog-line); }
body .dpr-rich-row .pk-icon { width:16px; height:16px; }
body .dpr-upload .dpr-rich-row select { min-height:28px; height:28px; font-size:12px; width:auto; max-width:85px; padding:2px; }
body .dpr-rich-row input[type=color] { width:24px; height:24px; padding:2px; border:0; cursor:pointer; }
body [data-dpr-rich] { min-height:90px; max-height:180px; overflow:auto; padding:8px 10px; outline:0; white-space:pre-wrap; overflow-wrap:anywhere; }
body [data-dpr-rich]:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
body [data-dpr-rich] p { margin:0 0 6px; }
body .dpr-mail-panel > small { font-size:11px; line-height:1.35; }
body .dpr-mail-panel .dpr-send-opts { gap:6px 12px; margin-top:8px; font-size:12px; }
body .dpr-file-types { text-align:left; font-size:12px; }
body .dpr-file-types summary { cursor:pointer; }
body [data-dpr-address-suggestions] { position:absolute; z-index:6; top:100%; left:0; right:0; max-height:200px; overflow:auto; background:white; border:1px solid var(--dialog-line); box-shadow:var(--dialog-shadow); border-radius:4px; }
body [data-dpr-address-suggestions][hidden] { display:none; }
body [data-dpr-address-suggestions] button { width:100%; padding:8px; text-align:left; border:0; background:white; font-size:12px; overflow-wrap:anywhere; }
body [data-dpr-address-suggestions] button:hover,body [data-dpr-address-suggestions] button:focus { background:var(--dialog-chrome); }
body .dpr-people-picker > header { display:flex; align-items:center; justify-content:space-between; }
body .dpr-people-picker .pk-modal-content { max-height:calc(100dvh - 210px); overflow:auto; }
body .dpr-people-picker input[type=search] { width:100%; }
body .dpr-people-tools,body .dpr-people-group { display:flex; gap:10px; align-items:center; padding:8px 0; border-bottom:1px solid var(--dialog-line); }
body .dpr-people-tools { justify-content:space-between; }
body .dpr-people-tools label { display:flex; align-items:center; gap:6px; }
body .dpr-people-group button { text-align:left; flex:1; font-weight:600; color:inherit; }
body .dpr-people-group button::after { content:'⌄'; float:right; }
body .dpr-people-person { display:flex; align-items:center; gap:12px; padding:6px 8px 6px 28px; }
body .dpr-people-person small { display:block; color:var(--muted); overflow-wrap:anywhere; }
body .dpr-people-picker footer { padding:12px 24px; }
@media(max-width:900px){
 body .dpr-upload.is-mail-open .dpr-upload-cols { display:block; }
 body .dpr-upload-body { padding:12px 16px; }
 body .dpr-mail-panel { padding:12px 0 0; }
 body .dpr-upload .dpr-icon-button { width:44px; height:44px; min-width:44px; }
 body .dpr-recipient-field .dpr-recipient-row { grid-template-columns:minmax(0,1fr) 44px; }
 body .dpr-template-row { grid-template-columns:minmax(0,1fr) repeat(3,44px); gap:4px; }
 body .dpr-upload .dpr-rich-row button { min-height:44px; min-width:32px; }
 body .dpr-upload .dpr-rich-row select { min-height:44px; }
}

body .dpr-external-entry { display:flex; flex-wrap:wrap; align-items:center; gap:3px; border:1px solid var(--dialog-line); border-radius:4px; padding:0 5px; min-height:40px; }
body [data-dpr-external-chips] { display:contents; }
body .dpr-upload [data-dpr-external-query] { min-width:100px; flex:1; width:100%; border:0; min-height:38px; padding:4px; }

body .dpr-mail-panel .dpr-send-field > input { display:block; width:100%; margin-top:3px; }
body .dpr-mail-panel [data-dpr-mail-status] { margin:4px 0; font-size:12px; }
body dialog.dpr-upload.pk-modal-frame .dpr-rich-row :is(button,select) { min-height:28px!important; height:28px; }
body .dpr-mail-panel .dpr-send-field > span { display:block; }
body .dpr-mail-panel [data-ki-slot] { float:none; display:inline-block; }
body .dpr-mail-panel [data-ki-slot] .ki-tools { display:inline-flex; vertical-align:middle; }
@media(max-width:900px){body dialog.dpr-upload.pk-modal-frame .dpr-rich-row :is(button,select){min-height:44px!important;height:44px;}}

body .dpr-mail-panel[data-can-manage=false] .dpr-template-row { grid-template-columns:minmax(0,1fr); }

body .dpr-upload.is-transferring [data-dpr-dismiss] { display:none; }

/* Compound recipient controls have one frame; only the outer container draws it. */
body dialog.dpr-upload.pk-modal-frame .dpr-recipient-control select,
body dialog.dpr-upload.pk-modal-frame .dpr-external-entry [data-dpr-external-query] {
 border:0!important; border-radius:0; box-shadow:none!important; outline-offset:-2px; background:transparent;
}
body .dpr-folder-toggle-slot { display:flex; align-items:center; justify-content:center; width:28px; min-width:28px; flex:none; }
body .dpr-upload .dpr-folder-toggle-slot .dpr-icon-button { width:28px; min-width:28px; height:32px; min-height:32px; padding:4px; }
body .dpr-folder-choice .dpr-folder-name { margin:0; padding:6px 4px; }

body .dpr-rich-row [data-ki-slot] { display:inline-flex; order:10; margin-left:auto; }
body .dpr-rich-row [data-ki-slot] .ki-tools { margin:0; display:inline-flex; gap:2px; }
body .dpr-rich-row [data-ki-slot] .ki-btn { padding:3px; width:28px; min-width:28px; }

@media(max-width:900px){body dialog.dpr-upload.pk-modal-frame .dpr-rich-row button,body .dpr-rich-row [data-ki-slot] .ki-btn {min-width:44px;width:44px;}}

/* A single frame connects the template selector with its three equal actions. */
body .dpr-template-row { gap:0; border:1px solid var(--dialog-line); border-radius:4px; overflow:hidden; background:var(--pk-legacy-color-f1f9fa); align-items:stretch; }
body dialog.dpr-upload.pk-modal-frame .dpr-template-row select { border:0!important; border-radius:0; background:transparent; min-height:40px; height:40px; margin:0; }
body dialog.dpr-upload.pk-modal-frame .dpr-template-row .dpr-icon-button { border:0; border-left:1px solid var(--dialog-line); border-radius:0; background:transparent; margin:0; height:40px; }
body dialog.dpr-upload.pk-modal-frame .dpr-template-row [data-dpr-template-new] { color:var(--pk-legacy-color-1468bf); }
body dialog.dpr-upload.pk-modal-frame .dpr-template-row [data-dpr-template-edit] { color:var(--pk-legacy-color-a65d00); }
body dialog.dpr-upload.pk-modal-frame .dpr-template-row [data-dpr-template-save] { color:var(--pk-legacy-color-087f83); }
body .dpr-template-row button:hover { background:var(--pk-legacy-color-e3f1f4); }
body dialog.dpr-upload.pk-modal-frame [data-dpr-people] { color:var(--pk-legacy-color-24649e); }
body dialog.dpr-upload.pk-modal-frame [data-dpr-addressbook] { color:var(--pk-legacy-color-087f83); }
/* Specific editor sizing must allow an active recording button to grow. */
body .dpr-rich-row [data-ki-slot] { max-width:100%; min-width:0; }
body .dpr-rich-row [data-ki-slot] .ki-tools { gap:0; }
body .dpr-rich-row [data-ki-slot] .ki-btn { color:var(--pk-legacy-color-087f83); height:28px; min-width:30px; width:30px; padding:0; background:transparent; }
body .dpr-rich-row [data-ki-slot] .ki-correct { color:var(--pk-legacy-color-7044b4); }
body .dpr-rich-row [data-ki-slot] .ki-btn:is(.is-recording,.is-processing) { width:auto; min-width:max-content; padding:0 8px; }
body .dpr-rich-row [data-ki-slot] .ki-btn.is-recording { color:var(--pk-legacy-color-b3261e); background:var(--pk-legacy-color-fff0ef); animation:none; }
body .dpr-rich-row [data-ki-slot] .ki-btn.is-processing { color:var(--pk-legacy-color-195f9e); background:var(--pk-legacy-color-edf5ff); }
@media(max-width:900px){body .dpr-upload .dpr-template-row .dpr-icon-button{height:44px;}body .dpr-rich-row [data-ki-slot] .ki-btn{width:44px;min-width:44px;height:44px;}}

body .dpr-template-row:focus-within { outline:2px solid var(--accent); outline-offset:2px; }

@media(max-width:900px){body dialog.dpr-upload.pk-modal-frame .dpr-template-row select{height:44px;min-height:44px;}}

@media(max-width:900px){body dialog.dpr-upload.pk-modal-frame .dpr-template-row .dpr-icon-button {height:44px;min-height:44px;}}

/* Site-wide field/action groups. Reuse pk-control-group for new compound fields. */
body :is(.pk-control-group,.input-with-toggle,.ava-lv-picker,.dpr-search,.dpr-recipient-row) {
 display:flex; flex-wrap:nowrap; align-items:stretch; gap:0; min-width:0;
 border:1px solid var(--dialog-line); border-radius:4px; background:var(--paper,var(--pk-legacy-color-fff));
}
body :is(.pk-control-group,.input-with-toggle,.ava-lv-picker,.dpr-search) > :is(input,select),
body .dpr-recipient-row > :is(.dpr-recipient-control,.dpr-external-control) {
 flex:1 1 0; min-width:0; width:0; margin:0; border:0!important; border-radius:0; box-shadow:none;
}
body .dpr-recipient-row .dpr-external-entry { border:0; border-radius:0; }
body :is(.pk-control-group,.input-with-toggle,.ava-lv-picker,.dpr-search,.dpr-recipient-row) > :is(button,.btn) {
 flex:0 0 auto; display:inline-flex; align-items:center; justify-content:center; gap:6px;
 align-self:stretch; height:auto; min-height:40px; margin:0; padding:0 12px;
 border:0!important; border-left:1px solid var(--dialog-line)!important; border-radius:0;
 background:var(--pk-legacy-color-f1f9fa); color:var(--pk-legacy-color-087f83); box-shadow:none; white-space:nowrap;
}
body dialog.dpr-upload.pk-modal-frame .dpr-recipient-row > .dpr-icon-button {height:auto;min-height:40px;}
body .dpr-recipient-row > .dpr-external-control { position:relative; }
body .dpr-search input { height:auto; min-height:40px; }
body .dpr-upload-target > div { padding:0 0 0 10px; }
body .dpr-upload-target > div > .dpr-text-button { align-self:stretch; min-height:40px; padding:0 12px; border-left:1px solid var(--dialog-line); background:var(--pk-legacy-color-f1f9fa); }
@media(max-width:900px){body :is(.pk-control-group,.input-with-toggle,.ava-lv-picker,.dpr-search,.dpr-recipient-row)>:is(input,select,button,.btn),body dialog.dpr-upload.pk-modal-frame .dpr-recipient-row>.dpr-icon-button {min-height:44px;}}

/* Quiet editing: no blue outline/halo around text fields or their surrounding area. */
:root { --focus-neutral:var(--pk-legacy-color-66717a); --field-edit-border:var(--pk-legacy-color-98a0a7); }
body :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),select,textarea,[contenteditable=true]):focus {
 outline:none!important; box-shadow:none!important;
}
body :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),select,textarea):focus:not([aria-invalid=true]):not(:user-invalid) {
 border-color:var(--field-edit-border)!important;
}
body :is(.ki-tools,.dpr-template-row,.ava-ki-ask,.kia-ask,.ws-richtext-box,.portal-switch-search,.portal-building-switch,.crm-filter-search,.pk-control-group,.input-with-toggle,.ava-lv-picker,.dpr-recipient-row):focus-within {
 outline:none!important; box-shadow:none!important;
}
body :is(.ava-ki-ask,.kia-ask,.ws-richtext-box,.portal-switch-search,.portal-building-switch,.crm-filter-search):focus-within { border-color:var(--field-edit-border); }
body .pc-field:focus-within>span { color:var(--ink); }
/* A neutral indicator remains on keyboard-operated actions, without outlining the entire group. */
body :is(button,a,summary,input[type=checkbox],input[type=radio]):focus-visible { outline:2px solid var(--focus-neutral)!important; outline-offset:-2px; box-shadow:none!important; }
body :is(.ws-chip:has(input:focus-visible),.pp-chip input:focus-visible+span,.ki-switch input:focus-visible+span,.crm-composer-types input:focus-visible+span,.term-time input:focus-visible+span,.term-chip input:focus-visible+span,.term-seg input:focus-visible+span,.term-person:has(input:focus-visible),.term-t input:focus-visible+span) {outline-color:var(--focus-neutral)!important;}

body :is(.pk-control-group,.input-with-toggle,.ava-lv-picker,.dpr-search)>:is(input,select) {height:auto;min-height:40px;align-self:stretch;box-sizing:border-box;}
body :is(.pk-control-group,.input-with-toggle,.ava-lv-picker,.dpr-search,.dpr-recipient-row)>:is(button,.btn) {position:static;inset:auto;transform:none;box-sizing:border-box;}
@media(max-width:900px){body :is(.pk-control-group,.input-with-toggle,.ava-lv-picker,.dpr-search)>:is(input,select){min-height:44px;}}

body input.pk-select[aria-expanded=true] {outline:none!important;box-shadow:none!important;}
body .pk-drop:focus-within {outline:none!important;box-shadow:none!important;border-color:var(--field-edit-border);}
body :is(.pk-control-group,.input-with-toggle,.ava-lv-picker,.dpr-search,.dpr-recipient-row):has([aria-invalid=true]) {border-color:var(--warn,var(--pk-legacy-color-b3261e));}

body :focus-visible,body input:focus-visible+span {outline-color:var(--focus-neutral)!important;}

body :is(.pk-control-group,.input-with-toggle,.ava-lv-picker,.dpr-search,.dpr-recipient-row):has(:user-invalid) {border-color:var(--warn,var(--pk-legacy-color-b3261e));}

body .dpr-mail-panel .dpr-template-label {display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 8px;}
body .dpr-template-label [data-dpr-template-notice] {color:var(--pk-legacy-color-28713f);font-size:12px;font-weight:400;}
body .dpr-template-label [data-dpr-template-notice][hidden] {display:none;}

/* Recipient pickers occupy the complete input width; their native arrow stays at the right edge. */
body .dpr-upload.pk-modal-frame .dpr-recipient-control :is(select,input.pk-select) {
 field-sizing:fixed; flex:1 1 100%; width:100%; max-width:none; min-width:0; margin:0; box-sizing:border-box;
}
body .dpr-upload.pk-modal-frame .dpr-recipient-control .ws-dd {flex:1 1 100%;width:100%;max-width:none;}

/* Recipient rows are grids: their inner controls must stretch, never keep a flex-only width:0. */
body .dpr-upload.pk-modal-frame .dpr-recipient-field .dpr-recipient-row {
 display:grid;grid-template-columns:minmax(0,1fr) 40px;gap:0;align-items:stretch;
}
body .dpr-upload.pk-modal-frame .dpr-recipient-field .dpr-recipient-row > :is(.dpr-recipient-control,.dpr-external-control) {
 width:auto;min-width:0;max-width:100%;justify-self:stretch;box-sizing:border-box;
}
body .dpr-upload.pk-modal-frame .dpr-external-entry {width:100%;min-width:0;box-sizing:border-box;}
body .dpr-upload.pk-modal-frame .dpr-external-entry [data-dpr-external-query] {field-sizing:fixed;flex:1 1 100%;width:100%;min-width:0;max-width:100%;}
@media(max-width:900px){body .dpr-upload.pk-modal-frame .dpr-recipient-field .dpr-recipient-row{grid-template-columns:minmax(0,1fr) 44px;}}
/* Compact recovery notice, below the title, with explicit continue/discard actions. */
body .pk-draft-note {display:flex;align-items:center;flex-wrap:wrap;gap:6px 10px;flex-shrink:0;padding:6px 10px;margin:0 0 10px;border:1px solid var(--dialog-line);border-radius:4px;background:var(--pk-legacy-color-f5f8f7);font-size:12px;line-height:1.35;}
body .dpr-upload .pk-draft-note {margin:8px 24px 0;}
body .pk-draft-note > span {flex:1 1 180px;min-width:0;}
body .pk-draft-note .pk-draft-actions {display:inline-flex;align-items:center;gap:6px;margin-left:auto;}
body .pk-draft-note .pk-draft-actions button {min-height:28px;height:auto;padding:3px 8px;margin:0;border:1px solid var(--dialog-line);border-radius:4px;box-shadow:none;font-size:12px;font-weight:400;background:white;color:var(--ink);white-space:nowrap;}
body .pk-draft-note .pk-draft-actions [data-pk-draft-continue] {color:var(--pk-legacy-color-087f83);}
@media(max-width:900px){body .dpr-upload .pk-draft-note{margin:8px 16px 0;}body .pk-draft-note .pk-draft-actions button{min-height:44px;}}

/* Upload recovery belongs directly below the file list (or dropzone when no files are selected). */
body .dpr-upload-main > .pk-draft-note {margin:12px 0 0;}
body .dpr-upload.is-transferring .pk-draft-note {display:none;}

/* One text inset across upload fields, chip controls and the message editor. */
body .dpr-upload {--dpr-text-inset:12px;}
body .dpr-upload.pk-modal-frame :is(.dpr-template-row select,[name=send_subject],[data-dpr-rich]) {padding-left:var(--dpr-text-inset);padding-right:var(--dpr-text-inset);}
body .dpr-upload.pk-modal-frame :is(.dpr-recipient-control,.dpr-external-entry) {padding-left:0;padding-right:0;}
body .dpr-upload.pk-modal-frame :is(.dpr-recipient-control select,.dpr-recipient-control input.pk-select,[data-dpr-external-query]) {padding-left:var(--dpr-text-inset);padding-right:var(--dpr-text-inset);}
body .dpr-upload.pk-modal-frame :is([data-dpr-recipient-chips],[data-dpr-external-chips]) > .dpr-recipient-chip:first-child {margin-left:calc(var(--dpr-text-inset) - 4px);}

body .dpr-upload.pk-modal-frame .dpr-upload-target>div {padding-left:var(--dpr-text-inset);}
body .dpr-upload.pk-modal-frame [data-dpr-folder-search] {padding-left:var(--dpr-text-inset);padding-right:var(--dpr-text-inset);}

