#readTogetherReaderScreen.v27-reader {
    --v27-ink: #3f4246;
    --v27-muted: #777b80;
    --v27-line: rgba(63, 66, 70, 0.22);
    --v27-paper: #f6f4ec;
    background: var(--v27-paper) !important;
    overflow: hidden;
    isolation: isolate;
}

#readTogetherReaderScreen.v27-reader .v27-reader-shell {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: clamp(92px, 16.667vh, 150px) minmax(0, 1fr) max(104px, calc(88px + env(safe-area-inset-bottom)));
    color: var(--v27-ink);
    background: inherit;
    overflow: hidden;
}

.v27-reader-top {
    position: relative;
    min-height: 0;
    z-index: 8;
}

.v27-reader-book-title {
    position: absolute;
    top: max(13px, env(safe-area-inset-top));
    left: 50%;
    max-width: 46%;
    transform: translateX(-50%);
    overflow: hidden;
    color: var(--v27-muted);
    font-size: 11px;
    line-height: 22px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.v27-reader-exit,
.v27-reader-history {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
}

.v27-reader-exit { right: 58px; }
.v27-reader-history { right: 12px; }

.v27-icon-button {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 38px;
    border: 1px solid var(--v27-line);
    border-radius: 50%;
    color: var(--v27-ink);
    background: rgba(255, 255, 255, 0.18);
    box-shadow: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.v27-icon-button:active,
.v27-icon-button.is-active {
    background: rgba(63, 66, 70, 0.1);
    transform: scale(0.96);
}

.v27-icon-button[disabled] {
    opacity: 0.28;
    pointer-events: none;
}

.v27-companion-stage {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    left: 12px;
    width: 40px;
    min-height: 44px;
    touch-action: none;
    z-index: 12;
}

.v27-companion-avatar {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--v27-line);
    border-radius: 50%;
    color: var(--v27-ink);
    background: rgba(255,255,255,0.72) center/cover no-repeat;
    font-size: 14px;
    touch-action: none;
    cursor: grab;
}

@keyframes v27-spin { to { transform: rotate(360deg); } }

.v27-avatar-loader {
    position: absolute;
    top: 45px;
    left: 13px;
    width: 14px;
    height: 14px;
    display: none;
    border: 2px solid rgba(63, 66, 70, 0.18);
    border-top-color: rgba(63, 66, 70, 0.78);
    border-radius: 50%;
    animation: v27-spin 0.75s linear infinite;
    pointer-events: none;
}

.v27-avatar-loader.show { display: block; }

.v27-companion-bubble {
    position: absolute;
    top: 1px;
    left: 48px;
    width: calc(100vw - 68px);
    min-width: 160px;
    max-width: calc(100vw - 16px);
    min-height: 72px;
    max-height: min(38vh, 250px);
    display: none;
    flex-direction: column;
    border: 1px solid var(--v27-line);
    border-radius: 8px;
    color: var(--v27-ink);
    background: rgba(255,255,255,0.92);
    box-shadow: 0 5px 18px rgba(20,20,20,0.08);
    touch-action: none;
}

.v27-companion-bubble.show { display: flex; }

.v27-companion-bubble::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 12px;
    width: 8px;
    height: 8px;
    border-left: 1px solid var(--v27-line);
    border-bottom: 1px solid var(--v27-line);
    background: rgba(255,255,255,0.92);
    transform: rotate(45deg);
}

.v27-companion-stage.bubble-left .v27-companion-bubble {
    left: auto;
    right: calc(100% - 32px);
}

.v27-companion-stage.bubble-left .v27-companion-bubble::before {
    left: auto;
    right: -5px;
    border-left: 0;
    border-bottom: 0;
    border-top: 1px solid var(--v27-line);
    border-right: 1px solid var(--v27-line);
}

.v27-bubble-text {
    min-height: 42px;
    padding: 10px 11px 7px;
    overflow: auto;
    color: inherit;
    font-size: 12px;
    line-height: 1.55;
    white-space: pre-wrap;
    user-select: text;
    -webkit-user-select: text;
}

