/* ==========================================
   诗墨华夏 - 核心设计系统与样式定义
   设计风格：现代国风 (Modern Guofeng) & 水墨毛笔感
   ========================================== */

/* 全局变量：色彩与字体定义 */
:root {
    --primary-red: #c0392b;       /* 经典朱砂红，用于按钮与高亮 */
    --primary-red-hover: #a62c21; /* 朱砂红悬停色 */
    --text-main: #1a1a1a;          /* 浓墨黑，主要文字 */
    --text-muted: #555555;         /* 焦墨黑，次要文字 */
    --bg-parchment: #f9f6f0;       /* 宣纸宣黄，卷轴纸张底色 */
    --bg-parchment-dark: #f0ebdf;  /* 熟宣色，用于深色卡片 */
    --border-color: #d1c7bd;       /* 古铜线框，古典隔线 */
    --gold-accent: #b89130;        /* 泥金黄，用于特殊边框及高亮 */
    --transition-speed: 0.3s;
    --font-serif: "Noto Serif SC", "Source Han Serif CN", Georgia, serif;
    --font-handwriting: "Ma Shan Zheng", cursive, serif;
}

/* 全局重置与排版 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', "Noto Serif SC", -apple-system, sans-serif;
    color: var(--text-main);
    background-color: #f7f5f0;
    overflow-x: hidden;
    min-height: 100vh;
}

/* 动态水墨背景层 */
.bg-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/bg.jpg');
    background-size: cover;
    background-position: center;
    z-index: -2;
    transform: scale(1.02);
    filter: blur(1px);
    transition: opacity 1s ease;
}

.bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(245,242,235,0.85) 100%);
    z-index: -1;
}

/* APP 容器排版 */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* 头部导航栏设计 */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    margin-bottom: 25px;
}

.logo-area {
    display: flex;
    flex-direction: column;
}

.logo-text {
    font-family: var(--font-handwriting);
    font-size: 2.2rem;
    color: var(--primary-red);
    line-height: 1;
    margin-bottom: 4px;
    letter-spacing: 2px;
}

.logo-subtext {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.nav-links {
    display: flex;
    gap: 15px;
}

.nav-item {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: 8px;
    transition: all var(--transition-speed);
    border: 1px solid transparent;
}

.nav-item:hover, .nav-item.active {
    color: var(--primary-red);
    background: rgba(192, 57, 43, 0.08);
    border-color: rgba(192, 57, 43, 0.2);
}

/* 视图面板容器 */
.view-panel {
    display: none;
    flex-grow: 1;
    animation: fadeIn var(--transition-speed) ease-in-out forwards;
}

.view-panel.active {
    display: flex;
    flex-direction: column;
}

/* 卡片玻璃拟态底座 */
.glass-card {
    background: rgba(254, 253, 250, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(209, 199, 189, 0.5);
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.03);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.05);
}

/* 一、时光画卷视图样式 */

/* 朝代时间轴 */
.dynasty-timeline {
    position: relative;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 25px 0;
    background: rgba(254, 253, 250, 0.9);
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid rgba(209, 199, 189, 0.4);
}

.timeline-line {
    position: absolute;
    top: 50%;
    left: 10%;
    right: 10%;
    height: 2px;
    background: linear-gradient(90deg, rgba(209,199,189,0.1) 0%, rgba(209,199,189,1) 50%, rgba(209,199,189,0.1) 100%);
    z-index: 1;
    transform: translateY(-50%);
}

.dynasty-node {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.node-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--border-color);
    margin-bottom: 10px;
    transition: all var(--transition-speed);
}

.node-name {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: all var(--transition-speed);
}

.node-year {
    font-size: 0.75rem;
    color: #888;
    margin-top: 2px;
}

.dynasty-node:hover .node-dot {
    border-color: var(--primary-red);
    background: var(--primary-red);
    transform: scale(1.2);
}

.dynasty-node:hover .node-name {
    color: var(--primary-red);
}

.dynasty-node.active .node-dot {
    width: 18px;
    height: 18px;
    border-color: var(--primary-red);
    background: var(--primary-red);
    box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.15);
}

