/* love咪 · 一起看书 · 独立样式（书架 / 阅读器 / 邀请层）
 * 须挂在 #app 内：position:absolute + inset:0 贴合小手机外框（勿用 fixed 铺满浏览器）
 */

/* 阅读器内置字体（与 style.css 引用同一批 assets 字体文件，浏览器只会下载一次） */
@font-face {
    font-family: 'RtFontKeBen';
    src: url('assets/AaGuDianKeBenSongYouMoBan-2.ttf') format('truetype');
    font-display: swap;
}

@font-face {
    font-family: 'RtFontKaiTi';
    src: url('assets/FangZhengKaiTiJianTi-1.ttf') format('truetype');
    font-display: swap;
}

@font-face {
    font-family: 'RtFontSongKe';
    src: url('assets/ShanHaiJiGuJiangNanSongKeW-2.ttf') format('truetype');
    font-display: swap;
}

#rt-overlay-root {
    position: absolute;
    inset: 0;
    z-index: 100150;
    display: none;
    align-items: stretch;
    justify-content: stretch;
    font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: inherit;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#rt-overlay-root * {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#rt-overlay-root::-webkit-scrollbar,
#rt-overlay-root *::-webkit-scrollbar {
    width: 0 !important;
    height: 0 !important;
    display: none;
}

#rt-overlay-root.is-visible {
    display: flex;
}

.rt-skin {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    width: 100%;
    height: 100%;
    background: #fbf3e4;
    color: var(--rt-shelf-fg, #3d3128);
}

/* --- 书架：暖色中世纪藏书室，生图层板与书行共同定位 --- */
.rt-shelf {
    --rt-shelf-paper: #fbf3e4;
    --rt-shelf-fg: #4c3528;
    --rt-shelf-muted: #796149;
    --rt-shelf-gold: #b29258;
    --rt-shelf-wood: #dbb579;
    --rt-shelf-hairline: rgba(126, 88, 41, 0.26);
    --rt-shelf-shadow: rgba(95, 55, 23, 0.2);
    --rt-shelf-display-font: "RtFontKeBen", "Songti SC", "STSong", serif;
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    container-type: inline-size;
    background: var(--rt-shelf-paper);
    color: var(--rt-shelf-fg);
}
.rt-shelf-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(18px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px))) max(22px, var(--safe-area-inset-right, 0px)) 12px max(22px, var(--safe-area-inset-left, 0px));
    background: var(--rt-shelf-paper);
}
.rt-shelf-head__copy { min-width: 0; }
.rt-shelf-head__title {
    display: block;
    font-family: var(--rt-shelf-display-font);
    font-size: 24px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--rt-shelf-fg);
}
.rt-shelf-head__subtitle {
    display: block;
    margin-top: 5px;
    font-size: 11px;
    line-height: 1.6;
    color: var(--rt-shelf-muted);
}
.rt-shelf-head__close {
    flex: none;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--rt-shelf-hairline);
    border-radius: 50%;
    background: transparent;
    color: var(--rt-shelf-fg);
    font: inherit;
    font-size: 23px;
    cursor: pointer;
}
.rt-shelf-toolbar {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0 22px 14px;
    font-size: 11px;
    color: var(--rt-shelf-muted);
}
.rt-shelf-import {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 34px;
    padding: 6px 14px;
    border: 1px solid var(--rt-shelf-gold);
    border-radius: 4px;
    background: #f0e0bd;
    color: var(--rt-shelf-fg);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}
