:root{
  --bg:#eef2f7;
  --panel:#ffffff;
  --text:#172033;
  --muted:#6b7280;
  --line:#dfe5ee;
  --accent:#2563eb;
  --accent-soft:#eff6ff;
  --danger:#dc2626;
  --success:#16a34a;
  --sidebar:#0f1726;
  --shadow:0 10px 30px rgba(20,32,60,.08);
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  display:grid;
  grid-template-columns:320px 1fr;
  min-height:100vh;
}
button,input,textarea{font:inherit}
button{cursor:pointer}
.sidebar{
  position:sticky;
  top:0;
  height:100vh;
  background:var(--sidebar);
  color:white;
  padding:24px 20px;
  display:flex;
  flex-direction:column;
  gap:16px;
  z-index:10;
}
.brand{display:flex;gap:12px;align-items:center}
.logo{
  width:48px;height:48px;border-radius:14px;
  display:grid;place-items:center;
  background:rgba(255,255,255,.1);
  font-size:24px;
}
.brand h1{margin:0;font-size:22px}
.brand p{margin:3px 0 0;color:#9ca3af;font-size:13px}
.primary{
  border:0;background:var(--accent);color:#fff;
  border-radius:12px;padding:11px 16px;font-weight:800;
}
.full{width:100%}
.search-box input{
  width:100%;border:1px solid #2b3649;background:#172033;color:white;
  padding:11px 12px;border-radius:10px;outline:none;
}
.nav-special{
  width:100%;border:1px solid #2b3649;background:#172033;color:#e5edf8;
  padding:11px 12px;border-radius:10px;text-align:left;font-weight:700;
}
.chapter-list{overflow:auto;display:flex;flex-direction:column;gap:8px;padding-right:3px}
.chapter-item{
  width:100%;border:1px solid transparent;background:transparent;color:#cbd5e1;
  border-radius:10px;padding:12px;text-align:left;
}
.chapter-item:hover{background:#172033}
.chapter-item.active{background:#1d4ed8;color:white}
.chapter-item small{display:block;opacity:.78;margin-top:4px}
.sidebar-footer{
  margin-top:auto;
  display:grid;grid-template-columns:repeat(3,1fr);gap:7px;
}
.sidebar-footer button{
  border:1px solid #2c3850;background:#172033;color:#dbe4f0;
  border-radius:9px;padding:9px 6px;font-size:12px;
}
.logout-link{
  color:#cbd5e1;text-decoration:none;font-size:12px;text-align:center;
  padding:2px 0 0;border:0;background:transparent;width:100%;cursor:pointer;
}
.main{padding:34px;max-width:1250px;width:100%;margin:auto}
.topbar{
  display:flex;justify-content:space-between;align-items:center;
  margin-bottom:10px;gap:20px;
}
.eyebrow{font-size:11px;letter-spacing:.14em;color:var(--accent);font-weight:800}
.topbar h2{margin:6px 0 0;font-size:30px}
.stats{display:flex;gap:10px}
.stats div{
  min-width:88px;background:white;border:1px solid var(--line);
  border-radius:12px;padding:10px 13px;text-align:center;
}
.stats strong{display:block;font-size:18px}
.stats span{font-size:11px;color:var(--muted)}
.save-status{
  min-height:22px;
  text-align:right;
  color:var(--muted);
  font-size:12px;
  margin-bottom:10px;
}
.save-status.saving{color:#b45309}
.save-status.error{color:var(--danger)}
.card{
  background:var(--panel);border:1px solid var(--line);border-radius:18px;
  box-shadow:var(--shadow);
}
.welcome{
  min-height:420px;display:flex;flex-direction:column;align-items:center;
  justify-content:center;text-align:center;padding:50px;
}
.welcome-icon{font-size:44px}
.welcome h3{font-size:26px;margin:15px 0 8px}
.welcome p{max-width:570px;color:var(--muted);line-height:1.6;margin:0 0 22px}
.hidden{display:none!important}
.chapter-header{padding:22px;margin-bottom:28px}
.chapter-title-row{display:flex;gap:10px;align-items:center}
.chapter-title-input{
  flex:1;border:0;outline:0;font-weight:850;font-size:29px;color:var(--text);
}
.chapter-header textarea{
  width:100%;border:0;outline:0;resize:vertical;min-height:65px;
  margin-top:10px;color:#4b5563;line-height:1.6;
}
.ghost{
  border:1px solid var(--line);background:white;color:var(--text);
  border-radius:10px;padding:9px 11px;
}
.danger{color:var(--danger)}
.toolbar{
  display:flex;align-items:center;justify-content:space-between;
  margin:0 2px 20px;gap:20px;
}
.toolbar h3{margin:0 0 4px}
.toolbar p{margin:0;color:var(--muted);font-size:13px}

/* Hoja A4 visual */
.lesson-list{
  display:flex;
  flex-direction:column;
  gap:34px;
  align-items:center;
}
.a4-page{
  position:relative;
  width:min(210mm,100%);
  min-height:297mm;
  background:white;
  border:1px solid #d9dee8;
  box-shadow:0 14px 40px rgba(20,32,60,.10);
  padding:22mm 20mm 20mm;
}
.a4-page.done{outline:3px solid rgba(22,163,74,.14)}
.page-top{
  display:flex;justify-content:space-between;gap:16px;align-items:flex-start;
  border-bottom:1px solid var(--line);
  padding-bottom:12px;margin-bottom:18px;
}
.page-kicker{font-size:11px;letter-spacing:.12em;color:var(--accent);font-weight:800}
.page-number{font-size:12px;color:var(--muted);white-space:nowrap}
.lesson-title{
  width:100%;border:0;outline:0;font-size:26px;font-weight:850;color:var(--text);
  padding:0;margin:7px 0 0;
}
.page-body{
  display:grid;grid-template-columns:1fr;gap:14px;
}
.lesson-note{
  width:100%;
  border:0;outline:0;resize:none;
  min-height:205mm;
  color:#263244;
  line-height:1.75;
  font-size:15px;
  padding:0;
  overflow:hidden;
  background:transparent;
}
.page-footer{
  position:absolute;left:20mm;right:20mm;bottom:12mm;
  display:flex;justify-content:space-between;align-items:center;
  border-top:1px solid var(--line);padding-top:10px;
  font-size:12px;color:var(--muted);
}
.complete-label{display:flex;align-items:center;gap:7px;color:var(--text);font-weight:700}
.complete-label input{accent-color:var(--success)}
.lesson-actions{display:flex;gap:6px}
.lesson-actions button{
  border:1px solid var(--line);background:#f8fafc;border-radius:8px;padding:6px 9px
}
.empty{
  width:min(210mm,100%);
  border:2px dashed #d5dbea;border-radius:16px;padding:32px;
  text-align:center;color:var(--muted);background:rgba(255,255,255,.5)
}

/* Índice */
.index-book{
  width:min(210mm,100%);
  min-height:297mm;
  margin:0 auto;
  background:white;
  border:1px solid #d9dee8;
  box-shadow:0 14px 40px rgba(20,32,60,.10);
  padding:22mm 20mm;
}
.index-book h1{font-size:30px;margin:0 0 6px}
.index-subtitle{color:var(--muted);margin-bottom:28px}
.index-chapter{margin-top:24px}
.index-chapter-title{
  font-size:18px;font-weight:850;border-bottom:2px solid var(--text);
  padding-bottom:7px;margin-bottom:8px;
}
.index-row{
  display:grid;
  grid-template-columns:auto 1fr auto;
  align-items:end;
  gap:8px;
  padding:6px 0;
}
.index-row .dots{
  border-bottom:1px dotted #9ca3af;
  transform:translateY(-4px);
}
.index-row button{
  appearance:none;border:0;background:transparent;padding:0;
  color:var(--text);text-align:left;cursor:pointer;
}
.index-row button:hover{color:var(--accent)}

/* Login */
.login-body{
  display:grid;
  grid-template-columns:1fr;
  min-height:100vh;
  place-items:center;
  background:linear-gradient(135deg,#eaf0f8,#f8fafc);
}
.login-shell{width:min(430px,calc(100% - 32px))}
.login-card{
  background:white;border:1px solid var(--line);border-radius:22px;
  box-shadow:0 24px 70px rgba(30,41,59,.13);padding:34px;
}
.login-logo{
  width:58px;height:58px;border-radius:16px;background:#101827;
  display:grid;place-items:center;font-size:30px;margin-bottom:18px;
}
.login-card h1{margin:5px 0 8px;font-size:29px}
.login-subtitle{color:var(--muted);margin:0 0 24px}
.login-card label{display:block;font-size:13px;font-weight:800;margin-bottom:7px}
.login-card input{
  width:100%;border:1px solid var(--line);border-radius:11px;padding:12px 13px;
  outline:none;margin-bottom:12px;
}
.login-error{
  color:#991b1b;background:#fef2f2;border:1px solid #fecaca;
  padding:10px 12px;border-radius:10px;margin-bottom:15px;
}

.modal{
  position:fixed;inset:0;background:rgba(0,0,0,.45);
  display:grid;place-items:center;padding:20px;z-index:20;
}
.modal-card{
  width:min(520px,100%);background:white;border-radius:18px;
  box-shadow:0 30px 80px rgba(0,0,0,.25);padding:22px;
}
.modal-head{display:flex;justify-content:space-between;align-items:center}
.modal-head h3{margin:0 0 15px}
.modal-card label{display:block;font-size:13px;font-weight:700;margin:12px 0 6px}
.modal-card input,.modal-card textarea{
  width:100%;border:1px solid var(--line);border-radius:10px;padding:11px 12px;outline:none
}
.modal-card textarea{min-height:100px;resize:vertical}
.modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}

@media(max-width:900px){
  body{grid-template-columns:1fr}
  .sidebar{position:relative;height:auto}
  .chapter-list{max-height:220px}
  .main{padding:20px}
  .topbar{align-items:flex-start;flex-direction:column}
  .a4-page,.index-book{min-height:auto;padding:28px}
  .lesson-note{min-height:500px}
  .page-footer{position:static;margin-top:25px}
}
@page{
  size:A4;
  margin:0;
}
@media print{
  body{display:block;background:white}
  .sidebar,.topbar,.save-status,.chapter-header,.toolbar,
  .lesson-actions,.modal{display:none!important}
  .main{max-width:none;padding:0;margin:0}
  #welcome{display:none!important}
  .lesson-list{gap:0}
  .a4-page,.index-book{
    width:210mm;
    height:297mm;
    min-height:297mm;
    margin:0;
    box-shadow:none;
    border:0;
    break-after:page;
    page-break-after:always;
  }
  .lesson-note{min-height:205mm}
}

/* =========================================================
   DASHBOARD RESPONSIVE 2026
   ========================================================= */
:root{
  --dashboard-sidebar:280px;
  --dashboard-bg:#edf2f8;
  --dashboard-surface:#ffffff;
  --dashboard-shadow:0 16px 45px rgba(15,23,42,.10);
}

body{
  grid-template-columns:var(--dashboard-sidebar) minmax(0,1fr)!important;
  background:var(--dashboard-bg);
}

.sidebar{
  width:var(--dashboard-sidebar);
  padding:18px 14px 14px!important;
  gap:12px!important;
  border-right:1px solid rgba(148,163,184,.14);
  box-shadow:8px 0 30px rgba(2,6,23,.08);
}
.brand{padding:2px 4px 8px}
.logo{width:42px;height:42px;border-radius:12px;font-size:21px}
.brand h1{font-size:19px}
.brand p{font-size:11px}
.sidebar-book-list{max-height:150px}
.book-navigation{min-height:0;overflow:hidden}
.chapter-list{min-height:0;max-height:none;scrollbar-width:thin}
.sidebar-content-panel{overflow-y:auto}
.sidebar-footer{margin-top:auto!important}
.sidebar form{margin:0}

.main{
  min-width:0;
  width:100%;
  padding:0 18px 32px!important;
  overflow-x:hidden!important;
}
.topbar{
  margin:0 -18px!important;
  padding:8px 18px!important;
  min-height:54px!important;
  box-shadow:0 1px 0 rgba(148,163,184,.18);
}
.topbar h2{font-size:18px!important}
.stats div{background:rgba(255,255,255,.82)!important}

.format-toolbar{
  flex-wrap:nowrap!important;
  overflow-x:auto!important;
  overflow-y:hidden!important;
  width:calc(100% + 4px);
  padding:6px 8px 7px!important;
  gap:5px!important;
  scrollbar-width:thin;
  scrollbar-color:#cbd5e1 transparent;
  overscroll-behavior-x:contain;
}
.format-toolbar::-webkit-scrollbar{height:5px}
.format-toolbar::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:999px}
.toolbar-group{flex:0 0 auto!important}
.toolbar-publish-actions{margin-left:0!important}

#editor,#frontMatterView,#indexView{
  width:100%;
  max-width:900px;
  margin-inline:auto;
}
.chapter-header,.front-matter-page,.index-book{
  border:1px solid #d8e0ea!important;
  border-radius:0 0 14px 14px!important;
  box-shadow:var(--dashboard-shadow)!important;
  background:var(--dashboard-surface)!important;
}
.chapter-header{padding:26px 34px!important}
.chapter-title-row{
  padding-bottom:13px;
  margin-bottom:12px;
  border-bottom:1px solid #e5eaf1;
}
.chapter-title-input{font-size:25px!important;font-family:Georgia,"Times New Roman",serif}
#chapterIntro{padding:8px 2px 28px!important;border:0!important;box-shadow:none!important}
#chapterIntro:focus{box-shadow:none!important}

.sidebar-toggle{
  display:none;
  flex:0 0 auto;
  width:38px;height:38px;
  border:1px solid #d8e0ea;
  border-radius:10px;
  background:#fff;color:#172033;
  font-size:18px;
}
.sidebar-backdrop{display:none}

@media(max-width:1180px) and (min-width:921px){
  :root{--dashboard-sidebar:248px}
  .sidebar{padding-inline:11px!important}
  .stats span{display:none}
  .stats div{min-width:42px!important}
  .chapter-header{padding-inline:28px!important}
}

@media(max-width:920px){
  body{display:block!important}
  .sidebar{
    position:fixed!important;
    inset:0 auto 0 0;
    width:min(300px,86vw)!important;
    height:100dvh!important;
    transform:translateX(-105%);
    transition:transform .22s ease;
    z-index:300!important;
  }
  body.sidebar-open{overflow:hidden}
  body.sidebar-open .sidebar{transform:translateX(0)}
  .sidebar-backdrop{
    display:block;
    position:fixed;inset:0;
    z-index:299;
    border:0;background:rgba(2,6,23,.55);
    opacity:0;pointer-events:none;
    transition:opacity .2s ease;
  }
  body.sidebar-open .sidebar-backdrop{opacity:1;pointer-events:auto}
  .sidebar-toggle{display:grid;place-items:center}
  .main{padding:0 10px 22px!important}
  .topbar{margin:0 -10px!important;padding:7px 10px!important;flex-direction:row!important}
  .topbar > div:first-of-type{min-width:0;flex:1}
  .topbar .eyebrow{display:none}
  .topbar h2{font-size:16px!important}
  .stats{display:none!important}
  .format-toolbar{top:54px!important;margin-inline:0!important}
  .study-toolbar,.reader-toolbar{top:98px!important}
  .chapter-header{padding:20px 18px!important}
  .chapter-title-input{font-size:21px!important}
  #editor,#frontMatterView,#indexView{max-width:100%}
}

/* El dashboard no debe alterar la pantalla de acceso. */
body.login-body{
  display:grid!important;grid-template-columns:minmax(0,1fr)!important;
  place-items:center!important;width:100%!important;min-height:100vh!important;min-height:100dvh!important;
  margin:0!important;padding:28px!important;overflow:auto!important;
  background:
    radial-gradient(circle at 18% 18%,rgba(37,99,235,.10),transparent 34%),
    radial-gradient(circle at 82% 78%,rgba(79,70,229,.08),transparent 32%),
    linear-gradient(135deg,#eaf0f8,#f8fafc)!important;
}
.login-shell{width:min(420px,100%)!important;margin:auto!important}
.login-card{
  width:100%!important;padding:34px!important;border-radius:22px!important;
  box-shadow:0 26px 75px rgba(15,23,42,.14)!important;
}
.login-card input{box-sizing:border-box!important}
@media(max-width:520px){
  body.login-body{padding:16px!important}
  .login-card{padding:26px 22px!important;border-radius:18px!important}
  .login-card h1{font-size:26px!important}
}

.book-sections-fieldset{
  margin:15px 0 4px;padding:12px;border:1px solid #dce4ee;border-radius:12px;background:#f8fafc;
}
.book-sections-fieldset legend{padding:0 6px;font-size:12px;font-weight:800;color:#1e293b}
.book-sections-fieldset > p{margin:0 0 10px;color:#64748b;font-size:10px;line-height:1.45}
.book-section-options{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
.book-section-options label{
  display:flex;align-items:center;gap:7px;min-height:35px;padding:7px 9px;
  margin:0!important;border:1px solid #dce4ee;border-radius:9px;background:#fff;color:#334155;font-size:11px;cursor:pointer;
}
.book-section-options label:hover{border-color:#93c5fd;background:#eff6ff}
.book-section-options input{width:15px;height:15px;accent-color:#2563eb}
@media(max-width:520px){.book-section-options{grid-template-columns:1fr}}
.modal-card{max-height:calc(100dvh - 32px);overflow-y:auto}

@media(max-width:560px){
  .save-status-inline #saveStatusText{display:none}
  .header-edit-title{margin-left:0!important}
  .format-toolbar button,.format-toolbar select{height:34px!important;min-width:34px!important}
  .chapter-header{min-height:calc(100dvh - 150px)!important}
  #chapterIntro{font-size:16px!important;line-height:1.72!important}
}

#printRoot{display:none}
@media print{
  .print-hidden-main{display:none!important}
  #printRoot{display:block!important}
}


/* ===== Editor de documento ===== */
.format-toolbar{
  position:sticky;
  top:12px;
  z-index:8;
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px;
  padding:10px 12px;
  margin:0 0 18px;
  background:rgba(255,255,255,.97);
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow:0 10px 26px rgba(20,32,60,.10);
  backdrop-filter:blur(8px);
}
.toolbar-group{
  display:flex;
  align-items:center;
  gap:4px;
  padding-right:8px;
  border-right:1px solid var(--line);
}
.toolbar-group:last-child{border-right:0;padding-right:0}
.format-toolbar button,
.format-toolbar select{
  height:36px;
  min-width:36px;
  border:1px solid #d8dee8;
  background:#fff;
  color:var(--text);
  border-radius:8px;
  padding:0 9px;
}
.format-toolbar button:hover,
.format-toolbar select:hover{background:#f4f7fb}
.format-toolbar button.active{
  background:var(--accent-soft);
  border-color:#9dbcfb;
  color:#1746a2;
}
.format-toolbar select{min-width:92px}
.color-group label{
  height:36px;
  min-width:42px;
  padding:0 8px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  border:1px solid #d8dee8;
  border-radius:8px;
  background:#fff;
  font-weight:800;
  cursor:pointer;
}
.color-group input[type="color"]{
  width:18px;height:18px;border:0;padding:0;background:transparent;cursor:pointer;
}

.rich-editor{
  width:100%;
  min-height:205mm;
  outline:0;
  color:#263244;
  line-height:1.7;
  font-size:16px;
  padding:2px 0 25px;
  overflow-wrap:anywhere;
}
.rich-editor:empty:before{
  content:attr(data-placeholder);
  color:#9ca3af;
  pointer-events:none;
}
.rich-editor p{margin:0 0 12px}
.rich-editor h2{font-size:26px;line-height:1.25;margin:18px 0 10px}
.rich-editor h3{font-size:21px;line-height:1.3;margin:16px 0 8px}
.rich-editor ul,.rich-editor ol{padding-left:28px;margin:8px 0 14px}
.rich-editor li{margin:4px 0}
.rich-editor blockquote{
  margin:14px 0;
  padding:10px 14px;
  border-left:4px solid #cbd5e1;
  background:#f8fafc;
}
.rich-editor hr{
  border:0;border-top:1px solid #cfd6e0;margin:18px 0;
}
.rich-editor a{color:#1d4ed8;text-decoration:underline}
.rich-editor table{
  width:100%;border-collapse:collapse;margin:14px 0;
}
.rich-editor th,.rich-editor td{
  border:1px solid #cfd6e0;padding:8px;vertical-align:top;
}

@media(max-width:900px){
  .format-toolbar{position:relative;top:auto}
  .toolbar-group{border-right:0;padding-right:0}
}

@media print{
  .format-toolbar{display:none!important}
  .rich-editor{
    min-height:205mm;
    font-size:15px;
  }
}


/* ===== Herramientas de estudio y lectura ===== */
.study-toolbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  flex-wrap:wrap;
  gap:10px;
  padding:10px 12px;
  margin:-8px 0 20px;
  background:#101827;
  color:#fff;
  border-radius:14px;
  box-shadow:0 8px 24px rgba(15,23,38,.12);
}
.study-left,.study-right{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:6px;
}
.study-toolbar button,.study-toolbar select{
  min-height:38px;
  border:1px solid #334155;
  background:#172033;
  color:#eef2ff;
  border-radius:9px;
  padding:7px 10px;
}
.study-toolbar button:hover,.study-toolbar select:hover{background:#22304a}
.study-toolbar .study-main{
  background:#2563eb;
  border-color:#2563eb;
  font-weight:800;
}
.study-toolbar button.active{
  background:#7c3aed;
  border-color:#7c3aed;
}
.study-toolbar select option{color:#111827;background:white}

.study-panel{
  width:min(210mm,100%);
  margin:0 auto 24px;
  background:white;
  border:1px solid var(--line);
  border-radius:16px;
  box-shadow:var(--shadow);
  padding:22px;
}
.study-panel-head{
  display:flex;justify-content:space-between;align-items:flex-start;gap:16px;
  border-bottom:1px solid var(--line);padding-bottom:14px;margin-bottom:18px;
}
.study-panel-head h3{margin:5px 0 0}
.study-card{
  border:1px solid var(--line);
  border-radius:14px;
  padding:18px;
  margin:12px 0;
  background:#fbfcfe;
}
.study-card h4{margin:0 0 8px;font-size:17px}
.study-card p{line-height:1.65;color:#3f4b5d}
.study-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.study-actions button{
  border:1px solid var(--line);background:white;border-radius:9px;padding:8px 11px;
}
.study-answer{
  margin-top:12px;padding:12px;border-radius:10px;background:#f0fdf4;
  border:1px solid #bbf7d0;white-space:pre-wrap;line-height:1.6;
}
.study-hidden{
  filter:blur(6px);
  user-select:none;
  transition:filter .18s ease;
}
.study-hidden.revealed{filter:none;user-select:text}
.study-progress{
  display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-top:14px;
}
.study-progress div{
  border:1px solid var(--line);border-radius:10px;padding:10px;text-align:center;
  font-size:12px;color:var(--muted);
}
.study-progress strong{display:block;font-size:18px;color:var(--text);margin-bottom:2px}
.study-badge{
  display:inline-flex;align-items:center;gap:5px;font-size:11px;font-weight:800;
  padding:4px 8px;border-radius:999px;background:#eef2ff;color:#3730a3;
}
@media(max-width:900px){
  .study-toolbar{align-items:stretch}
  .study-left,.study-right{width:100%}
  .study-toolbar select{max-width:180px}
  .study-progress{grid-template-columns:repeat(2,1fr)}
}
@media print{
  .study-toolbar,.study-panel{display:none!important}
}


/* ===== Biblioteca multi-libro ===== */
.library-button{
  border:1px solid #334155;background:#172033;color:#fff;
  border-radius:12px;padding:11px 16px;font-weight:800;
}
.library-button:hover{background:#22304a}
.library-view{width:100%}
.library-hero{
  display:flex;align-items:flex-end;justify-content:space-between;gap:20px;
  margin:8px 0 22px;
}
.library-hero h2{font-size:34px;margin:6px 0 7px}
.library-hero p{margin:0;color:var(--muted)}
.library-search{margin-bottom:18px}
.library-search input{
  width:min(520px,100%);border:1px solid var(--line);border-radius:12px;
  background:white;padding:12px 14px;outline:none;
}
.book-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(260px,1fr));
  gap:18px;
}
.book-card{
  position:relative;
  background:white;border:1px solid var(--line);border-radius:18px;
  padding:20px;box-shadow:var(--shadow);
  min-height:235px;display:flex;flex-direction:column;
}
.book-cover{
  width:52px;height:62px;border-radius:6px 10px 10px 6px;
  background:linear-gradient(135deg,#1d4ed8,#4338ca);
  display:grid;place-items:center;font-size:26px;color:white;
  box-shadow:inset 5px 0 rgba(255,255,255,.12);
  margin-bottom:14px;
}
.book-card h3{margin:0 0 6px;font-size:19px}
.book-card .desc{
  color:var(--muted);font-size:13px;line-height:1.5;
  min-height:40px;margin:0 0 13px;
}
.book-meta{font-size:11px;color:var(--muted);margin-bottom:10px}
.book-progress{
  height:7px;background:#edf1f6;border-radius:999px;overflow:hidden;margin-bottom:6px;
}
.book-progress span{display:block;height:100%;background:#2563eb;border-radius:999px}
.book-stats{font-size:11px;color:var(--muted)}
.book-actions{
  margin-top:auto;padding-top:16px;display:flex;gap:6px;flex-wrap:wrap;
}
.book-actions button{
  border:1px solid var(--line);background:#fff;border-radius:8px;padding:7px 9px;
  font-size:12px;
}
.book-actions .open-book{
  background:#2563eb;border-color:#2563eb;color:white;font-weight:800;
}
.book-empty{
  grid-column:1/-1;border:2px dashed #cfd7e4;border-radius:18px;
  padding:50px;text-align:center;background:rgba(255,255,255,.55);color:var(--muted);
}
@media(max-width:700px){
  .library-hero{align-items:flex-start;flex-direction:column}
}

/* El modo edición contiene solo herramientas de edición. */
body:not(.continuous-mode) .study-toolbar,
body:not(.continuous-mode) .study-panel,
body:not(.continuous-mode) .floating-read-controls{display:none!important}

/* Lectura de borde a borde: el header usa todo el ancho disponible. */
body.continuous-mode .main{padding:0!important;margin:0!important;max-width:none!important;width:100%!important}
body.continuous-mode #continuousBookView{width:100%!important;max-width:none!important;margin:0!important}
body.continuous-mode .continuous-sticky-header{
  left:0!important;right:0!important;width:100%!important;max-width:none!important;margin:0!important;
  box-sizing:border-box!important;
}
body.continuous-mode .continuous-document{width:100%!important;box-sizing:border-box!important}

/* =========================================================
   HEADER Y BARRA DE EDICIÓN MODERNOS
   ========================================================= */
.topbar{
  min-height:56px!important;padding:7px 16px!important;
  background:rgba(255,255,255,.97)!important;
}
.topbar-title .eyebrow{
  color:#64748b!important;font-size:8px!important;letter-spacing:.14em!important;
}
.topbar-title h2{font-size:17px!important;font-weight:780!important;color:#0f172a!important}
.header-edit-title{
  width:27px!important;height:27px!important;border-radius:8px!important;
  background:#f8fafc!important;border-color:#dbe3ed!important;
}
.topbar-title .save-status-inline{
  min-height:27px!important;padding:4px 8px!important;border-radius:8px!important;
  font-weight:700!important;
}
.topbar-title .header-full-book{
  min-height:29px!important;padding:5px 9px!important;border-radius:8px!important;
  background:#f8fafc!important;
}
.topbar-stats{padding-left:10px;border-left:1px solid #e2e8f0}
.topbar-stats div{
  display:grid!important;grid-template-columns:auto auto!important;align-items:baseline!important;gap:4px!important;
  min-width:auto!important;padding:5px 8px!important;background:#f8fafc!important;box-shadow:none!important;
}
.topbar-stats strong{font-size:12px!important}
.topbar-stats span{font-size:8px!important}

.format-toolbar{
  top:56px!important;display:flex!important;flex-wrap:nowrap!important;align-items:stretch!important;
  gap:6px!important;padding:7px 8px 8px!important;margin:0 0 8px!important;
  background:rgba(248,250,252,.98)!important;border:1px solid #dbe3ed!important;
  border-top:0!important;border-radius:0 0 12px 12px!important;
  box-shadow:0 7px 22px rgba(15,23,42,.07)!important;
}
.format-toolbar .toolbar-group{
  position:relative!important;display:flex!important;align-items:flex-end!important;
  gap:3px!important;padding:17px 6px 5px!important;
  background:#fff!important;border:1px solid #e2e8f0!important;border-radius:9px!important;
}
.format-toolbar .toolbar-group::before{
  content:attr(data-label);position:absolute;top:3px;left:7px;
  color:#7c8ba1;font-size:7px;font-weight:850;letter-spacing:.09em;text-transform:uppercase;
}
.format-toolbar button,.format-toolbar select,.format-toolbar .color-group label{
  height:30px!important;min-height:30px!important;border-radius:7px!important;
  border:1px solid #dce3ec!important;background:#fff!important;color:#263449!important;
  font-size:10px!important;
}
.format-toolbar button{min-width:30px!important;padding:0 7px!important}
.format-toolbar button:hover,.format-toolbar select:hover,.format-toolbar .color-group label:hover{
  background:#eff6ff!important;border-color:#93c5fd!important;color:#1d4ed8!important;
}
.format-toolbar button.active{background:#dbeafe!important;border-color:#60a5fa!important;color:#1d4ed8!important}
.font-tools #fontFamily{width:104px!important;min-width:104px!important}
.font-tools #fontSize{width:48px!important;min-width:48px!important}
.list-tools button{white-space:nowrap}
.color-group label{min-width:34px!important;padding:0 6px!important}
.insert-tools #insertExcelBtn{min-width:38px!important;font-size:8px!important;font-weight:850}
.page-view-tools #pageZoom{width:76px!important;min-width:76px!important}
.toolbar-publish-actions{background:#f8fbff!important;border-color:#bfdbfe!important}
.toolbar-publish-actions button{font-size:12px!important}
.toolbar-publish-actions button:last-of-type:not(.hidden){color:#b91c1c!important}

@media(max-width:920px){
  .topbar{min-height:52px!important;padding:6px 9px!important}
  .topbar-title h2{font-size:15px!important}
  .format-toolbar{top:52px!important}
  .topbar-stats{display:none!important}
}
@media print{.library-view{display:none!important}}


/* ===== Barra lateral: selector de libros ===== */
.sidebar-section-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  color:#f8fafc;
  font-size:12px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.06em;
  margin-top:2px;
}
.sidebar-section-head.second{margin-top:6px}
.sidebar-section-head button{
  width:28px;height:28px;border-radius:8px;
  border:1px solid #334155;background:#172033;color:#fff;
}
.sidebar-book-list{
  display:flex;
  flex-direction:column;
  gap:6px;
  max-height:220px;
  overflow:auto;
}
.sidebar-book{
  width:100%;
  display:flex;
  align-items:center;
  gap:9px;
  border:1px solid transparent;
  background:transparent;
  color:#cbd5e1;
  border-radius:9px;
  padding:9px 10px;
  text-align:left;
}
.sidebar-book:hover{background:#172033}
.sidebar-book.active{
  background:#1d4ed8;
  color:white;
}
.sidebar-book .sb-icon{
  width:28px;height:34px;border-radius:4px 7px 7px 4px;
  display:grid;place-items:center;
  background:linear-gradient(135deg,#2563eb,#4338ca);
  font-size:15px;flex:0 0 auto;
}
.sidebar-book .sb-text{
  min-width:0;flex:1;
}
.sidebar-book strong{
  display:block;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-size:12px;
}
.sidebar-book small{
  display:block;
  margin-top:2px;
  color:inherit;
  opacity:.72;
  font-size:10px;
}
.book-navigation{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.front-nav.active{
  background:#1d4ed8;
  border-color:#2563eb;
  color:#fff;
}
.front-matter-page{margin:0 auto}
.front-matter-page .rich-editor{
  min-height:205mm;
}


/* ===== Workspace compacto: header + toolbar + hoja ===== */
.main{
  max-width:none;
  padding:0 24px 34px;
  margin:0;
  overflow-x:auto;
}
.topbar{
  position:sticky;
  top:0;
  z-index:20;
  margin:0 -24px;
  padding:12px 24px 10px;
  background:rgba(238,243,249,.97);
  border-bottom:1px solid #dbe2ec;
  backdrop-filter:blur(10px);
}
.topbar h2{margin:3px 0 0;font-size:22px}
.save-status{
  position:fixed;
  right:26px;
  top:76px;
  z-index:23;
}
.format-toolbar{
  position:sticky;
  top:69px;
  z-index:19;
  margin:0 -2px 12px;
  border-radius:0 0 12px 12px;
  box-shadow:0 8px 18px rgba(20,32,60,.08);
}
#editor,#frontMatterView,#indexView{
  padding-top:0;
}
.lesson-list{gap:22px}
.a4-page,.index-book{
  transform-origin:top center;
  transition:transform .15s ease;
}
.page-view-tools{margin-left:auto;border-right:0}
.toolbar-caption{
  font-size:11px;font-weight:800;color:var(--muted);
  padding:0 3px;
}
#pageZoom{min-width:86px}

/* Floating reader */
.floating-reader{
  position:fixed;
  left:calc(280px + 18px);
  bottom:22px;
  z-index:50;
  display:flex;
  align-items:flex-end;
  gap:10px;
}
.reader-toggle{
  width:54px;height:54px;border:0;border-radius:50%;
  background:#2563eb;color:white;font-size:22px;
  box-shadow:0 12px 30px rgba(37,99,235,.34);
}
.reader-panel{
  width:min(390px,calc(100vw - 340px));
  background:#101827;color:white;
  border:1px solid #334155;border-radius:16px;
  box-shadow:0 18px 46px rgba(0,0,0,.28);
  overflow:hidden;
}
.reader-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:10px 12px;border-bottom:1px solid #334155;
}
.reader-head button{
  border:0;background:transparent;color:#cbd5e1;font-size:16px;
}
.reader-now{
  padding:12px 14px;
  min-height:78px;
  max-height:150px;
  overflow:auto;
  font-size:14px;line-height:1.6;
  color:#e2e8f0;
}
.reader-current{
  background:#facc15;color:#111827;border-radius:4px;padding:1px 3px;
}
.reader-controls{
  display:flex;gap:6px;align-items:center;padding:10px 12px;
  border-top:1px solid #334155;
}
.reader-controls button,.reader-controls select{
  min-height:34px;border:1px solid #475569;background:#172033;
  color:white;border-radius:8px;padding:6px 9px;
}
.reader-controls #readerPlay{background:#2563eb;border-color:#2563eb}

@media(max-width:900px){
  .main{padding:0 12px 26px}
  .topbar{margin:0 -12px;padding:10px 12px}
  .format-toolbar{top:66px}
  .floating-reader{left:18px}
  .reader-panel{width:min(360px,calc(100vw - 90px))}
}
@media print{
  .floating-reader{display:none!important}
}


/* Corrección lector */
.reader-now{
  white-space:normal;
}
.reader-current{
  display:inline;
  box-decoration-break:clone;
  -webkit-box-decoration-break:clone;
}


/* =========================================================
   ACTUALIZACIÓN: área de trabajo a altura completa + lector
   ========================================================= */

.reader-transcript{
  order:3;
  width:100%;
  display:flex;
  align-items:flex-start;
  gap:8px;
  padding:8px 11px;
  margin-top:2px;
  border-top:1px solid #334155;
  background:#0b1220;
  color:#e2e8f0;
  font-size:13px;
  line-height:1.5;
}
.reader-transcript.hidden{display:none!important}
#readerTranscriptText{
  min-width:0;
  max-height:58px;
  overflow:auto;
}
.reader-highlight{
  background:#facc15;
  color:#111827;
  padding:1px 4px;
  border-radius:4px;
}

/* No usar controles flotantes antiguos. */
.floating-reader,
.reader-panel,
.reader-toggle{
  display:none!important;
}

/* La página principal del capítulo llena el alto útil del navegador. */
.chapter-header{
  min-height:calc(100vh - 245px)!important;
  display:flex!important;
  flex-direction:column!important;
  margin-bottom:24px!important;
}

/* El área donde escribes ocupa el resto de la página. */
#chapterIntro,
.chapter-header textarea{
  flex:1 1 auto!important;
  min-height:calc(100vh - 345px)!important;
  height:auto!important;
  resize:vertical!important;
  overflow:auto!important;
}

/* La sección Hojas de aprendizaje queda realmente debajo. */
.toolbar{
  margin-top:0!important;
}

/* Páginas A4 y preliminares aprovechan el alto disponible. */
.front-matter-page,
.lesson-list .a4-page{
  min-height:calc(100vh - 210px);
}

@supports(height:100dvh){
  .chapter-header{
    min-height:calc(100dvh - 245px)!important;
  }
  #chapterIntro,
  .chapter-header textarea{
    min-height:calc(100dvh - 345px)!important;
  }
}

@media(max-height:760px){
  .chapter-header{min-height:520px!important}
  #chapterIntro,
  .chapter-header textarea{min-height:410px!important}
}

@media(max-width:900px){
  .chapter-header{min-height:620px!important}
  #chapterIntro,
  .chapter-header textarea{min-height:500px!important}
}


/* ===== Lector: franja visible y seguimiento ===== */
.reader-transcript{
  min-height:58px!important;
  padding:10px 14px!important;
  align-items:flex-start!important;
  font-size:14px!important;
  line-height:1.55!important;
}
#readerTranscriptText{
  display:block;
  flex:1 1 auto;
  min-height:42px;
  max-height:74px!important;
  overflow-y:auto!important;
  font-size:14px!important;
  line-height:1.55!important;
}
.reader-highlight{
  display:inline;
  background:#facc15!important;
  color:#111827!important;
  padding:2px 5px!important;
  border-radius:4px!important;
  box-decoration-break:clone;
  -webkit-box-decoration-break:clone;
}

/* Resaltado temporal del párrafo que corresponde a la lectura. */
.reader-source-highlight{
  background:rgba(250,204,21,.18)!important;
  outline:2px solid rgba(250,204,21,.5)!important;
  outline-offset:3px;
  border-radius:4px;
  transition:background .2s ease, outline .2s ease;
}


/* ===== Guardado automático ===== */
.save-status{
  position:static!important;
  display:inline-flex;
  align-items:center;
  gap:6px;
  min-height:28px;
  padding:5px 9px;
  border-radius:999px;
  font-size:11px;
  margin-left:auto;
}
.save-status small{
  margin-left:3px;
  opacity:.78;
}
.save-ok{
  color:#166534!important;
  background:#f0fdf4;
  border:1px solid #bbf7d0;
}
.save-saving{
  color:#92400e!important;
  background:#fffbeb;
  border:1px solid #fde68a;
}
.save-error{
  color:#991b1b!important;
  background:#fef2f2;
  border:1px solid #fecaca;
}

/* ===== Acciones de libro ===== */
.publish-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
  gap:6px;
  padding:7px 0 8px;
}
.publish-actions.hidden{display:none!important}
.publish-actions button{
  min-height:34px;
  border:1px solid #cfd7e4;
  background:white;
  color:#172033;
  border-radius:9px;
  padding:6px 10px;
  font-size:12px;
  font-weight:700;
}
.publish-actions button:hover{background:#f8fafc}
.publish-actions .share-action{
  background:#2563eb;
  border-color:#2563eb;
  color:white;
}
.publish-actions .danger-action{
  color:#b91c1c;
  border-color:#fecaca;
  background:#fff7f7;
}

.share-modal-card{width:min(620px,100%)}
.share-help{color:var(--muted);line-height:1.5}
.share-link-row{display:grid;grid-template-columns:1fr auto;gap:8px}
.share-link-row input{
  width:100%;
  border:1px solid var(--line);
  border-radius:10px;
  padding:11px 12px;
  background:#f8fafc;
}
.share-note{
  margin-top:12px;
  padding:10px 12px;
  background:#eff6ff;
  border:1px solid #bfdbfe;
  color:#1e3a8a;
  border-radius:10px;
  font-size:12px;
  line-height:1.5;
}

@media(max-width:900px){
  .publish-actions{justify-content:flex-start}
  .save-status{margin-left:0}
  .share-link-row{grid-template-columns:1fr}
}


/* ===== VISTA DE LIBRO CONTINUO ===== */
.continuous-book-button{
  width:calc(100% - 20px); margin:10px; padding:10px 12px; border:1px solid #334155;
  border-radius:8px; background:#172033; color:#fff; font-weight:700; cursor:pointer;
}
.continuous-book-button:hover{background:#2563eb}
.continuous-sticky-header{
  position:sticky; top:0; z-index:40; display:flex; align-items:center; justify-content:space-between;
  gap:20px; padding:12px 20px; background:rgba(241,245,249,.97); border-bottom:1px solid #dbe3ee;
  backdrop-filter:blur(8px);
}
.continuous-sticky-header small{font-size:10px;letter-spacing:1.5px;color:#2563eb;font-weight:800}
.continuous-sticky-header h2{margin:2px 0;font-size:20px}
.continuous-sticky-header p{margin:0;color:#64748b;font-size:12px}
.continuous-actions{display:flex;gap:7px;flex-wrap:wrap}
.continuous-actions button,.continuous-add-bottom{
  border:0;border-radius:7px;background:#2563eb;color:#fff;padding:9px 12px;font-weight:700;cursor:pointer
}
.continuous-document{
  width:100%; min-height:100vh; padding:24px 20px 70px; background:#e9eef5;
  display:flex; flex-direction:column; align-items:center; gap:22px;
}
.continuous-a4{
  box-sizing:border-box; width:min(210mm,calc(100vw - 310px)); min-height:297mm;
  background:#fff; box-shadow:0 4px 18px rgba(15,23,42,.10); padding:18mm 18mm 16mm;
  position:relative; cursor:default;
}
.continuous-a4:hover{box-shadow:0 7px 24px rgba(15,23,42,.16)}
.continuous-page-head{display:flex;justify-content:space-between;gap:20px;border-bottom:1px solid #dbe3ee;padding-bottom:10px}
.continuous-page-head small{font-size:9px;letter-spacing:1.4px;color:#2563eb;font-weight:800}
.continuous-page-head h1{font-size:22px;margin:5px 0 0}
.continuous-page-head>span{font-size:10px;color:#64748b;white-space:nowrap}
.continuous-page-content{padding-top:22px;font-size:13px;line-height:1.65;min-height:220mm}
.continuous-page-foot{position:absolute;left:18mm;right:18mm;bottom:10mm;display:flex;justify-content:space-between;border-top:1px solid #e5e7eb;padding-top:7px;color:#94a3b8;font-size:9px}
.continuous-index-title{font-size:20px;font-weight:800;margin-bottom:18px}
.continuous-index-row{display:flex;align-items:flex-end;gap:8px;margin:8px 0}
.continuous-index-row i{flex:1;border-bottom:1px dotted #94a3b8;transform:translateY(-4px)}
.continuous-index-row b{font-weight:600}
.continuous-index-chapter{font-weight:800;margin-top:14px}
.continuous-index-child{padding-left:18px}
.continuous-empty{color:#94a3b8;font-style:italic}
.continuous-add-bottom{margin:12px 0 30px;padding:12px 18px}
@media(max-width:900px){
  .continuous-a4{width:calc(100vw - 28px);min-height:calc((100vw - 28px)*1.414);padding:28px}
  .continuous-page-content{min-height:70vh}
  .continuous-page-foot{left:28px;right:28px}
  .continuous-sticky-header{align-items:flex-start;flex-direction:column}
}
@media print{
  .continuous-sticky-header,.continuous-add-bottom,.continuous-book-button{display:none!important}
  .continuous-document{padding:0;background:#fff;gap:0}
  .continuous-a4{width:210mm;min-height:297mm;box-shadow:none;page-break-after:always}
}


/* ===== Flujo automático de páginas ===== */
#btnAddLesson,
#continuousAddPage,
#continuousAddPageBottom,
.toolbar #btnAddLesson,
button[id*="AddLesson"]{
  display:none!important;
}


/* ===== Ordenar capítulos por arrastre ===== */
.chapter-item{
  display:flex!important;
  align-items:center;
  gap:8px;
}
.chapter-drag-handle{
  cursor:grab;
  flex:0 0 auto;
  color:#94a3b8;
  font-size:14px;
  user-select:none;
}
.chapter-drag-handle:active{cursor:grabbing}
.chapter-item-content{
  min-width:0;
  flex:1;
}
.chapter-item.dragging{
  opacity:.45;
}
.chapter-item.drag-over{
  outline:2px solid #60a5fa;
  background:#1e293b;
}

.continuous-chapter-page{
  position:relative;
}
.continuous-drag-badge{
  position:absolute;
  top:10px;
  left:10px;
  z-index:3;
  background:#0f172a;
  color:#fff;
  border-radius:7px;
  padding:5px 8px;
  font-size:11px;
  font-weight:700;
  cursor:grab;
  opacity:.78;
  user-select:none;
}
.continuous-chapter-page.dragging{
  opacity:.45;
}
.continuous-chapter-page.continuous-drag-over{
  outline:3px solid #60a5fa;
  outline-offset:4px;
}


/* ===== Simplificación del editor ===== */
/* Ya no mostramos la sección inferior de "Hojas de aprendizaje". */
.toolbar,
#lessonList{
  display:none!important;
}

/* El capítulo actual ocupa todo el espacio disponible sin dejar hueco abajo. */
.chapter-header{
  margin-bottom:0!important;
}


/* ===== Cabecera más compacta ===== */
.main{
  padding-top:0!important;
}

.topbar{
  min-height:auto!important;
  padding:6px 14px 5px!important;
  margin:0 -24px!important;
  gap:10px!important;
  align-items:center!important;
}

.topbar > div:first-child{
  min-width:0;
  flex:1;
}

.topbar .eyebrow{
  font-size:8px!important;
  letter-spacing:.11em!important;
  line-height:1!important;
}

.topbar h2{
  margin:2px 0 0!important;
  font-size:17px!important;
  line-height:1.15!important;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.stats{
  gap:5px!important;
  flex:0 0 auto;
}

.stats div{
  min-width:54px!important;
  padding:5px 7px!important;
  border-radius:8px!important;
}

.stats strong{
  font-size:13px!important;
  line-height:1.05!important;
}

.stats span{
  font-size:8px!important;
}

/* Guardado automático en una sola línea, sin consumir alto. */
.save-status{
  min-height:22px!important;
  padding:3px 7px!important;
  font-size:9px!important;
  margin:0!important;
}
.save-status small{
  font-size:8px!important;
}

/* Acciones del libro pegadas y compactas. */
.publish-actions{
  padding:4px 0 5px!important;
  gap:4px!important;
}
.publish-actions button{
  min-height:28px!important;
  padding:4px 8px!important;
  font-size:10px!important;
  border-radius:7px!important;
}

/* Barra de formato más fina. */
.format-toolbar{
  top:46px!important;
  padding:5px 7px!important;
  margin-bottom:5px!important;
  gap:4px!important;
  border-radius:0 0 8px 8px!important;
}
.toolbar-group{
  gap:2px!important;
  padding-right:4px!important;
}
.format-toolbar button,
.format-toolbar select{
  height:29px!important;
  min-width:29px!important;
  padding:0 6px!important;
  font-size:10px!important;
  border-radius:6px!important;
}
.format-toolbar select{
  min-width:72px!important;
}
.color-group label{
  height:29px!important;
  min-width:32px!important;
  padding:0 5px!important;
}
.toolbar-caption{
  font-size:9px!important;
}

/* Barra de lectura/estudio más compacta. */
.study-toolbar{
  padding:5px 7px!important;
  margin:-1px 0 6px!important;
  gap:4px!important;
  border-radius:8px!important;
}
.study-left,.study-right{
  gap:3px!important;
}
.study-toolbar button,
.study-toolbar select{
  min-height:29px!important;
  padding:4px 7px!important;
  font-size:10px!important;
  border-radius:6px!important;
}
.reader-transcript{
  min-height:38px!important;
  padding:6px 9px!important;
  font-size:11px!important;
}
#readerTranscriptText{
  min-height:28px!important;
  max-height:44px!important;
  font-size:11px!important;
}

/* El editor gana el alto liberado por la cabecera compacta. */
.chapter-header{
  min-height:calc(100vh - 185px)!important;
}
#chapterIntro,
.chapter-header textarea{
  min-height:calc(100vh - 265px)!important;
}

@supports(height:100dvh){
  .chapter-header{
    min-height:calc(100dvh - 185px)!important;
  }
  #chapterIntro,
  .chapter-header textarea{
    min-height:calc(100dvh - 265px)!important;
  }
}

@media(max-width:900px){
  .topbar{
    margin:0 -12px!important;
    padding:6px 10px!important;
  }
  .topbar h2{
    white-space:normal;
  }
  .format-toolbar{
    top:auto!important;
  }
}


/* ===== CONTENIDO como persiana ===== */
.sidebar-content-toggle{
  width:100%;
  border:0;
  background:transparent;
  color:#f8fafc;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:8px 2px 6px;
  margin-top:8px;
  font:inherit;
  font-size:10px;
  font-weight:800;
  cursor:pointer;
  text-align:left;
}
.content-toggle-arrow{
  width:20px;
  height:20px;
  border:1px solid #334155;
  border-radius:6px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
}
.sidebar-content-panel{
  max-height:260px;
  overflow:hidden;
  opacity:1;
  transition:max-height .2s ease, opacity .15s ease;
}
.sidebar-content-panel.collapsed{
  max-height:0;
  opacity:0;
  pointer-events:none;
}

/* Los antiguos Exportar / Importar / Imprimir ya no forman parte de la interfaz. */
.legacy-footer-actions{
  display:none!important;
}

/* Ver libro completo siempre abajo de todo. */
#continuousBookFooterHost{
  width:100%;
}
#continuousBookFooterHost .continuous-book-button{
  position:static!important;
  width:100%!important;
  margin:0!important;
  min-height:36px;
  display:block;
  font-weight:800;
}
.sidebar-footer{
  display:block!important;
  padding-top:8px!important;
}


/* ===== LECTOR: RESALTADO DIRECTAMENTE EN LA HOJA ===== */
#readerTranscript{
  display:none!important;
}

/* Capa de lectura sobre el textarea principal del capítulo. */
.reader-text-overlay{
  position:absolute;
  inset:0;
  z-index:4;
  background:#fff;
  color:#263244;
  padding:0;
  overflow:auto;
  white-space:pre-wrap;
  font:inherit;
  font-size:inherit;
  line-height:1.75;
  border-radius:inherit;
  pointer-events:none;
}

.reader-text-overlay .reader-current-sentence{
  background:#facc15;
  color:#111827;
  border-radius:3px;
  padding:1px 2px;
  box-decoration-break:clone;
  -webkit-box-decoration-break:clone;
}

.reader-overlay-host{
  position:relative!important;
}

.reader-direct-highlight{
  background:#facc15!important;
  color:#111827!important;
  border-radius:3px;
  padding:1px 2px;
  box-decoration-break:clone;
  -webkit-box-decoration-break:clone;
}


/* ===== CONTROLES FLOTANTES DE LECTURA ===== */
.floating-read-controls{
  position:fixed;
  left:calc(205px + 18px);
  bottom:18px;
  z-index:120;
  display:flex;
  align-items:center;
  gap:7px;
  padding:7px;
  border:1px solid #334155;
  background:rgba(15,23,42,.96);
  border-radius:999px;
  box-shadow:0 12px 30px rgba(15,23,42,.28);
  backdrop-filter:blur(8px);
}
.floating-read-controls.hidden{
  display:none!important;
}
.floating-read-controls button{
  width:38px;
  height:38px;
  padding:0;
  border:1px solid #475569;
  border-radius:50%;
  background:#172033;
  color:#fff;
  display:grid;
  place-items:center;
  cursor:pointer;
  font-size:14px;
}
.floating-read-controls .float-read-main{
  width:48px;
  height:48px;
  background:#2563eb;
  border-color:#2563eb;
  font-size:20px;
  box-shadow:0 5px 16px rgba(37,99,235,.34);
}
.floating-read-controls button:hover{
  background:#263754;
}
.floating-read-controls .float-read-main:hover{
  background:#1d4ed8;
}
.floating-read-controls button:focus-visible{
  outline:3px solid rgba(96,165,250,.45);
  outline-offset:2px;
}
.floating-read-controls.is-reading .float-read-main{
  background:#16a34a;
  border-color:#16a34a;
}
.floating-read-controls.is-paused .float-read-main{
  background:#d97706;
  border-color:#d97706;
}

@media(max-width:900px){
  .floating-read-controls{
    left:14px;
    bottom:14px;
  }
}
@media print{
  .floating-read-controls{
    display:none!important;
  }
}


/* ===== Navegación segura de Vista Libro Completo ===== */
.continuous-hidden-original{
  display:none!important;
}

#continuousBookView{
  width:100%;
  min-width:0;
}

.continuous-actions #continuousBack{
  background:#0f172a;
  color:#fff;
  border:1px solid #334155;
}

.continuous-actions #continuousBack:hover{
  background:#1e293b;
}

/* En modo libro completo, el sidebar sigue activo para volver con un clic. */
body.continuous-mode .sidebar{
  z-index:60;
}


/* ===== Header compacto: Guardado junto al título ===== */
.topbar > div:first-child{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:4px;
}
.topbar > div:first-child .eyebrow{
  flex-basis:100%;
}
.save-status-inline{
  display:inline-flex;
  align-items:center;
  gap:4px;
  margin-left:7px;
  padding:2px 6px;
  border-radius:999px;
  font-size:9px;
  line-height:1;
}
.save-status-inline.save-ok{
  color:#166534;
  background:#f0fdf4;
  border:1px solid #bbf7d0;
}
.save-status-inline.save-saving{
  color:#92400e;
  background:#fffbeb;
  border:1px solid #fde68a;
}
.save-status-inline.save-error{
  color:#991b1b;
  background:#fef2f2;
  border:1px solid #fecaca;
}

/* ===== Flechas volver / adelantar ===== */
.history-tools button{
  font-size:15px!important;
  font-weight:800;
}

/* ===== Acciones al final de la barra de formato ===== */
.toolbar-publish-actions{
  margin-left:auto!important;
  border-right:0!important;
  padding-right:0!important;
}
.toolbar-publish-actions button{
  min-width:30px!important;
  font-size:13px!important;
}
.toolbar-publish-actions .danger-action{
  color:#b91c1c!important;
}

/* Evitar espacio de la antigua barra independiente. */
.publish-actions:not(.toolbar-publish-actions){
  display:none!important;
}


/* ===== LECTOR FLOTANTE: SOLO EN "VER LIBRO COMPLETO" ===== */
.floating-read-controls{
  position:fixed;
  right:22px!important;
  left:auto!important;
  bottom:22px!important;
  z-index:160;
  display:flex;
  align-items:center;
  gap:7px;
  padding:7px;
  border:1px solid #334155;
  background:rgba(15,23,42,.96);
  border-radius:999px;
  box-shadow:0 12px 30px rgba(15,23,42,.28);
  backdrop-filter:blur(8px);
}

/* Por defecto no se muestra en editor, índice, páginas preliminares ni biblioteca. */
.floating-read-controls{
  display:none!important;
}

/* Solo aparece cuando realmente está abierta la vista del libro completo. */
body.continuous-mode .floating-read-controls{
  display:flex!important;
}

.floating-read-controls button{
  width:38px;
  height:38px;
  padding:0;
  border:1px solid #475569;
  border-radius:50%;
  background:#172033;
  color:#fff;
  display:grid;
  place-items:center;
  cursor:pointer;
  font-size:14px;
}

.floating-read-controls .float-read-main{
  width:48px;
  height:48px;
  background:#2563eb;
  border-color:#2563eb;
  font-size:20px;
  box-shadow:0 5px 16px rgba(37,99,235,.34);
}

.floating-read-controls.is-reading .float-read-main{
  background:#16a34a;
  border-color:#16a34a;
}

.floating-read-controls.is-paused .float-read-main{
  background:#d97706;
  border-color:#d97706;
}

@media(max-width:900px){
  .floating-read-controls{
    right:12px!important;
    bottom:12px!important;
  }
}

@media print{
  .floating-read-controls{
    display:none!important;
  }
}


/* ===== Gestión de capítulos ===== */
.header-edit-title{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:24px;
  height:24px;
  padding:0;
  margin-left:2px;
  border:1px solid #cbd5e1;
  border-radius:7px;
  background:#fff;
  color:#475569;
  cursor:pointer;
  font-size:13px;
}
.header-edit-title:hover{
  background:#eff6ff;
  border-color:#93c5fd;
  color:#1d4ed8;
}
.header-edit-title.hidden{display:none!important}

.chapter-more{
  flex:0 0 auto;
  width:22px;
  height:28px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:6px;
  color:inherit;
  opacity:.82;
  cursor:pointer;
  font-size:16px;
  line-height:1;
}
.chapter-more:hover{
  background:rgba(255,255,255,.14);
  opacity:1;
}

.chapter-menu{
  position:fixed;
  z-index:220;
  width:178px;
  padding:6px;
  border:1px solid #d8dee8;
  border-radius:10px;
  background:#fff;
  box-shadow:0 12px 30px rgba(15,23,42,.18);
}
.chapter-menu.hidden{display:none!important}
.chapter-menu button{
  width:100%;
  min-height:34px;
  border:0;
  border-radius:7px;
  background:transparent;
  color:#172033;
  padding:7px 9px;
  text-align:left;
  cursor:pointer;
  font-size:12px;
}
.chapter-menu button:hover{background:#f1f5f9}
.chapter-menu button.danger{color:#b91c1c}
.chapter-menu button.danger:hover{background:#fef2f2}


/* ===== AUDIO-LIBRO: leer desde cualquier punto ===== */
.continuous-page-content{
  cursor:text;
}

.continuous-page-content p,
.continuous-page-content li,
.continuous-page-content blockquote,
.continuous-page-content h1,
.continuous-page-content h2,
.continuous-page-content h3{
  border-radius:4px;
}

.continuous-reader-highlight{
  background:#facc15;
  color:#111827;
  border-radius:3px;
  padding:1px 2px;
  box-decoration-break:clone;
  -webkit-box-decoration-break:clone;
}

.continuous-reader-block-active{
  scroll-margin-top:90px;
}

.continuous-read-from-here{
  position:fixed;
  z-index:260;
  border:1px solid #2563eb;
  border-radius:999px;
  background:#2563eb;
  color:#fff;
  padding:8px 12px;
  font-size:12px;
  font-weight:800;
  box-shadow:0 10px 26px rgba(37,99,235,.28);
  cursor:pointer;
}

.continuous-read-from-here:hover{
  background:#1d4ed8;
}


/* ===== Corrección: cada frase leída debe quedar visualmente marcada ===== */
.continuous-reader-highlight{
  background:#facc15!important;
  color:#111827!important;
  border-radius:3px;
  padding:1px 2px;
  box-decoration-break:clone;
  -webkit-box-decoration-break:clone;
}

.continuous-reader-fallback{
  background:rgba(250,204,21,.48)!important;
  outline:2px solid rgba(234,179,8,.55);
  outline-offset:2px;
  border-radius:4px;
}

.continuous-reader-block-active{
  scroll-margin-top:110px;
}


/* =========================================================
   TIPOGRAFÍA Y MAQUETACIÓN TIPO LIBRO
   ========================================================= */

/* Texto principal: un poco más grande y con lectura más cómoda. */
.chapter-header,
.continuous-page-content,
.front-matter-page,
.a4-page{
  font-family: Georgia, "Times New Roman", serif;
  color:#1f2937;
}

/* Área principal de escritura */
#chapterIntro{
  font-family: Georgia, "Times New Roman", serif!important;
  font-size:16px!important;
  line-height:1.85!important;
  letter-spacing:.01em;
  tab-size:4;
  white-space:pre-wrap!important;
  word-break:normal;
  overflow-wrap:break-word;
  padding:20px 24px!important;
}

/* Respetar saltos de línea, espacios y tabulaciones en vistas renderizadas */
.continuous-page-content,
.front-matter-page .rich-editor,
.a4-page .rich-editor,
.chapter-main-content{
  white-space:pre-wrap!important;
  tab-size:4;
  font-size:16px!important;
  line-height:1.85!important;
  letter-spacing:.01em;
  text-align:left;
  hyphens:auto;
  overflow-wrap:break-word;
}

/* Párrafos como libro: separación y sangría */
.continuous-page-content p,
.front-matter-page .rich-editor p,
.a4-page .rich-editor p,
.chapter-main-content p{
  margin:0 0 1em;
}

/* Sangría para párrafos sucesivos, sin forzarla en títulos/listas */
.continuous-page-content p + p,
.front-matter-page .rich-editor p + p,
.a4-page .rich-editor p + p,
.chapter-main-content p + p{
  text-indent:1.6em;
}

/* Listas con aire editorial */
.continuous-page-content ul,
.continuous-page-content ol,
.front-matter-page .rich-editor ul,
.front-matter-page .rich-editor ol,
.a4-page .rich-editor ul,
.a4-page .rich-editor ol{
  margin:0 0 1em 1.5em;
  padding-left:1.1em;
}

.continuous-page-content li,
.front-matter-page .rich-editor li,
.a4-page .rich-editor li{
  margin:.35em 0;
}

/* Títulos con jerarquía más editorial */
.continuous-page-head h1,
.chapter-header h1,
.chapter-header h2,
.front-matter-page h1,
.front-matter-page h2,
.a4-page h1,
.a4-page h2{
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing:-.01em;
  line-height:1.2;
}

.continuous-page-head h1{
  font-size:26px!important;
  margin:.2em 0 .55em!important;
}

/* Mejor ancho de lectura dentro de A4 */
.continuous-page-content{
  max-width:72ch;
  margin-left:auto;
  margin-right:auto;
}

/* Evitar bloques demasiado pegados */
.continuous-page-content > * + *{
  margin-top:.35em;
}

/* Citas / reglas / bloques destacados */
.continuous-page-content blockquote,
.front-matter-page blockquote,
.a4-page blockquote{
  margin:1.2em 2em;
  padding:.4em 0 .4em 1em;
  border-left:3px solid #cbd5e1;
  color:#475569;
  font-style:italic;
}

/* Mantener tabulaciones visibles en contenido plano */
.preserve-book-spacing{
  white-space:pre-wrap!important;
  tab-size:4!important;
}


/* ===== Elementos insertables del libro ===== */
.book-insert-tools{
  display:flex;
  align-items:center;
  gap:4px;
  flex-wrap:wrap;
}
.book-table-wrap{
  width:100%;
  overflow-x:auto;
  margin:1.25em 0;
}
.book-table{
  width:100%;
  border-collapse:collapse;
  font-family:Georgia,"Times New Roman",serif;
  font-size:.95em;
  line-height:1.45;
}
.book-table th,
.book-table td{
  border:1px solid #94a3b8;
  padding:.55em .7em;
  min-width:70px;
  vertical-align:top;
}
.book-table th{
  font-weight:700;
  background:#f1f5f9;
}
.book-image{
  margin:1.5em auto;
  text-align:center;
  max-width:100%;
}
.book-image img{
  display:block;
  max-width:100%;
  max-height:620px;
  width:auto;
  height:auto;
  margin:0 auto;
  object-fit:contain;
  border-radius:3px;
}
.book-image figcaption{
  margin-top:.55em;
  font-size:.86em;
  line-height:1.4;
  color:#64748b;
  font-style:italic;
}
@media print{
  .book-table-wrap{overflow:visible;}
  .book-table{break-inside:avoid;}
  .book-image{break-inside:avoid;}
  .book-image img{max-height:22cm;}
}


/* =========================================================
   IMPRESIÓN / VISTA PREVIA TIPO LIBRO
   ========================================================= */

@page{
  size:A4;
  margin:18mm 18mm 20mm 18mm;
}

@media print{
  html, body{
    background:#fff!important;
    color:#111827!important;
    font-family:Georgia,"Times New Roman",serif!important;
    font-size:11.5pt!important;
    line-height:1.6!important;
  }

  body *{
    box-shadow:none!important;
  }

  .sidebar,
  .topbar,
  .format-toolbar,
  .study-toolbar,
  .floating-read-controls,
  .publish-actions,
  .continuous-sticky-header,
  .continuous-actions,
  .reader-toolbar,
  .book-insert-tools{
    display:none!important;
  }

  #printRoot{
    display:block!important;
    width:auto!important;
    margin:0!important;
    padding:0!important;
  }

  .a4-page,
  .continuous-a4{
    width:auto!important;
    min-height:auto!important;
    height:auto!important;
    margin:0!important;
    padding:0!important;
    border:0!important;
    box-shadow:none!important;
    page-break-after:always;
    break-after:page;
    background:#fff!important;
  }

  .page-top,
  .continuous-page-head{
    margin-bottom:10mm!important;
    padding-bottom:4mm!important;
    border-bottom:1px solid #d1d5db!important;
  }

  .page-kicker,
  .continuous-page-head small{
    font-family:Arial,sans-serif!important;
    font-size:8.5pt!important;
    letter-spacing:.12em!important;
    color:#4b5563!important;
  }

  .lesson-title,
  .continuous-page-head h1,
  .a4-page h1,
  .a4-page h2{
    font-family:Georgia,"Times New Roman",serif!important;
    font-size:18pt!important;
    line-height:1.2!important;
    margin:0 0 5mm!important;
    color:#111827!important;
  }

  .page-body,
  .continuous-page-content,
  .a4-page .rich-editor{
    max-width:none!important;
    margin:0!important;
    padding:0!important;
    font-family:Georgia,"Times New Roman",serif!important;
    font-size:11.5pt!important;
    line-height:1.65!important;
    text-align:justify!important;
    hyphens:auto!important;
  }

  .page-body p,
  .continuous-page-content p,
  .a4-page .rich-editor p{
    margin:0 0 .85em!important;
    orphans:3;
    widows:3;
  }

  .page-body p + p,
  .continuous-page-content p + p,
  .a4-page .rich-editor p + p{
    text-indent:1.5em!important;
  }

  .page-body ul,
  .page-body ol,
  .continuous-page-content ul,
  .continuous-page-content ol{
    margin:.6em 0 1em 1.6em!important;
  }

  .book-table{
    width:100%!important;
    border-collapse:collapse!important;
    font-size:10pt!important;
    page-break-inside:avoid;
  }

  .book-table th,
  .book-table td{
    border:1px solid #9ca3af!important;
    padding:5pt 6pt!important;
  }

  .book-image{
    page-break-inside:avoid;
    break-inside:avoid;
    margin:8mm auto!important;
  }

  .book-image img{
    max-width:100%!important;
    max-height:190mm!important;
    object-fit:contain!important;
  }

  .book-image figcaption{
    font-size:9pt!important;
    color:#6b7280!important;
    margin-top:3mm!important;
  }

  .page-footer,
  .continuous-page-foot{
    position:static!important;
    margin-top:10mm!important;
    padding-top:3mm!important;
    border-top:1px solid #e5e7eb!important;
    font-size:8.5pt!important;
    color:#6b7280!important;
  }
}

/* Vista previa en pantalla con proporción A4 correcta */
.a4-page,
.continuous-a4{
  box-sizing:border-box;
}

.book-empty-line{
  min-height:1em;
}


/* ===== CORRECCIÓN EDITOR DE CAPÍTULO Y ZOOM ===== */
.chapter-intro-editor{
  width:100%;
  min-height:128px;
  box-sizing:border-box;
  padding:20px 24px;
  border:1px solid #d7deea;
  border-radius:10px;
  background:#fff;
  color:#1f2937;
  font-family:Georgia,"Times New Roman",serif;
  font-size:16px;
  line-height:1.85;
  white-space:pre-wrap;
  tab-size:4;
  outline:none;
  overflow-wrap:break-word;
}
.chapter-intro-editor:focus{
  border-color:#93c5fd;
  box-shadow:0 0 0 3px rgba(59,130,246,.10);
}
.chapter-intro-editor:empty::before{
  content:attr(data-placeholder);
  color:#94a3b8;
  pointer-events:none;
}
.chapter-intro-editor p{
  margin:0 0 1em;
}
.chapter-intro-editor p + p{
  text-indent:1.6em;
}
.chapter-header,.a4-page,.index-book{
  transform-origin:top center;
}


/* =========================================================
   CORRECCIÓN: SIN SANGRÍA / TABULACIÓN AUTOMÁTICA
   ========================================================= */

/* El texto normal NO debe traer sangría por defecto. */
.chapter-intro-editor p,
.chapter-intro-editor p + p,
.continuous-page-content p,
.continuous-page-content p + p,
.front-matter-page .rich-editor p,
.front-matter-page .rich-editor p + p,
.a4-page .rich-editor p,
.a4-page .rich-editor p + p,
.chapter-main-content p,
.chapter-main-content p + p,
.page-body p,
.page-body p + p{
  text-indent:0!important;
  margin-left:0;
}

/* Respetar el orden escrito sin agregar tabulación visual automática. */
.chapter-intro-editor,
.continuous-page-content,
.front-matter-page .rich-editor,
.a4-page .rich-editor,
.chapter-main-content{
  tab-size:4;
}

/* La sangría solo aparece cuando el usuario la aplica realmente. */
.chapter-intro-editor [style*="margin-left"],
.continuous-page-content [style*="margin-left"],
.front-matter-page .rich-editor [style*="margin-left"],
.a4-page .rich-editor [style*="margin-left"]{
  text-indent:0!important;
}

/* Listas: no alterar párrafos normales; solo las listas reales tienen su margen. */
.chapter-intro-editor ul,
.chapter-intro-editor ol,
.continuous-page-content ul,
.continuous-page-content ol,
.front-matter-page .rich-editor ul,
.front-matter-page .rich-editor ol,
.a4-page .rich-editor ul,
.a4-page .rich-editor ol{
  margin-left:1.6em!important;
  padding-left:1.1em!important;
}

@media print{
  .page-body p,
  .page-body p + p,
  .continuous-page-content p,
  .continuous-page-content p + p,
  .a4-page .rich-editor p,
  .a4-page .rich-editor p + p{
    text-indent:0!important;
    margin-left:0!important;
  }
}


/* =========================================================
   CABECERA FLOTANTE DEL ÁREA DE TRABAJO
   Al bajar el scroll, título + formato + lector quedan visibles.
   ========================================================= */

/* El área principal debe permitir sticky correctamente. */
.main{
  overflow:visible!important;
}

/* Cabecera con título del capítulo/libro. */
.topbar{
  position:sticky!important;
  top:0!important;
  z-index:140!important;
  background:rgba(241,245,249,.98)!important;
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
  border-bottom:1px solid #dbe3ee;
}

/* Barra de formato pegada debajo del título. */
.format-toolbar{
  position:sticky!important;
  top:47px!important;
  z-index:139!important;
  background:rgba(255,255,255,.98)!important;
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px);
  box-shadow:0 2px 8px rgba(15,23,42,.06);
}

/* Barra Leer / Pausa / Estudiar pegada debajo de formato. */
.study-toolbar,
.reader-toolbar{
  position:sticky!important;
  top:88px!important;
  z-index:138!important;
  background:#0f172a!important;
  box-shadow:0 4px 10px rgba(15,23,42,.10);
}

/* Evitar que el contenido quede oculto al navegar a un punto. */
.chapter-header,
.a4-page,
.index-book,
.front-matter-page{
  scroll-margin-top:132px!important;
}

/* Cuando el header se pega, conservar aspecto compacto. */
.topbar,
.format-toolbar,
.study-toolbar,
.reader-toolbar{
  transition:box-shadow .15s ease, background .15s ease;
}

/* En libro completo usamos su propia cabecera flotante. */
body.continuous-mode .topbar,
body.continuous-mode .format-toolbar,
body.continuous-mode .study-toolbar,
body.continuous-mode .reader-toolbar{
  position:static!important;
}

.continuous-sticky-header{
  position:sticky!important;
  top:0!important;
  z-index:145!important;
}

/* Responsive: las barras pueden ocupar más alto. */
@media(max-width:900px){
  .format-toolbar{
    top:54px!important;
  }

  .study-toolbar,
  .reader-toolbar{
    top:108px!important;
  }

  .chapter-header,
  .a4-page,
  .index-book,
  .front-matter-page{
    scroll-margin-top:155px!important;
  }
}

/* La impresión nunca debe usar sticky. */
@media print{
  .topbar,
  .format-toolbar,
  .study-toolbar,
  .reader-toolbar,
  .continuous-sticky-header{
    position:static!important;
    box-shadow:none!important;
    backdrop-filter:none!important;
  }
}

/* Capa final del dashboard: prevalece sobre los estilos históricos. */
body{grid-template-columns:var(--dashboard-sidebar) minmax(0,1fr)!important;background:var(--dashboard-bg)!important}
.sidebar{width:var(--dashboard-sidebar)!important;padding:18px 14px 14px!important;gap:12px!important}
.main{min-width:0!important;width:100%!important;padding:0 18px 32px!important;overflow-x:hidden!important}
.topbar{margin:0 -18px!important;padding:8px 18px!important;min-height:54px!important}
.topbar > div:first-of-type{display:flex!important;align-items:center!important;flex-wrap:wrap!important;gap:4px!important;min-width:0!important;flex:1!important}
.topbar > div:first-of-type .eyebrow{flex-basis:100%!important}
.format-toolbar{
  top:54px!important;display:flex!important;flex-wrap:nowrap!important;
  overflow-x:auto!important;overflow-y:hidden!important;
  padding:6px 8px 7px!important;gap:5px!important;margin-bottom:8px!important;
}
.format-toolbar.hidden{display:none!important}
.toolbar-group{flex:0 0 auto!important}
.toolbar-publish-actions{margin-left:0!important}
#editor,#frontMatterView,#indexView{width:100%!important;max-width:900px!important;margin-inline:auto!important}
.chapter-header,.front-matter-page,.index-book{
  border:1px solid #d8e0ea!important;border-radius:0 0 14px 14px!important;
  box-shadow:var(--dashboard-shadow)!important;background:#fff!important;
}
.chapter-header{padding:26px 34px!important}
.chapter-title-row{padding-bottom:13px!important;margin-bottom:12px!important;border-bottom:1px solid #e5eaf1!important}
#chapterIntro{padding:8px 2px 28px!important;border:0!important;box-shadow:none!important}

@media(max-width:1180px) and (min-width:921px){
  :root{--dashboard-sidebar:248px}
  .stats span{display:none!important}
  .stats div{min-width:42px!important}
}

@media(max-width:920px){
  body{display:block!important}
  .sidebar{
    position:fixed!important;inset:0 auto 0 0!important;width:min(300px,86vw)!important;
    height:100dvh!important;transform:translateX(-105%);transition:transform .22s ease;z-index:300!important;
  }
  body.sidebar-open{overflow:hidden!important}
  body.sidebar-open .sidebar{transform:translateX(0)}
  .sidebar-toggle{display:grid!important;place-items:center!important}
  .sidebar-backdrop{display:block!important}
  body.sidebar-open .sidebar-backdrop{opacity:1!important;pointer-events:auto!important}
  .main{padding:0 10px 22px!important}
  .topbar{margin:0 -10px!important;padding:7px 10px!important;flex-direction:row!important;align-items:center!important}
  .topbar .eyebrow,.stats{display:none!important}
  .format-toolbar{top:54px!important;margin-inline:0!important}
  .study-toolbar,.reader-toolbar{top:99px!important}
  .chapter-header{padding:20px 18px!important}
  #editor,#frontMatterView,#indexView{max-width:100%!important}
}

@media print{
  .sidebar-toggle,.sidebar-backdrop{display:none!important}
}

/* ===== Lectura: reproducción integrada y cabecera siempre visible ===== */
body.continuous-mode .continuous-book-view{
  position:relative!important;
  overflow:visible!important;
}
body.continuous-mode .continuous-sticky-header{
  position:sticky!important;
  top:0!important;
  z-index:500!important;
  width:100%!important;
}
.continuous-reader-controls{
  display:flex;
  align-items:center;
}
.continuous-reader-controls:empty{display:none}
.continuous-reader-controls .floating-read-controls{
  position:static!important;
  inset:auto!important;
  display:flex!important;
  padding:3px!important;
  gap:3px!important;
  border:1px solid #d7e0eb!important;
  border-radius:9px!important;
  background:#f8fafc!important;
  box-shadow:none!important;
  backdrop-filter:none!important;
}
.continuous-reader-controls .floating-read-controls.hidden{display:flex!important}
.continuous-reader-controls .floating-read-controls button{
  width:27px!important;
  height:27px!important;
  min-height:27px!important;
  padding:0!important;
  border-radius:6px!important;
  font-size:11px!important;
  color:#334155!important;
  background:#fff!important;
  border:1px solid #d7e0eb!important;
}
.continuous-reader-controls .floating-read-controls .float-read-main{
  width:30px!important;
  height:27px!important;
  background:#2563eb!important;
  border-color:#2563eb!important;
  color:#fff!important;
  box-shadow:none!important;
}
.continuous-reader-controls .floating-read-controls.is-reading .float-read-main{
  background:#16a34a!important;
  border-color:#16a34a!important;
}
.continuous-reader-controls .floating-read-controls.is-paused .float-read-main{
  background:#d97706!important;
  border-color:#d97706!important;
}
@media(max-width:700px){
  .continuous-reader-controls{order:-1}
}
@media print{
  .floating-read-controls,
  .continuous-reader-controls,
  #floatingReadControls,
  [aria-label="Controles de lectura"],
  [aria-label="Reproducción del libro"]{
    display:none!important;
    visibility:hidden!important;
  }
}

/* ===== Navegación lateral compacta y búsqueda del libro ===== */
.book-navigation .sidebar-mode-switch{order:1!important}
.book-navigation > .search-box{
  order:2!important;
  display:block!important;
  margin:1px 0 3px!important;
}
.book-navigation #contentAccordionPanel{order:3!important}
.book-navigation .sidebar-section-head.second{display:none!important}
.book-navigation #chapterList{order:4!important}
.book-navigation #btnNewChapter{
  order:5!important;
  width:auto!important;
  min-height:28px!important;
  margin:0 8px!important;
  padding:5px 2px!important;
  border:0!important;
  border-radius:0!important;
  background:transparent!important;
  box-shadow:none!important;
  color:#93c5fd!important;
  font-size:12px!important;
  font-weight:750!important;
  text-align:left!important;
}
.book-navigation #btnNewChapter:hover{
  color:#fff!important;
  text-decoration:underline;
  background:transparent!important;
}
body.continuous-mode .book-navigation > .search-box{display:block!important}
body.continuous-mode #btnNewChapter{display:none!important}

/* Ajuste final de ritmo vertical en edición y lectura. */
.chapter-intro-editor,
.continuous-page-content.preserve-book-spacing{
  white-space:normal!important;
}
.chapter-intro-editor p,
.continuous-page-content p{
  margin:0 0 .68em!important;
  line-height:1.62!important;
}
.chapter-intro-editor p:empty,
.chapter-intro-editor p:has(> br:only-child),
.continuous-page-content p:empty,
.continuous-page-content p:has(> br:only-child),
.chapter-intro-editor .book-empty-line,
.continuous-page-content .book-empty-line{
  min-height:.32em!important;
  height:.32em!important;
  margin:0!important;
  padding:0!important;
  line-height:.32!important;
}
.chapter-intro-editor > * + *,
.continuous-page-content > * + *{
  margin-top:0!important;
}
body.continuous-mode{
  scroll-padding-top:calc(var(--continuous-header-height, 66px) + 18px);
}
body.continuous-mode .continuous-a4{
  scroll-margin-top:calc(var(--continuous-header-height, 66px) + 18px)!important;
}

.history-tools,
#publishActions,
.toolbar-publish-actions{display:none!important}
.topbar-title{grid-template-columns:auto auto auto 1fr!important}
.topbar-title .header-quick-actions{
  grid-column:3!important;grid-row:2!important;
  display:flex;align-items:center;gap:3px;margin-left:1px;
}
.topbar-title .header-quick-actions button{
  width:28px;height:28px;padding:0;border:1px solid #dce4ee;border-radius:7px;
  background:#fff;color:#334155;font-size:13px;font-weight:800;
}
.topbar-title .header-quick-actions button:hover{
  background:#eff6ff;border-color:#93c5fd;color:#1d4ed8;
}
.topbar-title .header-quick-actions #btnDeleteChapter{
  color:#dc2626!important;border-color:#fecaca!important;background:#fff7f7!important;
}
.topbar-title .header-quick-actions #btnDeleteChapter:hover{
  color:#fff!important;border-color:#dc2626!important;background:#dc2626!important;
}
.topbar-title .save-status-inline{grid-column:4!important}
body.library-view-mode .header-quick-actions,
body.continuous-mode .header-quick-actions{display:none!important}
.heading-tools::before,
.list-tools::before{display:none!important;content:none!important}
.list-tools [data-cmd="insertUnorderedList"],
.list-tools [data-cmd="insertOrderedList"]{
  min-width:34px!important;width:34px!important;padding:0 4px!important;
  font-size:11px!important;font-weight:850!important;letter-spacing:-1px;
}

.topbar-book-action{display:flex;align-items:center;margin-left:auto}
.view-full-book{
  min-height:34px;padding:7px 12px;border:1px solid #bfdbfe;border-radius:9px;
  background:#2563eb;color:#fff;font-size:11px;font-weight:800;white-space:nowrap;
  box-shadow:0 5px 14px rgba(37,99,235,.18);
}
.view-full-book:hover{background:#1d4ed8;border-color:#1d4ed8}
body.library-view-mode .topbar-book-action{display:none!important}
body.continuous-mode .topbar-book-action{display:none!important}
.final-preview-mode .continuous-actions .final-preview-print{
  background:#2563eb!important;color:#fff!important;border-color:#2563eb!important;
}
.final-preview-mode .continuous-page-content.preserve-book-spacing{
  white-space:normal!important;
}
.final-preview-mode .continuous-page-content p{
  margin:0 0 .7em!important;
  line-height:1.62!important;
}
.final-preview-mode .continuous-page-content > * + *{
  margin-top:0!important;
}
.final-preview-mode #btnSidebarRead{
  background:transparent!important;color:#cbd5e1!important;box-shadow:none!important;
}
.final-preview-mode #floatingReadControls,
.final-preview-mode .floating-read-controls,
.final-preview-mode .continuous-reader-controls{
  display:none!important;
  visibility:hidden!important;
}
@media(max-width:560px){
  .view-full-book{font-size:0;padding-inline:9px}
  .view-full-book::first-letter{font-size:14px}
}

/* Cabecera de lectura fija: permanece visible aunque el scroll esté en .main. */
body.continuous-mode .continuous-sticky-header{
  position:fixed!important;
  top:0!important;
  left:var(--dashboard-sidebar)!important;
  right:0!important;
  width:auto!important;
  z-index:500!important;
}
body.continuous-mode .continuous-document{
  padding-top:calc(var(--continuous-header-height, 66px) + 24px)!important;
}
@media(max-width:920px){
  body.continuous-mode .continuous-sticky-header{left:0!important}
}
@media print{
  body.continuous-mode .continuous-document{padding-top:0!important}
}

/* El modo lectura muestra solo herramientas de lectura. */
body.continuous-mode #formatToolbar,
body.continuous-mode .format-toolbar,
body.continuous-mode .toolbar{
  display:none!important;
}
.continuous-speech-voice{
  width:min(230px,24vw);min-width:150px;height:32px;
  padding:0 28px 0 9px;border:1px solid #d7e0eb;border-radius:8px;
  background:#fff;color:#334155;font-size:10px;font-weight:650;outline:none;
}
.continuous-speech-voice:focus{
  border-color:#60a5fa;box-shadow:0 0 0 3px rgba(96,165,250,.18);
}
@media(max-width:700px){
  .continuous-speech-voice{width:190px;min-width:190px}
}
@media print{
  .continuous-speech-voice{display:none!important}
}

::highlight(book-search){
  color:#111827;
  background:#fde047;
}

/* =========================================================
   SIDEBAR Y HEADER REDISEÑADOS
   ========================================================= */
.sidebar{
  background:linear-gradient(180deg,#0b1220 0%,#101a2d 58%,#0b1322 100%)!important;
  border-right:1px solid rgba(148,163,184,.16)!important;
}
.brand{
  min-height:62px;padding:8px 9px!important;border-radius:15px;
  background:linear-gradient(135deg,rgba(59,130,246,.13),rgba(99,102,241,.04));
  border:1px solid rgba(148,163,184,.12);
}
.brand .logo{
  color:#fff;background:linear-gradient(145deg,#2563eb,#4f46e5)!important;
  box-shadow:0 8px 22px rgba(37,99,235,.28);
}
.brand-copy{min-width:0;flex:1}
.brand-copy h1{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.brand-copy p{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.brand-back{
  flex:0 0 auto;width:34px;height:34px;display:grid;place-items:center;
  border:1px solid rgba(147,197,253,.24);border-radius:10px;
  background:rgba(37,99,235,.15);color:#dbeafe;font-size:18px;
  transition:background .15s ease,transform .15s ease;
}
.brand-back:hover{background:#2563eb;color:#fff;transform:translateX(-2px)}
.brand-back:not(.hidden) + .logo{display:none}
.sidebar-section-head{padding:5px 6px 0!important;color:#93a4bd!important;font-size:10px!important}
.sidebar-section-head button{
  border-color:rgba(148,163,184,.18)!important;background:rgba(255,255,255,.04)!important;
}
.sidebar-book-list{max-height:118px!important;padding:0 2px}
.sidebar-book{
  min-height:48px;border:1px solid rgba(148,163,184,.10)!important;
  background:rgba(255,255,255,.035)!important;border-radius:12px!important;
}
.sidebar-book:hover{background:rgba(59,130,246,.12)!important;border-color:rgba(96,165,250,.25)!important}
.sidebar-book.active{
  background:linear-gradient(135deg,#2563eb,#3157d5)!important;
  border-color:#60a5fa!important;box-shadow:0 8px 20px rgba(37,99,235,.22);
}
.library-button{
  min-height:42px!important;border-color:rgba(148,163,184,.18)!important;
  background:rgba(255,255,255,.045)!important;border-radius:12px!important;
}
.library-button:hover{background:rgba(59,130,246,.14)!important;border-color:#3b82f6!important}
.book-navigation{
  flex:1 1 auto!important;min-height:0!important;overflow-y:auto!important;overflow-x:hidden!important;
  padding:3px 2px 8px!important;scrollbar-width:thin;scrollbar-color:#334155 transparent;
}
.book-navigation::-webkit-scrollbar,.chapter-list::-webkit-scrollbar,.sidebar-book-list::-webkit-scrollbar{width:5px}
.book-navigation::-webkit-scrollbar-thumb,.chapter-list::-webkit-scrollbar-thumb,.sidebar-book-list::-webkit-scrollbar-thumb{background:#334155;border-radius:999px}
.sidebar-content-toggle{
  min-height:36px;padding:7px 8px!important;border-radius:10px!important;
  background:rgba(255,255,255,.035)!important;
}
.sidebar-content-panel{max-height:none!important;overflow:visible!important;padding:5px 0!important}
.sidebar-content-panel.collapsed{max-height:0!important;padding-block:0!important;overflow:hidden!important}
.nav-special{
  min-height:38px!important;margin:3px 0!important;padding:8px 10px!important;
  border-color:transparent!important;background:transparent!important;border-radius:10px!important;
  color:#b9c6d8!important;font-size:12px!important;
}
.nav-special:hover{background:rgba(255,255,255,.055)!important;color:#fff!important}
.nav-special.active{background:rgba(37,99,235,.18)!important;color:#fff!important;border-color:rgba(96,165,250,.25)!important}
#btnNewChapter{
  min-height:42px!important;border-radius:11px!important;
  background:linear-gradient(135deg,#2563eb,#3157d5)!important;
  box-shadow:0 8px 18px rgba(37,99,235,.20);
}
.search-box input{min-height:40px!important;background:rgba(255,255,255,.045)!important;border-color:rgba(148,163,184,.16)!important}
.chapter-list{overflow:visible!important;padding:0!important;gap:5px!important}
.chapter-item{
  min-height:52px!important;padding:9px 8px!important;border-radius:11px!important;
  border:1px solid transparent!important;color:#b9c6d8!important;
}
.chapter-item:hover{background:rgba(255,255,255,.05)!important}
.chapter-item.active{background:linear-gradient(135deg,#1d4ed8,#3157d5)!important;color:#fff!important;box-shadow:0 7px 18px rgba(29,78,216,.20)}
.sidebar-footer{padding-top:6px!important}
#continuousBookFooterHost .continuous-book-button{
  min-height:42px!important;border-radius:11px!important;background:rgba(255,255,255,.055)!important;
  border-color:rgba(148,163,184,.18)!important;
}
#continuousBookFooterHost .continuous-book-button:hover{background:#2563eb!important}
.logout-link{min-height:34px!important;color:#8190a6!important}
.logout-link:hover{color:#fff!important}

.topbar{
  background:rgba(248,250,252,.96)!important;border-bottom:1px solid #dbe3ed!important;
  box-shadow:0 4px 18px rgba(15,23,42,.045)!important;
}
.topbar-title{display:grid!important;grid-template-columns:auto auto 1fr!important;grid-template-rows:auto auto!important;column-gap:8px!important;row-gap:2px!important;align-items:center!important}
.topbar-title .eyebrow{grid-column:1/-1!important;grid-row:1!important;color:#2563eb!important;font-size:8px!important}
.topbar-title h2{grid-column:1!important;grid-row:2!important;font-size:18px!important;letter-spacing:-.015em!important}
.topbar-title .header-edit-title{grid-column:2!important;grid-row:2!important;margin:0!important}
.topbar-title .save-status-inline{grid-column:3!important;grid-row:2!important;justify-self:start!important;margin:0 0 0 2px!important;padding:5px 8px!important}
.topbar-stats{gap:7px!important}
.topbar-stats div{
  min-width:58px!important;padding:6px 9px!important;border:1px solid #e1e7ef!important;
  border-radius:10px!important;box-shadow:0 2px 8px rgba(15,23,42,.035);
}
.topbar-stats strong{font-size:14px!important;color:#0f172a!important}
.topbar-stats span{font-size:8px!important}
body.library-view-mode .topbar-title .save-status-inline,
body.library-view-mode .topbar-title .header-edit-title,
body.library-view-mode .topbar-stats{display:none!important}
body.library-view-mode .topbar-title{grid-template-columns:1fr!important}

/* Acciones repetidas retiradas de la parte inferior de la barra lateral. */
#btnLibrary,#continuousBookFooterHost{display:none!important}
.sidebar-footer{display:none!important}
.brand-copy h1{
  font-size:13px!important;line-height:1.25!important;white-space:normal!important;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;
}
.brand-copy p{font-size:9px!important;margin-top:2px!important}
.topbar-title h2{font-size:16px!important}
.topbar-title{grid-template-columns:auto auto auto minmax(0,1fr)!important}
.topbar-title .header-full-book{
  grid-column:4!important;grid-row:2!important;justify-self:start;
  min-height:28px;padding:4px 8px;border:1px solid #dbe3ed;border-radius:8px;
  background:#fff;color:#334155;font-size:10px;font-weight:750;
}
.topbar-title .header-full-book:hover{border-color:#93c5fd;background:#eff6ff;color:#1d4ed8}
body.library-view-mode .header-full-book{display:none!important}

/* Dentro de un libro el nombre ya está arriba: no repetir selector de libros. */
body:not(.library-view-mode) #sidebarBooksHeading,
body:not(.library-view-mode) #sidebarBookList{display:none!important}

/* Nuevo capítulo y búsqueda ocupan primero el espacio útil. */
.book-navigation .sidebar-section-head.second{order:1!important;margin-top:0!important}
.book-navigation #btnNewChapter{order:2!important}
.book-navigation .search-box{order:3!important}
.book-navigation #contentAccordionToggle{order:4!important;margin-top:4px!important}
.book-navigation #contentAccordionPanel{order:5!important}
.book-navigation #chapterList{order:6!important}

.book-navigation .sidebar-mode-switch{order:4!important}
.book-navigation #contentAccordionPanel{order:5!important}
.sidebar-mode-switch{
  display:grid;grid-template-columns:1fr 1fr;gap:4px;padding:4px;
  border:1px solid rgba(148,163,184,.16);border-radius:11px;background:rgba(255,255,255,.04);
}
.sidebar-mode-switch button{
  min-height:34px;border:0;border-radius:8px;background:transparent;color:#94a3b8;
  font-size:11px;font-weight:800;
}
.sidebar-mode-switch button:hover{background:rgba(255,255,255,.07);color:#fff}
body:not(.continuous-mode):not(.library-view-mode) #btnSidebarEdit,
body.continuous-mode #btnSidebarRead{
  background:#2563eb;color:#fff;box-shadow:0 5px 14px rgba(37,99,235,.25);
}
.sidebar-content-panel{max-height:none!important;opacity:1!important;overflow:visible!important;pointer-events:auto!important}
.topbar-title .header-full-book{display:none!important}

/* Escala tipográfica compacta para ventanas medianas. */
.brand-copy h1{font-size:12px!important;line-height:1.2!important}
.brand-copy p{font-size:8px!important}
.sidebar-section-head{font-size:9px!important}
.sidebar-content-toggle,.nav-special,.chapter-item,.library-button,#btnNewChapter{font-size:11px!important}
.sidebar-book strong{font-size:11px!important}
.sidebar-book small,.chapter-item small{font-size:9px!important}
.search-box input{font-size:11px!important}
.topbar-title h2{font-size:15px!important}
.topbar-title .save-status-inline{font-size:8px!important}
.topbar-stats strong{font-size:12px!important}
.topbar-stats span{font-size:7px!important}
.chapter-title-input{font-size:21px!important}
#chapterIntro,.chapter-intro-editor,.continuous-page-content,.front-matter-page .rich-editor{
  font-size:15px!important;line-height:1.7!important;
}

/* Letras legibles; el espacio se recupera reduciendo padding y separaciones. */
.sidebar{padding:11px 10px 9px!important;gap:8px!important}
.brand{min-height:50px!important;padding:5px 7px!important}
.brand-copy h1{font-size:13px!important;line-height:1.25!important}
.brand-copy p{font-size:9px!important}
.brand-back{width:30px!important;height:30px!important}
.sidebar-section-head{padding:3px 4px 0!important;font-size:10px!important}
.sidebar-section-head button{width:25px!important;height:25px!important}
.book-navigation{padding:1px 1px 5px!important;gap:5px!important}
.sidebar-content-toggle{min-height:31px!important;padding:5px 7px!important;font-size:12px!important}
.sidebar-content-panel{padding:2px 0!important}
.nav-special{min-height:32px!important;margin:1px 0!important;padding:5px 8px!important;font-size:12px!important}
#btnNewChapter{min-height:35px!important;padding:7px 10px!important;font-size:12px!important}
.search-box input{min-height:34px!important;padding:7px 9px!important;font-size:12px!important}
.chapter-list{gap:3px!important}
.chapter-item{min-height:43px!important;padding:6px 7px!important;font-size:12px!important}
.chapter-item small{font-size:10px!important;margin-top:2px!important}
.topbar{padding-block:6px!important;min-height:49px!important}
.topbar-title h2{font-size:16px!important}
.topbar-title .save-status-inline{font-size:9px!important;padding:4px 7px!important}
.chapter-title-input{font-size:23px!important}
#chapterIntro,.chapter-intro-editor,.continuous-page-content,.front-matter-page .rich-editor{
  font-size:16px!important;line-height:1.72!important;
}

.continuous-sidebar-toggle{
  display:none;
  flex:0 0 auto;
  width:38px;
  height:38px;
  border:1px solid #d8e0ea;
  border-radius:10px;
  background:#fff;
  color:#172033;
  font-size:18px;
}
/* Header y controles del modo lectura. */
.continuous-sticky-header{
  min-height:66px!important;padding:10px 18px!important;
  background:rgba(255,255,255,.97)!important;border-bottom:1px solid #dce4ee!important;
  box-shadow:0 5px 22px rgba(15,23,42,.07)!important;
}
.continuous-title-block{min-width:0}
.reading-mode-label{
  display:inline-flex;align-items:center;gap:5px;color:#2563eb;
  font-size:9px;font-weight:850;letter-spacing:.08em;text-transform:uppercase;
}
.reading-mode-label span{font-size:8px;color:#22c55e}
.continuous-sticky-header h2{font-size:17px!important;line-height:1.15!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:52vw}
.continuous-sticky-header p{font-size:10px!important}
.continuous-actions{align-items:center!important;gap:5px!important}
.continuous-actions button{
  min-height:32px!important;padding:6px 9px!important;border-radius:8px!important;
  font-size:10px!important;background:#fff!important;color:#334155!important;border:1px solid #d7e0eb!important;
}
.continuous-actions .continuous-edit{
  background:#2563eb!important;color:#fff!important;border-color:#2563eb!important;font-weight:800!important;
}
.continuous-actions .continuous-edit:hover{background:#1d4ed8!important}
.continuous-actions .continuous-library:hover{background:#f1f5f9!important}
body.continuous-mode #btnNewChapter,
body.continuous-mode .book-navigation > .search-box,
body.continuous-mode .book-navigation > .sidebar-section-head.second,
body.continuous-mode .chapter-drag-handle,
body.continuous-mode .chapter-more{display:none!important}
body.continuous-mode .chapter-item{cursor:pointer!important}

@media(max-width:700px){
  .continuous-sticky-header{display:grid!important;grid-template-columns:38px minmax(0,1fr)!important;align-items:start!important;padding:9px 10px!important}
  .continuous-sidebar-toggle{display:grid!important;place-items:center!important;grid-row:1!important}
  .continuous-title-block{grid-column:2!important;min-width:0!important}
  .continuous-actions{grid-column:1 / -1!important}
  .continuous-sticky-header h2{max-width:100%;font-size:15px!important}
  .continuous-actions{width:100%;overflow-x:auto;flex-wrap:nowrap!important}
  .continuous-actions button{flex:0 0 auto}
}

@media(max-width:920px){
  .topbar-title{display:grid!important;grid-template-columns:auto auto 1fr!important}
  .topbar-title h2{font-size:16px!important}
  .topbar-title .save-status-inline{padding:4px 6px!important}
  .topbar-title .header-full-book span{display:none}
  .topbar-title .header-full-book{padding-inline:7px}
}

/* Encabezado y formato fijos a todo el ancho durante la edición. */
body:not(.continuous-mode):not(.library-view-mode) .topbar{
  position:fixed!important;
  top:0!important;
  left:var(--dashboard-sidebar)!important;
  right:0!important;
  width:auto!important;
  min-height:54px!important;
  margin:0!important;
  padding:7px 14px!important;
  z-index:510!important;
  border-radius:0!important;
}
body:not(.continuous-mode):not(.library-view-mode) #formatToolbar{
  position:fixed!important;
  top:54px!important;
  left:var(--dashboard-sidebar)!important;
  right:0!important;
  width:auto!important;
  max-width:none!important;
  min-height:58px!important;
  margin:0!important;
  padding:6px 10px!important;
  z-index:505!important;
  border-radius:0!important;
  border-left:0!important;
  border-right:0!important;
  box-shadow:0 5px 14px rgba(15,23,42,.08)!important;
}
body:not(.continuous-mode):not(.library-view-mode) .main{
  padding-top:124px!important;
}
body:not(.continuous-mode):not(.library-view-mode) #formatToolbar.hidden{
  display:none!important;
}
body:not(.continuous-mode):not(.library-view-mode):has(#formatToolbar.hidden) .main{
  padding-top:66px!important;
}
@media(max-width:920px){
  body:not(.continuous-mode):not(.library-view-mode) .topbar,
  body:not(.continuous-mode):not(.library-view-mode) #formatToolbar{
    left:0!important;
  }

  body.continuous-mode .continuous-sidebar-toggle{
    display:grid!important;
    place-items:center!important;
  }

  /* El cajón móvil debe cubrir también la cabecera y la barra de edición. */
  .sidebar{
    z-index:700!important;
  }
  .sidebar-backdrop{
    z-index:690!important;
  }
}

/* Reglas finales de la navegación del libro. */
.book-navigation .sidebar-mode-switch{order:1!important}
.book-navigation > .search-box{order:2!important;display:block!important;margin:1px 0 3px!important}
.book-navigation #contentAccordionPanel{order:3!important}
.book-navigation > .sidebar-section-head.second{display:none!important}
.book-navigation #chapterList{order:4!important}
.book-navigation #btnNewChapter{
  order:5!important;width:auto!important;min-height:28px!important;
  margin:0 8px!important;padding:5px 2px!important;border:0!important;
  border-radius:0!important;background:transparent!important;box-shadow:none!important;
  color:#93c5fd!important;font-size:12px!important;font-weight:750!important;text-align:left!important;
}
.book-navigation #btnNewChapter:hover{
  color:#fff!important;text-decoration:underline;background:transparent!important;
}
body.continuous-mode .book-navigation > .search-box{display:block!important}
body.continuous-mode #btnNewChapter{display:none!important}
