/* Compact editor workspace: wide editor + one right inspector with tabs. */
:root { --insp-primary:#5b5bd6; --insp-line:#e4e8f0; --insp-line-2:#eef1f6; --insp-muted:#6b7688; --insp-ink:#1a2030; --insp-surface-2:#f5f7fb; }

/* Elevated specificity (shell class + [data-inspector-tab]) so these beat the
   stale 3-rail rules still present in analytics.css (which use :not() at 0,3,0). */
@media (min-width: 1280px) {
  .public-editor-shell[data-inspector-tab].is-inspector-open { display:grid; grid-template-columns:minmax(560px,1fr) 384px; grid-template-areas:"editor inspector"; gap:12px; min-height:calc(100vh - 96px); }
  .public-editor-shell[data-inspector-tab]:not(.is-inspector-open) { display:grid; grid-template-columns:1fr; grid-template-areas:"editor"; gap:12px; min-height:calc(100vh - 96px); }
  .public-editor-shell[data-inspector-tab]:not(.is-inspector-open) .editor-inspector { display:none; }
  .public-editor-shell[data-inspector-tab] .editor-main-panel { grid-area:editor; min-width:0; }
  /* top matches the 64px topbar + 16px gap: the page scrolls as a document, so
     a 0 offset would slide the inspector under the sticky topbar. */
  .public-editor-shell[data-inspector-tab] .editor-inspector { grid-area:inspector; position:sticky; top:80px; align-self:start; max-height:calc(100vh - 96px); }
}

/* neutralise stale drawer/grid-area rules from analytics.css for the nested panels */
.editor-inspector .editor-structure-panel,
.editor-inspector .editor-suggestions-panel { grid-area:auto; position:static; inset:auto; top:auto; right:auto; bottom:auto; left:auto; width:auto; max-height:none; z-index:auto; opacity:1; pointer-events:auto; transform:none; transition:none; box-shadow:none; border:0; border-radius:0; background:transparent; overflow:hidden; }

/* ---- inspector shell + tabs ---- */
.editor-inspector { display:flex; flex-direction:column; min-height:0; background:#fff; border:1px solid var(--insp-line); border-radius:12px; overflow:hidden; box-shadow:none; }
.inspector-tabs { display:flex; align-items:center; gap:2px; padding:8px 8px 0; border-bottom:1px solid var(--insp-line-2); }
.inspector-tab { position:relative; display:flex; align-items:center; gap:7px; padding:9px 12px 12px; border:0; background:transparent; color:var(--insp-muted); font:600 13.5px/1 var(--font-heading, inherit); cursor:pointer; }
.inspector-tab i, .inspector-tab svg { width:16px; height:16px; }
.inspector-tab:hover { color:var(--insp-ink); }
.inspector-tab.is-active { color:var(--insp-ink); }
.inspector-tab.is-active::after { content:""; position:absolute; left:10px; right:10px; bottom:-1px; height:2.5px; border-radius:3px; background:var(--insp-primary); }
.inspector-collapse { margin-left:auto; display:grid; place-items:center; width:32px; height:32px; border:0; background:transparent; border-radius:9px; color:var(--insp-muted); cursor:pointer; }
.inspector-collapse:hover { background:var(--insp-surface-2); color:var(--insp-ink); }
.inspector-collapse svg { width:16px; height:16px; }
.inspector-context-toggle { position:fixed; z-index:45; top:50%; right:10px; display:grid; place-items:center; width:38px; height:44px; padding:0; color:var(--insp-muted); background:#fff; border:1px solid var(--insp-line); border-radius:11px; box-shadow:0 8px 24px rgba(15,23,42,.12); cursor:pointer; transform:translateY(-50%); transition:color .15s ease, background .15s ease, box-shadow .15s ease; }
.inspector-context-toggle:hover { color:var(--insp-primary); background:var(--insp-surface-2); box-shadow:0 10px 28px rgba(15,23,42,.16); }
.inspector-context-toggle svg { width:18px; height:18px; }
.public-editor-shell.is-inspector-open .inspector-context-toggle { display:none; }

.editor-inspector .inspector-pane { flex:1; min-height:0; display:none; }
/* 0,4,0 selectors so the active pane beats analytics' 0,3,0 display:none on the panels */
.public-editor-shell[data-inspector-tab="estructura"] .inspector-pane[data-inspector-pane="estructura"] { display:flex; flex-direction:column; overflow:auto; }
.public-editor-shell[data-inspector-tab="sugerencias"] .inspector-pane[data-inspector-pane="sugerencias"] { display:flex; flex-direction:column; overflow:hidden; }
.editor-inspector .inspector-pane[data-inspector-pane="sugerencias"] [data-unified-suggestion-panel] { flex:1; min-height:0; }

/* structure + suggestions panels are now inspector panes, not grid rails */
.editor-structure-panel { padding:0; border:0; border-radius:0; box-shadow:none; background:transparent; }
.editor-suggestions-panel { display:flex; flex-direction:column; min-height:0; gap:0; padding:0; border:0; border-radius:0; box-shadow:none; background:transparent; }

/* ---- structure tree ---- */
.structure-head { padding:12px 13px 11px; }
.structure-head-actions { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.structure-head h1 { margin:8px 0 1px; font-size:14.5px; }
.structure-head p { margin:0; font-size:11px; color:var(--insp-muted); }
.structure-head .back-link { display:inline-flex; align-items:center; gap:5px; min-height:28px; padding:3px 5px; font-size:11.5px; color:var(--insp-muted); text-decoration:none; }
.structure-head .back-link:hover { color:var(--insp-ink); }
.structure-change-scope { display:inline-flex; align-items:center; gap:5px; min-height:28px; padding:3px 7px; color:var(--insp-primary); background:transparent; border:0; border-radius:7px; font:600 11.5px var(--font-heading); cursor:pointer; }
.structure-change-scope:hover { background:var(--insp-surface-2); }
.structure-change-scope svg { width:13px; height:13px; }
.editor-scope-dialog { width:min(860px, calc(100vw - 32px)); }
.editor-scope-dialog .dialog-card { min-width:0; }
.scope-picker-fields { max-height:min(560px, calc(100dvh - 250px)); overflow:auto; }
.scope-picker-section { display:grid; gap:10px; }
.scope-picker-label { display:flex; align-items:center; gap:8px; color:var(--insp-ink); font:650 13px var(--font-heading); }
.scope-picker-label > span { display:grid; place-items:center; width:22px; height:22px; color:var(--insp-primary); background:#eef2ff; border-radius:999px; font-size:11px; }
.scope-domain-options, .scope-text-type-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
.scope-domain-option, .scope-text-type-option { display:grid; min-width:0; align-items:center; gap:10px; padding:11px 12px; color:var(--insp-ink); text-align:left; background:#fff; border:1px solid var(--insp-line); border-radius:10px; cursor:pointer; transition:border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.scope-domain-option { grid-template-columns:36px minmax(0,1fr) 18px; }
.scope-text-type-option { grid-template-columns:32px minmax(0,1fr) 18px; }
.scope-domain-option:hover, .scope-text-type-option:hover { border-color:#a5b4fc; background:#fafaff; }
.scope-domain-option.is-selected, .scope-text-type-option.is-selected { border-color:var(--insp-primary); background:#f5f5ff; box-shadow:0 0 0 2px rgba(91,91,214,.12); }
.scope-option-icon { display:grid; place-items:center; width:36px; height:36px; color:var(--insp-primary); background:#eef2ff; border-radius:9px; }
.scope-text-type-option .scope-option-icon { width:32px; height:32px; }
.scope-option-icon svg { width:17px; height:17px; }
.scope-option-copy { display:flex; min-width:0; align-items:center; justify-content:space-between; gap:8px; }
.scope-option-copy strong, .scope-text-type-option strong { overflow:hidden; font:600 13px/1.25 var(--font-heading); text-overflow:ellipsis; }
.scope-option-copy small { flex:0 0 auto; min-width:22px; padding:2px 6px; color:var(--insp-muted); text-align:center; background:#f1f5f9; border-radius:999px; font-size:10px; }
.scope-option-check { width:16px; height:16px; color:transparent; }
.is-selected > .scope-option-check { color:var(--insp-primary); }
@media(max-width:640px){.scope-domain-options,.scope-text-type-options{grid-template-columns:1fr}.editor-scope-dialog{width:min(560px,calc(100vw - 20px))}}
.structure-tree { min-height:0; flex:1; overflow:auto; padding:6px; }
.structure-tree-section { border-bottom:1px solid var(--insp-line-2); }
.structure-tree-row { display:grid; grid-template-columns:minmax(0,1fr) 28px; align-items:center; gap:2px; }
.structure-tree-toggle { display:flex; min-width:0; align-items:center; gap:5px; padding:9px 5px; color:var(--text-main); text-align:left; background:transparent; border:0; cursor:pointer; }
.structure-tree-toggle > svg { flex:0 0 auto; width:14px; height:14px; color:#94a3b8; transition:transform .15s ease; }
.structure-tree-section.is-active > .structure-tree-row .structure-tree-toggle > svg,
.structure-tree-content.is-active > .structure-tree-row .structure-tree-toggle > svg { transform:rotate(90deg); }
.structure-tree-toggle > span { display:flex; min-width:0; flex:1; align-items:center; justify-content:space-between; gap:5px; }
.structure-tree-toggle strong { overflow:hidden; font:650 12.5px/1.3 var(--font-heading); text-overflow:ellipsis; }
.structure-tree-toggle small { flex:0 0 auto; color:#94a3b8; font-size:10px; }
.structure-tree-contents { padding:0 0 4px 13px; border-left:1px solid #dbeafe; }
.structure-tree-content { border-radius:6px; }
.structure-tree-content.is-active { background:#f0f9ff; }
.structure-tree-row.content-row .structure-tree-toggle { padding-top:6px; padding-bottom:6px; }
.structure-tree-row.content-row .structure-tree-toggle strong { font-weight:550; font-size:12px; }
.structure-tree-phrases { display:grid; gap:3px; padding:2px 5px 7px 17px; }
.structure-tree-phrases .phraseology-btn { min-height:0; padding:7px 8px; gap:6px; color:#475569; font-size:11.5px; line-height:1.4; background:#fff; border:1px solid #e2e8f0; border-radius:7px; }
.structure-tree-phrases .phraseology-btn svg { width:13px; }
.structure-insert-action { width:26px; height:26px; border:0; border-radius:6px; background:transparent; }
.structure-empty { padding:8px 10px; color:#94a3b8; font-size:11px; }

/* ---- relocated "clear draft" (trash) — mode row removed ---- */
.workspace-draft-clear { color:#9aa4b2; }
.workspace-draft-clear:hover { color:#ef4444; background:#fef2f2; }
.editor-workbar .workspace-draft-clear { margin-left:auto; }
.card-header .workspace-draft-clear { margin-left:auto; }

/* ---- editor column ---- */
.agent-editor-frame { min-height:calc(100vh - 96px); padding-bottom:10px; }
.editor-workbar { display:flex; align-items:center; justify-content:flex-start; gap:8px; width:100%; margin-bottom:7px; }
.editor-analyze-btn { min-height:38px; padding:0 15px; border-radius:9px; font-size:13px; box-shadow:none; }
.editor-toolbar { top:48px; width:100%; min-height:44px; padding:4px 7px; border-radius:10px 10px 0 0; box-shadow:none; }
.editor-document-card { width:100%; min-height:calc(100vh - 205px); border-radius:0 0 10px 10px; box-shadow:none; }
.document-status-line { position:relative; z-index:1; flex:0 0 auto; align-items:center; min-height:38px; padding:7px 11px; overflow:visible; font-size:11px; line-height:1.35; box-sizing:border-box; }
.document-status-line [data-editor-engine] { flex:0 0 auto; }
.document-status-line [data-editor-dirty] { min-width:0; }
.document-status-line [data-occurrence-count] { flex:0 0 auto; margin-left:auto; }
.rich-editor-surface { min-height:calc(100vh - 245px); padding:30px 38px 92px; font-size:16px; line-height:1.7; }
.rich-editor-content { max-width:740px; font-size:calc(16px * var(--editor-zoom,1)); line-height:1.7; }
.agent-command-bar { bottom:10px; min-height:46px; width:min(640px,calc(100% - 28px)); margin-top:-68px; padding:5px 7px 5px 12px; gap:7px; border-radius:12px; box-shadow:0 8px 22px rgba(15,23,42,.12); }
.agent-command-bar input { height:34px; font-size:13px; }
.editor-report-status { flex:0 0 auto; margin:10px 12px; padding:11px 12px; border-radius:10px; }
.editor-report-status > div { min-width:0; flex:1; }
.editor-report-status p { font-size:11.5px; }
.editor-report-status h3 { font-size:12.5px; }

/* ---- narrow: inspector becomes a right drawer ---- */
@media (max-width: 1279px) {
  .public-editor-shell { display:block; min-height:0; }
  .editor-main-panel { width:100%; }
  .editor-inspector { position:fixed; z-index:60; top:72px; right:0; bottom:0; width:min(384px,calc(100vw - 22px)); max-height:none; border-radius:12px 0 0 12px; opacity:0; pointer-events:none; transform:translateX(105%); transition:opacity .18s ease, transform .18s ease; }
  .public-editor-shell.is-inspector-open .editor-inspector { opacity:1; pointer-events:auto; transform:none; }
}

@media (max-width: 700px) {
  .editor-inspector { inset:62px 0 0; width:100%; border-radius:0; }
  .inspector-context-toggle { right:8px; width:36px; height:42px; }
}

/* =====================================================================
   "Word-like" editor: menu bar + connected toolbar, A4 page on a grey
   canvas, docked agent bar and a bottom status bar. Appended last so it
   wins over the earlier compact rules and over analytics.css.
   ===================================================================== */
:root { --editor-canvas:#eceef1; --editor-page-w:794px; --editor-page-h:1123px; --editor-margin:96px; }

/* editor column becomes a fixed-height flex stack: chrome pinned top,
   canvas scrolls in the middle, agent bar + status bar pinned bottom. */
.agent-editor-frame {
  display:flex; flex-direction:column; align-items:stretch; gap:0;
  height:calc(100vh - 96px); min-height:calc(100vh - 96px); padding:0;
}

/* ---- menu bar (File / Edit / Insert / …) ---- */
.editor-menubar {
  display:flex; align-items:center; gap:2px; width:100%; min-height:40px;
  padding:3px 8px; background:#fff; border:1px solid var(--insp-line);
  border-radius:10px 10px 0 0;
}
.editor-menu { position:relative; }
.editor-menu-trigger {
  padding:6px 10px; color:var(--insp-ink); background:transparent; border:0;
  border-radius:7px; font:600 13px var(--font-heading, inherit); cursor:pointer;
}
.editor-menu-trigger:hover,
.editor-menu.is-open .editor-menu-trigger { background:var(--insp-surface-2); color:var(--insp-ink); }
.editor-menu-list {
  position:absolute; top:calc(100% + 5px); left:0; z-index:60;
  display:none; flex-direction:column; min-width:236px; padding:6px;
  background:#fff; border:1px solid var(--insp-line); border-radius:11px;
  box-shadow:0 16px 38px rgba(15,23,42,.17);
}
.editor-menu.is-open .editor-menu-list { display:flex; }
.editor-menu-item {
  display:flex; align-items:center; gap:10px; width:100%; min-height:34px;
  padding:7px 10px; color:var(--insp-ink); background:transparent; border:0;
  border-radius:7px; font:500 13px var(--font-heading, inherit);
  text-align:left; cursor:pointer;
}
.editor-menu-item > svg { flex:0 0 auto; width:16px; height:16px; color:var(--insp-muted); }
.editor-menu-item > span:not(.menu-soon) { flex:1; min-width:0; }
.editor-menu-item:hover:not([disabled]) { background:var(--insp-surface-2); }
.editor-menu-item[disabled] { color:#aab2c0; cursor:default; }
.editor-menu-item[disabled] > svg { color:#c7cdd8; }
.menu-soon {
  flex:0 0 auto; padding:2px 7px; color:#8b93a3; background:#f1f3f7;
  border-radius:999px; font-size:9px; font-weight:700; letter-spacing:.05em;
  text-transform:uppercase;
}
.editor-menu-sep { display:block; height:1px; margin:5px 4px; background:var(--insp-line-2); }
.editor-menubar .editor-analyze-btn { margin-left:auto; min-height:34px; padding:0 14px; border-radius:8px; font-size:13px; box-shadow:none; }
.editor-menubar .editor-analyze-btn svg { width:16px; height:16px; }

/* ---- format toolbar: connected strip under the menu bar ---- */
.editor-toolbar { position:static; top:auto; width:100%; margin:0; border-top:0; border-radius:0; box-shadow:none; }

/* ---- grey canvas that scrolls, with an A4 page centred inside ---- */
.editor-document-card {
  flex:1 1 auto; min-height:0; width:100%; display:block; overflow:auto;
  padding:26px 24px 40px; background:var(--editor-canvas);
  border:1px solid var(--insp-line); border-top:0; border-radius:0; box-shadow:none;
}
.editor-document-card .rich-editor-surface {
  --page-content-h: calc((var(--editor-page-h, 1123px) - 2 * var(--editor-margin, 96px)) * var(--editor-zoom, 1));
  display:block; box-sizing:border-box; margin:0 auto; overflow:visible;
  width:calc(min(var(--editor-page-w, 794px), 100%) * var(--editor-zoom, 1));
  min-height:calc(var(--editor-page-h, 1123px) * var(--editor-zoom, 1));
  padding:calc(var(--editor-margin, 96px) * var(--editor-zoom, 1)) calc(var(--editor-margin, 96px) * var(--editor-zoom, 1));
  color:#1f3147;
  /* white sheet + automatic page-break guide lines (visual only: a repeating
     gradient, no DOM nodes, so suggestion offsets/marks are never touched). */
  background-color:#fff;
  background-image: repeating-linear-gradient(to bottom,
    transparent 0,
    transparent calc(var(--page-content-h) - 1px),
    rgba(15,23,42,.13) calc(var(--page-content-h) - 1px),
    rgba(15,23,42,.13) var(--page-content-h));
  background-origin:content-box;
  background-repeat:repeat-y;
  border:1px solid #e4e7ec; border-radius:2px;
  box-shadow:0 1px 3px rgba(15,23,42,.16), 0 12px 32px rgba(15,23,42,.10);
  font-size:16px; line-height:1.7;
}
.editor-document-card .rich-editor-content { max-width:none; width:100%; margin:0; }

/* font family / size pickers in the toolbar */
.editor-font-select, .editor-size-select {
  height:34px; padding:0 24px 0 10px; color:#334155; background:#f8fafc;
  border:1px solid transparent; border-radius:9px;
  font:600 12.5px var(--font-heading, inherit); cursor:pointer;
}
.editor-font-select { min-width:118px; }
.editor-size-select { min-width:56px; }
.editor-font-select:focus, .editor-size-select:focus { outline:2px solid rgba(14,165,233,.25); outline-offset:1px; }

/* page-setup menu: section labels + radio check marks */
.editor-menu-label { display:block; padding:7px 10px 3px; color:#8b93a3; font:700 9px var(--font-heading, inherit); letter-spacing:.06em; text-transform:uppercase; }
.editor-menu-item[role="menuitemradio"] > svg { color:transparent; }
.editor-menu-item.is-selected[role="menuitemradio"] > svg { color:var(--insp-primary); }
.editor-menu-item.is-selected { color:var(--insp-ink); font-weight:650; }

/* ---- agent command bar: docked in flow above the status bar ---- */
.agent-editor-frame .agent-command-bar {
  position:static; z-index:auto; flex:0 0 auto;
  width:min(640px, calc(100% - 16px)); margin:8px auto 0; min-height:44px;
  border-radius:12px; box-shadow:0 6px 18px rgba(15,23,42,.10);
}

/* ---- Word-style bottom status bar ---- */
.editor-statusbar {
  flex:0 0 auto; display:flex; align-items:center; justify-content:space-between;
  gap:12px; width:100%; min-height:34px; margin-top:8px; padding:5px 12px;
  color:var(--insp-muted); background:#fff; border:1px solid var(--insp-line);
  border-radius:10px; font:500 11.5px var(--font-heading, inherit);
}
.statusbar-left, .statusbar-right { display:flex; align-items:center; gap:9px; min-width:0; }
.statusbar-left { overflow:hidden; }
.statusbar-left > span { flex:0 0 auto; white-space:nowrap; }
.statusbar-sep { width:1px; height:12px; background:var(--insp-line); }
.statusbar-dirty { flex:0 1 auto !important; min-width:0; max-width:230px; overflow:hidden; color:#b45309; font-weight:600; text-overflow:ellipsis; }
.statusbar-lang { padding:1px 7px; color:var(--insp-ink); background:var(--insp-surface-2); border-radius:6px; font-weight:700; letter-spacing:.03em; }
.statusbar-right .badge { flex:0 0 auto; }
.statusbar-zoom { display:flex; align-items:center; gap:5px; }
.statusbar-zoom .icon-tool { width:26px; height:26px; }
.statusbar-zoom .icon-tool svg { width:15px; height:15px; }
.statusbar-zoom .editor-zoom-label { min-width:40px; font-size:11.5px; text-align:right; }
.zoom-slider { width:94px; accent-color:var(--insp-primary); cursor:pointer; }

@media (max-width: 1279px) {
  .agent-editor-frame { height:auto; min-height:calc(100vh - 96px); }
  .editor-document-card { min-height:52vh; }
}

@media (max-width: 700px) {
  .editor-menubar { overflow-x:auto; scrollbar-width:none; }
  .editor-menubar .editor-analyze-btn span { display:none; }
  .editor-document-card { padding:14px 10px 26px; }
  .statusbar-lang, .statusbar-page { display:none; }
  .zoom-slider { width:70px; }
}
