/* 手机英语学习APP样式 - 外研版三起（紧凑版） */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

html, body { height: 100%; overflow: hidden; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #000; color: #333;
}

.app-container {
    width: 100%; max-width: 430px; margin: 0 auto; background: #f5f5f5;
    height: 100vh; height: 100dvh; display: flex; flex-direction: column;
    position: relative; overflow: hidden;
}

/* ===== 顶部横幅（紧凑） ===== */
.top-banner {
    background: linear-gradient(135deg, #ff6f00 0%, #ff8f00 100%);
    padding: 7px 14px; display: flex; align-items: center; justify-content: space-between;
}
.banner-left-icon, .banner-right-icon { font-size: 20px; }
.banner-text { display: flex; flex-direction: column; align-items: center; }
.banner-title { color: #fff; font-size: 14px; font-weight: bold; }
.banner-subtitle { color: rgba(255,255,255,0.9); font-size: 9px; margin-top: 1px; }

/* ===== 主内容 ===== */
.main-content { flex: 1; min-height: 0; padding: 4px 10px; background: #f8f6f0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

.page-header {
    display: flex; align-items: center; padding: 2px 0; margin-bottom: 4px; gap: 10px;
}
.btn-icon {
    width: 28px; height: 28px; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.9); color: #333; font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.page-title { font-size: 17px; font-weight: bold; color: #333; margin: 0; }
.step-badge {
    margin-left: auto; padding: 3px 12px; background: #ff8f00; color: #fff;
    border-radius: 13px; font-size: 12px; font-weight: bold;
}

/* ===== 分类标签 ===== */
.word-categories {
    display: flex; gap: 0; margin-bottom: 5px; border-bottom: 1px solid #e0e0e0;
    overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.word-categories::-webkit-scrollbar { display: none; }
.category-tab {
    padding: 5px 9px; font-size: 12px; color: #999; cursor: pointer;
    position: relative; white-space: nowrap; flex-shrink: 0;
}
.category-tab.active { color: #333; font-weight: bold; }
.category-tab.active::after {
    content: ''; position: absolute; bottom: -1px; left: 0; width: 100%;
    height: 2.5px; background: #ff8f00; border-radius: 2px;
}

/* ===== 步骤选项 ===== */
.step-tabs { display: flex; gap: 10px; margin-bottom: 6px; }
.step-tab {
    width: 38px; height: 38px; border-radius: 50%; border: 2px solid #e0e0e0;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; color: #999; cursor: pointer; background: #fff;
}
.step-tab.active {
    border-color: #ff8f00; color: #333; background: #fff7e0;
    box-shadow: 0 2px 6px rgba(255,143,0,0.3);
}

/* ===== 单词展示 ===== */
.word-display {
    background: #fff; border-radius: 12px; padding: 9px;
    margin-bottom: 6px; text-align: center;
}
.word-main {
    font-size: 36px; font-weight: bold; margin-bottom: 5px; letter-spacing: 2px;
    cursor: pointer; user-select: none; min-height: 40px; line-height: 1.2;
}
.letter { display: inline-block; padding: 0 1px; }
.letter.blue { color: #4a90d9; }
.letter.red { color: #e05c5c; }
.letter.orange { color: #ff8f00; }
.letter.green { color: #66bb6a; }

.syllable-tags { display: flex; justify-content: center; gap: 12px; margin-bottom: 4px; }
.syllable-tag {
    padding: 3px 12px; background: #f0f7ff; color: #4a90d9;
    border-radius: 16px; font-size: 13px; font-weight: 500;
}
.phonetic-row { display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 4px; }
.phonetic { font-size: 15px; color: #666; font-family: "Times New Roman", serif; }
.audio-btn {
    width: 30px; height: 30px; border-radius: 50%; border: none;
    background: #e8f4fd; cursor: pointer; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
}
.audio-btn:active { transform: scale(0.9); background: #bbdefb; }
.definition { font-size: 13px; color: #777; line-height: 1.4; }

/* ===== 拼读表 ===== */
.phonics-table {
    background: #fff; border-radius: 12px; padding: 6px 10px;
    margin-bottom: 6px;
}
.phonics-row {
    display: flex; align-items: center; padding: 2px 8px;
    border-radius: 6px; margin-bottom: 1px; gap: 10px;
}
.phonics-row.highlight { background: #fff3e0; }
.phonics-letter { font-size: 15px; font-weight: bold; color: #333; min-width: 32px; text-align: center; }
.orange-tag { font-size: 12px; color: #ff8f00; font-weight: bold; }
.phonics-arrow { color: #ccc; font-size: 13px; }
.phonics-sound { font-size: 14px; color: #555; font-family: "Times New Roman", serif; margin-left: auto; }

/* ===== 功能按钮 ===== */
.feature-buttons { display: flex; gap: 10px; margin-bottom: 6px; }
.feature-btn {
    flex: 1; padding: 8px; border-radius: 20px; border: none;
    font-size: 13px; cursor: pointer; background: #f0f0f0; color: #666;
}
.feature-btn.green {
    background: linear-gradient(135deg, #43a047, #66bb6a);
    color: #fff; box-shadow: 0 2px 8px rgba(67,160,71,0.3);
}
.feature-btn.active { background: #ffe0b2; color: #ff8f00; }

/* ===== 例句 ===== */
.example-section {
    background: #fff; border-radius: 12px; padding: 8px 10px;
    margin-bottom: 6px;
}
.example-en { font-size: 15px; color: #333; line-height: 1.5; margin-bottom: 3px; font-weight: 500; }
.example-zh { font-size: 12px; color: #999; }

.example-read-row { display: flex; gap: 8px; margin-top: 7px; justify-content: center; }
.btn-read-sentence {
    padding: 6px 16px; border-radius: 16px; border: none;
    background: linear-gradient(135deg, #ff8f00, #ffb300);
    color: #fff; font-size: 12px; font-weight: bold; cursor: pointer;
    display: flex; align-items: center; gap: 4px;
}
.btn-read-sentence:active { transform: scale(0.95); }
.btn-read-sentence.slow {
    background: linear-gradient(135deg, #5c6bc0, #7986cb);
}
.btn-read-sentence.reading { animation: pulse 0.8s infinite; }

/* ===== 音频控制 ===== */
.audio-controls { display: flex; gap: 7px; margin-bottom: 6px; }
.audio-control-btn {
    flex: 1; padding: 6px 4px; border-radius: 10px; border: none;
    background: #fff; cursor: pointer; display: flex; flex-direction: column;
    align-items: center; gap: 2px;
}
.audio-control-btn:active { transform: scale(0.95); background: #e8f5e9; }
.control-icon { font-size: 15px; }
.audio-control-btn span:last-child { font-size: 10px; color: #666; }

/* ===== 底部操作 ===== */
.bottom-actions { display: flex; justify-content: space-around; gap: 7px; padding: 2px 0; }
.action-btn {
    flex: 1; padding: 6px 3px; border-radius: 10px; border: 1px solid #e0e0e0;
    background: #fff; cursor: pointer; display: flex; flex-direction: column;
    align-items: center; gap: 2px;
}
.action-btn:active { background: #f5f5f5; }
.action-icon { font-size: 15px; }
.action-text { font-size: 10px; color: #666; }

/* ===== 教材栏 ===== */
.textbook-bar {
    background: #fff; padding: 3px 10px; border-top: 1px solid #eee; position: relative;
}
.textbook-scroll { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.textbook-scroll::-webkit-scrollbar { height: 0; }
.textbook-item { text-align: center; flex-shrink: 0; width: 42px; cursor: pointer; }
.textbook-item .book-cover {
    font-size: 20px; line-height: 1; padding: 3px 0;
    border-radius: 6px; border: 2px solid transparent; transition: all 0.2s;
}
.textbook-item:active .book-cover { transform: scale(0.92); }
.textbook-item.selected .book-cover {
    border-color: #ff8f00; background: #fff7e0;
    box-shadow: 0 2px 6px rgba(255,143,0,0.3);
}
.textbook-item.selected span { color: #ff8f00; font-weight: bold; }
.textbook-item span { font-size: 9px; color: #999; white-space: nowrap; }
.live-label { display: flex; align-items: center; gap: 4px; font-size: 10px; color: #ff5252; margin-top: 2px; }
.live-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: #ff5252; animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }
.version-label { position: absolute; top: 6px; right: 14px; font-size: 9px; color: #999; }

/* ===== 通用 ===== */
.overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center;
}
.overlay.show { display: flex; }
.overlay-content {
    background: #fff; border-radius: 16px; padding: 20px; text-align: center;
    min-width: 250px; max-width: 80%;
}
.overlay-content h3 { margin-bottom: 8px; color: #333; font-size: 16px; }
.overlay-content p { color: #666; margin-bottom: 14px; line-height: 1.6; font-size: 14px; white-space: pre-line; }
.overlay-content button {
    padding: 8px 28px; border-radius: 20px; border: none;
    background: linear-gradient(135deg, #ff8f00, #ffa726);
    color: #fff; font-size: 14px; cursor: pointer;
}

/* ============================================================
   读 (Read) 功能区
   ============================================================ */
.read-practice { padding: 3px 0; }
.read-instruction { text-align: center; color: #999; font-size: 12px; margin-bottom: 8px; }
.read-sentence {
    background: #fff; border-radius: 12px; padding: 12px;
    margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px;
    justify-content: center; min-height: 50px; align-items: center;
}
.read-word {
    font-size: 22px; font-weight: bold; cursor: pointer; padding: 3px 6px;
    border-radius: 6px; transition: all 0.3s; user-select: none;
}
.read-word:active { transform: scale(1.15); }
.read-word.highlighted { background: #fff7e0; color: #ff8f00; }
.read-word.correct { background: #e8f5e9; color: #4caf50; }
.read-word.wrong { background: #ffebee; color: #f44336; }
.read-controls { display: flex; gap: 8px; margin-bottom: 8px; }
.read-result {
    text-align: center; margin-bottom: 8px; min-height: 22px;
    font-size: 14px; font-weight: bold; display: none;
}

.read-challenge {
    background: linear-gradient(135deg, #fff8e1, #fff3e0);
    border-radius: 12px; padding: 12px; text-align: center;
    border: 1px dashed #ffcc80;
}
.challenge-title { font-size: 15px; font-weight: bold; color: #ff8f00; margin-bottom: 4px; }
.challenge-desc { font-size: 12px; color: #999; margin-bottom: 8px; }
.btn-challenge {
    padding: 9px 28px; border-radius: 24px; border: none;
    background: linear-gradient(135deg, #ff8f00, #ffa726);
    color: #fff; font-size: 14px; font-weight: bold; cursor: pointer;
}
.btn-challenge:active { transform: scale(0.96); }
.btn-challenge.listening { background: linear-gradient(135deg, #e53935, #ef5350); animation: pulse 1s infinite; }
.read-score { margin-top: 8px; font-size: 20px; color: #ff8f00; display: none; }

/* ============================================================
   选 (Choose) 功能区
   ============================================================ */
.choose-practice { padding: 3px 0; }
.choose-prompt { font-size: 14px; font-weight: bold; color: #333; text-align: center; margin-bottom: 6px; }
.choose-hint {
    background: #fff; border-radius: 10px; padding: 10px; text-align: center;
    font-size: 18px; font-weight: bold; color: #ff8f00;
    margin-bottom: 8px; min-height: 24px;
}
.choose-options { display: flex; flex-direction: column; gap: 7px; margin-bottom: 8px; }
.choose-option {
    background: #fff; border-radius: 10px; padding: 11px 16px;
    font-size: 19px; font-weight: bold; cursor: pointer; text-align: center;
    transition: all 0.3s; border: 2px solid transparent;
}
.choose-option:active { transform: scale(0.97); }
.choose-option.correct { background: #e8f5e9; border-color: #4caf50; color: #2e7d32; }
.choose-option.wrong { background: #ffebee; border-color: #f44336; color: #c62828; }
.choose-option.disabled { pointer-events: none; opacity: 0.6; }
.choose-result {
    text-align: center; font-size: 15px; font-weight: bold;
    margin-bottom: 6px; min-height: 22px; display: none;
}
.choose-progress {
    display: flex; justify-content: space-around; padding: 7px;
    background: #fff3e0; border-radius: 10px; font-size: 12px;
}
.choose-progress b { color: #ff8f00; }

/* ============================================================
   拼 (Spell) 功能区
   ============================================================ */
.spell-practice { padding: 3px 0; }
.spell-prompt { font-size: 13px; font-weight: bold; color: #333; text-align: center; margin-bottom: 6px; }
.spell-hint {
    background: #fff; border-radius: 10px; padding: 8px; text-align: center;
    font-size: 16px; font-weight: bold; color: #ff8f00; margin-bottom: 5px;
    min-height: 22px;
}
.spell-phonetic {
    text-align: center; font-size: 13px; color: #999; margin-bottom: 8px;
    font-family: "Times New Roman", serif;
}
.spell-area {
    background: #fff; border-radius: 10px; padding: 10px; min-height: 48px;
    margin-bottom: 7px; display: flex; flex-wrap: wrap; gap: 5px;
    justify-content: center; align-items: center;
    border: 2px dashed #e0e0e0;
}
.spell-area.filled { border-color: #ff8f00; border-style: solid; }
.spell-slot {
    width: 34px; height: 40px; border-radius: 6px; background: #fafafa;
    display: flex; align-items: center; justify-content: center;
    font-size: 21px; font-weight: bold; color: #333;
    border-bottom: 2px solid #ddd;
}
.spell-slot.active { background: #fff7e0; border-bottom-color: #ff8f00; }
.spell-slot.wrong { background: #ffebee; border-bottom-color: #f44336; }

.spell-letters {
    display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-bottom: 8px;
    background: #f0f4f8; border-radius: 10px; padding: 8px; min-height: 40px;
}
.spell-letter {
    width: 36px; height: 36px; border-radius: 8px; background: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: bold; color: #333; cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08); user-select: none;
}
.spell-letter:active { transform: scale(0.9); }
.spell-letter.used { visibility: hidden; }

.spell-controls { display: flex; gap: 7px; margin-bottom: 7px; }
.spell-btn {
    flex: 1; padding: 8px; border-radius: 10px; border: none;
    background: linear-gradient(135deg, #ff8f00, #ffa726);
    color: #fff; font-size: 13px; font-weight: bold; cursor: pointer;
}
.spell-btn:active { transform: scale(0.96); }
.spell-btn.secondary { background: #f0f0f0; color: #666; }

.spell-result {
    text-align: center; font-size: 15px; font-weight: bold;
    margin-bottom: 5px; min-height: 22px; display: none;
}
.spell-progress {
    display: flex; justify-content: space-around; padding: 6px;
    background: #fff3e0; border-radius: 8px; font-size: 12px;
}
.spell-progress b { color: #ff8f00; }

/* ============================================================
   写 (Write) 功能区 — Canvas 手写
   ============================================================ */
.write-practice { padding: 3px 0; }
.write-prompt { font-size: 13px; font-weight: bold; color: #333; text-align: center; margin-bottom: 4px; }
.write-hint { text-align: center; font-size: 12px; color: #999; margin-bottom: 6px; }
.write-canvas-wrapper {
    position: relative; background: #fff; border-radius: 12px;
    margin-bottom: 7px; overflow: hidden;
}
#write-canvas {
    display: block; width: 100%; height: 200px;
    touch-action: none; cursor: crosshair;
}
.write-guide-text {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 80px; font-weight: bold; color: rgba(200,200,200,0.3);
    pointer-events: none; font-family: "Times New Roman", serif; user-select: none;
}
.write-guide-text.hidden { display: none; }

.write-precision {
    text-align: center; font-size: 12px; color: #4caf50;
    margin-bottom: 5px; min-height: 18px; display: none;
}
.write-tips {
    background: #fff8e1; border-radius: 10px; padding: 8px 10px;
    border-left: 3px solid #ffc107; margin-bottom: 6px;
}
.tip-title { font-size: 12px; font-weight: bold; color: #ff8f00; margin-bottom: 3px; }
.write-tips ul { padding-left: 16px; }
.write-tips li { font-size: 11px; color: #666; line-height: 1.6; }

/* ===== 教材模块内容面板 ===== */
.module-panel {
    display: none;
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background: #f8f6f0; z-index: 60; flex-direction: column;
}
.module-panel.show { display: flex; }
.module-header {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.module-title { font-size: 16px; font-weight: bold; color: #333; margin: 0; flex: 1; }
.module-body { flex: 1; overflow-y: auto; padding: 10px 12px; }
.module-section-title {
    font-size: 14px; font-weight: bold; color: #333;
    margin: 8px 0 8px;
}
.module-count { font-size: 12px; color: #999; font-weight: normal; }
.unit-group-title {
grid-column: 1 / -1;
font-size: 13px; font-weight: bold; color: #e8630a;
background: #fff3e6; border-radius: 8px;
padding: 6px 10px; margin: 6px 0 2px;
}
.module-words {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 8px; margin-bottom: 12px;
}
.module-word-card {
    background: #fff; border-radius: 10px; padding: 10px 6px;
    text-align: center; cursor: pointer; transition: all 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.module-word-card:active { transform: scale(0.95); background: #fff7e0; }
.module-word-card.current { border: 2px solid #ff8f00; background: #fff7e0; }
.mw-word { font-size: 15px; font-weight: bold; color: #333; }
.mw-def { font-size: 10px; color: #999; margin-top: 3px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.module-dialogue {
    background: #fff; border-radius: 12px; padding: 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.dialogue-line {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 14px; line-height: 1.5;
}
.dialogue-line .speaker { color: #4a90d9; font-weight: bold; flex-shrink: 0; }
.dialogue-line .text { color: #444; flex: 1; }
.dialogue-line .zh { color: #999; font-size: 12px; display: block; }
.dialogue-play {
    width: 26px; height: 26px; border-radius: 50%; border: none;
    background: #e8f4fd; cursor: pointer; font-size: 12px; flex-shrink: 0;
}
.module-tip {
    background: #fff8e1; border-radius: 10px; padding: 8px 12px;
    font-size: 12px; color: #8d6e00; margin-bottom: 10px;
    border-left: 3px solid #ffc107;
}

/* 响应式 */
@media (max-width: 375px) {
    .word-main { font-size: 30px; }
    .choose-option { font-size: 16px; padding: 9px 12px; }
    .read-word { font-size: 19px; }
    .spell-letter { width: 32px; height: 32px; font-size: 15px; }
    .spell-slot { width: 30px; height: 36px; font-size: 18px; }
}

/* ===== 手机竖屏矮屏一屏适配 ===== */
@media (max-height: 800px) {
    .top-banner { padding: 4px 12px; }
    .banner-subtitle { display: none; }
    .banner-title { font-size: 13px; }
    .word-main { font-size: 31px; margin-bottom: 4px; min-height: 36px; }
    .word-display { padding: 8px; margin-bottom: 5px; }
    .syllable-tag { padding: 2px 10px; font-size: 12px; }
    .phonetic { font-size: 14px; }
    .phonics-table { margin-bottom: 5px; }
    .phonics-row { padding: 1px 8px; }
    .phonics-letter { font-size: 14px; min-width: 28px; }
    .phonics-sound { font-size: 13px; }
    .feature-buttons { margin-bottom: 5px; }
    .feature-btn { padding: 6px; font-size: 12px; }
    .example-section { padding: 7px 10px; margin-bottom: 5px; }
    .example-en { font-size: 14px; }
    .example-read-row { margin-top: 5px; }
    .audio-controls { margin-bottom: 5px; }
    .audio-control-btn { padding: 4px 4px; }
    .bottom-actions { padding: 0; }
    .action-btn { padding: 4px 3px; }
    .textbook-item { width: 40px; }
}

/* 更低矮的手机进一步压缩 */
@media (max-height: 680px) {
    .step-tab { width: 34px; height: 34px; font-size: 13px; }
    .word-main { font-size: 28px; }
    .phonics-table { padding: 4px 10px; }
    .example-section { padding: 6px 10px; }
    .btn-read-sentence { padding: 4px 12px; }
    .read-sentence { padding: 8px; min-height: 40px; }
    .read-word { font-size: 19px; }
    .choose-option { padding: 8px 14px; font-size: 17px; }
    #write-canvas { height: 160px; }
    .textbook-bar { padding: 2px 10px; }
}

/* ===== 添加自定义单词表单 ===== */
.add-btn {
    width: 30px; height: 30px; margin-left: 2px; font-size: 18px; font-weight: bold;
    color: #ff8f00; background: #fff8ee; border: 1px solid #ffe0b2;
}
.add-form { min-width: 300px; max-width: 88%; text-align: left; max-height: 86vh; overflow-y: auto; }
.add-form h3 { text-align: center; margin-bottom: 12px; }
.add-form label {
    display: block; font-size: 12px; color: #888; margin: 10px 0 4px; font-weight: bold;
}
.add-form input, .add-form select {
    width: 100%; box-sizing: border-box; padding: 9px 10px; border: 1px solid #ddd;
    border-radius: 10px; font-size: 14px; background: #fafafa; color: #333; outline: none;
}
.add-form input:focus, .add-form select:focus { border-color: #ff8f00; background: #fff; }
.add-form-btns { display: flex; gap: 10px; margin-top: 16px; }
.add-form-btns button {
    flex: 1; padding: 10px 0; border-radius: 20px; border: none; font-size: 14px; cursor: pointer;
    background: linear-gradient(135deg, #ff8f00, #ffa726); color: #fff;
}
.add-form-btns button.cancel { background: #eee; color: #666; }
.empty-tip { grid-column: 1/-1; text-align: center; color: #aaa; font-size: 13px; padding: 24px 0; }
