/* ===========================================================================
   书架模块样式（bsf- 命名空间，配 bookshelf.js）
   网格视图沿用 style.css 的 .book-card / #bookshelf-list 既有规则；
   这里只加：列表视图、右上角选项菜单、标签 chip、完成徽章。
   =========================================================================== */

/* 列表视图：覆盖 #bookshelf-list 的 grid，改成单列行 */
#bookshelf-list.bsf-list-view {
    display: block !important;
    padding: 6px 2px;
}

.bsf-list-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    gap: 12px !important;
    background: var(--card-bg) !important;
    border-radius: 12px !important;
    padding: 12px !important;
    margin-bottom: 10px !important;
    box-shadow: var(--shadow) !important;
    transition: transform 0.15s;
}

.bsf-list-row:active {
    transform: scale(0.985);
}

.bsf-list-cover {
    flex-shrink: 0;
    width: 56px;
    height: 80px;
    border-radius: 4px 7px 7px 4px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0) 12%, rgba(255, 255, 255, 0.08) 50%, rgba(0, 0, 0, 0.08) 100%), var(--accent);
    box-shadow: -1px 0 0 rgba(0, 0, 0, 0.2), 2px 3px 7px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}

body .bsf-list-cover.has-cover {
    background-image: var(--book-cover-image, none) !important;
    background-size: cover !important;
    background-position: center !important;
}

.bsf-list-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
}

.bsf-list-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bsf-list-author {
    font-size: 0.76rem;
    opacity: 0.6;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bsf-list-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin: 2px 0;
}

.bsf-tag {
    font-size: 0.64rem;
    padding: 1px 8px;
    border-radius: 9px;
    background: rgba(var(--accent-rgb), 0.14);
    color: var(--accent);
}

.bsf-list-desc {
    font-size: 0.74rem;
    opacity: 0.6;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bsf-list-meta {
    font-size: 0.66rem;
    opacity: 0.5;
    margin-top: 2px;
}

.bsf-finished-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(var(--accent-rgb), 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 右上角选项菜单 */
.bsf-menu-btn {
    width: auto;
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.bsf-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
}

.bsf-menu-pop {
    position: fixed;
    min-width: 180px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(var(--accent-rgb), 0.15);
    padding: 6px;
    animation: bsfPop 0.14s ease;
}

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

.bsf-menu-group {
    font-size: 0.68rem;
    opacity: 0.5;
    padding: 6px 10px 3px;
}

.bsf-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.86rem;
    color: var(--text);
    transition: background 0.12s;
}

.bsf-menu-item:hover {
    background: rgba(var(--accent-rgb), 0.1);
}

.bsf-menu-item:active {
    transform: scale(0.98);
}

.bsf-check {
    color: var(--accent);
    font-weight: 700;
}

.bsf-menu-sep {
    height: 1px;
    background: rgba(var(--accent-rgb), 0.12);
    margin: 4px 6px;
}

/* ───────── 讨论 tab 顶部「最近在读」书架 ───────── */
#bsf-recent-shelf { margin-bottom: 18px; }
.bsf-recent-label { font-size: 0.82rem; font-weight: 600; opacity: 0.7; margin-bottom: 8px; }
.bsf-recent-stage { position: relative; padding: 0 6px 12px; }
.bsf-recent-row {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 140px;
    position: relative;
    z-index: 2;
}
.bsf-recent-book {
    flex-shrink: 0;
    width: 76px;
    border-radius: 3px 7px 7px 3px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.22) 0%, rgba(0, 0, 0, 0) 12%, rgba(255, 255, 255, 0.1) 50%, rgba(0, 0, 0, 0.12) 100%), var(--accent);
    box-shadow: -2px 0 0 rgba(0, 0, 0, 0.22), 4px 6px 14px rgba(0, 0, 0, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
    transform-origin: bottom center;
}
/* 鼠标滑过：抬起 + 放大 + 提到最前 + 加重投影 */
.bsf-recent-book:hover {
    transform: translateY(-9px) scale(1.05);
    z-index: 60 !important;
    box-shadow: -2px 0 0 rgba(0, 0, 0, 0.22), 8px 12px 22px rgba(0, 0, 0, 0.34);
}
.bsf-recent-book:active { transform: translateY(-2px) scale(0.97) !important; }
body .bsf-recent-book.has-cover {
    background-image: var(--book-cover-image, none) !important;
    background-size: cover !important;
    background-position: center !important;
}
/* 书架横板 */
.bsf-recent-ledge {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 10px;
    border-radius: 3px;
    background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.55), rgba(var(--accent-rgb), 0.32));
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
    z-index: 1;
}

