* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --text-color: #2c2c2c;
    --bg-color: #fdfbf7;
    --muted-color: #888;
    --border-color: #e0ddd5;
    --highlight-color: #f5f0e6;
    --font-serif: 'EB Garamond', Georgia, serif;
    --font-size-body: 1.2rem;
    --line-height: 1.7;
    --column-gap: 4rem;
    --page-padding: 3rem;
    --gutter-width: clamp(2.5rem, 6vw, 6rem);
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-serif);
    font-size: var(--font-size-body);
    line-height: var(--line-height);
    color: var(--text-color);
    background-color: var(--bg-color);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.view {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Library View */
#library-view {
    padding: var(--page-padding);
    overflow-y: auto;
}

.library-container {
    max-width: 760px;
    margin: 0 auto;
    width: 100%;
}

.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
}

.site-logo {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    display: block;
    object-fit: contain;
}

.library-site-logo {
    width: auto;
    height: clamp(3rem, 8vw, 5rem);
    max-width: 42%;
}

.site-wordmark {
    font-size: 1rem;
    letter-spacing: 0.04em;
    color: #252b43;
    font-weight: 600;
    white-space: nowrap;
}

.library-brand {
    display: flex;
    width: 100%;
    justify-content: flex-start;
    gap: 0.85rem;
    margin-bottom: 0.35rem;
}

.library-wordmark {
    font-size: clamp(1.8rem, 5.2vw, 3rem);
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 0.95;
    color: #1f243c;
    white-space: nowrap;
}

.library-title {
    font-size: 2.5rem;
    font-weight: 400;
    margin-bottom: 1.5rem;
    letter-spacing: 0.02em;
    text-align: center;
}

.library-subtitle {
    text-align: center;
    color: var(--muted-color);
    margin-bottom: 1.5rem;
    font-size: 1.02rem;
}

.library-account-row {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
}

.library-account-status {
    font-size: 0.82rem;
    color: var(--muted-color);
}

.library-search-container {
    position: relative;
    margin-bottom: 2rem;
}

.library-search {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-left: 2.5rem;
    padding-right: 6.75rem;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: transparent;
    color: var(--text-color);
    transition: border-color 0.2s;
}

.library-search:focus {
    outline: none;
    border-color: var(--muted-color);
}

.library-search::placeholder {
    color: var(--muted-color);
}

.library-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-color);
    pointer-events: none;
}

.library-search-submit {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: #fff;
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: 0.88rem;
    padding: 0.26rem 0.82rem;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, opacity 0.2s;
}

.library-search-submit:hover {
    background: var(--highlight-color);
}

.library-search-submit:disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

.library-search-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: -1.15rem;
    margin-bottom: 1.15rem;
    color: var(--muted-color);
    font-size: 0.84rem;
}

.library-search-status::before {
    content: '';
    width: 0.72rem;
    height: 0.72rem;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    border-top-color: var(--muted-color);
    animation: librarySearchSpin 0.8s linear infinite;
}

#library-search-error {
    margin: -0.35rem 0 1rem;
}

.library-search-container.is-loading .library-search {
    border-color: var(--muted-color);
}

.book-list.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

@keyframes librarySearchSpin {
    to {
        transform: rotate(360deg);
    }
}

.section-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.section-title-row .section-title {
    margin-bottom: 0;
}

.classroom-banner {
    margin: -0.2rem 0 1.15rem;
    border: 1px solid #c7c0ae;
    border-radius: 8px;
    background: #f7f2e6;
    padding: 0.7rem 0.85rem;
}

.classroom-label {
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6b5b37;
}

.classroom-feature-summary {
    margin-top: 0.22rem;
    font-size: 0.83rem;
    color: #6a6558;
}

.classroom-assignments-label {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6a6558;
}

.classroom-assignments-empty {
    margin-top: 0.6rem;
    font-size: 0.84rem;
    color: var(--muted-color);
}

.book-item-assignment-label {
    margin-top: 0.24rem;
    font-size: 0.76rem;
    color: #6f603f;
}

.book-progress-chip.assignment-due {
    border-color: #c8b37a;
    color: #6a5328;
    background: #f8efd8;
}

.book-progress-chip.assignment-due.overdue {
    border-color: #cf8f84;
    color: #7f372c;
    background: #fde9e5;
}

.book-progress-chip.assignment-quiz-required {
    border-color: #cf9d95;
    color: #7f372c;
    background: #fdecea;
}

.book-progress-chip.assignment-quiz-complete {
    border-color: #9cc3a8;
    color: #2f6f44;
    background: #eef7ef;
}

.book-progress-chip.assignment-quiz-unknown {
    border-color: #c2c7cd;
    color: #55606a;
    background: #f2f4f6;
}

.library-section {
    margin-bottom: 2rem;
}

.achievements-summary {
    color: var(--muted-color);
    font-size: 0.9rem;
    margin-bottom: 0.58rem;
}

