.reader-body {
    padding-bottom: 168px;
}

.library-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 28px 80px;
    position: relative;
    z-index: 1;
}

.library-hero {
    padding: 60px 0 30px;
    max-width: 760px;
}

.library-hero h1 {
    margin: 0;
    font-family: var(--serif);
    font-size: 46px;
    line-height: 1.18;
    letter-spacing: .02em;
}

.library-hero h1 em {
    color: var(--accent);
    font-style: normal;
}

.library-hero .lede {
    margin: 18px 0 0;
    color: var(--ink-soft);
    font-size: 17px;
}

.library-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
    margin: 22px 0;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.book-card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 190px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: linear-gradient(180deg, #fffefb, #fbf6ec);
    text-decoration: none;
    color: inherit;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.book-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 20px 40px -32px rgba(52, 38, 20, .45);
}

.book-card-del {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: .4;
    transition: opacity .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
}

.book-card-del:hover {
    opacity: 1;
    background: #f5d5cf;
    color: #b03a2e;
    border-color: #e8b8ae;
}

.book-card:hover .book-card-del {
    opacity: .7;
}

.book-card h3 {
    margin: 0 0 8px;
    font-family: var(--serif);
    font-size: 21px;
    line-height: 1.35;
}

.book-card p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.book-card .book-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
}

.book-card .tag {
    font-size: 12px;
}

.empty-note {
    padding: 36px;
    text-align: center;
    color: var(--muted);
}

.reader-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.reader-title-line {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.reader-title-line h2 {
    margin: 0;
    font-family: var(--serif);
    font-size: 30px;
}

.chapter-panel {
    position: sticky;
    top: 18px;
    max-height: calc(100vh - 40px);
    overflow: auto;
}

.chapter-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-nav button {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: var(--ink-soft);
    padding: 10px 12px;
    border-radius: 12px;
    cursor: pointer;
    font: inherit;
    line-height: 1.5;
}

.chapter-nav button:hover {
    background: var(--accent-soft);
    color: var(--accent-deep);
}

.chapter-nav button.active {
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-weight: 600;
}

.reading-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 34px;
    min-height: 60vh;
}

.reading-card h3 {
    margin: 0 0 22px;
    font-family: var(--serif);
    font-size: 26px;
}

.sentence-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sentence-item {
    padding: 10px 12px;
    margin: 2px -8px;
    border-radius: 10px;
    cursor: text;
    color: var(--ink-soft);
    font-family: var(--serif);
    font-size: 19px;
    line-height: 1.95;
    transition: background .15s ease, color .15s ease;
    -webkit-touch-callout: none; /* iOS: 禁用长按弹出的系统菜单 */
    touch-action: manipulation; /* 禁用双击缩放，提升响应速度 */
}

/* 手机端：禁用长按时的文字选中高亮，避免干扰自定义弹出菜单 */
@media (max-width: 560px) {
    .sentence-item {
        -webkit-user-select: none;
        user-select: none;
    }
}

.sentence-item.active {
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--accent);
}

.reader-menu {
    position: fixed;
    z-index: 40;
    min-width: 150px;
    padding: 6px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 18px 44px -24px rgba(52, 38, 20, .55);
}

.reader-menu[hidden] {
    display: none;
}

.reader-menu button {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--ink);
    text-align: left;
    padding: 9px 12px;
    border-radius: 8px;
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
}

.reader-menu button:hover {
    background: var(--accent-soft);
    color: var(--accent-deep);
}

/* 返回顶部按钮 */
.back-to-top {
    position: fixed;
    right: 26px;
    bottom: 116px;
    z-index: 21;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--card);
    color: var(--ink-soft);
    box-shadow: 0 14px 30px -18px rgba(52, 38, 20, .55);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform .18s ease, color .18s ease, background .18s ease;
}

.back-to-top[hidden] {
    display: none;
}

.back-to-top:hover {
    color: var(--accent);
    background: #fffef9;
    transform: translateY(-2px);
}

.back-to-top svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

@media (max-width: 860px) {
    .back-to-top {
        right: 16px;
        bottom: 200px;
    }
}

@media (max-width: 560px) {
    .back-to-top {
        right: 12px;
        bottom: 210px;
        width: 40px;
        height: 40px;
    }
    .back-to-top svg {
        width: 18px;
        height: 18px;
    }
}

.reader-player {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 980px;
    z-index: 20;
}

.reader-player-inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 18px;
    align-items: center;
    padding: 16px 18px;
    border-radius: 18px;
    background: rgba(29, 28, 26, .94);
    color: #fff8ee;
    box-shadow: 0 26px 60px -32px rgba(0, 0, 0, .7);
    backdrop-filter: blur(12px);
}