/* ───────── 书本详情页 ───────── */
#bsf-detail-screen {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 7200;
    background: var(--bg);
    flex-direction: column;
}

.bsf-detail-top {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px max(14px, env(safe-area-inset-top));
    padding-top: max(14px, env(safe-area-inset-top));
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

.bsf-detail-back, .bsf-detail-editbtn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.bsf-detail-back:hover, .bsf-detail-editbtn:hover { background: rgba(var(--accent-rgb), 0.1); }
.bsf-detail-back:active, .bsf-detail-editbtn:active { transform: scale(0.9); }
.bsf-detail-toptitle { font-weight: 700; font-size: 0.95rem; color: var(--accent); }

.bsf-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.bsf-detail-head {
    display: flex;
    gap: 14px;
    margin-bottom: 16px;
}

.bsf-detail-cover {
    flex-shrink: 0;
    width: 84px;
    height: 120px;
    border-radius: 4px 8px 8px 4px;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0) 12%, rgba(255, 255, 255, 0.1) 50%, rgba(0, 0, 0, 0.1) 100%), var(--accent);
    box-shadow: -2px 0 0 rgba(0, 0, 0, 0.2), 4px 4px 10px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center;
}
body .bsf-detail-cover.has-cover {
    background-image: var(--book-cover-image, none) !important;
    background-size: cover !important;
    background-position: center !important;
}

.bsf-detail-headinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.bsf-detail-title { font-size: 1.05rem; font-weight: 700; color: var(--accent); line-height: 1.3; }
.bsf-detail-author { font-size: 0.84rem; opacity: 0.7; }
.bsf-detail-meta { font-size: 0.74rem; opacity: 0.55; }
.bsf-detail-edit-input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid rgba(var(--accent-rgb), 0.25);
    border-radius: 7px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 4px;
}

.bsf-detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; align-items: center; }
.bsf-detail-tag { display: inline-flex; align-items: center; gap: 4px; }
.bsf-tag-x { cursor: pointer; opacity: 0.6; font-weight: 700; padding: 0 2px; }
.bsf-tag-x:hover { opacity: 1; color: #c62828; }
.bsf-tag-add {
    cursor: pointer;
    background: transparent;
    border: 1px dashed rgba(var(--accent-rgb), 0.4);
    color: var(--accent);
}

.bsf-common-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.bsf-common-label { font-size: 0.66rem; opacity: 0.45; }
.bsf-common-tag { cursor: pointer; opacity: 0.7; }
.bsf-common-tag:hover { opacity: 1; }
.bsf-common-tag:active { transform: scale(0.95); }

.bsf-detail-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.12);
    margin-bottom: 14px;
}
.bsf-detail-tab {
    padding: 9px 18px;
    cursor: pointer;
    font-size: 0.92rem;
    opacity: 0.55;
    margin-bottom: -1px;
    border-bottom: 2px solid transparent;
}
.bsf-detail-tab.active {
    opacity: 1;
    color: var(--accent);
    font-weight: 700;
    border-bottom-color: var(--accent);
}

