/* ============================================================
   圈子插件 · 读书圈独立样式
   ============================================================ */
.rdg-wrap {
    --rdg-primary: #2b5f9e;
    --rdg-primary-hover: #1f4a80;
    --rdg-primary-light: #eaf1fa;
    --rdg-accent: #b8860b;
    --rdg-accent-light: #fdf5e6;
    --rdg-bg: var(--mn-bg, #f5f6f8);
    --rdg-card: var(--mn-bg-card, #fff);
    --rdg-text: var(--mn-text, #1a1a1a);
    --rdg-text-2: var(--mn-text-secondary, #5a6472);
    --rdg-text-3: var(--mn-text-muted, #8c94a0);
    --rdg-border: var(--mn-border, #e3e6ec);
    --rdg-radius: 10px;

    padding: 20px 24px 48px;
    max-width: 1400px;
    margin: 0 auto;
    box-sizing: border-box;
    width: 100%;
    background: var(--rdg-bg);
    color: var(--rdg-text);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    font-size: 14px;
    line-height: 1.7;
}
html[data-theme="dark"] .rdg-wrap,
html.dark .rdg-wrap,
body.dark .rdg-wrap,
body.theme-dark .rdg-wrap,
.dark-theme .rdg-wrap {
    --rdg-primary: #5a8bd8;
    --rdg-primary-hover: #6f9ddf;
    --rdg-primary-light: rgba(90, 139, 216, .14);
    --rdg-accent: #d4a02a;
    --rdg-accent-light: rgba(212, 160, 42, .14);
}

/* 面包屑 */
.rdg-breadcrumb {
    display: flex; align-items: center; flex-wrap: wrap;
    font-size: 13px; color: var(--rdg-text-3);
    margin-bottom: 16px; gap: 4px; padding: 8px 0;
}
.rdg-breadcrumb a { color: var(--rdg-primary); text-decoration: none; }
.rdg-breadcrumb a:hover { text-decoration: underline; }
.rdg-breadcrumb-sep { opacity: .5; margin: 0 4px; }

/* 顶部卡片 */
.rdg-hero {
    display: flex;
    gap: 24px;
    padding: 24px;
    background: var(--rdg-card);
    border: 1px solid var(--rdg-border);
    border-radius: var(--rdg-radius);
    margin-bottom: 20px;
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}
.rdg-hero::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--rdg-primary), var(--rdg-accent));
    pointer-events: none;
}
.rdg-cover {
    width: 140px; height: 190px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--rdg-primary-light);
    display: flex; align-items: center; justify-content: center;
    font-size: 40px; color: var(--rdg-primary);
    box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.rdg-cover img { width: 100%; height: 100%; object-fit: cover; }
.rdg-hero-body { flex: 1; min-width: 240px; }
.rdg-hero-title {
    font-size: 26px; font-weight: 700;
    color: var(--rdg-text);
    margin: 0 0 10px;
    line-height: 1.3;
}
.rdg-hero-meta {
    display: flex; flex-wrap: wrap; gap: 14px;
    font-size: 13px; color: var(--rdg-text-3);
    margin: 0 0 12px;
}
.rdg-hero-meta strong { color: var(--rdg-primary); font-weight: 700; }
.rdg-hero-intro {
    font-size: 14px; color: var(--rdg-text-2);
    line-height: 1.75;
    margin: 0 0 16px;
    padding: 12px 14px;
    background: var(--rdg-bg);
    border-radius: 8px;
    border-left: 3px solid var(--rdg-primary);
    max-height: 4.5em; overflow: hidden; text-overflow: ellipsis;
}
.rdg-hero-actions {
    display: flex; gap: 10px; flex-wrap: wrap;
}
.rdg-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 20px; font-size: 13px; font-weight: 500;
    line-height: 1.5; font-family: inherit;
    background: var(--rdg-card); color: var(--rdg-text);
    border: 1px solid var(--rdg-border);
    border-radius: 8px; cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
}
.rdg-btn:hover {
    border-color: var(--rdg-primary);
    color: var(--rdg-primary);
    background: var(--rdg-primary-light);
}
.rdg-btn-primary {
    background: var(--rdg-primary); color: #fff;
    border-color: var(--rdg-primary);
    box-shadow: 0 4px 12px rgba(43, 95, 158, .25);
}
.rdg-btn-primary:hover {
    background: var(--rdg-primary-hover);
    border-color: var(--rdg-primary-hover);
    color: #fff;
    transform: translateY(-1px);
}
.rdg-btn-accent {
    background: var(--rdg-accent); color: #fff;
    border-color: var(--rdg-accent);
}
.rdg-btn-accent:hover {
    background: #a07510;
    border-color: #a07510;
    color: #fff;
}
.rdg-btn-lg { padding: 12px 26px; font-size: 14px; }

/* 主区 + 侧栏布局 */
.rdg-main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    align-items: start;
}
@media (max-width: 1024px) {
    .rdg-main-grid { grid-template-columns: 1fr; }
}
.rdg-main { min-width: 0; }
.rdg-side { min-width: 0; }

/* 区块 */
.rdg-panel {
    background: var(--rdg-card);
    border: 1px solid var(--rdg-border);
    border-radius: var(--rdg-radius);
    padding: 18px 20px;
    margin-bottom: 16px;
}
.rdg-panel-title {
    font-size: 15px; font-weight: 700;
    color: var(--rdg-text);
    margin: 0 0 12px;
    padding-left: 10px;
    border-left: 3px solid var(--rdg-primary);
    line-height: 1.4;
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
}
.rdg-panel-title a {
    font-size: 12.5px; font-weight: 400;
    color: var(--rdg-primary);
    text-decoration: none;
}

/* 章节列表 */
.rdg-chapters {
    list-style: none; padding: 0; margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
}
.rdg-chapters li { margin: 0; min-width: 0; }
.rdg-chapter-item {
    display: flex; gap: 8px; align-items: center;
    padding: 10px 12px;
    border-radius: 6px;
    color: var(--rdg-text);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .15s, color .15s;
    background: var(--rdg-bg);
    border: 1px solid transparent;
    min-width: 0;
}
.rdg-chapter-item:hover {
    background: var(--rdg-primary-light);
    color: var(--rdg-primary);
    border-color: var(--rdg-primary);
}
.rdg-chapter-no {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 22px; padding: 0 6px;
    border-radius: 5px;
    background: var(--rdg-primary-light);
    color: var(--rdg-primary);
    font-size: 11px; font-weight: 700;
    flex-shrink: 0;
}
.rdg-chapter-title {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rdg-chapter-words {
    font-size: 11.5px; color: var(--rdg-text-3);
    flex-shrink: 0;
}

/* 讨论列表 */
.rdg-threads { list-style: none; padding: 0; margin: 0; }
.rdg-thread-item {
    padding: 12px 0;
    border-bottom: 1px dashed var(--rdg-border);
    font-size: 13.5px;
    display: flex; align-items: center; gap: 10px;
    flex-wrap: wrap;
}
.rdg-thread-item:last-child { border-bottom: 0; }
.rdg-thread-item a {
    flex: 1; min-width: 0;
    color: var(--rdg-text);
    text-decoration: none;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rdg-thread-item a:hover { color: var(--rdg-primary); }
.rdg-thread-meta {
    font-size: 11.5px; color: var(--rdg-text-3);
    flex-shrink: 0;
}

/* 成员 */
.rdg-members {
    display: flex; flex-wrap: wrap; gap: 6px;
}
.rdg-member {
    display: inline-flex; align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    background: var(--rdg-bg);
    color: var(--rdg-text-2);
    text-decoration: none;
    border: 1px solid var(--rdg-border);
    transition: all .15s;
}
.rdg-member:hover {
    color: var(--rdg-primary);
    background: var(--rdg-primary-light);
    border-color: var(--rdg-primary);
}

/* 统计小卡 */
.rdg-stat-row {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
}
.rdg-stat {
    flex: 1 1 100px;
    padding: 12px 14px;
    background: var(--rdg-card);
    border: 1px solid var(--rdg-border);
    border-radius: 8px;
    text-align: center;
}
.rdg-stat-num {
    font-size: 20px; font-weight: 700;
    color: var(--rdg-primary);
    line-height: 1.2;
}
.rdg-stat-lbl {
    font-size: 11.5px; color: var(--rdg-text-3);
    margin-top: 4px;
}

/* 阅读进度 */
.rdg-progress {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    background: var(--rdg-primary-light);
    border-radius: 8px;
    font-size: 13px;
    color: var(--rdg-text-2);
    margin-bottom: 12px;
}
.rdg-progress-bar {
    flex: 1; height: 6px;
    background: rgba(0,0,0,.08);
    border-radius: 3px; overflow: hidden;
}
.rdg-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--rdg-primary), var(--rdg-accent));
    border-radius: 3px;
    transition: width .3s;
}

