/* ============================================================
   外贸故事集 · 完整样式
   兼容 PC / 移动端 · 含夜间模式
   ============================================================ */

/* ===== 1. 基础重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: #f4f6fa;
    color: #1e293b;
    line-height: 1.6;
    transition: background 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 防止文本被选中（辅助防复制） */
body:not(.allow-select) {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
/* 但输入框允许选中 */
input, textarea, [contenteditable] {
    user-select: text;
    -webkit-user-select: text;
}

a {
    text-decoration: none;
    color: #2563eb;
    transition: color 0.2s;
}
a:hover {
    color: #1d4ed8;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== 2. 通用组件 ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

.btn {
    display: inline-block;
    padding: 10px 28px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.4;
    text-decoration: none;
}
.btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}
.btn:active {
    transform: translateY(0);
}

.btn-outline {
    background: transparent;
    color: #2563eb;
    border: 2px solid #2563eb;
}
.btn-outline:hover {
    background: #2563eb;
    color: #fff;
}

.btn-sm {
    padding: 6px 16px;
    font-size: 13px;
    border-radius: 6px;
}

.btn-large {
    padding: 14px 40px;
    font-size: 18px;
}

.btn:disabled,
.btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ===== 3. 顶部导航 ===== */
.top-nav {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 10px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
    transition: background 0.3s, border-color 0.3s;
    flex-shrink: 0;
    min-height: 60px;
}

.top-nav .logo {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    transition: color 0.3s;
}
.top-nav .logo a {
    color: inherit;
}
.top-nav .logo span {
    color: #2563eb;
}

.top-nav .right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.top-nav .right .badge-group {
    font-size: 18px;
    display: flex;
    gap: 2px;
}
.top-nav .right .score-badge {
    font-size: 13px;
    font-weight: 600;
    background: #f1f5f9;
    padding: 2px 12px;
    border-radius: 20px;
    color: #1e293b;
    transition: background 0.3s, color 0.3s;
}

.dark-toggle {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.dark-toggle:hover {
    background: #f1f5f9;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 26px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.hamburger:hover {
    background: #f1f5f9;
}

/* ===== 4. 底部 ===== */
.site-footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 24px 20px 16px;
    text-align: center;
    font-size: 13px;
    color: #94a3b8;
    margin-top: auto;
    transition: background 0.3s, border-color 0.3s;
}
.site-footer .footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.site-footer .footer-links a {
    color: #64748b;
    font-size: 13px;
}
.site-footer .footer-links a:hover {
    color: #2563eb;
}
.site-footer p {
    margin: 0;
}

/* ===== 5. 首页 ===== */
.home-section {
    padding: 30px 0 50px;
}
.home-header {
    text-align: center;
    padding: 20px 0 30px;
}
.home-header h1 {
    font-size: 32px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 6px;
}
.home-header .subtitle {
    font-size: 17px;
    color: #64748b;
}

.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.story-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px 26px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    border: 1px solid #eef2f6;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
}
.story-card:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    transform: translateY(-3px);
    border-color: #dbeafe;
}

.story-card .story-badge {
    font-size: 12px;
    color: #2563eb;
    background: #eff6ff;
    padding: 2px 12px;
    border-radius: 20px;
    display: inline-block;
    width: fit-content;
    margin-bottom: 10px;
    font-weight: 500;
}
.story-card h2 {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
    line-height: 1.3;
}
.story-card .story-sub {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 12px;
}
.story-card .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}
.story-card .tags .tag {
    background: #f1f5f9;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 12px;
    color: #475569;
    transition: background 0.2s;
}
.story-card .card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
}
.story-card .card-footer .meta {
    font-size: 13px;
    color: #94a3b8;
}

.more-tip {
    text-align: center;
    padding: 40px 0 20px;
    color: #94a3b8;
    font-size: 15px;
}
.more-tip .small {
    font-size: 13px;
    margin-top: 4px;
}

