/* 悠悠众口 - 高级感白色主题 */
:root {
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --primary-dark: #5b21b6;
    --secondary: #06b6d4;
    --secondary-light: #67e8f9;
    --accent: #ec4899;
    --bg-main: #f8f9fe;
    --bg-card: #ffffff;
    --bg-input: #f1f0fb;
    --bg-gradient: linear-gradient(135deg, #f5f3ff 0%, #ecfdf5 50%, #f0f9ff 100%);
    --text: #1e1b4b;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --shadow-glow: 0 0 20px rgba(124,58,237,0.15);
}

/* 暗色主题（符合 UX 规范：所有站点提供 light/dark 切换） */
[data-theme="dark"] {
    --bg-main: #0e1016;
    --bg-card: #181b24;
    --bg-input: #232733;
    --bg-gradient: linear-gradient(135deg, #181b24 0%, #14171f 50%, #1d2030 100%);
    --text: #e6e8ee;
    --text-light: #9ca3af;
    --text-muted: #6b7280;
    --border: #2c323f;
    --border-light: #232733;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.35), 0 2px 4px -2px rgba(0,0,0,0.25);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
    --shadow-glow: 0 0 20px rgba(124,58,237,0.25);
}

/* 跟随系统（未手动选择时） */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-main: #0e1016;
        --bg-card: #181b24;
        --bg-input: #232733;
        --bg-gradient: linear-gradient(135deg, #181b24 0%, #14171f 50%, #1d2030 100%);
        --text: #e6e8ee;
        --text-light: #9ca3af;
        --text-muted: #6b7280;
        --border: #2c323f;
        --border-light: #232733;
        --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
        --shadow: 0 4px 6px -1px rgba(0,0,0,0.35), 0 2px 4px -2px rgba(0,0,0,0.25);
        --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
        --shadow-glow: 0 0 20px rgba(124,58,237,0.25);
    }
}

/* 暗色下导航/页脚底色覆盖（原为硬编码半透明白） */
[data-theme="dark"] .navbar { background: rgba(14,16,22,0.85); }
[data-theme="dark"] .footer { background: #181b24; }

/* 主题切换按钮 */
.theme-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.theme-toggle-btn:hover {
    border-color: var(--primary-light);
    background: var(--bg-input);
}

/* D3 图容器：移动端允许横向滚动，避免溢出 */
.graph-container {
    overflow-x: auto;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-main);
    background-image: var(--bg-gradient);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.logo {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
}

.nav-link {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
    position: relative;
}

.nav-link:hover {
    color: var(--primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
}

.nav-user {
    color: var(--primary);
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    width: 100%;
}

/* Footer */
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 20px 24px;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 2px 8px rgba(124,58,237,0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124,58,237,0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary-light);
    background: var(--bg-input);
}

.btn-ghost {
    background: transparent;
    color: var(--text-light);
}

.btn-ghost:hover {
    background: var(--bg-input);
    color: var(--primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-small {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text);
    font-weight: 500;
    font-size: 0.95rem;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 1rem;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.form-input::placeholder {
    color: var(--text-muted);
}

textarea.form-input {
    min-height: 200px;
    resize: vertical;
    font-family: inherit;
}

/* Tags */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
}

.tag-success {
    background: rgba(16,185,129,0.1);
    color: var(--success);
}

.tag-warning {
    background: rgba(245,158,11,0.1);
    color: var(--warning);
}

.tag-info {
    background: rgba(6,182,212,0.1);
    color: var(--secondary);
}

.tag-accent {
    background: rgba(236,72,153,0.1);
    color: var(--accent);
}

.tag-primary {
    background: rgba(124,58,237,0.1);
    color: var(--primary);
}

/* Story List */
.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
}

.story-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.story-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.story-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}

.story-card-meta {
    display: flex;
    gap: 14px;
    color: var(--text-muted);
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.story-card-excerpt {
    margin-top: 14px;
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Tabs */
.tabs {
    display: inline-flex;
    gap: 4px;
    background: var(--bg-input);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
}

.tab {
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-light);
    font-weight: 500;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.tab.active {
    background: var(--bg-card);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.tab:hover:not(.active) {
    color: var(--text);
}

/* Analysis Sections */
.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.section-title::before {
    content: '';
    width: 4px;
    height: 22px;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 2px;
}

/* Graph Container */
.graph-container {
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border);
    min-height: 450px;
    position: relative;
    overflow: hidden;
}

/* Suspicion Cards */
.suspicion-card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.suspicion-header {
    padding: 16px 20px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.suspicion-header:hover {
    background: var(--bg-input);
}

.suspicion-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.suspicion-badge {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.suspicion-body {
    padding: 0 20px 16px;
    display: none;
}

.suspicion-body.open {
    display: block;
}

.suspicion-desc {
    color: var(--text-light);
    margin-bottom: 14px;
    line-height: 1.7;
}

.suspicion-evidence {
    background: var(--bg-input);
    border-left: 3px solid var(--primary);
    padding: 14px 18px;
    border-radius: 0 10px 10px 0;
    color: var(--text-light);
    margin-bottom: 14px;
    line-height: 1.6;
}

/* Comments */
.comment-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.comment {
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
}

.comment-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
}

.comment-author {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
    color: var(--text);
}

.comment-text {
    color: var(--text-light);
    line-height: 1.6;
}

.comment-time {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.comment-input {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.comment-input input {
    flex: 1;
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    padding: 60px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 22px;
    border-radius: 12px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 9999;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

@keyframes slideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

/* Auth Forms */
.auth-container {
    max-width: 420px;
    margin: 60px auto;
}

.auth-container h1 {
    text-align: center;
    margin-bottom: 32px;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--primary);
    font-weight: 500;
}

/* Timeline Styles */
.timeline-item {
    position: relative;
    padding-left: 50px;
    margin-bottom: 28px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 18px;
    top: 40px;
    bottom: -28px;
    width: 2px;
    background: linear-gradient(180deg, var(--primary-light), var(--border));
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-dot {
    position: absolute;
    left: 8px;
    top: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
}

.timeline-content {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 18px 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.timeline-date {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.timeline-title {
    font-weight: 700;
    margin-bottom: 8px;
}

.timeline-desc {
    color: var(--text-light);
    line-height: 1.6;
}

.timeline-characters {
    margin-top: 10px;
    color: var(--secondary);
    font-size: 0.85rem;
}

/* Character Name Tags */
.character-tag {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 2px solid;
    margin: 2px;
}

.character-tag-main {
    border-color: var(--primary);
    background: rgba(124,58,237,0.08);
    color: var(--primary);
}

.character-tag-side {
    border-color: var(--secondary);
    background: rgba(6,182,212,0.08);
    color: var(--secondary);
}

.character-tag-other {
    border-color: var(--text-muted);
    background: rgba(156,163,175,0.08);
    color: var(--text-light);
}

/* 角色徽章 */
.role-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 6px;
    vertical-align: middle;
    letter-spacing: 0.3px;
    line-height: 1.5;
}
.role-super {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    border: 1px solid #f59e0b;
}
.role-co {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #1e40af;
    border: 1px solid #3b82f6;
}

/* PDF图片缩略图 */
.pdf-thumb-wrap {
    display: inline-block;
    margin: 4px;
    vertical-align: middle;
}
.pdf-thumb {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.pdf-thumb:hover {
    transform: scale(1.08);
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(124,58,237,0.25);
}

/* 灯箱全屏预览 */
.lightbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
    backdrop-filter: blur(4px);
}
.lightbox-overlay.active {
    display: flex;
}
.lightbox-img {
    max-width: 92vw;
    max-height: 92vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    cursor: default;
}
.lightbox-close {
    position: fixed;
    top: 20px;
    right: 24px;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 22px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox-close:hover {
    background: rgba(255,255,255,0.3);
}

/* 故事页侧边导航 */
.story-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}
.story-sidebar {
    position: sticky;
    top: 80px;
    width: 180px;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 0;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}
.story-sidebar-title {
    padding: 8px 16px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 4px;
}
.story-sidebar a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 0.88rem;
    color: var(--text-light);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    cursor: pointer;
}
.story-sidebar a:hover {
    color: var(--primary);
    background: rgba(124,58,237,0.04);
}
.story-sidebar a.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: rgba(124,58,237,0.06);
    font-weight: 600;
}
.story-main {
    flex: 1;
    min-width: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 12px 16px;
        gap: 12px;
    }
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 16px;
    }
    .story-grid {
        grid-template-columns: 1fr;
    }
    .footer-content {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    .main-content {
        padding: 20px 16px;
    }
    .story-sidebar {
        display: none;
    }
    .story-layout {
        gap: 0;
    }
}
