/* ==========================================================================
   Editor a pantalla completa: barra superior, cinta con pestañas,
   hoja + panel de datos, barra de estado
   ========================================================================== */
.ed-launch { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 40px; color: var(--muted); font-weight: 600; }
.ed-launch .spinner { width: 28px; height: 28px; margin: 0; border-width: 3px; }
body.editor-open { overflow: hidden; }
body.editor-open .navbar { display: none; }
.ed-shell {
    position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
    background: var(--bg); animation: shellIn .35s var(--ease);
}
.ed-shell[hidden] { display: none; }
@keyframes shellIn { from { opacity: 0; transform: scale(.985); } to { opacity: 1; transform: none; } }
.ed-grow { flex: 1; }

/* Barra superior */
.ed-top {
    height: 60px; flex-shrink: 0; box-sizing: border-box; padding: 0 18px; display: flex; align-items: center; gap: 10px;
    background: #fff; border-bottom: 1px solid var(--line);
}
.ed-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ed-name { display: flex; align-items: center; gap: 6px; max-width: 520px; }
.ed-name input {
    flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 8px; padding: 3px 8px; margin-left: -8px;
    font: 700 15px 'Inter', sans-serif; color: var(--ink); background: transparent; outline: none; transition: all .2s;
}
.ed-name input:hover { border-color: var(--line); }
.ed-name input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.ed-name .ico { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }
.ed-sub { font-size: 12px; color: var(--muted); }
.ed-sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.ed-top .undo-group .icon-btn { border: 0; background: transparent; }
.ed-top .undo-group .icon-btn:hover:not(:disabled) { background: var(--surface-2); }

/* Cinta con pestañas */
.ed-ribbon { flex-shrink: 0; background: #fff; border-bottom: 1px solid var(--line); }
.ed-tabs { height: 40px; box-sizing: border-box; padding: 0 18px; display: flex; align-items: flex-end; gap: 2px; }
.ed-tab {
    height: 34px; padding: 0 14px; border: 0; border-radius: 9px 9px 0 0; background: transparent;
    font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: color .2s, background .2s;
}
.ed-tab:hover { color: var(--ink); background: var(--surface-2); }
.ed-tab.on { color: var(--accent-ink); background: #fbfbfe; box-shadow: inset 0 -2px 0 var(--accent); }
.ed-tabs .rb-pages { align-self: center; margin-bottom: -2px; }
.ed-data-toggle {
    align-self: center; margin: 0 0 -2px 8px; height: 30px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--line-2); border-radius: 8px; background: #fff; color: var(--ink-2); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.ed-data-toggle .ico { width: 15px; height: 15px; }
.ed-data-toggle.on { border-color: #c7cbff; background: var(--accent-soft); color: var(--accent-ink); }
.ed-panel {
    min-height: 52px; box-sizing: border-box; padding: 6px 18px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    border-top: 1px solid #eef0f5; background: #fbfbfe; animation: fadeUp .25s var(--ease);
}
.ed-panel[hidden] { display: none; }
.ed-panel[data-rpanel="inicio"] { padding: 4px 12px; }
.ed-panel .toolbar-slot { position: static; width: 100%; max-width: none; }
.ed-panel .toolbar-slot .ql-toolbar.ql-snow { border: 0; border-radius: 0; background: transparent; box-shadow: none; padding: 4px 0; }
.rb-btn {
    height: 34px; padding: 0 12px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-2); border-radius: 9px;
    background: #fff; color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; transition: all .2s;
}
.rb-btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.rb-btn .ico { width: 16px; height: 16px; }
.rb-btn.accent { border-color: #c7cbff; background: var(--accent-soft); color: var(--accent-ink); }
.rb-sep { width: 1px; height: 24px; background: var(--line); margin: 0 6px; }
.rb-field { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.ed-panel select {
    height: 32px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff;
    font: 500 13px 'Inter', sans-serif; color: var(--ink); max-width: 200px; outline: none;
}
.ed-panel select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.ed-panel .rb-narrow { width: 76px; }
.ed-panel .seg button { height: 28px; }

/* Área de trabajo */
.ed-work { flex: 1; min-height: 0; display: flex; position: relative; }
.ed-work .editor-paper { flex: 1; min-width: 0; overflow: auto; border-radius: 0; padding: 28px 24px 60px; max-width: none; margin: 0; }
.ed-data {
    width: 290px; flex-shrink: 0; box-sizing: border-box; padding: 16px; display: flex; flex-direction: column; gap: 10px;
    background: #fff; border-left: 1px solid var(--line); overflow-y: auto; animation: slideIn .3s var(--ease);
}
.ed-data[hidden] { display: none; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.ed-data-head { display: flex; align-items: center; justify-content: space-between; }
.ed-data-head b { font-size: 14px; }
.ed-data-head .icon-btn { width: 30px; height: 30px; border: 0; }
.ed-data-help { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.ed-data-search input { width: 100%; }
.ed-data-title { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.ed-fields { display: flex; flex-direction: column; gap: 6px; }
.ed-field {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; padding: 6px 10px;
    border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; text-align: left; transition: all .2s;
}
.ed-field:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateX(-2px); }
.ed-field code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--accent-ink); word-break: break-all; }
.ed-field small { font-size: 11.5px; color: var(--muted); text-align: right; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-field.sys code, .ed-field.custom code { color: #6b21a8; }
.ed-field.sys:hover { border-color: var(--accent-2); background: #f5edff; }
.ed-empty { font-size: 12.5px; color: var(--muted); padding: 6px 2px; }

/* Barra de estado */
.ed-status {
    position: relative; height: 32px; flex-shrink: 0; box-sizing: border-box; padding: 0 18px; display: flex; align-items: center; gap: 18px;
    background: #fff; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.ed-status b { color: var(--accent-ink); }
.ed-help-btn { height: 24px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 600; cursor: pointer; }
.ed-help-btn .ico { width: 14px; height: 14px; }
.ed-help {
    position: absolute; right: 18px; bottom: 40px; width: 360px; box-sizing: border-box; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px;
    background: var(--ink); color: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 12.5px; line-height: 1.5; z-index: 5; animation: popIn .25s var(--spring);
}
.ed-help b { color: #fff; }
.ed-help[hidden] { display: none; }

@media (max-width: 900px) {
    .ed-top .btn span, .ed-data-toggle span { display: none; }
    .ed-data { position: absolute; right: 0; top: 0; bottom: 0; z-index: 30; box-shadow: var(--shadow-lg); }
    #stPaper { display: none; }
}

/* Vista previa rápida desde el editor */
.preview-modal { max-height: 70vh; overflow: auto; background: #e9ebf2; padding: 16px 8px; border-radius: 12px; text-align: left; }
.preview-modal .page { margin: 0 auto; }