.achievements-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.achievement-item {
    border: 1px solid #d7c6a0;
    border-radius: 10px;
    background: #fbf4e4;
    color: #57472b;
    min-width: 0;
    text-align: left;
    padding: 0.42rem 0.56rem;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.achievement-item:hover {
    border-color: #b89e62;
    background: #f6edd9;
}

.achievements-view-all {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: transparent;
    color: var(--muted-color);
    font-family: var(--font-serif);
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.14rem 0.52rem;
    cursor: pointer;
}

.achievements-view-all:hover {
    color: var(--text-color);
    background: var(--highlight-color);
    border-color: var(--muted-color);
}

.achievement-title {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.achievement-meta {
    display: block;
    font-size: 0.72rem;
    color: #7c6d52;
    margin-top: 0.12rem;
}

.book-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.book-item {
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
    background: rgba(255, 255, 255, 0.46);
}

.book-item:hover {
    background-color: var(--highlight-color);
    border-color: var(--muted-color);
}

.book-item-title {
    font-size: 1.15rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.book-item-title-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    justify-content: space-between;
}

.book-item-title-row .book-item-title {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}

.book-item-favorite-btn {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: transparent;
    color: var(--muted-color);
    font-family: var(--font-serif);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.14rem 0.52rem;
    cursor: pointer;
    white-space: nowrap;
}

.book-item-favorite-btn:hover {
    border-color: #9a8a5c;
    color: #5f5336;
    background: #f8f1de;
}

.book-item-favorite-btn.active {
    border-color: #b6a069;
    color: #5c4e2f;
    background: #f5ecd3;
}

.book-item-author {
    font-size: 0.95rem;
    color: var(--muted-color);
    font-style: italic;
}

.book-item-progress {
    margin-top: 0.4rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.book-progress-chip {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.08rem 0.46rem;
    font-size: 0.66rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted-color);
    background: rgba(255, 255, 255, 0.7);
}

.book-progress-chip-status.status-in-progress {
    color: #5c4e2f;
    border-color: #c6b185;
    background: #f7eed9;
}

.book-progress-chip-status.status-completed {
    color: #2f6f44;
    border-color: #9cc3a8;
    background: #eef7ef;
}

.book-progress-chip-status.status-not-started {
    color: #5f6469;
    border-color: #c7ccd1;
    background: #f2f4f6;
}

.book-item-meta {
    margin-top: 0.28rem;
    font-size: 0.82rem;
    color: var(--muted-color);
}

.book-item-discover-reason {
    margin-top: 0.34rem;
    font-size: 0.78rem;
    color: #5f5336;
    background: rgba(246, 238, 221, 0.82);
    border: 1px solid #d6c7a1;
    border-radius: 6px;
    padding: 0.2rem 0.46rem;
    display: inline-block;
}

.book-item-badge {
    display: inline-block;
    margin-left: 0.48rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    vertical-align: middle;
    color: var(--text-color);
}

#continue-reading .book-item {
    border-color: #c4b89f;
    box-shadow: 0 5px 18px rgba(96, 80, 43, 0.08);
}

.no-results {
    text-align: center;
    color: var(--muted-color);
    font-style: italic;
    padding: 2rem;
}

.library-catalog-mode-badge {
    margin-top: 1.2rem;
    text-align: right;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    color: #b5b5b5;
    text-transform: lowercase;
}

/* Reader View */
#reader-view {
    padding: var(--page-padding);
    padding-top: 1rem;
    padding-bottom: 1rem;
    touch-action: manipulation;
}

.reader-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
    flex-shrink: 0;
    overflow: visible;
    position: relative;
}

.reader-brand {
    flex-shrink: 0;
}

.back-to-library-link {
    text-decoration: none;
    color: inherit;
    border-radius: 6px;
}

.back-to-library-link:hover {
    background: var(--highlight-color);
}

.back-to-library-link:focus-visible {
    outline: 1px solid var(--muted-color);
    outline-offset: 2px;
}

.reader-site-logo {
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 4px;
}

.reader-wordmark {
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

.mobile-header-menu {
    display: flex;
    position: relative;
}

.mobile-header-menu-toggle {
    border: 1px solid var(--border-color);
}

.mobile-header-menu-panel {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    width: min(280px, calc(100vw - 2rem));
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
    padding: 0.35rem;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mobile-header-menu-row {
    display: flex;
    align-items: stretch;
    gap: 0.3rem;
}

.mobile-header-menu-search {
    display: none;
    align-items: center;
    gap: 0.35rem;
    padding-bottom: 0.15rem;
}

#speed-reading-container.header-mobile-action,
.annotation-menu.header-mobile-action {
    display: none;
}

/* Keep these quick reading actions in the desktop header. */
.reader-header .tts-container.header-mobile-action,
.reader-header .character-container.header-mobile-action {
    display: flex;
}

/* Keep account/list actions in the hamburger menu instead of the desktop header. */
.reader-header #favorite-toggle,
.reader-header #account-toggle {
    display: none;
}

.mobile-header-menu-search-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: 0.9rem;
    padding: 0.46rem 0.58rem;
}

.mobile-header-menu-search-input:focus {
    outline: none;
    border-color: var(--muted-color);
}

.mobile-header-menu-search-btn {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--highlight-color);
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: 0.82rem;
    line-height: 1.1;
    padding: 0.46rem 0.62rem;
    white-space: nowrap;
    cursor: pointer;
}

.mobile-header-menu-search-btn:hover {
    background: var(--bg-color);
}

.mobile-header-menu-item {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: 0.88rem;
    text-align: left;
    padding: 0.42rem 0.5rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
}

.mobile-header-menu-item-primary {
    flex: 1;
}

.mobile-header-menu-item:hover {
    background: var(--highlight-color);
}

.mobile-header-menu-item:focus-visible,
.mobile-header-menu-speed-btn:focus-visible,
.mobile-header-menu-search-btn:focus-visible {
    outline: 1px solid var(--muted-color);
    outline-offset: 1px;
    background: var(--highlight-color);
}

.mobile-header-menu-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.mobile-header-menu-item[data-shortcut]::after {
    content: attr(data-shortcut);
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    color: var(--muted-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 0.04rem 0.36rem;
    background: #fff;
    white-space: nowrap;
}

.mobile-header-menu-speed-btn {
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: 0.82rem;
    min-width: 4.4rem;
    padding: 0.42rem 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    cursor: pointer;
}

.mobile-header-menu-speed-btn:hover {
    background: var(--highlight-color);
}

.mobile-header-menu-speed-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.cache-only-indicator {
    margin-left: 0;
    font-size: 0.66rem;
    letter-spacing: 0.02em;
    color: #999;
    opacity: 0.9;
}

.recap-enable-btn {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.74rem;
    letter-spacing: 0.02em;
}

.auth-toggle {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.74rem;
    letter-spacing: 0.02em;
    min-width: 5rem;
}

.favorite-toggle {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.74rem;
    letter-spacing: 0.02em;
    min-width: 7.2rem;
}

.favorite-toggle.saved {
    color: #5c4e2f;
    border-color: #b6a069;
    background: #f5ecd3;
}

.auth-toggle.authenticated {
    color: #2f6f44;
    border-color: #9cc3a8;
    background: #eef7ef;
}

#reader-view.speed-reading-active .reader-content,
#reader-view.speed-reading-active .chapter-title,
#reader-view.speed-reading-active .reader-footer {
    display: none;
}

#reader-view.speed-reading-active .reader-gutter {
    display: none;
}

.header-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-color);
    padding: 0.5rem;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
}

