/* ==========================================================================
   Editor HTML — hoja de estilos principal
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;

  --bg: #eeeae1;
  --paper: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f4ed;
  --surface-3: #f1ede4;
  --border: #dfd9cc;
  --border-strong: #c9c1b1;
  --text: #211e19;
  --text-2: #4d473d;
  --muted: #7a7264;
  --muted-2: #a49b8b;
  --accent: #b84516;
  --accent-strong: #91330c;
  --accent-soft: #fbe8dc;
  --accent-soft-2: rgba(184, 69, 22, .13);
  --accent-contrast: #ffffff;
  --teal: #0e658f;
  --teal-soft: #e2f1f8;
  --green: #1c7a4b;
  --green-soft: #e3f5ea;
  --red: #b42318;
  --red-soft: #fdecea;
  --amber: #9a6200;
  --amber-soft: #fdf1d8;
  --selection: rgba(184, 69, 22, .2);
  --page-canvas: #e2dccf;
  --shadow-sm: 0 1px 2px rgba(42, 33, 20, .05), 0 3px 10px -6px rgba(42, 33, 20, .18);
  --shadow-md: 0 2px 6px rgba(42, 33, 20, .06), 0 18px 40px -22px rgba(42, 33, 20, .35);
  --shadow-lg: 0 30px 70px -30px rgba(24, 18, 10, .55);
  --radius: 12px;
  --radius-sm: 8px;
  --font-ui: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, "Liberation Mono", monospace;
  --topbar-h: 58px;
  --status-h: 32px;
  --cm-tag: #b23c17;
  --cm-attr: #0f6b63;
  --cm-string: #7c3aed;
  --cm-comment: #9a9284;
  --cm-atom: #2456c4;
  --cm-keyword: #9a3412;
  --cm-number: #0f6b63;
  --cm-operator: #6b6255;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p, dl, dd { margin: 0; }
img, svg { max-width: 100%; }
a { color: var(--teal); }
[hidden] { display: none !important; }
::selection { background: var(--selection); }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.icon--sm { width: 14px; height: 14px; }
.icon--xs { width: 12px; height: 12px; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible), select:focus:not(:focus-visible) { outline: none; }

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid transparent;
  border-radius: 10px;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: content-box; border: 3px solid transparent; }

/* ---------- Botones y controles ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .1s ease, box-shadow .16s ease;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; }

.btn--ghost { border-color: transparent; }
.btn--ghost:hover { border-color: var(--border); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06), 0 4px 12px -6px rgba(184, 69, 22, .7);
}
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--accent-contrast); }

.btn--soft {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-2);
}
.btn--soft:hover { background: var(--surface-2); border-color: var(--border-strong); }

.btn--sm { height: 29px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn--sm .icon { width: 14px; height: 14px; }

.btn--danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn--danger:hover { filter: brightness(1.08); color: #fff; }
.btn--danger-ghost { color: var(--red); }
.btn--danger-ghost:hover { background: var(--red-soft); border-color: transparent; color: var(--red); }

.btn--clean {
  height: 30px;
  padding: 0 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, #c9501d, var(--accent));
  border: 1px solid var(--accent-strong);
  color: #fff;
  font-weight: 700;
  letter-spacing: .01em;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .22) inset, 0 4px 12px -6px rgba(184, 69, 22, .8);
}
.btn--clean:hover { filter: brightness(1.06); color: #fff; }
.btn--clean .icon { width: 15px; height: 15px; }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.iconbtn:active { transform: translateY(1px); }
.iconbtn.is-active, .iconbtn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent-strong);
}
.iconbtn:disabled { opacity: .35; pointer-events: none; }
.iconbtn--xs { width: 24px; height: 24px; }
.iconbtn--xs .icon { width: 14px; height: 14px; }

.linkbtn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--teal);
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linkbtn:hover { color: var(--accent); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
}
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* ---------- Barra superior ---------- */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-h);
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand-logo { width: 30px; height: 30px; flex: 0 0 auto; display: block; }
.brand-name { font-size: 15.5px; letter-spacing: -.01em; white-space: nowrap; }
.brand-name strong { font-weight: 800; color: var(--accent); }

.topbar-center { flex: 1 1 auto; display: flex; justify-content: center; min-width: 0; }
.viewswitch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.viewswitch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: all .15s ease;
}
.viewswitch-btn .icon { width: 15px; height: 15px; }
.viewswitch-btn:hover { color: var(--text); }
.viewswitch-btn.is-active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(42, 33, 20, .08);
}

.topbar-actions { display: flex; align-items: center; gap: 5px; }
.menu-anchor { position: relative; }
.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 500;
  width: 292px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  animation: menu-in .14s ease-out;
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-5px) scale(.985); } to { opacity: 1; transform: none; } }
.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); outline: none; }
.menu button > .icon { width: 18px; height: 18px; color: var(--muted); }
.menu button span { display: flex; flex-direction: column; gap: 1px; }
.menu button strong { font-size: 12.5px; font-weight: 700; color: var(--text); }
.menu button small { font-size: 11px; color: var(--muted); }

