.insert-text-dialog {
  width: min(560px, calc(100% - 26px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
}

.insert-text-body {
  display: grid;
  gap: 11px;
}

.insert-text-body > p { margin: 0; }
.insert-text-body label:has(textarea, input:not([type="checkbox"]), select) {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.insert-text-body label :is(input:not([type="checkbox"]), select, textarea) { width: 100%; }
.insert-text-body label:has(input[type="checkbox"]) { display: flex; gap: 7px; align-items: center; }
.insert-text-body :is(textarea, input[type="file"]) {
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font: inherit;
}
.insert-text-body input[type="color"] { min-height: 33px; }
.insert-text-actions, .insert-math-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.insert-text-dialog .field-status:not(:empty) { margin-top: 11px; }
.insert-text-dialog .field-status:empty { display: none; }

.insert-draw-box {
  min-height: 114px;
  padding: 10px;
  border: 1px dashed #8094b9;
  background: var(--panel, #f7f9fc);
  cursor: crosshair;
  user-select: none;
  touch-action: none;
}
.insert-draw-box p { margin: 0 0 8px; font-size: .8125rem; }
.insert-draw-box span {
  display: block;
  width: 28%;
  height: 32px;
  border: 1px solid #2457c5;
  background: #dce9ff;
  pointer-events: none;
}
.insert-wordart-preview {
  min-height: 54px;
  padding: 9px;
  max-width: 100%;
  text-align: center;
  overflow-wrap: anywhere;
}
.insert-date-preview {
  padding: 9px 12px;
  background: var(--panel, #f7f9fc);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.insert-symbol-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(41px, 1fr));
  max-height: min(230px, 35dvh);
  overflow: auto;
  padding: 4px;
  gap: 4px;
}
.insert-symbol-gallery :is(button, p) { margin: 0; }
.insert-symbol-gallery button { display: grid; place-items: center; min-width: 0; min-height: 38px; font-size: 1.2rem; }
.insert-symbol-gallery p { grid-column: 1 / -1; }
.insert-math-keys button { padding: 4px 8px; }
.insert-matrix-values {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(var(--matrix-columns, 2), minmax(0, 1fr));
  gap: 6px;
}

#editor .brasa-textbox {
  max-width: 100%;
  margin: .8em 0;
  padding: 11px 14px;
  transform-origin: center;
}
#editor .brasa-textbox p:first-child { margin-top: 0; }
#editor .brasa-textbox p:last-child { margin-bottom: 0; }
#editor .brasa-textbox[data-brasa-box-layout="center"] { margin-inline: auto; }
#editor .brasa-textbox[data-brasa-box-layout="right"] { margin-inline-start: auto; }
#editor .brasa-textbox[data-brasa-box-layout="wrapLeft"] { float: left; margin-right: 1em; }
#editor .brasa-textbox[data-brasa-box-layout="wrapRight"] { float: right; margin-left: 1em; }
#editor .brasa-wordart {
  display: inline-block;
  max-width: 100%;
  font-weight: 700;
  line-height: 1.12;
  overflow-wrap: anywhere;
}
#editor .brasa-drop-cap { float: left; line-height: .86; margin-top: .08em; }
#editor .brasa-drop-cap[data-brasa-drop-cap="margin"] { margin-left: -.43em; }
#editor .brasa-signature-line { display: block; width: min(100%, 310px); margin-block: 2.4em .65em; }
#editor .brasa-signature-line p { margin: 0 0 .2em; }
#editor .brasa-signature-line p:first-child { padding-top: .25em; }
#editor .brasa-signature-field {
  display: inline-block;
  padding-inline: .25em;
  border: 1px dashed #6a87bd;
  color: #2457a1;
  background: #edf2fd;
}
#editor .brasa-attachment { text-decoration-style: dotted; }

#editor .brasa-equation {
  display: inline-flex;
  vertical-align: middle;
  align-items: baseline;
  gap: .05em;
  font-family: "Cambria Math", "Times New Roman", serif;
  line-height: 1.12;
}
#editor .brasa-equation[data-brasa-equation="fraction"] {
  display: inline-grid;
  grid-template-columns: minmax(min-content, max-content);
  justify-items: center;
  vertical-align: middle;
}
#editor .brasa-equation[data-brasa-equation="fraction"] > [data-math-part] { padding: .1em .28em; min-width: 100%; text-align: center; }
#editor .brasa-equation[data-brasa-equation="fraction"] > [data-math-part="numerator"] { border-bottom: 1px solid currentColor; }
#editor .brasa-equation :is([data-math-part="exponent"], [data-math-part="index"]) { font-size: .7em; display: inline-block; }
#editor .brasa-equation [data-math-part="exponent"] { transform: translateY(-.52em); }
#editor .brasa-equation[data-brasa-equation="subscript"] > [data-math-part="index"] { transform: translateY(.35em); }
#editor .brasa-equation[data-brasa-equation="radical"] > [data-math-display="operator"] { font-size: 1.18em; }
#editor .brasa-equation[data-brasa-equation="radical"]:not(:has(> [data-math-display="operator"]))::before { content: "√"; font-size: 1.18em; }
#editor .brasa-equation[data-brasa-equation="radical"] > [data-math-part="index"] { order: -1; align-self: start; }
#editor .brasa-equation [data-math-part="radicand"] { border-top: 1px solid currentColor; padding-inline: .07em; }
#editor .brasa-equation:is([data-brasa-equation="integral"], [data-brasa-equation="sum"], [data-brasa-equation="limit"]) {
  display: inline-grid;
  grid-template-areas: "upper body" "operator body" "lower body";
  align-items: center;
  justify-items: center;
  column-gap: .28em;
}
#editor .brasa-equation [data-math-display="operator"] { grid-area: operator; line-height: 1; }
#editor .brasa-equation:is([data-brasa-equation="integral"], [data-brasa-equation="sum"], [data-brasa-equation="limit"]):not(:has(> [data-math-display="operator"]))::before { grid-area: operator; line-height: 1; }
#editor .brasa-equation[data-brasa-equation="integral"]:not(:has(> [data-math-display="operator"]))::before { content: "∫"; font-size: 1.35em; }
#editor .brasa-equation[data-brasa-equation="sum"]:not(:has(> [data-math-display="operator"]))::before { content: "∑"; font-size: 1.35em; }
#editor .brasa-equation[data-brasa-equation="limit"]:not(:has(> [data-math-display="operator"]))::before { content: "lim"; }
#editor .brasa-equation:is([data-brasa-equation="integral"], [data-brasa-equation="sum"]) [data-math-display="operator"] { font-size: 1.35em; }
#editor .brasa-equation [data-math-part="lower"] { grid-area: lower; font-size: .68em; }
#editor .brasa-equation [data-math-part="upper"] { grid-area: upper; font-size: .68em; }
#editor .brasa-equation [data-math-part="body"] { grid-area: body; }
#editor .brasa-equation[data-brasa-equation="matrix"] {
  display: inline-grid;
  grid-template-columns: repeat(var(--matrix-columns, 2), minmax(.85em, max-content));
  justify-items: center;
  gap: .2em .55em;
  padding: .15em .34em;
  border-inline: 1px solid currentColor;
  border-radius: .16em;
}
@media (max-width: 420px) {
  .insert-text-body .dialog-fields { grid-template-columns: 1fr 1fr; }
  .insert-symbol-gallery { grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }
}