.rt-shelf-import svg { width: 14px; height: 14px; }
.rt-shelf-import:disabled { opacity: 0.5; cursor: wait; }
.rt-shelf-grid {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: block;
    padding: 0;
    background: var(--rt-shelf-wood);
    border-top: 1px solid var(--rt-shelf-gold);
}
.rt-shelf-row {
    display: grid;
    grid-template-columns: repeat(var(--rt-row-columns, 3), minmax(0, 1fr));
    align-items: end;
    gap: 3%;
    position: relative;
    padding: 5% 8% calc(34% / var(--rt-row-columns, 3));
    background: url("assets/read-together/medieval-shelf-bay.webp?v=1") center / 100% 100% no-repeat;
}
.rt-slot {
    position: relative;
    min-width: 0;
    width: 100%;
    aspect-ratio: 2 / 3;
    border: 0;
    background: transparent;
    color: var(--rt-shelf-fg);
    touch-action: pan-y;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.rt-slot-open {
    display: block;
    position: absolute;
    inset: 0;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 160ms ease;
}
.rt-slot-open:active { transform: translateY(2px); }
.rt-slot-cover { position: absolute; inset: 0; isolation: isolate; }
.rt-book-binding {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(2px 5px 3px var(--rt-shelf-shadow));
    -webkit-user-drag: none;
    pointer-events: none;
}
.rt-book-binding[hidden],
.rt-book-art[hidden] { display: none; }
/* Texture-independent fallback: a failed asset still leaves a readable bound volume. */
.rt-slot-cover::before {
    content: "";
    position: absolute;
    inset: 5% 5% 6% 9%;
    border: 1px solid var(--rt-shelf-gold);
    border-radius: 5px 7px 7px 5px;
    background: #eddbb8;
    box-shadow: inset 6px 0 0 rgba(133, 95, 47, 0.14), 2px 4px 5px var(--rt-shelf-shadow);
    z-index: -1;
}
.rt-slot-label {
    position: absolute;
    top: 31%;
    bottom: 27%;
    left: 22%;
    right: 15%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    text-align: center;
    overflow-wrap: anywhere;
    word-break: normal;
    font-family: var(--rt-shelf-display-font);
    font-size: 14px;
    font-size: clamp(12px, 3.6cqw, 18px);
    font-weight: 600;
    line-height: 1.5;
    color: var(--rt-shelf-fg);
    text-shadow: 0 1px 0 rgba(255, 250, 231, 0.35);
}
.rt-slot-label__text {
    display: -webkit-box;
    min-width: 0;
    min-height: 0;
    max-height: 100%;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.rt-slot--long-title .rt-slot-label {
    font-size: 12px;
    line-height: 1.4;
}
.rt-slot--loading .rt-slot-label,
.rt-slot--unavailable .rt-slot-label { font-family: inherit; font-size: 11px; line-height: 1.6; }
.rt-book-art {
    position: absolute;
    left: 22%;
    top: 25%;
    width: 64%;
    height: 42%;
    object-fit: cover;
    border: 1px solid var(--rt-shelf-gold);
    border-radius: 2px;
    box-sizing: border-box;
    -webkit-user-drag: none;
    pointer-events: none;
}
.rt-slot--custom-cover .rt-slot-label {
    top: 69%;
    bottom: 15%;
    left: 20%;
    right: 13%;
    font-size: 11px;
    line-height: 1.35;
    background: rgba(255, 246, 224, 0.92);
    border-radius: 2px;
}
.rt-slot--custom-cover .rt-slot-label__text { -webkit-line-clamp: 2; }
.rt-slot-manage {
    position: absolute;
    z-index: 3;
    right: -3px;
    bottom: 0;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--rt-shelf-hairline);
    border-radius: 50%;
    background: var(--rt-shelf-paper);
    color: var(--rt-shelf-fg);
    box-shadow: 0 2px 4px var(--rt-shelf-shadow);
    font: inherit;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
}
.rt-slot--empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    font-size: 11px;
    color: #705332;
}
.rt-slot--empty::before {
    content: "";
    position: absolute;
    inset: 18% 14% 15%;
    border: 1px solid rgba(119, 83, 39, 0.27);
    border-radius: 36% 36% 3px 3px / 17% 17% 3px 3px;
    box-shadow: inset 0 0 0 3px rgba(255, 246, 218, 0.17);
    pointer-events: none;
}
.rt-empty-icon { display: block; font-size: 25px; font-weight: 300; line-height: 1; }
.rt-empty-icon svg { width: 20px; height: 20px; }
.rt-slot--empty:hover::before { background: rgba(255, 248, 222, 0.24); }
.rt-slot--empty:active { background: rgba(255, 248, 222, 0.16); }
.rt-shelf button:focus-visible,
.rt-slot-open:focus-visible,
.rt-slot--empty:focus-visible {
    outline: 2px solid var(--rt-shelf-fg);
    outline-offset: 3px;
}
.rt-shelf-head__close:hover,
.rt-slot-manage:hover,
.rt-shelf-import:hover { background: #f0e0bd; }
.rt-shelf-head__close:active,
.rt-slot-manage:active,
.rt-shelf-import:active { transform: translateY(1px); }
.rt-hint {
    flex: none;
    margin: 0;
    padding: 10px max(14px, var(--safe-area-inset-right, 0px)) calc(10px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px))) max(14px, var(--safe-area-inset-left, 0px));
    text-align: center;
    font-size: 10px;
    line-height: 1.8;
    color: var(--rt-shelf-muted);
    background: var(--rt-shelf-paper);
    border-top: 1px solid var(--rt-shelf-hairline);
}
.rt-hint span { display: block; }
@container (max-width: 330px) {
    .rt-shelf-head { padding-inline: 16px; }
    .rt-shelf-head__title { font-size: 22px; }
    .rt-shelf-toolbar { padding-inline: 16px; }
    .rt-slot-label { font-size: 15px; }
    .rt-slot--custom-cover .rt-slot-label { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
    .rt-slot-open { transition: none; }
}

/* 书架：长按书籍后的操作表 */
.rt-shelf-sheet-backdrop {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 12px 14px calc(12px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    background: rgba(30, 40, 46, 0.38);
    box-sizing: border-box;
}

.rt-shelf-sheet-backdrop.is-visible {
    display: flex;
}

.rt-shelf-sheet {
    width: 100%;
    max-width: 340px;
    border-radius: 18px;
    max-height: 80%;
    overflow-y: auto;
    background: var(--rt-shelf-paper, #fbf3e4);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.16);
}

.rt-shelf-sheet__title {
    padding: 14px 16px 8px;
    font-family: var(--rt-shelf-display-font);
    font-size: 16px;
    font-weight: 700;
    color: var(--rt-shelf-fg);
    text-align: center;
    overflow-wrap: anywhere;
}

.rt-shelf-sheet__btn {
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: transparent;
    font-size: 15px;
    font-weight: 600;
    color: var(--rt-shelf-fg, #2c3a42);
    cursor: pointer;
    font-family: inherit;
}

.rt-shelf-sheet__btn:active {
    background: rgba(0, 0, 0, 0.05);
}

.rt-shelf-sheet__btn--danger {
    color: #b33a3a;
}

.rt-shelf-sheet__btn--muted {
    font-weight: 500;
    color: rgba(44, 58, 66, 0.5);
}

/* --- 阅读器 --- */
.rt-reader {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
    position: relative;
    background:
        linear-gradient(180deg, rgba(246, 246, 244, 0.92), rgba(226, 226, 222, 0.94)),
        radial-gradient(circle at 18% 0%, rgba(255, 255, 255, 0.72), transparent 32%);
    color: var(--rt-read-fg, #333333);
}

.rt-reader.is-visible {
    display: flex;
}

.rt-reader[data-rt-theme="hblue"] {
    --rt-read-bg: #f2f2ef;
    --rt-read-fg: #333333;
    --rt-read-title: #242424;
    --rt-read-muted: rgba(51, 51, 51, 0.56);
    --rt-read-accent: #7d8e98;
    --rt-read-highlight: rgba(167, 190, 203, 0.5);
}

.rt-reader[data-rt-theme="dpink"] {
    --rt-read-bg: #f4f1ef;
    --rt-read-fg: #342f2d;
    --rt-read-title: #2b2928;
    --rt-read-muted: rgba(52, 47, 45, 0.56);
    --rt-read-accent: #a08c88;
    --rt-read-highlight: rgba(202, 183, 177, 0.5);
}

.rt-reader[data-rt-theme="mint"] {
    --rt-read-bg: #EDF8F3;
    --rt-read-fg: #2d4a3e;
    --rt-read-title: #1f3329;
    --rt-read-muted: rgba(45, 74, 62, 0.56);
    --rt-read-accent: #A5C4B9;
    --rt-read-highlight: rgba(165, 196, 185, 0.5);
}

.rt-reader[data-rt-theme="lavender"] {
    --rt-read-bg: #DEEDFD;
    --rt-read-fg: #3a4a5e;
    --rt-read-title: #2a3545;
    --rt-read-muted: rgba(58, 74, 94, 0.56);
    --rt-read-accent: #9AB7C9;
    --rt-read-highlight: rgba(154, 183, 201, 0.5);
}

.rt-reader[data-rt-theme="rose"] {
    --rt-read-bg: #FDEDED;
    --rt-read-fg: #4a3a3e;
    --rt-read-title: #3a2a2e;
    --rt-read-muted: rgba(74, 58, 62, 0.56);
    --rt-read-accent: #C99B9A;
    --rt-read-highlight: rgba(201, 155, 154, 0.5);
}

.rt-reader[data-rt-theme="sage"] {
    --rt-read-bg: #D8E6E0;
    --rt-read-fg: #2f4540;
    --rt-read-title: #1f3530;
    --rt-read-muted: rgba(47, 69, 64, 0.56);
    --rt-read-accent: #7a9a8e;
    --rt-read-highlight: rgba(122, 154, 142, 0.5);
}

.rt-topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding:
        calc(8px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))
        max(10px, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))
        8px
        max(10px, var(--safe-area-inset-left, env(safe-area-inset-left, 0px)));
    background: rgba(246, 246, 243, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(42, 42, 42, 0.08);
    /* 高于 Char 悬浮球/台词气泡（z-index 10～11），避免长气泡盖住顶栏按钮 */
    position: relative;
    z-index: 12;
    transition: background-color 0.22s ease, border-color 0.22s ease, opacity 0.22s ease, transform 0.22s ease;
}

.rt-topbar__left,
.rt-topbar__right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.rt-topbar__left,
.rt-topbar__title,
.rt-toc-btn {
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
}

.rt-icon-btn {
    border: 0;
    background: rgba(255, 255, 255, 0.68);
    color: inherit;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(40, 40, 40, 0.08);
}

.rt-toc-btn {
    height: 36px;
    min-width: 48px;
    padding: 0 12px;
    border: 1px solid rgba(40, 40, 40, 0.12);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.42);
    color: var(--rt-read-fg, #333333);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
    -webkit-appearance: none;
    appearance: none;
}

.rt-toc-btn:active {
    transform: scale(0.97);
}

.rt-topbar__title {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--rt-read-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rt-toc-panel {
    position: absolute;
    top: 52px;
    right: 10px;
    width: min(286px, calc(100% - 20px));
    max-height: min(68vh, 430px);
    z-index: 26;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    background: rgba(250, 250, 247, 0.94);
    border: 1px solid rgba(40, 40, 40, 0.08);
    box-shadow: 0 18px 42px rgba(36, 36, 32, 0.18);
    color: var(--rt-read-fg, #333333);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.rt-toc-panel.is-visible {
    display: flex;
}

.rt-toc-panel__head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px 10px;
    border-bottom: 1px solid rgba(40, 40, 40, 0.07);
    font-size: 13px;
    font-weight: 800;
}

.rt-toc-panel__head button {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.05);
    color: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.rt-toc-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 6px;
}

.rt-toc-item {
    width: 100%;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: inherit;
    padding: 10px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.rt-toc-item:active,
.rt-toc-item.is-active {
    background: rgba(125, 142, 152, 0.13);
}

.rt-toc-item__title {
    min-width: 0;
    flex: 1;
    font-size: 13px;
    line-height: 1.45;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rt-toc-item__page {
    flex-shrink: 0;
    min-width: 28px;
    text-align: right;
    font-size: 11px;
    color: var(--rt-read-muted, rgba(51, 51, 51, 0.56));
}

.rt-toc-empty {
    padding: 20px 12px;
    text-align: center;
    font-size: 13px;
    color: var(--rt-read-muted, rgba(51, 51, 51, 0.56));
}

.rt-flip-wrap {
    flex: 1;
    min-height: 0;
    padding:
        12px
        max(14px, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))
        8px
        max(14px, var(--safe-area-inset-left, env(safe-area-inset-left, 0px)));
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.035), transparent 12%, transparent 88%, rgba(0, 0, 0, 0.025)),
        var(--rt-read-bg, #f2f2ef);
}

.rt-flip-sheet {
    height: 100%;
    width: 100%;
    position: relative;
    border-radius: 6px;
    background:
        linear-gradient(90deg, rgba(54, 54, 54, 0.07), transparent 10%, transparent 90%, rgba(255, 255, 255, 0.44)),
        linear-gradient(180deg, #fbfbf8, #f0f0eb);
    box-shadow: 0 14px 32px rgba(36, 36, 32, 0.14), inset 0 0 0 1px rgba(60, 60, 56, 0.08);
    border: 1px solid rgba(70, 70, 64, 0.12);
    overflow: hidden;
}

/* 章末纸页随正文结束，讨论区在纸页之外；外层只在章末允许上下滚动。 */
.rt-flip-wrap.is-chapter-end {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scroll-padding-block: 12px;
}

.rt-flip-wrap.is-chapter-end > .rt-flip-sheet {
    height: auto;
    min-height: min(120px, var(--rt-reader-page-height, 520px));
    max-height: var(--rt-reader-page-height, 520px);
    box-sizing: border-box;
}

.rt-flip-wrap.is-chapter-end > .rt-flip-sheet > .rt-read-scroll:not(.rt-reader-measure) {
    height: auto;
    min-height: inherit;
}

.rt-flip-wrap.is-chapter-end > .rt-flip-sheet > .rt-read-scroll:not(.rt-reader-measure) > .rt-page-body {
    flex: 0 0 auto;
    overflow: visible;
}

/* 短章打开划线点评时恢复整页空间，避免浮层被一两行正文高度挤压。 */
.rt-flip-wrap.is-chapter-end.has-anno-popup > .rt-flip-sheet {
    height: var(--rt-reader-page-height, 520px);
}

.rt-flip-wrap.is-chapter-end.has-anno-popup > .rt-flip-sheet > .rt-read-scroll:not(.rt-reader-measure) {
    height: 100%;
}

.rt-flip-wrap.is-chapter-end.has-anno-popup > .rt-flip-sheet > .rt-read-scroll:not(.rt-reader-measure) > .rt-page-body {
    flex: 1;
    overflow: hidden;
}

.rt-flip-sheet.is-fading-out {
    opacity: 0.18;
    transform: translateY(2px);
    transition: opacity 0.13s ease, transform 0.13s ease;
}

.rt-flip-sheet.is-fading-in {
    animation: rt-page-fade-in 0.28s ease both;
}

@keyframes rt-page-fade-in {
    from { opacity: 0.18; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 方向感知翻页动画：左右模式沿 X 轴滑动，上下模式沿 Y 轴滑动 */
.rt-reader[data-rt-flip-dir="horizontal"] .rt-flip-sheet.is-fading-out[data-turn="next"] {
    transform: translateX(-12px);
}

.rt-reader[data-rt-flip-dir="horizontal"] .rt-flip-sheet.is-fading-out[data-turn="prev"] {
    transform: translateX(12px);
}

.rt-reader[data-rt-flip-dir="vertical"] .rt-flip-sheet.is-fading-out[data-turn="next"] {
    transform: translateY(-12px);
}

.rt-reader[data-rt-flip-dir="vertical"] .rt-flip-sheet.is-fading-out[data-turn="prev"] {
    transform: translateY(12px);
}

.rt-reader[data-rt-flip-dir="horizontal"] .rt-flip-sheet.is-fading-in[data-turn="next"] {
    animation-name: rt-page-in-from-right;
}

.rt-reader[data-rt-flip-dir="horizontal"] .rt-flip-sheet.is-fading-in[data-turn="prev"] {
    animation-name: rt-page-in-from-left;
}

.rt-reader[data-rt-flip-dir="vertical"] .rt-flip-sheet.is-fading-in[data-turn="next"] {
    animation-name: rt-page-in-from-bottom;
}

.rt-reader[data-rt-flip-dir="vertical"] .rt-flip-sheet.is-fading-in[data-turn="prev"] {
    animation-name: rt-page-in-from-top;
}

@keyframes rt-page-in-from-right {
    from { opacity: 0.18; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes rt-page-in-from-left {
    from { opacity: 0.18; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes rt-page-in-from-bottom {
    from { opacity: 0.18; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes rt-page-in-from-top {
    from { opacity: 0.18; transform: translateY(-16px); }
    to { opacity: 1; transform: translateY(0); }
}

.rt-read-scroll {
    height: 100%;
    overflow: hidden;
    padding: 20px 22px 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overscroll-behavior: none;
}

/* 与可见纸页同尺寸的隐藏测量页：分页使用真实字体/字号/安全区，不再猜固定字符数。 */
.rt-reader-measure {
    position: absolute !important;
    inset: 0;
    width: auto !important;
    height: var(--rt-reader-page-height, 100%) !important;
    visibility: hidden !important;
    pointer-events: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    z-index: -1;
}

.rt-chapter-tag {
    flex-shrink: 0;
    font-size: 10px;
    letter-spacing: 0;
    color: var(--rt-read-accent);
    opacity: 0.78;
    margin-bottom: 8px;
    text-align: center;
    font-family: "Times New Roman", "Songti SC", serif;
}

.rt-page-title {
    flex-shrink: 0;
    font-family: var(--rt-font-family, "LoveMiHuiwenMingchao", "Songti SC", "STSong", "Source Han Serif SC", serif);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.45;
    color: var(--rt-read-title);
    margin: 16px 0 22px;
    text-align: center;
    letter-spacing: 0;
}

.rt-page-title.is-hidden {
    display: none;
}

.rt-page-body {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
    font-family: var(--rt-font-family, "LoveMiHuiwenMingchao", "Songti SC", "STSong", "Source Han Serif SC", serif);
    font-size: var(--rt-font-size, 16px);
    line-height: 1.9;
    letter-spacing: 0;
    color: var(--rt-read-fg);
    user-select: text;
    -webkit-user-select: text;
    text-align: justify;
    position: relative;
}

.rt-page-body::selection {
    background: var(--rt-read-highlight);
}

.rt-reader[data-rt-theme="dpink"] .rt-page-body::selection {
    background: var(--rt-read-highlight);
}

.rt-reader[data-rt-theme="mint"] .rt-page-body::selection {
    background: var(--rt-read-highlight);
}

.rt-reader[data-rt-theme="lavender"] .rt-page-body::selection {
    background: var(--rt-read-highlight);
}

.rt-reader[data-rt-theme="rose"] .rt-page-body::selection {
    background: var(--rt-read-highlight);
}

.rt-reader[data-rt-theme="sage"] .rt-page-body::selection {
    background: var(--rt-read-highlight);
}

.rt-anno-list { display: none; }

/* 划线虚线标记 */
.rt-anno-mark {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 8px;
    padding: 3px 8px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--rt-read-accent, #7d8e98);
    font: inherit;
    font-size: 11px;
    line-height: 1.2;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}
.rt-anno-mark::before,
.rt-anno-mark::after {
    content: none;
}
.rt-anno-mark__dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--rt-read-accent, #7d8e98);
    opacity: 0.7;
    flex-shrink: 0;
}

.rt-anno-mark__label {
    font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.rt-anno-highlight {
    padding: 0 0.05em;
    border-radius: 3px;
    background: var(--rt-read-highlight, rgba(167, 190, 203, 0.5));
    color: inherit;
    cursor: pointer;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* 划线评论作为纸页内浮层，不再撑高/滚动正文；仅气泡自身在超长时滚动。 */
.rt-anno-popup {
    position: absolute;
    left: 8px;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    /* 评论展开时高于 Char 头像/台词气泡，保证末行与译文按钮不被遮挡。 */
    z-index: 12;
    margin: 0;
    padding: 10px 13px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.07);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    font-size: 12px;
    line-height: 1.65;
    color: var(--rt-read-fg);
    word-break: break-word;
    animation: rt-popup-in 0.18s ease;
    max-height: calc(100% - 16px);
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: pan-y;
}
.rt-reader[data-rt-theme="dpink"] .rt-anno-popup {
    background: rgba(242, 234, 236, 0.88);
}

.rt-reader[data-rt-theme="mint"] .rt-anno-popup {
    background: rgba(237, 248, 243, 0.88);
}

.rt-reader[data-rt-theme="lavender"] .rt-anno-popup {
    background: rgba(222, 237, 253, 0.88);
}

.rt-reader[data-rt-theme="rose"] .rt-anno-popup {
    background: rgba(253, 237, 237, 0.88);
}

.rt-reader[data-rt-theme="sage"] .rt-anno-popup {
    background: rgba(216, 230, 224, 0.88);
}
@keyframes rt-popup-in {
    from { opacity: 0; transform: translateY(calc(-50% - 4px)); }
    to   { opacity: 1; transform: translateY(-50%); }
}
.rt-anno-popup__quote {
    font-size: 11px;
    color: var(--rt-read-muted);
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px dashed rgba(0,0,0,0.08);
    font-style: italic;
}
.rt-anno-popup__user {
    display: block;
    margin-bottom: 10px;
    cursor: pointer;
}
.rt-anno-popup__char {
    display: block;
    clear: both;
    cursor: pointer;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(0,0,0,0.08);
    padding-left: 8px;
    border-left: 2px solid var(--rt-read-accent, #3d6d84);
}
.rt-anno-popup__char-text {
    display: block;
    line-height: 1.85;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}
.rt-anno-popup__user-text,
.rt-thread-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.rt-anno-popup__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    font-size: 11px;
    color: var(--rt-read-muted);
}
.rt-anno-popup__actions button {
    border: 0;
    background: transparent;
    color: inherit;
    padding: 8px 0 8px 8px;
    font: inherit;
}
.rt-anno-popup__char-text br + br {
    display: block;
    content: "";
    margin-top: 0.55em;
}
.rt-comment-original,
.rt-comment-translation {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    text-align: start;
    line-height: 1.8;
}
.rt-comment-translation {
    margin-block-start: 0.5em;
    padding-block-start: 0.65em;
    border-top: 1px solid var(--rt-read-muted);
    color: var(--rt-read-fg);
    cursor: text;
}
.rt-comment-translation[hidden] {
    display: none;
}
.rt-translation-toggle {
    display: block;
    margin-block-start: 0.4em;
    padding: 0.3em 0.5em;
    min-width: 3em;
    min-height: 3em;
    border: 0;
    border-radius: 0.3em;
    background: transparent;
    color: var(--rt-read-fg);
    font: inherit;
    font-size: 0.85em;
    line-height: 1.4;
    text-align: start;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    cursor: pointer;
    touch-action: manipulation;
}
.rt-translation-toggle:hover {
    background: var(--rt-read-bg);
}
.rt-translation-toggle:active {
    text-decoration-thickness: 0.15em;
}
.rt-translation-toggle:focus-visible,
.rt-comment-original[role="button"]:focus-visible {
    outline: 2px solid var(--rt-read-fg);
    outline-offset: 2px;
}
.rt-anno-popup__who {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.65;
    margin-bottom: 2px;
}

.rt-chapter-board {
    position: relative;
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-width: 0;
    width: 100%;
    height: min(var(--rt-reader-page-height, 520px), max(260px, calc(var(--rt-reader-page-height, 520px) * 0.68)));
    min-height: min(240px, var(--rt-reader-page-height, 520px));
    max-height: var(--rt-reader-page-height, 520px);
    box-sizing: border-box;
    margin-top: 24px;
    padding: 0 8px 8px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--rt-read-fg);
    overflow: hidden;
    font-family: "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.rt-chapter-board[hidden] {
    display: none;
}

.rt-chapter-board__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex: 0 0 auto;
    min-width: 0;
    gap: 12px;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.5;
    padding-bottom: 10px;
    color: var(--rt-read-title);
}

.rt-chapter-board__count {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 400;
    color: var(--rt-read-fg);
}

.rt-thread {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scrollbar-width: thin;
    padding: 0 4px 8px 0;
    margin-bottom: 10px;
    scroll-padding-block: 8px;
}

#rt-overlay-root .rt-thread {
    scrollbar-width: thin;
    scrollbar-color: var(--rt-read-muted) transparent;
}

#rt-overlay-root .rt-thread::-webkit-scrollbar {
    display: block !important;
    width: 4px !important;
}

#rt-overlay-root .rt-thread::-webkit-scrollbar-thumb {
    background: var(--rt-read-muted);
    border-radius: 4px;
}

.rt-thread-floor {
    min-width: 0;
    padding-block: 12px;
}

.rt-thread-floor:first-child {
    padding-top: 0;
}

.rt-thread-floor + .rt-thread-floor {
    border-top: 1px solid var(--rt-read-muted);
}

.rt-thread-replies {
    margin: 10px 0 0 10px;
    padding-inline-start: 12px;
    border-inline-start: 1px solid var(--rt-read-muted);
    min-width: 0;
}

.rt-thread-replies > .rt-thread-msg + .rt-thread-msg {
    margin-top: 16px;
}

.rt-thread-empty {
    margin: 0;
    padding: 16px 0 24px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--rt-read-fg);
}

.rt-thread-msg {
    cursor: pointer;
    touch-action: pan-y;
    min-width: 0;
    font-size: 14px;
    line-height: 1.7;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    overflow-wrap: anywhere;
    text-align: start;
}
.rt-thread-quote {
    margin-bottom: 6px;
    padding-inline-start: 8px;
    border-inline-start: 2px solid var(--rt-read-muted);
    font-size: 12px;
    color: var(--rt-read-fg);
    overflow-wrap: anywhere;
}
.rt-thread-reply:not([hidden]) {
    position: relative;
    flex: 0 0 auto;
    min-width: 0;
    min-height: 28px;
    box-sizing: border-box;
    padding: 5px 8px;
    margin-bottom: 8px;
    border-inline-start: 2px solid var(--rt-read-accent);
    border-radius: 0;
    background: var(--rt-read-highlight);
    color: var(--rt-read-title);
    font-size: 12px;
    line-height: 1.5;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rt-thread-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 6px;
    color: var(--rt-read-fg);
}

.rt-thread-meta__name {
    min-width: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.rt-thread-meta__floor {
    flex: 0 0 auto;
    font-size: 11px;
}

.rt-thread-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 4px;
}

.rt-thread-actions button {
    min-height: 28px;
    min-width: 28px;
    padding: 3px 4px;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: var(--rt-read-fg);
    font: inherit;
    font-size: 12px;
    line-height: 1.5;
    cursor: pointer;
    touch-action: manipulation;
}

.rt-thread-actions button:hover {
    background: var(--rt-read-highlight);
}

.rt-thread-actions button:active {
    text-decoration: underline;
}

.rt-thread-actions button:disabled {
    opacity: 0.55;
    cursor: default;
}

.rt-thread-actions button:focus-visible,
.rt-thread-reply:focus-visible,
.rt-thread:focus-visible,
.rt-thread-input-row button:focus-visible,
.rt-thread-input-row textarea:focus-visible,
.rt-thread-input-row input:focus-visible {
    outline: 2px solid var(--rt-read-fg);
    outline-offset: 2px;
}

.rt-thread-input-row {
    display: flex;
    flex: 0 0 auto;
    min-width: 0;
    gap: 8px;
    align-items: flex-end;
}

.rt-thread-input-row input,
.rt-thread-input-row textarea {
    display: block;
    min-width: 0;
    width: 100%;
    flex: 1;
    box-sizing: border-box;
    min-height: 56px;
    max-height: 100px;
    border: 1px solid var(--rt-read-muted);
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    font-size: 16px;
    line-height: 1.4;
    background: var(--rt-read-bg);
    color: var(--rt-read-fg);
    resize: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.rt-thread-input-row textarea::placeholder,
.rt-thread-input-row input::placeholder {
    color: var(--rt-read-fg);
    opacity: 0.7;
}

.rt-thread-input-row textarea:disabled,
.rt-thread-input-row input:disabled {
    opacity: 0.6;
}

.rt-thread-input-row textarea[aria-invalid="true"],
.rt-thread-input-row input[aria-invalid="true"] {
    border-width: 2px;
}

.rt-thread-input-row button {
    flex: 0 0 auto;
    min-height: 44px;
    min-width: 52px;
    border: 0;
    border-radius: 8px;
    padding: 9px 12px;
    font: inherit;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 600;
    background: var(--rt-read-fg);
    color: var(--rt-read-bg);
    cursor: pointer;
    touch-action: manipulation;
}

.rt-thread-input-row button:hover {
    background: var(--rt-read-title);
}

.rt-thread-input-row button:active {
    transform: translateY(1px);
}

.rt-thread-input-row button:disabled {
    opacity: 0.55;
    cursor: default;
}

.rt-thread-input-row button[aria-busy="true"] {
    opacity: 1;
    cursor: progress;
}

.rt-bottom-nav {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding:
        10px
        max(14px, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))
        calc(10px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))
        max(14px, var(--safe-area-inset-left, env(safe-area-inset-left, 0px)));
    background: rgba(246, 246, 243, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(42, 42, 42, 0.08);
    position: relative;
    z-index: 12;
    transition: opacity 0.22s ease, visibility 0.22s ease, transform 0.22s ease;
}

.rt-bottom-nav button {
    flex: 1;
    border: 0;
    border-radius: 8px;
    padding: 11px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.68);
    color: inherit;
    box-shadow: inset 0 0 0 1px rgba(40, 40, 40, 0.08);
}

.rt-bottom-nav button:disabled {
    opacity: 0.4;
}

.rt-bottom-nav__hint {
    font-size: 11px;
    text-align: center;
    color: var(--rt-read-muted);
    flex: 1.2;
}

/* --- 邀请好友 --- */
.rt-invite-panel {
    position: absolute;
    inset: 0;
    background: rgba(233, 238, 242, 0.96);
    z-index: 25;
    display: none;
    flex-direction: column;
    min-height: 0;
}

.rt-invite-panel.is-visible {
    display: flex;
}

.rt-invite-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.5);
}

.rt-invite-list {
    flex: 1;
    overflow: auto;
    padding: 12px;
}

.rt-invite-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
    margin-bottom: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.rt-invite-ava {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.06) center/cover;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.rt-invite-meta {
    flex: 1;
    min-width: 0;
}

.rt-invite-name {
    font-size: 14px;
    font-weight: 600;
}

.rt-invite-bar {
    flex-shrink: 0;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    background: rgba(255, 255, 255, 0.55);
}

.rt-invite-bar button {
    border: 0;
    border-radius: 12px;
    padding: 11px 18px;
    font-weight: 700;
    cursor: pointer;
}

.rt-invite-bar button[data-act="cancel"] {
    background: rgba(0, 0, 0, 0.07);
    color: inherit;
}

.rt-invite-bar button[data-act="send"] {
    background: #3d6d84;
    color: #fff;
}

/* --- 备注弹层 --- */
.rt-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 25;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.rt-modal-backdrop.is-visible {
    display: flex;
}

.rt-modal {
    width: 100%;
    max-width: 320px;
    max-height: 85%;
    overflow-y: auto;
    box-sizing: border-box;
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}
.rt-modal [data-rt-modal-quote] {
    max-height: 24vh;
    overflow-y: auto;
    overflow-wrap: anywhere;
}

.rt-modal h3 {
    margin: 0 0 8px;
    font-size: 15px;
}

.rt-modal textarea {
    width: 100%;
    min-height: 72px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    padding: 10px;
    font-size: 14px;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
}

.rt-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}

.rt-modal-actions button {
    border: 0;
    border-radius: 10px;
    padding: 9px 14px;
    font-weight: 600;
    cursor: pointer;
}

.rt-modal-actions button[data-act="ok"] {
    background: #3d6d84;
    color: #fff;
}

/* --- 微信 · 一起看书邀请卡片 --- */
#chat-page .chat-message .chat-message-bubble.chat-message-bubble--rt-invite {
    overflow: visible !important;
}

.chat-rt-invite-card {
    width: 100%;
    max-width: 236px;
    border-radius: 18px;
    padding: 12px 14px 12px;
    background: linear-gradient(180deg, #e3edf2 0%, #f5f9fb 100%);
    border: 1px solid rgba(61, 109, 132, 0.22);
    box-shadow: 0 8px 22px rgba(61, 109, 132, 0.1);
    color: #243338;
}

.chat-rt-invite-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.chat-rt-invite-tag {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(61, 109, 132, 0.2);
    color: #2c5870;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.chat-rt-invite-chip {
    display: inline-flex;
    align-items: center;
    height: 20px;
    padding: 0 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.chat-rt-invite-chip--pending {
    background: rgba(255, 255, 255, 0.72);
    color: #5a6d78;
}

.chat-rt-invite-chip--accept {
    background: rgba(78, 168, 122, 0.18);
    color: #2f7c54;
}

.chat-rt-invite-chip--reject {
    background: rgba(155, 116, 130, 0.16);
    color: #7a5564;
}

.chat-rt-invite-title {
    font-size: clamp(13px, 3.9vw, 15px);
    line-height: 1.4;
    font-weight: 700;
    color: #243338;
    margin-bottom: 6px;
}

.chat-rt-invite-body {
    font-size: 12px;
    line-height: 1.55;
    color: #3d4f59;
    word-break: break-word;
}

.chat-rt-invite-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.chat-rt-invite-actions button {
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid rgba(80,80,80,.16);
    border-radius: 10px;
    background: rgba(255,255,255,.65);
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.chat-rt-invite-actions button:disabled { opacity: .5; cursor: default; }
.chat-rt-invite-sub {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(61, 109, 132, 0.2);
    font-size: 11px;
    line-height: 1.5;
    color: #5a6d78;
}

/* --- Char 悬浮球 --- */
.rt-char-ball {
    position: absolute;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: #fff center/cover no-repeat;
    box-shadow: 0 3px 12px rgba(0,0,0,0.18);
    border: 2px solid rgba(255,255,255,0.9);
    cursor: pointer;
    z-index: 10;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: opacity 0.35s ease, box-shadow 0.15s;
    opacity: 1;
}
.rt-char-ball.rt-char-ball--idle {
    opacity: 0.75;
}
.rt-char-ball:active {
    box-shadow: 0 5px 18px rgba(0,0,0,0.28);
}
.rt-char-ball--loading {
    box-shadow: 0 5px 18px rgba(61, 109, 132, 0.28), 0 0 0 4px rgba(255,255,255,0.32);
}
.rt-char-ball-loading {
    position: absolute;
    left: 50%;
    top: -24px;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 42px;
    height: 20px;
    padding: 0 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(61, 109, 132, 0.18);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.14);
    pointer-events: none;
    z-index: 2;
}
.rt-char-ball-loading::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -4px;
    width: 8px;
    height: 8px;
    margin-left: -4px;
    background: rgba(255, 255, 255, 0.94);
    border-right: 1px solid rgba(61, 109, 132, 0.16);
    border-bottom: 1px solid rgba(61, 109, 132, 0.16);
    transform: rotate(45deg);
}
.rt-char-ball-loading span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--rt-read-accent, #3d6d84);
    opacity: 0.35;
    animation: rt-char-loading-dot 0.9s infinite ease-in-out;
}
.rt-char-ball-loading span:nth-child(2) {
    animation-delay: 0.15s;
}
.rt-char-ball-loading span:nth-child(3) {
    animation-delay: 0.3s;
}
@keyframes rt-char-loading-dot {
    0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
    .rt-char-ball-loading span {
        animation: none;
        opacity: 0.82;
    }
}

/* --- Char 情绪气泡（台词可较长：加宽 + 必要时内部纵向滚动，避免被 200px 宽挤成无限高裁切） --- */
.rt-char-bubble {
    box-sizing: border-box;
    position: absolute;
    max-width: min(272px, calc(100% - 44px));
    max-height: min(46vh, 360px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 9px 12px;
    border-radius: 16px 16px 4px 16px;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
    border: 1px solid rgba(0,0,0,0.07);
    font-size: 13px;
    line-height: 1.6;
    color: #2a3338;
    z-index: 11;
    cursor: default;
    word-break: break-word;
    white-space: pre-wrap;
    overscroll-behavior: contain;
    animation: rt-bubble-in 0.22s ease;
    opacity: 1;
    transition: opacity 0.28s ease, box-shadow 0.2s ease;
}
.rt-char-bubble.rt-char-bubble--dimmed {
    opacity: 0.6;
}
.rt-reader[data-rt-theme="dpink"] .rt-char-bubble {
    border-color: rgba(154,102,116,0.18);
}

.rt-reader[data-rt-theme="mint"] .rt-char-bubble {
    border-color: rgba(165,196,185,0.18);
}

.rt-reader[data-rt-theme="lavender"] .rt-char-bubble {
    border-color: rgba(154,183,201,0.18);
}

.rt-reader[data-rt-theme="rose"] .rt-char-bubble {
    border-color: rgba(201,155,154,0.18);
}

.rt-reader[data-rt-theme="sage"] .rt-char-bubble {
    border-color: rgba(122,154,142,0.18);
}

/* --- 阅读设置面板（配色 / 字体 / 字号 / 翻页） --- */
.rt-icon-btn--settings {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

/* --- 全屏阅读：工具栏覆盖纸页，显隐不改变分页尺寸 --- */
.rt-reader.is-immersive .rt-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 24;
}

.rt-reader.is-immersive .rt-bottom-nav {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 24;
}

.rt-reader.is-immersive .rt-flip-wrap {
    padding:
        calc(10px + var(--safe-area-inset-top, env(safe-area-inset-top, 0px)))
        max(10px, var(--safe-area-inset-right, env(safe-area-inset-right, 0px)))
        calc(10px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)))
        max(10px, var(--safe-area-inset-left, env(safe-area-inset-left, 0px)));
}

