/* ================================================================
   novel_plot_recall.css — 小说情节回忆工具样式
   主题：书页翻阅感，复古羊皮卷风格，沉浸式阅读体验
   ================================================================ */

/* ---- 全局变量 ---- */
:root {
    --novel-bg: #faf6f0;
    --novel-surface: #fff9f2;
    --novel-border: #e8d8c0;
    --novel-border-light: #f0e4d0;
    --novel-accent: #8b4513;
    --novel-accent-hover: #a0522d;
    --novel-accent-light: #f5ebe0;
    --novel-text: #3d2b1a;
    --novel-text-muted: #8a7060;
    --novel-text-light: #b89880;
    --novel-gold: #c8922a;
    --novel-gold-light: #f5e8cc;
    --novel-shadow: rgba(139, 69, 19, 0.12);
    --novel-shadow-md: rgba(139, 69, 19, 0.18);
    --novel-radius: 8px;
    --novel-radius-lg: 12px;
    --toolbar-height: 52px;
    --history-width: 220px;
    --input-width: 340px;
}

/* ---- 主容器 ---- */
.novel-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
    min-height: 560px;
    background: var(--novel-bg);
    border: 1px solid var(--novel-border);
    border-radius: var(--novel-radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 20px var(--novel-shadow);
    font-family: 'Georgia', 'STSong', '宋体', serif;
}

/* ---- 工具栏 ---- */
.novel-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    height: var(--toolbar-height);
    background: linear-gradient(135deg, #4a2c0a 0%, #7a3e0e 50%, #5c2f0b 100%);
    border-bottom: 2px solid var(--novel-gold);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-group + .toolbar-group {
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid rgba(200, 146, 42, 0.4);
}

.toolbar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--novel-gold);
    margin-right: 6px;
    letter-spacing: 0.5px;
    font-family: 'Georgia', serif;
}

.toolbar-btn {
    padding: 5px 10px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(200, 146, 42, 0.4);
    border-radius: 5px;
    cursor: pointer;
    color: #f5e8cc;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: sans-serif;
}

.toolbar-btn:hover:not(:disabled) {
    background: rgba(200, 146, 42, 0.25);
    border-color: var(--novel-gold);
    color: #fff;
}

.toolbar-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.toolbar-btn-primary {
    background: linear-gradient(135deg, #c8922a, #e0a83a);
    border-color: #e0a83a;
    color: #3d2b1a;
    font-weight: 600;
}

.toolbar-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #d9a030, #f0b840);
    border-color: #f0b840;
    color: #2a1a0a;
}

.toolbar-btn-cancel {
    background: rgba(180, 60, 40, 0.3);
    border-color: rgba(200, 80, 60, 0.5);
    color: #ffb0a0;
}

.toolbar-btn-cancel:hover:not(:disabled) {
    background: rgba(200, 80, 60, 0.5);
    color: #fff;
}

/* ---- 主内容三栏布局 ---- */
.novel-main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---- 左栏：历史记录 ---- */
.novel-history-panel {
    width: var(--history-width);
    min-width: var(--history-width);
    display: flex;
    flex-direction: column;
    background: #fdf6ec;
    border-right: 1px solid var(--novel-border);
    overflow: hidden;
}

.history-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 12px 8px;
    background: linear-gradient(to bottom, #fdf0e0 0%, #f8e8d0 100%);
    border-bottom: 1px solid var(--novel-border-light);
    flex-shrink: 0;
}

.history-panel-header h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--novel-accent);
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 0;
}

.history-count {
    display: inline-block;
    background: var(--novel-gold);
    color: #fff;
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 4px;
    font-weight: normal;
}

.history-count:empty {
    display: none;
}

.history-clear-btn {
    background: #fff0e8;
    border: 1px solid #f0c0a0;
    color: #c05030;
    font-size: 10px;
    cursor: pointer;
    padding: 2px 7px;
    border-radius: 4px;
    transition: all 0.2s;
    white-space: nowrap;
}

.history-clear-btn:hover {
    background: #fde0d0;
    border-color: #e08060;
}