.v27-bubble-meta {
    display: none;
}

.v27-bubble-actions {
    height: 30px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    border-top: 1px solid rgba(63,66,70,0.1);
}

.v27-bubble-action {
    width: 25px;
    height: 25px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    color: var(--v27-ink);
    background: transparent;
    font-size: 14px;
}

.v27-voice-button {
    position: relative;
    overflow: visible;
}

.v27-voice-button:disabled { opacity: 1; }

.v27-voice-spinner {
    width: 14px;
    height: 14px;
    display: none;
    border: 2px solid rgba(63, 66, 70, 0.18);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: v27-spin 0.72s linear infinite;
}

.v27-voice-icon {
    display: inline-block;
    position: relative;
    width: 17px;
    height: 17px;
}
.v27-voice-icon > i { display: block; font-size: 17px; line-height: 17px; }
.v27-voice-reveal {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 17px;
    height: 17px;
    overflow: hidden;
    clip-path: circle(25px at left bottom);
    -webkit-clip-path: circle(25px at left bottom);
    will-change: clip-path;
}
.v27-voice-reveal > i {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    line-height: 17px;
}
.v27-voice-button.is-loading .v27-voice-spinner { display: block; }
.v27-voice-button.is-loading .v27-voice-icon { display: none; }
.v27-voice-button.is-playing .v27-voice-icon { display: none; }
.v27-voice-button.is-playing .v27-reader-voice-wave-icon { display: block; }
.v27-voice-button.is-playing .v27-reader-voice-wave-icon .guajiguaji-chat-voice-wave-reveal {
    animation: guajiguaji-chat-voice-sweep 0.62s ease-in-out infinite;
}

@keyframes v27-original-voice-sweep {
    0%, 18% { clip-path: circle(6.5px at left bottom); -webkit-clip-path: circle(6.5px at left bottom); }
    40%, 54% { clip-path: circle(12px at left bottom); -webkit-clip-path: circle(12px at left bottom); }
    76%, 90% { clip-path: circle(25px at left bottom); -webkit-clip-path: circle(25px at left bottom); }
    100% { clip-path: circle(6.5px at left bottom); -webkit-clip-path: circle(6.5px at left bottom); }
}

/* Persistent TTS button: slightly overlaps each received text bubble. */
.message.received .message-content { position: relative; }