/* 沉浸模式导航覆盖阅读区，章末保留底部滚动余量使输入框始终可移到导航上方。 */
.rt-reader.is-immersive .rt-chapter-board {
    margin-bottom: 64px;
}

.rt-reader.is-immersive.is-controls-hidden .rt-topbar {
    background: transparent;
    border-bottom-color: transparent;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
}

.rt-reader.is-immersive.is-controls-hidden .rt-topbar__left,
.rt-reader.is-immersive.is-controls-hidden .rt-topbar__title,
.rt-reader.is-immersive.is-controls-hidden .rt-toc-btn {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-7px);
    pointer-events: none;
}

.rt-reader.is-immersive.is-controls-hidden .rt-topbar__right {
    margin-left: auto;
    pointer-events: none;
}

.rt-reader.is-immersive.is-controls-hidden .rt-icon-btn--settings {
    width: 44px;
    height: 44px;
    opacity: 0.46;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.52);
    box-shadow:
        0 4px 16px rgba(24, 31, 35, 0.12),
        inset 0 0 0 1px rgba(40, 40, 40, 0.08);
}

.rt-reader.is-immersive.is-controls-hidden .rt-icon-btn--settings:active {
    opacity: 0.78;
    transform: scale(0.96);
}

.rt-reader.is-immersive.is-controls-hidden .rt-bottom-nav {
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    pointer-events: none;
}