.dynasty-node.active .node-name {
    color: var(--primary-red);
    font-weight: 900;
    transform: scale(1.1);
}

/* 时光画卷网格布局 */
.dynasty-content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    align-items: stretch;
}

/* 标题国风样式 */
.section-title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    color: var(--text-main);
    border-bottom: 2px solid var(--primary-red);
    padding-bottom: 10px;
    margin-bottom: 18px;
    display: inline-block;
}

.sub-title {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    color: var(--primary-red);
    margin-bottom: 12px;
    border-left: 3px solid var(--primary-red);
    padding-left: 8px;
}

/* 服饰展示板块 */
.fashion-display {
    margin-top: 20px;
}

.clothing-image-container {
    position: relative;
    width: 100%;
    height: 380px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: #fff;
    margin-bottom: 12px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.05);
}

.clothing-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.5s ease;
}

.clothing-image-container:hover .clothing-img {
    transform: scale(1.03);
}

.clothing-tag {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 4px;
    letter-spacing: 1px;
}

.clothing-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* 历史大事记列表 */
.event-list {
    list-style: none;
}

.event-list li {
    display: flex;
    gap: 15px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border-color);
    align-items: flex-start;
}

.event-list li:last-child {
    border-bottom: none;
}

.event-year {
    font-family: var(--font-serif);
    font-weight: 600;
    color: var(--primary-red);
    min-width: 60px;
    font-size: 0.95rem;
    text-align: right;
}

.event-text {
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.5;
}

/* 诗人与作品网格 */
.poets-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-grow: 1;
}

.dynasty-poets-panel .card {
    display: flex;
    flex-direction: column;
}

.poet-card {
    display: flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-parchment);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 18px;
    cursor: pointer;
    transition: all var(--transition-speed);
    flex-grow: 1;
}

.poet-card:hover {
    border-color: var(--primary-red);
    background: #fff;
    transform: translateX(4px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

.poet-avatar-placeholder {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--bg-parchment-dark);
    border: 1px dashed var(--primary-red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--primary-red);
    font-weight: bold;
}

.poet-info {
    flex-grow: 1;
}

.poet-name {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: var(--text-main);
}

.poet-title {
    font-size: 0.8rem;
    color: var(--gold-accent);
    margin-left: 8px;
    border: 1px solid var(--gold-accent);
    padding: 1px 6px;
    border-radius: 4px;
}

.poem-preview {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 600;
    margin-bottom: 2px;
}

.poem-lines {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-family: var(--font-serif);
}

.arrow-icon {
    font-size: 1.2rem;
    color: var(--border-color);
    transition: color var(--transition-speed);
}

.poet-card:hover .arrow-icon {
    color: var(--primary-red);
}


/* 二、诗词阁视图样式 */

.poetry-workspace {
    display: grid;
    grid-template-columns: 2.8fr 4.7fr 4.5fr;
    gap: 20px;
    align-items: start;
}

/* 诗词卷轴区 */
.poetry-scroll-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 20px 0;
}

