/* Estilos exclusivos del libro; el diseño general y las demás vistas se conservan. */
#view-book .reader-body h4 {
  color: var(--gold-light);
  font-size: calc(var(--reader-font-size) * 1.12);
  line-height: 1.5;
  margin: 24px 0 12px;
}
#view-book .reader-body blockquote {
  font-size: var(--reader-font-size);
  line-height: 1.78;
}
#view-book .book-list-item {
  padding-left: 1.2em;
  text-indent: -1.2em;
  text-align: left;
}
#view-book .book-folio {
  display: block;
  color: var(--text-muted);
  text-align: right;
  font-size: 0.7rem;
  margin: 12px 0;
}
#view-book .book-table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin: 16px 0;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
}
#view-book .book-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  color: #e2e8f0;
  font-size: var(--reader-font-size);
  line-height: 1.65;
}
#view-book .book-table th, #view-book .book-table td {
  border: 1px solid var(--border-subtle);
  padding: 10px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}
#view-book .book-table th { background: var(--bg-card-elevated); color: var(--gold-light); }
#view-book .book-table tr:nth-child(even) { background: rgba(0, 229, 255, 0.035); }
#view-book .book-table td:empty { height: 2.5em; }
#view-book .chapter-meta, #view-book .chapter-title-group { min-width: 0; }
#view-book .chapter-title-group h3 { overflow-wrap: anywhere; }
#view-book .book-toc-link { color: inherit; text-decoration-color: var(--gold); }
@media (max-width: 600px) {
  #view-book .book-table th, #view-book .book-table td { padding: 7px; }
  #view-book .book-table:has(tr > :nth-child(3)) { min-width: 520px; }
}

#view-book .reader-body .book-list { list-style: none; margin-left: 0; padding-left: 0; }

#view-book > div:first-child { flex-wrap: wrap; gap: 12px; }
#view-book .reader-controls-bar { flex-wrap: wrap; gap: 12px; }
#view-book .section-heading { min-width: 0; }

#view-book .chapter-card { scroll-margin-top: 76px; }

/* Recurso visual trasladado desde Inicio al capítulo del bucle del hábito. */
#view-book #book-habit-resource { min-width: 0; }
#view-book #book-habit-title { font-size: 0.95rem; margin: 0; }
#view-book #book-habit-resource .chip-btn { max-width: 100%; white-space: normal; }
@media (max-width: 600px) {
  #view-book #book-habit-resource { padding: 12px; }
}