/* ---------- Layout de trabajo ---------- */
.app-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  padding: 10px;
  background: var(--bg);
}
.workspace {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--split, 50%) 12px minmax(0, 1fr);
  align-items: stretch;
}
.workspace[data-view="visual"] { grid-template-columns: minmax(0, 1fr); }
.workspace[data-view="visual"] .splitter,
.workspace[data-view="visual"] .pane--source { display: none; }
.workspace[data-view="source"] { grid-template-columns: minmax(0, 1fr); }
.workspace[data-view="source"] .splitter,
.workspace[data-view="source"] .pane--visual { display: none; }
.workspace[data-view="source"] .cm-wrap { min-height: 180px; }
/* El botón «Dividido» intercambia los paneles: el de código pasa a la izquierda. */
.workspace.is-swapped .pane--source { order: 1; }
.workspace.is-swapped .splitter { order: 2; }
.workspace.is-swapped .pane--visual { order: 3; }

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.splitter {
  position: relative;
  cursor: col-resize;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.splitter::before {
  content: "";
  width: 3px;
  height: 44px;
  max-height: 40%;
  border-radius: 3px;
  background: var(--border-strong);
  opacity: .55;
  transition: background .15s ease, opacity .15s ease, height .15s ease;
}
.splitter:hover::before, .splitter:focus-visible::before, .splitter.is-dragging::before {
  background: var(--accent);
  opacity: 1;
  height: 72px;
}
.splitter:focus-visible { outline: none; }
body.is-resizing { cursor: col-resize; user-select: none; }
body.is-resizing iframe { pointer-events: none; }

/* ---------- Cabeceras de panel ---------- */
.pane-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.file-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}
.file-tab .icon { width: 15px; height: 15px; color: var(--muted); }
.file-tab span:not(.dirty-dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name-edit {
  display: inline-flex;
  align-items: baseline;
  min-width: 0;
  max-width: 100%;
}
.file-name-edit input {
  width: 13ch;
  min-width: 3ch;
  max-width: 42ch;
  height: 22px;
  margin: 0 -1px 0 0;
  padding: 0 2px;
  border: 1px solid transparent;
  border-radius: 5px 0 0 5px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-weight: 600;
  text-overflow: ellipsis;
}
.file-name-edit input:hover { border-color: var(--border); background: var(--surface-2); }
.file-name-edit input:focus {
  border-color: var(--accent);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  outline: 2px solid var(--accent-soft-2);
}
.file-ext {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-weight: 600;
  user-select: none;
}
.dirty-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}
.source-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 3px 0;
}
.source-actions::-webkit-scrollbar { display: none; }
.source-actions .iconbtn { width: 28px; height: 28px; }
.source-actions .iconbtn .icon { width: 16px; height: 16px; }
.toolbar-sep { width: 1px; height: 16px; background: var(--border); margin: 0 3px; flex: 0 0 auto; }
.tb-sep { width: 1px; height: 16px; margin: 0 2px; background: var(--border); flex: 0 0 auto; }
.char-pill {
  display: inline-flex;
  align-items: center;
  height: 21px;
  margin-left: 6px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Barra de herramientas WYSIWYG ---------- */
.toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1px 1px;
  min-height: 44px;
  padding: 3px 6px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  user-select: none;
}
.tb-group {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0 4px;
  border-right: 1px solid var(--border);
  flex: 0 0 auto;
}
.tb-group:first-child { padding-left: 0; }
.tb-group:last-child { border-right: 0; padding-right: 0; }

.tbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  transition: background .14s ease, color .14s ease;
}
.tbtn:hover { background: var(--surface-2); color: var(--text); }
.tbtn:active { transform: translateY(1px); }
.tbtn.is-active, .tbtn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent-strong);
}
.tbtn:disabled { opacity: .35; pointer-events: none; }
.tbtn .icon { width: 16px; height: 16px; }
.tbtn-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
}

.tb-select { position: relative; display: inline-flex; align-items: center; flex: 0 0 auto; }
.tb-select select {
  width: 100%;
  height: 28px;
  padding: 0 22px 0 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  text-overflow: ellipsis;
}
.tb-select select:hover { background: var(--surface-2); }
.tb-select select:focus { border-color: var(--accent); outline: none; background: var(--surface); }
.tb-trigger {
  display: inline-flex;
  align-items: center;
  width: 100%;
  height: 30px;
  padding: 0 22px 0 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.tb-trigger:hover { background: var(--surface-2); }
.tb-trigger[aria-expanded="true"] {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--text);
}
.tb-trigger-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tb-select .tb-chevron {
  position: absolute;
  right: 4px;
  width: 13px;
  height: 13px;
  color: var(--muted);
  pointer-events: none;
}
.tb-select--block { width: 104px; }
.tb-select--font { width: 96px; }
.tb-select--size { width: 84px; }
/* La barra se adapta al ancho de su propio panel, no al de la ventana. */
.pane--visual { container-type: inline-size; }
@container (max-width: 800px) {
  .tb-select--font { display: none; }
}
@container (max-width: 640px) {
  .tb-select--size { display: none; }
  .tb-group { padding: 0 3px; }
  .tbtn { width: 26px; height: 26px; }
}