.history-search {
    padding: 8px 10px;
    border-bottom: 1px solid var(--novel-border-light);
    flex-shrink: 0;
}

.history-search input {
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    border: 1px solid var(--novel-border);
    border-radius: 4px;
    background: var(--novel-surface);
    color: var(--novel-text);
    box-sizing: border-box;
    outline: none;
    font-family: sans-serif;
}

.history-search input:focus {
    border-color: var(--novel-gold);
    box-shadow: 0 0 0 2px rgba(200, 146, 42, 0.15);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.history-list::-webkit-scrollbar { width: 4px; }
.history-list::-webkit-scrollbar-thumb { background: #d0b090; border-radius: 2px; }

.history-empty {
    text-align: center;
    color: var(--novel-text-light);
    font-size: 12px;
    padding: 24px 12px;
    line-height: 1.8;
}

.history-item {
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--novel-border-light);
    transition: background 0.15s;
    position: relative;
}

.history-item:hover {
    background: var(--novel-gold-light);
}

.history-item.active {
    background: #f5e8cc;
    border-left: 3px solid var(--novel-gold);
    padding-left: 9px;
}

.history-item::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 50%;
    background: var(--novel-gold);
    border-radius: 2px 0 0 2px;
    transition: width 0.2s;
}

.history-item:not(.active):hover::after {
    width: 3px;
}

.history-item-top {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 3px;
}

.history-item-clue {
    font-size: 12px;
    color: var(--novel-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    flex: 1;
    min-width: 0;
}

.history-item-del {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--novel-text-light);
    font-size: 13px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    border-radius: 3px;
}

.history-item:hover .history-item-del {
    opacity: 1;
}

.history-item-del:hover {
    color: #e05030;
    background: rgba(224, 80, 48, 0.1);
}

.history-item-meta {
    display: flex;
    gap: 4px;
    align-items: center;
}

.history-item-genre {
    font-size: 10px;
    background: var(--novel-gold-light);
    color: var(--novel-accent);
    padding: 1px 5px;
    border-radius: 3px;
    border: 1px solid #e0c080;
}

.history-item-mode {
    font-size: 10px;
    color: var(--novel-text-muted);
}

.history-item-time {
    font-size: 10px;
    color: var(--novel-text-light);
    margin-left: auto;
}

/* ---- 中栏：输入面板 ---- */
.novel-input-panel {
    width: var(--input-width);
    min-width: var(--input-width);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--novel-border);
    background: var(--novel-surface);
    overflow: hidden;
}

.panel-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--novel-border-light);
    background: linear-gradient(to bottom, #fdf3e8 0%, #faeede 100%);
    flex-shrink: 0;
}

.panel-header h3 {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 600;
    color: var(--novel-accent);
    background: none;
    border: none;
    padding: 0;
    font-family: 'Georgia', serif;
}

.panel-tip {
    font-size: 11px;
    color: var(--novel-text-muted);
    font-family: sans-serif;
}

.novel-input-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.novel-input-body::-webkit-scrollbar { width: 4px; }
.novel-input-body::-webkit-scrollbar-thumb { background: #d0b090; border-radius: 2px; }

/* 小说类型选择 */
.genre-selector {}

.genre-label, .mode-label, .clue-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--novel-accent);
    margin-bottom: 7px;
    font-family: sans-serif;
}

.genre-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.genre-tag {
    padding: 3px 9px;
    font-size: 12px;
    border: 1px solid var(--novel-border);
    border-radius: 12px;
    cursor: pointer;
    color: var(--novel-text-muted);
    background: var(--novel-bg);
    transition: all 0.2s;
    user-select: none;
    font-family: sans-serif;
}

.genre-tag:hover {
    border-color: var(--novel-gold);
    color: var(--novel-accent);
    background: var(--novel-gold-light);
}

.genre-tag.selected {
    background: var(--novel-gold);
    border-color: var(--novel-gold);
    color: #fff;
    font-weight: 600;
    transform: scale(1.05);
}

/* 回忆模式选择 */
.mode-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--novel-border);
    border-radius: var(--novel-radius);
    cursor: pointer;
    background: var(--novel-bg);
    transition: all 0.2s;
    user-select: none;
}

