/* ==========================================================
   MetaOffice — sistema de diseño común
   Minimalismo tipo Apple: superficies limpias, cristal, muelles suaves.
   Cada app fija su color con <body data-app="doc|cell|slide|draw|math|base">.
   ========================================================== */

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --surface-3: #f2f2f5;
  --glass: rgba(255, 255, 255, .74);
  --glass-strong: rgba(255, 255, 255, .9);
  --canvas: #e8e8ed;
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --ink-3: #8e8e93;
  --line: rgba(0, 0, 0, .1);
  --line-2: rgba(0, 0, 0, .06);
  --hover: rgba(0, 0, 0, .05);
  --press: rgba(0, 0, 0, .09);
  --danger: #ff3b30;
  --ok: #34c759;
  --warn: #ff9f0a;

  --accent: #007aff;
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
  --accent-line: color-mix(in srgb, var(--accent) 40%, transparent);

  --r-xs: 5px;
  --r-sm: 7px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-2xl: 28px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06), 0 0 0 .5px rgba(0, 0, 0, .05);
  --shadow: 0 4px 16px -6px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .06);
  --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, .28), 0 0 0 .5px rgba(0, 0, 0, .1);
  --shadow-page: 0 1px 3px rgba(0, 0, 0, .08), 0 10px 30px -12px rgba(0, 0, 0, .18);

  --ease: cubic-bezier(.32, .72, 0, 1);
  --spring: cubic-bezier(.34, 1.4, .64, 1);
  --fast: .16s;
  --mid: .28s;
  --slow: .5s;

  --titlebar-h: 52px;
  --menubar-h: 32px;
  --toolbar-h: 48px;
  --statusbar-h: 28px;

  color-scheme: light;
}