.header-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.header-btn:hover {
    color: var(--text-color);
    background-color: var(--highlight-color);
}

.header-btn.active {
    color: var(--text-color);
    background-color: var(--highlight-color);
}

.annotation-menu {
    position: relative;
}

.annotation-menu-panel {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    min-width: 220px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
    padding: 0.35rem;
    z-index: 220;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.annotation-action-btn {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
}

.annotation-action-btn:hover {
    background: var(--highlight-color);
}

.annotation-action-btn.active {
    background: var(--highlight-color);
    color: var(--text-color);
}

.annotation-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.annotation-action-btn kbd {
    margin: 0;
}

.book-meta {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(34rem, 42vw);
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    align-items: center;
    text-align: center;
    pointer-events: none;
}

.book-title {
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1.2;
    padding-bottom: 0.08em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.book-author {
    font-size: 0.82rem;
    color: var(--muted-color);
    font-style: italic;
    line-height: 1.2;
    padding-bottom: 0.08em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.header-right-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.search-container {
    position: relative;
    width: 2.15rem;
    transition: width 0.2s ease;
}

.search-container.expanded {
    width: 200px;
}

.search-toggle {
    position: absolute;
    left: 0.18rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.8rem;
    height: 1.8rem;
    border: none;
    background: transparent;
    color: var(--muted-color);
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
    z-index: 1;
}

.search-toggle:hover {
    color: var(--text-color);
    background: var(--highlight-color);
}

.search-toggle:focus-visible {
    outline: 1px solid var(--muted-color);
    outline-offset: 1px;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    padding-left: 2rem;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: transparent;
    color: var(--text-color);
    transition: border-color 0.2s, opacity 0.15s;
}

.search-container:not(.expanded) .search-input {
    opacity: 0;
    pointer-events: none;
    border-color: transparent;
    color: transparent;
    caret-color: transparent;
}

.search-container.expanded .search-input {
    opacity: 1;
    pointer-events: auto;
}

.search-input:focus {
    outline: none;
    border-color: var(--muted-color);
}

.search-input::placeholder {
    color: var(--muted-color);
}

.search-icon {
    position: absolute;
    left: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-color);
    pointer-events: none;
}

.reader-settings-menu {
    position: relative;
}

.reader-settings-panel {
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    width: 240px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.14);
    padding: 0.55rem;
    z-index: 220;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.reader-settings-title {
    font-size: 0.82rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted-color);
}

.reader-settings-field {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    column-gap: 0.5rem;
    row-gap: 0.3rem;
}

.reader-settings-field label {
    font-size: 0.9rem;
}

.reader-settings-value {
    font-size: 0.78rem;
    color: var(--muted-color);
}

.reader-settings-range {
    grid-column: 1 / 3;
    width: 100%;
    accent-color: #8f8571;
}

.reader-settings-select {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: 0.86rem;
    padding: 0.2rem 0.35rem;
}

.reader-settings-reset {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--muted-color);
    border-radius: 999px;
    padding: 0.24rem 0.7rem;
    font-family: var(--font-serif);
    font-size: 0.82rem;
    cursor: pointer;
    align-self: flex-start;
}

.reader-settings-reset:hover {
    color: var(--text-color);
    background: var(--highlight-color);
}

.search-results {
    position: absolute;
    top: 80px;
    left: var(--page-padding);
    right: var(--page-padding);
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    max-height: 300px;
    overflow: hidden;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.search-results-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
}

.search-results-toolbar label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-color);
}

.search-results-filter {
    margin-left: auto;
    max-width: 70%;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: 0.86rem;
    padding: 0.18rem 0.35rem;
}

.search-results-list {
    overflow-y: auto;
    max-height: 248px;
}

.search-group-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-color);
    padding: 0.55rem 0.9rem 0.25rem;
    border-top: 1px solid var(--border-color);
}

.search-group:first-child .search-group-title {
    border-top: none;
}

.search-result-empty {
    padding: 0.9rem 1rem;
    color: var(--muted-color);
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: var(--highlight-color);
}

.search-result-chapter {
    font-size: 0.85rem;
    color: var(--muted-color);
    margin-bottom: 0.25rem;
}

.search-result-snippet {
    font-size: 0.95rem;
}

.search-result-snippet mark {
    background-color: #fff3cd;
    padding: 0 2px;
}

.inline-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.5rem 0.75rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid #e6b7b0;
    border-radius: 6px;
    background: #fff2ef;
    color: #7e3328;
    font-size: 0.84rem;
    line-height: 1.35;
}

.inline-error span {
    flex: 1;
    min-width: 0;
}

.inline-error-btn {
    border: 1px solid #d6a49d;
    border-radius: 999px;
    background: #fff;
    color: #7e3328;
    font-family: var(--font-serif);
    font-size: 0.8rem;
    padding: 0.22rem 0.72rem;
    cursor: pointer;
    white-space: nowrap;
}

.inline-error-btn:hover {
    background: #fde7e3;
}

.chapter-title {
    font-size: 1.5rem;
    font-weight: 400;
    text-align: center;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
}

/* Two-column reading area */
.reader-stage {
    flex: 1;
    display: flex;
    min-height: 0;
}

.reader-gutter {
    width: var(--gutter-width);
    border: none;
    background: linear-gradient(90deg, rgba(245, 240, 230, 0.65), rgba(245, 240, 230, 0));
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s, opacity 0.2s;
}

.reader-gutter-left {
    background: linear-gradient(90deg, rgba(245, 240, 230, 0.65), rgba(245, 240, 230, 0));
}

.reader-gutter-right {
    background: linear-gradient(270deg, rgba(245, 240, 230, 0.65), rgba(245, 240, 230, 0));
}

.reader-gutter:hover,
.reader-gutter:focus-visible {
    background-color: var(--highlight-color);
    outline: none;
}

.reader-gutter:active {
    opacity: 0.8;
}

.reader-content {
    flex: 1;
    display: flex;
    gap: var(--column-gap);
    overflow: hidden;
    min-height: 0;
}

.column {
    flex: 1;
    overflow: hidden;
}

.paragraph {
    text-indent: 1.5em;
    margin-bottom: 0;
    text-align: justify;
    hyphens: auto;
    cursor: pointer;
    position: relative;
}

.paragraph:first-child {
    text-indent: 0;
}

