:root {
    --primary-color: #8B4513;
    --secondary-color: #D2691E;
    --accent-color: #CD853F;
    --bg-light: #FFF8DC;
    --bg-card: #FFFAF0;
    --bg-body: #fdfbf7;
    --bg-dot: #e6e2d8;
    --text-dark: #333;
    --text-light: #666;
    --text-body: #2c2c2c;
    --border-color: #D2691E;
    --success-color: #2ECC71;
    --error-color: #E74C3C;
    --card-shadow: rgba(139, 69, 19, 0.08);
    --card-shadow-hover: rgba(139, 69, 19, 0.12);
}

/* 深色主题 */
[data-theme="dark"] {
    --primary-color: #CD853F;
    --secondary-color: #DEB887;
    --accent-color: #F4A460;
    --bg-light: #2d2d2d;
    --bg-card: #3d3d3d;
    --bg-body: #1a1a1a;
    --bg-dot: #333;
    --text-dark: #e0e0e0;
    --text-light: #aaa;
    --text-body: #d0d0d0;
    --border-color: #CD853F;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --card-shadow-hover: rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 页面加载过渡动画 */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.4s ease-out;
}

.page-transition.hidden {
    opacity: 0;
    pointer-events: none;
}

.page-transition-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

body.page-loading .navbar,
body.page-loading .main-content,
body.page-loading .footer {
    opacity: 0;
}

body:not(.page-loading) .navbar,
body:not(.page-loading) .main-content,
body:not(.page-loading) .footer {
    opacity: 1;
    transition: opacity 0.4s ease-out;
}