body[data-app="doc"]   { --accent: #007aff; }
body[data-app="cell"]  { --accent: #28a745; }
body[data-app="slide"] { --accent: #ff7a00; }
body[data-app="draw"]  { --accent: #f2b200; --accent-ink: #1d1d1f; }
body[data-app="math"]  { --accent: #5856d6; }
body[data-app="base"]  { --accent: #af52de; }

/* ---------- Modo oscuro (automático o elegido) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1e; --surface: #2c2c2e; --surface-2: #242426; --surface-3: #3a3a3c;
    --glass: rgba(36, 36, 38, .74); --glass-strong: rgba(40, 40, 42, .92); --canvas: #121214;
    --ink: #f5f5f7; --ink-2: #aeaeb2; --ink-3: #8e8e93;
    --line: rgba(255, 255, 255, .12); --line-2: rgba(255, 255, 255, .07);
    --hover: rgba(255, 255, 255, .07); --press: rgba(255, 255, 255, .12);
    --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, .7), 0 0 0 .5px rgba(255, 255, 255, .12);
    --shadow: 0 4px 16px -6px rgba(0, 0, 0, .6), 0 0 0 .5px rgba(255, 255, 255, .08);
    --shadow-page: 0 1px 3px rgba(0, 0, 0, .4), 0 12px 34px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1c1c1e; --surface: #2c2c2e; --surface-2: #242426; --surface-3: #3a3a3c;
  --glass: rgba(36, 36, 38, .74); --glass-strong: rgba(40, 40, 42, .92); --canvas: #121214;
  --ink: #f5f5f7; --ink-2: #aeaeb2; --ink-3: #8e8e93;
  --line: rgba(255, 255, 255, .12); --line-2: rgba(255, 255, 255, .07);
  --hover: rgba(255, 255, 255, .07); --press: rgba(255, 255, 255, .12);
  --shadow-pop: 0 18px 50px -12px rgba(0, 0, 0, .7), 0 0 0 .5px rgba(255, 255, 255, .12);
  --shadow: 0 4px 16px -6px rgba(0, 0, 0, .6), 0 0 0 .5px rgba(255, 255, 255, .08);
  --shadow-page: 0 1px 3px rgba(0, 0, 0, .4), 0 12px 34px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: default; }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }
.mo-hidden { display: none !important; }

* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--ink) 22%, transparent) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--ink) 20%, transparent); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--ink) 35%, transparent); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Esqueleto de una app ---------- */
.mo-shell {
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--titlebar-h) var(--menubar-h) auto 1fr var(--statusbar-h);
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}
.mo-main { position: relative; min-height: 0; display: flex; overflow: hidden; background: var(--canvas); }
.mo-workspace { position: relative; flex: 1; min-width: 0; overflow: auto; }

/* Barra de título */
.mo-titlebar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.mo-titlebar .mo-home { flex: 0 0 auto; }
.mo-brand { display: flex; align-items: center; gap: 9px; min-width: 0; flex: 1; }
.mo-brand .mo-appicon { flex: 0 0 auto; }
.mo-doctitle { display: flex; flex-direction: column; min-width: 0; }
.mo-doctitle input {
  border: 0;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 2px 6px;
  margin-left: -6px;
  border-radius: var(--r-xs);
  min-width: 60px;
  max-width: min(46vw, 420px);
  outline: none;
  transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.mo-doctitle input:hover { background: var(--hover); }
.mo-doctitle input:focus { background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent-line); }
.mo-doctitle small { font-size: 11px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; padding-left: 0; white-space: nowrap; }
.mo-doctitle small .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); transition: background var(--mid) var(--ease); }
.mo-doctitle small.saving .dot { background: var(--warn); }
.mo-titlebar-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
/* Selector de idioma (idioma_selector() de la web, con el aspecto de los botones de la barra) */
.mo-titlebar .mw-idioma-btn { height: 30px; padding: 0 9px; border-radius: var(--r-sm); color: var(--ink-2); font-size: 12px; opacity: 1; }
.mo-titlebar .mw-idioma-btn:hover, .mo-titlebar .mw-idioma.abierto .mw-idioma-btn { background: var(--hover); color: var(--ink); }
.mo-titlebar .mw-idiomas { top: calc(100% + 6px); right: 0; background: var(--glass-strong); box-shadow: var(--shadow-pop); border-radius: var(--r-lg); }
.mo-titlebar .mw-idiomas a { color: var(--ink); font-size: 13px; padding: 7px 10px; border-radius: var(--r-sm); }
.mo-titlebar .mw-idiomas a:hover, .mo-titlebar .mw-idiomas a:focus-visible { background: var(--hover); }
.mo-titlebar .mw-idiomas a[aria-current]::after { border-color: var(--accent); }

/* Barra de menús (tipo LibreOffice, con estilo Apple) */
.mo-menubar {
  position: relative;
  z-index: 29;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 8px;
  background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.mo-menubar::-webkit-scrollbar { display: none; }
.mo-menubar > button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  transition: background var(--fast) var(--ease);
}
.mo-menubar > button:hover, .mo-menubar > button.open { background: var(--press); }

/* Barra de herramientas */
.mo-toolbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--toolbar-h);
  padding: 7px 10px;
  background: var(--surface-2);
  border-bottom: .5px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.mo-toolbar::-webkit-scrollbar { display: none; }
.mo-toolbar + .mo-toolbar { min-height: 40px; padding-top: 4px; padding-bottom: 4px; }
.mo-group { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.mo-group.boxed { background: var(--surface-3); border-radius: var(--r); padding: 2px; }
.mo-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; flex: 0 0 auto; }
.mo-spacer { flex: 1; }

/* ---------- Botones ---------- */
.mo-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), color var(--fast) var(--ease);
}
.mo-btn:hover { background: color-mix(in srgb, var(--surface) 92%, var(--ink)); }
.mo-btn:active { transform: scale(.96); }
.mo-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent); }
.mo-btn[disabled] { opacity: .4; pointer-events: none; }
.mo-btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.mo-btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.mo-btn.danger { background: var(--danger); color: #fff; }
.mo-btn.ghost { background: transparent; box-shadow: none; }
.mo-btn.ghost:hover { background: var(--hover); }
.mo-btn.icon { width: 30px; padding: 0; }
.mo-btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.mo-btn.sm.icon { width: 26px; }
.mo-btn.lg { height: 38px; padding: 0 18px; font-size: 14px; border-radius: var(--r); }
.mo-btn.pill { border-radius: 99px; }
.mo-btn svg { width: 17px; height: 17px; flex: 0 0 auto; }
.mo-btn.sm svg { width: 15px; height: 15px; }

/* Botón de herramienta (sin fondo, se ilumina al activarse) */
.mo-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  user-select: none;
  flex: 0 0 auto;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.mo-tool:hover { background: var(--hover); }
.mo-tool:active { transform: scale(.92); background: var(--press); }
.mo-tool.on { background: var(--accent-soft); color: var(--accent); }
body[data-app="draw"] .mo-tool.on { color: color-mix(in srgb, var(--accent) 70%, #000); }
.mo-tool[disabled] { opacity: .35; pointer-events: none; }
.mo-tool svg { width: 18px; height: 18px; flex: 0 0 auto; }
.mo-tool .lbl { font-size: 12px; }
.mo-tool.stack { flex-direction: column; height: auto; padding: 4px 8px; gap: 2px; }
.mo-tool.stack .lbl { font-size: 10.5px; color: var(--ink-2); }
.mo-tool .caret { width: 10px !important; height: 10px !important; opacity: .55; margin-left: -1px; }

/* Botón de color: icono + barra con el color actual */
.mo-colorbtn { position: relative; flex-direction: column; gap: 0; padding-top: 2px; }
.mo-colorbtn svg { width: 16px; height: 16px; }
.mo-colorbtn .bar { width: 16px; height: 3.5px; border-radius: 2px; margin-top: 1px; background: currentColor; box-shadow: 0 0 0 .5px var(--line); }

/* ---------- Campos ---------- */
.mo-input, .mo-select, .mo-textarea {
  height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: inset 0 0 0 .5px var(--line), var(--shadow-sm);
  outline: none;
  font-size: 13px;
  min-width: 0;
  transition: box-shadow var(--fast) var(--ease);
}
.mo-textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.45; }
.mo-input:focus, .mo-select:focus, .mo-textarea:focus { box-shadow: 0 0 0 3px var(--accent-soft), inset 0 0 0 1px var(--accent); }
.mo-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
.mo-toolbar .mo-select, .mo-toolbar .mo-input { height: 28px; font-size: 12.5px; }
.mo-input[type="color"] { padding: 3px; width: 40px; cursor: pointer; }
.mo-input[type="number"] { width: 64px; }
.mo-input[type="range"] { box-shadow: none; background: transparent; padding: 0; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

.mo-field { display: grid; gap: 5px; margin-bottom: 12px; }
.mo-field > span, .mo-label { font-size: 11.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.mo-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mo-row > .mo-field { flex: 1; min-width: 110px; }
.mo-check { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }

/* Interruptor */
.mo-switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 auto; }
.mo-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.mo-switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); box-shadow: inset 0 0 0 .5px var(--line); transition: background var(--mid) var(--ease); }
.mo-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform var(--mid) var(--spring); }
.mo-switch input:checked + span { background: var(--ok); }
.mo-switch input:checked + span::after { transform: translateX(16px); }