/* ===== 6. 扉页 ===== */
.cover-page {
    max-width: 780px;
    margin: 30px auto;
    background: #ffffff;
    border-radius: 24px;
    padding: 48px 44px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid #eef2f6;
    transition: background 0.3s, border-color 0.3s;
}

.cover-page .story-id {
    font-size: 13px;
    color: #94a3b8;
    letter-spacing: 2px;
    font-weight: 500;
}
.cover-page h1 {
    font-size: 34px;
    font-weight: 800;
    margin: 6px 0 4px;
    line-height: 1.2;
    color: #0f172a;
}
.cover-page .subtitle {
    font-size: 18px;
    color: #64748b;
    margin-bottom: 18px;
}

.cover-page .tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 18px;
}
.cover-page .tag-list .tag {
    background: #dbeafe;
    color: #1e40af;
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.cover-page .meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
    background: #f8fafc;
    padding: 18px 22px;
    border-radius: 12px;
    margin: 16px 0;
    transition: background 0.3s;
}
.cover-page .meta-grid > div {
    font-size: 14px;
    color: #1e293b;
}
.cover-page .meta-grid strong {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cover-page .core-methods {
    background: #f0f7ff;
    padding: 16px 22px;
    border-radius: 12px;
    margin: 16px 0;
    border: 1px solid #dbeafe;
}
.cover-page .core-methods strong {
    color: #1e40af;
    font-size: 14px;
    display: block;
    margin-bottom: 4px;
}
.cover-page .core-methods p {
    font-size: 14px;
    color: #1e293b;
    margin: 0;
}

.cover-page .action-area {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 28px;
    padding-top: 28px;
    border-top: 1px solid #e2e8f0;
}
.cover-page .action-area .btn {
    flex: 1;
    min-width: 180px;
}
.cover-page .interact-hint {
    margin-top: 16px;
    font-size: 14px;
    color: #94a3b8;
    text-align: center;
}

/* ===== 7. 阅读器 ===== */
.reader-wrapper {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 60px - 100px);
    background: #ffffff;
    transition: background 0.3s;
}

/* 侧边栏 */
.reader-sidebar {
    width: 280px;
    background: #fafbfc;
    border-right: 1px solid #e2e8f0;
    overflow-y: auto;
    padding: 20px 16px;
    flex-shrink: 0;
    transition: background 0.3s, border-color 0.3s, transform 0.3s ease;
    height: 100%;
    max-height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
}

.reader-sidebar .user-box {
    background: #ffffff;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 18px;
    border: 1px solid #e2e8f0;
    transition: background 0.3s, border-color 0.3s;
}
.reader-sidebar .user-box .user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.reader-sidebar .user-box .label {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}
.reader-sidebar .user-box .name-input {
    display: flex;
    gap: 6px;
    margin-top: 2px;
    width: 100%;
    max-width: 100%;
    flex-wrap: nowrap;
}
.reader-sidebar .user-box .name-input input {
    flex: 1 1 0%;
    min-width: 40px;
    max-width: 100%;
    padding: 5px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.reader-sidebar .user-box .name-input input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.reader-sidebar .user-box .name-input .btn-sm {
    flex: 0 0 auto;
    padding: 5px 14px;
    font-size: 13px;
    white-space: nowrap;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1.4;
    min-width: fit-content;
}
.reader-sidebar .user-box .name-input .btn-sm:hover {
    background: #1d4ed8;
}
.reader-sidebar .user-box .user-stats {
    display: flex;
    gap: 16px;
    margin-top: 8px;
    font-size: 14px;
    color: #475569;
    padding-top: 8px;
    border-top: 1px solid #f1f5f9;
}

/* 目录列表 */
.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.toc-list li {
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.toc-list li:hover {
    background: #f1f5f9;
}
.toc-list li.active {
    background: #eff6ff;
    border-left-color: #2563eb;
    color: #1e40af;
    font-weight: 600;
}
.toc-list li .status {
    font-size: 14px;
    color: #94a3b8;
}
.toc-list li .status.done {
    color: #22c55e;
}

/* 侧边栏底部 */
.sidebar-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sidebar-actions .full-width {
    width: 100%;
    text-align: center;
}
.sidebar-actions .external-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 6px;
}
.sidebar-actions .external-links a {
    font-size: 12px;
    color: #94a3b8;
    padding: 2px 10px;
    border-radius: 12px;
    background: #f1f5f9;
    transition: all 0.2s;
}
.sidebar-actions .external-links a:hover {
    background: #e2e8f0;
    color: #2563eb;
}

/* 正文区 */
.reader-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px 44px 50px;
    background: #ffffff;
    transition: background 0.3s;
    min-width: 0;
}