/* 阅读器 */
.rdg-reader {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 24px 100px;
    box-sizing: border-box;
}
.rdg-reader-topbar {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--rdg-border);
    flex-wrap: wrap;
}
.rdg-reader-title {
    flex: 1; min-width: 0;
    font-size: 15px; font-weight: 600;
    color: var(--rdg-text-2);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rdg-reader-chapter-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--rdg-text);
    margin: 20px 0 26px;
    line-height: 1.4;
    text-align: center;
}
.rdg-reader-content {
    font-size: 18px;
    line-height: 1.95;
    color: var(--rdg-text);
    word-break: break-word;
}
.rdg-reader-content p {
    margin: 0 0 1em;
    text-indent: 0;
}
.rdg-reader-wordcount {
    text-align: right;
    font-size: 13px;
    color: var(--rdg-text-3);
    margin-top: 30px;
    padding-top: 14px;
    border-top: 1px dashed var(--rdg-border);
}
.rdg-reader-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    display: flex; gap: 10px; justify-content: center;
    padding: 12px 16px;
    background: var(--rdg-card);
    border-top: 1px solid var(--rdg-border);
    z-index: 30;
    box-shadow: 0 -6px 20px rgba(0,0,0,.06);
}
.rdg-reader-navbtn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 9px 22px;
    border-radius: 8px;
    border: 1px solid var(--rdg-border);
    background: var(--rdg-card);
    color: var(--rdg-text);
    text-decoration: none;
    font-size: 13.5px;
    transition: all .15s;
}
.rdg-reader-navbtn:hover {
    border-color: var(--rdg-primary);
    color: var(--rdg-primary);
    background: var(--rdg-primary-light);
}
.rdg-reader-navbtn.disabled {
    opacity: .35; pointer-events: none;
}

