/* Lectura adaptable: sin bloquear zoom y sin ocultar desbordamientos. */
html { scroll-padding-bottom: 100px; }
/* La navegación lateral/inferior sustituye la cabecera global en toda la app. */
.app-main > .topbar { display: none; }
.app-main > main { min-height: calc(100dvh - 68px); }
.app-main, main, .reader-panel, .feature-copy, .movement-card > div,
.journey-card > div, .profile-grid > *, .journal-grid > * { min-width: 0; }
h1, h2, h3, p, .chapter-link, .tag, .button { overflow-wrap: anywhere; }
.utility-link { display: inline-flex; align-items: center; min-height: 44px; font-size: .8rem; color: var(--green); }
.mobile-journey, .contents-toggle { display: none; }
.book-text { max-width: 70ch; margin-inline: auto; padding: clamp(24px, 4vw, 48px); }
.book-text p {
  line-height: 1.8;
  text-align: justify;
  text-align-last: start;
  hyphens: none;
  -webkit-hyphens: none;
  word-break: normal;
  overflow-wrap: normal;
}
.book-text h1 { font-size: clamp(1.65rem, 3vw, 2.2rem); }
.reader-toolbar { gap: 12px; }
.reader-toolbar > div { min-width: 0; }
.reader-toolbar .icon-button, .reader-toolbar .text-button { min-height: 44px; min-width: 44px; }
.reader-pagination { flex-wrap: wrap; }
.reader-pagination .button { white-space: normal; }
dialog { overscroll-behavior: contain; }
@media (max-width: 980px) {
  .contents-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 10px 14px; border: 0; background: var(--mint); border-radius: 8px; color: var(--green); text-align: left; }
  .contents-toggle > svg:last-child { margin-left: auto; transition: transform .15s; }
  .contents.is-open .contents-toggle > svg:last-child { transform: rotate(90deg); }
  .contents { padding: 12px !important; }
  .contents > .section-kicker, .contents > h2, .contents > .muted { display: none; }
  .contents > nav { display: none; }
  .contents.is-open > nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 12px; overflow: visible; }
  .chapter-link { width: 100%; min-width: 0; min-height: 48px; }
}
@media (max-width: 760px) {
  .mobile-journey { display: inline-flex; }
  .topbar { flex-wrap: wrap; padding-block: 10px; gap: 2px 14px; }
  .top-actions { flex-wrap: wrap; gap: 16px; }
  .work-badge { display: none; }
  main { padding-inline: max(16px, env(safe-area-inset-left)); padding-bottom: 30px; }
  .app-footer { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .reader-toolbar { align-items: flex-start; padding: 12px 16px; }
  .reader-toolbar > span { width: 100%; }
  .reader-toolbar > div { width: 100%; justify-content: space-between; gap: 4px; }
  .book-text { padding: 26px 20px; }
  .book-text p { margin-bottom: 1.2em; }
  .reader-pagination { padding: 16px; }
  .reader-pagination .button { flex: 1; padding-inline: 10px; min-height: 48px; }
  .reader-pagination > span { display: block; flex-basis: 100%; order: 3; text-align: center; }
  .reading-pause { padding: 18px; margin-inline: 12px; }
  .pause-actions > .button { width: 100%; }
  .filter-tabs { flex-wrap: wrap; }
  .filter-tab { min-height: 44px; }
  .theme-filter { min-width: 0; }
  .theme-filter select { max-width: 100%; min-height: 44px; font-size: 16px; }
  .exercise-header > div { min-width: 0; }
  .exercise-header h1 { font-size: clamp(1.65rem, 6vw, 2rem); }
  .movement-card > div { min-width: 0; }
  .result-next > .button { width: 100%; }
  .personal-note > div { min-width: 0; }
  dialog { max-height: calc(100dvh - 24px); padding: 24px 20px; }
  #toast { bottom: calc(82px + env(safe-area-inset-bottom)); width: calc(100% - 32px); max-width: 550px; }
}
@media (max-width: 420px) {
  .contents.is-open > nav { grid-template-columns: 1fr; }
  .reading-feature { flex-direction: column; align-items: flex-start; }
  .book-display { display: none; }
  .feature-copy h2 { font-size: clamp(1.7rem, 8vw, 2rem); }
  .diagnostic-intro h1 { font-size: clamp(2rem, 10vw, 2.9rem); }
  .question-card h1 { font-size: clamp(1.6rem, 7vw, 1.85rem); }
  .question-top { align-items: flex-start; }
  .question-top .text-button { min-height: 44px; }
  .movement-card { padding: 18px; gap: 12px; }
  .movement-card > div { width: calc(100% - 60px); }
  .journey-card { padding: 20px; gap: 12px; }
  .score-row > div { flex-wrap: wrap; }
  .reader-toolbar .text-button { font-size: .75rem; }
}
@media (max-height: 600px) and (min-width: 761px) {
  .sidebar { overflow-y: auto; padding-top: 16px; }
  .brand { padding-bottom: 16px; }
  .side-message { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .contents-toggle > svg:last-child { transition: none; }
}

/* Hoja editorial: sin altura fija ni recortes al ampliar la letra. */
.book-cover-page { width: 100%; max-width: 720px; margin-inline: auto; box-shadow: 0 8px 28px #302e2710; }
.book-cover-page img { display: block; width: 100%; height: auto; }
.front-matter p { margin: 0 0 .75em; text-indent: 0; white-space: normal; }
.front-matter .front-center { text-align: center; text-align-last: center; }
.front-matter .front-section-start { margin-top: 2em; }
.front-matter .front-legal-start { margin-top: 12em; }
.front-small { font-size: .82em; }
/* Títulos editoriales uniformes, sin modificar el manuscrito. */
.book-text, .book-text h1, .book-text h2, .book-text h3,
.book-text p, .book-text span, .book-text strong, .book-text em,
.book-continuation, .chapter-link > span {
  hyphens: none;
  -webkit-hyphens: none;
  word-break: normal;
  overflow-wrap: normal;
}
.contents { padding: 16px 12px; top: 12px; }
.contents > .section-kicker { display: none; }
.contents > h2 { font-size: 1.15rem; margin-top: 0; }
.contents > .muted { margin: 4px 9px 10px; font-size: .72rem; }
.contents > nav { overflow: visible; padding: 0; }
.contents .chapter-link {
  min-height: 44px; padding: 6px 8px; margin: 0;
  gap: 7px; font-size: .72rem; line-height: 1.25;
}
.contents .chapter-number { min-width: 16px; padding-top: 1px; }
.contents > .notice { display: none; }
@media (min-width: 981px) {
  .reader-layout { padding-top: 0; }
  .app-main:has(.reader-layout) > main { padding-top: 16px; }
}
@media (max-width: 980px) {
  .contents.is-open > nav { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; gap: 2px; }
  .contents .chapter-link { min-width: 0; width: 100%; min-height: 48px; }
}
.book-text h1, .book-text h2, .book-text h3,
.book-continuation, .contents h2, .chapter-link > span:last-child {
  text-transform: uppercase;
  font-weight: 700;
}
.reader-panel { background: transparent; border: 0; box-shadow: none; overflow: visible; }
.reader-toolbar { background: transparent; padding: 0; border: 0; min-height: 0; }
.book-text {
  display: flex; flex-direction: column;
  width: 100%; max-width: 720px; min-height: 900px;
  padding: clamp(28px, 5vw, 64px);
  background: var(--book-paper); color: var(--book-ink);
  border: 1px solid var(--book-line); border-radius: 2px;
  box-shadow: 0 8px 28px #302e2710, 4px 4px 0 #eee8dc, 6px 6px 0 #e5dfd1;
}
.book-running-head { text-align: center; font: small-caps .8rem/1.5 Georgia, serif; letter-spacing: .08em; margin-bottom: 48px; color: #777063; }
.book-continuation { text-align: center; font: small-caps .85rem/1.5 Georgia, serif; margin-bottom: 28px; color: #777063; }
.book-text h1 { margin-block: 16px 32px; }
.book-text .book-page-body p { line-height: 1.65; margin: 0; }
.book-page-body p + p { text-indent: 1.4em; }
.book-page-body h3 { margin-block: 24px 12px; }
.book-page-number { margin-top: auto; padding-top: 40px; text-align: center; font: 1.1rem/1.5 Georgia, serif; font-variant-numeric: lining-nums; }
.reader-pagination { max-width: 720px; margin-inline: auto; padding-inline: 0; }
/* Paleta inferior disponible al desplazarse, sin cabecera fija. */
.reader-toolbar > .reader-tools {
  position: fixed; right: max(24px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom)); z-index: 24;
  display: flex; align-items: center; gap: 8px;
  width: auto; padding: 6px 12px;
  background: #fffdf7f5; border: 1px solid #ded8cb; border-radius: 16px;
  box-shadow: 0 4px 20px #302e2720; backdrop-filter: blur(12px);
}
.reader-tools .text-button { padding-inline: 8px; }
.app-main:has(.reader-layout) > main { padding-bottom: 110px; }
body:has(.reader-layout) #toast { bottom: 96px; }
@media (max-width: 760px) {
  .reader-toolbar > .reader-tools {
    left: max(16px, env(safe-area-inset-left)); right: max(16px, env(safe-area-inset-right));
    bottom: calc(82px + env(safe-area-inset-bottom));
    width: auto; justify-content: space-between; gap: 2px; padding: 6px 8px;
  }
  .reader-tools .text-button { font-size: .75rem; padding-inline: 4px; }
  .app-main:has(.reader-layout) > main { padding-bottom: 90px; }
  body:has(.reader-layout) #toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
  .book-text { min-height: 75dvh; padding: 30px 22px 24px; }
  .book-running-head { margin-bottom: 32px; font-size: .72rem; }
  .book-text h1 { font-size: 1.65rem; }
  .book-page-number { padding-top: 32px; }
}

/* El menú fijo debe poder desplazarse cuando la altura de tablet no alcance. */
@media (min-width: 761px) {
  .sidebar {
    bottom: auto;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #cbd6cc transparent;
    padding-bottom: max(21px, env(safe-area-inset-bottom));
  }
  .brand, .side-group, .side-bottom { flex-shrink: 0; }
  .profile-link span { min-width: 0; overflow-wrap: anywhere; }
  .admin-sidebar-link { display: flex; align-items: center; min-height: 44px; }
}

@media (min-width: 761px) and (max-width: 1200px) and (max-height: 850px) {
  .sidebar { padding-top: 18px; }
  .brand { padding-bottom: 15px; }
  .side-group { margin: 3px 0 10px; }
  .nav-caption { margin-top: 8px; margin-bottom: 8px; }
  .side-message { display: none; }
  .profile-link { padding-top: 12px; }
}

/* Inicio ocupa una pantalla; en zoom o alturas excepcionalmente bajas conserva desplazamiento accesible. */
.app-main:has(.home-screen) > main {
  display: flex;
  height: 100dvh;
  min-height: 0;
  overflow-y: auto;
  padding-block: clamp(18px, 3vh, 34px);
}
.home-screen {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.8vh, 18px);
  width: 100%;
  min-height: 0;
}
.home-screen .page-heading { margin: 0; }
.home-screen .page-heading h1 { font-size: clamp(1.85rem, 3.2vw, 2.7rem); margin: 4px 0 5px; }
.home-screen .page-heading p { line-height: 1.4; }
.home-screen .home-grid { min-height: 0; }
.home-screen .reading-feature { height: 100%; min-height: 0; padding: clamp(20px, 2.6vw, 34px); }
.home-screen .feature-copy h2 { margin: 10px 0 9px; }
.home-screen .feature-copy .button { margin-top: 14px; }
.home-screen .compass-card { min-height: 0; padding: clamp(18px, 2.3vw, 28px); }
.home-screen .compass-card .section-kicker { margin-bottom: 10px; }
.home-screen .compass-card p { margin: 7px 0 10px; line-height: 1.45; }
.home-screen .mini-bars { margin-bottom: 5px; }
.home-screen .mini-row { margin: 5px 0; }
.home-actions .section-heading { margin: 0 0 8px; }
.home-actions .section-heading h2 { font-size: 1.35rem; }
.home-actions .journey-grid { gap: 12px; }
.home-actions .journey-card { padding: 12px 16px; gap: 12px; align-items: center; }
.home-actions .tile-icon { width: 36px; height: 36px; }
.home-actions .journey-card h3 { font-size: 1.12rem; margin: 3px 0 2px; }
.home-actions .journey-card p { font-size: .75rem; line-height: 1.3; }
.home-actions .tile-foot { margin-top: 5px; }
@media (max-width: 980px) {
  .home-screen .home-grid { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; gap: 10px; }
  .home-screen .book-display, .home-screen .compass-mark, .home-screen .focus-icon,
  .home-screen .mini-bars, .home-screen .compass-card .quiet-line { display: none; }
  .home-screen .compass-card { display: block; }
  .home-screen .compass-card .section-kicker { margin-bottom: 4px; }
  .home-screen .compass-card h2 { font-size: 1.4rem; }
  .home-screen .compass-card p { margin: 4px 0 7px; }
  .home-actions .journey-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .app-main:has(.home-screen) > main {
    height: calc(100dvh - 68px - env(safe-area-inset-bottom));
    padding: 12px max(16px, env(safe-area-inset-left)) 8px max(16px, env(safe-area-inset-right));
  }
  .home-screen { gap: 8px; }
  .home-screen .page-heading { display: block; }
  .home-screen .page-heading h1 { font-size: clamp(1.45rem, 5.5vw, 1.8rem); margin: 3px 0; line-height: 1.08; }
  .home-screen .page-heading p { font-size: .78rem; line-height: 1.3; }
  .home-screen .reading-feature { padding: 15px 17px; }
  .home-screen .feature-copy h2 { font-size: clamp(1.42rem, 5.5vw, 1.8rem); line-height: 1.1; margin: 7px 0; }
  .home-screen .feature-copy p { font-size: .75rem; line-height: 1.4; }
  .home-screen .feature-copy .button { margin-top: 10px; min-height: 44px; }
  .home-screen .compass-card { padding: 13px 17px; }
  .home-screen .compass-card h2 { font-size: 1.25rem; }
  .home-screen .compass-card p, .home-screen .compass-card .fine { display: none; }
  .home-screen .compass-card .button, .home-screen .compass-card .text-link { min-height: 44px; margin-top: 4px; }
  .home-actions .section-heading { margin-bottom: 5px; }
  .home-actions .section-heading h2 { font-size: 1.1rem; }
  .home-actions .journey-grid { gap: 8px; }
  .home-actions .journey-card { padding: 10px; gap: 7px; min-height: 68px; }
  .home-actions .tile-icon { width: 30px; height: 30px; }
  .home-actions .tile-icon svg { width: 17px; height: 17px; }
  .home-actions .journey-card h3 { font-size: .9rem; line-height: 1.2; margin: 0; }
  .home-actions .journey-card .section-kicker, .home-actions .journey-card p, .home-actions .tile-foot { display: none; }
}
@media (max-height: 700px) {
  .home-screen .feature-copy p,
  .home-screen .compass-card p, .home-screen .mini-bars,
  .home-actions .journey-card p, .home-actions .tile-foot { display: none; }
  .home-screen .reading-feature { padding-block: 14px; }
  .home-screen .compass-card { padding-block: 12px; }
}
@media (max-width: 760px) and (max-height: 620px) {
  .home-screen .page-heading p { display: none; }
  .home-screen .feature-copy h2 { font-size: 1.35rem; }
  .home-screen .reading-feature, .home-screen .compass-card { padding-block: 10px; }
  .home-screen .compass-card h2 { font-size: 1.12rem; }
  .home-actions .section-heading { display: none; }
}
