* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* 禁止滚动条 */
}

body {
    font-family: 'Microsoft YaHei', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
}

/* 主布局容器 */
.main-layout {
    display: flex;
    flex: 1;
    height: 100vh;
    overflow: hidden;
}

/* ========== 左侧栏 ========== */
.left-sidebar {
    width: 300px;
    min-width: 250px;
    background-color: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* LOGO区域 */
.logo-area {
    height: 80px;
    min-height: 80px;
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.logo-placeholder {
    font-size: 1.5rem;
    font-weight: bold;
    color: #666;
    text-align: center;
}

.logo-image {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    object-fit: contain;
}

/* 章节树区域 */
.chapter-tree-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background-color: #f8f9fa; /* 确保背景色可见 */
    opacity: 1; /* 确保完全不透明 */
}

.chapter-tree {
    font-size: 0.9rem;
}

.tree-loading {
    text-align: center;
    color: #999;
    padding: 20px;
}

/* 树形结构样式 */
.tree-volume {
    margin-bottom: 10px;
    display: block !important;
    visibility: visible !important;
}

.tree-volume-title {
    font-weight: bold;
    font-size: 1rem;
    padding: 8px 10px;
    background-color: #e9ecef;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    display: block !important; /* 确保册标题始终显示 */
    visibility: visible !important;
    color: #333 !important;
}

.tree-volume-title:hover {
    background-color: #dee2e6;
}

.tree-volume-title.active {
    background-color: #0d6efd;
    color: white;
}

.tree-chapter {
    margin-left: 15px;
    margin-top: 5px;
    display: none; /* 默认隐藏，点击册后显示 */
}

.tree-chapter.show {
    display: block;
}

.tree-chapter-title {
    font-weight: 500;
    font-size: 0.95rem;
    padding: 6px 10px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    border-radius: 3px;
}

.tree-chapter-title:hover {
    background-color: #f0f0f0;
}

.tree-chapter-title.active {
    background-color: #cfe2ff;
    color: #0d6efd;
}

.tree-section {
    margin-left: 15px; /* 从30px改为15px，因为现在直接在册下 */
    margin-top: 3px;
    display: none; /* 默认隐藏，点击册后显示 */
}

.tree-section.show {
    display: block;
}

.tree-section-title {
    font-size: 0.9rem;
    padding: 5px 10px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    border-radius: 3px;
}

.tree-section-title:hover {
    background-color: #f8f9fa;
}

.tree-section-title.active {
    background-color: #e7f3ff;
    color: #0d6efd;
}

.tree-items {
    margin-left: 45px;
    margin-top: 2px;
    display: none; /* 默认隐藏，点击节后显示 */
}

.tree-items.show {
    display: block;
}

.tree-item {
    font-size: 0.85rem;
    padding: 4px 10px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    border-radius: 3px;
    color: #555;
}

.tree-item:hover {
    background-color: #f0f0f0;
}

.tree-item.active {
    background-color: #d1ecf1;
    color: #0c5460;
    font-weight: 500;
}

/* 音频播放器区域 */
.audio-player-area {
    height: 150px;
    min-height: 150px;
    background-color: #fff;
    border-top: 1px solid #dee2e6;
    padding: 10px;
    overflow: hidden;
}

.audio-player-container {
    width: 100%;
}

#audioPlayer {
    width: 100%;
    height: 40px;
}

.audio-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    gap: 15px;
}