/* Control segmentado */
.mo-seg { display: inline-flex; position: relative; padding: 2px; border-radius: var(--r-sm); background: var(--surface-3); gap: 0; }
.mo-seg button { position: relative; z-index: 1; border: 0; background: transparent; padding: 4px 12px; font-size: 12.5px; font-weight: 500; border-radius: 6px; color: var(--ink-2); transition: color var(--fast) var(--ease); white-space: nowrap; }
.mo-seg button.on { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 0 0 .5px var(--line-2); }
.mo-seg button svg { width: 16px; height: 16px; display: block; }
.mo-seg.full { display: flex; }
.mo-seg.full button { flex: 1; }

/* ---------- Menús desplegables ---------- */
.mo-menu {
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  max-width: 340px;
  max-height: calc(100dvh - 20px);
  overflow-y: auto;
  padding: 5px;
  border-radius: var(--r);
  background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  box-shadow: var(--shadow-pop);
  transform-origin: top left;
  animation: mo-pop var(--mid) var(--spring);
  user-select: none;
}
.mo-menu.closing { animation: mo-fade-out var(--fast) var(--ease) forwards; }
.mo-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 26px;
  padding: 3px 10px 3px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  text-align: left;
  color: var(--ink);
}
.mo-menu-item .ic { width: 16px; height: 16px; flex: 0 0 16px; display: grid; place-items: center; color: var(--ink-2); }
.mo-menu-item .ic svg { width: 15px; height: 15px; }
.mo-menu-item .tx { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mo-menu-item .kb { font-size: 12px; color: var(--ink-3); letter-spacing: .04em; white-space: nowrap; }
@media (hover: none) and (pointer: coarse) { .mo-menu-item .kb { display: none; } } /* en el móvil no hay atajos de teclado */
.mo-menu-item .sub { width: 10px; height: 10px; opacity: .6; }
.mo-menu-item:hover, .mo-menu-item.hl { background: var(--accent); color: var(--accent-ink); }
.mo-menu-item:hover .ic, .mo-menu-item:hover .kb, .mo-menu-item.hl .ic, .mo-menu-item.hl .kb { color: inherit; opacity: .9; }
.mo-menu-item[disabled] { opacity: .38; pointer-events: none; }
.mo-menu-item.danger { color: var(--danger); }
.mo-menu-item.danger:hover { background: var(--danger); color: #fff; }
.mo-menu-sep { height: 1px; margin: 5px 8px; background: var(--line); }
.mo-menu-head { padding: 6px 10px 3px; font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Popover (colores, tablas, formas...) ---------- */
.mo-popover {
  position: fixed;
  z-index: 1001;
  padding: 12px;
  border-radius: var(--r-lg);
  background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(28px);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  box-shadow: var(--shadow-pop);
  transform-origin: top center;
  animation: mo-pop var(--mid) var(--spring);
}
.mo-swatches { display: grid; grid-template-columns: repeat(10, 20px); gap: 5px; }
.mo-swatch { width: 20px; height: 20px; border-radius: 5px; border: 0; padding: 0; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .18); transition: transform var(--fast) var(--spring); }
.mo-swatch:hover { transform: scale(1.18); }
.mo-swatch.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%), var(--surface); }
.mo-popover-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }

/* ---------- Diálogos (hojas) ---------- */
.mo-backdrop {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .28);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: mo-fade var(--mid) var(--ease);
}
.mo-backdrop.closing { animation: mo-fade-out var(--mid) var(--ease) forwards; }
.mo-dialog {
  width: min(var(--w, 460px), 100%);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: mo-sheet var(--slow) var(--spring);
  overflow: hidden;
}
.mo-backdrop.closing .mo-dialog { animation: mo-sheet-out var(--mid) var(--ease) forwards; }
.mo-dialog-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 4px; }
.mo-dialog-head h2 { margin: 0; flex: 1; font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.mo-dialog-body { padding: 12px 20px 8px; overflow: auto; }
.mo-dialog-body p { margin: 0 0 10px; color: var(--ink-2); }
.mo-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; flex-wrap: wrap; }
.mo-dialog-foot .left { margin-right: auto; }

/* Rejilla de formatos para «Descargar como» */
.mo-formats { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.mo-format {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 8px 12px;
  border: 0;
  border-radius: var(--r-lg);
  background: var(--surface-3);
  text-align: center;
  transition: transform var(--mid) var(--spring), box-shadow var(--mid) var(--ease), background var(--fast) var(--ease);
}
.mo-format:hover { transform: translateY(-3px); background: var(--surface); box-shadow: var(--shadow); }
.mo-format:active { transform: scale(.97); }
.mo-format.on { box-shadow: 0 0 0 2px var(--accent); background: var(--surface); }
.mo-format .file {
  position: relative;
  width: 44px;
  height: 54px;
  border-radius: 6px 14px 6px 6px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--fc, var(--accent)) 85%, #fff), var(--fc, var(--accent)));
  box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--fc, var(--accent)) 70%, transparent);
  display: grid;
  place-items: end center;
  padding-bottom: 7px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .03em;
}
.mo-format .file::before { content: ""; position: absolute; top: 0; right: 0; width: 14px; height: 14px; border-radius: 0 14px 0 6px; background: rgba(255, 255, 255, .45); }
.mo-format b { font-size: 12.5px; font-weight: 600; }
.mo-format small { font-size: 11px; color: var(--ink-3); line-height: 1.25; }