/* Menús desplegables con vista previa */
.tb-menu {
  position: fixed;
  z-index: 850;
  width: 224px;
  max-width: calc(100vw - 16px);
  max-height: min(460px, calc(100vh - 24px));
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  animation: menu-in .14s ease-out;
}
.tb-menu--size { width: 168px; }
.tb-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  outline: none;
}
.tb-option:hover,
.tb-option.is-selected { background: var(--accent-soft); }
.tb-option:focus-visible {
  background: var(--accent-soft);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.tb-option-sample { display: block; line-height: 1.1; color: var(--text); }
.tb-option-meta {
  flex: 0 0 auto;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.tb-option.is-selected .tb-option-meta { color: var(--accent-strong); }
.tb-option--quote .tb-option-sample { padding-left: 8px; border-left: 3px solid var(--accent); font-style: italic; }
.tb-option--pre .tb-option-sample { font-family: var(--font-mono); }

.tbtn-glyph--math { font-family: Georgia, "Times New Roman", serif; font-size: 16px; font-weight: 700; }
.tbtn--color { flex-direction: column; gap: 0; width: 32px; }
.color-glyph { font-size: 14px; font-weight: 800; line-height: 15px; }
.color-bar {
  display: block;
  width: 17px;
  height: 3px;
  margin-top: 1px;
  border-radius: 2px;
  background: var(--accent);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08);
}

/* ---------- Lienzo visual ---------- */
.visual-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  background: var(--paper);
  display: flex;
  overflow: hidden;
}
/* La hoja ocupa todo el panel: sin marco, sin sombra y sin fondo alrededor. */
.paper-frame {
  position: relative;
  width: 100%;
  max-width: none;
  height: 100%;
  background: var(--paper);
  overflow: hidden;
}
.visual-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--paper);
}

/* ---------- Editor de código ---------- */
.cm-wrap {
  flex: 1 1 auto;
  min-height: 80px;
  position: relative;
  overflow: hidden;
  background: var(--surface);
}
.cm-wrap[hidden] { display: none; }

/* ---------- Conmutador HTML / Markdown ---------- */
.langswitch {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.langswitch-btn {
  min-width: 34px;
  height: 20px;
  padding: 0 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
}
.langswitch-btn:hover { color: var(--text); }
.langswitch-btn.is-active {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: var(--shadow-sm);
}
.langswitch-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.md-chip {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  height: 21px;
  margin-left: 5px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font: inherit;
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.md-chip[hidden] { display: none; }
.md-chip:hover { border-color: var(--border-strong); color: var(--text-2); }
.md-chip.is-active {
  border-color: rgba(184, 69, 22, .3);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.md-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#sourcePane.is-md #encodingBtn,
#sourcePane.is-md #indentBtn,
#sourcePane.is-md #compressBtn { display: none; }
.cm-wrap .CodeMirror {
  height: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  background: transparent;
  color: var(--text);
  border: 0;
}
.cm-wrap .CodeMirror-scroll { padding-bottom: 24px; }
.cm-wrap .CodeMirror-lines { padding: 10px 0 24px; }
.cm-wrap .CodeMirror pre.CodeMirror-line,
.cm-wrap .CodeMirror pre.CodeMirror-line-like { padding: 0 14px 0 6px; }
.cm-wrap .CodeMirror-gutters {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}
.cm-wrap .CodeMirror-linenumber { color: var(--muted-2); padding: 0 8px 0 10px; font-size: 11px; }
.cm-wrap .CodeMirror-cursor { border-left: 2px solid var(--accent); }
.cm-wrap .CodeMirror-activeline-background { background: var(--accent-soft-2); }
.cm-wrap .CodeMirror-selected { background: var(--selection) !important; }
.cm-wrap .CodeMirror-focused .CodeMirror-selected { background: var(--selection) !important; }
.cm-wrap .CodeMirror-matchingtag { background: rgba(28, 122, 75, .16); text-decoration: underline; }
.cm-wrap .CodeMirror-matchingbracket { color: var(--green) !important; font-weight: 700; }
.cm-wrap .cm-s-default .cm-tag { color: var(--cm-tag); }
.cm-wrap .cm-s-default .cm-attribute { color: var(--cm-attr); }
.cm-wrap .cm-s-default .cm-string { color: var(--cm-string); }
.cm-wrap .cm-s-default .cm-comment { color: var(--cm-comment); font-style: italic; }
.cm-wrap .cm-s-default .cm-atom { color: var(--cm-atom); }
.cm-wrap .cm-s-default .cm-number { color: var(--cm-number); }
.cm-wrap .cm-s-default .cm-keyword { color: var(--cm-keyword); }
.cm-wrap .cm-s-default .cm-operator { color: var(--cm-operator); }
.cm-wrap .cm-s-default .cm-def { color: var(--cm-attr); }
.cm-wrap .cm-s-default .cm-property { color: var(--cm-attr); }
.cm-wrap .cm-s-default .cm-variable { color: var(--cm-atom); }
.cm-wrap .cm-s-default .cm-variable-2 { color: var(--cm-atom); }

/* ---------- Dock de herramientas ---------- */
.dock {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 43px;
  padding: 0 8px 0 8px;
  background: var(--surface-2);
}
.dock-tabs { display: flex; align-items: center; gap: 3px; min-width: 0; }
.dock-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 31px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: all .14s ease;
}
.dock-tab .icon { width: 15px; height: 15px; }
.dock-tab:hover { color: var(--text); background: var(--surface); }
.dock-tab.is-active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(42, 33, 20, .06);
}
.dock-tab.is-active .icon { color: var(--accent); }
.dock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
}
.dock-head-actions { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.dock-body {
  max-height: 258px;
  overflow: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.dock.is-collapsed .dock-body { display: none; }
.dock:not(.is-collapsed) #dockToggle {
  background: var(--accent-soft);
  border-color: var(--accent-soft);
  color: var(--accent-strong);
}

.dock-panel { padding: 10px 12px 14px; }
.dock-help {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.5;
}
.dock-help strong { color: var(--text-2); }
.dock-help .linkbtn { flex: 0 0 auto; white-space: nowrap; }

.clean-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 6px;
}
.clean-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.clean-chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.clean-chip.is-on {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface));
}
.clean-chip input[type="checkbox"] { flex: 0 0 auto; margin: 0; }
.clean-chip > label {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
}
.clean-chip .clean-name { color: var(--text); font-size: 12.5px; font-weight: 650; line-height: 1.35; }
.clean-chip .clean-desc {
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clean-chip .run-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  transition: all .14s ease;
}
.clean-chip:hover .run-btn, .clean-chip:focus-within .run-btn { opacity: 1; }
.clean-chip .run-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.clean-chip .run-btn .icon { width: 13px; height: 13px; }

