/* =============================================================================
   SITE CSS — TABLE OF CONTENTS
   1. Tokens / base document
   2. Picture-book pages (quiet-stories / tall-tales)
   3. Site chrome (header, nav drawer, icon buttons, download dialog)
   4. Shared prose (links, print defaults)
   5. English overlay rules (baked cover/chapter text)
   6. Article pages (about / rules)
   7. Home
   8. book-text.html (text layout + all-langs print pack)
   9. book-text.html screen UI (marker toggles + Print Options dialog)
   ============================================================================= */

/* --- 1. Tokens / base document --- */


  :root { color-scheme: light; }


  * { box-sizing: border-box; }


  html, body { margin: 0; padding: 0; background: #efe7d8; }



  html { scroll-padding-top: max(5rem, env(safe-area-inset-top) + 4rem); }


  .site-link:focus-visible,
  .seelink:focus-visible,
  a:focus-visible,
  button:focus-visible,
  select:focus-visible {
    outline: 2px solid #1b1108;
    outline-offset: 3px;
  }



  body { font-family: "Nunito", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }


  h1, h2, h3 { font-family: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif; font-optical-sizing: auto; font-weight: 600; letter-spacing: 0.01em; }


  .book {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6vw;
    padding: 0.6vw;
  }


  .page {
    position: relative;
    line-height: 0;
    background: #efe7d8;
    overflow: hidden;
  }


  .page .page-num {
      position: absolute;
      left: 0; right: 0; top: 0;
      z-index: 2;
      padding: 4% 7% 6%;
      text-align: center;
      line-height: 1.25;
      font-size: clamp(0.7rem, 1.4vw, 1.3rem);
      color: #1b1108;
      text-shadow: 0 0 4px rgba(255,255,255,0.95), 0 0 9px rgba(255,255,255,0.85), 0 1px 3px rgba(40,30,20,0.4);
  }


  .page img {
    width: 100%;
    height: auto;
    display: block;
  }


  .page p {
    padding: 0;
    margin: 0;
  }


  .book-single {
      display: block;
      padding: 0.6vw;
  }


  .book-single .page img {
      width: 96vw;
      margin: 0 auto;
      aspect-ratio: initial;
  }


  .book-single .page video {
      display: block;
      max-height: 96vh;
      max-width: 96vw;
      width: auto;
      margin: 0 auto;
  }


  /* --- 2. Picture-book pages --- */
  /* Cover: hide static img while video is present; show when no video */
  .page:has(#cover-video) .cover-img { display: none; }


  /* Cover title overlay (screen only; printed JPG keeps its own baked text) */
  .book.cover > .page:first-child {
      display: flex;
      align-items: center;
      justify-content: center;
  }


  .book.cover > .page:first-child > video {
      display: block;
      width: 100%;
      height: auto;
  }


  .book.cover > .page:first-child > .cardtext { position: absolute; left: 0; right: 0; top: 0; bottom: 30%; z-index: 3; display: flex; flex-direction: column; justify-content: center; padding: 4% 10%; line-height: 0.75; color: #1b1108; text-shadow: 0 0 4px rgba(255,255,255,0.95), 0 0 9px rgba(255,255,255,0.85), 0 1px 3px rgba(40,30,20,0.4); }


  /* Chapter title page overlays sit over the upper image area */
  .chapter-title {
      position: absolute;
      left: 0; right: 0; top: 6%;
      z-index: 2;
      text-align: center;
      padding: 4% 8% 0;
      pointer-events: none;
      line-height: 1.3;
      color: #1b1108;
      text-shadow: 0 0 4px rgba(255,255,255,0.95), 0 0 9px rgba(255,255,255,0.85), 0 1px 3px rgba(40,30,20,0.4);
  }


  .chapter-title.bottom {
      top: auto;
      bottom: 6%;
      padding: 0 8% 4%;
  }


  .chapter-title h2 { font-size: clamp(1.1rem, 2.4vw, 2.2rem); margin: 0 0 0.3em; }


  .chapter-title p { font-size: clamp(0.8rem, 1.6vw, 1.4rem); margin: 0; }


  .caption {
    position: absolute;
    left: 0; right: 0;
    bottom: 5%;
    z-index: 1;
    padding: 4% 7% 6%;
    text-align: center;
    line-height: 1.25;
    font-size: clamp(0.7rem, 1.4vw, 1.3rem);
    color: #1b1108;
    text-shadow: 0 0 4px rgba(255,255,255,0.95), 0 0 9px rgba(255,255,255,0.85), 0 1px 3px rgba(40,30,20,0.4);
  }


  .caption hr {
      width: 40px;
      border: none; color: transparent;
      border-top: 3px dotted rgba(150,140,120,0.8);
  }


  .textpage {
    background: #fbf4e6;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
  }


  .cardtext {
    line-height: 1.5;
    text-align: center;
    padding: 8% 10%;
    font-size: clamp(0.7rem, 1.4vw, 1.3rem);
    color: #3a2f22;
  }


  .cardtext hr {
      width: 40px;
      border: none; color: transparent;
      border-top: 3px dotted rgba(150,140,120,0.8);
  }


  .cardtext strong { font-size: 1.15em; }


  @media (max-width: 1024px) {
    .book { grid-template-columns: 1fr; }
    .textpage { min-height: 30vh; }
  }



  @media (max-width: 720px) {
    .caption, .page .page-num, .cardtext {
      font-size: clamp(0.9rem, 3.6vw, 1.15rem);
    }
    .chapter-title h2 { font-size: clamp(1.05rem, 5vw, 1.6rem); }
    .chapter-title p { font-size: clamp(0.85rem, 3.8vw, 1.2rem); }
    .book, .book-single { padding: 0.4rem; gap: 0.5rem; }
    .book-single .page img { width: 100%; }
    .book-single .page video {
      max-height: min(85vh, calc(100dvh - 5rem));
      max-width: 100%;
    }
  }





  /* --- 3. Site chrome --- */
  .site-chrome {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem clamp(0.8rem, 3vw, 2rem);
    padding-top: max(0.45rem, env(safe-area-inset-top));
    padding-left: max(clamp(0.8rem, 3vw, 2rem), env(safe-area-inset-left));
    padding-right: max(clamp(0.8rem, 3vw, 2rem), env(safe-area-inset-right));
    background: rgba(239,231,216,0.97);
    border-bottom: 1px solid rgba(150,140,120,0.45);
    font-family: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  }


  .site-chrome .site-header {
    position: static;
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0;
    background: transparent;
    border: none;
    overflow: visible;
  }



  .site-header {
    /* layout provided by .site-chrome */
  }


  .site-title {
    font-family: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1b1108;
    letter-spacing: 0.01em;
    min-width: 0;
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }


  .nav-toggle, .nav-close {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: #1b1108;
    background: rgba(107,98,86,0.12);
    border: 1px solid rgba(150,140,120,0.45);
    border-radius: 999px;
    padding: 0.45rem 0.95rem;
    min-height: 2.5rem;
    cursor: pointer;
    flex: 0 0 auto;
  }


  .nav-toggle:hover, .nav-close:hover {
    background: rgba(107,98,86,0.22);
    border-color: #6b6256;
  }


  .nav-close { align-self: flex-end; }


  .nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(27,17,8,0.35);
  }


  body.nav-open .nav-backdrop { display: block; }


  body.nav-open { overflow: hidden; }



  /* When site.js mounts drawer on body (mobile), keep full-viewport overlay */
  body > .site-drawer {
    z-index: 200;
  }


  body > .nav-backdrop {
    z-index: 150;
  }



  .site-drawer {
    display: flex;
    align-items: center;
  }


  .site-nav {
    display: flex;
    gap: 0.65rem 0.85rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
  }


  .nav-utils {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
  }


  .nav-clusters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem 0.9rem;
    align-items: center;
    padding-left: 0.75rem;
    border-left: 1px solid rgba(150,140,120,0.45);
  }


  .nav-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
  }


  .nav-group + .nav-group {
    padding-left: 0.75rem;
    border-left: 1px solid rgba(150,140,120,0.45);
  }


  .nav-group-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
  }


  .site-link {
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    color: #6b6256;
    background: rgba(107,98,86,0.10);
    border: 1px solid rgba(150,140,120,0.45);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    min-height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
    cursor: pointer;
    font-family: inherit;
  }


  .site-link:hover { background: rgba(107,98,86,0.22); border-color: #6b6256; color: #1b1108; }


  .site-link.active {
    cursor: default;
    color: #1b1108;
    background: rgba(107,98,86,0.30);
    border-color: #6b6256;
    font-weight: 700;
  }


  .site-link.active:hover { background: rgba(107,98,86,0.30); border-color: #6b6256; color: #1b1108; }


  /* Icon buttons (Print / Download): compact width with hover tooltip */
  .icon-btn {
    position: relative;
    width: 2.5rem;
    padding-left: 0;
    padding-right: 0;
    gap: 0.4rem;
  }


  .icon-btn-glyph {
    width: 1.15em;
    height: 1.15em;
    flex: none;
  }


  .icon-btn-label {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: #2a2018;
    color: #f7f0e2;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.25rem 0.55rem;
    border-radius: 0.4rem;
    box-shadow: 0 4px 14px rgba(40,30,20,0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity .12s ease;
    z-index: 5;
  }


  .icon-btn-label::after {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: #2a2018;
  }


  .icon-btn:hover .icon-btn-label,
  .icon-btn:focus-visible .icon-btn-label { opacity: 1; }


  /* Download confirmation dialog */
  .site-dialog {
    border: 1px solid rgba(150,140,120,0.55);
    border-radius: 0.9rem;
    background: #f7f0e2;
    color: #3a2f22;
    padding: 1.4rem 1.5rem 1.2rem;
    max-width: min(28rem, 92vw);
    box-shadow: 0 18px 50px rgba(40,30,20,0.30);
  }


  .site-dialog::backdrop {
    background: rgba(28,20,12,0.42);
    backdrop-filter: blur(1px);
  }


  .site-dialog h2 {
    margin: 0 0 0.6rem;
    font-size: 1.15rem;
    color: #1b1108;
  }


  .site-dialog p {
    margin: 0 0 1.1rem;
    line-height: 1.5;
    font-size: 0.95rem;
  }


  .site-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
  }


  .site-dialog-actions .site-link {
    min-height: 2.4rem;
    padding: 0.35rem 1.1rem;
  }


  .site-dialog-status {
    margin: 0 0 1.1rem;
    min-height: 1.2rem;
    font-size: 0.9rem;
    font-style: italic;
    color: #6b6256;
  }


  #lang-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 1.4rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b6256' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.6rem center;
  }


  /* Desktop: horizontal nav, no toggle */
  .nav-toggle { display: none; }


  .nav-close { display: none; }


  @media (max-width: 1100px) {
    .nav-toggle { display: inline-flex; align-items: center; }
    .site-drawer {
      display: none;
      position: fixed;
      top: 0;
      right: 0;
      bottom: 0;
      left: auto;
      z-index: 200;
      width: min(22rem, 90vw);
      max-width: 100vw;
      height: 100%;
      max-height: 100dvh;
      margin: 0;
      flex-direction: column;
      align-items: stretch;
      gap: 0.75rem;
      padding: max(0.75rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
      padding-right: max(1rem, env(safe-area-inset-right));
      background: #f7f0e2;
      border-left: 1px solid rgba(150,140,120,0.45);
      box-shadow: -8px 0 28px rgba(40,30,20,0.18);
      overflow-x: hidden;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }
    body.nav-open .site-drawer { display: flex; }
    .nav-close { display: inline-flex; align-items: center; }
    .site-nav {
      flex-direction: column;
      align-items: stretch;
      justify-content: flex-start;
      gap: 0.85rem;
    }
    .nav-utils {
      flex-direction: column;
      align-items: stretch;
      gap: 0.45rem;
    }
    .nav-clusters {
      flex-direction: column;
      align-items: stretch;
      gap: 0.85rem;
      padding-left: 0;
      border-left: none;
      padding-top: 0.75rem;
      border-top: 1px solid rgba(150,140,120,0.35);
    }
    .nav-group {
      flex-direction: column;
      align-items: stretch;
      gap: 0.4rem;
    }
    .nav-group + .nav-group {
      padding-left: 0;
      border-left: none;
      padding-top: 0.75rem;
      border-top: 1px solid rgba(150,140,120,0.35);
    }
    .nav-group-links {
      flex-direction: column;
      align-items: stretch;
      gap: 0.4rem;
    }
    .site-drawer .site-link,
    .site-drawer #lang-select,
    .site-drawer .nav-close {
      width: 100%;
      justify-content: center;
      min-height: 2.75rem;
      font-size: 1rem;
      box-sizing: border-box;
    }
    .site-drawer .icon-btn {
      width: 100%;
      justify-content: center;
      padding-left: 0.9rem;
      padding-right: 0.9rem;
    }
    .site-drawer .icon-btn-label {
      position: static;
      transform: none;
      opacity: 1;
      pointer-events: auto;
      background: none;
      color: inherit;
      font-size: 1rem;
      font-weight: 600;
      padding: 0;
      box-shadow: none;
    }
    .site-drawer .icon-btn-label::after { display: none; }
  }



  @media (max-width: 1100px) {
    html[dir="rtl"] .site-drawer {
      right: auto;
      left: 0;
      border-left: none;
      border-right: 1px solid rgba(150,140,120,0.45);
      box-shadow: 8px 0 28px rgba(40,30,20,0.18);
    }
    html[dir="rtl"] .nav-group + .nav-group {
      border-left: none;
    }
  }




  /* --- 4. Shared prose helpers --- */
  /* Inline see-also links: dark, slightly off-color, wrap-friendly */
  .seelink {
    color: #4a3a26;
    text-decoration: underline;
    text-decoration-color: rgba(107,98,86,0.55);
    text-underline-offset: 0.18em;
    transition: color .15s ease, text-decoration-color .15s ease;
  }


  .seelink:hover {
    color: #1b1108;
    text-decoration-color: var(--stone);
  }



  @media print {
    html, body { background: #efe7d8; }
    body, .page, .textpage, .card {
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
    }
    .site-chrome, .site-header { display: none !important; }
    .book { grid-template-columns: 1fr 1fr; gap: 0; padding: 0; }
    .book > .page {
      overflow: hidden;
      break-inside: avoid;
      page-break-inside: avoid;
    }
    .book > .page:nth-child(even) {
      break-after: page;
      page-break-after: page;
    }
    .page img { width: 100%; height: auto; display: block; transform: none !important; }
    .page img.ph,
    .page img.img-ph {
      min-height: 0;
      aspect-ratio: auto;
      object-fit: fill;
      background: none;
    }
    .img-ph-alt { display: none !important; }
    /* Keep overlay type as real text (no compositing that rasterizes print PDFs). */
    .caption, .page-num, .chapter-title, .cardtext {
      text-shadow: none;
      filter: none !important;
      transform: none !important;
      opacity: 1 !important;
      backdrop-filter: none !important;
      -webkit-backdrop-filter: none !important;
      mix-blend-mode: normal !important;
    }
    .book-single {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 11in;
      height: 8.5in;
      padding: 0;
      break-after: page;
      page-break-after: always;
    }
    .book-single:last-child {
      break-after: auto;
      page-break-after: auto;
    }
    .book-single .page {
      width: 100%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .book-single .page img {
      max-width: 100%;
      max-height: 100%;
      width: auto;
      height: auto;
      object-fit: contain;
    }
    .book-single .page video,
    .book.cover video,
    #cover-video { display: none; }
    .cover-img { display: block !important; }
    .textpage { min-height: 0; }
  }


  .caption .phon {
      font-size: 0.75em;
      font-style: italic;
      opacity: 0.7;
  }


  /* --- 5. English overlay / a11y rules --- */
  /* Hide new overlays for English on index.html (baked-in image text is used instead) */
  html[data-lang="en"] body.page-book .book.cover > .page:first-child > .cardtext { display: none !important; }


  /* EN chapter titles stay in a11y tree on index.html (baked into image for sighted) */
  html[data-lang="en"] body.page-book .chapter-title {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    pointer-events: none;
  }



  .img-desc-btn {
    position: absolute;
    top: 0.55rem;
    inset-inline-end: 0.55rem;
    z-index: 6;
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(27, 17, 8, 0.28);
    border-radius: 999px;
    background: rgba(251, 244, 230, 0.82);
    color: #3a2f22;
    box-shadow: 0 1px 4px rgba(40, 30, 20, 0.18);
    cursor: pointer;
    opacity: 0.78;
    transition: opacity 0.15s ease, background 0.15s ease;
  }


  .img-desc-btn:hover,
  .img-desc-btn:focus-visible,
  .page.img-desc-open .img-desc-btn {
    opacity: 1;
    background: rgba(251, 244, 230, 0.96);
  }


  .img-desc-btn svg { display: block; }


  .img-desc-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 25%;
    z-index: 5;
    box-sizing: border-box;
    padding: 2.5rem 1rem 0.65rem;
    overflow: auto;
    line-height: 1.3;
    font-size: clamp(0.7rem, 1.35vw, 0.95rem);
    text-align: center;
    color: #fbf4e6;
    background: rgba(27, 17, 8, 0.58);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
  }


  .img-desc-btn:hover + .img-desc-panel,
  .img-desc-btn:focus-visible + .img-desc-panel,
  .page.img-desc-open .img-desc-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }


  .img-ph-alt {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4;
    box-sizing: border-box;
    padding: 0.7rem 2.75rem 0.7rem 0.9rem;
    line-height: 1.3;
    font-size: clamp(0.7rem, 1.35vw, 0.95rem);
    text-align: center;
    color: #3a2f22;
    background: linear-gradient(180deg, rgba(251, 244, 230, 0.96) 0%, rgba(239, 231, 216, 0.9) 100%);
    border-bottom: 1px solid rgba(150, 140, 120, 0.45);
    pointer-events: none;
  }


  .page.img-missing .img-ph-alt { display: block; }


  .page img.img-ph,
  .page img.ph {
    aspect-ratio: 1650 / 2550;
    object-fit: cover;
    background: linear-gradient(180deg, #e8e0d0 0%, #d9d0bc 45%, #efe7d8 100%);
    min-height: 40vh;
  }


  @media print {
    .img-desc-btn,
    .img-desc-panel { display: none !important; }
  }


  :root {
    color-scheme: light;
    --paper: #efe7d8;
    --slab: #fbf4e6;
    --slab-tint: #f3ead8;
    --ink: #1b1108;
    --ink-soft: #3a2f22;
    --stone: #6b6256;
    --line: rgba(150,140,120,0.45);
    --dot: rgba(150,140,120,0.85);
    --shadow: 0 1px 2px rgba(60,46,30,0.10), 0 6px 18px rgba(60,46,30,0.10);
    --shadow-lift: 0 2px 4px rgba(60,46,30,0.14), 0 14px 34px rgba(60,46,30,0.16);
  }


  html, body { margin: 0; padding: 0; background: var(--paper); }


  body {
    font-family: "Nunito", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    color: var(--ink);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }


  h1, h2, h3, .site-title, .rule .num {
    font-family: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
    font-optical-sizing: auto;
  }


  h1, h2, h3 { font-weight: 600; letter-spacing: 0.01em; }


  .hero h1 { font-weight: 600; letter-spacing: 0.005em; }


  .rule .num { font-weight: 700; }



  .wrap { max-width: 1180px; margin: 0 auto; padding: clamp(1rem, 3vw, 2.6rem); }



  .board {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: clamp(0.7rem, 1.4vw, 1.2rem);
    align-items: stretch;
  }



  .card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--slab);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: clamp(1.1rem, 2vw, 1.9rem);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease;
  }


  .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }



  .span12 { grid-column: span 12; }


  .span7  { grid-column: span 7; }


  .span5  { grid-column: span 5; }


  .span8  { grid-column: span 8; }


  .span4  { grid-column: span 4; }


  .span6  { grid-column: span 6; }



  /* --- 6–7. Article pages + home --- */
  /* Hero */
  .hero { text-align: center; padding: clamp(1.8rem, 4vw, 3.2rem) clamp(1rem,4vw,2.5rem); }


  .hero h1 {
    margin: 0;
    font-size: clamp(1.7rem, 4.4vw, 3rem);
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.12;
  }


  .hero .essence {
    margin: 1rem auto 0;
    max-width: 38ch;
    font-style: italic;
    color: var(--ink-soft);
    font-size: clamp(0.95rem, 1.7vw, 1.2rem);
  }


  .hero .dotrule {
    width: 120px; margin: 1.4rem auto 0;
    border: none; border-top: 3px dotted var(--dot);
  }



  /* Section headings inside cards */
  h2 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.15rem, 2.2vw, 1.55rem);
    font-weight: 600;
    letter-spacing: 0.01em;
  }


  h3 {
    margin: 0 0 0.4rem;
    font-size: clamp(1.05rem, 1.8vw, 1.3rem);
    font-weight: 600;
  }


  p { margin: 0 0 0.85rem; }


  p:last-child { margin-bottom: 0; }


  strong { font-weight: 600; }



  .tint { background: var(--slab-tint); }



  blockquote {
    margin: 0 0 0.9rem;
    padding: 0.85rem 1.1rem;
    background: rgba(107,98,86,0.07);
    border-left: 3px solid var(--stone);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: var(--ink-soft);
  }


  blockquote p { margin: 0 0 0.5rem; }


  blockquote p:last-child { margin-bottom: 0; }



  /* Cluster tags */
  .tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: auto; padding-top: 1rem; padding-right: 3.5rem; position: relative; z-index: 2; }


  .tag {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--stone);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.18rem 0.6rem;
    background: rgba(255,255,255,0.35);
  }



  /* Rule cards */
  .rule .num {
    position: absolute;
    right: 0.5rem;
    bottom: -0.6rem;
    font-size: clamp(4.5rem, 11vw, 9rem);
    font-weight: 700;
    line-height: 1;
    color: rgba(107,98,86,0.12);
    pointer-events: none;
    user-select: none;
  }


  .rule .rule-title {
    position: relative;
    font-size: clamp(1.2rem, 2.3vw, 1.7rem);
    font-weight: 600;
    margin: 0 0 0.6rem;
    padding-right: 3.5rem;
    z-index: 1;
  }


  .rule p { position: relative; z-index: 1; }


  .rule.feature { background: var(--slab-tint); }



  .chip {
    font-family: "SFMono-Regular", ui-monospace, "Menlo", Consolas, monospace;
    font-size: 0.82em;
    color: var(--stone);
    background: rgba(107,98,86,0.10);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.05em 0.38em;
    white-space: nowrap;
  }


  a.chip { text-decoration: none; transition: background .15s ease, border-color .15s ease, color .15s ease; }


  a.chip:hover {
    background: rgba(107,98,86,0.22);
    border-color: var(--stone);
    color: var(--ink);
  }



  .closing { text-align: center; }


  .closing p { max-width: 56ch; margin-left: auto; margin-right: auto; }


  .closing .big {
    font-size: clamp(1.15rem, 2.4vw, 1.6rem);
    font-style: italic;
    color: var(--ink-soft);
  }


  .closing .final {
    margin-top: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
  }



  .footnote { text-align:center; color: var(--stone); font-size: 0.8rem; margin-top: 1.6rem; }



  /* Two-column reading layout inside a wide card */
  .twocol {
    column-count: 2;
    column-gap: clamp(1.2rem, 2.4vw, 2.2rem);
    column-rule: 1px solid var(--line);
    margin-top: 0.4rem;
  }


  .twocol p { margin: 0 0 0.85rem; break-inside: avoid; }


  .twocol p:last-child { margin-bottom: 0; }



  @media (max-width: 860px) {
    .twocol { column-count: 1; column-rule: none; }
    .board { grid-template-columns: 1fr; }
    .span12, .span7, .span5, .span8, .span4, .span6 { grid-column: span 1; }
    .rule .num { font-size: 5rem; }
  }


  @media print {
    html, body { background: #fff; }
    .site-chrome, .site-header { display: none !important; }
    .wrap { max-width: none; margin: 0; padding: 0; }
    .board { grid-template-columns: repeat(12, 1fr); gap: 0.4rem; }
    .span12 { grid-column: span 12; }
    .span7  { grid-column: span 7; }
    .span5  { grid-column: span 5; }
    .span8  { grid-column: span 8; }
    .span4  { grid-column: span 4; }
    .span6  { grid-column: span 6; }
.card {
       background: none !important;
       box-shadow: none !important;
       border-color: #6b6256;
       color: #000;
       -webkit-print-color-adjust: exact;
       print-color-adjust: exact;
       break-inside: avoid;
       page-break-inside: avoid;
     }
    .card * { color: #000 !important; }
    .tint, .rule.feature { background: none !important; }
  }



  @media (max-width: 860px) {
    .board { grid-template-columns: 1fr; }
    .span12, .span7, .span5, .span8, .span4, .span6 { grid-column: span 1; }
    .rule .num { font-size: 5rem; }
  }


  /* --- 6b. A Mending Place (long-form guide) --- */
  .guide-wrap {
    max-width: 1180px;
  }


  .guide-hero {
    text-align: center;
    padding: clamp(1.4rem, 3.5vw, 2.6rem) clamp(0.6rem, 2vw, 1.5rem) 0.4rem;
  }


  .guide-hero h1 {
    margin: 0;
    font-size: clamp(1.85rem, 4.6vw, 3.1rem);
    line-height: 1.12;
  }


  .guide-subtitle {
    margin: 0.55rem 0 0;
    font-style: italic;
    color: var(--ink-soft);
    font-size: clamp(1.05rem, 2vw, 1.35rem);
  }


  .guide-meta,
  .guide-companions {
    margin: 0.75rem auto 0;
    max-width: 52ch;
    color: var(--stone);
    font-size: 0.95rem;
    line-height: 1.45;
  }


  .guide-hero .dotrule {
    width: 120px;
    margin: 1.3rem auto 0;
    border: none;
    border-top: 3px dotted var(--dot);
  }


  .guide-layout {
    display: grid;
    grid-template-columns: minmax(12rem, 16rem) minmax(0, 1fr);
    gap: clamp(1rem, 2.5vw, 2.2rem);
    align-items: start;
    margin-top: 1.4rem;
  }


  .guide-toc {
    position: sticky;
    top: 4.5rem;
    max-height: calc(100vh - 5.5rem);
    overflow: auto;
    padding: 0.9rem 1rem 1.1rem;
    background: var(--slab);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
  }


  .guide-toc h2 {
    margin: 0 0 0.65rem;
    font-size: 1rem;
  }


  .guide-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
  }


  .guide-toc-list a {
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.88rem;
    line-height: 1.3;
    font-weight: 600;
  }


  .guide-toc-list a:hover {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 0.15em;
  }


  .guide-toc-list a.is-active {
    color: var(--ink);
    background: rgba(107, 98, 86, 0.12);
    box-shadow: inset 3px 0 0 var(--stone);
    border-radius: 4px;
    padding: 0.12rem 0.35rem 0.12rem 0.45rem;
    margin-left: -0.45rem;
  }


  .guide-toc-list .toc-sub {
    padding-left: 0.85rem;
  }


  .guide-toc-list .toc-sub a {
    font-weight: 500;
    font-size: 0.82rem;
  }


  .guide-toc-list .toc-sub a.is-active {
    font-weight: 600;
  }


  .guide-body {
    background: var(--slab);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: clamp(1.2rem, 2.4vw, 2.1rem);
    color: var(--ink);
    line-height: 1.55;
    font-size: clamp(0.98rem, 1.15vw, 1.08rem);
  }


  .guide-body > h1 {
    margin: 1.6rem 0 0.35rem;
    font-size: clamp(1.45rem, 2.6vw, 1.9rem);
    scroll-margin-top: 5rem;
  }


  .guide-body > h1:first-child,
  .guide-body > h2:first-child {
    margin-top: 0;
  }


  .guide-body > h2 {
    margin: 1.35rem 0 0.45rem;
    font-size: clamp(1.2rem, 2.1vw, 1.5rem);
    scroll-margin-top: 5rem;
  }


  .guide-body > h2.part-subtitle {
    margin-top: 0.15rem;
    margin-bottom: 0.85rem;
    font-weight: 500;
    font-style: italic;
    color: var(--ink-soft);
    font-size: clamp(1.05rem, 1.8vw, 1.3rem);
  }


  .guide-body > h3 {
    margin: 1.2rem 0 0.4rem;
    font-size: clamp(1.05rem, 1.7vw, 1.25rem);
    scroll-margin-top: 5rem;
  }


  .guide-body > h4 {
    margin: 1rem 0 0.35rem;
    font-size: clamp(0.98rem, 1.4vw, 1.1rem);
    font-weight: 600;
    color: var(--ink-soft);
    scroll-margin-top: 5rem;
  }


  .guide-body p {
    margin: 0 0 0.85rem;
  }


  .guide-body p:last-child {
    margin-bottom: 0;
  }


  .guide-subhead {
    margin: -0.15rem 0 0.9rem !important;
    color: var(--ink-soft);
  }


  .guide-body ul,
  .guide-body ol {
    margin: 0 0 0.95rem;
    padding-left: 1.35rem;
  }


  .guide-body li {
    margin: 0 0 0.35rem;
  }


  .guide-body li:last-child {
    margin-bottom: 0;
  }


  .guide-rule {
    border: none;
    border-top: 1px solid var(--line);
    margin: 1.4rem 0;
  }


  .guide-callout {
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    background: rgba(107,98,86,0.07);
    border-left: 3px solid var(--stone);
  }


  .guide-diagnostic {
    border-left-color: #7a5c3a;
  }


  .guide-experiment {
    border-left-color: #4a6b52;
  }


  .guide-seealso {
    border-left-color: #5a6478;
    font-size: 0.95em;
  }


  .guide-table-wrap {
    overflow-x: auto;
    margin: 0.6rem 0 1.1rem;
  }


  .guide-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
    background: rgba(255,255,255,0.28);
  }


  .guide-table th,
  .guide-table td {
    border: 1px solid var(--line);
    padding: 0.55rem 0.7rem;
    text-align: left;
    vertical-align: top;
  }


  .guide-table th {
    background: rgba(107,98,86,0.12);
    font-weight: 700;
    color: var(--ink);
  }


  .guide-table tr:nth-child(even) td {
    background: rgba(107,98,86,0.04);
  }


  .guide-glossary {
    margin: 0.4rem 0 0;
  }


  .guide-glossary dt {
    margin: 1rem 0 0.25rem;
    font-family: "Fraunces", "Iowan Old Style", Palatino, Georgia, serif;
    font-weight: 700;
    font-size: 1.05em;
    scroll-margin-top: 5rem;
  }


  .guide-glossary dt:first-child {
    margin-top: 0.2rem;
  }


  .guide-glossary dd {
    margin: 0 0 0.35rem;
    padding-left: 0;
  }


  .guide-glossary dd p {
    margin: 0 0 0.45rem;
  }


  .guide-glossary dd ul {
    margin: 0.35rem 0 0.55rem;
  }


  /* Two-column prose when the reading pane is wide enough.
     Sidebar TOC is present from 1000px; full two-col body needs more room. */
  @media (min-width: 1000px) and (max-width: 1279px) {
    .guide-layout {
      grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr);
    }
  }


  @media (min-width: 1280px) {
    .guide-body {
      column-count: 2;
      column-gap: clamp(1.4rem, 2.8vw, 2.4rem);
      column-rule: 1px solid var(--line);
    }
    .guide-body > h1,
    .guide-body > h2,
    .guide-body > h3,
    .guide-body > h4,
    .guide-body .guide-table-wrap,
    .guide-body .guide-glossary,
    .guide-body .guide-rule {
      column-span: all;
    }
    .guide-body li {
      break-inside: avoid;
    }
    .guide-table {
      break-inside: avoid;
    }
  }


  @media (max-width: 999px) {
    .guide-layout {
      grid-template-columns: 1fr;
    }
    .guide-toc {
      position: static;
      max-height: none;
    }
  }


  @media print {
    .guide-wrap {
      max-width: none;
      margin: 0;
      padding: 0;
    }
    .guide-hero {
      text-align: center;
      padding: 0 0 0.6rem;
      break-inside: avoid;
      page-break-inside: avoid;
    }
    .guide-hero h1 {
      font-size: 1.65rem;
    }
    .guide-subtitle {
      font-size: 1.05rem;
      color: #000;
    }
    .guide-meta,
    .guide-companions {
      max-width: none;
      color: #000;
      font-size: 0.85rem;
    }
    .guide-hero .dotrule {
      border-top-color: #6b6256;
      margin: 0.7rem auto 0;
    }
    .guide-layout {
      display: block;
      margin-top: 0.4rem;
    }
    /* Flat TOC — no card chrome */
    .guide-toc {
      position: static;
      max-height: none;
      overflow: visible;
      margin: 0 0 0.9rem;
      padding: 0 0 0.7rem;
      background: none !important;
      border: none !important;
      border-radius: 0;
      box-shadow: none !important;
      border-bottom: 1px solid #6b6256 !important;
      break-inside: avoid;
      page-break-inside: avoid;
    }
    .guide-toc h2 {
      font-size: 1rem;
      margin: 0 0 0.4rem;
    }
    .guide-toc-list {
      display: block; /* flex blocks multi-column */
      column-count: 2;
      column-gap: 1.35rem;
      column-rule: 1px solid #b0a898;
      gap: 0;
    }
    .guide-toc-list li {
      break-inside: avoid;
      margin: 0 0 0.2rem;
    }
    .guide-toc-list .toc-sub {
      padding-left: 0.75rem;
      margin: 0.1rem 0 0.25rem;
    }
    .guide-toc-list .toc-sub li {
      margin: 0 0 0.08rem;
    }
    .guide-toc-list a {
      color: #000 !important;
      font-size: 0.82rem;
      font-weight: 600;
      text-decoration: none;
    }
    .guide-toc-list a.is-active {
      background: none !important;
      box-shadow: none !important;
      border-radius: 0;
      padding: 0;
      margin-left: 0;
      font-weight: 600;
    }
    .guide-toc-list .toc-sub a {
      font-size: 0.75rem;
      font-weight: 500;
    }
    .guide-toc-list .toc-sub a.is-active {
      font-weight: 500;
    }
    /* Flat body — no card; two-column portrait prose */
    .guide-body {
      column-count: 2 !important;
      column-gap: 1.35rem !important;
      column-rule: 1px solid #b0a898 !important;
      column-fill: auto;
      margin: 0;
      padding: 0 !important;
      background: none !important;
      border: none !important;
      border-radius: 0 !important;
      box-shadow: none !important;
      color: #000;
      font-size: 9.5pt;
      line-height: 1.35;
    }
    .guide-body * {
      color: #000 !important;
    }
    .guide-body > h1 {
      column-span: all;
      font-size: 1.25rem;
      margin: 0.85rem 0 0.35rem;
      break-after: avoid;
      page-break-after: avoid;
    }
    .guide-body > h2 {
      column-span: all;
      font-size: 1.08rem;
      margin: 0.7rem 0 0.3rem;
      break-after: avoid;
      page-break-after: avoid;
    }
    .guide-body > h2.part-subtitle {
      column-span: all;
      font-size: 0.95rem;
      margin: 0.1rem 0 0.45rem;
    }
    .guide-body > h3 {
      column-span: all;
      font-size: 0.98rem;
      margin: 0.55rem 0 0.25rem;
      break-after: avoid;
      page-break-after: avoid;
    }
    .guide-body > h4 {
      column-span: all;
      font-size: 0.9rem;
      margin: 0.45rem 0 0.2rem;
      break-after: avoid;
      page-break-after: avoid;
      color: #000 !important;
    }
    .guide-body p {
      margin: 0 0 0.45rem;
      orphans: 3;
      widows: 3;
    }
    .guide-body ul,
    .guide-body ol {
      margin: 0 0 0.5rem;
      padding-left: 1.1rem;
    }
    .guide-body li {
      margin: 0 0 0.15rem;
    }
    .guide-rule {
      column-span: all;
      border-top-color: #6b6256;
      margin: 0.65rem 0;
    }
    .guide-callout {
      background: none !important;
      border: none;
      border-left: 2px solid #6b6256;
      border-radius: 0;
      padding: 0.15rem 0 0.15rem 0.55rem;
      margin-bottom: 0.45rem;
      break-inside: avoid;
    }
    .guide-table-wrap {
      column-span: all;
      margin: 0.4rem 0 0.65rem;
      overflow: visible;
    }
    .guide-table {
      font-size: 0.9em;
      break-inside: avoid;
      page-break-inside: avoid;
    }
    .guide-table th,
    .guide-table td {
      border-color: #6b6256;
      background: none !important;
      padding: 0.28rem 0.4rem;
    }
    .guide-table th {
      font-weight: 700;
    }
    .guide-glossary {
      column-span: all;
      column-count: 2;
      column-gap: 1.35rem;
      column-rule: 1px solid #b0a898;
    }
    .guide-glossary dt {
      break-after: avoid;
      page-break-after: avoid;
      margin-top: 0.55rem;
      font-size: 0.95em;
    }
    .guide-glossary dd {
      break-before: avoid;
    }
    .guide-wrap .footnote {
      column-span: all;
      margin-top: 0.9rem;
      font-size: 0.75rem;
      color: #000;
    }
  }


  .page img.ph {
    aspect-ratio: 1650 / 2550;
    object-fit: cover;
    background: linear-gradient(180deg, #e8e0d0 0%, #d9d0bc 45%, #efe7d8 100%);
    min-height: 40vh;
  }


  .book-single .page img.ph {
      aspect-ratio: 1650 / 2550;
      max-width: 96vw;
      max-height: 96vh;
      width: auto;
  }


  .book.cover > .page:first-child h1 {
      font-size: clamp(3.5rem, 7vw, 6.5rem);
  }


  .chapter-title {
      position: absolute;
      left: 0; right: 0; top: 6%;
      z-index: 2;
      text-align: center;
      padding: 4% 8% 0;
      pointer-events: none;
      line-height: 1.3;
      color: #1b1108;
      text-shadow: 0 0 4px rgba(255,255,255,0.95), 0 0 9px rgba(255,255,255,0.85), 0 1px 3px rgba(40,30,20,0.4);
  }




  .seelink {
    color: #4a3a26;
    text-decoration: underline;
    text-decoration-color: rgba(107,98,86,0.55);
    text-underline-offset: 0.18em;
    transition: color .15s ease, text-decoration-color .15s ease;
  }


  .seelink:hover {
    color: #1b1108;
    text-decoration-color: #6b6256;
  }


  .page img.img-ph {
    aspect-ratio: 1650 / 2550;
    object-fit: cover;
    background: linear-gradient(180deg, #e8e0d0 0%, #d9d0bc 45%, #efe7d8 100%);
    min-height: 40vh;
  }


  /* --- 8. book-text.html layout + all-langs pack --- */
  /* ===== All-book text page (book-text.html) ===== */
  .booktext {
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2.6rem) clamp(0.8rem, 3vw, 2rem) 4rem;
  }

  .booktext-section { margin: 0 auto 3.2rem; }

  .book-cover-icon {
    display: block;
    width: clamp(96px, 32%, 150px);
    height: auto;
    margin: 0 auto 0.3rem;
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(40, 30, 20, 0.18);
  }

  .booktext-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(0.8rem, 2vw, 1.5rem);
    max-width: 1100px;
    margin: 0 auto;
  }

  @media (max-width: 800px) {
    .booktext-grid { grid-template-columns: 1fr; }
  }

  .text-page {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    background: #fbf4e6;
    border: 1px solid rgba(107, 98, 86, 0.18);
    border-radius: 16px;
    padding: 1rem 1.1rem 1.1rem;
    box-shadow: 0 6px 18px rgba(40, 30, 20, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    break-inside: avoid;
  }

  .text-page:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 26px rgba(40, 30, 20, 0.14);
  }

  .text-page.tp-solo {
    grid-column: 1 / -1;
    max-width: 560px;
    margin: 0 auto;
  }

  .tp-head { display: flex; align-items: center; }

  .tp-badge {
    display: inline-block;
    font-family: "Fraunces", Georgia, serif;
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fbf4e6;
    background: #6b6256;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
  }

  .tp-body {
    font-family: "Nunito", Georgia, serif;
    color: #3a2f22;
    line-height: 1.5;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    text-align: center;
  }

  .tp-body p { margin: 0; }
  .tp-body h1, .tp-body h2, .tp-body h3 {
    font-family: "Fraunces", Georgia, serif;
    color: #1b1108;
    margin: 0 0 0.2em;
    line-height: 1.2;
  }
  .tp-body h1 { font-size: clamp(1.1rem, 2vw, 1.6rem); }
  .tp-body h2 { font-size: clamp(1rem, 1.8vw, 1.35rem); }
  .tp-body h3 { font-size: clamp(0.95rem, 1.6vw, 1.2rem); }
  .tp-body em { font-style: italic; }

  .tp-body hr {
    width: 40px;
    border: none;
    color: transparent;
    border-top: 3px dotted rgba(150, 140, 120, 0.8);
    margin: 0.45rem auto;
  }

  .tp-alt {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    margin-top: auto;
    background: rgba(107, 98, 86, 0.10);
    border-left: 3px solid #6b6256;
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    font-family: "Nunito", Georgia, serif;
  }

  .tp-alt-glyph {
    flex: 0 0 auto;
    width: 13px;
    height: 13px;
    margin-top: 0.2rem;
    color: #6b6256;
    opacity: 0.7;
  }
  .tp-alt-text {
    display: block;
    color: #3a2f22;
    font-size: 0.85rem;
    line-height: 1.45;
    font-style: italic;
  }

  @media print {
    .booktext { max-width: none; padding: 0; }
    .booktext-grid { grid-template-columns: 1fr 1fr; gap: 0.35rem; max-width: none; }
    .booktext-icon { box-shadow: none; }
    .text-page {
      background: none;
      border: 1px solid #6b6256;
      box-shadow: none;
      break-inside: avoid;
      padding: 0.5rem 0.6rem 0.6rem;
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
    }
    .book-cover-icon { width: 80px; margin-bottom: 0.25rem; box-shadow: none; }
    .tp-body { font-size: 0.72rem; line-height: 1.35; color: #000; }
    .tp-body h1, .tp-body h2, .tp-body h3 { color: #000; }
    .tp-alt {
      padding: 0.4rem 0.55rem;
      background: none;
      border: 1px solid rgba(107, 98, 86, 0.5);
      border-left: 3px solid #6b6256;
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
    }
    .tp-alt-text { font-size: 0.68rem; line-height: 1.3; color: #000; }
    .tp-alt-glyph { opacity: 0.8; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .tp-head { margin-bottom: 0.15rem; }
    .tp-badge { font-size: 0.66rem; padding: 0.12rem 0.5rem; }
  }

  /* "All languages" print mode (book-text.html) */
  @media print {
    body.all-langs > main.booktext,
    body.all-langs .site-nav,
    body.all-langs .marker-toggle,
    body.all-langs #print-all-langs-btn,
    body.all-langs #all-langs-dialog { display: none !important; }
    body.all-langs #all-langs { display: block; }
    #all-langs .booktext { max-width: none; padding: 0; }
    .lang-head { break-before: page; }
    #all-langs.al-continuous .lang-head { break-before: auto; }
    .al-toc { break-after: page; }
    #all-langs.al-continuous .al-toc { break-after: auto; }
    #all-langs.al-with-bg .text-page.has-bg,
    #all-langs.al-with-bg .text-page.has-bg .tp-body,
    #all-langs.al-with-bg .text-page.has-bg .tp-alt-text {
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
    }
  }

  /* Background images + near-white text halo (book-text.html print-all-langs) */
  #all-langs.al-with-bg .text-page.has-bg {
    position: relative;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #all-langs.al-with-bg .text-page.has-bg .tp-body,
  #all-langs.al-with-bg .text-page.has-bg .tp-alt-text {
    text-shadow:
      0 0 3px #fff, 0 0 3px #fff,
      0 0 16px #fff, 0 0 16px #fff, 0 0 16px #fff,
      0 0 16px #fff, 0 0 16px #fff, 0 0 16px #fff,
      0 0 16px #fff, 0 0 16px #fff;
  }

  /* ===========================================================================
     All-languages print-preview typography (BASE, not @media print).
     Defined outside @media print so the on-screen preview matches the printed
     layout exactly. Scale shrinks type/spacing via --al-scale (no CSS transform).
     Named @page so this does not fight book landscape rules from site.js.
     =========================================================================== */
  @page all-langs-page { size: letter portrait; margin: 10mm 8mm; }

  body.all-langs {
    page: all-langs-page;
  }

  body.all-langs #all-langs {
    display: block;
    position: relative;
    --al-scale: 1;
    --al-gap: calc(0.35rem * var(--al-scale));
    --al-pad-y: calc(0.5rem * var(--al-scale));
    --al-pad-x: calc(0.6rem * var(--al-scale));
    --al-body-fs: calc(0.72rem * var(--al-scale));
    --al-alt-fs: calc(0.68rem * var(--al-scale));
    --al-badge-fs: calc(0.66rem * var(--al-scale));
    --al-icon: calc(80px * var(--al-scale));
    max-width: calc(8.5in - 16mm);
    margin: 0 auto;
  }
  /* Keep letter pages clear of the floating panel on screen. */
  @media screen {
    body.all-langs { padding-right: min(23rem, 42vw); }
  }
  /* Template clones only — packed pages are the printable content. */
  body.all-langs #all-langs .lang-block {
    display: none !important;
  }
  body.all-langs .booktext { max-width: none; padding: 0; }
  body.all-langs .booktext-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--al-gap);
    max-width: none;
  }
  body.all-langs .text-page {
    padding: var(--al-pad-y) var(--al-pad-x) calc(0.6rem * var(--al-scale));
    box-shadow: none;
    border: 1px solid rgba(107, 98, 86, 0.18);
    border-radius: calc(16px * var(--al-scale));
    break-inside: avoid;
    gap: calc(0.7rem * var(--al-scale));
    transform: none;
    transition: none;
  }
  body.all-langs .text-page:hover {
    transform: none;
    box-shadow: none;
  }
  body.all-langs .text-page.tp-solo {
    grid-column: auto;
    max-width: none;
    margin: 0;
  }
  body.all-langs .book-cover-icon {
    width: var(--al-icon);
    max-width: 100%;
    height: auto;
    margin-bottom: calc(0.25rem * var(--al-scale));
    box-shadow: none;
  }
  body.all-langs .tp-body { font-size: var(--al-body-fs); line-height: 1.35; color: #000; }
  body.all-langs .tp-body h1,
  body.all-langs .tp-body h2,
  body.all-langs .tp-body h3 { color: #000; }
  body.all-langs .tp-alt {
    padding: calc(0.4rem * var(--al-scale)) calc(0.55rem * var(--al-scale));
    background: rgba(107, 98, 86, 0.10);
    border: 1px solid rgba(107, 98, 86, 0.5);
    border-left: calc(3px * var(--al-scale)) solid #6b6256;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.all-langs .tp-alt-text { font-size: var(--al-alt-fs); line-height: 1.3; color: #000; }
  body.all-langs .tp-alt-glyph {
    width: calc(13px * var(--al-scale));
    height: calc(13px * var(--al-scale));
  }
  body.all-langs .tp-head { margin-bottom: calc(0.15rem * var(--al-scale)); }
  body.all-langs .tp-badge {
    font-size: var(--al-badge-fs);
    padding: calc(0.12rem * var(--al-scale)) calc(0.5rem * var(--al-scale));
  }

  /* Optional system fonts — smaller embedded PDF, slightly different look. */
  body.all-langs.al-font-system #all-langs,
  body.all-langs.al-font-system #all-langs .tp-body,
  body.all-langs.al-font-system #all-langs .tp-body h1,
  body.all-langs.al-font-system #all-langs .tp-body h2,
  body.all-langs.al-font-system #all-langs .tp-body h3,
  body.all-langs.al-font-system #all-langs .lang-head,
  body.all-langs.al-font-system #all-langs .al-toc {
    font-family: Georgia, "Times New Roman", Times, serif;
  }
  body.all-langs.al-font-system #all-langs .tp-badge,
  body.all-langs.al-font-system #all-langs .tp-alt-text {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  }

  /* Page-fill: fixed US Letter box; type scale via --al-scale (vector-safe). */
  body.all-langs #all-langs.al-pagefill .al-print-page {
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    break-after: page;
    page-break-after: always;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.all-langs #all-langs.al-pagefill .al-page-grid {
    display: flex;
    flex-direction: column;
    gap: var(--al-gap);
    box-sizing: border-box;
    height: 100%;
  }
  body.all-langs #all-langs.al-pagefill .al-page-row {
    /* Grow into leftover space; never shrink below content (min-height:auto). */
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--al-gap);
    align-content: stretch;
  }
  body.all-langs #all-langs.al-pagefill .al-page-row-head {
    grid-template-columns: 1fr;
    flex: 0 0 auto;
  }
  body.all-langs #all-langs.al-pagefill .al-page-row > .text-page {
    height: 100%;
  }
  body.all-langs #all-langs.al-pagefill .al-page-row > .text-page.lone {
    grid-column: 1 / -1;
  }
  body.all-langs #all-langs.al-pagefill .lang-head { break-before: auto; }
  /* While packing, use natural row heights so overflow checks are real. */
  body.all-langs #all-langs.al-pagefill .al-page-grid.is-packing {
    height: auto;
  }
  body.all-langs #all-langs.al-pagefill .al-page-grid.is-packing .al-page-row {
    flex: 0 0 auto;
    min-height: min-content;
  }
  body.all-langs #all-langs.al-pagefill .al-page-grid.is-packing .al-page-row > .text-page {
    height: auto;
    overflow: visible;
  }