.rt-reader.is-immersive.is-controls-hidden .rt-settings-panel,
.rt-reader.is-immersive.is-controls-hidden .rt-toc-panel {
    display: none !important;
}

/* 字体方案：通过 data-rt-font 切换正文与标题字族 */
.rt-reader[data-rt-font="keben"] {
    --rt-font-family: "RtFontKeBen", "LoveMiHuiwenMingchao", "Songti SC", "STSong", "Source Han Serif SC", serif;
}

.rt-reader[data-rt-font="kaiti"] {
    --rt-font-family: "RtFontKaiTi", "Kaiti SC", "STKaiti", "KaiTi", "LoveMiHuiwenMingchao", serif;
}

.rt-reader[data-rt-font="songke"] {
    --rt-font-family: "RtFontSongKe", "LoveMiHuiwenMingchao", "Songti SC", "STSong", "Source Han Serif SC", serif;
}

.rt-reader[data-rt-font="user"] {
    --rt-font-family: "RtThemeUserFont", "ThemeUserFont", "LoveMiHuiwenMingchao", "Songti SC", "STSong", serif;
}

.rt-settings-panel {
    position: absolute;
    top: 52px;
    right: 10px;
    width: min(276px, calc(100% - 20px));
    max-height: min(72vh, 480px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: none;
    flex-direction: column;
    gap: 13px;
    padding: 14px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.97);
    border-radius: 16px;
    border: 1px solid rgba(40, 40, 40, 0.08);
    box-shadow: 0 14px 34px rgba(31, 41, 51, 0.2);
    z-index: 30;
    color: #33393e;
}