.guajiguaji-chat-voice-button {
    position: absolute;
    top: -3px;
    right: -3px;
    z-index: 4;
    width: 23px;
    height: 20px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    border: 1px solid rgba(60, 60, 67, 0.1);
    border-radius: 8px 8px 3px 8px;
    color: var(--text-color, #333);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.09);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.guajiguaji-chat-voice-button:disabled { opacity: 1; }
.guajiguaji-chat-voice-button .v27-voice-spinner { width: 11px; height: 11px; border-width: 1.5px; }
.guajiguaji-chat-voice-play-icon { display: block; font-size: 14px; line-height: 1; }
.guajiguaji-chat-voice-wave-icon {
    display: none;
    position: relative;
    width: 16px;
    height: 16px;
    overflow: hidden;
}
.guajiguaji-chat-voice-wave-reveal {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 6px;
    height: 6px;
    overflow: hidden;
    border-radius: 0 100% 0 0;
    will-change: width, height;
}
.guajiguaji-chat-voice-wave-reveal > i {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 16px;
}
.guajiguaji-chat-voice-button.is-loading .guajiguaji-chat-voice-play-icon,
.guajiguaji-chat-voice-button.is-playing .guajiguaji-chat-voice-play-icon { display: none; }
.guajiguaji-chat-voice-button.is-loading .v27-voice-spinner { display: block; }
.guajiguaji-chat-voice-button.is-playing .guajiguaji-chat-voice-wave-icon {
    display: block;
}
.guajiguaji-chat-voice-button.is-playing .guajiguaji-chat-voice-wave-reveal {
    animation: guajiguaji-chat-voice-sweep 0.62s ease-in-out infinite;
}

@keyframes guajiguaji-chat-voice-sweep {
    0%, 10% {
        width: 6px;
        height: 6px;
    }
    32% {
        width: 12px;
        height: 12px;
    }
    58%, 78% {
        width: 25px;
        height: 25px;
    }
    100% {
        width: 6px;
        height: 6px;
    }
}

.wechat-dark-mode .guajiguaji-chat-voice-button {
    color: #f2f2f2;
    background: rgba(58, 58, 60, 0.96);
    border-color: rgba(255, 255, 255, 0.12);
}

.v27-auto-button {
    width: auto;
    min-width: 42px;
    padding: 0 5px;
    gap: 2px;
    border-radius: 14px;
    font-size: 8px;
    letter-spacing: 0;
}

.v27-auto-button i { font-size: 10px; }
.v27-auto-button.is-active { background: rgba(63,66,70,0.1); }

.v27-bubble-resize {
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    color: rgba(63,66,70,0.45);
    font-size: 12px;
    cursor: nwse-resize;
    touch-action: none;
}

.v27-reader-page {
    min-height: 0;
    padding: 0 clamp(24px, 8vw, 46px);
    display: flex;
    align-items: stretch;
    overflow: hidden;
}

#readTogetherReaderScreen.v27-reader #readerContent {
    width: 100%;
    height: 100%;
    padding: 0 !important;
    overflow: hidden !important;
    color: #333;
    background: transparent !important;
    background-size: cover;
    background-position: center;
    font-family: "Noto Serif SC", serif;
    font-size: 18px;
    line-height: 1.85;
    text-align: justify;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: text;
    -webkit-user-select: text;
    touch-action: none;
}

.v27-reader-bottom {
    position: relative;
    min-height: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0 18px max(14px, env(safe-area-inset-bottom));
}

.v27-page-indicator {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--v27-muted);
    font-size: 10px;
    white-space: nowrap;
}

.v27-reader-toolbar {
    width: min(100%, 330px);
    display: grid;
    grid-template-columns: 42px 1fr 58px 42px 1fr 42px;
    align-items: center;
    justify-items: center;
}

.v27-record-button {
    width: 56px;
    height: 56px;
    flex-basis: 56px;
    border-width: 1.5px;
    font-size: 25px;
    touch-action: manipulation;
}

.v27-reply-composer {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: max(78px, calc(64px + env(safe-area-inset-bottom)));
    z-index: 30;
    padding: 8px;
    display: none;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--v27-line);
    border-radius: 8px;
    background: rgba(255,255,255,0.97);
    box-shadow: 0 6px 24px rgba(20,20,20,0.12);
}

.v27-reply-composer.show { display: flex; }

.v27-reply-input {
    min-width: 0;
    flex: 1;
    padding: 7px 4px;
    border: 0;
    outline: 0;
    color: var(--v27-ink);
    background: transparent;
    font-size: 14px;
    user-select: text;
    -webkit-user-select: text;
}

.v27-history-drawer {
    position: absolute;
    inset: 0 0 0 auto;
    width: min(88%, 380px);
    z-index: 50;
    display: flex;
    flex-direction: column;
    color: var(--v27-ink);
    background: rgba(250,250,248,0.98);
    border-left: 1px solid var(--v27-line);
    transform: translateX(102%);
    transition: transform 0.22s ease;
}

.v27-history-drawer.show { transform: translateX(0); }

.v27-history-header {
    height: 58px;
    padding: max(10px, env(safe-area-inset-top)) 12px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    border-bottom: 1px solid rgba(63,66,70,0.1);
    font-size: 14px;
}

.v27-history-list {
    min-height: 0;
    padding: 12px;
    flex: 1;
    overflow-y: auto;
}

.v27-history-empty {
    padding: 42px 12px;
    color: var(--v27-muted);
    font-size: 12px;
    text-align: center;
}