/* Galería de plantillas */
.mo-templates { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.mo-template { border: 0; background: transparent; padding: 0; text-align: center; display: grid; gap: 8px; }
.mo-template .thumb {
  aspect-ratio: var(--ar, 3 / 4);
  border-radius: var(--r);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform var(--mid) var(--spring), box-shadow var(--mid) var(--ease);
  display: grid;
  place-items: center;
}
.mo-template:hover .thumb { transform: translateY(-4px) scale(1.02); box-shadow: var(--shadow-pop); }
.mo-template.on .thumb { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.mo-template span { font-size: 12.5px; font-weight: 500; }

/* ---------- Avisos flotantes ---------- */
.mo-toasts { position: fixed; left: 50%; bottom: calc(var(--statusbar-h) + 18px); transform: translateX(-50%); z-index: 1100; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(520px, calc(100% - 32px)); }
.mo-toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 16px;
  border-radius: 99px;
  background: color-mix(in srgb, #1d1d1f 88%, transparent);
  color: #fff;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .45);
  font-size: 13px;
  font-weight: 500;
  animation: mo-toast-in var(--slow) var(--spring);
  pointer-events: auto;
}
.mo-toast.out { animation: mo-toast-out var(--mid) var(--ease) forwards; }
.mo-toast svg { width: 16px; height: 16px; }
.mo-toast.ok svg { color: #30d158; }
.mo-toast.error svg { color: #ff453a; }

/* ---------- Inspector (panel lateral derecho tipo Pages) ---------- */
.mo-inspector {
  flex: 0 0 280px;
  width: 280px;
  min-height: 0;
  overflow-y: auto;
  background: var(--surface-2);
  border-left: .5px solid var(--line);
  padding: 14px;
  transition: margin-right var(--slow) var(--ease), opacity var(--mid) var(--ease);
}
.mo-inspector.collapsed { margin-right: -280px; opacity: 0; pointer-events: none; }
.mo-preload .mo-inspector, .mo-preload .mo-sidebar { transition: none !important; }
.mo-inspector h3 { margin: 4px 0 10px; font-size: 13px; font-weight: 600; }
.mo-inspector section { padding: 12px 0; border-bottom: .5px solid var(--line); }
.mo-inspector section:last-child { border-bottom: 0; }
.mo-sidebar {
  flex: 0 0 210px;
  width: 210px;
  min-height: 0;
  overflow-y: auto;
  background: var(--surface-2);
  border-right: .5px solid var(--line);
  transition: margin-left var(--slow) var(--ease), opacity var(--mid) var(--ease);
}
.mo-sidebar.collapsed { margin-left: -210px; opacity: 0; pointer-events: none; }

/* ---------- Barra de estado y firma ---------- */
.mo-statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  font-size: 11.5px;
  color: var(--ink-2);
  background: var(--surface-2);
  border-top: .5px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
}
.mo-statusbar .mo-spacer { flex: 1; }
.mo-statusbar .mo-zoom { display: flex; align-items: center; gap: 6px; }
.mo-statusbar .mo-zoom input[type="range"] { width: 110px; height: 16px; }
.mo-statusbar button { border: 0; background: transparent; color: inherit; padding: 2px 6px; border-radius: 5px; font-size: 11.5px; }
.mo-statusbar button:hover { background: var(--hover); color: var(--ink); }
.firma { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.05; color: var(--ink-3); font-size: 10px; }
.firma .v { font-weight: 600; font-variant-numeric: tabular-nums; }
.firma .a { font-size: 9.5px; }
.firma.center { align-items: center; }

/* ---------- Iconos de app ---------- */
.mo-appicon { --s: 28px; width: var(--s); height: var(--s); border-radius: calc(var(--s) * .235); display: inline-grid; place-items: center; flex: 0 0 auto; overflow: hidden; }
.mo-appicon svg { width: 100%; height: 100%; display: block; }

/* ---------- Utilidades ---------- */
.mo-empty { display: grid; place-items: center; gap: 8px; padding: 40px 20px; color: var(--ink-3); text-align: center; }
.mo-kbd { font-family: var(--font); font-size: 11px; padding: 1px 6px; border-radius: 5px; background: var(--surface-3); box-shadow: inset 0 -1px 0 var(--line); }
.mo-badge { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.mo-tabs { display: flex; gap: 2px; border-bottom: .5px solid var(--line); margin-bottom: 12px; }
.mo-tabs button { border: 0; background: transparent; padding: 7px 10px; font-size: 12.5px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color var(--fast), border-color var(--mid) var(--ease); }
.mo-tabs button.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.mo-list { display: grid; gap: 2px; }
.mo-list button { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 6px 10px; border-radius: var(--r-sm); text-align: left; font-size: 13px; }
.mo-list button:hover { background: var(--hover); }
.mo-list button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mo-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.mo-table th, .mo-table td { padding: 6px 8px; text-align: left; border-bottom: .5px solid var(--line); }
.mo-table th { font-weight: 600; color: var(--ink-2); font-size: 11.5px; }
.mo-spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: mo-rot .8s linear infinite; }

/* Pantalla de carga */
.mo-loading { position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center; background: var(--bg); transition: opacity var(--slow) var(--ease), visibility var(--slow); }
.mo-loading.done { opacity: 0; visibility: hidden; }
.mo-loading .mo-appicon { --s: 72px; animation: mo-breathe 1.6s var(--ease) infinite; box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .4); }

/* ---------- Animaciones ---------- */
@keyframes mo-pop { from { opacity: 0; transform: scale(.94) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes mo-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mo-fade-out { to { opacity: 0; } }
@keyframes mo-sheet { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes mo-sheet-out { to { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes mo-toast-in { from { opacity: 0; transform: translateY(16px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes mo-toast-out { to { opacity: 0; transform: translateY(8px) scale(.96); } }
@keyframes mo-rot { to { transform: rotate(360deg); } }
@keyframes mo-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes mo-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.mo-rise { animation: mo-rise var(--slow) var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
  :root { --titlebar-h: 50px; --menubar-h: 34px; }
  .mo-titlebar { padding: 0 8px; gap: 6px; }
  .mo-titlebar-actions .mo-btn .lbl { display: none; }
  .mo-titlebar-actions .mo-btn:not(.icon) { padding: 0 9px; }
  .mo-titlebar .mw-idioma-btn { padding: 0 6px; gap: 3px; }
  .mo-doctitle input { max-width: 38vw; font-size: 13.5px; }
  .mo-menubar { padding: 0 4px; }
  .mo-menubar > button { padding: 6px 10px; font-size: 13.5px; }
  .mo-menu { min-width: 0; max-width: calc(100vw - 16px); }
  .mo-menu-item { min-height: 36px; font-size: 14px; }
  .mo-tool { min-width: 36px; height: 36px; }
  .mo-inspector {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    width: auto;
    max-height: 62dvh;
    border-left: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: var(--shadow-pop);
    transition: transform var(--slow) var(--ease), opacity var(--mid) var(--ease);
  }
  .mo-inspector.collapsed { margin-right: 0; transform: translateY(105%); }
  .mo-sidebar { position: absolute; top: 0; bottom: 0; left: 0; z-index: 50; box-shadow: var(--shadow-pop); }
  .mo-statusbar { gap: 8px; }
  .mo-statusbar .mo-hide-sm { display: none; }
  .mo-statusbar .mo-zoom input[type="range"] { width: 70px; }
  .mo-dialog { border-radius: var(--r-xl); }
  .mo-backdrop { align-items: end; padding: 8px; }
  .mo-formats { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}
@media print {
  .mo-titlebar, .mo-menubar, .mo-toolbar, .mo-statusbar, .mo-inspector, .mo-sidebar, .mo-toasts { display: none !important; }
}