/* Ciclo de tres etapas: controles accesibles sobre las flechas del canvas. */
#view-book #book-habit-resource { --habit-accent: #3b82f6; }
#view-book #habit-loop-badge { color: #93c5fd; background: #13233d; border: 1px solid #284b7a; }
#view-book .habit-modes { margin: 14px 0; }
#view-book .habit-modes .chip-btn[aria-pressed="true"] { color: #fff; border-color: #3b82f6; background: #17325a; }
#view-book #habit-mode-summary, #view-book #habit-node-instructions { text-align: left; line-height: 1.6; }
#view-book #habit-mode-summary { font-size: 0.85rem; color: #cbd5e1; margin-bottom: 8px; }
#view-book #habit-node-instructions { font-size: 0.78rem; color: #94a3b8; margin-bottom: 0; }
#view-book .habit-diagram { position: relative; width: 100%; height: 320px; margin-top: 8px; }
#view-book #canvasHabitLoop { display: block; width: 100%; height: 320px; }
#view-book .habit-node {
  position: absolute; transform: translate(-50%, -50%); width: clamp(90px, 31%, 150px);
  height: 92px; padding: 7px 5px; display: flex; flex-direction: column;
  justify-content: center; align-items: center; gap: 3px; border: 1px solid #315077;
  border-radius: 16px; background: #0d1728; color: #e2e8f0; cursor: pointer;
  font-family: inherit; line-height: 1.25; box-sizing: border-box;
}
#view-book #habit-node-trigger { left: 50%; top: 18%; }
#view-book #habit-node-routine { left: 78%; top: 73%; }
#view-book #habit-node-reward { left: 22%; top: 73%; }
#view-book .habit-node.is-selected { border: 2px solid #60a5fa; background: #142d50; box-shadow: 0 0 18px #2563eb26; }
#view-book .habit-node:hover { background: #17325a; }
#view-book .habit-node:focus-visible, #view-book .habit-modes button:focus-visible { outline: 3px solid #bfdbfe; outline-offset: 4px; }
#view-book .habit-step { font-size: 0.66rem; font-weight: 700; color: #93c5fd; }
#view-book .habit-node-name { font-size: clamp(0.72rem, 1.4vw, 0.92rem); font-weight: 700; }
#view-book .habit-node-term { font-size: 0.64rem; color: #b3c5df; }
#view-book .reader-body .habit-cycle-order { font-size: 0.74rem; line-height: 1.7; color: #93c5fd; text-align: center; margin: 0 0 18px; }
#view-book .habit-detail { background: #0d1728; border-left: 3px solid #3b82f6; border-radius: 8px; padding: 16px; }
#view-book #habit-detail-title { color: #bfdbfe; font-size: var(--reader-font-size); line-height: 1.4; margin: 0 0 10px; }
#view-book #habit-detail-text { text-align: left; margin-bottom: 10px; }
#view-book #habit-detail-source { display: block; color: #94a3b8; font-size: 0.72rem; line-height: 1.6; }

/* Referencias del lector al único formulario del Registro Conductual. */
#view-book .book-log-link { color: #60a5fa; text-decoration: underline; text-underline-offset: 0.18em; font-weight: inherit; }
#view-book .book-log-link:hover { color: #bfdbfe; }
#view-book .book-record-cta, #book-return-control {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; max-width: 100%; padding: 10px 16px; margin: 8px 0 16px;
  border: 1px solid #3b82f6; border-radius: 10px; background: #132b4c;
  color: #dbeafe; font-family: inherit; font-size: 0.88rem; font-weight: 600;
  line-height: 1.5; text-align: center; text-decoration: none; white-space: normal; cursor: pointer;
}
#view-book .book-record-cta:hover, #book-return-control:hover { background: #1e3a5f; }
#view-book .book-log-link:focus-visible, #view-book .book-record-cta:focus-visible, #book-return-control:focus-visible { outline: 3px solid #93c5fd; outline-offset: 4px; }
#book-return-control[hidden] { display: none; }
#behaviorLogForm, #book-return-control { scroll-margin-top: 88px; }

/* Grupos de recursos: un acceso por material dentro de cada contexto. */
#view-book .book-resource-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 20px; }
#view-book .book-resource-button {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; max-width: 100%;
  padding: 9px 13px; border: 1px solid #315b91; border-radius: 10px;
  background: #102139; color: #bfdbfe; text-decoration: none; font-size: 0.82rem;
  font-weight: 600; line-height: 1.5; overflow-wrap: anywhere;
}
#view-book .book-resource-button:hover { background: #17345a; border-color: #60a5fa; }
#view-book .book-resource-button:focus-visible { outline: 3px solid #93c5fd; outline-offset: 4px; }
#view-book .book-resource-button svg, #view-book .book-record-cta svg { flex-shrink: 0; }
[data-context-resource-target] { scroll-margin-top: 88px; }

