/* Formula reading and editing interactions adapted from Conspect. */
.graph-rich-text { text-align: left; overflow-wrap: break-word; }
.graph-clauses > .graph-text-clause { overflow: visible; white-space: normal; line-height: 1.85; }
.graph-clauses > .graph-text-clause + .graph-text-clause { margin-top: .85em; }
.graph-rich-text .math-expression { font-size: 1.08em; line-height: normal; }
.math-expression[role="button"] { cursor: pointer; border-radius: 4px; }
.math-expression[role="button"]:hover { background: #f1f0e8; }
.math-expression[role="button"]:focus-visible { outline: 2px solid var(--accent, #47736e); outline-offset: 3px; }
.graph-rich-text .math-formula-block {
  display: block; position: relative; box-sizing: border-box; width: fit-content;
  min-width: 0; max-width: 100%; margin: .65rem 0; padding: .85rem 2.5rem .85rem 1rem;
  border-left: 3px solid #bacdc4; border-radius: 0 6px 6px 0; background: #f5f7f2;
  overflow-x: auto; font-size: 1.17em; scrollbar-width: thin;
}
.math-expand-button {
  position: absolute; top: .25rem; right: .25rem; padding: .2rem .35rem;
  border: 1px solid #d0d8cd; border-radius: 4px; background: #fff; color: #365b55;
  line-height: 1.2; cursor: pointer; font-size: 1rem;
}
.math-tex .katex-display { margin: 0; text-align: left; }
.math-tex .katex-display > .katex { text-align: left; }
.graph-rich-text .katex-mathml math { font-size: inherit; }
.math-workbench-dialog {
  box-sizing: border-box; width: min(1000px, 94vw); max-width: 94vw; max-height: 88vh;
  padding: 1.3rem; color: #263c37; background: #fffefa; border: 1px solid #cdd7cd;
  border-radius: 12px; box-shadow: 0 18px 70px #142b2a40; overflow-y: auto;
  font: 16px/1.6 system-ui, sans-serif;
}
.math-workbench-dialog::backdrop { background: #132c2b66; }
.math-workbench-dialog > header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.math-workbench-dialog h2 { margin: 0; font-size: 1.2rem; }
.math-workbench-dialog button, .math-editor-toolbar button, .math-table-header button {
  font: inherit; border: 1px solid #c7d3c6; border-radius: 6px; padding: .35rem .65rem;
  color: #2e504a; background: #f5f7f1; cursor: pointer;
}
.math-workbench-dialog button:hover, .math-editor-toolbar button:hover, .math-table-header button:hover { background: #e8efe5; }
.math-workbench-dialog button:disabled { opacity: .45; cursor: default; }
.math-workbench-dialog .math-dialog-close { font-size: 1.5rem; padding: 0 .6rem; }
.math-dialog-viewport { overflow: auto; max-width: 100%; max-height: 55vh; padding: 1rem 0; overscroll-behavior: contain; }
.math-dialog-formula { width: max-content; min-width: 100%; text-align: left; padding: .5rem; box-sizing: border-box; }
.math-dialog-formula math { font-family: "Cambria Math", "STIX Two Math", math; }
.math-dialog-formula .math-expression { max-width: none; overflow: visible; }
.math-dialog-formula .math-formula-block { display: block; }
.math-dialog-formula .katex-display { margin: 0; }
.math-dialog-toolbar, .math-symbol-choices, .math-editor-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .75rem 0; }
.math-dialog-toolbar output { min-width: 3.5em; text-align: center; }
.math-workbench-dialog textarea { width: 100%; min-height: 6rem; box-sizing: border-box; font: 15px/1.6 ui-monospace, monospace; padding: .6rem; border: 1px solid #bfcbbb; border-radius: 6px; resize: vertical; }
.math-workbench-dialog [data-math-symbol], .math-workbench-dialog [data-math-value], .math-workbench-dialog [data-math-number] { cursor: pointer; }
.math-workbench-dialog [data-math-symbol]:hover, .math-workbench-dialog [data-math-symbol]:focus-visible,
.math-workbench-dialog [data-math-value]:focus-visible, .math-workbench-dialog [data-math-number]:focus-visible { outline: 1px solid #628b7c; background: #e4eee1; }
.math-symbol-explanation { border-top: 1px solid #d8e0d2; padding: .8rem; background: #f5f7f1; overflow-wrap: anywhere; }
.math-symbol-explanation p { margin: .4rem 0; }
.math-symbol-explanation .math-expression { max-width: 100%; overflow-x: auto; display: inline-block; }
.math-calculation-fold, .math-calculation-body { display: block; max-width: 100%; }
.math-calculation-fold > button { font: inherit; padding: .4rem .65rem; color: #365b55; background: #f5f7f1; border: 1px solid #c7d3c6; border-radius: 5px; cursor: pointer; }
.math-calculation-body[hidden] { display: none; }
.math-fold-all { display:flex; gap:.5rem; margin:.5rem 0; }
.math-inline-tip { position:fixed; z-index:10001; box-sizing:border-box; width:350px; max-width:calc(100vw - 16px); max-height:65vh; overflow:auto; padding:.8rem 1rem; background:#f3f6ee; border:1px solid #a9bda3; border-radius:.5rem; box-shadow:0 6px 22px #18372b26; font-size:1rem; line-height:1.65; }
.math-zoom-dialog { width:fit-content; min-width:min(28rem,94vw); }
.math-zoom-dialog .math-dialog-formula { min-width:0; }
.math-zoom-dialog .math-expression { font-size:inherit; }
.previous-development-part + .previous-development-part { margin-top:1rem; }
.previous-development-part > strong { display:block; margin-bottom:.35rem; color:#476b66; }
.math-expression [role="button"] { cursor:help; }
.math-inline-tip button, .math-notes button { font:inherit; padding:.35rem .65rem; margin:.25rem; border:1px solid #b8c8b1; border-radius:.35rem; background:#f5f8f0; color:#294940; cursor:pointer; }
.math-notes { border-top:1px solid #cbd6c5; margin-top:1.25rem; padding-top:.5rem; font-size:1rem; line-height:1.6; }
.math-notes details { margin:.75rem 0; }
.math-notes select { font:inherit; padding:.4rem; max-width:100%; margin:.4rem; }
.math-notes textarea { display:block; box-sizing:border-box; width:100%; min-height:5rem; font:inherit; padding:.6rem; }
.math-meaning-table { width:100%; border-collapse:collapse; }
.math-meaning-table th,.math-meaning-table td { border-bottom:1px solid #d5dece; text-align:left; vertical-align:top; padding:.5rem; }
.math-meaning-table th { width:23%; overflow-wrap:anywhere; }
.math-chat { margin:1rem 0; padding:1rem; background:#fafbf6; border:1px solid #d5dece; border-radius:.5rem; }
.math-chat > div > div { margin:.8rem 0; }
.math-value-highlight { background:#fff0a0; outline:2px solid #bd9b34; }
.math-dependency-highlight { background:#e1f0fd; outline:2px solid #5381b2; }
.math-return { position:fixed; bottom:1rem; right:1rem; padding:.7rem 1rem; z-index:10000; }
.math-recorded-button { font: .8rem system-ui; margin-left:.5rem; padding:.25rem .4rem; border:1px solid #bcccb3; border-radius:.3rem; color:#365b55; background:#f3f7ed; cursor:pointer; }
.math-expression [role="button"]:focus-visible { outline:2px solid #4c7465; outline-offset:3px; }
.math-notes button:disabled { opacity:.55; cursor:default; }
.math-table-fold, .math-table-body { display: block; max-width: 100%; min-width: 0; }
.math-table-fold { margin: 1rem 0; border: 1px solid #d0dacb; border-radius: 7px; overflow: hidden; }
.math-table-header { display: flex; gap: .5rem; justify-content: space-between; flex-wrap: wrap; padding: .5rem; background: #f5f7f1; }
.math-table-header button:first-child { text-align: left; flex: 1; }
.math-table-body { overflow-x: auto; }
.math-table-body[hidden] { display: none; }
.math-data-table, .math-dialog-viewport table { border-collapse: collapse; min-width: 100%; font-size: 1rem; }
.math-data-table th, .math-data-table td, .math-dialog-viewport th, .math-dialog-viewport td { border: 1px solid #d7dfd2; padding: .65rem .85rem; text-align: left; vertical-align: top; min-width: 7rem; }
.math-data-table th { background: #f0f4ec; }
.math-data-table td .math-formula-block { font-size: 1em; min-width: max-content; }
.math-editor-preview { margin: .6rem 0 1rem; padding: 1rem; border: 1px solid #d0dacb; border-radius: 6px; background: #fffefa; max-height: 32rem; overflow: auto; }
.math-formula-preview { padding: 1rem; margin: .75rem 0; background: #f5f7f1; overflow: auto; font-size: 1.35rem; }
.math-table-editor { max-width: 100%; overflow: auto; margin: .75rem 0; }
.math-table-editor input { width: 12rem; box-sizing: border-box; padding: .55rem; font: inherit; border: 1px solid #c8d3c2; }
@media (max-width: 600px) {
  .math-workbench-dialog { padding: .75rem; width: 96vw; max-width: 96vw; }
  .graph-rich-text .math-formula-block { font-size: 1.08em; padding-left: .5rem; }
  .math-editor-preview { padding: .6rem; }
}
@media print {
  .math-expand-button, .math-table-header, .math-workbench-dialog, .math-editor-toolbar { display: none !important; }
  .math-table-body[hidden] { display: block; }
  .math-calculation-body[hidden] { display: block; }
  .math-calculation-fold > button { display: none; }
  .graph-rich-text .math-formula-block { overflow: visible; }
}