.paragraph.highlighted {
    background-color: var(--highlight-color);
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding: 0.25rem 0.5rem;
    border-radius: 2px;
}

.paragraph.search-match {
    box-shadow: inset 0 0 0 1px rgba(143, 133, 113, 0.35);
}

.paragraph mark.search-hit {
    background: #ffe4a8;
    padding: 0 0.08em;
    border-radius: 2px;
}

.paragraph.annotation-highlight {
    background-color: rgba(247, 224, 146, 0.25);
    border-radius: 2px;
}

.paragraph.annotation-bookmarked::before {
    content: '';
    position: absolute;
    top: 0.35rem;
    left: -0.65rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #b5741f;
}

.paragraph.annotation-noted {
    text-decoration: underline;
    text-decoration-style: dashed;
    text-decoration-color: rgba(80, 80, 80, 0.6);
    text-underline-offset: 0.15em;
}

/* Footer */
.reader-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
    flex-shrink: 0;
}

.reader-footer-left {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.mobile-layout-hint {
    font-size: 0.78rem;
    color: var(--muted-color);
    letter-spacing: 0.01em;
}

.footer-icon-btn {
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--muted-color);
    border-radius: 6px;
    cursor: pointer;
    padding: 0.35rem 0.45rem;
    line-height: 1;
    transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

.footer-icon-btn:hover {
    color: var(--text-color);
    border-color: var(--muted-color);
    background: var(--highlight-color);
}

.mobile-reader-nav {
    display: none;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(0.5rem + env(safe-area-inset-bottom));
    width: min(720px, calc(100vw - 1rem));
    padding: 0.4rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: rgba(253, 251, 247, 0.96);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
    z-index: 900;
    flex-direction: column;
    gap: 0.35rem;
}

.mobile-reader-nav-row {
    display: grid;
    gap: 0.35rem;
}

.mobile-reader-nav-row-chapter {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mobile-reader-nav-row-reading {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mobile-reader-nav-btn {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: 0.84rem;
    padding: 0.42rem 0.32rem;
    min-height: 2.05rem;
    cursor: pointer;
    touch-action: manipulation;
}

.mobile-reader-nav-btn:active {
    background: var(--highlight-color);
}

.mobile-reader-nav-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

kbd {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    font-family: var(--font-serif);
    font-size: 0.75rem;
    background-color: var(--highlight-color);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    margin: 0 0.1rem;
}

.page-indicator {
    font-size: 0.85rem;
    color: var(--muted-color);
}

/* No content message */
.no-content {
    text-align: center;
    color: var(--muted-color);
    font-style: italic;
    margin-top: 2rem;
}

/* Imported badge */
.imported-badge {
    display: inline-block;
    margin-left: 0.5rem;
    color: #5a8f5a;
    font-size: 0.9em;
}

.book-item.imported {
    border-color: #c5dfc5;
}

/* Importing overlay */
#importing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(253, 251, 247, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

#importing-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.importing-message {
    font-size: 1.3rem;
    color: var(--text-color);
    font-style: italic;
}

.importing-message::after {
    content: '';
    animation: ellipsis 1.5s infinite;
}

@keyframes ellipsis {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* Chapter recap overlay */
.chapter-recap-overlay {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chapter-recap-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(14, 13, 10, 0.52);
}

.chapter-recap-card {
    position: relative;
    width: min(640px, 92vw);
    max-height: 86vh;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.2);
    padding: 1.25rem 1.4rem 1.35rem;
    display: flex;
    flex-direction: column;
}

.chapter-recap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.chapter-recap-header h3 {
    font-size: 1.25rem;
    font-weight: 500;
}

.chapter-recap-close {
    border: none;
    background: transparent;
    color: var(--muted-color);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem 0.35rem;
}

.chapter-recap-close:hover {
    color: var(--text-color);
}

.chapter-recap-chapter-title {
    color: var(--muted-color);
    font-size: 0.86rem;
    margin-bottom: 0.4rem;
}

.chapter-recap-tabs {
    display: flex;
    gap: 0.45rem;
    margin-bottom: 0.7rem;
}

.chapter-recap-tab {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: transparent;
    color: var(--muted-color);
    font-size: 0.84rem;
    padding: 0.35rem 0.8rem;
    cursor: pointer;
}

.chapter-recap-tab.active {
    background: var(--text-color);
    border-color: var(--text-color);
    color: var(--bg-color);
}

.chapter-recap-tab.unavailable {
    opacity: 0.7;
}

.chapter-recap-panel {
    min-height: 190px;
}

.chapter-recap-scroll-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.15rem;
}

.chapter-recap-status {
    font-size: 0.82rem;
    color: var(--muted-color);
    margin-bottom: 0.65rem;
}

.chapter-recap-summary {
    font-size: 1rem;
    line-height: 1.55;
    margin-bottom: 0.9rem;
}

.chapter-recap-section {
    margin-bottom: 0.85rem;
}

.chapter-recap-section h4 {
    font-size: 0.86rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-color);
    margin-bottom: 0.35rem;
}

.chapter-recap-list {
    margin: 0;
    padding-left: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.chapter-recap-optout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
    font-size: 0.85rem;
    color: var(--muted-color);
}

