/* Sagatales: accessible, single-scroll reading experience. */
body.saga-reader-open { overflow: hidden; }
.sr-dialog {
  --sr-ink: #173a30;
  --sr-paper: #fffdf7;
  --sr-text-size: 21px;
  width: min(1180px, calc(100vw - 48px));
  max-width: none;
  max-height: calc(100dvh - 40px);
  margin: auto;
  padding: 0;
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 24px;
  color: var(--sr-ink);
  background: #f8f5ee;
  box-shadow: 0 32px 100px #08251b40;
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
.sr-dialog::backdrop { background: rgba(16,42,32,.66); backdrop-filter: blur(8px); }
.sr-dialog *, .sr-dialog *::before, .sr-dialog *::after { box-sizing: border-box; }
.sr-dialog button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.sr-dialog button:disabled { cursor: default; opacity: .4; }
.sr-dialog button:focus-visible { outline: 3px solid #a95135; outline-offset: 4px; }
.sr-dialog svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.sr-dialog [hidden] { display: none !important; }
.sr-shell { padding: 28px 36px 24px; }
.sr-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.sr-heading-group { max-width: 820px; }
.sr-eyebrow { display: block; font-size: 12px; letter-spacing: .13em; font-weight: 700; color: #6c776b; margin-bottom: 7px; }
.sr-header h2 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(24px, 3vw, 34px); font-weight: 400; line-height: 1.2; margin: 0; letter-spacing: -.025em; }
.sr-icon-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; min-width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1px solid #d9ddd3; background: #fffdf8; color: var(--sr-ink); }

.sr-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 25px 0 18px; }
.sr-toolbar-start { display: flex; align-items: center; gap: 14px; min-width: 0; }
.sr-soft-button { min-height: 44px; padding: 10px 14px; border: 1px solid #d9ddd3; border-radius: 30px; background: transparent; color: var(--sr-ink); display: inline-flex; align-items: center; gap: 8px; font-size: 14px !important; font-weight: 600 !important; }
 .sr-soft-button.is-active, .sr-soft-button[aria-pressed="true"]{ background: #e9ede3; border-color: #aab6a5; }
.sr-style-label { font-size: 13px; color: #6a786b; }
.sr-stage { min-height: 360px; outline: none; }
.sr-book { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 390px; margin: 0; position: relative; background: var(--sr-paper); border-radius: 4px 10px 10px 4px; border: 1px solid #d9d4c7; box-shadow: 0 16px 30px #173a3012, 0 3px 0 #e9e2d5, 0 5px 0 #d9d1c2; overflow: visible; }
.sr-book::after { content: ""; position: absolute; top: 0; bottom: 0; width: 24px; left: 51.2%; transform: translateX(-50%); pointer-events: none; background: linear-gradient(90deg, transparent, #87795b17 45%, #87795b29 50%, #fffdf750 60%, transparent); }
.sr-illustration { position: relative; display: flex; align-items: center; justify-content: center; margin: 0; padding: 20px; background: #ece6d7; border-radius: 4px 0 0 4px; min-width: 0; }
.sr-illustration img { display: block; width: 100%; height: auto; max-height: 440px; object-fit: contain; border-radius: 4px; }
.sr-illustration-label { position: absolute; left: 24px; bottom: 18px; background: #fffdf5ed; border-radius: 24px; padding: 6px 12px; font-size: 12px; font-weight: 600; color: #455e4b; }
.sr-story-page { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 34px 38px 26px; min-width: 0; }
.sr-page-ornament { font-size: 28px; color: #a95135; margin-bottom: 13px; line-height: 1; }
.sr-story-page h3 { font-family: Georgia, "Times New Roman", serif; font-size: calc(var(--sr-text-size) * 1.2); line-height: 1.28; font-weight: 400; margin: 0 0 18px; letter-spacing: -.015em; color: var(--sr-ink); }
.sr-story-text { font-family: Georgia, "Times New Roman", serif; font-size: var(--sr-text-size); line-height: 1.68; margin: 0; white-space: pre-line; overflow-wrap: anywhere; color: #2c3e33; }
.sr-story-text [data-word] { box-decoration-break: clone; -webkit-box-decoration-break: clone; border-radius: 3px; transition: background-color .12s; }
.sr-story-text .is-speaking { background: #edcf84; box-shadow: 2px 0 #edcf84, -2px 0 #edcf84; }
.sr-folio { display: block; align-self: flex-end; margin-top: 30px; color: #8b8f7c; font: italic 14px Georgia, serif; }
.sr-page-navigation { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 20px; }
.sr-page-button { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; width: fit-content; border: 0; border-radius: 28px; padding: 8px 10px; background: transparent; color: var(--sr-ink); font-size: 14px !important; font-weight: 600 !important; }

.sr-page-button[data-reader="next"] { justify-self: end; }
.sr-progress { display: flex; align-items: center; flex-direction: column; gap: 0; }
.sr-page-count { font-size: 13px; line-height: 1.4; color: #596b5c; }
.sr-page-dots { display: flex; gap: 1px; justify-content: center; flex-wrap: wrap; max-width: 280px; }
.sr-page-dots button { background: transparent; border: 0; padding: 11px 7px; min-height: 32px; display: flex; align-items: center; justify-content: center; }
.sr-page-dots button span { width: 6px; height: 6px; border-radius: 99px; background: #cbd2c5; transition: width .2s, background .2s; }
.sr-page-dots button.is-current span { width: 18px; background: #a95135; }
.sr-controls { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid #dcded3; padding-top: 18px; margin-top: 8px; }
.sr-type-controls { display: flex; align-items: center; gap: 5px; }
.sr-type-controls > span { font-size: 13px; margin-right: 7px; color: #677163; }
.sr-type-controls button { width: 42px; height: 42px; padding: 0; border-radius: 50%; border: 1px solid #d9ddd3; background: #fffdf7; font-size: 18px; font-family: Georgia, serif; color: var(--sr-ink); }
.sr-type-controls button span { font: 12px Manrope, sans-serif; margin-left: 1px; }

.sr-audio-controls { display: flex; align-items: center; gap: 8px; }
.sr-play { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 190px; min-height: 48px; border: 0; border-radius: 30px; padding: 12px 21px; color: #fffdf7; background: var(--sr-ink); font-size: 14px !important; font-weight: 600 !important; }

.sr-audio-note { font-size: 12px; color: #6c776b; max-width: 145px; text-align: right; line-height: 1.55; }
.sr-message { margin: 10px 0 0; font-size: 14px; line-height: 1.6; color: #93462d; }
.sr-message:empty { display: none; }
.sr-footer { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 23px; margin-top: 16px; border-top: 1px solid #dcded3; }
.sr-footer p { margin: 0; font-size: 14px; color: #657061; }
.sr-create { border: 0; border-radius: 30px; min-height: 48px; padding: 13px 23px; background: #a95135; color: #fffdf7; font-size: 14px !important; line-height: 1.4; font-weight: 650 !important; }

.sr-cover-view { display: flex; align-items: center; flex-direction: column; justify-content: center; padding: 20px 20px 7px; min-height: 360px; background: radial-gradient(ellipse at 50% 55%, #e9dfca, transparent 70%); }
.sr-cover { width: min(290px, 75vw); aspect-ratio: 3 / 4; position: relative; border-radius: 3px 10px 10px 3px; box-shadow: 11px 12px 25px #173a3026, inset 3px 0 #fff8; transform: rotate(-2deg); overflow: hidden; background: #1d5c61; border-left: 5px solid #21483e; }
.sr-cover img { width: 100%; height: 100%; object-fit: cover; }
.sr-cover::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, #173a30c9, transparent 65%, #173a3077); border-radius: inherit; box-shadow: inset 3px 0 5px #ffffff3d; }
.sr-cover-title { position: absolute; z-index: 1; top: 28px; left: 25px; right: 25px; text-align: center; color: #fff9dd; }
.sr-cover-title > span { font-size: 12px; letter-spacing: .1em; font-weight: 600; }
.sr-cover-title h3 { font: 400 28px/1.15 Georgia, serif; margin: 16px 0 0; }
.sr-cover-brand { position: absolute; z-index: 1; bottom: 21px; left: 0; right: 0; text-align: center; color: #fffdf7; font: 24px Georgia, serif; letter-spacing: -.045em; }
.sr-cover-brand span { color: #e8c98c; padding-left: 2px; font-size: 18px; }
.sr-cover-view > p { font-size: 13px; color: #6b7769; margin: 23px 0 0; text-align: center; }
.sr-reading-focus .sr-book { display: block; max-width: 800px; margin: auto; }
.sr-reading-focus .sr-book::after { display: none; }
.sr-reading-focus .sr-illustration { display: none; }
.sr-reading-focus .sr-story-page { padding: 50px 64px; min-height: 370px; }
.sr-reading-focus .sr-story-text { line-height: 1.8; }
.sr-loading { width: 17px; height: 17px; border-radius: 50%; border: 2px solid #ffffff55; border-top-color: white; animation: sr-spin .8s linear infinite; }
@keyframes sr-spin { to { transform: rotate(360deg); } }
@media (max-width: 800px) {
  .sr-shell { padding: 22px 24px; }
  .sr-story-page { padding: 26px 26px 22px; }
  .sr-illustration { padding: 12px; }
  .sr-audio-note { display: none; }
  .sr-header h2 { font-size: 28px; }
}
@media (max-width: 620px) {
  .sr-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; border-radius: 0; margin: 0; }
  .sr-shell { padding: 20px 18px 22px; }
  .sr-header { gap: 12px; }
  .sr-header h2 { font-size: 25px; }
  .sr-eyebrow { font-size: 12px; letter-spacing: .06em; line-height: 1.5; }
  .sr-toolbar { margin: 19px 0 15px; gap: 8px; }
  .sr-toolbar-start { gap: 9px; }
  .sr-soft-button { padding: 9px 11px; font-size: 14px !important; }
  .sr-soft-button svg { width: 18px; height: 18px; }
  .sr-style-label { font-size: 12px; max-width: 100px; }
  .sr-book { grid-template-columns: 1fr; border-radius: 8px; }
  .sr-book::after { display: none; }
  .sr-illustration { padding: 0; border-radius: 8px 8px 0 0; overflow: hidden; background: #e9e5d5; }
  .sr-illustration img { border-radius: 0; width: 100%; max-height: 310px; object-fit: contain; }
  .sr-illustration-label { bottom: 10px; left: 12px; font-size: 12px; padding: 5px 10px; }
  .sr-story-page { padding: 26px 25px 20px; }
  .sr-page-ornament { font-size: 24px; margin-bottom: 12px; }
  .sr-story-page h3 { margin-bottom: 14px; }
  .sr-story-text { font-size: var(--sr-text-size); line-height: 1.65; }
  .sr-folio { margin-top: 20px; }
  .sr-page-navigation { margin-top: 17px; gap: 2px; }
  .sr-page-button { padding: 8px 3px; gap: 1px; font-size: 14px !important; }
  .sr-page-button svg { width: 19px; height: 19px; }
  .sr-page-count { font-size: 13px; }
  .sr-page-dots { max-width: 145px; }
  .sr-page-dots button { padding: 10px 5px; }
  .sr-controls { position: sticky; bottom: -1px; z-index: 3; margin: 7px -18px 0; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: #f8f5eeed; backdrop-filter: blur(12px); box-shadow: 0 -10px 25px #173a3008; gap: 12px; display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .sr-type-controls > span { display: none; }
  .sr-type-controls { gap: 4px; }
  .sr-type-controls button { width: 42px; height: 44px; }
  .sr-play { flex: 1; min-width: 0; min-height: 45px; padding: 11px 13px; font-size: 14px !important; }
  .sr-play svg { width: 20px; height: 20px; }
  .sr-stop { width: 44px; min-width: 44px; height: 44px; }
  .sr-audio-controls { gap: 5px; min-width: 0; justify-content: flex-end; }
  .sr-footer { flex-direction: column; align-items: stretch; gap: 12px; margin-top: 13px; padding-top: 18px; text-align: center; }
  .sr-footer p { font-size: 13px; }
  .sr-create { width: 100%; }
  .sr-message { font-size: 13px; }
  .sr-cover-view { padding: 20px 10px 10px; }
  .sr-reading-focus .sr-story-page { padding: 30px 25px; min-height: 320px; }
}
@media (prefers-reduced-motion: reduce) {
  .sr-dialog { scroll-behavior: auto; }
  .sr-dialog *, .sr-dialog *::before, .sr-dialog *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
