/* 流梦故事 - 主样式表 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5a67d8;
    --primary-light: #9f7aea;
    --secondary-color: #764ba2;
    --accent-color: #f093fb;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 布局 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* 导航栏 */
.navbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 20px;
}

.logo-icon {
    font-size: 28px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--primary-color);
}

/* 按钮 */
.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* 主内容区 */
.main-content {
    flex: 1;
    padding: 40px 0;
}

/* 页脚 */
.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 24px 0;
    text-align: center;
    color: var(--text-muted);
}

/* 首页样式 */
.page-header {
    text-align: center;
    margin-bottom: 48px;
}

.page-header h1 {
    font-size: 40px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    font-size: 18px;
    margin-bottom: 24px;
}

/* 小说网格 */
.novels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.novel-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
}

.novel-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.novel-cover {
    height: 160px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 16px;
    position: relative;
}

.novel-genre-tag {
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.novel-info {
    padding: 20px;
}

.novel-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.novel-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}

.meta-item {
    color: var(--text-muted);
    font-size: 13px;
}

.latest-chapter {
    color: var(--text-secondary);
    font-size: 14px;
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 80px 0;
}

.empty-icon {
    font-size: 72px;
    margin-bottom: 24px;
}

.empty-state h2 {
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 32px;
}

/* 创建页面样式 */
.create-page {
    max-width: 900px;
    margin: 0 auto;
}

/* 进度步骤 */
.progress-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 48px;
    gap: 8px;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
}