.chapter-recap-chat {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.chapter-recap-chat-status {
    font-size: 0.8rem;
    color: var(--muted-color);
    margin-bottom: 0.4rem;
}

.chapter-recap-chat-messages {
    min-height: 98px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
}

.chapter-recap-chat .chat-message {
    font-size: 0.9rem;
    line-height: 1.45;
}

.chapter-recap-chat-empty {
    font-size: 0.85rem;
    color: var(--muted-color);
}

.chapter-recap-chat-input-container {
    margin-top: 0.55rem;
    padding: 0;
    border-top: none;
}

.chapter-recap-chat-input-container textarea {
    min-height: 58px;
    font-size: 0.9rem;
}

.chapter-recap-quiz h4 {
    margin-bottom: 0.35rem;
}

.chapter-quiz-status {
    font-size: 0.8rem;
    color: var(--muted-color);
    margin-bottom: 0.6rem;
}

.chapter-quiz-questions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chapter-quiz-question {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    background: #fff;
}

.chapter-quiz-question-title {
    font-size: 0.92rem;
    margin-bottom: 0.45rem;
}

.chapter-quiz-options {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.38rem;
    list-style: none;
}

.chapter-quiz-options label {
    display: flex;
    gap: 0.45rem;
    align-items: flex-start;
    font-size: 0.88rem;
    line-height: 1.35;
    color: var(--text-color);
}

.chapter-quiz-submit {
    margin-top: 0.7rem;
}

.chapter-quiz-feedback {
    margin-top: 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    background: #fff;
}

.chapter-quiz-feedback-score {
    font-size: 0.88rem;
    margin-bottom: 0.45rem;
}

.chapter-quiz-feedback-meta {
    font-size: 0.8rem;
    color: var(--muted-color);
    margin-bottom: 0.5rem;
}

.chapter-quiz-trophies {
    font-size: 0.84rem;
    margin-bottom: 0.55rem;
}

.chapter-quiz-feedback-list {
    margin: 0;
    padding-left: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.84rem;
}

.chapter-recap-actions {
    margin-top: 1.05rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.55rem;
}

.chapter-recap-btn {
    border-radius: 999px;
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
}

.chapter-recap-btn-primary {
    background: var(--text-color);
    border-color: var(--text-color);
    color: var(--bg-color);
}

.chapter-recap-btn-secondary {
    background: transparent;
    color: var(--text-color);
}

/* Collaborator auth modal */
.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 9, 7, 0.5);
}

.auth-modal-card {
    position: relative;
    width: min(420px, 92vw);
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
    padding: 1rem 1.1rem 1.1rem;
}

.auth-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
}

.auth-modal-header h3 {
    font-size: 1.16rem;
    font-weight: 500;
}

.auth-modal-close {
    border: none;
    background: transparent;
    font-size: 1.45rem;
    line-height: 1;
    color: var(--muted-color);
    cursor: pointer;
    padding: 0.2rem 0.35rem;
}

.auth-modal-help {
    color: var(--muted-color);
    font-size: 0.84rem;
    margin-bottom: 0.6rem;
}

.auth-modal-status {
    min-height: 1.35rem;
    font-size: 0.84rem;
    color: var(--muted-color);
    margin-bottom: 0.45rem;
}

.auth-modal-status.error {
    color: #8f2f2f;
}

.auth-modal-status.success {
    color: #2f6f44;
}

.auth-modal-label {
    display: block;
    font-size: 0.84rem;
    margin-bottom: 0.3rem;
}

.auth-modal-input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.56rem 0.68rem;
    font-family: var(--font-serif);
    font-size: 0.96rem;
    background: #fff;
    margin-bottom: 0.8rem;
}

.auth-modal-input:focus {
    outline: none;
    border-color: var(--muted-color);
}

.auth-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.achievements-modal-card {
    width: min(560px, 92vw);
    max-height: 82vh;
    display: flex;
    flex-direction: column;
}

.achievements-modal-list {
    margin-top: 0.3rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    max-height: 58vh;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.45);
}

.achievements-modal-item {
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    text-align: left;
    padding: 0.62rem 0.72rem;
    color: var(--text-color);
    cursor: pointer;
}

.achievements-modal-item:last-child {
    border-bottom: none;
}

.achievements-modal-item:hover {
    background: var(--highlight-color);
}

.achievements-modal-item-title {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
}

.achievements-modal-item-subtitle {
    display: block;
    margin-top: 0.16rem;
    color: var(--muted-color);
    font-size: 0.78rem;
}

/* Chapter list overlay */
.chapter-list-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(253, 251, 247, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.chapter-list-container {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 90%;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
}

.chapter-list-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.chapter-list-header h3 {
    font-size: 1.3rem;
    font-weight: 500;
    margin: 0 0 0.25rem 0;
}

.chapter-list-hint {
    font-size: 0.8rem;
    color: var(--muted-color);
}

.chapter-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    overflow-y: auto;
    flex: 1;
}

.chapter-list-item {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: background-color 0.15s;
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.chapter-list-item:hover {
    background-color: var(--highlight-color);
}

.chapter-list-item.selected {
    background-color: var(--highlight-color);
}

.chapter-list-item.current {
    font-weight: 500;
}

.chapter-list-item.current::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--text-color);
    border-radius: 50%;
    margin-right: 0.5rem;
}

.chapter-number {
    color: var(--muted-color);
    font-size: 0.85rem;
    min-width: 2rem;
}

.chapter-name {
    flex: 1;
}

.shortcuts-container {
    max-width: 560px;
}

.shortcuts-list {
    padding: 0.75rem 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.shortcut-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.92rem;
    padding: 0.42rem 0.35rem;
    border-bottom: 1px solid rgba(224, 221, 213, 0.55);
}

.shortcut-row:last-child {
    border-bottom: none;
}

.shortcut-row span:last-child {
    color: var(--muted-color);
}

.bookmarks-list-container {
    max-width: 720px;
}

.bookmark-list {
    padding: 0.5rem 0;
}

.bookmark-list-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
}

.bookmark-item-top {
    display: flex;
    gap: 0.6rem;
    align-items: baseline;
}

.bookmark-item-snippet {
    font-size: 0.9rem;
    color: var(--muted-color);
    line-height: 1.35;
    padding-left: 2.65rem;
}

.bookmark-list-empty {
    padding: 1rem 1.5rem;
    color: var(--muted-color);
    font-style: italic;
}

.app-toast-region {
    position: fixed;
    right: 1.1rem;
    bottom: 1.1rem;
    z-index: 1700;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    pointer-events: none;
}

.app-toast {
    width: min(420px, calc(100vw - 2.2rem));
    background: var(--bg-color);
    border: 1px solid #d6cbc0;
    border-left: 4px solid #7e3328;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.17);
    padding: 0.72rem 0.82rem;
    pointer-events: auto;
    animation: appToastIn 0.22s ease;
}

.app-toast.fade-out {
    opacity: 0;
    transform: translateX(16px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.app-toast-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.22rem;
}

.app-toast-title {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #7e3328;
}

.app-toast-close {
    border: none;
    background: transparent;
    color: #9a8e7d;
    cursor: pointer;
    line-height: 1;
    font-size: 1rem;
    padding: 0.1rem 0.2rem;
}

.app-toast-close:hover {
    color: var(--text-color);
}

.app-toast-message {
    font-size: 0.92rem;
    line-height: 1.4;
    color: var(--text-color);
}

.app-toast-detail {
    margin-top: 0.42rem;
    border-top: 1px dashed var(--border-color);
    padding-top: 0.4rem;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--muted-color);
    overflow-wrap: anywhere;
}