.scroll-wood {
    width: 96%;
    height: 18px;
    background: linear-gradient(90deg, #4d2b12 0%, #7d4d29 50%, #4d2b12 100%);
    border-radius: 9px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.scroll-top {
    margin-bottom: -5px;
    z-index: 2;
}

.scroll-bottom {
    margin-top: -5px;
    z-index: 2;
}

.poetry-paper {
    width: 94%;
    background-color: var(--bg-parchment);
    background-image: radial-gradient(rgba(0, 0, 0, 0.015) 1px, transparent 0),
                      radial-gradient(rgba(0, 0, 0, 0.015) 1px, transparent 0);
    background-size: 8px 8px;
    background-position: 0 0, 4px 4px;
    border-left: 10px solid #e3dac9;
    border-right: 10px solid #e3dac9;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    padding: 50px 40px;
    min-height: 520px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 排版模式切换 */
.layout-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 5px;
    background: rgba(0,0,0,0.04);
    padding: 3px;
    border-radius: 6px;
    z-index: 10;
}

.toggle-btn {
    border: none;
    background: none;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-speed);
}

.toggle-btn.active {
    background: #fff;
    color: var(--primary-red);
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

/* 诗词文本排版 */
.poetry-display-content {
    transition: all 0.4s ease;
}

/* 竖排模式 */
.poetry-display-content.vertical {
    writing-mode: vertical-rl;
    text-orientation: upright;
    height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 30px;
}

.poetry-display-content.vertical .calligraphy-title {
    font-size: 2.6rem;
    letter-spacing: 6px;
    margin-bottom: 0;
    margin-left: 15px;
}

.poetry-display-content.vertical .poem-meta {
    margin-bottom: 0;
    margin-left: 10px;
    font-size: 1rem;
    letter-spacing: 4px;
    align-items: center;
}

.poetry-display-content.vertical .poem-body p {
    font-size: 1.55rem;
    line-height: 2.2;
    letter-spacing: 6px;
    margin-bottom: 0;
    margin-left: 15px;
}

/* 横排模式 */
.poetry-display-content.horizontal {
    text-align: center;
    width: 100%;
}

.poetry-display-content.horizontal .calligraphy-title {
    font-family: var(--font-serif);
    font-weight: 900;
    font-size: 2.4rem;
    color: var(--text-main);
    margin-bottom: 12px;
    letter-spacing: 3px;
}

.poetry-display-content.horizontal .poem-meta {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 25px;
    letter-spacing: 1px;
}

.poetry-display-content.horizontal .poem-body p {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 1.4rem;
    line-height: 1.8;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

/* 右侧详情及视频 */

/* 意境视频卡片（仿制播放器） */
.video-card {
    padding: 0;
    overflow: hidden;
    background: #111;
    border-color: #333;
}

.card-tag {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 10;
    background: var(--primary-red);
    color: #fff;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 1px;
}

.mock-video-player {
    position: relative;
    width: 100%;
    height: 260px;
    background: #000;
}

.video-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(rgba(0,0,0,0.2), rgba(0,0,0,0.6)), url('assets/bg.jpg');
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 5;
    transition: opacity 0.5s ease;
}

.video-overlay-play {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(192, 57, 43, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, background 0.3s ease;
    box-shadow: 0 0 20px rgba(192, 57, 43, 0.4);
}

.video-overlay-play:hover {
    transform: scale(1.1);
    background: var(--primary-red-hover);
}

.play-button-icon {
    width: 0;
    height: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 18px solid #fff;
    margin-left: 4px;
}

.video-title-overlay {
    margin-top: 15px;
    color: #fff;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

/* 视频播放态模拟 */
.mock-video-canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.landscape-canvas-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('assets/bg.jpg');
    background-size: cover;
    background-position: center;
    opacity: 0.7;
    filter: brightness(0.6);
    z-index: 1;
}

/* 粒子动画效果 */
.canvas-floating-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 100%);
    pointer-events: none;
}

.canvas-poetry-animation {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-family: var(--font-serif);
    font-size: 1.4rem;
    letter-spacing: 3px;
    z-index: 3;
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
    white-space: nowrap;
    animation: textScroll 10s linear infinite;
}

.video-controls {
    position: relative;
    z-index: 4;
    background: rgba(0,0,0,0.6);
    padding: 8px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-btn {
    border: none;
    background: none;
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.control-btn:hover {
    background: rgba(255,255,255,0.1);
}

.progress-bar-wrap {
    flex-grow: 1;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-red);
    transition: width 0.1s linear;
}

.video-time {
    color: #bbb;
    font-size: 0.75rem;
}

/* 讲解选项卡卡片 */
.study-tabs-card {
    padding: 0;
    overflow: hidden;
}

.tabs-header {
    display: flex;
    background: var(--bg-parchment-dark);
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex-grow: 1;
    border: none;
    background: none;
    padding: 14px 0;
    font-family: var(--font-serif);
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-speed);
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--primary-red);
}