.step.active .step-num,
.step.completed .step-num {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.step-label {
    font-size: 13px;
    color: var(--text-muted);
}

.step.active .step-label {
    color: var(--text-primary);
    font-weight: 500;
}

.step-line {
    width: 60px;
    height: 2px;
    background: var(--border-color);
    margin-bottom: 20px;
}

.step-line.completed {
    background: var(--primary-color);
}

/* 步骤内容 */
.step-content {
    display: none;
    background: var(--bg-primary);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.step-content.active {
    display: block;
}

.step-content h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.step-desc {
    color: var(--text-muted);
    margin-bottom: 32px;
}

/* 选项网格 */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.protagonist-grid {
    grid-template-columns: repeat(3, 1fr);
}

.option-card {
    position: relative;
    cursor: pointer;
}

.option-card input {
    position: absolute;
    opacity: 0;
}

.option-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    text-align: center;
    transition: var(--transition);
}

.option-card:hover .option-content {
    border-color: var(--primary-light);
    background: var(--bg-tertiary);
}

.option-card input:checked + .option-content {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
}

.option-icon {
    font-size: 40px;
}

.option-title {
    font-weight: 600;
    font-size: 16px;
}

.option-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* 文本输入区 */
.textarea-container {
    margin-bottom: 16px;
}

.textarea-container textarea {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

.textarea-container textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.textarea-hint {
    text-align: right;
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 8px;
}

.tip {
    color: var(--text-muted);
    font-size: 14px;
}

/* 摘要卡片 */
.summary-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-label {
    color: var(--text-muted);
}

.summary-value {
    font-weight: 500;
}

.ready-text {
    text-align: center;
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* 表单导航 */
.form-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* 加载状态 */
.loading-state {
    text-align: center;
    padding: 80px 0;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-dots span {
    animation: dots 1.5s infinite;
    opacity: 0;
}

.loading-dots span:nth-child(2) { animation-delay: 0.3s; }
.loading-dots span:nth-child(3) { animation-delay: 0.6s; }

@keyframes dots {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.loading-state h3 {
    font-size: 22px;
    margin-bottom: 12px;
}

.loading-desc {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.loading-tips {
    color: var(--text-muted);
    font-size: 14px;
}

/* 小说详情页 */
.novel-page {
    display: flex;
    min-height: calc(100vh - 160px);
}

/* 侧边栏 */
.sidebar {
    width: 300px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    overflow-y: auto;
    position: sticky;
    top: 64px;
    height: calc(100vh - 64px);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.back-link:hover {
    color: var(--primary-color);
}

.novel-title-sidebar {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
}

.novel-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.tag {
    background: var(--bg-tertiary);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* 阶段进度指示器 */
.stage-progress {
    background: var(--bg-tertiary);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 12px;
}
.stage-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.stage-vol-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}
.stage-vol-range {
    color: var(--text-muted, #888);
    font-size: 11px;
}
.stage-vol-pct {
    font-weight: 600;
    color: var(--primary, #667eea);
    font-size: 12px;
}
.stage-progress-bar {
    height: 4px;
    background: var(--bg-secondary, #e0e0e0);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}
.stage-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
    transition: width 0.3s ease;
}
.stage-sub-bar {
    height: 3px;
    margin-bottom: 4px;
}
.stage-sub-bar .stage-progress-fill {
    background: linear-gradient(90deg, #43e97b, #38f9d7);
}
.stage-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.stage-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-secondary, #ccc);
    flex-shrink: 0;
}
.stage-dot.active {
    background: #43e97b;
    box-shadow: 0 0 4px rgba(67, 233, 123, 0.5);
}
.stage-label {
    font-weight: 500;
    font-size: 12px;
    color: var(--text-primary);
    flex: 1;
}
.stage-pct {
    font-size: 11px;
    color: #43e97b;
    font-weight: 500;
}
.stage-goal {
    color: var(--text-muted, #999);
    font-size: 11px;
    margin-top: 4px;
    line-height: 1.4;
}

.chapter-list h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.chapter-list ul {
    list-style: none;
}

.chapter-link {
    display: block;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 14px;
}

.chapter-link:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
}

.chapter-link.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    color: var(--primary-color);
    font-weight: 500;
}

/* 章节目录项 - 操作按钮默认隐藏，hover 时浮现 */
.chapter-item {
    display: flex;
    align-items: center;
}

.chapter-item .chapter-link {
    flex: 1;
    min-width: 0;
}

.chapter-actions {
    display: none;
    gap: 2px;
    flex-shrink: 0;
    margin-left: 4px;
}

.chapter-item:hover .chapter-actions {
    display: flex;
}

.chapter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    opacity: 0.4;
    transition: opacity 0.15s, background 0.15s;
}

.chapter-btn:hover {
    opacity: 1;
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.chapter-btn.delete:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}

.chapter-checkbox {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    margin-right: 6px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

/* 主内容区 */
.novel-main {
    flex: 1;
    padding: 32px 48px;
    max-width: 900px;
}

.novel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    position: sticky;
    top: 64px;
    z-index: 50;
    background: var(--bg-primary);
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.chapter-indicator {
    color: var(--text-muted);
    font-weight: 500;
}

/* 文章顶部章内导航 */
.toolbar-chapter-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}
.toolbar-nav-btn {
    padding: 4px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #fff;
    color: #555;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
    line-height: 1;
}
.toolbar-nav-btn:hover { background: #f0f0f0; border-color: #ccc; }
.toolbar-nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.toolbar-nav-info {
    font-size: 12px;
    color: #888;
    font-weight: 500;
    min-width: 55px;
    text-align: center;
}

/* 故事圣经 */
.bible-panel {
    background: #fefcf3;
    border: 1px solid #f0e6d3;
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 32px;
    display: none;
}

.bible-panel.visible {
    display: block;
}

.bible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.bible-header h3 {
    font-size: 18px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.bible-content pre {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-secondary);
}

.empty-bible {
    color: var(--text-muted);
    text-align: center;
    padding: 24px;
}

/* 章节内容 */
.chapter-content {
    background: var(--bg-primary);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 32px;
}

.chapter-text {
    font-size: 17px;
    line-height: 1.9;
    color: var(--text-primary);
}

.chapter-text p {
    margin-bottom: 16px;
    text-indent: 2em;
}

.empty-chapter {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 0;
}

/* 操作区 */
.novel-actions {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.user-input-section {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.user-input-section textarea {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    transition: var(--transition);
}

.user-input-section textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

#generateNextBtn {
    align-self: center;
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-primary);
    padding: 48px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 400px;
}

.modal-content h3 {
    font-size: 20px;
    margin-bottom: 12px;
}

.modal-content p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.modal-content .loading-dots {
    font-size: 24px;
}

/* 平行世界 Fork 模态框 */
.fork-modal-content {
    padding: 0;
    text-align: left;
    max-width: 550px;
    width: 90%;
    border-radius: 12px;
    overflow: hidden;
}

/* 流式内容样式 */
.stream-content {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-primary);
}

.stream-content p {
    margin-bottom: 12px;
    text-indent: 2em;
}

/* 打字光标效果 */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.typing-cursor {
    display: inline-block;
    width: 8px;
    height: 18px;
    background: var(--primary-color);
    margin-left: 2px;
    animation: blink 1s infinite;
    vertical-align: middle;
}

/* 响应式 */
@media (max-width: 768px) {
    .page-header h1 {
        font-size: 32px;
    }

    .novels-grid {
        grid-template-columns: 1fr;
    }

    .options-grid,
    .protagonist-grid {
        grid-template-columns: 1fr;
    }

    .step-content {
        padding: 24px;
    }

    .novel-page {
        flex-direction: column;
        position: relative;
    }

    /* 移动端侧边栏：默认隐藏，叠加层滑出 */
    .sidebar {
        position: fixed;
        top: 0;
        left: -320px;
        width: 300px;
        height: 100vh;
        z-index: 200;
        border-right: 1px solid var(--border-color);
        border-bottom: none;
        box-shadow: var(--shadow-lg);
        transition: left 0.3s ease;
        overflow-y: auto;
        padding: 20px;
    }

    .sidebar.open {
        left: 0;
    }

    /* 侧边栏遮罩 */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.4);
        z-index: 199;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* 移动端汉堡菜单按钮 */
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        background: none;
        border: none;
        font-size: 14px;
        color: var(--text-secondary);
        cursor: pointer;
        padding: 4px 8px;
    }

    .sidebar-toggle:hover {
        color: var(--primary-color);
    }

    .novel-main {
        padding: 12px 8px;
        max-width: 100%;
    }

    .novel-toolbar {
        position: static;
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 0;
        margin-bottom: 12px;
    }

    .novel-toolbar .btn-secondary,
    .novel-toolbar .btn-export {
        font-size: 12px;
        padding: 4px 8px;
    }

    .toolbar-right {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .chapter-indicator {
        font-size: 12px;
    }

    .chapter-content {
        padding: 16px 12px;
        border-radius: var(--radius-md);
    }

    .chapter-text {
        font-size: 16px;
        line-height: 1.85;
    }

    .chapter-tabs-header .chapter-tab {
        font-size: 12px !important;
        padding: 6px 0 !important;
    }

    .chapter-tab-panel {
        padding: 0;
    }

    .user-input-section {
        flex-direction: column;
    }

    .user-input-section textarea {
        width: 100%;
    }

    .progress-steps {
        flex-wrap: wrap;
    }

    .step-line {
        width: 24px;
    }
}

/* 工具栏右侧 */
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 桌面端隐藏汉堡菜单 */
.sidebar-toggle {
    display: none;
}

@media (max-width: 768px) {
    .sidebar-toggle {
        display: inline-flex;
    }
}

/* 用户菜单 */
.user-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
    padding-left: 16px;
    border-left: 1px solid var(--border-color);
}

.user-greeting {
    font-size: 14px;
    color: var(--text-secondary);
}

.user-points {
    font-size: 13px;
    color: #f0a500;
    font-weight: 600;
    margin-left: 6px;
    padding: 2px 8px;
    background: rgba(240, 165, 0, 0.1);
    border-radius: 10px;
    cursor: help;
}

.dropdown {
    position: relative;
}

/* 用伪元素桥接 toggle 和 menu 之间的间隙，防止鼠标移动时菜单消失 */
.dropdown::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 12px;
    z-index: 999;
}

.dropdown-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    color: var(--text-muted);
    font-size: 12px;
    transition: var(--transition);
}

.dropdown-toggle:hover {
    color: var(--primary-color);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    display: none;
    z-index: 1000;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: var(--transition);
}

.dropdown-menu a:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
}

.dropdown-menu hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 8px 0;
}

/* Flash 消息 */
.flash-messages {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.flash {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.flash-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.flash-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.flash-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.5;
    transition: var(--transition);
}

.flash-close:hover {
    opacity: 1;
}

/* 管理员后台样式 */
.admin-dashboard {
    padding: 40px 0;
}

.admin-header {
    margin-bottom: 32px;
}

.admin-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.stat-card .stat-number {
    font-size: 36px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.stat-card .stat-label {
    color: var(--text-muted);
    font-size: 14px;
}

.admin-section {
    background: white;
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.admin-section h2 {
    font-size: 18px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.admin-table tr:hover {
    background: var(--bg-secondary);
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination a,
.pagination span {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
}

.pagination .current {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.search-form {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-form input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.filter-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-tabs a {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    transition: var(--transition);
}

.filter-tabs a:hover {
    background: var(--bg-secondary);
}

.filter-tabs a.active {
    background: var(--primary-color);
    color: white;
}

/* ==================== 故事管理模态框 ==================== */
.mgmt-modal-content {
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    text-align: left;
    padding: 0;
}

.mgmt-modal-content .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.mgmt-modal-content .modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.mgmt-modal-content .close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

/* Tab 导航 */
.mgmt-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-secondary);
}

.mgmt-tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.mgmt-tab:hover {
    color: var(--primary-color);
    background: var(--bg-tertiary);
}

.mgmt-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: white;
}

/* Tab 内容 */
.mgmt-tab-content {
    display: none;
    padding: 20px 24px;
}

.mgmt-tab-content.active {
    display: block;
}

.mgmt-tab-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.mgmt-section-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

.empty-mgmt {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
    font-size: 14px;
}

/* 伏笔表格 */
.foreshadow-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.foreshadow-table th {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
}

.foreshadow-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.foreshadow-table tr:hover {
    background: var(--bg-secondary);
}

.foreshadow-table .content-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.foreshadow-table .actions-cell {
    white-space: nowrap;
    text-align: right;
}

.foreshadow-table .actions-cell button {
    margin-left: 4px;
}

/* 伏笔状态徽章 */
.badge-planned {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: #f3e8ff;
    color: #6b21a8;
}

.badge-open {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: #dbeafe;
    color: #1e40af;
}

.badge-used {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: #fef3c7;
    color: #92400e;
}

.badge-closed {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    background: #d1fae5;
    color: #065f46;
}

/* 级别徽章 */
.level-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.level-badge.level-small { background: #f0fdf4; color: #166534; }
.level-badge.level-medium { background: #fefce8; color: #854d0e; }
.level-badge.level-large { background: #fef2f2; color: #991b1b; }
.level-badge.level-super { background: #faf5ff; color: #6b21a8; }

/* 伏笔表单 */
.foreshadow-form {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 16px;
}

.foreshadow-form h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    color: var(--text-primary);
}

.foreshadow-form .form-group {
    margin-bottom: 12px;
}

.foreshadow-form .form-group label {
    display: block;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
}

.code-input {
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 13px;
    line-height: 1.5;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* 推进历史 - 时间线样式 */
.advance-badge {
    display: inline-block;
    background: #eef2ff;
    color: #4f46e5;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.advance-badge:hover {
    background: #c7d2fe;
}
.advance-cell {
    text-align: center;
}
.advance-detail-row td {
    padding: 0 16px 12px 16px;
    background: #fafbff;
}
.advance-timeline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 0;
}
.advance-timeline-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    font-size: 13px;
}
.advance-node {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 13px;
    flex-shrink: 0;
}
.advance-node.advance {
    background: #fef3c7;
}
.advance-node.payoff {
    background: #d1fae5;
}
.advance-chapter {
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}
.advance-action-label {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: #eef2ff;
    color: #4f46e5;
    white-space: nowrap;
}
.advance-content {
    color: var(--text-secondary);
    flex: 1;
    white-space: normal;
    max-width: none;
    overflow: visible;
    word-break: break-word;
}

/* 可编辑伏笔推进/回收历史 */
.advance-edit-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.advance-edit-row:last-of-type {
    border-bottom: none;
}
.advance-edit-action {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    background: #fff;
    flex-shrink: 0;
}
.advance-edit-chapter {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    flex-shrink: 0;
}
.advance-edit-timestamp {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    flex-shrink: 0;
}
.advance-edit-delete {
    padding: 2px 8px;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    margin-left: auto;
}
.advance-edit-textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    min-height: 40px;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .advance-timeline-item {
        flex-wrap: wrap;
        gap: 4px;
        padding: 8px;
    }
    .advance-content {
        max-width: 100%;
        width: 100%;
    }
}

/* 演进记录列表 */
.evolution-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.evolution-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.evolution-item .ev-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.evolution-item .ev-type {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary-color);
}

.evolution-item .ev-time {
    font-size: 12px;
    color: var(--text-muted);
}

.evolution-item .ev-instruction {
    background: #fefce8;
    border: 1px solid #fde68a;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 13px;
    color: #92400e;
    margin-bottom: 8px;
}

.evolution-item .ev-summary {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}

.evolution-item .ev-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.evolution-item .ev-meta span {
    margin-right: 16px;
}

/* ==================== 聊天助手悬浮组件 ==================== */

/* 悬浮按钮 */
.chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
    z-index: 999;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.55);
}

/* 聊天面板 */
.chat-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 400px;
    height: 500px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    z-index: 998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.chat-panel.open {
    display: flex;
}
.chat-panel.dragging {
    transition: none !important;
    opacity: 0.92;
}
.chat-panel.resizing {
    transition: none !important;
    opacity: 0.92;
    user-select: none;
}
/* 最小化：只显示头部 */
.chat-panel.minimized {
    height: auto !important;
    min-height: unset !important;
}
.chat-panel.minimized .chat-messages,
.chat-panel.minimized .chat-input-area,
.chat-panel.minimized .chat-resize-handles,
.chat-panel.minimized .chat-session-bar {
    display: none;
}
/* 最大化：占满视口 */
.chat-panel.maximized {
    top: 12px !important;
    left: 12px !important;
    bottom: auto !important;
    right: auto !important;
    width: calc(100vw - 24px) !important;
    height: calc(100vh - 24px) !important;
    border-radius: 12px !important;
}
/* 调整大小手柄（8方向） */
.chat-resize-handles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}
.chat-resize-handles .rz {
    position: absolute;
    pointer-events: auto;
}
/* 四边 */
.rz-n { top: 0; left: 8px; right: 8px; height: 6px; cursor: n-resize; }
.rz-s { bottom: 0; left: 8px; right: 8px; height: 6px; cursor: s-resize; }
.rz-e { right: 0; top: 8px; bottom: 8px; width: 6px; cursor: e-resize; }
.rz-w { left: 0; top: 8px; bottom: 8px; width: 6px; cursor: w-resize; }
/* 四角 */
.rz-ne { top: 0; right: 0; width: 16px; height: 16px; cursor: ne-resize; }
.rz-nw { top: 0; left: 0; width: 16px; height: 16px; cursor: nw-resize; }
.rz-se { bottom: 0; right: 0; width: 16px; height: 16px; cursor: se-resize; }
.rz-sw { bottom: 0; left: 0; width: 16px; height: 16px; cursor: sw-resize; }

/* 聊天面板头部 */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-weight: 600;
    font-size: 15px;
}

.chat-header select option {
    background: #fff;
    color: #333;
}

/* 会话选择栏（头部下方） */
.chat-session-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
.chat-session-bar select {
    flex: 1;
    padding: 5px 8px;
    font-size: 13px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    max-width: none;
}
.chat-session-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
    transition: all 0.15s;
    line-height: 1;
    flex-shrink: 0;
}
.chat-session-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary-color);
    background: var(--bg-primary);
}