.reader-content .chapter-header {
    margin-bottom: 24px;
}
.reader-content .chapter-title {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}
.reader-content .chapter-sub {
    color: #64748b;
    font-size: 15px;
    border-left: 4px solid #2563eb;
    padding-left: 16px;
    background: #f8fafc;
    padding: 10px 18px;
    border-radius: 0 8px 8px 0;
    transition: background 0.3s;
}

.reader-content .story-text p {
    font-size: 17px;
    line-height: 1.9;
    margin-bottom: 18px;
    color: #1e293b;
    transition: color 0.3s;
}
.reader-content .story-text .dialogue {
    background: #f1f5f9;
    padding: 14px 20px;
    border-radius: 8px;
    margin: 16px 0;
    border-left: 4px solid #94a3b8;
    transition: background 0.3s;
    font-style: italic;
}
.reader-content .story-text .highlight-box {
    background: #eff6ff;
    padding: 14px 20px;
    border-radius: 8px;
    margin: 16px 0;
    border: 1px solid #bfdbfe;
}
.reader-content .story-text .highlight-box strong {
    color: #1e40af;
}

/* 互动卡片 */
.interaction-box {
    margin-top: 40px;
    border-top: 2px dashed #d1d5db;
    padding-top: 28px;
}
.interaction-box h3 {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #0f172a;
}
.interaction-box .q-item {
    background: #f8fafc;
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
    transition: background 0.3s, border-color 0.3s;
}
.interaction-box .q-item .q-label {
    font-weight: 600;
    font-size: 15px;
    display: block;
    margin-bottom: 8px;
    color: #1e293b;
}
.interaction-box .q-item .options label {
    display: block;
    padding: 4px 0;
    font-size: 15px;
    cursor: pointer;
    color: #334155;
    transition: color 0.2s;
}
.interaction-box .q-item .options label:hover {
    color: #2563eb;
}
.interaction-box .q-item input[type="radio"] {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}
.interaction-box .actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.interaction-box .feedback-card {
    margin-top: 16px;
    padding: 16px 20px;
    background: #ecfdf5;
    border-left: 4px solid #10b981;
    border-radius: 6px;
    display: none;
    transition: all 0.3s;
}
.interaction-box .feedback-card.show {
    display: block;
}
.interaction-box .feedback-card .feedback-title {
    font-weight: 600;
    color: #065f46;
    font-size: 14px;
}
.interaction-box .feedback-card #feedbackText {
    margin-top: 4px;
    font-size: 15px;
    color: #1e293b;
}
.interaction-box .feedback-card #feedbackText > div {
    margin-top: 4px;
}
.interaction-box .interact-status {
    margin-top: 10px;
    font-size: 14px;
    color: #16a34a;
    display: none;
}
.interaction-box .interact-status.show {
    display: block;
}

/* 笔记章节 */
.notes-section {
    margin-top: 40px;
    border-top: 2px solid #e2e8f0;
    padding-top: 28px;
}
.notes-section h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}
.notes-section .note-block {
    background: #f8fafc;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 12px;
    border-left: 4px solid #2563eb;
}
.notes-section .note-block h4 {
    font-size: 15px;
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 4px;
}
.notes-section .note-block ul {
    margin: 4px 0 0 18px;
    padding: 0;
}
.notes-section .note-block ul li {
    font-size: 14px;
    color: #334155;
    line-height: 1.7;
}

