:root {
    --bg-color: #0f172a;
    --bg-gradient: url('千字文背景.jpg') no-repeat center right / cover;
    --panel-bg: rgba(255, 255, 255, 0.6); /* 增加背景不透明度以支持黑色文字 */
    --panel-border: rgba(0, 0, 0, 0.1);
    --text-primary: #000000; /* 修改为黑色 */
    --text-secondary: #333333;
    --accent-color: #6366f1;
    --accent-hover: #4f46e5;
    --glow-color: rgba(99, 102, 241, 0.5);
    --success-glow: rgba(34, 197, 94, 0.5);
}

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

body {
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start; /* 严格靠左对齐 */
    overflow-x: auto;
    overflow-y: hidden;
    position: relative;
}

/* 环境光晕特效 */
.ambient-light {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    height: 80vh;
    background: radial-gradient(circle, var(--glow-color) 0%, transparent 60%);
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
    filter: blur(100px);
}

.app-container {
    width: 2500px; /* 合理调整整体宽度，让每个模块空间足够且右侧留空 */
    max-width: 95vw;
    height: 680px; /* 锁死高度，确保在 800px 屏幕内下绝对不会溢出 */
    margin-left: 4%; /* 偏左对齐 */
    margin-right: auto;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

.main-content {
    display: grid;
    grid-template-columns: 800px 1fr 1fr; /* 将视频宽度硬锁定在800px左右，保护其原始比例，防止过宽 */
    gap: 2rem;
    height: 100%;
    min-height: 0; /* 关键：防止网格容器撑爆外层 */
}

/* 玻璃拟物态通用类 */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* 左侧数字人区域 */
.avatar-section {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.25rem;
    min-height: 0; /* 防止内容撑爆高度 */
    height: 100%;
}

.avatar-container {
    flex-grow: 1;
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.01));
    border: 1px solid var(--panel-border);
    min-height: 0; /* 允许视频区域纵向自我压缩，不会将字幕挤压出界限 */
}

.avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(1.2) contrast(1.1);
    transition: transform 0.5s ease;
}

/* 播放时的脉冲动画 */
.avatar-container.speaking .pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 50px var(--glow-color);
    animation: pulsate 2s infinite ease-in-out;
    pointer-events: none;
}

@keyframes pulsate {
    0% { opacity: 0.5; box-shadow: inset 0 0 20px var(--glow-color); }
    50% { opacity: 1; box-shadow: inset 0 0 80px var(--glow-color); }
    100% { opacity: 0.5; box-shadow: inset 0 0 20px var(--glow-color); }
}

/* 字幕区 */
.subtitles-section {
    height: 140px; /* 锁死字幕框高度，确保它永远不会消失 */
    flex-shrink: 0; /* 禁止弹性变小 */
}

.subtitles-box {
    padding: 1.5rem 2rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.subtitle-content {
    font-size: 1.6rem; /* 放大字体 */
    line-height: 1.5;
    letter-spacing: 0.5px;
    font-weight: 700;
    color: #000000;
}

.typing-indicator {
    display: none;
    margin-top: 1rem;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--accent-color);
    border-radius: 50%;
    margin-right: 5px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 右侧题目区 */
.questions-section {
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow: hidden;
    min-height: 0; /* 确保弹性子级可以滚动处理溢出，不撑爆外壳 */
}

.questions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.questions-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #000000;
    display: flex;
    align-items: center;
    gap: 10px;
}

.refresh-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.questions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    padding-right: 10px;
    flex-grow: 1; /* 撑满剩余垂直空间 */
    min-height: 0; /* 允许出现内部滚动条 */
}

/* 自定义滚动条 */
.questions-list::-webkit-scrollbar {
    width: 6px;
}
.questions-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
}
.questions-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}
.questions-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.question-item {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid var(--panel-border);
    padding: 1.5rem 2rem;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-size: 1.4rem; /* 放大题目字体 */
    font-weight: 600;
    line-height: 1.4;
    color: #000000;
    position: relative;
    overflow: hidden;
}

.question-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-color);
    transform: scaleY(0);
    transition: transform 0.3s ease;
    transform-origin: bottom;
}

.question-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(5px);
    border-color: rgba(255, 255, 255, 0.15);
}

.question-item:hover::before {
    transform: scaleY(1);
}

.question-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.question-item.active::before {
    transform: scaleY(1);
}

.loading-questions {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
    font-style: italic;
}

/* 禁用状态 */
.question-item.disabled, .refresh-btn.disabled, #micBtn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.5);
}

/* 录音状态下的呼吸灯特效 */
#micBtn.recording {
    background: rgba(239, 68, 68, 0.4) !important;
    border-color: rgba(239, 68, 68, 0.6) !important;
    color: #fff !important;
    animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* 底部备案号样式 */
.footer {
    position: relative;
    margin-top: 15px;
    margin-left: 4%; /* 与主容器对齐 */
    width: auto;
    text-align: left; /* 靠左对齐 */
    z-index: 10;
    pointer-events: auto;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 30px;
}

.footer a {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 400;
    display: flex;
    align-items: center;
}

.footer .psb-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    vertical-align: middle;
}

.footer a:hover {
    color: var(--text-primary);
}

/* 太平山水图介绍板块样式 */
.intro-section {
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow: hidden;
    min-height: 0; /* 确保弹性子级可以滚动处理溢出，不撑爆外壳 */
}

.intro-header h2 {
    font-size: 2rem;
    font-weight: 700;
    color: #000000;
    margin-bottom: 2rem;
}

.intro-content {
    overflow-y: auto;
    padding-right: 15px;
    font-size: 1.2rem;
    line-height: 1.8;
    color: #1a1a1a;
    flex-grow: 1; /* 撑满剩余垂直空间 */
    min-height: 0; /* 允许出现内部滚动条 */
}

.intro-content p {
    margin-bottom: 1.5rem;
    text-indent: 2em; /* 首行缩进 */
}

.intro-content p:first-child {
    text-indent: 0; /* 第一段人物介绍不缩进 */
}

/* 自定义介绍区滚动条 */
.intro-content::-webkit-scrollbar {
    width: 6px;
}
.intro-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}
.intro-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

/* 响应式设计 */
@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .app-container {
        height: auto;
        min-height: 100vh;
        padding: 1rem;
    }
    .avatar-section {
        height: 60vh;
    }
}
