/* Sinen reader — distraction-free, light on data, three themes. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Noto+Sans+Ethiopic:wght@400;500;600&display=swap');

:root { --bg: #ffffff; --fg: #1d1d1f; --muted: #6e6e73; --bar: rgba(255,255,255,.92); --line: rgba(0,0,0,.1); --btn: rgba(0,0,0,.05); --accent: #613cad; --page-shadow: 0 2px 6px rgba(0,0,0,.08), 0 20px 50px rgba(0,0,0,.12); }
[data-theme="sepia"] { --bg: #f6efe2; --fg: #3b2f22; --muted: #7b6a55; --bar: rgba(246,239,226,.94); --line: rgba(59,47,34,.14); --btn: rgba(59,47,34,.07); }
[data-theme="dark"] { --bg: #1c1c1e; --fg: #e9e9ec; --muted: #9a9aa0; --bar: rgba(28,28,30,.92); --line: rgba(255,255,255,.12); --btn: rgba(255,255,255,.08); --accent: #b79cf0; --page-shadow: 0 0 0 1px rgba(255,255,255,.06); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: "Inter", "Noto Sans Ethiopic", system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
body { display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.rd-skip { position: absolute; left: -999px; top: 8px; z-index: 50; padding: 8px 12px; border-radius: 8px; background: var(--fg); color: var(--bg); }
.rd-skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rd-bar { position: relative; z-index: 20; display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 10px; padding-top: env(safe-area-inset-top); background: var(--bar); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line); transition: transform .25s ease, opacity .25s ease; }
.rd-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.2; }
.rd-title strong { font-size: 14px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-title span { font-size: 12px; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-tools { display: flex; gap: 2px; }
.rd-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 40px; height: 40px; padding: 0 8px; border: 0; border-radius: 10px; background: transparent; color: var(--fg); font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; }
.rd-btn:hover { background: var(--btn); }
.rd-btn[aria-pressed="true"] { color: var(--accent); }
.rd-btn[hidden] { display: none; }
.rd-btn--sm { min-width: 34px; height: 32px; font-size: 13px; background: var(--btn); }
.rd-aa { font-weight: 600; font-size: 16px; letter-spacing: -0.02em; }
@media (max-width: 560px) { .rd-hide-sm { display: none !important; } .rd-bar { gap: 4px; } .rd-btn { min-width: 36px; padding: 0 6px; } }

.rd-stage { position: relative; overflow: hidden; outline: none; min-height: 0; }
.rd-loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); font-size: 15px; }
.rd-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: rd-spin .9s linear infinite; }
@keyframes rd-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .rd-spinner { animation-duration: 3s; } }
.rd-error { max-width: 420px; margin: 18vh auto 0; padding: 24px; text-align: center; color: var(--fg); }
.rd-error a { color: var(--accent); }

foliate-view { display: block; width: 100%; height: 100%; }

/* PDF and picture-book pages */
.rd-pdf { position: absolute; inset: 0; overflow: auto; display: grid; place-items: center; padding: 16px; touch-action: pan-x pan-y pinch-zoom; }
.rd-pdf canvas { display: block; background: #fff; box-shadow: var(--page-shadow); border-radius: 2px; }
.rd-pdf__page { position: relative; }
.rd-pdf .textLayer { position: absolute; inset: 0; overflow: hidden; line-height: 1; opacity: .25; }
.rd-pdf .textLayer span { position: absolute; color: transparent; white-space: pre; transform-origin: 0 0; }
.rd-pdf .textLayer span.hit { background: rgba(228,196,65,.85); border-radius: 2px; }

.rd-turn { position: fixed; top: 50%; z-index: 15; display: grid; place-items: center; width: 52px; height: 52px; margin-top: -26px; border: 0; border-radius: 999px; background: var(--bar); color: var(--fg); box-shadow: 0 4px 16px rgba(0,0,0,.12); cursor: pointer; transition: opacity .2s; }
.rd-turn:disabled { opacity: .25; cursor: default; }
.rd-turn--prev { left: max(10px, env(safe-area-inset-left)); }
.rd-turn--next { right: max(10px, env(safe-area-inset-right)); }
@media (max-width: 700px) { [data-mode="epub"] .rd-turn, [data-mode="pdf"] .rd-turn { opacity: 0; pointer-events: none; } }

/* Picture-book mode: big friendly controls for small hands */
[data-mode="picturebook"] .rd-turn { width: 72px; height: 72px; margin-top: -36px; background: #613cad; color: #fff; box-shadow: 0 8px 24px rgba(97,60,173,.35); }
[data-mode="picturebook"] .rd-turn svg { width: 36px; height: 36px; }
[data-mode="picturebook"] .rd-pdf { padding: 12px 96px; }
@media (max-width: 700px) {
  [data-mode="picturebook"] .rd-pdf { padding: 8px 8px 96px; }
  [data-mode="picturebook"] .rd-turn { top: auto; bottom: calc(80px + env(safe-area-inset-bottom)); margin-top: 0; width: 64px; height: 64px; }
}
[data-mode="picturebook"] .rd-progress { display: none; }
[data-mode="picturebook"] #rd-where { font-size: 18px; font-weight: 600; }
.rd-dots { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.rd-dots span { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.rd-dots span.on { background: #613cad; }

.rd-foot { position: relative; z-index: 20; padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--bar); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line); transition: transform .25s ease, opacity .25s ease; }
.rd-progress { width: 100%; accent-color: var(--accent); margin: 0; }
.rd-foot__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; font-size: 13px; color: var(--muted); }
.rd-zoom { display: inline-flex; gap: 6px; }
.rd-zoom[hidden] { display: none; }
html.rd-immersive .rd-bar { transform: translateY(-100%); opacity: 0; }
html.rd-immersive .rd-foot { transform: translateY(100%); opacity: 0; }
@media (prefers-reduced-motion: reduce) { .rd-bar, .rd-foot { transition: none; } }

/* Panels */
.rd-panel { width: min(420px, 100vw); max-height: min(80vh, 640px); margin: auto 0 0 auto; padding: 0; border: 0; border-radius: 18px 18px 0 0; background: var(--bg); color: var(--fg); box-shadow: 0 -10px 40px rgba(0,0,0,.25); }
@media (min-width: 700px) { .rd-panel { margin: 64px 12px auto auto; border-radius: 18px; } }
.rd-panel::backdrop { background: rgba(0,0,0,.3); }
.rd-panel__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; position: sticky; top: 0; background: var(--bg); }
.rd-panel__head h2 { margin: 0; font-size: 17px; }
.rd-panel__body { padding: 6px 16px 20px; overflow: auto; }
.rd-panel ul { list-style: none; margin: 0; padding: 0; }
.rd-panel li a, .rd-panel li button { display: block; width: 100%; padding: 10px 8px; border: 0; border-radius: 10px; background: none; color: var(--fg); font: inherit; font-size: 15px; text-align: left; text-decoration: none; cursor: pointer; }
.rd-panel li a:hover, .rd-panel li button:hover { background: var(--btn); }
.rd-panel li ul { padding-left: 14px; }
.rd-panel small { color: var(--muted); }
.rd-set { display: grid; gap: 18px; }
.rd-set h3 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.rd-seg { display: flex; gap: 6px; }
.rd-seg button { flex: 1; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--btn); color: var(--fg); font: inherit; cursor: pointer; }
.rd-seg button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.rd-seg .t-light { background: #fff; color: #1d1d1f; } .rd-seg .t-sepia { background: #f6efe2; color: #3b2f22; } .rd-seg .t-dark { background: #1c1c1e; color: #e9e9ec; }
.rd-search input { width: 100%; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); font: inherit; font-size: 16px; }
.rd-thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.rd-thumbs button { padding: 0; border: 2px solid transparent; border-radius: 6px; background: none; cursor: pointer; color: var(--muted); font-size: 12px; }
.rd-thumbs button[aria-current="page"] { border-color: var(--accent); }
.rd-thumbs canvas { display: block; width: 100%; height: auto; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.rd-noscript { padding: 24px; text-align: center; }
