/* 重置預設邊距，讓畫面更乾淨 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    /* 使用系統預設字體，在手機上看起來最自然 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f3f4f6; /* 電腦版背景用淺灰色 */
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* 📱 模擬手機螢幕的主容器 */
.container {
    width: 100%;
    max-width: 430px; /* 限制最大寬度，呈現直式手機版型 */
    background-color: #ffffff; /* App 背景為白色 */
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.05); /* 讓它在電腦螢幕上有個立體的陰影 */
    display: flex;
    flex-direction: column;
}

/* App 頂部標題列 */
.header {
    text-align: center;
    padding: 18px 15px;
    background-color: #ffffff;
    border-bottom: 1px solid #f0f0f0;
    position: sticky; /* 讓標題固定在最上方 */
    top: 0;
    z-index: 10;
}

.header h1 {
    font-size: 18px;
    color: #333;
    font-weight: 600;
}

/* 播放與按鈕控制區 */
.controls {
    padding: 20px 20px 10px 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: #fafafa;
    border-bottom: 1px solid #eee;
}

/* 讓內建播放器撐滿手機寬度 */
audio {
    width: 100%;
    height: 44px;
    outline: none;
}

/* 觸控友善的大按鈕 */
button {
    width: 100%;
    padding: 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 12px; /* 圓角更現代化 */
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
    box-shadow: 0 4px 6px rgba(76, 175, 80, 0.2);
}

button:hover {
    background-color: #45a049;
}

/* 文章內容區 */
.text-content {
    padding: 25px 20px 40px 20px;
    font-size: 22px; /* 字體調大，保護眼睛 */
    line-height: 1.8;
    color: #444;
    transition: filter 0.3s ease;
    flex-grow: 1; /* 讓文字區塊自動填滿剩下的空間 */
}

/* 句子高亮樣式優化 */
.sentence {
    padding: 3px 0;
    border-radius: 4px;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.sentence.active {
    background-color: #fef08a; /* 柔和的螢光黃 */
    color: #b45309; /* 字體變成深橘色，對比更明顯 */
    font-weight: 600;
}

/* 盲聽遮蓋 (維持不變) */
.text-content.hidden-text {
    filter: blur(8px);
    pointer-events: none;
    user-select: none;
}

/* --- 單字互動樣式 --- */
.word {
    cursor: pointer;
    border-bottom: 1px dashed transparent;
    transition: all 0.2s ease;
    display: inline-block; /* 讓單字點擊區塊更明確 */
}

/* 點擊單字或滑鼠滑過時的提示效果 */
.word:hover, .word:active {
    background-color: #e0f2fe;
    color: #0284c7;
    border-bottom: 1px dashed #0284c7;
    border-radius: 4px;
}

/* --- 字典彈出視窗樣式 (手機版底部抽屜) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: flex-end; /* 讓視窗貼在底部 */
    z-index: 100;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background-color: white;
    width: 100%;
    max-width: 430px; /* 配合手機版寬度 */
    border-radius: 20px 20px 0 0;
    padding: 25px;
    box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.hidden .modal-content {
    transform: translateY(100%); /* 隱藏時往下縮回去 */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.modal-header h2 {
    color: #1f2937;
    font-size: 24px;
    text-transform: capitalize; /* 首字母自動大寫 */
}

.close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: auto;
    box-shadow: none;
}

.phonetic {
    color: #6b7280;
    font-size: 16px;
    margin-bottom: 15px;
    font-family: monospace;
}

.meaning {
    color: #4b5563;
    font-size: 16px;
    line-height: 1.6;
    max-height: 40vh; /* 內容太多時可以滾動 */
    overflow-y: auto;
}

/* 字典內容的排版 */
.meaning-item {
    margin-bottom: 15px;
}
.part-of-speech {
    font-weight: bold;
    color: #4f46e5;
    background: #e0e7ff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 14px;
    margin-right: 8px;
}

/* --- 🎙️ 錄音專區樣式 --- */
.record-section {
    padding: 0 20px 15px 20px;
    background-color: #fafafa;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.record-btn {
    background-color: #ef4444; /* 錄音按鈕用醒目的紅色 */
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.2);
}

.record-btn:hover {
    background-color: #dc2626;
}

/* 正在錄音時的閃爍呼吸燈特效 */
.record-btn.recording {
    background-color: #b91c1c;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(0.97); opacity: 0.9; }
    100% { transform: scale(1); }
}

/* 隱藏元素的通用 class */
.hidden {
    display: none !important;
}

/* 錄音回放播放器的樣式 */
#recordedAudioPlayer {
    width: 100%;
    height: 44px;
    outline: none;
    border-radius: 22px;
    background-color: #fce7f3; /* 給它一個淡淡的粉色背景做區別 */
}

/* --- 🌟 換課控制區樣式 --- */
.nav-section {
    display: flex;
    gap: 10px;
    padding: 20px;
    background-color: #ffffff;
    border-top: 1px solid #eee;
    margin-top: auto; /* 讓它自動推到 App 的最底部 */
}

.nav-btn {
    flex: 1; /* 讓兩個按鈕平分寬度 */
    background-color: #3b82f6; /* 藍色系區隔功能 */
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.2);
}

.nav-btn:hover {
    background-color: #2563eb;
}