/* --- 9. book-text.html screen UI (marker toggles + Print Options) --- */

.marker-toggle {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 300;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    border: 1px solid #6b6256;
    background: #fff;
    color: #6b6256;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    cursor: pointer;
  }
  .marker-toggle:hover { background: #f3efe7; }
  .marker-toggle:disabled { opacity: .5; cursor: default; }
  .marker-hl {
    background: #fff3b0;
    border-radius: 2px;
    padding: 0 .04em;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .marker-num {
    font-size: .62em;
    font-weight: 700;
    color: #6b6256;
    vertical-align: super;
    margin-left: .1em;
  }

  /* "All languages" print panel — floats over the page; Apply updates in place */
  #print-all-langs-btn {
    right: 1rem;
    bottom: 4.6rem;
  }
  #all-langs { display: none; }
  body.all-langs #all-langs { display: block; }
  body.all-langs > main.booktext,
  body.all-langs .site-nav,
  body.all-langs .marker-toggle { display: none !important; }

  #all-langs-dialog {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 400;
    width: min(22rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
  }
  #all-langs-dialog[hidden] { display: none; }
  .al-dialog {
    background: #fffdf8;
    border: 1px solid #6b6256;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,.28);
    padding: 0.9rem 1rem 1rem;
    color: #2c2820;
  }
  .al-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.7rem;
  }
  .al-dialog h2 {
    margin: 0;
    font-family: "Fraunces", Georgia, serif;
    font-size: 1.15rem;
    line-height: 1.25;
  }
  .al-close {
    flex: 0 0 auto;
    width: 1.85rem;
    height: 1.85rem;
    margin: -0.15rem -0.25rem 0 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #6b6256;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
  }
  .al-close:hover { background: rgba(107, 98, 86, 0.12); }
  .al-field { margin: 0 0 0.75rem; }
  .al-field > label { display: block; font-weight: 700; margin-bottom: .3rem; font-size: 0.92rem; }
  .al-field select {
    width: 100%;
    padding: .35rem .45rem;
    border: 1px solid #6b6256;
    border-radius: 8px;
    background: #fff;
    font: inherit;
  }
  .al-scale-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  .al-scale-row input[type="range"] { flex: 1; min-width: 0; }
  #al-scale-val {
    min-width: 2.75rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 0.9rem;
  }
  .al-lang-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    margin-bottom: .3rem;
    font-size: 0.92rem;
  }
  .al-mini {
    font: inherit;
    font-size: .75rem;
    padding: .12rem .45rem;
    border: 1px solid #6b6256;
    border-radius: 999px;
    background: #fff;
    color: #6b6256;
    cursor: pointer;
  }
  .al-mini + .al-mini { margin-left: .3rem; }
  .al-lang-list {
    max-height: 11rem;
    overflow: auto;
    border: 1px solid #d8d0c2;
    border-radius: 8px;
    padding: .3rem .45rem;
    background: #fff;
  }
  .al-lang-item {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .14rem .1rem;
    cursor: pointer;
    font-size: 0.9rem;
  }
  .al-lang-item small { color: #8a8170; }
  .al-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .35rem;
  }
  .al-btn {
    font: inherit;
    padding: .4rem 0.9rem;
    border: 1px solid #6b6256;
    border-radius: 999px;
    background: #fff;
    color: #6b6256;
    cursor: pointer;
  }
  .al-btn:disabled { opacity: .55; cursor: default; }
  .al-primary { background: #6b6256; color: #fffdf8; border-color: #6b6256; }
  @media print {
    #all-langs-dialog { display: none !important; }
  }

  .al-toc { font-family: "Fraunces", Georgia, serif; }
  .al-toc ul { list-style: none; padding: 0; margin: .3rem 0 0; }
  .al-toc li { padding: .12rem 0; }
  .al-toc a { color: #2c2820; text-decoration: none; }
  .lang-head {
    font-family: "Fraunces", Georgia, serif;
    margin: 0 0 .6rem;
    padding-bottom: .25rem;
    border-bottom: 2px solid #6b6256;
  }