.app-toast-actions {
    margin-top: 0.5rem;
}

.app-toast-action {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: #fff;
    color: var(--text-color);
    font-family: var(--font-serif);
    font-size: 0.84rem;
    padding: 0.24rem 0.85rem;
    cursor: pointer;
}

.app-toast-action:hover {
    background: var(--highlight-color);
}

@keyframes appToastIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Voice notification */
.voice-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 1rem 1.25rem;
    max-width: 350px;
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

.voice-notification-content {
    font-size: 0.9rem;
    line-height: 1.5;
}

.voice-notification-content strong {
    color: var(--text-color);
}

.voice-notification-content small {
    color: var(--muted-color);
    display: block;
    margin-top: 0.25rem;
}

.voice-notification.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* TTS container and speed indicator */
.tts-container {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
}

.speed-reading-container {
    display: flex;
    align-items: center;
}

.tts-speed {
    font-size: 0.6rem;
    color: var(--muted-color);
}

.tts-speed:empty {
    display: none;
}

.tts-mode {
    font-size: 0.55rem;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 1px 3px;
    border-radius: 2px;
    background: rgba(0,0,0,0.05);
}

.tts-mode:empty {
    display: none;
}

.tts-mode.openai {
    color: #10a37f;
    background: rgba(16, 163, 127, 0.1);
}

.tts-mode.browser {
    color: #666;
    background: rgba(0,0,0,0.08);
}

/* Speed notification */
.speed-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 2rem;
    font-weight: 500;
    padding: 1rem 2rem;
    border-radius: 12px;
    z-index: 1002;
    animation: fadeInScale 0.15s ease;
}

.speed-notification.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ========================================
   Illustration Mode Styles
   ======================================== */

/* Illustration toggle button active state */
.illustration-container .header-btn.active {
    background: var(--highlight-color);
}

.illustration-container .header-btn.active svg {
    fill: var(--text-color);
    fill-opacity: 0.15;
}

/* Illustration column */
.illustration-column {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    min-height: 0;
}

.illustration-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

/* Skeleton placeholder */
.illustration-skeleton {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--highlight-color);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.skeleton-shimmer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.skeleton-text {
    position: relative;
    z-index: 1;
    color: var(--muted-color);
    font-style: italic;
    font-size: 0.9rem;
}

/* Illustration error state */
.illustration-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--muted-color);
    font-style: italic;
}

.illustration-error svg {
    opacity: 0.5;
}

/* Style notification (similar to voice notification) */
.style-notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 1rem 1.25rem;
    max-width: 350px;
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

.style-notification-content {
    font-size: 0.9rem;
    line-height: 1.4;
}

.style-notification-content small {
    color: var(--muted-color);
}

.style-notification.fade-out {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Make illustration image clickable when prompt editing is enabled */
.illustration-image.editable {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.illustration-image.editable:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

/* ========================================
   Speed Reading Styles
   ======================================== */

.speed-reading-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    background: #000;
    color: #fff;
    z-index: 120;
}

.speed-reading-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    width: min(700px, 90vw);
}

.speed-reading-word {
    font-size: 3.5rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: #fff;
}

.speed-reading-word .pivot {
    color: #c0392b;
}

.speed-reading-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: #fff;
}

.speed-reading-play {
    border: 1px solid #fff;
    background: #fff;
    color: #000;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    cursor: pointer;
}

.speed-reading-exit {
    border: 1px solid #fff;
    background: transparent;
    color: #fff;
    padding: 0.5rem 1.2rem;
    border-radius: 999px;
    cursor: pointer;
}

.speed-reading-slider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    color: #fff;
}

.speed-reading-slider input[type="range"] {
    accent-color: #c0392b;
}

.speed-reading-wpm {
    min-width: 80px;
    text-align: right;
    color: #fff;
}

.speed-reading-chapter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 130;
}

.speed-reading-chapter-card {
    border: 1px solid #333;
    background: #111;
    color: #fff;
    padding: 2rem 2.5rem;
    border-radius: 12px;
    text-align: center;
    width: min(480px, 90vw);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.speed-reading-chapter-card h3 {
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
}

.speed-reading-chapter-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.speed-reading-btn {
    border-radius: 999px;
    padding: 0.6rem 1.4rem;
    font-size: 0.95rem;
    border: 1px solid #fff;
    cursor: pointer;
}

.speed-reading-btn-primary {
    background: #fff;
    color: #000;
    border-color: #fff;
}

.speed-reading-btn-secondary {
    background: transparent;
    color: #fff;
}

/* ========================================
   Prompt Editing Modal
   ======================================== */

.prompt-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prompt-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.prompt-modal-container {
    position: relative;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.2s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.prompt-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.prompt-modal-header h3 {
    font-size: 1.2rem;
    font-weight: 500;
    margin: 0;
}

.prompt-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted-color);
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
}

.prompt-modal-close:hover {
    color: var(--text-color);
    background-color: var(--highlight-color);
}

.prompt-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.prompt-modal-hint {
    font-size: 0.9rem;
    color: var(--muted-color);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.prompt-textarea {
    width: 100%;
    padding: 1rem;
    font-family: var(--font-serif);
    font-size: 1rem;
    line-height: 1.6;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: white;
    color: var(--text-color);
    resize: vertical;
    min-height: 150px;
    transition: border-color 0.2s;
}

.prompt-textarea:focus {
    outline: none;
    border-color: var(--muted-color);
}

.prompt-textarea::placeholder {
    color: var(--muted-color);
    font-style: italic;
}

.prompt-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.prompt-btn {
    padding: 0.6rem 1.25rem;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.prompt-btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--muted-color);
}

.prompt-btn-secondary:hover {
    border-color: var(--muted-color);
    color: var(--text-color);
}

.prompt-btn-primary {
    background: var(--text-color);
    border: 1px solid var(--text-color);
    color: var(--bg-color);
}

.prompt-btn-primary:hover {
    background: #1a1a1a;
}