.v27-history-item {
    position: relative;
    margin-bottom: 13px;
    padding: 10px 39px 10px 11px;
    border-left: 2px solid rgba(63,66,70,0.22);
    background: rgba(63,66,70,0.035);
    font-size: 12px;
    line-height: 1.6;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.v27-history-item.user { border-left-style: dashed; }
.v27-history-item-role { margin-bottom: 3px; color: var(--v27-muted); font-size: 9px; }
.v27-history-play { position: absolute; top: 8px; right: 6px; }

.v27-history-modal,
.v27-history-action-sheet {
    position: absolute;
    inset: 0;
    z-index: 72;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(20, 22, 24, 0.28);
}

.v27-history-modal.show,
.v27-history-action-sheet.show { display: flex; }

.v27-history-modal-card {
    width: min(100%, 330px);
    padding: 16px;
    border: 1px solid rgba(63,66,70,0.16);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(20,20,20,0.14);
}

.v27-history-modal-title {
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 600;
}

.v27-history-modal-card label {
    min-height: 39px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(63,66,70,0.08);
    font-size: 12px;
}

.v27-history-modal-card input[type="color"] {
    width: 42px;
    height: 27px;
    padding: 1px;
    border: 1px solid rgba(63,66,70,0.18);
    border-radius: 4px;
    background: transparent;
}

#v27HistoryEditInput {
    width: 100%;
    min-height: 132px;
    padding: 10px;
    resize: vertical;
    border: 1px solid rgba(63,66,70,0.18);
    border-radius: 6px;
    outline: 0;
    color: var(--v27-ink);
    background: #fafafa;
    font: inherit;
    font-size: 13px;
    line-height: 1.6;
}

.v27-history-modal-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.v27-history-modal-actions button,
.v27-history-action-sheet button {
    min-height: 36px;
    padding: 0 15px;
    border: 1px solid rgba(63,66,70,0.14);
    border-radius: 6px;
    color: var(--v27-ink);
    background: #f8f8f7;
    font-size: 12px;
}

.v27-history-modal-actions button:last-child {
    color: #fff;
    border-color: #3f4246;
    background: #3f4246;
}

.v27-history-action-sheet {
    align-items: flex-end;
    flex-direction: column;
    justify-content: flex-end;
    gap: 7px;
    padding-bottom: max(18px, env(safe-area-inset-bottom));
}

.v27-history-action-sheet button {
    width: min(100%, 330px);
    min-height: 44px;
    background: #fff;
}

.v27-history-action-sheet button.danger { color: #b42318; }

.v27-toast {
    position: absolute;
    left: 50%;
    bottom: 95px;
    z-index: 80;
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 6px;
    color: #fff;
    background: rgba(35,37,39,0.82);
    font-size: 11px;
    line-height: 1.45;
    text-align: center;
    transform: translateX(-50%);
    pointer-events: none;
}

#readTogetherReaderScreen.v27-reader #readerSettingsPanel {
    z-index: 60;
}

#readTogetherReaderScreen.v27-reader #readerSettingsPanel .setting-row:has(#btnModeScroll),
#readTogetherReaderScreen.v27-reader #readerSettingsPanel .setting-row:has(#pageSizeInput) {
    display: none !important;
}

body.v27-modal-open { overflow: hidden; }

#readTogetherReaderScreen.v27-reader #readerSettingsPanel {
    position: fixed;
}

.v27-bubble-resize { display: none; }

@media (max-height: 560px) {
    #readTogetherReaderScreen.v27-reader .v27-reader-shell {
        grid-template-rows: 76px minmax(0, 1fr) max(90px, calc(76px + env(safe-area-inset-bottom)));
    }
    .v27-companion-stage { width: 36px; }
    .v27-companion-avatar { width: 36px; height: 36px; }
    .v27-companion-bubble { left: 44px; }
    .v27-record-button { width: 50px; height: 50px; flex-basis: 50px; }
}