.chat-header-drag {
    cursor: grab;
    user-select: none;
}
.chat-header-drag:active {
    cursor: grabbing;
}
.chat-header-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 2px 5px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
}
.chat-header-btn:hover {
    opacity: 1;
    background: rgba(255,255,255,0.15);
}

/* 聊天消息区 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-secondary);
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

/* 聊天气泡 */
.chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
    align-self: flex-start;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

/* 聊天工具进度气泡 */
.chat-bubble.tool-progress {
    align-self: flex-start;
    background: linear-gradient(135deg, #f0f4ff, #e8edf8);
    color: var(--primary-color);
    border: 1px solid rgba(102, 126, 234, 0.2);
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 10px;
    animation: toolPulse 2s infinite;
}

@keyframes toolPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 聊天工具结果气泡 */
.chat-bubble.tool-result {
    align-self: flex-start;
    background: #f8faf8;
    color: var(--text-muted);
    border: 1px solid rgba(76, 175, 80, 0.15);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 8px;
    margin-top: -4px;
    margin-left: 24px;
}

/* 聊天气泡中的 Markdown 文本样式（文档级排版） */
.chat-bubble.assistant.rendered {
    white-space: normal;
    font-size: 14px;
    line-height: 1.75;
}
/* 段落间距 */
.chat-bubble.assistant.rendered p {
    margin: 0 0 10px 0;
}
.chat-bubble.assistant.rendered p:last-child {
    margin-bottom: 0;
}
/* 标题层级 */
.chat-bubble.assistant.rendered h1 {
    margin: 16px 0 10px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 6px;
}
.chat-bubble.assistant.rendered h2 {
    margin: 14px 0 8px 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.chat-bubble.assistant.rendered h3 {
    margin: 12px 0 6px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.chat-bubble.assistant.rendered h4 {
    margin: 10px 0 6px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}
/* 粗体 / 斜体 */
.chat-bubble.assistant.rendered strong {
    font-weight: 700;
    color: var(--text-primary);
}
.chat-bubble.assistant.rendered em {
    font-style: italic;
}
/* 行内代码 */
.chat-bubble.assistant.rendered code {
    background: var(--bg-secondary);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 13px;
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
    color: #e74c3c;
}
/* 代码块 */
.chat-bubble.assistant.rendered pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 12px 14px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre;
}
.chat-bubble.assistant.rendered pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}
/* 列表 */
.chat-bubble.assistant.rendered ul,
.chat-bubble.assistant.rendered ol {
    margin: 8px 0;
    padding-left: 22px;
}
.chat-bubble.assistant.rendered li {
    margin: 3px 0;
}
.chat-bubble.assistant.rendered ul li {
    list-style-type: disc;
}
.chat-bubble.assistant.rendered ol li {
    list-style-type: decimal;
}
/* 引用块 */
.chat-bubble.assistant.rendered blockquote {
    border-left: 3px solid var(--primary-color);
    padding: 6px 14px;
    margin: 10px 0;
    color: var(--text-muted);
    background: var(--bg-secondary);
    border-radius: 0 6px 6px 0;
}
.chat-bubble.assistant.rendered blockquote p {
    margin: 0;
}
/* 删除线 */
.chat-bubble.assistant.rendered del {
    text-decoration: line-through;
    opacity: 0.7;
}
/* 链接 */
.chat-bubble.assistant.rendered a {
    color: var(--primary-color);
    text-decoration: underline;
}
/* 表格 */
.chat-bubble.assistant.rendered table {
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
    width: 100%;
}
.chat-bubble.assistant.rendered th,
.chat-bubble.assistant.rendered td {
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    text-align: left;
}
.chat-bubble.assistant.rendered th {
    background: var(--bg-secondary);
    font-weight: 600;
}
/* 分隔线 */
.chat-bubble.assistant.rendered hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 14px 0;
}
/* Mermaid 图表在聊天气泡中 */
.chat-bubble.assistant.rendered .mermaid {
    margin: 10px 0;
    padding: 10px;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    text-align: center;
}
.chat-bubble.assistant.rendered .mermaid svg {
    max-width: 100%;
    height: auto;
}
.chat-bubble.assistant.rendered .mermaid-error {
    opacity: 0.6;
}

/* 聊天输入区 */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
}

.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: var(--primary-color);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    transform: scale(1.08);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* 聊天打字指示器 */
.chat-typing {
    align-self: flex-start;
    padding: 10px 14px;
    display: flex;
    gap: 4px;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: chatTyping 1.4s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 聊天思考指示器（REACT轮次之间） */
.chat-thinking {
    align-self: flex-start;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #f0f4ff, #e8edf8);
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: 14px;
    font-size: 13px;
    color: var(--primary-color);
}

.chat-thinking::before {
    content: '思考中';
    font-size: 12px;
    opacity: 0.7;
}

.chat-thinking span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: chatThinking 1.2s infinite;
}