/* Buscar y reemplazar */
.fr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; flex-wrap: wrap; }
.fr-head .dock-help { margin: 0; }
.fr-head-actions { display: flex; align-items: center; gap: 6px; }
.fr-count { font-size: 11.5px; color: var(--green); font-weight: 600; }
.fr-count.is-error { color: var(--red); }
.fr-rows { display: flex; flex-direction: column; gap: 7px; }
.fr-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}
.fr-row input[type="text"] {
  flex: 1 1 180px;
  min-width: 0;
  height: 31px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 11.5px;
}
.fr-row input[type="text"]:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft-2); }
.fr-row .mini-check {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
}
.fr-row .mini-check input { width: 13px; height: 13px; }
.fr-row .fr-row-actions { display: flex; align-items: center; gap: 1px; margin-left: auto; }
.fr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}
.fr-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.fr-btn--apply:hover { background: var(--green); border-color: var(--green); color: #fff; }
.fr-btn--remove:hover { background: var(--red-soft); border-color: transparent; color: var(--red); }
.fr-btn .icon { width: 14px; height: 14px; }
.fr-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 12px; }

/* ---------- Barra de estado de cada editor ---------- */
.pane-status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 28px;
  padding: 0 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.pane-status-label {
  margin-right: auto;
  color: var(--text-2);
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  font-size: 10px;
}
.pane-status-item {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pane-status-sep { width: 1px; height: 11px; background: var(--border); }
.workspace[data-view="source"] .pane-status { min-height: 30px; }

/* ---------- Barra de estado ---------- */
.statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  height: var(--status-h);
  padding: 0 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  z-index: 50;
}
.status-left, .status-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-item--muted { color: var(--muted-2); }
.status-left .status-item:first-child { color: var(--green); font-weight: 600; }
.status-left .status-item:first-child.is-saving { color: var(--amber); }
.status-left .status-item:first-child.is-error { color: var(--red); }
.status-sep { width: 1px; height: 12px; background: var(--border); }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: calc(var(--status-h) + 14px);
  z-index: 1400;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  max-width: 380px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  animation: toast-in .2s cubic-bezier(.2, .8, .2, 1);
}
.toast .icon { width: 16px; height: 16px; margin-top: 1px; flex: 0 0 auto; }
.toast--success { border-color: color-mix(in srgb, var(--green) 30%, var(--border)); }
.toast--success .icon { color: var(--green); }
.toast--error { border-color: color-mix(in srgb, var(--red) 35%, var(--border)); }
.toast--error .icon { color: var(--red); }
.toast--info .icon { color: var(--teal); }
.toast--warn .icon { color: var(--amber); }
.toast.is-leaving { animation: toast-out .18s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------- Overlays ---------- */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(6px);
}
.drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(460px, 100%);
  padding: 38px 30px;
  border: 2px dashed var(--accent);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.drop-card .icon { width: 38px; height: 38px; color: var(--accent); margin-bottom: 4px; }
.drop-card strong { font-size: 16px; }
.drop-card span { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }

.busy {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  backdrop-filter: blur(4px);
}
.busy-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
}
.spinner {
  width: 21px;
  height: 21px;
  border: 2.5px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Popover de color ---------- */
.color-pop {
  position: fixed;
  z-index: 900;
  width: 262px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  animation: menu-in .14s ease-out;
}
.color-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
}
.color-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 5px; }
.color-swatch {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, .14);
  border-radius: 5px;
  background: var(--swatch, #000);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
  transition: transform .1s ease, box-shadow .1s ease;
}
.color-swatch:hover {
  transform: scale(1.12);
  box-shadow: 0 0 0 2px var(--accent);
  z-index: 1;
}
.color-swatch.is-selected {
  box-shadow: 0 0 0 1px var(--surface), 0 0 0 3px var(--accent);
}
.color-pop-label {
  display: block;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted-2);
}
.color-pop-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
}
.color-custom-row { display: flex; align-items: center; gap: 6px; }
.color-hex {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.color-hex:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft-2);
}
.color-hex.is-invalid {
  border-color: var(--red);
  box-shadow: 0 0 0 2px var(--red-soft);
}
.color-hex-symbol {
  flex: 0 0 auto;
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}
.color-hex input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.color-hex input:focus { outline: none; }
.color-hex input::placeholder { color: var(--muted-2); text-transform: none; letter-spacing: 0; font-weight: 400; }
.color-apply {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text-2);
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.color-apply:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.color-apply .icon { width: 14px; height: 14px; }
.color-custom { display: inline-flex; align-items: center; flex: 0 0 auto; cursor: pointer; }
.color-custom input[type="color"] {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}
.color-pop-foot .linkbtn { align-self: flex-start; font-size: 11.5px; }

/* ---------- Selector de emoticonos y caracteres ---------- */
.glyph-pop {
  position: fixed;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 416px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  animation: menu-in .14s ease-out;
}
.glyph-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
}
.glyph-search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.glyph-search:focus-within {
  border-color: var(--accent);
  background: var(--surface);
  outline: 2px solid var(--accent-soft-2);
}
.glyph-search .icon { flex: 0 0 auto; width: 15px; height: 15px; color: var(--muted); }
.glyph-search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  outline: none;
}
.glyph-search input::placeholder { color: var(--muted-2); }
.glyph-select { position: relative; }
.glyph-select select {
  width: 100%;
  height: 34px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a7264' stroke-width='2.4' 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 10px center;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
}
.glyph-select select:hover { background-color: var(--surface-3); }
.glyph-select select:focus {
  border-color: var(--accent);
  background-color: var(--surface);
  outline: 2px solid var(--accent-soft-2);
}
.glyph-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}
.glyph-grid--emoji { min-height: 120px; max-height: 246px; }
.glyph-grid--tall { grid-template-columns: repeat(10, minmax(0, 1fr)); min-height: 190px; max-height: 300px; }
.glyph-grid--char { grid-template-columns: repeat(10, minmax(0, 1fr)); max-height: 292px; }
.glyph-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background .1s ease, transform .1s ease;
}
.glyph-btn:hover, .glyph-btn:focus-visible {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  outline: none;
}
.glyph-btn:active { transform: scale(.93); }
.glyph-grid--emoji .glyph-btn {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Segoe UI Symbol", var(--font-ui);
}
.glyph-grid--char .glyph-btn { font-family: var(--font-ui); font-size: 18.5px; }
.glyph-empty {
  padding: 20px 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.glyph-pop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 2px;
  color: var(--muted-2);
  font-size: 10.5px;
}
.glyph-pop-hint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.glyph-search--dialog { margin-bottom: 2px; }
.dialog.dialog--wide { width: min(660px, calc(100vw - 28px)); }
.dialog.dialog--wide .dialog-body { gap: 10px; }

.field-hint { margin: -7px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.date-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  text-align: center;
}
.field > span em { font-style: normal; letter-spacing: 0; text-transform: none; color: var(--muted-2); }
.video-note {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 600;
}
.video-note.is-bad { background: var(--red-soft); color: var(--red); }

/* ---------- Ecuaciones ---------- */
.math { max-width: 100%; }
.math--inline { display: inline-block; vertical-align: middle; }
.math--block { display: block; margin: 1em 0; overflow-x: auto; overflow-y: hidden; text-align: center; }
.math math { font-size: 1.08em; }
.math--block math { margin: 0 auto; }
.math[contenteditable="false"] { cursor: default; }
.math-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  padding: 10px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  overflow-x: auto;
}
.math-preview.is-error { border-color: var(--red); background: var(--red-soft); }
.math-preview-empty { color: var(--muted); font-size: 12px; }
.math-preview math { font-size: 1.35em; }

/* ---------- Vista previa ---------- */
.dialog.dialog--preview {
  width: min(1120px, calc(100vw - 24px));
  height: min(900px, calc(100vh - 32px));
  height: min(900px, calc(100dvh - 32px));
}
.preview-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.preview-devices {
  display: inline-flex;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.preview-device {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}
.preview-device .icon { width: 14px; height: 14px; }
.preview-device:hover { background: var(--surface); color: var(--text); }
.preview-device.is-active { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-sm); }
.preview-body { flex: 1 1 auto; min-height: 0; padding: 0; gap: 0; background: var(--surface-3); }
.preview-stage { flex: 1 1 auto; min-height: 0; display: flex; justify-content: center; padding: 14px; overflow: hidden; }
.preview-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow-md);
}
.preview-stage[data-device="mobile"] .preview-frame { width: 390px; max-width: 100%; }
.preview-hint {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 14px 10px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
  background: var(--surface-3);
}