/* 导航按钮 */
.nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    flex-wrap: wrap;
}
.nav-buttons .btn {
    min-width: 120px;
}
.nav-buttons .btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===== 8. 勋章弹窗 ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 998;
    display: none;
    animation: fadeIn 0.3s ease;
}

.badge-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    padding: 36px 44px 32px;
    border-radius: 24px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
    z-index: 999;
    text-align: center;
    border: 1px solid #e2e8f0;
    display: none;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90vw;
    width: 400px;
}
.badge-popup .big-icon {
    font-size: 64px;
    display: block;
}
.badge-popup h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 12px 0 4px;
    color: #0f172a;
}
.badge-popup p {
    color: #64748b;
    font-size: 15px;
    margin: 0 0 16px;
}
.badge-popup .btn {
    margin-top: 4px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes popIn {
    from {
        transform: translate(-50%, -50%) scale(0.85);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* ===== 9. 错误/提示页 ===== */
.error {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}
.error p {
    font-size: 18px;
}

/* ===== 10. 夜间模式 ===== */
body.dark {
    background: #0f172a;
    color: #e2e8f0;
}

body.dark .top-nav {
    background: #1e293b;
    border-bottom-color: #334155;
}
body.dark .top-nav .logo {
    color: #f1f5f9;
}
body.dark .top-nav .right .score-badge {
    background: #334155;
    color: #e2e8f0;
}
body.dark .dark-toggle:hover {
    background: #334155;
}
body.dark .hamburger:hover {
    background: #334155;
}

body.dark .site-footer {
    background: #1e293b;
    border-top-color: #334155;
}
body.dark .site-footer .footer-links a {
    color: #94a3b8;
}
body.dark .site-footer .footer-links a:hover {
    color: #60a5fa;
}

body.dark .story-card {
    background: #1e293b;
    border-color: #334155;
}
body.dark .story-card:hover {
    border-color: #3b82f6;
}
body.dark .story-card h2 {
    color: #f1f5f9;
}
body.dark .story-card .story-sub {
    color: #94a3b8;
}
body.dark .story-card .tags .tag {
    background: #334155;
    color: #cbd5e1;
}
body.dark .story-card .card-footer {
    border-top-color: #334155;
}
body.dark .story-card .story-badge {
    background: #1e3a5f;
    color: #60a5fa;
}

body.dark .cover-page {
    background: #1e293b;
    border-color: #334155;
}
body.dark .cover-page h1 {
    color: #f1f5f9;
}
body.dark .cover-page .subtitle {
    color: #94a3b8;
}
body.dark .cover-page .tag-list .tag {
    background: #1e3a5f;
    color: #93c5fd;
}
body.dark .cover-page .meta-grid {
    background: #0f172a;
}
body.dark .cover-page .meta-grid > div {
    color: #e2e8f0;
}
body.dark .cover-page .core-methods {
    background: #0f172a;
    border-color: #1e3a5f;
}
body.dark .cover-page .core-methods strong {
    color: #60a5fa;
}
body.dark .cover-page .core-methods p {
    color: #e2e8f0;
}
body.dark .cover-page .action-area {
    border-top-color: #334155;
}

body.dark .reader-wrapper {
    background: #0f172a;
}

body.dark .reader-sidebar {
    background: #1e293b;
    border-right-color: #334155;
}
body.dark .reader-sidebar .user-box {
    background: #0f172a;
    border-color: #334155;
}
body.dark .reader-sidebar .user-box .label {
    color: #f1f5f9;
}
body.dark .reader-sidebar .user-box .user-stats {
    border-top-color: #334155;
    color: #cbd5e1;
}
body.dark .reader-sidebar .user-box .name-input input {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}
body.dark .reader-sidebar .user-box .name-input input:focus {
    border-color: #3b82f6;
}
body.dark .toc-list li {
    color: #cbd5e1;
}
body.dark .toc-list li:hover {
    background: #0f172a;
}
body.dark .toc-list li.active {
    background: #1e3a5f;
    color: #93c5fd;
}
body.dark .sidebar-actions {
    border-top-color: #334155;
}
body.dark .sidebar-actions .external-links a {
    background: #334155;
    color: #94a3b8;
}
body.dark .sidebar-actions .external-links a:hover {
    background: #475569;
    color: #60a5fa;
}

body.dark .reader-content {
    background: #0f172a;
}
body.dark .reader-content .chapter-title {
    color: #f1f5f9;
}
body.dark .reader-content .chapter-sub {
    color: #94a3b8;
    background: #1e293b;
}
body.dark .reader-content .story-text p {
    color: #e2e8f0;
}
body.dark .reader-content .story-text .dialogue {
    background: #1e293b;
    border-left-color: #475569;
}
body.dark .reader-content .story-text .highlight-box {
    background: #1e293b;
    border-color: #334155;
}
body.dark .reader-content .story-text .highlight-box strong {
    color: #60a5fa;
}
body.dark .interaction-box {
    border-top-color: #334155;
}
body.dark .interaction-box h3 {
    color: #f1f5f9;
}
body.dark .interaction-box .q-item {
    background: #1e293b;
    border-color: #334155;
}
body.dark .interaction-box .q-item .q-label {
    color: #f1f5f9;
}
body.dark .interaction-box .q-item .options label {
    color: #cbd5e1;
}
body.dark .interaction-box .q-item .options label:hover {
    color: #60a5fa;
}
body.dark .interaction-box .feedback-card {
    background: #064e3b;
    border-left-color: #10b981;
}
body.dark .interaction-box .feedback-card .feedback-title {
    color: #6ee7b7;
}
body.dark .interaction-box .feedback-card #feedbackText {
    color: #d1fae5;
}
body.dark .interaction-box .interact-status {
    color: #34d399;
}
body.dark .notes-section {
    border-top-color: #334155;
}
body.dark .notes-section h3 {
    color: #f1f5f9;
}
body.dark .notes-section .note-block {
    background: #1e293b;
    border-left-color: #3b82f6;
}
body.dark .notes-section .note-block h4 {
    color: #60a5fa;
}
body.dark .notes-section .note-block ul li {
    color: #e2e8f0;
}
body.dark .nav-buttons {
    border-top-color: #334155;
}

body.dark .badge-popup {
    background: #1e293b;
    border-color: #334155;
}
body.dark .badge-popup h3 {
    color: #f1f5f9;
}
body.dark .badge-popup p {
    color: #94a3b8;
}
body.dark .overlay {
    background: rgba(0, 0, 0, 0.7);
}

body.dark .home-header h1 {
    color: #f1f5f9;
}
body.dark .home-header .subtitle {
    color: #94a3b8;
}
body.dark .more-tip {
    color: #64748b;
}

body.dark .error {
    color: #64748b;
}

/* ===== 11. 响应式设计 ===== */

/* 平板及小屏笔记本 */
@media (max-width: 1024px) {
    .reader-content {
        padding: 24px 28px 40px;
    }
    .cover-page {
        padding: 36px 28px;
    }
}

/* 手机 */
@media (max-width: 768px) {
    /* 导航 */
    .top-nav {
        padding: 8px 16px;
        min-height: 52px;
    }
    .top-nav .logo {
        font-size: 17px;
    }
    .top-nav .right .badge-group {
        font-size: 16px;
    }
    .top-nav .right .score-badge {
        font-size: 12px;
        padding: 1px 10px;
    }
    .hamburger {
        display: block;
    }
    .top-nav .right .btn-outline {
        display: none;
    }

 

    /* 遮罩 */
    #sidebarOverlay {
        display: none !important;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 150;
        backdrop-filter: blur(2px);
    }
    #sidebarOverlay.active {
        display: block !important;
    }

    .reader-content {
        padding: 18px 16px 30px;
    }
    .reader-content .chapter-title {
        font-size: 22px;
    }
    .reader-content .story-text p {
        font-size: 16px;
        line-height: 1.85;
    }
    .reader-content .story-text .dialogue {
        padding: 12px 16px;
        font-size: 15px;
    }

    /* 互动 */
    .interaction-box .q-item {
        padding: 12px 14px;
    }
    .interaction-box .q-item .q-label {
        font-size: 14px;
    }
    .interaction-box .q-item .options label {
        font-size: 14px;
        padding: 3px 0;
    }

    /* 扉页 */
    .cover-page {
        padding: 24px 18px;
        margin: 12px 10px;
        border-radius: 16px;
    }
    .cover-page h1 {
        font-size: 26px;
    }
    .cover-page .subtitle {
        font-size: 16px;
    }
    .cover-page .meta-grid {
        grid-template-columns: 1fr;
        gap: 6px;
        padding: 14px 16px;
    }
    .cover-page .action-area {
        flex-direction: column;
    }
    .cover-page .action-area .btn {
        min-width: auto;
        width: 100%;
    }

    /* 首页 */
    .home-section {
        padding: 16px 0 30px;
    }
    .home-header h1 {
        font-size: 26px;
    }
    .story-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .story-card {
        padding: 18px 20px;
    }

    .container {
        padding: 0 16px;
    }

    .nav-buttons .btn {
        min-width: 80px;
        padding: 8px 18px;
        font-size: 14px;
    }

    .badge-popup {
        padding: 28px 24px 24px;
        width: 88vw;
    }
    .badge-popup .big-icon {
        font-size: 48px;
    }
    .badge-popup h3 {
        font-size: 20px;
    }

    .site-footer {
        padding: 16px 16px 12px;
        font-size: 12px;
    }
    .site-footer .footer-links {
        gap: 12px;
    }
    /* 侧边栏打开时，主内容区域宽度自适应 */
    .reader-wrapper {
        position: relative;
        overflow: hidden;
    }
    .reader-content {
        width: 100%;
        padding: 18px 16px 30px;
        flex: 1;
        min-width: 0;
    }
    
    /* 确保侧边栏在移动端是覆盖层，不挤压主内容 */
    .reader-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        z-index: 200;
        transform: translateX(-105%);
        transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
        background: #fafbfc;
        border-radius: 0 16px 16px 0;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
        padding-top: 60px;
        overflow-y: auto;
    }
    .reader-sidebar.open {
        transform: translateX(0);
    }
    
    /* 遮罩层 */
    #sidebarOverlay {
        display: none !important;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 150;
        backdrop-filter: blur(2px);
    }
    #sidebarOverlay.active {
        display: block !important;
    }	
}