.bsf-intro-block { margin-bottom: 16px; }
.bsf-intro-label { font-size: 0.78rem; opacity: 0.55; margin-bottom: 6px; }
.bsf-intro-text {
    width: 100%;
    box-sizing: border-box;
    min-height: 70px;
    border: 1px solid rgba(var(--accent-rgb), 0.18);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.88rem;
    line-height: 1.6;
    background: var(--card-bg);
    color: var(--text);
    resize: vertical;
}
.bsf-intro-save {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 10px;
    background: var(--accent);
    color: var(--bg);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
}
.bsf-intro-save:active { transform: scale(0.99); }

/* 10-13：简介默认只读展示，「编辑」进编辑态；按钮是小号胶囊，不和底部「开始阅读」抢分量 */
.bsf-intro-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.bsf-intro-head .bsf-intro-label { margin-bottom: 0; }
.bsf-intro-view {
    font-size: 0.88rem;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 2px 2px 0;
}
.bsf-intro-view.bsf-intro-empty { opacity: 0.45; }
.bsf-intro-actions { display: flex; justify-content: flex-end; gap: 8px; }
.bsf-intro-btn {
    padding: 5px 14px;
    border-radius: 999px;
    border: 1px solid rgba(var(--accent-rgb), 0.28);
    background: transparent;
    color: var(--accent);
    font-size: 0.8rem;
    line-height: 1.4;
    cursor: pointer;
}
.bsf-intro-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.bsf-intro-btn:active { transform: scale(0.97); }