.audio-controls-left {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.audio-controls-center {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.audio-controls-right {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.audio-controls .btn {
    font-size: 0.75rem;
    padding: 3px 8px;
}

.audio-controls .btn.active {
    background-color: #0dcaf0;
    border-color: #0dcaf0;
    color: white;
}

.audio-controls .form-select {
    font-size: 0.75rem;
    padding: 3px 6px;
    width: auto;
    min-width: 70px;
}

.audio-controls .form-check-label {
    font-size: 0.75rem;
    margin-left: 5px;
}

/* ========== 右侧内容区 ========== */
.right-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 广告区域 */
.ad-area {
    height: 90px;
    min-height: 90px;
    max-height: 90px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    flex-shrink: 0;
}

.ad-placeholder {
    font-size: 1rem;
    color: #999;
    text-align: center;
    width: 728px;
    height: 90px;
    line-height: 90px;
    background-color: #e9ecef;
    border: 1px dashed #ccc;
    display: block;
}

/* 练习内容区域 */
.practice-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 30px 40px;
    overflow-y: auto;
    gap: 20px;
}

/* 练习标题行 */
.practice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.practice-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.practice-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.lesson-info-inline {
    font-size: 0.95rem;
}

.practice-buttons {
    display: flex;
    gap: 10px;
}

/* 韩文练习显示 */
.korean-text-display {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    position: relative; /* 为覆盖层定位 */
    overflow: hidden; /* 防止内容溢出导致布局变化 */
}

.korean-text-display p {
    font-size: 4.5rem;
    line-height: 1.3;
    color: #333;
    font-weight: 500;
    word-break: keep-all;
    text-align: center;
    margin: 0;
    letter-spacing: 0.1em; /* 字符之间添加间距 */
    position: relative; /* 确保文字在键盘图片之上 */
    z-index: 20; /* 高于键盘图片的z-index */
    opacity: 1; /* 确保100%不透明 */
    min-height: 1.3em; /* 防止高度变化 */
    width: 100%; /* 固定宽度 */
}

/* 隐藏字符（下划线）的间距 */
.korean-text-display p .hidden-char {
    margin: 0 0.15em; /* 左右各添加间距 */
    display: inline-block;
    color: #0066cc !important; /* 蓝色 */
}

/* 键盘提示覆盖层（在中文解释区域居中显示） */
.keyboard-hint-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none; /* 不阻挡点击事件，不影响其他操作 */
}

.keyboard-overlay-image {
    max-width: 95%;
    max-height: 95%;
    width: auto;
    height: auto;
    opacity: 0.4; /* 图片透明度40%，稍微提高可见度 */
    object-fit: contain;
}

/* 中文说明区域（用于键盘提示图片） */
.chinese-translation-area {
    position: relative; /* 为键盘提示覆盖层提供定位上下文 */
    min-height: 200px; /* 增大最小高度，为键盘提示图片提供更多空间 */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 0;
}

/* 中文说明文字（在输入框标签行显示） */
.chinese-translation-text {
    font-size: 0.9rem; /* 小字 */
    color: #666;
    font-style: italic;
    text-align: center;
    flex: 1;
    word-break: keep-all;
    margin-left: 10px;
}

.chinese-translation-text.hidden {
    display: none;
}

/* 键盘提示区域 */
.keyboard-hint-area {
    padding: 20px;
    margin: 10px 0;
    background-color: rgba(248, 249, 250, 0.95);
    border-radius: 8px;
    border: 1px solid #dee2e6;
    max-height: 500px;
    overflow-y: auto;
}

.keyboard-hint-content h5 {
    margin-bottom: 15px;
    color: #495057;
    font-size: 1.2rem;
}

.keyboard-shortcuts {
    margin-bottom: 20px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 15px;
}

.shortcut-item kbd {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    min-width: 60px;
    text-align: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.shortcut-item span {
    color: #495057;
    font-size: 0.95rem;
}

.keyboard-layout {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #dee2e6;
}

.keyboard-layout h6 {
    margin-bottom: 15px;
    color: #495057;
    font-size: 1rem;
}

.keyboard-image-container {
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.keyboard-image {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.hidden {
    display: none !important;
}

/* 输入区域 */
.input-area {
    flex: 0 0 auto;
}

.input-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.input-label {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 0;
    flex: 0 0 auto;
}

.input-wrapper {
    position: relative;
    width: 100%;
}

#inputText {
    font-size: 3.5rem; /* 从3rem增大到3.5rem */
    padding: 25px;
    height: auto;
    min-height: 80px; /* 固定最小高度，防止布局变化 */
    line-height: 1.5;
    text-align: center;
    box-sizing: border-box; /* 确保padding不影响总高度 */
    width: 100%; /* 固定宽度 */
    background-color: transparent; /* 透明背景 */
    color: transparent; /* 透明文字，让覆盖层显示 */
    caret-color: #333; /* 光标颜色 */
    letter-spacing: 0.1em; /* 与显示文字保持一致的字间距 */
}

#inputText::placeholder {
    color: #999; /* placeholder颜色 */
    opacity: 1; /* 确保placeholder可见 */
}

.input-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none; /* 不阻挡输入 */
    font-size: 3.5rem; /* 与输入框保持一致 */
    line-height: 1.5;
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    word-break: break-all;
    box-sizing: border-box;
    white-space: pre-wrap; /* 保持空格和换行 */
    letter-spacing: 0.1em; /* 与输入框保持一致的字间距 */
    overflow: hidden; /* 防止溢出 */
}

.input-overlay .char {
    display: inline-block;
}

.input-overlay .char.correct {
    color: #006400; /* 深绿色 */
}

.input-overlay .char.incorrect {
    color: #dc3545; /* 红色 */
}

.input-overlay .char.pending {
    color: #333; /* 未输入的字符用灰色 */
}

.input-message-row {
    min-height: 2em; /* 固定高度占位，防止布局变化 */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    position: relative;
}

.input-message {
    position: absolute;
    font-size: 1.2rem;
    text-align: center;
    width: 100%;
    opacity: 0; /* 默认隐藏 */
    transition: opacity 0.2s;
    min-height: 1.5em; /* 固定高度占位 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-message.show {
    opacity: 1;
}

#errorMessage {
    color: #dc3545;
}

#successMessage {
    color: #28a745;
}

#inputText.correct {
    border-color: #28a745;
    background-color: #d4edda;
}

#inputText.error {
    border-color: #dc3545;
    background-color: #f8d7da;
}

/* 课程信息 */
.lesson-info {
    flex: 0 0 auto;
    text-align: center;
    padding: 10px 0;
}

/* 完成提示 */
.completion-message {
    text-align: center;
    padding: 15px 0;
    color: #28a745;
    font-size: 1.2rem;
    font-weight: 500;
}

/* 响应式设计 - 小屏幕 */
@media (max-width: 768px) {
    .main-layout {
        height: calc(100vh - 60px);
    }
    
    .left-sidebar {
        width: 250px;
        min-width: 200px;
    }
    
    .ad-area {
        height: 60px;
        min-height: 60px;
    }
    
    .ad-placeholder {
        width: 468px;
        height: 60px;
        line-height: 60px;
    }
    
    .korean-text-display p {
        font-size: 3rem;
    }
    
    .chinese-translation-text {
        font-size: 1.2rem; /* 小屏幕上相应减小 */
    }
    
    #inputText {
        font-size: 3rem; /* 小屏幕上保持较大字体 */
        padding: 20px;
    }
    
    .input-overlay {
        font-size: 3rem; /* 与输入框保持一致 */
    }
    
    .practice-header-right {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }
    
    .ad-container-top {
        height: 60px;
    }
    
    .ad-desktop {
        display: none !important;
    }
    
    .ad-mobile {
        display: inline-block !important;
        width: 468px !important;
        height: 60px !important;
        max-width: calc(100% - 10px);
    }
}