/* Respiración cuadrada integrada exclusivamente en la lectura. */
#book-box-breathing { margin: 20px 0; padding: 18px; border: 1px solid #315b91; border-radius: 16px; background: #0a1423; }
#view-book #box-breath-title { margin: 0 0 12px; font-size: 1.05rem; color: #93c5fd; }
#view-book #book-box-breathing .box-breath-intro { font-size: 0.82rem; line-height: 1.7; text-align: left; color: #b3c5df; }
.box-breath-square { position: relative; width: min(100%, 320px); aspect-ratio: 1; margin: 0 auto; }
.box-breath-square svg { width: 100%; height: 100%; display: block; overflow: visible; }
.box-breath-track { fill: none; stroke: #233d60; stroke-width: 3; }
.box-breath-square line { stroke: #315077; stroke-width: 3; stroke-linecap: round; }
.box-breath-square line.is-active { stroke: #60a5fa; stroke-width: 5; }
#box-breath-dot { fill: #dbeafe; stroke: #3b82f6; stroke-width: 3; }
.box-breath-markers { fill: #93c5fd; text-anchor: middle; font-size: 16px; font-weight: 700; }
.box-breath-center { position: absolute; inset: 20%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #dbeafe; }
#box-breath-label { font-size: 1rem; font-weight: 700; }
#view-book #box-breath-seconds { font-size: 2.4rem; line-height: 1.2; color: #93c5fd; }
.box-breath-center > span:last-of-type, #box-breath-state { font-size: 0.72rem; color: #94a3b8; }
#view-book #book-box-breathing .box-breath-live { text-align: center; font-size: 0.82rem; color: #bfdbfe; }
#view-book .reader-body .box-breath-phases { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#view-book .box-breath-phases li { padding: 8px; margin: 0; border: 1px solid #233d60; border-radius: 8px; font-size: 0.76rem; line-height: 1.5; color: #b3c5df; }
#view-book .box-breath-phases li.is-active { border-color: #60a5fa; background: #142d50; color: #dbeafe; }
.box-breath-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.box-breath-controls button { min-height: 44px; padding: 8px 12px; border-radius: 9px; border: 1px solid #3b82f6; background: #142d50; color: #dbeafe; font-family: inherit; font-weight: 600; cursor: pointer; }
.box-breath-controls button:disabled { opacity: 0.45; cursor: default; }
.box-breath-controls button:focus-visible, .mentorship-whatsapp-link:focus-visible { outline: 3px solid #93c5fd; outline-offset: 4px; }
#mentorship-contact { margin-top: 16px; }
#mentorship-contact p { font-size: 0.85rem; line-height: 1.7; margin-bottom: 12px; }
.mentorship-whatsapp-link { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; padding: 10px 14px; border: 1px solid #3b82f6; border-radius: 10px; background: #132b4c; color: #dbeafe; font-size: 0.85rem; font-weight: 600; line-height: 1.5; text-decoration: none; overflow-wrap: anywhere; }
@media (max-width: 600px) { #book-box-breathing { padding: 12px; } }
@media (prefers-reduced-motion: reduce) { #box-breath-dot { display: none; } }

/* Citas del libro: frase íntegra y atribución en un solo recuadro. */
#view-book .reader-body .book-quote {
  display: flex; flex-direction: column; box-sizing: border-box; min-width: 0; max-width: 100%;
  height: auto; margin: 20px 0; padding: 16px 20px; background: #0d1728;
  border: 0; border-left: 3px solid #3b82f6; border-radius: 0 8px 8px 0;
  overflow-wrap: anywhere; white-space: normal; color: #f1f5f9;
}
#view-book .reader-body .book-quote blockquote {
  order: 0; margin: 0; padding: 0; border: 0; background: none; font-style: italic;
}
#view-book .reader-body .book-quote figcaption {
  order: 1; margin-top: 12px; font-style: normal; color: #b3c5df; text-align: right;
}
#view-book .reader-body .book-quote blockquote p {
  margin: 0; font-size: var(--reader-font-size); line-height: 1.78; text-align: left;
}
#view-book .reader-body .book-quote figcaption p {
  margin: 0; font-size: calc(var(--reader-font-size) * 0.86); line-height: 1.6; text-align: right;
}
@media (max-width: 600px) { #view-book .reader-body .book-quote { padding: 14px 16px; } }