.prompt-btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Generating mode */
.prompt-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
    color: var(--muted-color);
    font-style: italic;
}

.prompt-generating-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--text-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Preview mode */
.prompt-preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: var(--highlight-color);
    border-radius: 6px;
    min-height: 200px;
    max-height: 400px;
}

.prompt-preview-image {
    max-width: 100%;
    max-height: 380px;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.note-modal-container {
    max-width: 560px;
}

.note-modal-location {
    font-size: 0.84rem;
    color: var(--muted-color);
    margin-bottom: 0.6rem;
}

/* ========================================
   Character Feature Styles
   ======================================== */

/* Character Toast Notification */
.character-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    display: flex;
    align-items: stretch;
    max-width: 400px;
    z-index: 1500;
    animation: toastSlideIn 0.4s ease;
    overflow: hidden;
}

.character-toast-portrait {
    width: 80px;
    min-height: 100px;
    flex-shrink: 0;
    position: relative;
    background: var(--highlight-color);
}

.character-toast-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.character-toast-content {
    padding: 1rem;
    flex: 1;
    min-width: 0;
}

.character-toast-title {
    font-size: 0.75rem;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.character-toast-name {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.character-toast-desc {
    font-size: 0.85rem;
    color: var(--muted-color);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.character-toast-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--muted-color);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}

.character-toast-close:hover {
    color: var(--text-color);
}

.character-toast.fade-out {
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.4s ease;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* Character Modal (shared styles for browser and chat) */
.character-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.character-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.character-modal-container {
    position: relative;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.2s ease;
}

.character-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.character-modal-header h3 {
    font-size: 1.2rem;
    font-weight: 500;
    margin: 0;
}

.character-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--muted-color);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
}

.character-modal-close:hover {
    color: var(--text-color);
    background-color: var(--highlight-color);
}

.character-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Character List View */
.character-list-view {
    min-height: 200px;
}

.character-list-empty {
    text-align: center;
    color: var(--muted-color);
    font-style: italic;
    padding: 2rem;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.character-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.character-card:hover {
    background-color: var(--highlight-color);
    border-color: var(--muted-color);
}

.character-card-portrait {
    width: 80px;
    height: 100px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--highlight-color);
    margin-bottom: 0.75rem;
}

.character-card-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.character-card-portrait.pending {
    display: flex;
    align-items: center;
    justify-content: center;
}

.character-card-portrait.pending svg {
    color: var(--muted-color);
    opacity: 0.5;
}

.character-card-name {
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
}

/* Flowing character layout - primary large cards first, secondary smaller below */
.character-grid:has(.character-flow) {
    display: block;
}

.character-flow {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.character-flow .character-card {
    flex: 0 0 auto;
}

/* Large cards for PRIMARY characters */
.character-card-large {
    width: 130px;
    padding: 1rem;
}

.character-card-large .character-card-portrait {
    width: 100px;
    height: 125px;
}

.character-card-large .character-card-name {
    font-size: 1.05rem;
}

/* Small cards for SECONDARY characters */
.character-card-small {
    width: 90px;
    padding: 0.75rem;
}

.character-card-small .character-card-portrait {
    width: 60px;
    height: 75px;
    margin-bottom: 0.5rem;
}

.character-card-small .character-card-name {
    font-size: 0.85rem;
}

/* Character Detail View */
.character-detail-view {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.character-back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--muted-color);
    font-family: var(--font-serif);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    transition: color 0.2s;
}

.character-back-btn:hover {
    color: var(--text-color);
}

.character-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.character-portrait-large {
    width: 160px;
    height: 200px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--highlight-color);
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.character-portrait-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.character-detail h4 {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.character-detail p {
    font-size: 1rem;
    color: var(--muted-color);
    line-height: 1.6;
    margin-bottom: 1rem;
    max-width: 400px;
}

.character-first-appearance {
    font-size: 0.9rem;
    color: var(--muted-color);
    text-decoration: none;
    margin-bottom: 1.5rem;
    transition: color 0.2s;
}

.character-first-appearance:hover {
    color: var(--text-color);
    text-decoration: underline;
}

.character-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--text-color);
    color: var(--bg-color);
    border: none;
    border-radius: 6px;
    font-family: var(--font-serif);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.character-chat-btn:hover {
    background: #1a1a1a;
}

/* Character Chat Modal */
.character-chat-container {
    position: relative;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    height: 70vh;
    max-height: 600px;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.2s ease;
}

.character-chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.chat-portrait-small {
    width: 40px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
}

.character-chat-header h3 {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--text-color);
    color: var(--bg-color);
    border-bottom-right-radius: 4px;
}

.chat-message.character {
    align-self: flex-start;
    background: var(--highlight-color);
    color: var(--text-color);
    border-bottom-left-radius: 4px;
}

.chat-message.loading {
    color: var(--muted-color);
    font-style: italic;
}

.chat-message.loading::after {
    content: '';
    animation: ellipsis 1.5s infinite;
}

