/* === 课文朗读训练 === */

.rp-fullscreen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
}

/* --- Header --- */
.rp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    z-index: 10;
}
.rp-header .back-btn-wrap { flex: 0 0 auto; }
.rp-header .back-btn {
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    opacity: 0.8;
}
.rp-header .title {
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    flex: 1;
}
.points-badge {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: rgba(255, 193, 7, 0.2);
    padding: 0.25rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    color: #ffc107;
}

/* --- Main area --- */
.rp-main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

/* --- Screens --- */
.screen {
    display: none;
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}
.screen.active { display: block; }

/* --- Menu screen --- */
.menu-title {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin: 0.8rem 0 0.3rem;
}
.menu-desc {
    text-align: center;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 1.2rem;
}

.opt-group { margin-bottom: 1rem; }
.opt-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 0.5rem;
}

.unit-btns, .section-btns, .threshold-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.unit-btn, .section-btn, .th-btn {
    padding: 0.5rem 0.8rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.unit-btn:hover, .section-btn:hover, .th-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}
.unit-btn.active, .section-btn.active, .th-btn.active {
    background: rgba(99, 102, 241, 0.5);
    border-color: #6366f1;
}
.unit-btn .unit-check {
    font-size: 0.7rem;
    color: #4ade80;
    margin-left: 0.2rem;
}
.section-placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.85rem;
    padding: 0.5rem;
}
.section-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    flex: 1;
    min-width: 45%;
}
.section-btn .sec-name { font-size: 0.85rem; font-weight: 500; }
.section-btn .sec-info {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 0.15rem;
}

.start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.9rem;
    border: none;
    border-radius: 0.8rem;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: opacity 0.2s;
}
.start-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.menu-stats {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    text-align: center;
}

/* === Practice screen === */
.progress-area {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}
.progress-track {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a78bfa);
    border-radius: 3px;
    transition: width 0.3s;
    width: 0%;
}
.progress-label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
}

/* 句子区 */
.sentence-area {
    text-align: center;
    margin-bottom: 0.8rem;
}
.sentence-zh {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.4rem;
}
.sentence-en {
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.5;
    color: #fff;
    margin-bottom: 0.6rem;
}

/* 听发音按钮 */
.listen-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 1rem;
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 2rem;
    background: rgba(99, 102, 241, 0.12);
    color: #a78bfa;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.listen-btn.playing {
    animation: pulse-glow 1s infinite;
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(99, 102, 241, 0); }
}

/* === 评分结果 === */
.result-area {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.8rem;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.result-area.hidden { display: none; }

.result-header {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.2rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.result-score {
    font-size: 1.8rem;
    font-weight: 700;
}
.result-score.good { color: #4ade80; }
.result-score.ok { color: #facc15; }
.result-score.bad { color: #ef4444; }
.result-unit {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-right: 0.6rem;
}
.result-detail {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0 0.3rem;
}
.result-detail b {
    color: #fff;
    font-weight: 600;
    margin-left: 0.15rem;
}

/* 逐词反馈 */
.word-feedback {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3rem;
    margin-bottom: 0.6rem;
}
.word-chip {
    padding: 0.25rem 0.5rem;
    border-radius: 0.3rem;
    font-size: 0.85rem;
    font-weight: 500;
}
.word-chip.perfect { background: rgba(74, 222, 128, 0.15); color: #4ade80; }
.word-chip.good { background: rgba(250, 204, 21, 0.15); color: #facc15; }
.word-chip.bad { background: rgba(239, 68, 68, 0.2); color: #ef4444; text-decoration: underline wavy; }
.word-chip.missed { background: rgba(239, 68, 68, 0.1); color: rgba(239, 68, 68, 0.6); text-decoration: line-through; }
.word-chip .word-score {
    display: block;
    font-size: 0.55rem;
    text-align: center;
    opacity: 0.7;
}

/* 重试 / 下一句按钮 */
.result-actions {
    display: flex;
    gap: 0.5rem;
}
.action-btn {
    flex: 1;
    padding: 0.55rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.action-btn.next-btn {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-color: transparent;
}
.action-btn.next-btn:disabled { background: rgba(99, 102, 241, 0.3); }

/* 底部留白 */
.bottom-spacer { height: 6rem; }

/* === 浮动录音按钮 === */
.floating-record {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 0.3rem 1rem 0.6rem;
    padding-bottom: calc(0.6rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(transparent, rgba(15, 12, 41, 0.95) 30%);
    z-index: 20;
}
.floating-record.visible { display: block; }
.record-hint {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 0.3rem;
}
.record-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    transition: all 0.2s;
}
.record-btn:active, .record-btn.recording {
    background: rgba(239, 68, 68, 0.4);
    border-color: #ef4444;
    transform: scale(1.08);
}
.record-btn.recording {
    animation: recording-pulse 1.2s infinite;
}
@keyframes recording-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}
.record-btn.disabled { opacity: 0.4; pointer-events: none; }

/* === Done screen === */
.done-icon {
    text-align: center;
    font-size: 4rem;
    color: #fbbf24;
    margin: 2rem 0 1rem;
}
.done-title {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 1rem;
}
.done-stats {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.8rem;
    padding: 1rem;
    margin-bottom: 1.5rem;
}
.done-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    font-size: 0.9rem;
}
.done-stat-row .label { color: rgba(255, 255, 255, 0.6); }
.done-stat-row .value { font-weight: 600; }
.done-actions { display: flex; gap: 0.8rem; }

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-box {
    background: #1e1b4b;
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 360px;
    width: 100%;
    text-align: center;
}
.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.8rem; }
.modal-body {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
    margin-bottom: 1.2rem;
}
.modal-close-btn {
    padding: 0.6rem 2rem;
    border: none;
    border-radius: 0.5rem;
    background: #6366f1;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
}