/* ---------- Diálogos ---------- */
.dialog[open] { display: flex; flex-direction: column; }
.dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dialog--sm { width: min(430px, calc(100vw - 28px)); }
.dialog::backdrop { background: rgba(24, 19, 12, .48); backdrop-filter: blur(3px); }
.dialog[open] { animation: dialog-in .18s cubic-bezier(.2, .8, .2, 1); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

.dialog form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 42px); max-height: calc(100dvh - 42px); }
.dialog > form { flex: 1 1 auto; min-height: 0; }
.dialog > .dialog-head,
.dialog > .dialog-foot { flex: 0 0 auto; }
.dialog > .dialog-body { flex: 1 1 auto; min-height: 0; }
.dialog > .dialog-head,
.dialog > .dialog-foot { flex-shrink: 0; }
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px 15px 20px;
  border-bottom: 1px solid var(--border);
}
.dialog-head h2 { font-size: 15.5px; letter-spacing: -.01em; font-weight: 700; }
.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 18px 20px;
  overflow-y: auto;
  font-size: 13px;
}
.dialog-foot {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.spacer { flex: 1 1 auto; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 11px; font-weight: 700; letter-spacing: .03em; color: var(--muted); text-transform: uppercase; }
.field input,
.field select {
  height: 36px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 400;
}
.field select {
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a7264' stroke-width='2.4' 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 10px center;
  appearance: none;
  cursor: pointer;
}
.field input:focus,
.field select:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft-2); }
.field textarea {
  width: 100%;
  min-height: 74px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
}
.field textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft-2); }
.field-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.field-row .check { padding-bottom: 8px; }
.field--half { flex: 1 1 0; min-width: 140px; }
.field-error { color: var(--red); font-size: 11.5px; font-weight: 600; }
.dialog-hint { color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.confirm-message { color: var(--text-2); font-size: 13px; line-height: 1.6; }

.or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted-2);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 700;
}
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.upload-zone:hover, .upload-zone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone .icon { width: 22px; height: 22px; color: var(--accent); }
.upload-zone small { color: var(--muted); font-size: 10.5px; font-weight: 400; }
.image-preview { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); padding: 8px; text-align: center; }
.image-preview img { max-height: 140px; max-width: 100%; border-radius: 5px; display: inline-block; }

.dialog.dialog--help { width: min(860px, calc(100vw - 28px)); }
@media (min-width: 720px) {
  .dialog--help .help-body { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 28px; align-content: start; }
  .dialog--help .help-body > .help-credit { grid-column: 1 / -1; }
}
.help-body { gap: 18px; overscroll-behavior: contain; }
.help-body section { display: flex; flex-direction: column; gap: 7px; }
.help-body h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text);
}
.help-body h3 .icon { width: 15px; height: 15px; color: var(--accent); }
.help-body p { color: var(--text-2); font-size: 12.5px; line-height: 1.6; }
.help-body code {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: 11px;
}
.shortcuts { display: flex; flex-direction: column; gap: 1px; }
.shortcuts > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.shortcuts > div:last-child { border-bottom: 0; }
.shortcuts dt { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; color: var(--text-2); font-size: 11px; }
.shortcuts dd { color: var(--muted); font-size: 11.5px; text-align: right; }
.help-credit { color: var(--muted-2) !important; font-size: 11px !important; border-top: 1px solid var(--border); padding-top: 12px; }

/* ---------- Chips de las barras de cada panel ---------- */
.pane-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 240px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.pane-status-btn:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.page-chip.is-page { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }
.lint-chip .icon { color: var(--green); }
.lint-chip.is-warn { color: var(--amber); border-color: currentColor; }
.lint-chip.is-warn .icon { color: var(--amber); }
.lint-chip.is-error { color: var(--red); border-color: currentColor; background: var(--red-soft); }
.lint-chip.is-error .icon { color: var(--red); }