/* Chat Input */
.chat-input-container {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.chat-input-container textarea {
    flex: 1;
    padding: 0.75rem;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
    color: var(--text-color);
    resize: none;
    transition: border-color 0.2s;
}

.chat-input-container textarea:focus {
    outline: none;
    border-color: var(--muted-color);
}

.chat-input-container textarea::placeholder {
    color: var(--muted-color);
}

.chat-send-btn {
    padding: 0.75rem;
    background: var(--text-color);
    color: var(--bg-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn:hover {
    background: #1a1a1a;
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 960px) {
    #library-view {
        padding: 1rem 0.9rem 1.3rem;
    }

    .library-container {
        max-width: 100%;
    }

    .library-title {
        font-size: 2.05rem;
        margin-bottom: 0.65rem;
    }

    .site-logo {
        width: 1.8rem;
        height: 1.8rem;
    }

    .library-site-logo {
        height: clamp(2.4rem, 12vw, 3.4rem);
        max-width: 44%;
    }

    .site-wordmark {
        font-size: 0.9rem;
        letter-spacing: 0.03em;
    }

    .library-brand {
        gap: 0.65rem;
        margin-bottom: 0.2rem;
    }

    .library-wordmark {
        font-size: clamp(1.3rem, 7vw, 2rem);
        white-space: normal;
        line-height: 1;
    }

    .library-subtitle {
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }

    .library-search-container {
        margin-bottom: 1.25rem;
    }

    .library-search {
        padding-right: 6.25rem;
    }

    .library-search-submit {
        font-size: 0.82rem;
        padding: 0.24rem 0.72rem;
    }

    .library-search-status {
        margin-top: -0.6rem;
        margin-bottom: 0.9rem;
    }

    .classroom-banner {
        margin-bottom: 0.9rem;
        padding: 0.62rem 0.72rem;
    }

    .classroom-label {
        font-size: 0.76rem;
    }

    .classroom-feature-summary {
        font-size: 0.78rem;
    }

    .library-section {
        margin-bottom: 1.25rem;
    }

    .book-item {
        padding: 0.82rem 0.95rem;
    }

    .book-item-title {
        font-size: 1.03rem;
    }

    .book-item-author {
        font-size: 0.86rem;
    }

    .book-item-meta {
        font-size: 0.76rem;
    }

    .book-progress-chip {
        font-size: 0.6rem;
        padding: 0.08rem 0.42rem;
    }

    .book-item-favorite-btn {
        font-size: 0.62rem;
        padding: 0.12rem 0.45rem;
    }

    .achievements-summary {
        font-size: 0.82rem;
        margin-bottom: 0.42rem;
    }

    .achievements-list {
        gap: 0.35rem;
    }

    .achievement-item {
        width: 100%;
    }

    .achievements-view-all {
        font-size: 0.64rem;
        padding: 0.12rem 0.44rem;
    }

    #reader-view {
        padding: 0.9rem;
    }

    #reader-view.mobile-layout {
        padding-bottom: calc(5.1rem + env(safe-area-inset-bottom));
    }

    #reader-view.mobile-layout .reader-header {
        flex-wrap: wrap;
        gap: 0.4rem;
        margin-bottom: 0.75rem;
        padding-bottom: 0.75rem;
    }

    #reader-view.mobile-layout .mobile-header-menu {
        display: flex;
        margin-left: auto;
    }

    #reader-view.mobile-layout .mobile-header-menu-search {
        display: flex;
    }

    #reader-view.mobile-layout .mobile-header-menu-item[data-shortcut]::after {
        content: none;
    }

    #reader-view.mobile-layout .reader-brand {
        gap: 0.4rem;
    }

    #reader-view.mobile-layout .reader-wordmark {
        display: none;
    }

    #reader-view.mobile-layout .reader-site-logo {
        width: 1.4rem;
        height: 1.4rem;
    }

    #reader-view.mobile-layout .mobile-header-menu-panel {
        position: fixed;
        top: calc(env(safe-area-inset-top) + 3.6rem);
        left: 0.6rem;
        right: 0.6rem;
        width: auto;
        max-width: none;
        max-height: 62vh;
        overflow-y: auto;
    }

    #reader-view.mobile-layout .header-mobile-action {
        display: none !important;
    }

    #reader-view.mobile-layout .reader-settings-menu.header-mobile-action {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 0;
        height: 0;
        overflow: visible;
        z-index: 2050;
    }

    #reader-view.mobile-layout #reader-settings-toggle {
        display: none;
    }

    #reader-view.mobile-layout #reader-settings-panel {
        position: fixed;
        top: calc(env(safe-area-inset-top) + 3.6rem);
        left: 0.6rem;
        right: 0.6rem;
        width: auto;
        max-width: none;
        max-height: 62vh;
        overflow-y: auto;
        z-index: 2060;
    }

    #reader-view.mobile-layout .book-meta {
        order: 2;
        width: 100%;
        position: static;
        left: auto;
        transform: none;
        margin: 0 auto;
        align-items: center;
        text-align: center;
        pointer-events: auto;
    }

    #reader-view.mobile-layout .header-right-controls {
        order: 3;
        width: 0;
        height: 0;
        overflow: visible;
        margin-left: 0;
    }

    #reader-view.mobile-layout .search-container {
        display: none;
    }

    #reader-view.mobile-layout .chapter-title {
        margin-bottom: 0.75rem;
        font-size: 1.25rem;
    }

    #reader-view.mobile-layout .reader-gutter {
        display: none;
    }

    #reader-view.mobile-layout .reader-content {
        gap: 0;
    }

    #reader-view.mobile-layout #column-right {
        display: none;
    }

    #reader-view.mobile-layout .reader-footer {
        display: none;
    }

    #reader-view.mobile-layout #shortcuts-toggle {
        display: none;
    }

    #reader-view.mobile-layout .mobile-reader-nav {
        display: flex;
    }

    #reader-view.mobile-layout .chapter-list-container {
        width: 96vw;
        max-height: 78vh;
    }

    #reader-view.mobile-layout .chapter-recap-card {
        width: 96vw;
        max-height: 88vh;
        padding: 0.95rem 0.95rem 1rem;
    }
}

@media (max-width: 960px) and (orientation: landscape) {
    #reader-view.mobile-layout {
        padding: 0.45rem;
        padding-bottom: calc(3.4rem + env(safe-area-inset-bottom));
    }

    #reader-view.mobile-layout .reader-header {
        gap: 0.25rem;
        margin-bottom: 0.35rem;
        padding-bottom: 0.35rem;
    }

    #reader-view.mobile-layout .header-btn {
        padding: 0.32rem;
    }

    #reader-view.mobile-layout .book-title {
        font-size: 1rem;
    }

    #reader-view.mobile-layout .reader-site-logo {
        width: 1.25rem;
        height: 1.25rem;
    }

    #reader-view.mobile-layout .book-author {
        display: none;
    }

    #reader-view.mobile-layout .chapter-title {
        font-size: 1.08rem;
        margin-bottom: 0.35rem;
    }

    #reader-view.mobile-layout .mobile-reader-nav {
        bottom: calc(0.2rem + env(safe-area-inset-bottom));
        width: calc(100vw - 0.7rem);
        padding: 0.24rem;
        gap: 0.22rem;
    }

    #reader-view.mobile-layout .mobile-reader-nav-row {
        gap: 0.22rem;
    }

    #reader-view.mobile-layout .mobile-reader-nav-btn {
        font-size: 0.75rem;
        min-height: 1.55rem;
        padding: 0.26rem 0.2rem;
    }
}