body {
    /* 中文字体组合：思源黑体作为正文，更具中国文化感 */
    font-family: "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
    line-height: 1.8;
    color: var(--text-body);
    /* 宣纸纹理背景，更有文化感 */
    background: var(--bg-body);
    background-image: radial-gradient(var(--bg-dot) 1px, transparent 1px);
    background-size: 20px 20px;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* 标题字体：使用思源宋体，更具古典韵味 */
h1, h2, h3, h4, h5, h6 {
    font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "SimSun", serif;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.navbar {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
}

.nav-brand {
    font-size: 1.3rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-logo {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 50%;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    flex-shrink: 0;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 0.8rem;
    border-radius: 5px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
    font-size: 0.95rem;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,0.2);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

#userMenu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.user-link,
.logout-link,
.auth-link {
    color: white;
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    white-space: nowrap;
}

.user-link:hover,
.logout-link:hover,
.auth-link:hover {
    background: rgba(255, 255, 255, 0.15);
}

.user-link {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.logout-link {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.logout-link:hover {
    background: rgba(231, 76, 60, 0.3);
}

.config-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.config-btn:hover {
    background: white;
    color: var(--primary-color);
}

.main-content {
    min-height: calc(100vh - 200px);
    padding: 2rem 0;
}

.section {
    display: none;
    animation: fadeIn 0.5s;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hero {
    text-align: center;
    padding: 3rem 0;
}

.hero-title {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.hero-title-logo {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 50%;
}

.hero-logo {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 50%;
}

.auth-logo {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 50%;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-light);
    margin-bottom: 3rem;
}

.features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin: 3rem 0;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.feature-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s;
}

.feature-card:hover {
    box-shadow: 0 10px 30px var(--card-shadow-hover);
}

.feature-icon {
    font-size: 3rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.feature-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    /* 赭石色系渐变，更现代的质感 */
    background: linear-gradient(135deg, #b85c37 0%, #8c4226 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(140, 66, 38, 0.25);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #c96d48 0%, #9d5337 100%);
    box-shadow: 0 6px 20px rgba(140, 66, 38, 0.35);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: white;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.section-title {
    font-size: 2.5rem;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.section-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 3rem;
}

.recognize-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.upload-area {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    padding: 2rem;
}

.upload-box {
    border: 3px dashed var(--border-color);
    border-radius: 10px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-box:hover {
    background: rgba(210, 105, 30, 0.1);
    border-color: var(--secondary-color);
}

.upload-icon {
    font-size: 4rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.image-preview {
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.result-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.artifact-card,
.introduction-card,
.kg-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    padding: 1.5rem;
}

.artifact-card h3,
.introduction-card h3,
.kg-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.artifact-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.info-item {
    display: flex;
    gap: 0.5rem;
}

.info-item .label {
    font-weight: bold;
    color: var(--text-dark);
}

.info-item .value {
    color: var(--text-light);
}

.introduction-content {
    line-height: 1.8;
    color: var(--text-dark);
}

.speech-controls {
    display: flex;
    gap: 0.5rem;
}

.speech-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    font-size: 1rem;
}

.speech-btn:hover {
    background: var(--primary-color);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(210, 105, 30, 0.3);
}

.speech-btn:active {
    transform: scale(0.95);
}

.speech-btn.speaking {
    background: #E74C3C;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(231, 76, 60, 0);
    }
}

.kg-container {
    min-height: 400px;
    background: var(--bg-card);
    border-radius: 10px;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

.kg-container canvas {
    display: block;
    margin: 0 auto;
    cursor: default;
}

.kg-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 10px;
    margin: 0 2px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    color: var(--text-dark);
}

.kg-btn:hover {
    background: var(--bg-light);
    border-color: var(--secondary-color);
}

.kg-search {
    transition: all 0.3s;
}

.kg-search:focus {
    outline: none;
    border-color: #D2691E;
    box-shadow: 0 0 0 3px rgba(210, 105, 30, 0.1);
    width: 250px;
}

.qa-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
}

.qa-sidebar {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    padding: 1.5rem;
}

.qa-sidebar h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    margin-bottom: 1rem;
    background: var(--bg-card);
    color: var(--text-dark);
    transition: background-color 0.3s, color 0.3s;
}

.quick-questions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quick-question-btn {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    padding: 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s;
    color: var(--text-dark);
}

.quick-question-btn:hover {
    background: var(--bg-light);
    border-color: var(--secondary-color);
}

.qa-main {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: 600px;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding: 1rem;
}

.chat-welcome {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

.chat-welcome i {
    font-size: 3rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.chat-message {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
}

.chat-message.user {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 70%;
    padding: 1rem;
    border-radius: 15px;
    line-height: 1.6;
}

.chat-message.user .message-bubble {
    background: var(--primary-color);
    color: white;
}

.chat-message.assistant .message-bubble {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-dark);
}

.chat-input-container {
    display: flex;
    gap: 1rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 25px;
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text-dark);
}

.timeline-controls {
    /* 卡片化设计 */
    background: var(--bg-card);
    border: none;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 30px var(--card-shadow);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s;
}

.timeline-controls:hover {
    box-shadow: 0 15px 40px var(--card-shadow-hover);
}

.timeline-container,
.kg-full-container {
    /* 卡片化设计 */
    background: var(--bg-card);
    border: none;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 10px 30px var(--card-shadow);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s;
}

.timeline-container:hover,
.kg-full-container:hover {
    box-shadow: 0 15px 40px var(--card-shadow-hover);
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    background: var(--bg-card);
    margin: 10% auto;
    padding: 2rem;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-light);
}

.close:hover {
    color: var(--text-dark);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
    color: var(--text-dark);
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    background: var(--bg-card);
    color: var(--text-dark);
}

.form-group small {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-light);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    color: white;
}

.spinner {
    border: 5px solid rgba(255,255,255,0.3);
    border-top: 5px solid white;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.footer {
    background: var(--primary-color);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

/* ========== 响应式设计 ========== */

/* 平板端 (1024px 以下) */
@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }
    
    .features {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .timeline-container,
    .kg-full-container {
        padding: 1.5rem;
    }
    
    .hero-title {
        font-size: 2.5rem;
    }
}

/* 手机端 (768px 以下) */
@media (max-width: 768px) {
    /* 导航栏优化 */
    .navbar {
        padding: 0.75rem 0;
    }
    
    .navbar .container {
        flex-direction: column;
        gap: 0.75rem;
        align-items: center;
    }
    
    .nav-brand {
        font-size: 1rem;
        justify-content: center;
    }
    
    .nav-logo {
        width: 28px;
        height: 28px;
    }
    
    .nav-brand span {
        font-size: 0.95rem;
    }
    
    /* 菜单项优化：单行显示，滚动 */
    .nav-menu {
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        width: 100%;
        padding: 0.5rem 0;
        gap: 0.25rem;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }
    
    .nav-menu::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }
    
    .nav-link {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .nav-link i {
        font-size: 0.9rem;
    }
    
    /* 用户区域优化 */
    .nav-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    #userMenu {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }
    
    .user-link,
    .logout-link,
    .auth-link {
        width: 100%;
        text-align: center;
        padding: 0.5rem 1rem;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.1);
        font-size: 0.85rem;
    }
    
    .user-link:hover,
    .logout-link:hover,
    .auth-link:hover {
        background: rgba(255, 255, 255, 0.2);
    }
    
    /* 容器优化 */
    .container {
        padding: 0 10px;
    }
    
    /* 标题优化 */
    .hero-title {
        font-size: 1.8rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    /* 特性卡片优化 */
    .features {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .feature-card {
        padding: 1.5rem;
    }
    
    /* 识别和问答容器 */
    .recognize-container,
    .qa-container {
        grid-template-columns: 1fr;
    }
    
    /* 时间轴控制 */
    .timeline-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .timeline-controls select,
    .timeline-controls input,
    .timeline-controls button {
        width: 100%;
    }
    
    /* 卡片优化 */
    .timeline-container,
    .kg-full-container {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    /* 按钮优化 */
    .btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
    
    .btn-block {
        width: 100%;
    }
    
    /* 表单优化 */
    .form-control {
        font-size: 16px; /* 防止 iOS 自动缩放 */
    }
}

/* 小屏手机 (480px 以下) */
@media (max-width: 480px) {
    .hero-title {
        font-size: 1.5rem;
    }
    
    .hero-subtitle {
        font-size: 0.9rem;
    }
    
    .nav-brand {
        font-size: 1rem;
    }
    
    .feature-card {
        padding: 1rem;
    }
    
    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .timeline-container,
    .kg-full-container {
        padding: 0.75rem;
    }
}

/* 知识图谱节点详情动画 */
@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

#kg-node-info {
    animation: fadeIn 0.3s ease-out;
}

/* Tooltip动画 */
@keyframes tooltipFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
