/* Only the edition reader: the shell's legacy pages retain their geometry. */
body.ui-reperes:has(.rp-reader) {
    --rp-bottom-h: calc(var(--rp-nav-h) + 6rem);
    --rp-reader-leading: 1.60;
}
body.ui-reperes:has(.rp-reader) .main-content {
    padding-block: calc(var(--rp-header-h) + 24px) calc(var(--rp-bottom-h) + 24px);
    padding-inline: max(calc(1 * var(--ui-unit)), env(safe-area-inset-left, 0px)) max(calc(1 * var(--ui-unit)), env(safe-area-inset-right, 0px));
    min-width: 0;
}
body.ui-reperes:has(.rp-reader) .rp-shell-inner {
    min-width: 0;
    flex-wrap: wrap;
    padding-inline: max(calc(1 * var(--ui-unit)), env(safe-area-inset-left, 0px)) max(calc(1 * var(--ui-unit)), env(safe-area-inset-right, 0px));
}
body.ui-reperes:has(.rp-reader) .rp-nav a {
    min-width: 0;
    padding-inline: calc(0.25 * var(--ui-unit));
    font-size: calc(0.875 * var(--ui-unit) * min(var(--text-scale, 1), 1.3));
}
body.ui-reperes:has(.rp-reader) *,
body.ui-reperes:has(.rp-reader) *:not(.is-just-filled)::before,
body.ui-reperes:has(.rp-reader) *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}
body.ui-reperes:has(.rp-reader) button:active { transform: none; }
.rp-reader, .rp-reader * { min-width: 0; overflow-wrap: anywhere; }
.rp-reader { max-width: calc(40 * var(--ui-unit)); margin-inline: auto; }
.rp-reader h1 { margin: 0; }
.rp-article-meta { margin-block: 16px 24px; color: var(--rp-muted); font-size: 0.875rem; }
.rp-article-meta p { margin-block: 0 8px; }
body.ui-reperes .rp-article-meta h2 { font-size: calc(0.875 * var(--rp-heading-unit)); margin-block: 12px 0; }
.rp-article-meta ul { margin-block: 0; padding-inline-start: calc(1.25 * var(--ui-unit)); }
.rp-article-meta a { display: inline-flex; align-items: center; min-height: 44px; }
.rp-article-text { font-size: 1.25rem; line-height: var(--rp-reader-leading); }
.rp-article-text p { margin-block: 0 24px; white-space: pre-wrap; }
.rp-article-sources { margin-block: 0 24px; color: var(--rp-muted); font-size: 0.875rem; }
.rp-article-sources summary { min-height: 44px; cursor: pointer; }
.rp-article-sources ul { margin-block: 8px 0; padding-inline-start: calc(1.25 * var(--ui-unit)); }
.rp-article-sources p { margin-block: 8px 0; }
.rp-article-sources a { display: inline-flex; align-items: center; min-height: 44px; }
body.ui-reperes .rp-word {
    display: inline;
    max-width: 100%;
    padding: 0;
    border: 0;
    min-height: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.rp-word.is-proposed { text-decoration: underline dotted; text-underline-offset: 0.18em; }
.rp-word.is-kept { text-decoration: underline solid; text-underline-offset: 0.18em; }
.rp-finish { width: 100%; padding: 12px calc(1 * var(--ui-unit)); }
.rp-reading-bottom {
    position: fixed;
    inset-inline: 0;
    bottom: var(--rp-nav-h);
    z-index: 210;
    border-top: 1px solid var(--rp-border);
    background: var(--rp-panel);
    color: var(--rp-panel-text);
}
.rp-reading-bottom.is-assembled { bottom: 0; }
body.ui-reperes .rp-reading-bottom .rp-nav { position: static; }
.rp-kept-strip {
    max-width: calc(40 * var(--ui-unit));
    margin-inline: auto;
    padding: 8px calc(1 * var(--ui-unit)) 0;
    padding-inline: max(calc(1 * var(--ui-unit)), env(safe-area-inset-left, 0px)) max(calc(1 * var(--ui-unit)), env(safe-area-inset-right, 0px));
}
.rp-kept-strip p { margin: 0 0 8px; font-size: 0.875rem; }
.rp-kept-boxes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
body.ui-reperes .rp-kept-box {
    position: relative;
    min-height: max(44px, 4rem);
    padding: 8px calc(0.25 * var(--ui-unit));
    border: 1px solid var(--rp-border);
    background: var(--rp-panel);
    color: var(--rp-panel-text);
    line-height: 1.45;
    opacity: 1;
}
body.ui-reperes .rp-kept-box + .rp-kept-box { border-inline-start: 0; }
body.ui-reperes .rp-kept-box.is-filled { background: var(--rp-action); color: var(--rp-action-text); border-color: var(--rp-action); }
body.ui-reperes .rp-kept-box.is-filled.is-just-filled { background: var(--rp-panel); color: var(--rp-panel-text); }
.rp-kept-box.is-just-filled::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--rp-action);
    clip-path: inset(0);
    animation: rp-kept-fill 150ms steps(3) both;
    animation-delay: var(--rp-fill-delay, 0ms);
}
@keyframes rp-kept-fill {
    from { clip-path: inset(0 0 100% 0); }
    to { clip-path: inset(0); }
}
@keyframes rp-kept-text {
    from { color: var(--rp-panel-text); }
    to { color: var(--rp-action-text); }
}
.rp-kept-box.is-filled + .rp-kept-box.is-filled { border-inline-start: 2px solid var(--rp-panel); }
/* Two normal lines fit; unusually long words grow instead of being clipped. */
.rp-kept-box span { display: block; position: relative; z-index: 1; }
body.ui-reperes .rp-kept-box.is-just-filled span {
    animation: rp-kept-text 150ms steps(1, end) both !important;
    animation-delay: var(--rp-fill-delay, 0ms) !important;
}
body.ui-reperes .rp-kept-box:focus-visible { outline-offset: -4px; outline-color: var(--rp-action) !important; }
body.ui-reperes .rp-kept-box.is-filled:focus-visible { outline-color: var(--rp-action-text) !important; }
.rp-word-sheet {
    position: fixed;
    z-index: 220;
    inset-inline: 0;
    bottom: var(--rp-bottom-h);
    max-height: max(0px, calc(100dvh - var(--rp-header-h) - var(--rp-bottom-h)));
    overflow: auto;
    overscroll-behavior: contain;
    margin-inline: auto;
    max-width: calc(40 * var(--ui-unit));
    padding: 16px calc(1 * var(--ui-unit));
    padding-inline: max(calc(1 * var(--ui-unit)), env(safe-area-inset-left, 0px)) max(calc(1 * var(--ui-unit)), env(safe-area-inset-right, 0px));
    border-block: 2px solid var(--rp-text);
    background: var(--rp-bg);
    color: var(--rp-text);
}
.rp-word-sheet[hidden], .rp-word-sheet [hidden] { display: none; }
.rp-word-sheet h2, .rp-word-sheet p { margin-block: 0 12px; }
#rp-sheet-sentence { font-size: 1.125rem; }
.rp-sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rp-sheet-actions button { min-width: 44px; padding: 8px calc(0.5 * var(--ui-unit)); }
.rp-sheet-actions .rp-listen { font: inherit; font-weight: 700; }
.rp-word-sheet [aria-busy="true"] { color: var(--rp-muted); }
@media (prefers-reduced-motion: reduce) {
    .rp-reader { scroll-behavior: auto; }
    body.ui-reperes .rp-kept-box.is-filled.is-just-filled { background: var(--rp-action); color: var(--rp-action-text); }
    .rp-kept-box.is-just-filled,
    .rp-kept-box.is-just-filled::before,
    body.ui-reperes .rp-kept-box.is-just-filled span {
        animation: none !important;
    }
}
/* Completion and recall share the reader's type and safe-area rhythm. */
.rp-reader [hidden], .rp-recall [hidden] { display: none; }
.rp-finished { margin-block: 24px 0; }
.rp-finished-sentences { padding-inline-start: calc(1.25 * var(--ui-unit)); }
.rp-finished-sentences li { margin-block: 0 12px; font-size: 1.125rem; }
.rp-recall-link { width: 100%; }
.rp-recall a, .rp-reader .rp-recall-link {
    display: flex;
    align-items: center;
    box-sizing: border-box;
}
.rp-recall-end a + a { margin-block-start: 12px; }
#rp-article-text { scroll-margin-top: calc(var(--rp-header-h) + 12px); }
.rp-finished { scroll-margin-top: calc(var(--rp-header-h) + 12px); }
body.ui-reperes:has(.rp-recall) .main-content {
    padding-block: calc(var(--rp-header-h) + 24px) calc(var(--rp-nav-h) + 24px);
    padding-inline: max(calc(1 * var(--ui-unit)), env(safe-area-inset-left, 0px)) max(calc(1 * var(--ui-unit)), env(safe-area-inset-right, 0px));
    min-width: 0;
}
.rp-recall, .rp-recall * { min-width: 0; overflow-wrap: anywhere; }
.rp-recall { max-width: calc(40 * var(--ui-unit)); margin-inline: auto; }
.rp-recall-prompt, .rp-recall-sentence { font-size: 1.125rem; line-height: 1.60; }
.rp-recall-word { font-size: 1.5rem; font-weight: 700; }
.rp-recall button, .rp-recall a, .rp-reader .rp-recall-link {
    min-height: 44px;
    max-width: 100%;
    white-space: normal;
    padding: 12px calc(0.75 * var(--ui-unit));
}
.rp-recall [data-result="right"] { color: var(--rp-correct); }
.rp-recall [data-result="wrong"] { color: var(--rp-wrong); }
body.ui-reperes:has(.rp-recall) *, body.ui-reperes:has(.rp-recall) *::before,
body.ui-reperes:has(.rp-recall) *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}