.tab-btn.active {
    background: #fefffd;
    color: var(--primary-red);
    border-bottom-color: var(--primary-red);
    font-weight: bold;
}

.tab-content-container {
    padding: 20px;
    min-height: 180px;
    max-height: 240px;
    overflow-y: auto;
    background: #fefffd;
}

.tab-content-panel {
    display: none;
    animation: fadeIn var(--transition-speed) ease;
}

.tab-content-panel.active {
    display: block;
}

/* 注释列表排版 */
.annotation-list {
    list-style: none;
}

.annotation-list li {
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.6;
    margin-bottom: 10px;
    border-left: 2px solid var(--border-color);
    padding-left: 10px;
}

.annotation-list li strong {
    color: var(--primary-red);
}

/* 译文/赏析文本排版 */
.translation-text, .appreciation-text {
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.7;
    text-align: justify;
}


/* 三、“小书童” AI 学习助教浮窗样式 */

.ai-assistant-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 15px;
}

.ai-bubble {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 0.85rem;
    color: var(--text-main);
    box-shadow: 0 4px 15px rgba(0,0,0,0.06);
    max-width: 260px;
    line-height: 1.5;
    position: relative;
    animation: float 4s ease-in-out infinite;
    pointer-events: none;
    transform-origin: right center;
    transition: opacity 0.3s;
}

/* 气泡三角标 */
.ai-bubble::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -7px;
    transform: translateY(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: #fff;
    border-right: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
}

.ai-avatar-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: 3px solid #fff;
    background: var(--bg-parchment);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    cursor: pointer;
    position: relative;
    outline: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.ai-avatar-btn:hover {
    transform: scale(1.08) rotate(3deg);
}

.ai-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* 呼吸光环 */
.ai-pulse-ring {
    position: absolute;
    top: -3px;
    left: -3px;
    width: calc(100% + 6px);
    height: calc(100% + 6px);
    border: 2px solid var(--primary-red);
    border-radius: 50%;
    animation: pulse 2s infinite;
    opacity: 0.7;
}

/* 助教聊天面板 */
.ai-chat-panel {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 360px;
    height: 520px; /* 适当调高一些，以留足 API Key 面板展开后的空间 */
    z-index: 101;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 15px 40px rgba(0,0,0,0.12);
    animation: slideUp 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    
    /* 极其重要：强制覆盖 .glass-card 卡片带来的 25px 挤压内边距，让聊天各版块贴合边缘 */
    padding: 0 !important;
}

/* 极其重要：消除聊天面板在 hover 时的 translateY 上下颠簸抖动，保持其稳定漂浮 */
.ai-chat-panel.glass-card:hover {
    transform: none !important;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15) !important;
}

.ai-chat-panel.active {
    display: flex;
}

.chat-header {
    background: var(--bg-parchment-dark);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 12px 18px;
    gap: 12px;
    flex-shrink: 0; /* 头部绝对不能收缩，保持固定高度 */
}

/* API Key 配置面板弹性锁定 */
.api-key-panel {
    flex-shrink: 0; /* 绝对不能收缩 */
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #fff;
    object-fit: cover;
}

.chat-header-info h4 {
    font-size: 0.95rem;
    color: var(--text-main);
}

.chat-status {
    font-size: 0.75rem;
    color: #27ae60;
}

