/* ========== 全局样式 ========== */
body {
    background: #f5f7fa;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    padding-top: 55px;
    color: #2c3e50;
}

.main-content {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 10px;
}

/* ========== 页面切换 ========== */
.page { display: none; }
.page.active { display: block; animation: fadeIn .25s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ========== 首页 ========== */
.home-header {
    text-align: center;
    padding: 30px 0 20px;
}
.home-header h2 { margin: 0; font-size: 22px; color: #2c3e50; }
.home-header p { margin: 8px 0 0; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 20px 0;
}
.feature-item {
    text-align: center;
    background: #fff;
    border-radius: 12px;
    padding: 20px 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    cursor: pointer;
    transition: transform .2s, box-shadow .2s;
}
.feature-item:active {
    transform: scale(.95);
}
.feature-icon { font-size: 32px; margin-bottom: 8px; }
.feature-label { font-size: 13px; color: #7f8c8d; }

.quick-stats {
    display: flex;
    justify-content: space-around;
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    margin-top: 10px;
}
.qs-item { text-align: center; }
.qs-num { display: block; font-size: 22px; font-weight: bold; color: #3498db; }
.qs-label { font-size: 12px; color: #95a5a6; }

/* ========== 页面标题栏 ========== */
.page-title-bar {
    display: flex;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #ecf0f1;
    margin-bottom: 15px;
}
.page-title-bar h3 { margin: 0; font-size: 18px; }
.back-btn {
    font-size: 22px;
    margin-right: 15px;
    text-decoration: none;
    color: #3498db;
}

/* ========== 字母索引 ========== */
.letter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 8px 0;
    justify-content: center;
}
.letter-bar .lb-item {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border-radius: 4px;
    font-size: 13px;
    font-weight: bold;
    color: #7f8c8d;
    cursor: pointer;
    background: #fff;
}
.letter-bar .lb-item.active,
.letter-bar .lb-item:active {
    background: #3498db;
    color: #fff;
}
.letter-bar .lb-item.has-data {
    color: #2c3e50;
    font-weight: bold;
}

/* ========== 词汇列表 ========== */
.vocab-list .vl-item {
    background: #fff;
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.vl-item .vl-word { font-size: 17px; font-weight: bold; color: #2c3e50; }
.vl-item .vl-phonetic { font-size: 13px; color: #95a5a6; margin-left: 8px; }
.vl-item .vl-pos {
    display: inline-block;
    font-size: 11px;
    color: #fff;
    background: #3498db;
    border-radius: 3px;
    padding: 1px 6px;
    margin-left: 6px;
}
.vl-item .vl-meaning { font-size: 14px; color: #555; margin-top: 4px; }
.vl-item .vl-mastery {
    display: inline-block;
    font-size: 11px;
    border-radius: 3px;
    padding: 1px 6px;
    margin-top: 4px;
}
.mastery-0 { background: #ecf0f1; color: #95a5a6; }
.mastery-1 { background: #fef3cd; color: #856404; }
.mastery-2 { background: #f8d7da; color: #721c24; }
.mastery-3 { background: #d4edda; color: #155724; }

/* ========== 搜索框 ========== */
.search-box { margin-bottom: 15px; }

/* ========== 闪卡模式 ========== */
.flashcard-container {
    perspective: 1000px;
    padding: 20px 0;
}
.flashcard {
    width: 100%;
    min-height: 280px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform .6s;
    cursor: pointer;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-front, .flashcard-back {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    backface-visibility: hidden;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
}
.flashcard-back { transform: rotateY(180deg); }
.fc-word { font-size: 32px; font-weight: bold; color: #2c3e50; }
.fc-phonetic { font-size: 16px; color: #7f8c8d; margin-top: 8px; }
.fc-pos { font-size: 14px; color: #3498db; margin-top: 6px; }
.fc-meaning { font-size: 20px; color: #27ae60; text-align: center; line-height: 1.5; }
.fc-hint { font-size: 12px; color: #bdc3c7; margin-top: 20px; }

.flashcard-actions {
    display: flex;
    justify-content: space-between;
    padding: 20px 30px;
}
.fc-btn { width: 45%; font-size: 16px; padding: 12px; border-radius: 10px; }
.fc-progress { text-align: center; color: #95a5a6; padding: 10px; }

/* ========== 四选一测验 ========== */
.quiz-container {
    background: #fff;
    border-radius: 16px;
    padding: 30px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    text-align: center;
}
.quiz-word { font-size: 28px; font-weight: bold; color: #2c3e50; }
.quiz-phonetic { font-size: 14px; color: #95a5a6; margin-top: 5px; }
.quiz-pos { font-size: 13px; color: #3498db; margin-bottom: 20px; }
.quiz-options { text-align: left; }
.quiz-options .btn {
    display: block;
    width: 100%;
    margin-bottom: 10px;
    text-align: left;
    padding: 12px 15px;
    border-radius: 8px;
    font-size: 14px;
    white-space: normal;
}
.quiz-result {
    padding: 15px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    margin-top: 15px;
}
.quiz-result.correct { background: #d4edda; color: #155724; }
.quiz-result.wrong { background: #f8d7da; color: #721c24; }

.quiz-stats {
    display: flex;
    justify-content: space-around;
    padding: 15px;
    margin-top: 15px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

/* ========== 挖空练习 ========== */
.fill-container {
    background: #fff;
    border-radius: 16px;
    padding: 30px 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    text-align: center;
}
.fill-meaning { font-size: 20px; color: #2c3e50; font-weight: bold; margin-bottom: 5px; }
.fill-pos { font-size: 13px; color: #3498db; margin-bottom: 20px; }
.fill-input-box {
    display: flex;
    gap: 10px;
}
.fill-input-box input { font-size: 18px; height: 46px; }
.fill-input-box .btn { font-size: 16px; padding: 6px 20px; }
.fill-result {
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    margin-top: 15px;
}

/* ========== 学习统计 ========== */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}
.sc-item {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 1px 5px rgba(0,0,0,.05);
}
.sc-num { font-size: 28px; font-weight: bold; color: #3498db; }
.sc-label { font-size: 12px; color: #95a5a6; margin-top: 5px; }

.progress-section, .today-section, .checkin-section {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 1px 5px rgba(0,0,0,.05);
}
.progress-section h4, .today-section h4 { margin: 0 0 12px; font-size: 16px; }

.today-stats {
    display: flex;
    justify-content: space-around;
}
.ts-item { text-align: center; font-size: 14px; color: #555; }
.ts-item span { display: block; font-size: 20px; font-weight: bold; color: #2c3e50; }

/* ========== 登录注册 ========== */
.auth-panel { border-radius: 12px; border: none; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.auth-panel .panel-heading { background: #3498db; color: #fff; border-radius: 12px 12px 0 0; text-align: center; }
.auth-panel .panel-body { padding: 25px; }

/* ========== 个人中心 ========== */
.profile-card {
    text-align: center;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: #fff;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 20px;
}
.profile-avatar { font-size: 50px; margin-bottom: 10px; }
.profile-name { font-size: 20px; font-weight: bold; }
.profile-score { font-size: 14px; opacity: .8; margin-top: 8px; }
.profile-form { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 5px rgba(0,0,0,.05); }

/* ========== 空状态 ========== */
.empty-tip {
    text-align: center;
    color: #95a5a6;
    padding: 50px 20px;
    font-size: 16px;
}

/* ========== 响应式 ========== */
/* ========== Mobile ========== */
@media (max-width: 767px) {
    .read-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: #fff;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
        padding: 8px 15px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        max-width: 480px;
        margin: 0 auto;
    }
    .read-nav .btn {
        padding: 8px 20px;
        font-size: 14px;
    }
    #page-read {
        padding-bottom: 55px;
    }
    .page-title-bar {
        padding: 8px 0;
        margin-bottom: 6px;
    }
    .read-progress-bar {
        margin: 4px 15px;
    }
    .read-step-tabs {
        padding: 4px 15px;
        margin-bottom: 0;
    }
    .read-word-section {
        padding: 10px 15px 5px;
    }
    .read-word-display {
        font-size: 2.2em;
        margin-bottom: 8px;
        letter-spacing: 2px;
    }
    .read-mode-toggle {
        margin-bottom: 8px;
    }
    .read-mode-btn {
        padding: 4px 14px;
        font-size: 12px;
    }
    .read-syllable-blocks {
        min-height: auto;
        margin-bottom: 8px;
    }
    .syllable-block {
        padding: 6px 14px;
    }
    .read-phonetic-row {
        margin-bottom: 4px;
    }
    .read-meaning {
        margin-bottom: 5px;
    }
    .read-example-section {
        padding: 8px 12px;
        margin: 0 10px 6px;
    }
    .read-example-header {
        margin-bottom: 4px;
    }
    .example-item {
        padding: 6px 10px;
    }
    .read-examples-list {
        gap: 6px;
    }
    .read-actions {
        padding: 8px 10px 6px;
    }
}
/* ========== 小屏幕适配 (≤360px) ========== */
@media (max-width: 360px) {
    .feature-grid { gap: 10px; }
    .feature-item { padding: 15px 8px; }
    .feature-icon { font-size: 26px; }
    .feature-label { font-size: 11px; }
    .fc-word { font-size: 26px; }
    .fc-meaning { font-size: 16px; }
    .quiz-word { font-size: 22px; }
    .letter-bar .lb-item { width: 26px; height: 26px; line-height: 26px; font-size: 11px; }
}

/* ========== 平板适配 ========== */
@media (min-width: 768px) {
    .main-content { max-width: 600px; }
    .feature-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
    .feature-item { padding: 25px 15px; }
    .feature-icon { font-size: 36px; }
}

/* ========== 加载动画 ========== */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ecf0f1;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 消息提示 ========== */
.toast-msg {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,.75);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 9999;
    animation: toastIn .3s;
}
/* ========== 跟读练习页面 ========== */

/* 进度条 */
.read-progress-bar {
    position: relative;
    height: 8px;
    background: #e8e8e8;
    border-radius: 4px;
    margin: 8px 15px;
    overflow: hidden;
}
.read-progress-inner {
    height: 100%;
    background: linear-gradient(90deg, #ff6600, #00aa44);
    border-radius: 4px;
    transition: width 0.4s ease;
    max-width: 100%;
}
.read-progress-text {
    position: absolute;
    right: 0;
    top: -22px;
    font-size: 12px;
    color: #95a5a6;
}

/* 步骤标签 */
.read-step-tabs {
    display: flex;
    justify-content: space-around;
    padding: 8px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    margin-bottom: 5px;
}
.read-tab {
    padding: 4px 14px;
    border-radius: 15px;
    font-size: 13px;
    color: #aaa;
    cursor: default;
    transition: all 0.2s;
}
.read-tab.active {
    background: #00aa44;
    color: #fff;
    font-weight: 500;
}

/* 单词展示区 */
.read-word-section {
    padding: 20px 15px 10px;
    text-align: center;
}
.read-word-display {
    font-size: 2.8em;
    font-weight: bold;
    letter-spacing: 3px;
    margin-bottom: 12px;
    min-height: 1.2em;
    line-height: 1.3;
}
.read-loading {
    color: #aaa;
    font-size: 1.2em;
    padding: 40px;
}
.read-empty {
    color: #95a5a6;
    font-size: 1em;
    padding: 40px;
}

/* 模式切换按钮 */
.read-mode-toggle {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}
.read-mode-btn {
    padding: 5px 18px;
    border-radius: 20px;
    border: 1px solid #ddd;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    color: #666;
    transition: all 0.2s;
}
.read-mode-btn.active {
    background: #ff6600;
    color: #fff;
    border-color: #ff6600;
}

/* 音节拆解块 */
.read-syllable-blocks {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
    min-height: 50px;
}
.syllable-block {
    padding: 10px 18px;
    border-radius: 10px;
    min-width: 55px;
    text-align: center;
    transition: transform 0.15s;
}
.syllable-block:active {
    transform: scale(0.95);
}
.sb-text {
    font-size: 1.3em;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}
.sb-phonetic {
    font-size: 0.85em;
    color: #999;
    margin-top: 3px;
}

/* 音标行 */
.read-phonetic-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 1.05em;
    color: #555;
}
.read-phonetic-label {
    color: #ff6600;
    font-weight: bold;
    font-size: 0.9em;
}
.read-phonetic-text {
    font-style: italic;
    color: #777;
}
.read-phonetic-btn {
    background: none;
    border: none;
    font-size: 1.3em;
    cursor: pointer;
    padding: 2px 6px;
    color: #ff6600;
    transition: transform 0.15s;
}
.read-phonetic-btn:active {
    transform: scale(0.85);
}

/* 词性 */
.read-pos {
    font-size: 0.85em;
    color: #aaa;
    margin-bottom: 4px;
}

/* 中文释义 */
.read-meaning {
    font-size: 1.1em;
    color: #333;
    font-weight: 500;
    margin-bottom: 10px;
}

/* 例句区 */
.read-example-section {
    background: #f9f9f9;
    padding: 14px 16px;
    margin: 0 15px 12px;
    border-radius: 10px;
    border-left: 3px solid #ff6600;
}
.read-example-label {
    font-size: 11px;
    color: #bbb;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 例句列表 */
.read-examples-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* 例句头部（包含标签和刷新按钮） */
.read-example-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.example-refresh-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    transition: background 0.2s;
}
.example-refresh-btn:hover {
    background: rgba(0,0,0,0.05);
}
.example-refresh-btn:active {
    background: rgba(0,0,0,0.1);
}
.example-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.example-spin {
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.example-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}
.example-item:active {
    transform: scale(0.98);
}
.example-item.active {
    border-color: #ff6600;
    background: #fff9f5;
}
.example-item:hover:not(.active) {
    border-color: #ddd;
    background: #fafafa;
}

.example-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    background: #ff6600;
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

.example-content {
    flex: 1;
    min-width: 0;
}

.example-en {
    font-size: 1em;
    color: #2c3e50;
    line-height: 1.6;
    margin-bottom: 3px;
}
.example-cn {
    font-size: 0.85em;
    color: #888;
    line-height: 1.4;
}

.example-loading,
.example-error {
    text-align: center;
    padding: 15px;
    color: #999;
    font-size: 0.9em;
}
.example-error {
    color: #e74c3c;
}

/* 兼容旧样式 */
.read-example-en {
    font-size: 1.05em;
    color: #2c3e50;
    line-height: 1.7;
    margin-bottom: 5px;
}
.read-example-cn {
    font-size: 0.9em;
    color: #888;
}

/* 跟读操作区 */
.read-actions {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 14px 10px 10px;
}
.read-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 12px 18px;
    border: none;
    background: #f0f0f0;
    border-radius: 14px;
    cursor: pointer;
    min-width: 78px;
    transition: all 0.2s;
    color: #555;
}
.read-action-btn:active {
    transform: scale(0.93);
}
.read-action-record {
    background: #e8f5e9;
    color: #2e7d32;
}
.read-action-record.recording {
    background: #ff5722;
    color: #fff;
}
.read-action-btn.disabled {
    opacity: 0.35;
    pointer-events: none;
}
.ra-icon {
    font-size: 1.6em;
    line-height: 1;
}
.ra-label {
    font-size: 11px;
    font-weight: 500;
}

/* 底部翻页 */
.read-nav {
    display: flex;
    justify-content: space-between;
    padding: 8px 15px 25px;
}
.read-nav .btn {
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
}