.rt-settings-panel.is-visible {
    display: flex;
}
.rt-set-bubble-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
    font-size: 13px;
}
.rt-set-bubble-row span { white-space: nowrap; }
.rt-set-bubble-row input {
    width: 64px;
    padding: 8px;
    border: 1px solid rgba(40,40,40,.16);
    border-radius: 8px;
    color: inherit;
    background: rgba(255,255,255,.8);
    font: inherit;
    text-align: center;
}

.rt-fullscreen-toggle {
    width: 100%;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid rgba(40, 40, 40, 0.1);
    border-radius: 12px;
    background: rgba(247, 248, 249, 0.9);
    color: inherit;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.rt-fullscreen-toggle.is-active {
    background: rgba(61, 109, 132, 0.12);
    border-color: rgba(61, 109, 132, 0.32);
}

.rt-fullscreen-toggle__icon {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: rgba(61, 109, 132, 0.1);
    color: #3d6d84;
    font-size: 20px;
    line-height: 1;
}

.rt-fullscreen-toggle__copy {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rt-fullscreen-toggle__copy strong {
    font-size: 13px;
    line-height: 1.3;
}

.rt-fullscreen-toggle__copy small {
    font-size: 10px;
    line-height: 1.35;
    color: rgba(51, 57, 62, 0.58);
}

.rt-fullscreen-toggle__status {
    flex-shrink: 0;
    font-size: 10px;
    color: rgba(51, 57, 62, 0.58);
}

.rt-fullscreen-toggle.is-active .rt-fullscreen-toggle__status {
    color: #3d6d84;
    font-weight: 700;
}

.rt-set-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rt-set-group + .rt-set-group {
    border-top: 1px solid rgba(40, 40, 40, 0.07);
    padding-top: 11px;
}

.rt-set-group__title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: rgba(51, 57, 62, 0.55);
}

.rt-set-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 4px;
}