.mode-option:hover {
    border-color: var(--novel-gold);
    background: var(--novel-gold-light);
}

.mode-option.selected {
    border-color: var(--novel-gold);
    background: linear-gradient(135deg, #fdf5e0, #f5e8cc);
    box-shadow: 0 2px 8px rgba(200, 146, 42, 0.2);
}

.mode-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.mode-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--novel-text);
    font-family: sans-serif;
}

.mode-desc {
    font-size: 11px;
    color: var(--novel-text-muted);
    margin-left: auto;
    font-family: sans-serif;
    white-space: nowrap;
}

/* 线索输入框 */
.clue-input-wrap {
    position: relative;
}

.clue-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 13px;
    border: 1px solid var(--novel-border);
    border-radius: var(--novel-radius);
    background: var(--novel-surface);
    color: var(--novel-text);
    caret-color: var(--novel-gold);
    resize: vertical;
    min-height: 110px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: 'Georgia', 'STSong', '宋体', serif;
    line-height: 1.7;
}

.clue-textarea:focus {
    border-color: var(--novel-gold);
    box-shadow: 0 0 0 3px rgba(200, 146, 42, 0.15);
}

.clue-textarea.shake {
    border-color: #e05030;
    animation: novelShake 0.4s ease;
}

@keyframes novelShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.clue-counter {
    text-align: right;
    font-size: 11px;
    color: var(--novel-text-light);
    margin-top: 3px;
    font-family: sans-serif;
}

#novelClueCount.warn {
    color: #e05030;
    font-weight: 600;
}

/* 使用提示 */
.novel-tips-box {
    background: linear-gradient(135deg, #fdf8f0, #f5ebe0);
    border: 1px solid var(--novel-border-light);
    border-radius: var(--novel-radius);
    padding: 10px 14px;
    font-family: sans-serif;
}

.novel-tips-box p {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--novel-gold);
}

.novel-tips-box ul {
    margin: 0;
    padding-left: 14px;
    list-style: none;
}

.novel-tips-box ul li {
    font-size: 11px;
    color: var(--novel-text-muted);
    line-height: 1.9;
    position: relative;
}

.novel-tips-box ul li::before {
    content: '›';
    position: absolute;
    left: -10px;
    color: var(--novel-gold);
    font-weight: bold;
}

/* ---- 右栏：结果面板 ---- */
.novel-result-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fffcf7;
}

.novel-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 44px;
    padding: 8px 18px;
    background: linear-gradient(to bottom, #fdf3e8 0%, #faeede 100%);
    border-bottom: 1px solid var(--novel-border-light);
    flex-shrink: 0;
}

.novel-result-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--novel-accent);
    background: none;
    border: none;
    padding: 0;
    font-family: 'Georgia', serif;
}

.result-meta-info {
    display: flex;
    gap: 6px;
    align-items: center;
}

.result-mode-badge, .result-genre-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--novel-gold-light);
    color: var(--novel-accent);
    border: 1px solid #e0c080;
    font-family: sans-serif;
}

.result-genre-badge {
    background: #f0e8f8;
    color: #7030a0;
    border-color: #c0a0d8;
}

.novel-result-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px 28px;
}

.novel-result-body::-webkit-scrollbar { width: 5px; }
.novel-result-body::-webkit-scrollbar-thumb { background: #d0b090; border-radius: 3px; }

/* 占位提示 */
.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 280px;
    color: var(--novel-text-light);
    text-align: center;
}

@keyframes placeholderFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.placeholder-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.6;
    animation: placeholderFloat 3.5s ease-in-out infinite;
    display: inline-block;
}

.placeholder-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--novel-text-muted);
    margin: 0 0 12px;
    font-family: 'Georgia', serif;
}

.placeholder-desc {
    font-size: 13px;
    color: var(--novel-text-light);
    margin: 3px 0;
    font-family: sans-serif;
}

/* 加载动画：翻书效果 */
.result-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    gap: 24px;
}

.loading-book {
    position: relative;
    width: 60px;
    height: 48px;
    perspective: 300px;
}