/* ---------- Idioma de corrección en la barra ---------- */
.tb-lang {
  display: inline-flex;
  align-items: center;
  margin: 0;
}
.tb-lang select {
  height: 26px;
  width: 48px;
  padding: 0 14px 0 5px;
  border: 1px solid transparent;
  border-radius: 5px;
  background-color: transparent;
  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='%237a7264' 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 2px center;
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  appearance: none;
  cursor: pointer;
}
.tb-lang select:hover { border-color: var(--border); background-color: var(--surface); color: var(--accent-strong); }
.tb-lang select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Hoja con formato de página ---------- */
.visual-scroll.has-page {
  padding: 18px 16px 26px;
  background: var(--page-canvas);
  justify-content: center;
  align-items: stretch;
}
.visual-scroll.has-page .paper-frame {
  width: min(100%, var(--page-width, 210mm));
  max-width: var(--page-width, 210mm);
  flex: 0 0 auto;
  margin: 0 auto;
  border: 0;
  border-radius: 3px;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(24, 18, 10, .12), 0 1px 2px rgba(24, 18, 10, .12), 0 22px 44px -22px rgba(24, 18, 10, .5);
  overflow: hidden;
}
:root[data-theme="dark"] .visual-scroll.has-page { background: #060606; }
:root[data-theme="dark"] .visual-scroll.has-page .paper-frame {
  box-shadow: 0 1px 2px rgba(0, 0, 0, .6), 0 22px 44px -22px rgba(0, 0, 0, .9);
}
body.focus-mode .visual-scroll.has-page {
  padding: 22px 18px 30px;
  background: var(--page-canvas);
}

/* ---------- Diálogo: formato de página ---------- */
.page-custom {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.field--quarter { min-width: 0; }
.field--quarter input { width: 100%; }
.page-summary {
  padding: 9px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

/* ---------- Diálogo: historial de versiones ---------- */
.dialog--history { width: min(660px, calc(100vw - 28px)); }
.history-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.history-interval { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.history-toolbar select {
  height: 30px;
  padding: 0 26px 0 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%237a7264' stroke-width='2.6' 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 8px center;
  color: var(--text);
  font-size: 12px;
  appearance: none;
  cursor: pointer;
}
.history-toolbar .btn { margin-left: auto; }
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(54vh, 480px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.history-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  transition: border-color .15s ease, background .15s ease;
}
.history-item:hover { border-color: var(--border-strong); background: var(--surface); }
.history-main { flex: 1 1 auto; min-width: 0; }
.history-head { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.history-head strong { color: var(--text); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.history-badge {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.history-badge--manual { background: var(--accent-soft); color: var(--accent-strong); }
.history-badge--restore { background: var(--teal-soft); color: var(--teal); }
.history-time { margin-left: auto; color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.history-excerpt {
  margin: 3px 0 2px;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.history-meta { color: var(--muted-2); font-size: 10px; font-variant-numeric: tabular-nums; }
.history-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.history-empty { padding: 18px 8px; color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- Diálogo: revisión del HTML ---------- */
.lint-summary {
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}
.lint-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; max-height: min(52vh, 460px); overflow-y: auto; overscroll-behavior: contain; }
.lint-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.lint-item:hover { background: var(--surface-2); }
.lint-item--error { border-left-color: var(--red); }
.lint-item--warning { border-left-color: var(--amber); }
.lint-icon { display: inline-flex; color: var(--amber); padding-top: 1px; }
.lint-item--error .lint-icon { color: var(--red); }
.lint-text { flex: 1 1 auto; min-width: 0; }
.lint-message { display: block; color: var(--text); font-size: 12px; line-height: 1.45; }
.lint-where { display: block; color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.lint-go { flex: 0 0 auto; color: var(--accent-strong); font-size: 10.5px; font-weight: 700; white-space: nowrap; opacity: .8; }
.lint-item:hover .lint-go { opacity: 1; }
.lint-clean { padding: 18px 8px; color: var(--green); font-size: 12px; font-weight: 600; text-align: center; }

/* ---------- Diálogo: paleta de comandos ---------- */
.dialog--palette {
  width: min(620px, calc(100vw - 24px));
  margin-top: max(48px, 10vh);
  border-radius: 14px;
}
.palette { display: flex; flex-direction: column; min-height: 0; }
.palette-search {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.palette-search .icon { color: var(--muted); }
.palette-search input {
  flex: 1 1 auto;
  min-width: 0;
  height: 28px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
}
.palette-search input:focus { outline: none; }
.palette-esc { flex: 0 0 auto; }
.palette-list {
  max-height: min(58vh, 520px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.palette-group {
  padding: 8px 9px 4px;
  color: var(--muted-2);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  text-align: left;
}
.palette-item.is-active { background: var(--accent-soft); border-color: var(--accent-soft-2); color: var(--text); }
.palette-icon { display: inline-flex; color: var(--accent-strong); }
.palette-text { flex: 1 1 auto; min-width: 0; }
.palette-title { display: block; font-size: 13px; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-hint { display: block; color: var(--muted); font-size: 10.5px; }
.palette-keys { display: inline-flex; gap: 3px; flex: 0 0 auto; }
.palette-empty { padding: 22px 14px; color: var(--muted); font-size: 12px; text-align: center; }
.palette-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10px;
}
.palette-foot span { display: inline-flex; align-items: center; gap: 3px; }

/* ---------- Tablas: barra flotante ---------- */
.table-tools {
  position: fixed;
  z-index: 1250;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.table-tools-label {
  padding: 0 6px 0 5px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.table-tools-sep { width: 1px; height: 16px; background: var(--border); margin: 0 2px; }
.table-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
}
.table-tool:hover { background: var(--accent-soft); color: var(--accent-strong); }
.table-tool--danger:hover { background: var(--red-soft); color: var(--red); }

/* ---------- Imágenes: marco de redimensionado ---------- */
.image-tools {
  position: fixed;
  z-index: 1240;
  pointer-events: none;
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-radius: 2px;
}
.image-tools-box { position: absolute; inset: 0; }
.image-size {
  position: absolute;
  left: -2px;
  bottom: calc(100% + 5px);
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.image-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 2px solid var(--surface);
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: nwse-resize;
  pointer-events: auto;
  touch-action: none;
}
.image-handle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
body.is-resizing-image { cursor: nwse-resize; user-select: none; }
body.is-resizing-image .visual-frame { pointer-events: none; }

/* ---------- Salir del modo enfoque ---------- */
.focus-exit {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1300;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease, background .15s ease;
}
.focus-exit:hover { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
body.focus-mode .focus-exit { opacity: 1; pointer-events: auto; transform: none; }

/* ---------- Modo enfoque ---------- */
body.focus-mode .topbar,
body.focus-mode .statusbar,
body.focus-mode .toolbar,
body.focus-mode .pane-status,
body.focus-mode .pane--source,
body.focus-mode .splitter { display: none; }
body.focus-mode .app-shell { padding: 0; }
body.focus-mode .workspace { grid-template-columns: minmax(0, 1fr); }
body.focus-mode .pane--visual { border-radius: 0; border: 0; box-shadow: none; }
body.focus-mode .visual-scroll { padding: 0; background: var(--paper); }
body.focus-mode .paper-frame { max-width: none; }
body.focus-mode .visual-frame { max-width: none; }
body.focus-mode .app-shell,
body.focus-mode body { background: var(--bg); }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .tb-select--font { width: 100px; }
}

@media (max-width: 1040px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .brand-name { font-size: 14.5px; }
  .btn { padding: 0 9px; }
  .viewswitch-btn { padding: 0 8px; }
}

@media (max-width: 900px) {
  :root { --topbar-h: auto; }
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 7px 10px;
    gap: 7px;
  }
  .brand { order: 1; }
  .topbar-actions { order: 2; margin-left: auto; }
  .topbar-center { order: 3; width: 100%; flex: 1 0 100%; }
  .viewswitch { width: 100%; max-width: 420px; margin: 0 auto; }
  .viewswitch-btn { flex: 1; justify-content: center; }
  .viewswitch [data-view="split"] { display: none; }
  .workspace[data-view="split"] { grid-template-columns: minmax(0, 1fr); }
  .workspace[data-view="split"] .splitter,
  .workspace[data-view="split"] .pane--source { display: none; }
  .app-shell { padding: 7px; }
  .pane { border-radius: 10px; }
  .dock-body { max-height: 300px; }
  .br-label { display: none; }
}

@media (max-width: 700px) {
  .glyph-pop { width: min(416px, calc(100vw - 16px)); }
  .glyph-grid--emoji { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .glyph-grid--char { grid-template-columns: repeat(8, minmax(0, 1fr)); }
  .brand-name { font-size: 14px; }
  .btn-label { display: none; }
  #downloadBtn .btn-label { display: inline; }
  #previewBtn { width: 32px; padding: 0; justify-content: center; }
  .preview-devices .preview-device span { display: none; }
  .preview-device { padding: 0 7px; }
  .topbar-actions .iconbtn { width: 32px; height: 32px; }
  .toolbar { min-height: 43px; padding: 3px 5px; }
  .tb-group { padding: 0 3px; }
  .tb-select--block { width: 96px; }
  .tb-select--font { display: none; }
  .tb-select--size { width: 78px; }
  .statusbar { padding: 0 9px; gap: 8px; }
  .status-left .status-item--muted { display: none; }
  .status-right { gap: 8px; }
  .dock-help { display: none; }
  .dock-head { min-height: 40px; }
  .dock-tab { font-size: 11.5px; padding: 0 7px; }
  .clean-grid { grid-template-columns: 1fr; }
  .page-custom { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-item { flex-direction: column; }
  .history-actions { width: 100%; justify-content: flex-end; }
  .dialog--palette { margin-top: 12px; width: min(620px, calc(100vw - 16px)); }
  .palette-list { max-height: 56vh; }
  .palette-keys { display: none; }
  .visual-scroll.has-page { padding: 10px 8px 16px; }
  .fr-row input[type="text"] { flex: 1 1 100%; }
  .fr-row .fr-row-actions { margin-left: 0; }
  .fr-head { align-items: flex-start; }
  .toasts { left: 10px; right: 10px; align-items: stretch; }
  .toast { max-width: none; }
}

@media (max-width: 480px) {
  .brand-name strong { display: inline; }
  .viewswitch-btn { font-size: 11.5px; gap: 4px; }
  .viewswitch-btn .icon { width: 14px; height: 14px; }
  .pane-head { padding: 0 6px 0 10px; }
  .source-actions .iconbtn { width: 26px; height: 26px; }
  .char-pill { display: none; }
  .toolbar { gap: 0; }
  .tb-select--size { display: none; }
  .dialog { width: calc(100vw - 16px); }
  .dialog.dialog--preview { width: calc(100vw - 8px); height: calc(100dvh - 12px); }
  .preview-stage { padding: 8px; }
  .preview-hint { font-size: 10.5px; padding: 6px 10px 8px; }
  .color-pop { width: min(246px, calc(100vw - 20px)); }
}

@media (hover: none) {
  .clean-chip .run-btn { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