.rt-set-swatch {
    flex: 0 0 calc(33.33% - 3px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 7px 2px 6px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    box-sizing: border-box;
}

.rt-set-swatch__name {
    font-size: 10px;
    line-height: 1;
    color: rgba(51, 57, 62, 0.72);
}

.rt-set-swatch.is-active {
    background: rgba(61, 109, 132, 0.1);
    border-color: rgba(61, 109, 132, 0.28);
}

.rt-set-swatch.is-active .rt-set-swatch__name {
    font-weight: 700;
    color: #33556a;
}

.rt-set-fonts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rt-set-font-btn {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
    padding: 8px 6px;
    border: 1px solid rgba(40, 40, 40, 0.12);
    border-radius: 10px;
    background: rgba(250, 250, 249, 0.9);
    font-size: 12px;
    color: #3a4148;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.rt-set-font-btn.is-active {
    background: rgba(61, 109, 132, 0.12);
    border-color: rgba(61, 109, 132, 0.4);
    color: #2c4b5e;
    font-weight: 700;
}

.rt-set-font-btn.is-unavailable {
    opacity: 0.48;
}

.rt-set-size-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rt-set-size-row__label {
    font-size: 12px;
    color: rgba(51, 57, 62, 0.72);
}

.rt-set-size-btn {
    width: 44px;
    height: 32px;
    border: 1px solid rgba(40, 40, 40, 0.12);
    border-radius: 9px;
    background: rgba(250, 250, 249, 0.9);
    font-size: 13px;
    font-weight: 700;
    color: #3a4148;
    cursor: pointer;
    font-family: inherit;
}

.rt-set-size-btn:active {
    background: rgba(61, 109, 132, 0.12);
}

.rt-set-size-val {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: #2c4b5e;
}

.rt-set-seg {
    display: flex;
    gap: 0;
    border: 1px solid rgba(40, 40, 40, 0.12);
    border-radius: 10px;
    overflow: hidden;
}

.rt-set-seg button {
    flex: 1;
    padding: 8px 4px;
    border: 0;
    background: rgba(250, 250, 249, 0.9);
    font-size: 12px;
    color: #3a4148;
    cursor: pointer;
    font-family: inherit;
}

.rt-set-seg button + button {
    border-left: 1px solid rgba(40, 40, 40, 0.1);
}

.rt-set-seg button.is-active {
    background: rgba(61, 109, 132, 0.85);
    color: #fff;
    font-weight: 700;
}

.rt-set-hint {
    font-size: 11px;
    line-height: 1.55;
    color: rgba(51, 57, 62, 0.6);
    margin: 0;
}

/* --- 配色圆点（设置面板内复用） --- */
.rt-theme-circle {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.rt-theme-circle::before,
.rt-theme-circle::after {
    content: '';
    position: absolute;
    width: 50%;
    height: 100%;
    top: 0;
}

.rt-theme-circle::before {
    left: 0;
}

.rt-theme-circle::after {
    right: 0;
}

/* 各配色方案的圆形显示 */
.rt-theme-circle[data-theme="hblue"]::before {
    background: #f2f2ef;
}
.rt-theme-circle[data-theme="hblue"]::after {
    background: #7d8e98;
}

.rt-theme-circle[data-theme="dpink"]::before {
    background: #f4f1ef;
}
.rt-theme-circle[data-theme="dpink"]::after {
    background: #a08c88;
}

.rt-theme-circle[data-theme="mint"]::before {
    background: #EDF8F3;
}
.rt-theme-circle[data-theme="mint"]::after {
    background: #A5C4B9;
}

.rt-theme-circle[data-theme="lavender"]::before {
    background: #DEEDFD;
}
.rt-theme-circle[data-theme="lavender"]::after {
    background: #9AB7C9;
}

.rt-theme-circle[data-theme="rose"]::before {
    background: #FDEDED;
}
.rt-theme-circle[data-theme="rose"]::after {
    background: #C99B9A;
}

.rt-theme-circle[data-theme="sage"]::before {
    background: #D8E6E0;
}
.rt-theme-circle[data-theme="sage"]::after {
    background: #7a9a8e;
}

/* 划线评论：Char 回复前缀为好友备注/昵称，不再展示模型 attitude 标签 */
.rt-anno-char-who {
    font-weight: 600;
    color: var(--rt-read-title);
    margin-right: 2px;
}
@keyframes rt-bubble-in {
    from { opacity: 0; transform: scale(0.85) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- 阅读正文排版优化 --- */
.rt-page-body p {
    margin: 0 0 0.82em;
    text-indent: 2em;
    break-inside: avoid;
}
.rt-page-body p:last-child {
    margin-bottom: 0;
}

/* Char 头像快捷菜单 · 换书弹层 */
.rt-char-quick-menu {
    position: absolute;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
    padding: 8px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
    border: 1px solid rgba(0, 0, 0, 0.06);
}
.rt-char-quick-item {
    border: none;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    background: rgba(61, 109, 132, 0.08);
    color: #2a3f4a;
}
.rt-char-quick-item:active {
    opacity: 0.88;
}
.rt-book-pick-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(20, 28, 36, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.rt-book-pick-panel {
    width: 100%;
    max-width: 320px;
    max-height: 85%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.rt-book-pick-title {
    margin: 0;
    padding: 14px 16px 6px;
    font-size: 16px;
    font-weight: 700;
    color: #1e2a30;
}
.rt-book-pick-hint {
    margin: 0;
    padding: 0 16px 10px;
    font-size: 12px;
    line-height: 1.45;
    color: #5a6d78;
}
.rt-book-pick-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 10px;
    -webkit-overflow-scrolling: touch;
}
.rt-book-pick-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 8px;
    border-radius: 10px;
    margin-bottom: 6px;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.06);
}
.rt-book-pick-row:hover {
    background: rgba(61, 109, 132, 0.06);
}
.rt-book-pick-row-txt {
    font-size: 13px;
    line-height: 1.45;
    color: #2a3338;
    flex: 1;
}
.rt-book-pick-actions {
    display: flex;
    gap: 10px;
    padding: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.rt-book-pick-actions button {
    flex: 1;
    padding: 10px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.rt-book-pick-cancel {
    background: rgba(0, 0, 0, 0.06);
    color: #333;
}
.rt-book-pick-ok {
    background: linear-gradient(135deg, #5a8ca8, #3d6d84);
    color: #fff;
}

/* 矮屏/横屏压缩固定装饰，把可用高度优先留给正文；分页测量页同步继承。 */
@media (max-height: 600px) {
    .rt-read-scroll {
        padding: 12px 14px 10px;
    }

    .rt-chapter-tag {
        margin-bottom: 4px;
    }

    .rt-page-title {
        margin: 7px 0 11px;
        font-size: 20px;
        line-height: 1.35;
    }

    .rt-chapter-board {
        margin-top: 16px;
        padding-inline: 4px;
    }

    .rt-chapter-board__head {
        padding-bottom: 8px;
    }

    .rt-thread {
        margin-bottom: 8px;
    }

    .rt-thread-replies {
        margin-inline-start: 6px;
        padding-inline-start: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rt-topbar,
    .rt-bottom-nav,
    .rt-topbar__left,
    .rt-topbar__title,
    .rt-toc-btn,
    .rt-flip-sheet,
    .rt-anno-popup {
        transition: none !important;
        animation: none !important;
    }
}
