/* Читалка: минимум интерфейса, чёрный (OLED) фон по умолчанию, панели прячутся. */
.rd { --rd-bg: #000; --rd-fg: #EFE9DC; --rd-bar: rgba(10, 10, 11, .92); --rd-line: rgba(239, 233, 220, .35); position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; background: var(--rd-bg); color: var(--rd-fg); overflow: hidden; }
.rd[data-bg="gray"] { --rd-bg: #1e1e20; }
.rd[data-bg="paper"] { --rd-bg: #F4EFE6; --rd-fg: #111; --rd-bar: rgba(244, 239, 230, .94); --rd-line: rgba(17, 17, 17, .45); }
.rd a { color: inherit; }
.rd .icon-btn { color: var(--rd-fg); }
.rd .icon-btn:hover { background: color-mix(in srgb, var(--rd-fg) 14%, transparent); border-color: var(--rd-line); color: var(--rd-fg); }
.rd .icon-btn[disabled] { opacity: .3; pointer-events: none; }
.rd--boot { align-items: center; justify-content: center; overflow: auto; background: var(--paper); color: var(--ink); }
.rd-boot__links { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.rd--boot .wrap { text-align: center; }

.rd-prog { position: absolute; left: 0; right: 0; top: 0; z-index: 6; height: 4px; background: rgba(128, 128, 128, .25); pointer-events: none; }
.rd-prog i { display: block; height: 100%; background: var(--red); transform-origin: left; transform: scaleX(0); transition: transform .25s var(--ease); }

.rd-bar { position: absolute; left: 0; right: 0; top: 4px; z-index: 5; display: flex; align-items: center; gap: 6px; padding: 6px 8px; padding-top: calc(6px + env(safe-area-inset-top)); background: var(--rd-bar); border-bottom: 2px solid var(--rd-line); transform: translateY(-110%); transition: transform .28s var(--ease); backdrop-filter: blur(6px); }
.rd-bar__t { display: grid; flex: 1; min-width: 0; line-height: 1.2; }
.rd-bar__m { font: 700 1.02rem var(--f-head); letter-spacing: .05em; text-transform: uppercase; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-bar__c { font-size: .78rem; opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-bar__btns { display: flex; }
.rd-foot { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: var(--rd-bar); border-top: 2px solid var(--rd-line); transform: translateY(110%); transition: transform .28s var(--ease); backdrop-filter: blur(6px); }
.rd.is-chrome .rd-bar, .rd.is-chrome .rd-foot { transform: none; }
.rd-slider { position: relative; flex: 1; display: flex; align-items: center; gap: 12px; padding: 0 8px; min-width: 0; }
.rd-slider input[type="range"] { flex: 1; min-width: 0; height: 44px; margin: 0; background: transparent; accent-color: var(--red); cursor: pointer; }
.rd-slider output { flex: none; min-width: 7ch; text-align: right; font: 700 .9rem var(--f-head); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .rd-slider output { min-width: 6ch; font-size: .8rem; } }

.rd-stage { position: relative; flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; outline: 0; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(128, 128, 128, .5) transparent; -webkit-overflow-scrolling: touch; }
.rd-busy { position: absolute; left: 50%; top: 50%; z-index: 4; transform: translate(-50%, -50%); padding: 10px 16px; background: var(--rd-bar); border: 2px solid var(--rd-line); color: var(--rd-fg); }
.rd-busy .spinner { color: inherit; }

/* лента */
.rd-strip { width: min(var(--w, 860px), 100%); margin: 0 auto; padding-bottom: 14vh; }
.rd-intro { display: grid; justify-items: center; gap: 6px; padding: calc(84px + env(safe-area-inset-top)) 20px 36px; text-align: center; }
.rd-intro h1 { font-size: clamp(1.4rem, 4vw, 2.2rem); }
.rd-intro p { margin: 0; opacity: .85; }
.rd-intro__g { font-size: .88rem; opacity: .7; }
.rd-pg { position: relative; margin: 0; background: color-mix(in srgb, var(--rd-fg) 7%, transparent); }
.rd-pg img { display: block; width: 100%; height: auto; opacity: 0; transition: opacity .3s; user-select: none; }
.rd-pg img.is-in { opacity: 1; }
.rd-ph { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--rd-fg); }
.rd-ph .spinner { color: color-mix(in srgb, var(--rd-fg) 60%, transparent); }
.rd-err, .rd-pgerr > span { font-weight: 700; text-align: center; padding: 0 16px; }

/* постранично */
.rd[data-mode="paged"] .rd-stage { display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: safe center; overflow: auto; }
.rd-spread { grid-area: 1 / 1; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-width: 0; }
.rd-img { display: block; user-select: none; -webkit-user-drag: none; object-fit: contain; background: color-mix(in srgb, var(--rd-fg) 6%, transparent); }
.rd[data-fit="screen"] .rd-img { max-width: 100%; max-height: 100%; width: auto; height: auto; }
.rd[data-fit="screen"] .rd-spread--2 .rd-img { max-width: 50%; }
.rd[data-fit="height"] .rd-img { height: 100%; width: auto; max-width: none; }
.rd[data-fit="width"] .rd-spread { height: auto; align-items: flex-start; }
.rd[data-fit="width"] .rd-img { width: 100%; height: auto; }
.rd[data-fit="width"] .rd-spread--2 .rd-img { width: 50%; }
.rd[data-fit="orig"] .rd-spread { width: max-content; height: max-content; min-width: 100%; min-height: 100%; }
.rd[data-fit="orig"] .rd-img { max-width: none; }
.rd[data-mode="paged"] .rd-stage { padding-block: 0; }
.rd-pgerr { display: grid; gap: 12px; justify-items: center; padding: 30px; }

/* конец главы */
.rd-end { display: grid; justify-items: center; padding: 56px 18px 20px; text-align: center; }
.rd-spread--end { align-items: center; overflow: auto; }
.rd-end__in { display: grid; justify-items: center; gap: 14px; max-width: 560px; }
.rd-end__in h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
.rd-end__nav { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.rd-end__nav p { margin: 0; }
.rd .btn--ghost { --b-fg: var(--rd-fg); --b-sh: var(--rd-line); border-color: var(--rd-line); }
.rd .btn--ghost:hover { background: color-mix(in srgb, var(--rd-fg) 12%, transparent); }
.rd .btn--red { --b-sh: var(--rd-line); }
.rd .btn:not(.btn--red):not(.btn--ghost) { --b-bg: var(--rd-fg); --b-fg: var(--rd-bg); }
.rd-end__credit { margin: 4px 0 0; font-size: .88rem; opacity: .85; line-height: 1.7; }
.rd-end__sup { margin: 0; font-size: .8rem; opacity: .65; }
.rd-end .burst--ink { background: var(--rd-fg); color: var(--rd-bg); }

/* панели */
.rd-panel { position: absolute; z-index: 8; top: 4px; right: 0; bottom: 0; width: min(100%, 400px); display: flex; flex-direction: column; background: var(--rd-bar); color: var(--rd-fg); border-left: 3px solid var(--rd-line); box-shadow: -8px 0 0 rgba(0, 0, 0, .25); animation: panel-in .28s var(--ease) both; backdrop-filter: blur(10px); }
.rd-panel[hidden] { display: none; }
@keyframes panel-in { from { transform: translateX(40px); opacity: 0; } }
.rd-panel__h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 16px; border-bottom: 2px solid var(--rd-line); }
.rd-panel__h h2 { font-size: 1.15rem; }
.rd-panel__b { flex: 1; overflow: auto; padding: 12px 16px 24px; display: grid; gap: 16px; align-content: start; }
.rd-panel .row { display: grid; gap: 8px; }
.rd-panel .row[hidden] { display: none; }
.rd-panel .lbl { font: 700 .8rem var(--f-head); letter-spacing: .12em; text-transform: uppercase; opacity: .75; }
.rd-panel .hint { color: inherit; opacity: .7; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; background: transparent; color: inherit; border: 2px solid var(--rd-line); font-weight: 600; font-size: .88rem; }
.seg button[aria-checked="true"] { background: var(--rd-fg); color: var(--rd-bg); border-color: var(--rd-fg); }
.seg button:hover { border-color: var(--rd-fg); }
.row input[type="range"] { width: 100%; height: 44px; accent-color: var(--red); background: transparent; }
.row output { font-size: .85rem; opacity: .75; }
.keys summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font: 700 .8rem var(--f-head); letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.keys dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: .85rem; }
.keys dt { font: 700 .82rem ui-monospace, monospace; padding: 2px 6px; border: 1px solid var(--rd-line); white-space: nowrap; }
.keys dd { margin: 0; }
.toc { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; }
.toc__a { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 16px; text-decoration: none; border-bottom: 1px solid var(--rd-line); }
.toc__a b { flex: none; font: 700 .95rem var(--f-head); letter-spacing: .04em; text-transform: uppercase; min-width: 7ch; }
.toc__a span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; opacity: .8; }
.toc__a:hover { background: color-mix(in srgb, var(--rd-fg) 12%, transparent); color: inherit; }
.toc__a.is-cur { background: var(--red); color: var(--on-red); }
.toc__a.is-read { opacity: .6; }
.bm-note { font: 400 1.25rem/1.3 var(--f-hand); }
.rd .state p { color: inherit; opacity: .75; }
.rd .btn:disabled { opacity: .4; }
@media (max-width: 520px) { .rd-panel { width: 100%; } .rd-bar__btns .icon-btn { width: 40px; } }