.close-chat-btn {
    margin-left: auto;
    border: none;
    background: none;
    font-size: 1.1rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.close-chat-btn:hover {
    color: var(--primary-red);
}

/* 聊天消息区 */
.chat-messages {
    flex-grow: 1;
    flex-shrink: 1; /* 消息区允许自由收缩以适应容器，并内部滚动 */
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #fefffd;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.message.system {
    align-self: center;
    background: rgba(0,0,0,0.03);
    color: var(--text-muted);
    text-align: center;
    font-size: 0.75rem;
    max-width: 90%;
}

.message.assistant {
    align-self: flex-start;
    background: var(--bg-parchment);
    border-bottom-left-radius: 2px;
    border: 1px solid rgba(209,199,189,0.3);
    color: var(--text-main);
}

.message.user {
    align-self: flex-end;
    background: var(--primary-red);
    color: #fff;
    border-bottom-right-radius: 2px;
}

/* 快捷提问推荐 */
.quick-questions {
    display: flex;
    gap: 8px;
    padding: 8px 15px;
    overflow-x: auto;
    background: #fff;
    border-top: 1px solid rgba(209,199,189,0.2);
    flex-shrink: 0; /* 绝对不能收缩，保持固定高度 */
}

/* 隐藏快捷栏滚动条 */
.quick-questions::-webkit-scrollbar {
    display: none;
}

.quick-q-btn {
    border: 1px solid var(--border-color);
    background: var(--bg-parchment);
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 0.75rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-q-btn:hover {
    color: var(--primary-red);
    border-color: var(--primary-red);
    background: rgba(192, 57, 43, 0.03);
}

/* 聊天输入框区 */
.chat-input-area {
    display: flex;
    padding: 10px 15px;
    background: var(--bg-parchment-dark);
    border-top: 1px solid var(--border-color);
    gap: 10px;
    flex-shrink: 0; /* 绝对不能收缩，保持底栏尺寸固定 */
}

#chat-input {
    flex-grow: 1;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.85rem;
    outline: none;
    background: #fff;
}

#chat-input:focus {
    border-color: var(--primary-red);
}

.send-message-btn {
    border: none;
    background: var(--primary-red);
    color: #fff;
    padding: 0 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.send-message-btn:hover {
    background: var(--primary-red-hover);
}


/* ==========================================
   动画与关键帧
   ========================================== */

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

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

@keyframes textScroll {
    0% { transform: translate(-50%, -50%) translateX(100%); }
    100% { transform: translate(-50%, -50%) translateX(-100%); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.06); opacity: 0.3; }
    100% { transform: scale(1.15); opacity: 0; }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

.h-100 {
    height: 100%;
}


/* ==========================================
   响应式断点 (Responsive Breakpoints)
   ========================================== */

@media (max-width: 960px) {
    .dynasty-content-grid {
        grid-template-columns: 1fr;
    }
    
    .poetry-workspace {
        grid-template-columns: 1fr;
    }
    
    .ai-chat-panel {
        width: calc(100vw - 40px);
        right: 20px;
        bottom: 100px;
    }
}

/* ==========================================
   四、背诵自测模块样式
   ========================================== */
.recitation-box {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.recitation-tip {
    font-size: 0.85rem;
    color: var(--text-muted);
    border-left: 2.5px solid var(--gold-accent);
    padding-left: 8px;
    margin-bottom: 5px;
}

.recitation-form {
    background: var(--bg-parchment);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    max-height: 220px;
    overflow-y: auto;
}

.recitation-line {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    line-height: 2;
    margin-bottom: 8px;
    letter-spacing: 1px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
}

.recit-input {
    width: 28px;
    height: 28px;
    text-align: center;
    font-family: var(--font-serif);
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-bottom: 2px dashed var(--primary-red);
    background: transparent;
    color: var(--text-main);
    outline: none;
    padding: 0;
    transition: all 0.2s;
}

.recit-input:focus {
    border-bottom-style: solid;
    background: rgba(192, 57, 43, 0.03);
}

.recit-input.correct {
    border-bottom-color: #27ae60;
    color: #27ae60;
    background: rgba(39, 174, 96, 0.05);
}

.recit-input.incorrect {
    border-bottom-color: var(--primary-red);
    color: var(--primary-red);
    background: rgba(192, 57, 43, 0.05);
    animation: shake 0.3s ease;
}

.recitation-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 5px;
}

.recitation-btn {
    border: 1px solid var(--border-color);
    background: #fff;
    color: var(--text-muted);
    font-family: var(--font-serif);
    font-size: 0.9rem;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.recitation-btn:hover {
    color: var(--primary-red);
    border-color: var(--primary-red);
    background: rgba(192, 57, 43, 0.02);
}

.recitation-btn.submit-btn {
    background: var(--primary-red);
    color: #fff;
    border-color: var(--primary-red);
}

.recitation-btn.submit-btn:hover {
    background: var(--primary-red-hover);
}

/* 测评得分面板 */
.recitation-result {
    margin-top: 15px;
    background: rgba(254, 253, 250, 0.95);
    border: 1.5px solid var(--gold-accent);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 5px 20px rgba(184, 145, 48, 0.1);
}

.score-circle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px double var(--gold-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.score-num {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary-red);
}

.score-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 2px;
}

.score-rank {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--gold-accent);
    margin-bottom: 6px;
    letter-spacing: 2px;
}