/* 超小屏 */
@media (max-width: 420px) {
    .reader-content {
        padding: 14px 12px 24px;
    }
    .reader-content .chapter-title {
        font-size: 20px;
    }
    .reader-content .story-text p {
        font-size: 15px;
        line-height: 1.8;
    }
    .top-nav .logo {
        font-size: 15px;
    }
    .cover-page h1 {
        font-size: 22px;
    }
    .interaction-box .q-item {
        padding: 10px 12px;
    }
    .interaction-box .q-item .q-label {
        font-size: 13px;
    }
    .interaction-box .q-item .options label {
        font-size: 13px;
    }
    .btn {
        padding: 8px 18px;
        font-size: 14px;
    }
    .btn-large {
        padding: 12px 28px;
        font-size: 16px;
    }
    .badge-popup {
        padding: 20px 16px 20px;
    }
}

/* ===== 12. 工具类 ===== */
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.w-full { width: 100%; }

/* ===== 13. 打印样式 ===== */
@media print {
    .top-nav, .reader-sidebar, .nav-buttons, .interaction-box, .site-footer,
    .hamburger, .dark-toggle, .btn, .action-area .btn-outline {
        display: none !important;
    }
    .reader-content {
        padding: 20px !important;
        overflow: visible !important;
    }
    .reader-wrapper {
        display: block !important;
    }
    body {
        background: #fff !important;
        color: #000 !important;
    }
    .story-text p {
        color: #000 !important;
    }
    .cover-page {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}
/* ===== 扉页新增样式 ===== */

.cover-page .cover-description {
    background: #f8fafc;
    padding: 16px 20px;
    border-radius: 12px;
    margin: 16px 0;
    border-left: 4px solid #2563eb;
    transition: background 0.3s;
}
.cover-page .cover-description p {
    margin: 0;
    font-size: 15px;
    line-height: 1.8;
    color: #1e293b;
}

.cover-page .reader-recommend {
    background: #fefce8;
    padding: 16px 20px;
    border-radius: 12px;
    margin: 16px 0;
    border: 1px solid #fde68a;
    transition: background 0.3s, border-color 0.3s;
}
.cover-page .reader-recommend p {
    margin: 4px 0;
    font-size: 14px;
    line-height: 1.7;
    color: #1e293b;
}
.cover-page .reader-recommend p:first-child {
    font-weight: 600;
    color: #92400e;
}

.cover-page .reading-tip {
    background: #eff6ff;
    padding: 14px 18px;
    border-radius: 10px;
    margin: 16px 0;
    border: 1px solid #bfdbfe;
    font-size: 14px;
    line-height: 1.7;
    color: #1e293b;
    transition: background 0.3s, border-color 0.3s;
}
.cover-page .reading-tip strong {
    color: #1e40af;
}

/* 夜间模式适配 */
body.dark .cover-page .cover-description {
    background: #1e293b;
}
body.dark .cover-page .cover-description p {
    color: #e2e8f0;
}

body.dark .cover-page .reader-recommend {
    background: #422006;
    border-color: #78350f;
}
body.dark .cover-page .reader-recommend p {
    color: #fde68a;
}
body.dark .cover-page .reader-recommend p:first-child {
    color: #fbbf24;
}

body.dark .cover-page .reading-tip {
    background: #172554;
    border-color: #1e3a5f;
    color: #e2e8f0;
}
body.dark .cover-page .reading-tip strong {
    color: #60a5fa;
}
/* ===== 强制夜间模式 ===== */
html.dark {
    background: #0f172a !important;
}

html.dark body {
    background: #0f172a !important;
    color: #e2e8f0 !important;
}

html.dark .top-nav {
    background: #1e293b !important;
    border-bottom-color: #334155 !important;
}

html.dark .top-nav .logo {
    color: #f1f5f9 !important;
}

html.dark .reader-sidebar {
    background: #1e293b !important;
    border-right-color: #334155 !important;
}

html.dark .reader-content {
    background: #0f172a !important;
}

html.dark .reader-content .chapter-title {
    color: #f1f5f9 !important;
}

html.dark .reader-content .story-text p {
    color: #e2e8f0 !important;
}

html.dark .reader-sidebar .user-box {
    background: #0f172a !important;
    border-color: #334155 !important;
}

html.dark .reader-sidebar .user-box .label {
    color: #f1f5f9 !important;
}

html.dark .reader-sidebar .user-box .name-input input {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
}

html.dark .reader-sidebar .user-box .user-stats {
    border-top-color: #334155 !important;
    color: #cbd5e1 !important;
}

html.dark .toc-list li {
    color: #cbd5e1 !important;
}

html.dark .toc-list li.active {
    background: #1e3a5f !important;
    color: #93c5fd !important;
}

html.dark .toc-list li:hover {
    background: #0f172a !important;
}

html.dark .interaction-box .q-item {
    background: #1e293b !important;
    border-color: #334155 !important;
}

html.dark .interaction-box .q-item .q-label {
    color: #f1f5f9 !important;
}

html.dark .interaction-box h3 {
    color: #f1f5f9 !important;
}

html.dark .nav-buttons {
    border-top-color: #334155 !important;
}

html.dark .sidebar-actions {
    border-top-color: #334155 !important;
}

html.dark .sidebar-actions .external-links a {
    background: #334155 !important;
    color: #94a3b8 !important;
}

html.dark .sidebar-actions .external-links a:hover {
    background: #475569 !important;
    color: #60a5fa !important;
}

html.dark .dark-toggle {
    color: #fbbf24 !important;
}

html.dark .site-footer {
    background: #1e293b !important;
    border-top-color: #334155 !important;
}

html.dark .site-footer .footer-links a {
    color: #94a3b8 !important;
}
 
/* ===== 夜间模式 - 投票选项加强 ===== */
html.dark .interaction-box .q-item .options label,
body.dark .interaction-box .q-item .options label {
    color: #e2e8f0 !important;
}

html.dark .interaction-box .q-item .options label:hover,
body.dark .interaction-box .q-item .options label:hover {
    color: #93c5fd !important;
}

html.dark .vote-stat,
body.dark .vote-stat {
    color: #94a3b8 !important;
}

html.dark .interaction-box .q-item .q-label,
body.dark .interaction-box .q-item .q-label {
    color: #f1f5f9 !important;
}

html.dark .interaction-box h3,
body.dark .interaction-box h3 {
    color: #f1f5f9 !important;
}
/* ============================================================
   阅读工具栏
   ============================================================ */

.reading-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: #f8fafc;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid #e2e8f0;
    flex-wrap: wrap;
    transition: background 0.3s, border-color 0.3s;
}

