/* Editor rumus: dialog mandiri, tanpa dependensi dialog dari CDN. */
.equation-dialog {
  width: min(1240px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  height: min(940px, 94dvh);
  max-height: 94dvh;
  margin: auto;
  padding: 0;
  border: 1px solid var(--bs-border-color, #d8e0e8);
  border-radius: 18px;
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #1f2937);
  box-shadow: 0 24px 100px #0d1b3440;
  font-family: system-ui, sans-serif;
}
.equation-dialog[open] {
  display: flex;
  flex-direction: column;
}
.equation-dialog::backdrop {
  background: #14233d99;
}
body:has(.equation-dialog[open]) {
  overflow: hidden;
}
.equation-dialog.eq-maximized {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 0;
}
.eq-header,
.eq-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  flex-shrink: 0;
  border-bottom: 1px solid var(--bs-border-color, #d8e0e8);
}
.eq-header h2 {
  font-size: 1.3rem;
  margin: 0 0 0.25rem;
}
.eq-header p {
  font-size: 0.85rem;
  margin: 0;
  color: var(--bs-secondary-color, #586674);
  max-width: 60ch;
}
.eq-header-actions,
.eq-footer > div,
.eq-toolbar,
.eq-format-bar,
.eq-mode-bar,
.eq-export-options {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}
.eq-header-actions {
  flex-shrink: 0;
}
.equation-dialog button {
  cursor: pointer;
  min-height: 36px;
}
.equation-dialog button:disabled {
  cursor: not-allowed;
}
.equation-dialog button:focus-visible,
.equation-dialog summary:focus-visible,
.equation-dialog select:focus-visible,
.equation-dialog input:focus-visible {
  outline: 3px solid #448cfd;
  outline-offset: 2px;
}
.equation-dialog label {
  font-size: 0.86rem;
}
.equation-dialog select,
.equation-dialog input[type="number"] {
  padding: 0.45rem;
  border: 1px solid var(--bs-border-color, #d8e0e8);
  border-radius: 6px;
  color: inherit;
  background: var(--bs-body-bg, #fff);
  max-width: 100%;
}
.equation-dialog .btn {
  font-size: 0.84rem;
}
.equation-dialog [hidden] {
  display: none !important;
}
.eq-scroll {
  flex: 1;
  min-height: 0;
  padding: 1rem 1.25rem;
  overflow: auto;
  overscroll-behavior: contain;
}
.eq-notice {
  font-size: 0.9rem;
  color: #137766;
}
.eq-notice:empty {
  display: none;
}
.eq-workspace {
  display: grid;
  grid-template-columns: minmax(235px, 0.8fr) minmax(0, 2fr);
  gap: 1.25rem;
}
.eq-main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}
.eq-palette {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  border-right: 1px solid var(--bs-border-color, #d8e0e8);
  padding-right: 1rem;
}
.eq-palette > label {
  display: block;
  margin-bottom: 0.35rem;
}
.eq-palette > input,
.eq-palette > select {
  margin-bottom: 0.7rem;
}
.eq-toolbar {
  margin-bottom: 0.65rem;
}
.eq-mode-bar {
  margin: 0.75rem 0;
}
.eq-zoom-label {
  margin-left: auto;
  white-space: nowrap;
}
.eq-format-bar {
  margin: 0.65rem 0;
}
.eq-format-bar label {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}
.eq-format-bar input[type="color"] {
  width: 2.5rem;
  height: 2rem;
  padding: 2px;
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
}
.eq-hint {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--bs-secondary-color, #586674);
  margin: 0.5rem 0;
}
#eqVisualHost {
  overflow-x: auto;
  max-width: 100%;
  font-size: 20px;
  border: 1px solid var(--bs-border-color, #d8e0e8);
  border-radius: 10px;
}
#eqVisualHost math-field {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 82px;
  max-height: 260px;
  padding: 14px;
  border: 0;
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #17212f);
  overflow: auto;
  font-size: inherit;
  --caret-color: #2563eb;
  --selection-background-color: #b9d5ff70;
  --contains-highlight-background-color: #dbeafe60;
  --placeholder-color: #2563eb;
  --placeholder-opacity: 0.9;
}
#eqVisualHost math-field::part(virtual-keyboard-toggle),
#eqVisualHost math-field::part(menu-toggle) {
  display: none;
}
.eq-source {
  margin-top: 0.85rem;
}
.eq-source textarea {
  margin-top: 0.45rem;
  min-height: 100px;
  resize: vertical;
  font-size: 0.95rem;
}
.eq-source > summary,
.eq-builder > summary,
.eq-import > summary,
.eq-export > summary,
.eq-library > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.5rem 0;
}
.eq-completions {
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  max-height: 190px;
  overflow: auto;
  background: var(--bs-body-bg);
}
.eq-completions button {
  display: block;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  width: 100%;
  padding: 0.5rem 0.7rem;
}
.eq-completions button[aria-selected="true"] {
  background: #287cf326;
}
.eq-display-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 0.85rem 0;
}
.eq-display-bar label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.eq-errors {
  color: #8a5b00;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
  margin: 0.6rem 0;
}
.eq-errors.has-error {
  color: var(--bs-danger-text-emphasis, #a61d2a);
  background: #dc354510;
  padding: 0.65rem;
  border-radius: 8px;
}
.eq-preview-section {
  margin: 1rem 0;
}
.eq-preview-section h3 {
  font-size: 0.9rem;
}
.eq-preview {
  padding: 1rem;
  border: 1px solid var(--bs-border-color, #d8e0e8);
  border-radius: 10px;
  background: var(--bs-tertiary-bg, #f5f7fb);
  min-height: 72px;
  max-height: 300px;
  overflow: auto;
  font-size: 20px;
  overflow-wrap: anywhere;
}
.eq-preview mjx-container {
  margin: 0.25rem 0 !important;
}
.eq-preview svg {
  overflow: visible;
}
.eq-builder,
.eq-import,
.eq-export,
.eq-library {
  border-top: 1px solid var(--bs-border-color, #d8e0e8);
  margin-top: 1rem;
  padding-top: 0.4rem;
}
.eq-builder-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.5rem 0;
}
.eq-builder-controls label,
.eq-import label,
.eq-library label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.eq-builder-controls input {
  max-width: 5rem;
}
.eq-matrix-grid {
  display: grid;
  gap: 0.35rem;
  overflow: auto;
  max-width: 100%;
  padding: 0.2rem 0.15rem 0.5rem;
}
.eq-matrix-grid input {
  min-width: 5rem;
  font-family: monospace;
  font-size: 0.9rem;
}
.eq-import label {
  margin: 0.6rem 0;
  max-width: 100%;
}
.eq-import input[type="file"] {
  max-width: 100%;
  font-size: 0.85rem;
}
.eq-export-options {
  margin: 0.75rem 0;
}
.eq-export-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.eq-palette-entries {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  max-height: 520px;
  overflow: auto;
  padding: 0.15rem;
}
.eq-symbol {
  display: flex;
  min-width: 0;
  border: 1px solid var(--bs-border-color, #d8e0e8);
  border-radius: 9px;
  overflow: hidden;
  background: var(--bs-body-bg);
}
.eq-symbol:hover {
  border-color: #367bf0;
}
.eq-symbol-insert {
  flex: 1;
  padding: 0.55rem 0.2rem;
  min-width: 0;
  color: inherit;
  background: transparent;
  border: 0;
}
.eq-symbol-preview {
  display: block;
  overflow: hidden;
  font-size: 1.15rem;
  min-height: 32px;
}
.eq-symbol-label {
  display: block;
  font-size: 0.7rem;
  line-height: 1.3;
  margin-top: 0.35rem;
  overflow-wrap: anywhere;
}
.eq-favorite {
  align-self: start;
  border: 0;
  background: transparent;
  color: #8b6b05;
  font-size: 1.1rem;
  padding: 0.2rem;
  min-width: 25px;
}
.eq-favorite[aria-pressed="true"] {
  color: #a87300;
}
.eq-library label {
  margin: 0.5rem 0;
}
#eqSnippets {
  margin: 0.8rem 0;
  font-size: 0.8rem;
  color: var(--bs-secondary-color);
}
.eq-snippet {
  display: flex;
  gap: 0.3rem;
  margin: 0.35rem 0;
}
.eq-snippet > button:first-child {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: left;
}
.eq-help {
  border: 1px solid var(--bs-border-color, #d8e0e8);
  padding: 1rem;
  border-radius: 12px;
  margin-top: 1.25rem;
  background: var(--bs-tertiary-bg, #f5f7fb);
}
.eq-help-heading {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.eq-help h3 {
  font-size: 1.1rem;
  margin: 0;
}
.eq-help-layout {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(0, 3fr);
  gap: 1rem;
  margin-top: 1rem;
}
.eq-help nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 420px;
  overflow: auto;
  padding: 0.2rem;
}
.eq-help nav button {
  text-align: left;
}
.eq-help nav button[aria-current="true"] {
  background: #367bf022;
  border-color: #367bf0;
}
.eq-help article {
  min-width: 0;
  font-size: 0.92rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.eq-help h4 {
  font-size: 1.05rem;
  margin-bottom: 0.8rem;
}
.eq-help table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.eq-help th,
.eq-help td {
  padding: 0.45rem;
  border: 1px solid var(--bs-border-color);
  vertical-align: top;
}
.eq-help code {
  white-space: normal;
}
.eq-help-example {
  margin: 0.25rem 0.3rem 0.25rem 0;
}
.eq-keyboard-host {
  position: relative;
  flex-shrink: 0;
  width: 100%;
  min-height: 0;
  --keyboard-zindex: 1100;
  --keyboard-background: var(--bs-tertiary-bg, #f0f3f8);
}
.eq-footer {
  border-top: 1px solid var(--bs-border-color);
  border-bottom: 0;
  align-items: center;
}
.eq-footer p {
  font-size: 0.76rem;
  color: var(--bs-secondary-color);
  margin: 0;
  max-width: 52ch;
}
.eq-footer > div {
  flex-shrink: 0;
}
.eq-footer kbd {
  background: transparent;
  color: inherit;
  padding: 0 0.2rem;
  font-size: 0.72rem;
}
@media (max-width: 800px) {
  .eq-workspace {
    display: flex;
    flex-direction: column;
  }
  .eq-palette {
    border-right: 0;
    border-top: 1px solid var(--bs-border-color);
    padding-right: 0;
    padding-top: 1rem;
  }
  .eq-palette-entries {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    max-height: 340px;
  }
  .eq-help-layout {
    grid-template-columns: 1fr;
  }
  .eq-help nav {
    max-height: 160px;
  }
  .eq-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 0.5rem;
  }
  .eq-footer > div {
    justify-content: flex-end;
  }
}
@media (max-width: 575.98px) {
  .equation-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .eq-header {
    padding: 0.75rem;
    align-items: start;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  .eq-header h2 {
    font-size: 1.1rem;
  }
  .eq-header p {
    font-size: 0.75rem;
  }
  .eq-header-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .eq-scroll {
    padding: 0.75rem;
  }
  .eq-footer {
    padding: 0.65rem 0.75rem;
  }
  .eq-footer > div {
    display: grid;
    grid-template-columns: auto 1fr;
  }
  .eq-footer kbd {
    display: none;
  }
  .eq-palette-entries {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .eq-help {
    padding: 0.7rem;
  }
  .eq-help-heading {
    flex-wrap: wrap;
  }
  .eq-toolbar,
  .eq-format-bar {
    gap: 0.3rem;
  }
  .eq-zoom-label {
    margin-left: 0;
  }
}
@media (pointer: coarse) {
  .equation-dialog button {
    min-height: 44px;
  }
}