/* 移动端 */
@media (max-width: 640px) {
    .rdg-wrap { padding: 12px 12px 30px; }
    .rdg-cover { width: 96px; height: 130px; font-size: 30px; }
    .rdg-hero { padding: 16px; gap: 14px; }
    .rdg-hero-title { font-size: 20px; }
    .rdg-reader { padding: 14px 14px 90px; }
    .rdg-reader-chapter-title { font-size: 19px; margin: 12px 0 18px; }
    .rdg-reader-content { font-size: 16px; }
    .rdg-reader-navbtn { padding: 8px 14px; font-size: 13px; }
    .rdg-chapters { grid-template-columns: 1fr; }
}

/* ============================================================
   圈子首页 Hero · 读书圈一体化增强
   ============================================================ */

/* Hero 里的读书圈标签 */
.grp-reading-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    margin-left: 2px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    color: #2b5f9e;
    background: color-mix(in srgb, #2b5f9e 12%, transparent);
    border: 1px solid color-mix(in srgb, #2b5f9e 30%, transparent);
    line-height: 1.6;
    vertical-align: middle;
    letter-spacing: .2px;
}
html[data-theme="dark"] .grp-reading-badge,
html.dark .grp-reading-badge,
body.dark .grp-reading-badge,
body.theme-dark .grp-reading-badge,
.dark-theme .grp-reading-badge {
    color: #5a8bd8;
    background: rgba(90, 139, 216, .15);
    border-color: rgba(90, 139, 216, .4);
}

/* Hero 里的"小说信息行"（原著 · 章节 · 字数 · 状态） */
.grp-reading-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    font-size: 13px;
    color: var(--mn-text-muted, #8c94a0);
    margin: 0 0 10px;
    line-height: 1.6;
}
.grp-reading-meta strong {
    color: #2b5f9e;
    font-weight: 700;
}
html[data-theme="dark"] .grp-reading-meta strong,
html.dark .grp-reading-meta strong,
body.dark .grp-reading-meta strong,
body.theme-dark .grp-reading-meta strong,
.dark-theme .grp-reading-meta strong {
    color: #5a8bd8;
}
.grp-reading-meta .grp-reading-meta-dot {
    opacity: .5;
}

/* ============================================================
   ★ Hero v2：上下分区布局（信息在上，操作条在下）
   ============================================================ */

/* 覆盖原 .grp-hero 的横向 flex 布局：改为上下两段 */
.grp-hero.grp-hero-v2 {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    flex-wrap: nowrap;
    box-sizing: border-box;
}

/* 上段：封面 + 信息，占满整行 */
.grp-hero-v2 .grp-hero-main {
    display: flex;
    gap: 24px;
    padding: 24px;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
    box-sizing: border-box;
}
.grp-hero-v2 .grp-hero-body {
    flex: 1 1 320px;
    min-width: 0;
}

/* 下段：操作条，横跨整宽 */
.grp-hero-v2 .grp-hero-actionbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    border-top: 1px solid var(--grp-border, #e3e6ec);
    background: color-mix(in srgb, var(--grp-bg, #f5f6f8) 55%, transparent);
    flex-wrap: wrap;
    box-sizing: border-box;
    min-height: 60px;
}

/* 操作组（每组内按钮水平排列，wrap 兜底） */
.grp-hero-v2 .grp-action-group {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
}

/* 通用按钮组自动推到最右，与左侧读书圈组形成两端对齐 */
.grp-hero-v2 .grp-action-group-common {
    margin-left: auto;
}

/* 读书圈主按钮：蓝色实底（"打开小说详情页 ↗"） */
.grp-action-btn-reading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
    color: #fff !important;
    background: linear-gradient(135deg, #2b5f9e, #1f4a80);
    border: 1px solid #1f4a80;
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 3px 10px rgba(43, 95, 158, 0.22);
    transition: transform .15s, box-shadow .2s, filter .15s;
    cursor: pointer;
    font-family: inherit;
}
.grp-action-btn-reading:hover {
    color: #fff !important;
    transform: translateY(-1px);
    filter: brightness(1.06);
    box-shadow: 0 5px 14px rgba(43, 95, 158, 0.34);
}
.grp-action-btn-reading:active {
    transform: translateY(0);
}

/* 读书圈次按钮：白底蓝框（"读书圈首页"） */
.grp-action-btn-reading-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    color: #2b5f9e !important;
    background: #fff;
    border: 1px solid color-mix(in srgb, #2b5f9e 35%, transparent);
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
    transition: all .15s;
    cursor: pointer;
    font-family: inherit;
}
.grp-action-btn-reading-outline:hover {
    background: color-mix(in srgb, #2b5f9e 8%, #fff);
    border-color: #2b5f9e;
    color: #2b5f9e !important;
}

/* 暗色主题适配 */
html[data-theme="dark"] .grp-action-btn-reading,
html.dark .grp-action-btn-reading,
body.dark .grp-action-btn-reading,
body.theme-dark .grp-action-btn-reading,
.dark-theme .grp-action-btn-reading {
    background: linear-gradient(135deg, #4a7bc8, #2b5f9e);
    border-color: #2b5f9e;
}
html[data-theme="dark"] .grp-action-btn-reading-outline,
html.dark .grp-action-btn-reading-outline,
body.dark .grp-action-btn-reading-outline,
body.theme-dark .grp-action-btn-reading-outline,
.dark-theme .grp-action-btn-reading-outline {
    background: rgba(90, 139, 216, 0.08);
    color: #5a8bd8 !important;
    border-color: rgba(90, 139, 216, 0.45);
}
html[data-theme="dark"] .grp-action-btn-reading-outline:hover,
html.dark .grp-action-btn-reading-outline:hover,
body.dark .grp-action-btn-reading-outline:hover,
body.theme-dark .grp-action-btn-reading-outline:hover,
.dark-theme .grp-action-btn-reading-outline:hover {
    background: rgba(90, 139, 216, 0.16);
    color: #5a8bd8 !important;
}

/* 响应式：中屏起按钮区单独成行；移动端整体左对齐更易点击 */
@media (max-width: 900px) {
    .grp-hero-v2 .grp-hero-main { padding: 20px; gap: 18px; }
    .grp-hero-v2 .grp-hero-actionbar { padding: 12px 20px; }
}
@media (max-width: 768px) {
    .grp-hero-v2 .grp-action-group-common { margin-left: 0; }
}
@media (max-width: 640px) {
    .grp-hero-v2 .grp-hero-main { padding: 14px; gap: 12px; }
    .grp-hero-v2 .grp-hero-actionbar {
        padding: 10px 14px;
        gap: 8px;
        min-height: 0;
    }
    .grp-action-btn-reading,
    .grp-action-btn-reading-outline {
        padding: 7px 14px;
        font-size: 12.5px;
    }
    .grp-hero-v2 .grp-action-group { gap: 6px; }
    .grp-reading-meta { font-size: 12px; gap: 4px 12px; }
}

/* ============================================================
   ★ 圈子首页右栏 · 本书目录面板
   —— 固定最大高度 + 内部滚动；章节链接新窗口打开小说内页
   ============================================================ */
.grp-reading-catalog {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.grp-reading-catalog .grp-h2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}
.grp-reading-catalog-count {
    font-size: 12px;
    font-weight: 400;
    color: var(--mn-text-muted, #8c94a0);
    white-space: nowrap;
}

/* 目录列表：固定最大高度 + 滚动条 */
.grp-reading-catalog-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 420px;
    overflow-y: auto;
    /* Firefox 细滚动条 */
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--mn-text-muted, #888) 35%, transparent) transparent;
    /* 保证内部滚动容器不撑破面板 */
    min-height: 0;
    /* 首尾留点内边距，滚动更自然 */
    padding-right: 2px;
}
/* WebKit 细滚动条 */
.grp-reading-catalog-list::-webkit-scrollbar { width: 6px; }
.grp-reading-catalog-list::-webkit-scrollbar-track {
    background: transparent;
}
.grp-reading-catalog-list::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--mn-text-muted, #888) 30%, transparent);
    border-radius: 3px;
    transition: background .15s;
}
.grp-reading-catalog-list::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, #2b5f9e 45%, transparent);
}

.grp-reading-catalog-list li {
    margin: 0;
    padding: 0;
}

/* 单条章节链接 */
.grp-reading-catalog-list a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 6px;
    color: var(--mn-text, #333);
    text-decoration: none;
    font-size: 13px;
    line-height: 1.5;
    transition: background .15s, color .15s;
    min-width: 0;
}
.grp-reading-catalog-list a:hover {
    background: color-mix(in srgb, #2b5f9e 8%, transparent);
    color: #2b5f9e;
}

/* 章号 */
.grp-reading-catalog-no {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 20px;
    padding: 0 5px;
    border-radius: 4px;
    background: color-mix(in srgb, #2b5f9e 10%, transparent);
    color: #2b5f9e;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* 章节标题（超长省略） */
.grp-reading-catalog-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 字数 */
.grp-reading-catalog-words {
    font-size: 11px;
    color: var(--mn-text-muted, #8c94a0);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* 暗色主题适配 */
html[data-theme="dark"] .grp-reading-catalog-no,
html.dark .grp-reading-catalog-no,
body.dark .grp-reading-catalog-no,
body.theme-dark .grp-reading-catalog-no,
.dark-theme .grp-reading-catalog-no {
    background: rgba(90, 139, 216, 0.18);
    color: #5a8bd8;
}
html[data-theme="dark"] .grp-reading-catalog-list a:hover,
html.dark .grp-reading-catalog-list a:hover,
body.dark .grp-reading-catalog-list a:hover,
body.theme-dark .grp-reading-catalog-list a:hover,
.dark-theme .grp-reading-catalog-list a:hover {
    background: rgba(90, 139, 216, 0.14);
    color: #5a8bd8;
}

/* 移动端 */
@media (max-width: 640px) {
    .grp-reading-catalog-list {
        max-height: 320px;
    }
    .grp-reading-catalog-list a {
        padding: 6px 6px;
        font-size: 12.5px;
    }
    .grp-reading-catalog-no {
        min-width: 22px;
        height: 18px;
        font-size: 10.5px;
    }
    .grp-reading-catalog-words {
        display: none;
    }
}