.reading-toolbar .toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.reading-toolbar .toolbar-divider {
    width: 1px;
    height: 24px;
    background: #e2e8f0;
    flex-shrink: 0;
}

.reading-toolbar .toolbar-btn {
    padding: 4px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #1e293b;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.6;
    min-width: 36px;
}

.reading-toolbar .toolbar-btn:hover {
    background: #f1f5f9;
    border-color: #2563eb;
}

.reading-toolbar .toolbar-btn:active {
    transform: scale(0.95);
}

.reading-toolbar .toolbar-btn.active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.reading-toolbar .toolbar-btn.active:hover {
    background: #1d4ed8;
}

.reading-toolbar .font-size-indicator {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
    min-width: 28px;
    text-align: center;
}

.reading-toolbar .speech-status {
    font-size: 13px;
    color: #94a3b8;
    min-width: 60px;
}

/* 夜间模式适配 */
body.dark .reading-toolbar {
    background: #1e293b;
    border-color: #334155;
}

body.dark .reading-toolbar .toolbar-btn {
    background: #0f172a;
    color: #e2e8f0;
    border-color: #475569;
}

body.dark .reading-toolbar .toolbar-btn:hover {
    background: #334155;
    border-color: #60a5fa;
}

body.dark .reading-toolbar .toolbar-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

body.dark .reading-toolbar .font-size-indicator {
    color: #94a3b8;
}

body.dark .reading-toolbar .toolbar-divider {
    background: #334155;
}

body.dark .reading-toolbar .speech-status {
    color: #64748b;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .reading-toolbar {
        gap: 10px;
        padding: 8px 12px;
        flex-wrap: wrap;
    }
    .reading-toolbar .toolbar-btn {
        padding: 4px 10px;
        font-size: 13px;
        min-width: 32px;
    }
    .reading-toolbar .toolbar-divider {
        height: 20px;
    }
    .reading-toolbar .speech-status {
        font-size: 12px;
        min-width: 40px;
    }
}

@media (max-width: 420px) {
    .reading-toolbar {
        gap: 6px;
        padding: 6px 10px;
    }
    .reading-toolbar .toolbar-btn {
        padding: 3px 8px;
        font-size: 12px;
        min-width: 28px;
    }
    .reading-toolbar .font-size-indicator {
        font-size: 12px;
        min-width: 20px;
    }
}