.score-comment {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 15px;
}

.recitation-btn.retry-btn {
    width: 100%;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

@media (max-width: 600px) {
    .dynasty-timeline {
        justify-content: flex-start;
        overflow-x: auto;
        gap: 35px;
        padding: 20px 20px;
    }
    .timeline-line {
        display: none;
    }
    .dynasty-node {
        flex-shrink: 0;
    }
}

/* 独立背诵挑战布局 */
.recitation-workspace {
    display: grid;
    grid-template-columns: 4.2fr 5.8fr;
    gap: 30px;
    align-items: start;
}

.classic-select {
    width: 100%;
    padding: 12px 20px;
    font-family: var(--font-serif);
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-parchment);
    color: var(--text-main);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%23c0392b' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
    background-repeat: no-repeat;
    background-position: right 15px center;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    transition: all var(--transition-speed);
}

.classic-select:focus {
    border-color: var(--primary-red);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}

@media (max-width: 960px) {
    .recitation-workspace {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   五 McKay：诗词阁左侧侧边栏目录样式
   ========================================== */
.poetry-sidebar {
    display: flex;
    flex-direction: column;
    padding: 20px 15px !important;
    max-height: calc(100vh - 180px);
    overflow: hidden;
}

.sidebar-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    color: var(--primary-red);
    margin-bottom: 12px;
    border-left: 3px solid var(--primary-red);
    padding-left: 8px;
    font-weight: bold;
}

.sidebar-search-box {
    margin-bottom: 15px;
}

#poetry-search-input {
    width: 100%;
    padding: 8px 15px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    background: #fff;
    outline: none;
    transition: all var(--transition-speed);
}

#poetry-search-input:focus {
    border-color: var(--primary-red);
    box-shadow: 0 0 5px rgba(192, 57, 43, 0.15);
}

.poetry-list-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 5px;
}

/* 侧边栏滚动条美化 */
.poetry-list-wrapper::-webkit-scrollbar {
    width: 4px;
}

.poetry-list-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.sidebar-dynasty-group {
    margin-bottom: 18px;
}

.sidebar-dynasty-title {
    font-family: var(--font-serif);
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 600;
    padding-bottom: 5px;
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 8px;
    position: sticky;
    top: 0;
    background: #fdfcf7; /* Parchment backing to hide text under sticky header */
    z-index: 1;
}

.sidebar-poem-item {
    font-size: 0.88rem;
    color: var(--text-main);
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.sidebar-poem-item:hover {
    background: rgba(192, 57, 43, 0.05);
    color: var(--primary-red);
}

.sidebar-poem-item.active {
    background: rgba(192, 57, 43, 0.08);
    color: var(--primary-red);
    font-weight: 600;
    border-left: 3.5px solid var(--primary-red);
    border-radius: 0 6px 6px 0;
    padding-left: 8px;
}

.sidebar-author {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.sidebar-poem-item.active .sidebar-author {
    color: var(--primary-red);
    opacity: 0.8;
}

/* 响应式适配 */
@media (max-width: 960px) {
    .poetry-sidebar {
        max-height: 250px;
        margin-bottom: 10px;
    }
}

/* API 设置与思考状态动画扩展 */
.api-settings-btn:hover {
    transform: rotate(60deg);
}

.thinking-dots {
    display: inline-block;
    animation: textPulse 1.5s infinite ease-in-out;
}

@keyframes textPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.loading-item {
    font-style: italic;
    color: var(--text-muted);
    animation: textPulse 1.5s infinite ease-in-out;
}