.bsf-review, .bsf-note {
    background: rgba(var(--accent-rgb), 0.05);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
}
.bsf-review-head, .bsf-note-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.bsf-review-text { font-size: 0.88rem; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.bsf-note-chapter { font-size: 0.8rem; font-weight: 600; opacity: 0.78; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.bsf-note-excerpt {
    font-size: 0.83rem; margin-top: 4px; padding: 6px 10px; line-height: 1.5;
    background: rgba(0, 0, 0, 0.03); border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; opacity: 0.85;
}
.bsf-note-body { font-size: 0.83rem; margin-top: 6px; line-height: 1.5; font-style: italic; }

.bsf-empty { text-align: center; opacity: 0.5; padding: 24px; font-size: 0.85rem; }

/* Round B-C/D: 书评 tab 微信读书式 feed + AI 书评 + 角色选择器 */
.bsf-feed-acts { display: flex; gap: 8px; margin-bottom: 14px; }
.bsf-feed-acts .bsf-intro-save { margin-bottom: 0; flex: 1; }
.bsf-ai-review { background: rgba(var(--accent-rgb), 0.12) !important; color: var(--accent) !important; }
.bsf-feed-card { padding: 12px 14px; margin-bottom: 10px; border-radius: 12px; background: rgba(var(--accent-rgb), 0.04);
    border: 1px solid rgba(var(--accent-rgb), 0.1); cursor: pointer; transition: background 0.15s; }
.bsf-feed-card:hover { background: rgba(var(--accent-rgb), 0.08); }
.bsf-feed-card:active { transform: scale(0.995); }
.bsf-feed-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bsf-feed-tag { font-size: 0.66rem; padding: 1px 7px; border-radius: 8px; background: rgba(var(--accent-rgb), 0.14); color: var(--text); opacity: 0.8; }
.bsf-feed-tag.ai { background: var(--accent); color: var(--bg); opacity: 1; font-weight: 700; }
.bsf-feed-quote { font-size: 0.76rem; line-height: 1.45; opacity: 0.7; padding: 5px 9px; margin-bottom: 6px;
    background: rgba(var(--accent-rgb), 0.06); border-left: 2px solid var(--accent); border-radius: 0 6px 6px 0; word-break: break-word; }
.bsf-feed-text { font-size: 0.86rem; line-height: 1.5; word-break: break-word; }
.bsf-feed-foot { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: 0.72rem; opacity: 0.55; }
.bsf-feed-more { color: var(--accent); opacity: 0.9; }
/* AI 角色名小 chip（笔记列表 + feed） */
.bsf-ai-chip { display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 10px; font-size: 0.66rem; font-weight: 700; background: var(--accent); color: var(--bg); flex-shrink: 0; }
/* 角色选择器 */
.bsf-pick-title { font-size: 0.86rem; font-weight: 600; opacity: 0.75; margin-bottom: 12px; text-align: center; }
.bsf-char-pick { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 8px; border-radius: 12px;
    background: rgba(var(--accent-rgb), 0.05); cursor: pointer; transition: background 0.15s; }
.bsf-char-pick:hover { background: rgba(var(--accent-rgb), 0.12); }
.bsf-char-pick:active { transform: scale(0.98); }

.bsf-detail-foot {
    flex-shrink: 0;
    padding: 12px 16px max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(var(--accent-rgb), 0.1);
    background: var(--card-bg);
}
.bsf-detail-read {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: var(--bg);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
}
.bsf-detail-read:active { transform: scale(0.99); }

/* 刀5c-ish：共读进度卡片（详情页简介 tab 顶部，我 + 一起读过的小 AI 各一条进度条；themed，不写死粉色） */
.bsf-coread-progress:empty { display: none; }
.bsf-coread-progress {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 14px 16px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow, 0 2px 10px rgba(0,0,0,0.06));
}
.bsf-cp-title { font-size: 0.92rem; font-weight: 700; color: var(--accent); margin-bottom: 12px; }
.bsf-cp-sub { font-size: 0.66rem; letter-spacing: 1.5px; opacity: 0.45; font-weight: 400; margin-left: 6px; }
.bsf-cp-row { margin-bottom: 12px; }
.bsf-cp-row:last-child { margin-bottom: 0; }
.bsf-cp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bsf-cp-av { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.bsf-cp-av-ph { display: inline-flex; align-items: center; justify-content: center; background: rgba(var(--accent-rgb, 79,195,247), 0.22); color: var(--accent); font-size: 0.7rem; font-weight: 700; }
.bsf-cp-who { font-size: 0.85rem; color: var(--text); font-weight: 600; }
.bsf-cp-pct { margin-left: auto; font-size: 0.78rem; opacity: 0.6; font-variant-numeric: tabular-nums; }
.bsf-cp-bar { height: 6px; border-radius: 3px; background: rgba(var(--accent-rgb, 79,195,247), 0.14); overflow: hidden; }
.bsf-cp-fill { height: 100%; border-radius: 3px; background: rgba(var(--accent-rgb, 79,195,247), 0.55); transition: width 0.4s ease; }
.bsf-cp-fill-self { background: var(--accent); }
.bsf-cp-empty { font-size: 0.78rem; opacity: 0.6; line-height: 1.6; }

/* 刀5c 共读记录（存档的阅读报告卡片）*/
.bsf-coread-cards:empty { display: none; }
.bsf-coread-cards {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 14px 16px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow, 0 2px 10px rgba(0,0,0,0.06));
}
.bsf-cc-title { font-size: 0.92rem; font-weight: 700; color: var(--accent); margin-bottom: 12px; }
.bsf-cc-card {
    border: 1px solid rgba(var(--accent-rgb, 79,195,247), 0.18);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background 0.15s;
}
.bsf-cc-card:last-child { margin-bottom: 0; }
.bsf-cc-card:hover { background: rgba(var(--accent-rgb, 79,195,247), 0.06); }
.bsf-cc-head { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.bsf-cc-who { font-size: 0.82rem; font-weight: 600; color: var(--text); }
.bsf-cc-date { font-size: 0.72rem; opacity: 0.5; font-variant-numeric: tabular-nums; }
.bsf-cc-del { margin-left: auto; flex-shrink: 0; width: 22px; height: 22px; border: none; background: none; color: var(--text); opacity: 0.4; font-size: 0.8rem; cursor: pointer; border-radius: 6px; }
.bsf-cc-del:hover { opacity: 1; }
.bsf-cc-summary { font-size: 0.84rem; line-height: 1.55; color: var(--text); word-break: break-word; }
.bsf-cc-foot { font-size: 0.72rem; opacity: 0.55; margin-top: 6px; }
