/* MetaMath — editor de fórmulas. Usa las variables de meta.css (modo oscuro incluido). */

/* ---------- Lista de fórmulas (izquierda) ---------- */
.mm-side { display: flex; flex-direction: column; }
.mm-side-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 6px 14px; }
.mm-side-head b { font-size: 11.5px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; }
.mm-list { display: grid; gap: 4px; padding: 2px 8px 14px; overflow-y: auto; align-content: start; }
.mm-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 2px;
  padding: 7px;
  border-radius: var(--r);
  outline: none;
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease), opacity var(--fast);
  animation: mo-rise var(--slow) var(--ease) both;
}
.mm-item:hover { background: var(--hover); }
.mm-item:focus-visible { box-shadow: 0 0 0 2px var(--accent-line); }
.mm-item.on { background: var(--accent-soft); }
.mm-item.drag { opacity: .4; }
.mm-item.over { box-shadow: inset 0 2px 0 var(--accent); }
.mm-item-prev {
  grid-column: 1 / -1;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--mid) var(--ease);
}
.mm-item.on .mm-item-prev { box-shadow: 0 0 0 2px var(--accent); }
.mm-item-prev svg { max-width: 100%; max-height: 40px; }
.mm-item-empty { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--ink-3); }
.mm-item-empty svg { width: 13px; height: 13px; color: var(--warn); }
.mm-item-name { display: flex; flex-direction: column; min-width: 0; padding-left: 3px; }
.mm-item-name span { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-item-name small { font-size: 10.5px; color: var(--ink-3); }
.mm-item.on .mm-item-name span { color: var(--accent); font-weight: 600; }
.mm-item-more { opacity: 0; transition: opacity var(--fast); }
.mm-item:hover .mm-item-more, .mm-item.on .mm-item-more { opacity: 1; }

/* ---------- Centro: fórmula arriba, código abajo ---------- */
.mm-center { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mm-stage { flex: 1; min-height: 70px; overflow: auto; display: grid; place-items: center; padding: 28px; }
.mm-paper {
  min-width: min(520px, 100%);
  padding: 30px 44px;
  border-radius: var(--r-lg);
  background: #fff;
  color: #000;
  box-shadow: var(--shadow-page);
  transition: opacity var(--mid) var(--ease), box-shadow var(--mid) var(--ease);
  animation: mo-sheet var(--slow) var(--spring);
}
.mm-paper.stale { opacity: .42; }
.mm-paper.empty { min-height: 150px; display: grid; place-items: center; }
.mm-render { line-height: 1; }
.mm-render svg { display: inline-block; overflow: visible; }
.mm-hint { display: flex; flex-direction: column; align-items: center; gap: 8px; font: 13px/1.4 var(--font); color: #8e8e93; text-align: center; }
.mm-hint svg { width: 30px; height: 30px; color: #c7c7cc; }

.mm-split { position: relative; flex: 0 0 8px; cursor: row-resize; background: var(--surface-2); border-top: .5px solid var(--line); touch-action: none; }
.mm-split::after { content: ""; position: absolute; left: 50%; top: 2.5px; width: 38px; height: 3px; margin-left: -19px; border-radius: 3px; background: var(--line); transition: background var(--fast); }
.mm-split:hover::after { background: var(--accent); }

.mm-editor { height: 36%; min-height: 90px; flex: 0 0 auto; display: flex; flex-direction: column; background: var(--surface); }
.mm-edhead { display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 2px 8px 0 14px; }
.mm-edlang { font-size: 11.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-edhead .mo-btn { color: var(--ink-2); }

/* Código con colores: un <pre> pintado detrás de un textarea transparente */
.mm-code { position: relative; flex: 1; min-height: 0; }
.mm-hl, .mm-ta {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 8px 16px 16px;
  border: 0;
  font: 14.5px/1.6 var(--mono);
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  overflow: auto;
}
.mm-hl { pointer-events: none; color: var(--ink); overflow: hidden; }
.mm-ta {
  resize: none;
  outline: none;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: var(--accent);
}
.mm-ta::placeholder { color: var(--ink-3); -webkit-text-fill-color: var(--ink-3); }
.mm-ta::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.mm-hl i { font-style: normal; }
.mm-hl .k { color: var(--accent); font-weight: 500; }
.mm-hl .k-rel, .mm-hl .k-sum, .mm-hl .k-prod { color: #c41040; }
.mm-hl .k-oper, .mm-hl .k-func, .mm-hl .k-unop { color: #3634a3; }
.mm-hl .k-attr, .mm-hl .k-font { color: #b25000; }
.mm-hl .k-lbrace, .mm-hl .k-rbrace, .mm-hl .k-both, .mm-hl .k-misc, .mm-hl .k-align, .mm-hl .k-power, .mm-hl .k-limit { color: #0055c2; }
.mm-hl .k-sym, .mm-hl .g { color: #00807a; }
.mm-hl .n { color: #c76f00; }
.mm-hl .s { color: #1f8a3c; }
.mm-hl .c { color: var(--ink-3); font-style: italic; }
.mm-hl .b, .mm-hl .o { color: var(--ink-3); }
.mm-hl .p { border-radius: 4px; background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 1px var(--accent-line); }
.mm-hl mark { color: inherit; background: color-mix(in srgb, var(--danger) 22%, transparent); border-radius: 3px; box-shadow: inset 0 -2px 0 var(--danger); }
:root[data-theme="dark"] .mm-hl .k-rel, :root[data-theme="dark"] .mm-hl .k-sum, :root[data-theme="dark"] .mm-hl .k-prod { color: #ff6b8e; }
:root[data-theme="dark"] .mm-hl .k-oper, :root[data-theme="dark"] .mm-hl .k-func, :root[data-theme="dark"] .mm-hl .k-unop { color: #a8a6ff; }
:root[data-theme="dark"] .mm-hl .k-attr, :root[data-theme="dark"] .mm-hl .k-font { color: #ffb05c; }
:root[data-theme="dark"] .mm-hl .k-lbrace, :root[data-theme="dark"] .mm-hl .k-rbrace, :root[data-theme="dark"] .mm-hl .k-both, :root[data-theme="dark"] .mm-hl .k-misc,
:root[data-theme="dark"] .mm-hl .k-align, :root[data-theme="dark"] .mm-hl .k-power, :root[data-theme="dark"] .mm-hl .k-limit { color: #6cb4ff; }
:root[data-theme="dark"] .mm-hl .k-sym, :root[data-theme="dark"] .mm-hl .g { color: #4fd8cf; }
:root[data-theme="dark"] .mm-hl .n { color: #ffb340; }
:root[data-theme="dark"] .mm-hl .s { color: #6ee08a; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mm-hl .k-rel, :root:not([data-theme="light"]) .mm-hl .k-sum, :root:not([data-theme="light"]) .mm-hl .k-prod { color: #ff6b8e; }
  :root:not([data-theme="light"]) .mm-hl .k-oper, :root:not([data-theme="light"]) .mm-hl .k-func, :root:not([data-theme="light"]) .mm-hl .k-unop { color: #a8a6ff; }
  :root:not([data-theme="light"]) .mm-hl .k-attr, :root:not([data-theme="light"]) .mm-hl .k-font { color: #ffb05c; }
  :root:not([data-theme="light"]) .mm-hl .k-lbrace, :root:not([data-theme="light"]) .mm-hl .k-rbrace, :root:not([data-theme="light"]) .mm-hl .k-both,
  :root:not([data-theme="light"]) .mm-hl .k-misc, :root:not([data-theme="light"]) .mm-hl .k-align, :root:not([data-theme="light"]) .mm-hl .k-power,
  :root:not([data-theme="light"]) .mm-hl .k-limit { color: #6cb4ff; }
  :root:not([data-theme="light"]) .mm-hl .k-sym, :root:not([data-theme="light"]) .mm-hl .g { color: #4fd8cf; }
  :root:not([data-theme="light"]) .mm-hl .n { color: #ffb340; }
  :root:not([data-theme="light"]) .mm-hl .s { color: #6ee08a; }
}

.mm-err {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
  border-top: .5px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.mm-err.on { display: flex; animation: mo-rise var(--mid) var(--ease); }
.mm-err svg { width: 16px; height: 16px; flex: 0 0 auto; }
.mm-err span { flex: 1; min-width: 0; }
.mm-errgo { border: 0; background: transparent; color: inherit; font-size: 12px; text-decoration: underline; text-underline-offset: 2px; padding: 0; white-space: nowrap; }

/* ---------- Panel de elementos (derecha) ---------- */
.mm-elements { padding: 0; display: flex; flex-direction: column; }
.mm-el-head { position: sticky; top: 0; z-index: 1; display: flex; gap: 6px; padding: 10px; background: var(--surface-2); border-bottom: .5px solid var(--line); }
.mm-el-head .mo-select { flex: 1; }
.mm-el-close { display: none !important; }
.mm-el-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; padding: 10px 10px 18px; }
.mm-el-grid.big { grid-template-columns: 1fr; }
.mm-el {
  height: 50px;
  padding: 4px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-size: 11px;
  transition: transform var(--fast) var(--spring), box-shadow var(--fast) var(--ease), background var(--fast);
  animation: mo-rise .36s var(--ease) both;
}
.mm-el:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.mm-el:active { transform: scale(.93); }
.mm-el:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--accent); }
.mm-el svg { max-width: 100%; max-height: 42px; }
.mm-el-grid.big .mm-el { height: auto; min-height: 58px; padding: 10px 8px; }

/* ---------- Plantillas, exportar, guía ---------- */
.mm-tpl { width: 100%; height: 100%; display: grid; place-items: center; padding: 10px; color: #1d1d1f; overflow: hidden; }
.mm-tpl svg { max-width: 100%; max-height: 100%; }
.mm-tpl-blank svg { width: 38px; height: 38px; color: #aeaeb2; }
.mm-exopts { margin-top: 16px; }
.mm-ex-note { min-height: 1em; font-size: 12px; margin: 2px 0 0 !important; }
.mm-guide code { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.mm-toolbar .mo-select[data-a="size"] { width: 74px; }
.mm-toolbar .mo-select[data-a="font"] { width: 98px; }
.mm-toolbar .mo-seg button { display: inline-flex; align-items: center; }
.mm-align button { padding: 4px 7px; }
.mm-align svg { width: 15px; height: 15px; }

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  .mm-stage { padding: 14px 10px; }
  .mm-paper { min-width: 0; max-width: 100%; padding: 18px 16px; }
  .mm-render { overflow-x: auto; }
  .mm-editor { height: 42%; }
  .mm-hl, .mm-ta { font-size: 15px; padding: 6px 12px 12px; }
  .mm-elements { max-height: 58dvh; }
  .mm-el-close { display: inline-flex !important; }
  .mm-el { height: 54px; }
  .mm-el-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
  .mm-side { width: 240px; flex-basis: 240px; }
  .mm-toolbar .mo-select[data-a="font"] { width: 88px; }
  .mm-edhead .mo-btn span { display: none; }
}
@media print { .mm-side, .mm-elements, .mm-editor, .mm-split { display: none !important; } .mm-stage { overflow: visible; } }