.book-cover {
    position: absolute;
    width: 60px;
    height: 48px;
    background: linear-gradient(135deg, #8b4513, #c8742a);
    border-radius: 2px 8px 8px 2px;
    box-shadow: 2px 2px 8px rgba(139, 69, 19, 0.4);
}

.book-page {
    position: absolute;
    left: 2px;
    top: 4px;
    width: 52px;
    height: 40px;
    background: #fff9f0;
    border-radius: 1px 6px 6px 1px;
    transform-origin: left center;
    border: 1px solid #e8d0b0;
}

.book-page.page1 { animation: pageFlip 1.6s ease-in-out infinite; }
.book-page.page2 { animation: pageFlip 1.6s ease-in-out 0.3s infinite; }
.book-page.page3 { animation: pageFlip 1.6s ease-in-out 0.6s infinite; }

@keyframes pageFlip {
    0% { transform: rotateY(0deg); opacity: 1; }
    50% { transform: rotateY(-120deg); opacity: 0.6; }
    100% { transform: rotateY(0deg); opacity: 1; }
}

.loading-text {
    font-size: 14px;
    color: var(--novel-text-muted);
    font-family: 'Georgia', serif;
    font-style: italic;
    animation: loadingTextFade 2s ease-in-out infinite;
}

@keyframes loadingTextFade {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 结果内容样式 */
.result-content {
    animation: fadeInUp 0.4s ease;
    font-family: 'Georgia', 'STSong', '宋体', serif;
    line-height: 1.8;
    color: var(--novel-text);
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* result-content 内可点击的标签样式 */
.result-content strong {
    font-weight: 700;
    color: var(--novel-accent);
    cursor: pointer;
    transition: color 0.15s;
}

.result-content strong:hover {
    color: var(--novel-gold);
    text-decoration: underline dotted;
}

.result-content em {
    font-style: italic;
    color: var(--novel-text-muted);
}

.result-content h3,
.result-content h4,
.result-content h5 {
    font-family: 'Georgia', serif;
    color: var(--novel-accent);
    margin: 12px 0 6px;
}

.result-content pre {
    background: var(--novel-bg);
    border: 1px solid var(--novel-border);
    border-radius: 5px;
    padding: 10px 14px;
    overflow-x: auto;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    margin: 6px 0;
    line-height: 1.6;
}

/* 代码块一键复制按钮 */
.code-copy-btn {
    position: absolute;
    top: 6px;
    right: 8px;
    padding: 2px 8px;
    font-size: 11px;
    background: rgba(200, 146, 42, 0.12);
    border: 1px solid rgba(200, 146, 42, 0.3);
    border-radius: 4px;
    color: var(--novel-text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    font-family: sans-serif;
    line-height: 1.4;
    user-select: none;
    z-index: 1;
}

.code-copy-btn.with-label {
    top: 30px;
}

.result-content pre:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: rgba(200, 146, 42, 0.25);
    border-color: var(--novel-gold);
    color: var(--novel-accent);
}

.code-copy-btn.copied {
    opacity: 1;
    background: rgba(72, 160, 80, 0.15);
    border-color: rgba(72, 160, 80, 0.4);
    color: #3a9040;
}

.result-content code {
    background: var(--novel-gold-light);
    color: var(--novel-accent);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

.result-content blockquote {
    border-left: 3px solid var(--novel-gold);
    padding: 8px 14px;
    margin: 8px 0;
    color: var(--novel-text-muted);
    font-style: italic;
    background: var(--novel-gold-light);
    border-radius: 0 5px 5px 0;
}

/* AI 结果中的情节结果 */
.result-content .recall-result {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* AI 结果中的关键词标签（可点击填入线索框） */
.result-content .recall-tag {
    display: inline-block;
    padding: 1px 8px;
    background: var(--novel-gold-light);
    border: 1px solid #e0c080;
    border-radius: 10px;
    font-size: 12px;
    color: var(--novel-accent);
    cursor: pointer;
    margin: 2px 2px;
    transition: all 0.2s;
    font-family: sans-serif;
}

.result-content .recall-tag:hover {
    background: var(--novel-gold);
    border-color: var(--novel-gold);
    color: #fff;
    transform: translateY(-1px);
}

.result-content .recall-summary {
    background: linear-gradient(135deg, #fdf8f0, #f8eddc);
    border: 1px solid var(--novel-border);
    border-left: 4px solid var(--novel-gold);
    border-radius: var(--novel-radius);
    padding: 14px 18px;
}

.result-content .recall-summary h4 {
    margin: 0 0 8px;
    font-size: 15px;
    color: var(--novel-gold);
    font-family: 'Georgia', serif;
}

.result-content .recall-summary p {
    margin: 0;
    font-size: 14px;
    color: var(--novel-text);
    line-height: 1.8;
}

.result-content .recall-section {
    background: var(--novel-surface);
    border: 1px solid var(--novel-border-light);
    border-radius: var(--novel-radius);
    padding: 14px 18px;
    transition: box-shadow 0.25s;
}

.result-content .recall-section:hover {
    box-shadow: 0 4px 16px var(--novel-shadow);
}

.result-content .recall-section h4 {
    margin: 0 0 10px;
    font-size: 14px;
    color: var(--novel-accent);
    border-bottom: 1px dashed var(--novel-border);
    padding-bottom: 6px;
    font-family: 'Georgia', serif;
}

.result-content .recall-section p {
    margin: 0;
    font-size: 13px;
    color: var(--novel-text);
    line-height: 1.9;
}

.result-content .recall-section ul,
.result-content .recall-section ol {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    color: var(--novel-text);
}

.result-content .recall-section li {
    line-height: 1.9;
    margin-bottom: 2px;
}

.result-content .recall-guess {
    background: linear-gradient(135deg, #f8f0fc, #f0e8f8);
    border-color: #c0a0d8;
    border-left: 4px solid #9060c0;
}

.result-content .recall-guess h4 {
    color: #7030a0;
}

/* 人物卡片 */
.result-content .character-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.result-content .character-card {
    background: var(--novel-gold-light);
    border: 1px solid #e0c080;
    border-radius: var(--novel-radius);
    padding: 8px 12px;
    flex: 1;
    min-width: 140px;
}

.result-content .character-card strong {
    display: block;
    font-size: 13px;
    color: var(--novel-accent);
    margin-bottom: 2px;
    font-family: 'Georgia', serif;
}

.result-content .character-card .char-role {
    display: inline-block;
    font-size: 11px;
    background: var(--novel-accent);
    color: #fff;
    padding: 1px 6px;
    border-radius: 8px;
    margin-bottom: 4px;
}

.result-content .character-card p {
    font-size: 12px;
    color: var(--novel-text-muted);
    margin: 0;
    line-height: 1.6;
}

/* 错误提示 */
.result-error {
    background: #fff5f5;
    border: 1px solid #fcd0d0;
    border-left: 4px solid #e05030;
    border-radius: var(--novel-radius);
    padding: 14px 18px;
    font-size: 13px;
    color: #c04030;
    font-family: sans-serif;
    margin-top: 12px;
}

.result-error .error-msg {
    display: block;
    margin: 4px 0 8px;
    font-size: 12px;
    opacity: 0.85;
}

.novel-retry-btn {
    display: inline-block;
    margin-top: 6px;
    padding: 5px 14px;
    background: #fff0ee;
    border: 1px solid #e05030;
    border-radius: 5px;
    color: #c04030;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: sans-serif;
}

.novel-retry-btn:hover {
    background: #ffe0dc;
    border-color: #c04030;
}

/* ---- 示例模态框 ---- */
.novel-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(50, 30, 10, 0.5);
    z-index: 9000;
    backdrop-filter: blur(2px);
}

.novel-modal-overlay.active {
    display: block;
}

.novel-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--novel-surface);
    border: 1px solid var(--novel-border);
    border-radius: var(--novel-radius-lg);
    box-shadow: 0 20px 60px rgba(50, 30, 10, 0.35);
    z-index: 9001;
    width: 680px;
    max-width: 92vw;
    max-height: 80vh;
    overflow: hidden;
    flex-direction: column;
    animation: modalSlideIn 0.25s ease forwards;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translate(-50%, -52%) scale(0.93); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.novel-modal.active {
    display: flex;
}

.novel-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #4a2c0a 0%, #7a3e0e 100%);
    flex-shrink: 0;
}

.novel-modal-header h3 {
    margin: 0;
    font-size: 15px;
    color: var(--novel-gold);
    font-family: 'Georgia', serif;
}

.novel-modal-close {
    background: none;
    border: none;
    color: #f5e8cc;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.novel-modal-close:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.novel-modal-body {
    overflow-y: auto;
    padding: 16px 20px;
    flex: 1;
    min-height: 0;
}

.example-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.example-card {
    background: linear-gradient(135deg, #fdf8f0, #f5ece0);
    border: 1px solid var(--novel-border);
    border-radius: var(--novel-radius);
    padding: 12px 14px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.example-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--novel-gold);
    border-radius: 2px 0 0 2px;
}

.example-card:hover {
    border-color: var(--novel-gold);
    box-shadow: 0 4px 12px var(--novel-shadow);
    transform: translateY(-1px);
}

.example-card-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.example-card-label .label-text {
    font-size: 11px;
    background: var(--novel-gold);
    color: #fff;
    padding: 1px 7px;
    border-radius: 8px;
    font-family: sans-serif;
    font-weight: 600;
}

.example-card-clue {
    font-size: 12px;
    color: var(--novel-text);
    line-height: 1.7;
    font-family: 'Georgia', 'STSong', serif;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---- Toast 提示 ---- */
.novel-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(74, 44, 10, 0.92);
    color: #f5e8cc;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    font-family: sans-serif;
    border: 1px solid rgba(200, 146, 42, 0.4);
    white-space: nowrap;
}

.novel-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---- 全屏模式 ---- */
.novel-container.fullscreen {
    position: fixed;
    inset: 0;
    height: 100vh;
    border-radius: 0;
    z-index: 8000;
    border: none;
}

/* ---- 暗黑模式 ---- */
body.dark {
    --novel-bg: #1e1610;
    --novel-surface: #251c14;
    --novel-border: #3d2e1e;
    --novel-border-light: #332416;
    --novel-accent: #c8922a;
    --novel-accent-hover: #d9a030;
    --novel-accent-light: #2a2010;
    --novel-text: #e8d8c0;
    --novel-text-muted: #a89070;
    --novel-text-light: #7a6050;
    --novel-gold: #c8922a;
    --novel-gold-light: #2a2010;
    --novel-shadow: rgba(0, 0, 0, 0.4);
    --novel-shadow-md: rgba(0, 0, 0, 0.5);
}

body.dark .novel-container {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
}

body.dark .novel-history-panel {
    background: #1a1208;
}

body.dark .history-panel-header {
    background: linear-gradient(to bottom, #201508, #1a1206);
}

body.dark .history-search input {
    background: #1a1208;
    color: var(--novel-text);
}

body.dark .history-item:hover {
    background: #2a1c0c;
}

body.dark .history-item.active {
    background: #2e1e0a;
}

body.dark .history-clear-btn {
    background: #2a1a10;
    border-color: #5a3020;
    color: #e0805a;
}

body.dark .novel-input-panel {
    background: var(--novel-surface);
}

body.dark .panel-header {
    background: linear-gradient(to bottom, #1e1408, #1a1206);
}

body.dark .genre-tag {
    background: #1e1408;
    border-color: #3d2e1e;
    color: var(--novel-text-muted);
}

body.dark .genre-tag:hover {
    background: #2a1c0c;
    border-color: var(--novel-gold);
}

body.dark .mode-option {
    background: #1e1408;
    border-color: #3d2e1e;
}

body.dark .mode-option:hover {
    background: #2a1c0c;
}

body.dark .mode-option.selected {
    background: linear-gradient(135deg, #2e1e0a, #3a2614);
}

body.dark .mode-name {
    color: var(--novel-text);
}

body.dark .clue-textarea {
    background: #1a1208;
    color: var(--novel-text);
    border-color: #3d2e1e;
}

body.dark .clue-textarea:focus {
    border-color: var(--novel-gold);
}

body.dark .novel-tips-box {
    background: linear-gradient(135deg, #1e1408, #1a1206);
    border-color: #3d2e1e;
}

body.dark .novel-result-panel {
    background: #1c1208;
}

body.dark .novel-result-header {
    background: linear-gradient(to bottom, #1e1408, #1a1206);
}

body.dark .result-content .recall-summary {
    background: linear-gradient(135deg, #201508, #1e1408);
}

body.dark .result-content .recall-section {
    background: var(--novel-surface);
    border-color: var(--novel-border);
}

body.dark .result-content .recall-guess {
    background: linear-gradient(135deg, #1a1020, #201028);
    border-color: #4a2870;
}

body.dark .result-content .character-card {
    background: #2a1c0c;
    border-color: #5a4020;
}

body.dark .novel-modal {
    background: #1e1610;
    border-color: #3d2e1e;
}

body.dark .example-card {
    background: linear-gradient(135deg, #1e1408, #1a1206);
    border-color: #3d2e1e;
}

body.dark .example-card:hover {
    border-color: var(--novel-gold);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

body.dark .result-error {
    background: #1e0c0c;
    border-color: #5a2020;
    color: #e06050;
}

body.dark input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
}

body.dark .placeholder-desc {
    color: #64748b;
}

body.dark .clue-counter {
    color: #64748b;
}

body.dark #novelClueCount.warn {
    color: #ff6b4a;
}

body.dark .novel-modal-body::-webkit-scrollbar {
    width: 4px;
}

body.dark .novel-modal-body::-webkit-scrollbar-thumb {
    background: #5a4020;
    border-radius: 2px;
}

body.dark .result-content strong {
    color: var(--novel-gold);
}

body.dark .result-content code {
    background: #2a1c0c;
    color: var(--novel-gold);
}

body.dark .result-content pre {
    background: #1a1208;
    border-color: #3d2e1e;
}

body.dark .result-content blockquote {
    background: #2a1c0c;
    border-color: var(--novel-gold);
    color: var(--novel-text-muted);
}

body.dark .novel-retry-btn {
    background: #2a1010;
    border-color: #8a3020;
    color: #e06050;
}

body.dark .novel-retry-btn:hover {
    background: #3a1818;
    border-color: #c04030;
}

body.dark .history-item-del {
    color: #7a6050;
}

body.dark .history-item-del:hover {
    color: #e06050;
    background: rgba(224, 80, 48, 0.15);
}

body.dark .result-content .recall-tag {
    background: #2a1c0c;
    border-color: #5a4020;
    color: var(--novel-gold);
}

body.dark .result-content .recall-tag:hover {
    background: var(--novel-gold);
    border-color: var(--novel-gold);
    color: #1e1208;
}

body.dark .result-content strong {
    color: var(--novel-gold);
}

body.dark .result-content strong:hover {
    color: #e0a83a;
}

body.dark .code-copy-btn {
    background: rgba(200, 146, 42, 0.08);
    border-color: rgba(200, 146, 42, 0.2);
    color: var(--novel-text-muted);
}

body.dark .code-copy-btn:hover {
    background: rgba(200, 146, 42, 0.2);
    border-color: var(--novel-gold);
    color: var(--novel-gold);
}

body.dark .code-copy-btn.copied {
    background: rgba(72, 160, 80, 0.12);
    border-color: rgba(72, 160, 80, 0.3);
    color: #5ab860;
}

/* ---- 响应式 ---- */
@media (max-width: 900px) {
    :root {
        --history-width: 180px;
        --input-width: 260px;
    }
}

@media (max-width: 700px) {
    .novel-main-content {
        flex-direction: column;
    }

    .novel-history-panel {
        width: 100%;
        min-width: 100%;
        height: 140px;
        border-right: none;
        border-bottom: 1px solid var(--novel-border);
    }

    .novel-input-panel {
        width: 100%;
        min-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--novel-border);
    }

    .novel-container {
        height: auto;
        min-height: 0;
    }

    .example-grid {
        grid-template-columns: 1fr;
    }

    .toolbar-title {
        display: none;
    }
}