.chat-thinking span:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatThinking {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.3; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* 禁用输入框样式 */
.chat-input-area input:disabled {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ==================== 侧边栏管理功能区 ==================== */
.sidebar-mgmt {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sidebar-mgmt-btn {
    flex: 1 1 calc(50% - 6px);
    min-width: 70px;
    padding: 7px 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.sidebar-mgmt-btn:hover {
    background: var(--bg-tertiary);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ==================== 完结状态横幅 ==================== */
.ending-banner {
    text-align: center;
    padding: 40px 24px;
    margin: 20px 0;
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cd 30%, #ffe8a1 60%, #ffd700 100%);
    border: 2px solid #ffc107;
    border-radius: var(--radius-lg);
    box-shadow: 0 4px 20px rgba(255, 193, 7, 0.2);
}

.ending-banner .ending-icon {
    font-size: 48px;
    margin-bottom: 12px;
    animation: endingBounce 1.5s ease-in-out infinite;
}

@keyframes endingBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.ending-banner h2 {
    font-size: 24px;
    color: #856404;
    margin: 0 0 8px 0;
    font-weight: 700;
}

.ending-banner p {
    font-size: 16px;
    color: #92600a;
    margin: 0 0 20px 0;
}

.btn-unend {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #856404;
    background: linear-gradient(135deg, #fff3cd, #ffe8a1);
    border: 1px solid #ffc107;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-unend:hover {
    background: linear-gradient(135deg, #ffe8a1, #ffd700);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
    transform: translateY(-1px);
}

.ending-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btn-postscript {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-postscript:hover {
    background: linear-gradient(135deg, #7b93f5, #8b5fbf);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.btn-postscript:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 续篇按钮 */
.btn-sequel {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-sequel:hover {
    background: linear-gradient(135deg, #34d399, #10b981);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

/* 续篇横幅（创建页） */
.sequel-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 2px solid #10b981;
    border-radius: var(--radius-md);
}

.sequel-banner-icon {
    font-size: 36px;
    flex-shrink: 0;
}

.sequel-banner-text strong {
    font-size: 16px;
    color: #065f46;
}

.sequel-banner-text p {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: #047857;
}

/* 续篇来源标记（首页卡片） */
.sequel-origin {
    font-size: 12px;
    color: #059669;
    margin-bottom: 4px;
    opacity: 0.85;
}

/* 有续篇标记（首页卡片） */
.sequel-has-badge {
    font-size: 11px;
    color: #059669;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 10px;
    padding: 1px 8px;
    display: inline-block;
    margin-bottom: 4px;
}

/* 侧边栏续篇信息 */
.sequel-badge-sidebar {
    font-size: 12px;
    color: #059669;
    margin-top: 6px;
    padding: 4px 10px;
    background: #ecfdf5;
    border-radius: 8px;
    border: 1px solid #a7f3d0;
}

.sequel-badge-sidebar a {
    color: #059669;
    text-decoration: none;
    font-weight: 500;
}

.sequel-badge-sidebar a:hover {
    text-decoration: underline;
}

.sequel-badge-sidebar.sequel-has {
    color: #6366f1;
    background: #eef2ff;
    border-color: #c7d2fe;
}

.sequel-badge-sidebar.sequel-has a {
    color: #6366f1;
}

.postscript-badge {
    display: inline-block;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #9f7aea, #667eea);
    border-radius: 10px;
    margin-right: 6px;
    vertical-align: middle;
}

.btn-end-story {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #856404;
    background: linear-gradient(135deg, #fff3cd, #ffe8a1);
    border: 1px solid #ffc107;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-end-story:hover {
    background: linear-gradient(135deg, #ffe8a1, #ffd700);
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
    transform: translateY(-1px);
}

/* ==================== 响应式 - 聊天面板 ==================== */
@media (max-width: 500px) {
    /* 移动端隐藏调整大小手柄（6px 无法用手指抓取） */
    .chat-resize-handles { display: none; }

    /* 面板全屏化 + safe-area 适配 */
    .chat-panel {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 0;
        height: auto;
        max-height: calc(100vh - 50px);
        border-radius: 12px 12px 0 0;
    }

    /* 最大化使用 safe-area */
    .chat-panel.maximized {
        top: env(safe-area-inset-top, 0) !important;
        left: env(safe-area-inset-left, 0) !important;
        width: calc(100vw - env(safe-area-inset-left, 0) - env(safe-area-inset-right, 0)) !important;
        height: calc(100vh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0)) !important;
        border-radius: 0 !important;
    }

    /* FAB 按钮避开底部安全区 */
    .chat-fab {
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    /* 扩大 header 按钮触控目标（WCAG 44x44） */
    .chat-header-btn {
        min-width: 44px;
        min-height: 44px;
        font-size: 18px;
        padding: 6px 10px;
    }

    /* 扩大 session 按钮最小尺寸 */
    .chat-session-btn {
        min-width: 40px;
        min-height: 36px;
        padding: 6px 10px;
        font-size: 15px;
    }

    /* 扩大发送按钮 */
    .chat-send-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    /* 输入框增大字体（防 iOS 缩放） */
    .chat-input-area input {
        font-size: 16px;
    }
}

/* ==================== 断点续传横幅 ==================== */

.refine-resume-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    font-size: 14px;
    color: #92400e;
    flex-wrap: wrap;
}

.refine-resume-banner span {
    flex: 1;
    min-width: 200px;
}

.refine-resume-banner .btn-sm,
.create-resume-banner .btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 6px;
    white-space: nowrap;
}

/* ==================== 创建流程断点续传横幅 ==================== */

.create-resume-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    font-size: 14px;
    color: #92400e;
    flex-wrap: wrap;
}

.create-resume-banner span {
    flex: 1;
    min-width: 200px;
}

/* ============================================================
   爽剧模块 (Drama Module) 样式
   ============================================================ */

/* --- 剧集卡片网格 --- */
.drama-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.drama-card {
    display: block;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.drama-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.drama-card-gradient {
    height: 8px;
    width: 100%;
}

.drama-card-body {
    padding: 20px;
}

.drama-card-genre {
    margin-bottom: 8px;
}

.genre-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    font-size: 12px;
    color: var(--text-secondary);
}

.drama-card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.drama-card-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
}

.badge-ended {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: #e2e8f0;
    color: #64748b;
    font-size: 11px;
    margin-top: 8px;
}

/* --- 剧集主页 --- */
.drama-series-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

.drama-series-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.series-title {
    font-size: 24px;
    font-weight: 700;
}

.series-meta {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.badge-genre, .badge-mood {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 13px;
    background: var(--bg-tertiary);
}

.episode-count {
    font-size: 14px;
    color: var(--text-muted);
    padding: 4px 8px;
}

.btn-bible {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 13px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
}
.btn-bible:hover {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* 架构弹窗 */
.bible-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bible-overlay-content {
    background: var(--bg-primary);
    border-radius: 12px;
    width: min(720px, 90vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.bible-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.bible-overlay-header h2 {
    font-size: 18px;
    margin: 0;
}
.bible-overlay-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}
.bible-modal {
    background: var(--bg-primary);
    border-radius: 12px;
    width: min(720px, 90vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.bible-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.bible-modal-header h2 {
    font-size: 18px;
    margin: 0;
}
.bible-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-tertiary);
    cursor: pointer;
    font-size: 16px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.bible-close:hover {
    background: var(--danger-color, #e74c3c);
    color: #fff;
}
.bible-modal-body {
    padding: 20px;
    overflow-y: auto;
}

.btn-generate {
    padding: 12px 24px;
    font-size: 16px;
}

/* 两栏布局 */
.drama-main {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    min-height: 60vh;
}

/* 侧边栏 */
.drama-sidebar {
    border-right: 1px solid var(--border-color);
    padding-right: 16px;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section h3 {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 剧集列表 */
.episode-list {
    max-height: 50vh;
    overflow-y: auto;
}

.episode-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.episode-item:hover {
    background: var(--bg-tertiary);
}

.episode-item.active {
    background: rgba(102, 126, 234, 0.1);
    border-left-color: var(--primary-color);
}

.ep-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 60px;
}

.ep-title {
    flex: 1;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ep-shuang-badge {
    font-size: 11px;
    color: #f59e0b;
}

/* 角色列表 */
.character-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    font-size: 13px;
}

.char-name {
    font-weight: 600;
}

.char-role {
    color: var(--text-muted);
    font-size: 12px;
}

.char-archetype {
    background: var(--bg-tertiary);
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

/* 角色管理弹层卡片 */
.char-overlay-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.character-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 10px;
    transition: box-shadow 0.2s;
}
.character-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.char-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.char-card-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}
.char-card-role {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.char-card-role.role-main {
    background: #fef3c7; color: #92400e;
}
.char-card-role.role-villain {
    background: #fee2e2; color: #991b1b;
}
.char-card-role.role-support {
    background: #e0e7ff; color: #3730a3;
}
.char-card-role.role-assist {
    background: #d1fae5; color: #065f46;
}
.char-card-role.role-atmo {
    background: #f3f4f6; color: #6b7280;
}
.char-card-archetype {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 1px 8px;
    border-radius: 8px;
}
.char-card-status {
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 8px;
    margin-left: auto;
}
.char-card-status.status-active { background: #d1fae5; color: #065f46; }
.char-card-status.status-inactive { background: #f3f4f6; color: #6b7280; }
.char-card-status.status-deceased { background: #fee2e2; color: #991b1b; }
.char-card-status.status-left { background: #fef3c7; color: #92400e; }
.char-card-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    font-size: 13px;
}
.char-card-detail {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.char-card-detail strong {
    color: var(--text-primary);
}
.char-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    justify-content: flex-end;
}
.char-card-actions button {
    font-size: 12px;
    padding: 4px 12px;
}

/* 伏笔列表 */
.foreshadow-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    transition: opacity 0.2s;
}
.foreshadow-item:last-child {
    border-bottom: none;
}
.foreshadow-item.fs-status-closed {
    opacity: 0.5;
}
.foreshadow-item.fs-stale {
    border-left: 3px solid #f0ad4e;
    padding-left: 8px;
    background: #fffdf5;
}
.fs-badge-stale {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    background: #fdf5e6;
    color: #c77d20;
    margin-left: 6px;
    font-weight: 500;
}
.fs-last-adv {
    color: var(--text-muted);
    font-size: 11px;
}
.fs-content {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 4px;
}
.fs-meta {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    flex-wrap: wrap;
}
.fs-payoff {
    color: var(--accent-green);
}
.fs-badge {
    padding: 0 4px;
    border-radius: 4px;
    font-size: 10px;
}
.fs-badge-open { background: #fff3cd; color: #856404; }
.fs-badge-used { background: #d4edda; color: #155724; }
.fs-badge-closed { background: #e2e3e5; color: #383d41; }
.fs-actions {
    display: flex;
    gap: 4px;
}
.btn-fs-action {
    padding: 2px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    cursor: pointer;
    font-size: 11px;
    transition: all 0.15s;
}
.btn-fs-action:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}
.btn-fs-use:hover { border-color: var(--accent-green); color: var(--accent-green); }
.btn-fs-close:hover { border-color: var(--accent-red); color: var(--accent-red); }
.btn-fs-delete:hover { border-color: var(--accent-red); color: var(--accent-red); background: #fff5f5; }
.fs-count {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 12px;
}

.fs-add-form {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}
.fs-add-input {
    flex: 1;
    min-width: 0;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg-primary);
    color: var(--text-primary);
}
.fs-add-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* 剧集详情信息面板 */
.ep-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}
.ep-info-item {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 10px 14px;
}
.ep-info-item.ep-info-full {
    grid-column: 1 / -1;
}
.ep-info-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ep-info-value {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}
.ep-info-value.emotion-value {
    font-weight: 600;
}
.shot-chip {
    display: inline-block;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 4px;
    margin-bottom: 4px;
}
.fs-add-input::placeholder {
    color: var(--text-muted);
}
.btn-fs-add {
    padding: 6px 12px;
    border: 1px solid var(--accent-primary);
    border-radius: 6px;
    background: var(--accent-primary);
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: opacity 0.15s;
}
.btn-fs-add:hover {
    opacity: 0.85;
}

/* 伏笔侧边栏摘要 */
.fs-sidebar-summary {
    margin-bottom: 10px;
}
.fs-summary-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.fs-stat {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}
.fs-stat-planned { background: #e8e0f0; color: #5a3d7a; }
.fs-stat-open { background: #fff3cd; color: #856404; }
.fs-stat-used { background: #d4edda; color: #155724; }
.fs-stat-closed { background: #e2e3e5; color: #383d41; }
.fs-stale-warning {
    font-size: 12px;
    color: #c77d20;
    background: #fdf5e6;
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 4px;
}
.btn-fs-manage {
    width: 100%;
    padding: 8px 12px;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
    transition: all 0.15s;
}
.btn-fs-manage:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--bg-primary);
}

/* 伏笔 Modal 表格 */
.drama-fs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: fixed;
}
.drama-fs-table th {
    background: var(--bg-secondary);
    padding: 8px 6px;
    text-align: left;
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    white-space: nowrap;
    font-size: 12px;
}
.drama-fs-table th:nth-child(1) { width: 50px; }   /* 编号 */
.drama-fs-table th:nth-child(2) { /* 内容 - auto */ }
.drama-fs-table th:nth-child(3) { width: 52px; }   /* 级别 */
.drama-fs-table th:nth-child(4) { width: 56px; }   /* 状态 */
.drama-fs-table th:nth-child(5) { width: 42px; }   /* 埋设 */
.drama-fs-table th:nth-child(6) { width: 62px; }   /* 计划回收 */
.drama-fs-table th:nth-child(7) { width: 62px; }   /* 实际回收 */
.drama-fs-table th:nth-child(8) { width: 42px; }   /* 推进 */
.drama-fs-table th:nth-child(9) { width: 64px; }   /* 操作 */
.drama-fs-table td {
    padding: 8px 6px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}
.drama-fs-table td:nth-child(5),
.drama-fs-table td:nth-child(6),
.drama-fs-table td:nth-child(7),
.drama-fs-table td:nth-child(8) {
    text-align: center;
    font-size: 12px;
}
.drama-fs-table td:nth-child(9) {
    text-align: center;
}
.drama-fs-table tr:hover td {
    background: #f8f9ff;
}
.drama-fs-table .fs-content-cell {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.5;
}
.fs-level-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}
.fs-level-episode { background: #e3f2fd; color: #1565c0; }
.fs-level-season { background: #fff3e0; color: #e65100; }
.fs-level-series { background: #fce4ec; color: #c62828; }
.fs-status-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}
.fs-status-planned { background: #e8e0f0; color: #5a3d7a; }
.fs-status-open { background: #fff3cd; color: #856404; }
.fs-status-used { background: #d4edda; color: #155724; }
.fs-status-closed { background: #e2e3e5; color: #383d41; }
.fs-adv-badge {
    cursor: pointer;
    color: var(--accent-primary);
    font-weight: 500;
    font-size: 12px;
}
.fs-adv-badge:hover {
    text-decoration: underline;
}
.fs-adv-detail-row {
    background: #fafafa;
}
.fs-adv-detail-row td {
    padding: 4px 12px 8px;
    font-size: 12px;
    color: #666;
}
.fs-adv-entry {
    padding: 2px 0;
    border-bottom: 1px dotted #e0e0e0;
}
.fs-adv-entry:last-child {
    border-bottom: none;
}

/* 推进日志时间线 */
.advance-timeline {
    font-size: 12px;
}
.advance-entry {
    background: #f5f5f5;
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 6px;
}
.advance-entry-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 10px;
    color: #999;
}
.advance-entry-content {
    color: #444;
    line-height: 1.4;
}
.advance-add-btn {
    font-size: 11px;
    padding: 3px 10px;
    margin-top: 6px;
}
.advance-edit-row {
    margin-top: 6px;
    display: flex;
    gap: 6px;
    align-items: center;
}
.advance-edit-row input {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}
.advance-edit-row select {
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
}

/* 内容区 */
.drama-content {
    min-width: 0;
}

/* Tab 切换 */
.script-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.script-tab {
    padding: 8px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}

.script-tab:hover {
    color: var(--text-primary);
}

.script-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

.script-subtab {
    padding: 4px 12px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    transition: var(--transition);
}

.script-subtab:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.script-subtab.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.btn-copy {
    margin-left: auto;
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    transition: var(--transition);
    white-space: nowrap;
}

.btn-copy:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.script-content {
    min-height: 400px;
}

.episode-view-title {
    font-size: 20px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.shot-content {
    white-space: pre-wrap;
    line-height: 2;
    font-size: 15px;
}

.pure-script {
    white-space: pre-wrap;
    font-family: inherit;
    line-height: 2;
    font-size: 15px;
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius-md);
}

.reflection-text {
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.8;
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius-md);
    overflow-y: auto;
}

/* 钩子提示框 */
.cliffhanger-box {
    margin-top: 20px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-radius: var(--radius-md);
    border-left: 4px solid #f59e0b;
}

.cliffhanger-label {
    font-weight: 700;
    font-size: 14px;
    display: block;
    margin-bottom: 4px;
}

.cliffhanger-box p {
    font-size: 14px;
    margin: 0;
}

/* --- 镜头标记样式 --- */
.shot-marker-texie {
    display: inline;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin: 0 2px;
}

.shot-marker-zhongjing {
    display: inline;
    background: #3b82f6;
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin: 0 2px;
}

.shot-marker-quanjing {
    display: inline;
    background: #10b981;
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin: 0 2px;
}

.shot-marker-zhuanchang {
    display: inline;
    background: #8b5cf6;
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin: 0 2px;
}

.shot-marker-zimu {
    display: inline;
    background: #6b7280;
    color: white;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin: 0 2px;
}

.shot-marker-shuangdian {
    display: inline;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    margin: 0 2px;
    animation: pulse-glow 2s infinite;
}

/* 爽点亮点条 */
.shuang-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(239, 68, 68, 0.08));
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 10px;
    align-items: center;
}

.shuang-strip::before {
    content: '⚡ 爽点亮点';
    font-size: 13px;
    font-weight: 700;
    color: #f59e0b;
    margin-right: 4px;
    white-space: nowrap;
}

.shuang-strip-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    animation: pulse-glow 2.5s infinite;
}

/* 行内爽点标记（带描述） */
.shot-marker-shuangdian-inline {
    display: inline;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin: 0 2px;
    box-shadow: 0 1px 4px rgba(245, 158, 11, 0.35);
    animation: pulse-glow 2s infinite;
    line-height: 1.8;
}

.shot-marker-shuangdian-inline em {
    font-style: normal;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.shot-marker-gouzi {
    display: inline;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    margin: 0 2px;
    animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(239, 68, 68, 0); }
}

/* --- 生成叠加层 --- */
.generating-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-top: 2px solid var(--primary-color);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 60vh;
    overflow-y: auto;
    padding: 16px 24px;
}

.generating-container {
    max-width: 800px;
    margin: 0 auto;
}

.gen-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.gen-spinner-sm {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.gen-stream-content {
    white-space: pre-wrap;
    line-height: 2;
    font-size: 15px;
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius-md);
    min-height: 100px;
}

/* --- 创建向导中的生成状态 --- */
.generation-status {
    text-align: center;
    padding: 40px 20px;
}

.gen-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}

.gen-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.gen-text h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.gen-text p {
    font-size: 14px;
    color: var(--text-muted);
}

.gen-preview {
    max-width: 600px;
    margin: 0 auto;
    text-align: left;
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: var(--radius-md);
}

.gen-preview h4 {
    font-size: 14px;
    margin-bottom: 8px;
}

.gen-preview pre {
    white-space: pre-wrap;
    font-size: 12px;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

/* 空状态 */
.empty-episodes {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.empty-content {
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

/* --- 情感弧线 --- */
.emotion-arc {
    padding: 4px 0;
}

.emotion-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0;
}

.emotion-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid transparent;
}

.emotion-dot:hover {
    transform: scale(1.5);
    border-color: var(--text-primary);
    z-index: 2;
}

/* 10种情感颜色 */
.emotion-羞辱 { background: #6366f1; }
.emotion-反转 { background: #f59e0b; }
.emotion-打脸 { background: #ef4444; }
.emotion-告白 { background: #ec4899; }
.emotion-背叛 { background: #6b7280; }
.emotion-甜宠 { background: #f472b6; }
.emotion-悬疑 { background: #8b5cf6; }
.emotion-温馨 { background: #10b981; }
.emotion-霸气 { background: #f97316; }
.emotion-其他 { background: #94a3b8; }

.emotion-legend {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* 情感标签（小徽章） */
.emotion-tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    margin-left: 4px;
    vertical-align: middle;
}

.emotion-tag-甜宠 { background: #ec4899; }
.emotion-tag-虐心 { background: #6366f1; }
.emotion-tag-紧张 { background: #ef4444; }
.emotion-tag-痛快 { background: #f59e0b; }
.emotion-tag-震惊 { background: #8b5cf6; }
.emotion-tag-感动 { background: #10b981; }
.emotion-tag-温馨 { background: #22c55e; }
.emotion-tag-悬疑 { background: #7c3aed; }
.emotion-tag-霸气 { background: #f97316; }
.emotion-tag-羞辱 { background: #94a3b8; }
.emotion-tag-背叛 { background: #6b7280; }
.emotion-tag-告白 { background: #f472b6; }
.emotion-tag-期待 { background: #14b8a6; }
.emotion-tag-其他 { background: #94a3b8; }

/* --- 名场面卡片 --- */
.highlight-card {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid #fcd34d;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.15);
}

.highlight-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.highlight-icon {
    font-weight: 700;
    font-size: 14px;
    color: #92400e;
}

.btn-share-highlight {
    background: #f59e0b;
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-share-highlight:hover {
    background: #d97706;
}

.highlight-body {
    font-size: 14px;
    line-height: 1.8;
    color: #78350f;
    white-space: pre-wrap;
}

/* --- 质量指标（首页卡片） --- */
.drama-card-good {
    border-left: 4px solid #10b981;
}

.drama-card-medium {
    border-left: 4px solid #f59e0b;
}

.drama-card-low {
    border-left: 4px solid #ef4444;
}

.drama-card-new {
    border-left: 4px solid var(--border-color);
}

.drama-card-metrics {
    display: flex;
    gap: 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--bg-tertiary);
}

.metric-item {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 2px;
}

.quality-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}

.quality-good {
    background: #d1fae5;
    color: #065f46;
}

.quality-medium {
    background: #fef3c7;
    color: #92400e;
}

.quality-low {
    background: #fee2e2;
    color: #991b1b;
}

/* 剧集操作按钮（删除/重写） */
.btn-ep-action {
    font-size: 12px;
    padding: 5px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-regenerate:hover {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}

.btn-delete-ep:hover {
    background: #fee2e2;
    border-color: #ef4444;
    color: #991b1b;
}

/* 剧集列表项中的重写按钮 */
.btn-ep-item-regen {
    margin-left: auto;
    font-size: 11px;
    padding: 3px 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    opacity: 0;
    flex-shrink: 0;
}

.episode-item:hover .btn-ep-item-regen {
    opacity: 1;
    border-color: var(--border-color);
}

.btn-ep-item-regen:hover {
    background: #fef3c7;
    border-color: #f59e0b;
    color: #92400e;
}

/* 级联重写警告 */
.cascade-warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    margin: 10px 0;
    color: #991b1b;
    font-size: 13px;
}

/* 剧集分隔线（多集流式） */
.episode-separator {
    text-align: center;
    padding: 12px 0;
    margin: 16px 0;
    color: #10b981;
    font-weight: 600;
    border-top: 2px dashed var(--border-color);
    border-bottom: 2px dashed var(--border-color);
}

/* ============================================================
   DIFF 对比视图（与小说系统一致）
   ============================================================ */

.diff-modal-content {
    max-width: 900px;
    max-height: 85vh;
}

.inline-diff {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.inline-diff-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 1;
}

.diff-label {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.diff-label-old {
    color: #dc2626;
    background: #fef2f2;
}

.diff-label-new {
    color: #16a34a;
    background: #f0fdf4;
}

.diff-label-stats {
    margin-left: auto;
    font-size: 12px;
    color: #64748b;
}

.diff-stat-add {
    color: #16a34a;
    font-weight: 600;
}

.diff-stat-del {
    color: #dc2626;
    font-weight: 600;
}

.diff-line {
    display: flex;
    align-items: baseline;
    padding: 1px 0;
    border-bottom: 1px solid #f1f5f9;
}

.diff-gutter {
    width: 48px;
    min-width: 48px;
    text-align: right;
    padding-right: 8px;
    color: #94a3b8;
    font-size: 11px;
    user-select: none;
}

.diff-sign {
    width: 20px;
    min-width: 20px;
    text-align: center;
    font-weight: 700;
    user-select: none;
}

.diff-text {
    flex: 1;
    padding-left: 4px;
    white-space: pre-wrap;
    word-break: break-all;
}

.diff-context .diff-text {
    color: #475569;
}

.diff-del {
    background: #fef2f2;
}

.diff-del .diff-sign {
    color: #dc2626;
}

.diff-del .diff-text {
    color: #dc2626;
}

.diff-add {
    background: #f0fdf4;
}

.diff-add .diff-sign {
    color: #16a34a;
}

.diff-add .diff-text {
    color: #16a34a;
}

.diff-skip {
    background: #f8fafc;
    justify-content: center;
}

.diff-skip .diff-text {
    color: #94a3b8;
    font-size: 12px;
    font-style: italic;
    text-align: center;
}

/* 字符级高亮 */
.cdel {
    background: #fca5a5;
    color: #991b1b;
    text-decoration: line-through;
    border-radius: 2px;
    padding: 0 1px;
}

.cins {
    background: #86efac;
    color: #166534;
    border-radius: 2px;
    padding: 0 1px;
}

/* 版本恢复按钮 */
.btn-restore {
    color: #b45309;
    border-color: #f59e0b;
}

.btn-restore:hover {
    background: #fffbeb;
    border-color: #d97706;
    color: #92400e;
}

/* 重试提示 */
.retry-note {
    color: #f59e0b;
    font-size: 13px;
    padding: 8px 0;
    font-style: italic;
    border-bottom: 1px dashed #f59e0b;
    margin: 8px 0;
}

/* --- 质量评分卡片 --- */
.quality-scorecard {
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border: 1px solid #7dd3fc;
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin: 12px 0;
}

.quality-scorecard.quality-final {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-color: #86efac;
}

.scorecard-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.scorecard-breakdown {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    white-space: pre-wrap;
    line-height: 1.6;
}

.scorecard-dims {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.dim-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.dim-good {
    background: #d1fae5;
    color: #065f46;
}

.dim-ok {
    background: #fef3c7;
    color: #92400e;
}

.dim-low {
    background: #fee2e2;
    color: #991b1b;
}

.scorecard-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    font-style: italic;
}

/* 重试徽章（剧集列表） */
.retry-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    background: #fef3c7;
    color: #92400e;
    margin-left: 4px;
    vertical-align: middle;
}

/* --- 生成尝试记录面板 --- */
.attempts-panel {
    margin-top: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.attempts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
}

.attempts-header:hover {
    background: var(--bg-tertiary);
}

.attempts-arrow {
    font-size: 11px;
    transition: transform 0.3s;
}

.attempts-body {
    padding: 8px 16px 16px;
}

.attempt-item {
    padding: 12px;
    margin-top: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border-color);
}

.attempt-item.attempt-final {
    border-left-color: #10b981;
    background: #f0fdf4;
}

.attempt-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.attempt-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    background: #e2e8f0;
    color: var(--text-secondary);
}

.attempt-score {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.attempt-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.attempt-reason {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.attempt-content {
    margin-top: 8px;
}

.attempt-content pre {
    white-space: pre-wrap;
    font-size: 13px;
    line-height: 1.8;
    background: #fff;
    padding: 12px;
    border-radius: var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
}

.btn-attempt-view {
    font-size: 11px;
    padding: 3px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
    color: var(--text-secondary);
}

.btn-attempt-view:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* --- 响应式 --- */
@media (max-width: 768px) {
    .drama-main {
        grid-template-columns: 1fr;
    }
    .drama-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-right: 0;
        padding-bottom: 16px;
    }
    .drama-grid {
        grid-template-columns: 1fr;
    }
}

/* --- 剧集圣经/架构面板 --- */
.bible-content {
    padding: 0 4px;
}

.bible-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--bg-tertiary);
}

.bible-section h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.bible-section p {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.bible-section ul {
    padding-left: 20px;
}

.bible-section ul li {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.arc-card {
    background: var(--bg-secondary);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    border-left: 3px solid var(--primary-color);
}

.arc-card h4 {
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.arc-card p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.key-events {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.event-chip {
    display: inline-block;
    padding: 2px 10px;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
}

/* ============================================================
   对话体 - 微信风格聊天气泡
   ============================================================ */

.chat-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 16px 0;
}

.chat-placeholder {
    text-align: center;
    padding: 40px;
}

.chat-system-msg {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px 16px;
    margin: 4px 0;
}

.chat-row {
    display: flex;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 10px;
}

.chat-row.chat-left {
    justify-content: flex-start;
}

.chat-row.chat-right {
    justify-content: flex-end;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
    user-select: none;
}

.chat-bubble-wrap {
    max-width: 65%;
    display: flex;
    flex-direction: column;
}

.chat-right .chat-bubble-wrap {
    align-items: flex-end;
}

.chat-left .chat-bubble-wrap {
    align-items: flex-start;
}

.chat-char-name {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
    padding: 0 4px;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.7;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-left .chat-bubble {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
}

.chat-right .chat-bubble {
    background: #95ec69;
    border-top-right-radius: 4px;
}

/* ============================================================
   高光 Feed - 瀑布流卡片
   ============================================================ */

.highlights-feed {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 8px 0;
}

.highlights-feed .text-muted {
    grid-column: 1 / -1;
    text-align: center;
}

.highlights-feed .gen-spinner-sm {
    grid-column: 1 / -1;
    width: 24px;
    height: 24px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.highlight-feed-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.highlight-feed-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.feed-ep-num {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.feed-emotion-tag {
    align-self: flex-start;
}

.feed-card-text {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.feed-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid var(--bg-tertiary);
    margin-top: auto;
}

.feed-metrics {
    display: flex;
    gap: 10px;
}

.feed-metric-item {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-feed-share {
    padding: 4px 10px;
    font-size: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-feed-share:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ============================================================
   视频提示词 - 生成按钮
   ============================================================ */

.btn-video-prompt {
    padding: 6px 14px;
    font-size: 13px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    margin: 0 4px;
    transition: all 0.2s;
}
.btn-video-prompt:hover {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}
.btn-video-prompt:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ============================================================
   视频提示词 - 格式选择弹窗
   ============================================================ */

.vp-format-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.vp-format-modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 520px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.vp-format-modal h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    text-align: center;
}

.vp-format-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.vp-format-card {
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}
.vp-format-card:hover {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.05);
}
.vp-format-card.active {
    border-color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
}

.vp-format-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.vp-format-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.vp-format-cancel {
    display: block;
    width: 100%;
    padding: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
}
.vp-format-cancel:hover {
    background: var(--bg-tertiary);
}

/* ============================================================
   视频提示词 - 卡片展示
   ============================================================ */

.vp-cards-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.vp-empty-hint {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.vp-empty-hint p {
    margin: 8px 0;
}

.vp-stream-counter {
    font-size: 13px;
    color: #8b5cf6;
    font-weight: 600;
    animation: vp-pulse 1.5s ease-in-out infinite;
}

.vp-stream-text {
    max-height: 250px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(139, 92, 246, 0.15);
    border-radius: 8px;
    padding: 12px;
    margin: 12px auto 0;
    font-size: 11px;
    line-height: 1.5;
    color: #555;
    text-align: left;
    white-space: pre-wrap;
    word-break: break-all;
    max-width: 600px;
}

@keyframes vp-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.vp-format-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.vp-filter-btn {
    padding: 5px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.vp-filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.vp-filter-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.vp-fallback-note {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    font-size: 13px;
    color: #92400e;
    margin-bottom: 8px;
}

.vp-error {
    color: #ef4444;
    font-weight: 500;
}

.vp-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.2s;
}
.vp-card:hover {
    border-color: #8b5cf6;
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.1);
}

.vp-card-new {
    animation: vp-card-in 0.4s ease-out;
}

@keyframes vp-card-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.vp-card-updated {
    animation: vp-card-flash 0.6s ease-out;
}

@keyframes vp-card-flash {
    0%   { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.5); border-color: #8b5cf6; }
    50%  { box-shadow: 0 0 16px 4px rgba(139, 92, 246, 0.25); border-color: #a78bfa; }
    100% { box-shadow: 0 2px 6px rgba(139, 92, 246, 0.05); border-color: var(--border-color); }
}

.vp-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.vp-scene-label {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.vp-format-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    white-space: nowrap;
}

.vp-duration-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    white-space: nowrap;
    margin-left: auto;
}

.vp-source-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    color: white;
    white-space: nowrap;
    font-weight: 600;
}
.vp-source-rule {
    background: #6b7280;
}
.vp-source-llm {
    background: linear-gradient(135deg, #10b981, #059669);
    animation: vp-badge-pop 0.4s ease-out;
}
@keyframes vp-badge-pop {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.vp-card-body {
    padding: 14px 16px;
}

.vp-field {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
    align-items: baseline;
}
.vp-label {
    font-size: 12px;
    font-weight: 600;
    color: #8b5cf6;
    white-space: nowrap;
    min-width: 56px;
}
.vp-value {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    flex: 1;
}

.vp-full-prompt {
    margin-top: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.vp-full-prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.vp-full-prompt pre {
    margin: 0;
    padding: 12px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

/* 复制按钮 */
.btn-copy-vp {
    padding: 3px 10px;
    font-size: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: all 0.2s;
}
.btn-copy-vp:hover {
    background: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}
.btn-copy-vp.copied {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

/* ============================================================
   视频提示词 - 独立工具页面
   ============================================================ */

.vp-tool-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.vp-tool-header {
    margin-bottom: 24px;
}
.vp-tool-header h1 {
    margin: 8px 0 4px;
    font-size: 24px;
}
.vp-tool-header .back-link {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 8px;
}
.vp-tool-header .back-link:hover {
    color: var(--primary-color);
}

.vp-tool-main {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.vp-tool-editor {
    flex: 1;
    min-width: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.vp-tool-history {
    width: 340px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    position: sticky;
    top: 20px;
}
.vp-tool-history h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
}

.vp-editor-section {
    margin-bottom: 16px;
}
.vp-editor-section h3 {
    margin: 0 0 10px 0;
    font-size: 15px;
}

.vp-field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.vp-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}
.vp-textarea:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}
.vp-full-prompt-input {
    font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.vp-select, .vp-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    box-sizing: border-box;
}
.vp-select:focus, .vp-input:focus {
    outline: none;
    border-color: #8b5cf6;
}

.vp-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.vp-tool-status {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
}
.vp-status-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}
.vp-status-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}
.vp-status-loading {
    background: #e0e7ff;
    color: #3730a3;
    border: 1px solid #6366f1;
}

/* 历史列表 */
.vp-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.vp-history-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    transition: all 0.2s;
}
.vp-history-item:hover {
    border-color: #8b5cf6;
}

.vp-history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.vp-history-series {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.vp-history-preview {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.vp-history-actions {
    display: flex;
    gap: 6px;
}
.btn-vp-load, .btn-vp-delete {
    padding: 3px 10px;
    font-size: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: all 0.2s;
}
.btn-vp-load:hover {
    background: #8b5cf6;
    color: white;
    border-color: #8b5cf6;
}
.btn-vp-delete:hover {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

/* ============================================================
   视频提示词 - 移动端适配
   ============================================================ */

@media (max-width: 768px) {
    .vp-format-selector {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .vp-format-card {
        padding: 12px 8px;
    }
    .vp-format-name {
        font-size: 15px;
    }

    .vp-card-body {
        padding: 10px 12px;
    }

    .vp-tool-main {
        flex-direction: column;
    }
    .vp-tool-history {
        width: 100%;
        max-height: none;
        position: static;
    }
    .vp-editor-actions {
        flex-direction: column;
    }
    .vp-editor-actions .btn {
        width: 100%;
        text-align: center;
    }

    .btn-video-prompt {
        font-size: 12px;
        padding: 5px 10px;
    }
}

/* ============================================================
   短句播报模块
   ============================================================ */

.short-sentence-toolbar {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

.ss-toolbar-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.ss-toolbar-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ss-toolbar-item label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.ss-toolbar-item select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}

.ss-toolbar-item input[type="range"] {
    width: 100px;
}

.ss-toolbar-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
    align-items: center;
}

.sentence-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: calc(100vh - 420px);
    overflow-y: auto;
    padding-right: 4px;
}

.sentence-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    transition: all 0.2s;
}

.sentence-card:hover {
    border-color: #c0c0c0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.sentence-card.sentence-playing {
    background: #e8f5e9;
    border-color: #66bb6a;
    box-shadow: 0 0 8px rgba(76,175,80,0.2);
}

.sentence-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.sentence-card-body {
    flex: 1;
    min-width: 0;
}

.sentence-card-name {
    font-size: 12px;
    color: #888;
    margin-bottom: 2px;
}

.sentence-card-text {
    font-size: 14px;
    color: #333;
    line-height: 1.5;
    word-break: break-all;
}

.sentence-card-play {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.sentence-card-play.btn-play-ready {
    background: #e8f5e9;
    color: #43a047;
}

.sentence-card-play.btn-play-ready:hover {
    background: #c8e6c9;
}

.sentence-card-play.btn-play-pending {
    background: #f5f5f5;
    color: #bbb;
    cursor: not-allowed;
}

.sentence-card.sentence-card-error {
    border-color: #ffcdd2;
    background: #fff5f5;
}

.sentence-card-play.btn-play-error {
    background: #ffebee;
    color: #e53935;
}

.sentence-card-play.btn-play-error:hover {
    background: #ffcdd2;
}

/* 迷你播放器 */
.sentence-audio-bar {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 2px solid #e0e0e0;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
    z-index: 10;
}

.ss-bar-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ss-bar-char {
    font-size: 12px;
    color: #888;
    font-weight: 500;
}

.ss-bar-text {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ss-bar-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.ss-bar-controls .btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.ss-bar-controls .btn-icon:hover {
    background: #f0f0f0;
    border-color: #aaa;
}

.sentence-audio-bar audio {
    display: none;
}

.btn-success {
    background: #43a047;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.btn-success:hover { background: #388e3c; }

.btn-danger {
    background: #e53935;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.btn-danger:hover { background: #c62828; }

/* ============================================================
   思考面板 — 流式生成时展示 LLM 推理过程
   ============================================================ */
.thinking-panel {
    margin-bottom: 16px;
    border: 1px solid #e8d5b5;
    border-radius: 10px;
    overflow: hidden;
    background: #fefdf8;
}

.thinking-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #fef7ed;
    border-bottom: 1px solid #f0e4cc;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}

.thinking-panel-header:hover {
    background: #fef0db;
}

.thinking-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #b45309;
}

.thinking-panel-title .thinking-icon {
    font-size: 16px;
    animation: thinking-pulse 2s ease-in-out infinite;
}

@keyframes thinking-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.thinking-panel-toggle {
    font-size: 12px;
    color: #b45309;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.thinking-panel-toggle:hover {
    background: rgba(180, 83, 9, 0.08);
}

.thinking-panel-body {
    max-height: 240px;
    overflow-y: auto;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.7;
    color: #92400e;
    white-space: pre-wrap;
    word-break: break-word;
}

.thinking-panel.collapsed .thinking-panel-body {
    display: none;
}

.thinking-panel.collapsed .thinking-panel-toggle {
    transform: rotate(-90deg);
}

.thinking-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #f59e0b;
    margin-right: 4px;
    animation: thinking-blink 1.4s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-blink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}
.btn-danger:disabled { background: #ef9a9a; cursor: not-allowed; }

/* ==================== 流梦空间 ==================== */

/* 广场页面 */
.space-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px;
}

.space-hero {
    text-align: center;
    margin-bottom: 32px;
}

.space-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.space-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* 筛选栏 */
.space-filters {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.space-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.space-filter-group label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.space-filter-group select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

/* 作品卡片网格 */
.space-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.space-card {
    display: block;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

.space-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.space-card-header {
    margin-bottom: 10px;
}

.space-card-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.space-card-author {
    font-size: 13px;
    color: var(--text-muted);
}

.space-card-meta {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.space-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.space-tag.genre {
    background: #e8f0fe;
    color: #1967d2;
}

.space-tag.mood {
    background: #f3e8fd;
    color: #7b1fa2;
}

.space-card-theme {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.space-card-stats {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.space-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.space-empty p {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

/* 阅读页 */
.space-read-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

.space-read-header {
    background: var(--bg-primary);
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.space-read-header-content {
    max-width: 1100px;
    margin: 0 auto;
}

.space-back-link {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
}

.space-back-link:hover {
    text-decoration: underline;
}

.space-novel-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 8px;
    margin-bottom: 6px;
}

.space-novel-meta {
    font-size: 14px;
    color: var(--text-muted);
}

.space-novel-meta span {
    margin-right: 16px;
}

.space-novel-intro {
    margin-top: 10px;
    padding: 10px 14px;
    background: #f9f9f9;
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* 阅读布局：左侧目录 + 右侧正文 */
.space-read-layout {
    display: flex;
    gap: 24px;
    max-width: 1100px;
    margin: 0 auto;
}

/* 左侧章节目录 */
.space-toc {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 140px;
    align-self: flex-start;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 12px 0;
}

.space-toc-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 0 16px 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.space-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.space-toc-item {
    border-bottom: 1px solid #f5f5f5;
}

.space-toc-item:last-child {
    border-bottom: none;
}

.space-toc-link {
    display: block;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background 0.15s;
    line-height: 1.4;
}

.space-toc-link:hover {
    background: var(--bg-secondary);
    color: var(--primary-color);
}

.space-toc-item.active .space-toc-link {
    background: #e8f0fe;
    color: var(--primary-color);
    font-weight: 600;
}

.space-toc-item.unpublished .space-toc-link.disabled {
    color: #ccc;
    cursor: not-allowed;
    pointer-events: none;
}

.space-toc-num {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

.space-toc-item.active .space-toc-num {
    color: var(--primary-color);
}

.space-toc-chapter-title {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.space-toc-lock {
    font-size: 10px;
    margin-left: 2px;
}

/* 右侧阅读主区 */
.space-read-main {
    flex: 1;
    min-width: 0;
}

/* 章节导航 */
.space-chapter-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-primary);
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.space-chapter-nav.bottom-nav {
    margin-top: 24px;
}

.space-nav-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: var(--bg-primary);
    color: #555;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    text-decoration: none;
}

.space-nav-btn:hover {
    background: #f0f0f0;
    border-color: #ccc;
    text-decoration: none;
}

.space-nav-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.space-nav-info {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 章节内容 */
.space-chapter {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    min-height: 200px;
}

.space-chapter-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
    color: #222;
}

.space-chapter-content {
    font-size: 1.05rem;
    line-height: 2;
    color: #444;
    text-align: justify;
}

.space-chapter-content p {
    margin-bottom: 1.2em;
    text-indent: 2em;
}

.space-chapter-content p:first-of-type {
    text-indent: 0;
}

.space-read-footer {
    text-align: center;
    padding: 30px;
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 20px;
}

.space-read-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

/* ==================== 发布状态指示 ==================== */

.published-dot {
    display: inline-flex;
    font-size: 10px;
    margin-right: 4px;
    vertical-align: middle;
    line-height: 1;
}

.chapter-btn.publish {
    opacity: 0.4;
}

.chapter-btn.publish:hover {
    opacity: 1;
    background: #e8f5e9;
    border-color: #a5d6a7;
}

.chapter-btn.publish:disabled {
    opacity: 0.15;
    cursor: not-allowed;
}

.chapter-btn.publish:disabled:hover {
    background: transparent;
    border-color: transparent;
}

/* Toast 消息 */
.toast-message {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10000;
    animation: toast-in 0.3s ease;
}

.toast-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.toast-error {
    background: #fce4ec;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 响应式 */
@media (max-width: 768px) {
    .space-grid {
        grid-template-columns: 1fr;
    }

    .space-hero h1 {
        font-size: 1.5rem;
    }

    .space-filters {
        flex-direction: column;
        align-items: center;
    }

    .space-read-page {
        padding: 0 10px 60px;
    }

    .space-read-layout {
        flex-direction: column;
    }

    .space-toc {
        width: 100%;
        position: static;
        max-height: none;
        margin-bottom: 16px;
    }

    .space-toc-list {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        padding: 8px;
    }

    .space-toc-item {
        border-bottom: none;
    }

    .space-toc-link {
        padding: 4px 10px;
        border-radius: 4px;
        background: var(--bg-secondary);
        font-size: 12px;
    }

    .space-toc-num,
    .space-toc-chapter-title {
        display: inline;
    }

    .space-toc-chapter-title {
        display: none;
    }

    .space-chapter {
        padding: 20px;
    }

    .space-chapter-title {
        font-size: 1.1rem;
    }

    .space-chapter-content {
        font-size: 1rem;
    }

    .space-chapter-nav {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .space-chapter-nav .space-nav-info {
        width: 100%;
        text-align: center;
    }
}