.reader-main-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reader-main-controls button {
    border: 1px solid rgba(255, 248, 238, .22);
    background: rgba(255, 255, 255, .08);
    color: inherit;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.reader-main-controls button.primary {
    background: var(--accent);
    border-color: var(--accent);
    width: 48px;
    height: 48px;
}

.reader-main-controls svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.reader-now {
    min-width: 0;
}

.reader-now-title {
    font-family: var(--serif);
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reader-now-sub {
    color: rgba(255, 248, 238, .68);
    font-size: 12px;
    margin-top: 2px;
}

.reader-side {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reader-side select,
.reader-side button {
    border: 1px solid rgba(255, 248, 238, .22);
    background: rgba(255, 255, 255, .08);
    color: inherit;
    border-radius: 10px;
    padding: 9px 11px;
    font: inherit;
}

.reader-side select option {
    color: var(--ink);
}

/* 下拉分组标题：默认继承浅色文字，在浅色下拉面板里几乎看不见，改用品牌色加粗区分 */
.reader-side select optgroup {
    color: var(--accent-deep);
    background: #fff;
    font-weight: 700;
    font-style: normal;
}

.uploading {
    pointer-events: none;
    opacity: .65;
}

@media (max-width: 860px) {
    .reader-layout {
        grid-template-columns: 1fr;
    }
    .chapter-panel {
        position: static;
        max-height: 260px;
    }
    .reader-player-inner {
        grid-template-columns: 1fr;
    }
    .reader-side {
        justify-content: space-between;
    }
}

/* ================================================================
   手机端响应式优化（≤ 560px）
   ================================================================ */

@media (max-width: 560px) {
    /* ----- 书架页面 ----- */
    .library-shell {
        padding: 0 14px 80px;
    }
    .library-hero {
        padding: 36px 0 24px;
    }
    .library-hero h1 {
        font-size: clamp(28px, 8vw, 38px);
    }
    .library-hero .lede {
        font-size: 14px;
        margin-top: 14px;
        line-height: 1.8;
    }
    .library-card {
        padding: 18px;
        margin: 16px 0;
    }

    /* ----- 书架网格 ----- */
    .library-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .book-card {
        min-height: auto;
        padding: 16px;
        border-radius: 16px;
    }
    .book-card h3 {
        font-size: 18px;
        line-height: 1.3;
        padding-right: 28px;
    }
    .book-card p {
        font-size: 12.5px;
        margin-top: 4px;
    }
    .book-card .book-card-foot {
        margin-top: 14px;
    }
    .book-card .tag {
        font-size: 11px;
    }
    .book-card-del {
        top: 10px;
        right: 10px;
        width: 32px;
        height: 32px;
        font-size: 20px;
        opacity: .35; /* 手机上默认稍微明显一点，好发现 */
    }

    /* ----- 阅读器标题 ----- */
    .reader-title-line {
        margin-bottom: 14px;
        gap: 10px;
    }
    .reader-title-line h2 {
        font-size: 22px;
        line-height: 1.3;
    }

    /* ----- 章节目录面板 ----- */
    .chapter-panel {
        padding: 16px;
        max-height: 220px;
        border-radius: 16px;
    }
    .chapter-nav button {
        padding: 12px 12px; /* 加大触控区域 */
        font-size: 14px;
        border-radius: 10px;
        line-height: 1.5;
        min-height: 44px;
    }

    /* ----- 阅读卡片 ----- */
    .reading-card {
        padding: 22px 18px 20px;
        min-height: 50vh;
        border-radius: 16px;
    }
    .reading-card h3 {
        font-size: 20px;
        margin-bottom: 16px;
        line-height: 1.35;
    }

    /* ----- 句子列表 ----- */
    .sentence-item {
        padding: 12px 12px;
        margin: 3px -4px;
        border-radius: 10px;
        font-size: 17px;
        line-height: 2;
        font-family: var(--serif);
    }
    .sentence-item.active {
        box-shadow: inset 3px 0 0 var(--accent);
    }

    /* ----- 底部阅读器播放器 ----- */
    .reader-player {
        width: calc(100% - 20px);
        bottom: 10px;
    }
    .reader-player-inner {
        padding: 12px 14px;
        border-radius: 18px;
        gap: 12px;
    }

    /* 第一行：播放控件 */
    .reader-player-inner > .reader-main-controls {
        justify-content: center;
    }
    .reader-main-controls button {
        width: 44px;
        height: 44px;
    }
    .reader-main-controls button.primary {
        width: 50px;
        height: 50px;
    }
    .reader-main-controls svg {
        width: 20px;
        height: 20px;
    }

    /* 中间：当前播放信息 */
    .reader-now {
        text-align: center;
        padding: 0 4px;
    }
    .reader-now-title {
        font-size: 15px;
        font-family: var(--sans);
        line-height: 1.4;
        max-height: 2.8em;
        overflow: hidden;
    }
    .reader-now-sub {
        font-size: 11px;
        margin-top: 3px;
    }

    /* 第三行：声音 + 倍速 */
    .reader-side {
        justify-content: center;
        gap: 8px;
    }
    .reader-side label {
        display: none; /* 隐藏 label 节省空间，select 的 option 文字本身足够 */
    }
    .reader-side select {
        border-radius: 8px;
        padding: 10px 22px 10px 10px;
        font-size: 13px;
        min-height: 40px;
    }

    /* ----- 右键菜单 ----- */
    .reader-menu {
        min-width: 130px;
    }
    .reader-menu button {
        padding: 11px 14px;
        font-size: 14px;
        min-height: 44px;
    }
}

/* 更小屏幕（< 380px） */
@media (max-width: 380px) {
    .library-hero h1 {
        font-size: clamp(24px, 8vw, 32px);
    }
    .reader-title-line h2 {
        font-size: 19px;
    }
    .reading-card h3 {
        font-size: 18px;
    }
    .sentence-item {
        font-size: 16px;
        padding: 10px 10px;
    }
    .book-card h3 {
        font-size: 16px;
    }
    .chapter-panel {
        max-height: 180px;
    }
}
