/* --- 1. 全局变量 (Kunkwan Daily 品牌色) --- */
:root {
    --kunkwan-red: #D32F2F; 
    --kunkwan-white: #FFFFFF;
    --text-dark: #1F2937;
    --text-gray: #6B7280;
    --bg-light: #F9FAFB;
    --border-light: #E5E7EB;
}

/* --- 2. 基础重置 --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html {
    height: 100%;
}

body {
    background-color: var(--bg-light);
    color: var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: stretch;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
}

/* --- 3. 手机端视口容器 --- */
.app-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    min-height: 100%;
    background-color: var(--kunkwan-white);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* --- 4. 页面内容布局 --- */
.screen {
    display: none;
    flex: 1;
    flex-direction: column;
    padding: 40px 24px;
    text-align: center;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

.justify-center {
    justify-content: center;
}

.logo-placeholder {
    width: 80px; height: 80px; background-color: var(--kunkwan-red); border-radius: 20px;
    margin: 0 auto 32px auto; display: flex; align-items: center; justify-content: center;
    color: white; font-size: 32px; font-weight: bold;
}

h1 { font-size: 28px; font-weight: 700; margin-bottom: 16px; line-height: 1.3; }
p { font-size: 16px; color: var(--text-gray); line-height: 1.5; margin-bottom: 32px; }

/* --- 5. 选项按钮 (Onboarding 问答用) --- */
.option-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.btn-option {
    background-color: var(--kunkwan-white); border: 2px solid var(--border-light);
    color: var(--text-dark); border-radius: 16px; padding: 16px 20px;
    font-size: 16px; font-weight: 600; text-align: left; cursor: pointer; transition: all 0.2s ease;
}
.btn-option:active, .btn-option.selected { border-color: var(--kunkwan-red); background-color: rgba(211, 47, 47, 0.05); }

/* --- 6. 核心操作按钮 --- */
.footer-action {
    padding: 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    background: var(--kunkwan-white);
}
.btn-primary {
    width: 100%; background-color: var(--kunkwan-red); color: var(--kunkwan-white);
    border: none; border-radius: 100px; padding: 18px 24px; font-size: 16px; font-weight: 700; cursor: pointer;
}

/* --- 7. 主页特定的布局 --- */
.home-container {
    flex: 1; overflow-y: auto; padding: 32px 24px; padding-bottom: 100px;
    text-align: left; background-color: var(--bg-light);
}

/* 修改: Home 顶部红色区域 (去圆角) */
.home-header {
    background-color: var(--kunkwan-red); color: var(--kunkwan-white);
    padding: 32px 24px 40px 24px; display: flex; align-items: center; gap: 16px;
    margin: -32px -24px 24px -24px; box-shadow: 0 4px 12px rgba(211, 47, 47, 0.15);
}
.header-text-block { flex: 1; }
.home-header h2 { color: var(--kunkwan-white); font-size: 22px; margin-bottom: 4px; }
.home-header p { color: rgba(255, 255, 255, 0.9); font-size: 14px; margin: 0; }
.header-mascot { width: 80px; height: auto; object-fit: contain; }

/* --- 8. 普通卡片 --- */
.card {
    background: var(--kunkwan-white); border-radius: 24px; overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04); margin-bottom: 24px; border: 1px solid var(--border-light);
}

/* --- 9. 底部导航栏 --- */
/* --- 9. 底部导航栏 --- */
/* ========================================= */
        /* 终极底部导航栏 (带中央悬浮大按键) */
        /* ========================================= */
        .bottom-nav-container {
            position: fixed;
            bottom: 0;
            width: 100%;
            max-width: 480px;
            z-index: 100;
        }

        .bottom-nav {
            background: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 10px 24px 10px;
            border-top-left-radius: 24px;
            border-top-right-radius: 24px;
            box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
            position: relative;
        }

        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            color: #9CA3AF;
            font-size: 10px;
            font-weight: 800;
            gap: 6px;
            cursor: pointer;
            width: 50px;
        }
        .nav-item.active { color: #E52D27; }
        .nav-item i { font-size: 22px; }

        /* 中间的悬浮播放键 */
        .nav-center-wrapper {
            position: absolute;
            top: -24px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            cursor: pointer;
        }

        .floating-play-btn {
            width: 60px;
            height: 60px;
            background: #E52D27; /* Kunkwan Red */
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-size: 24px;
            box-shadow: 0 8px 20px rgba(229,45,39,0.4);
            border: 4px solid white; /* 白色边框产生嵌入感 */
            transition: transform 0.1s;
        }
        .floating-play-btn:active { transform: scale(0.95); }
.nav-item { display: flex; flex-direction: column; align-items: center; color: var(--text-gray); text-decoration: none; font-size: 11px; font-weight: 600; gap: 4px; }
.nav-item i { font-size: 20px; }
.nav-item.active { color: var(--kunkwan-red); }

/* --- 10. 播放器 UI (playerF1E1.html) --- */
.player-header { display: flex; align-items: center; padding: calc(20px + env(safe-area-inset-top, 0px)) 24px 20px; gap: 16px; }
.btn-close { background: none; border: none; font-size: 24px; color: var(--text-gray); cursor: pointer; }
.progress-container { flex: 1; height: 8px; background-color: var(--border-light); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; width: 20%; background-color: var(--kunkwan-red); border-radius: 4px; transition: width 0.3s ease; }

.stage-song { display: flex; flex-direction: column; align-items: center; padding: 0 24px; flex: 1; }
.album-art { width: 240px; height: 240px; background: linear-gradient(135deg, #FF7E5F, #FEB47B); border-radius: 24px; margin-bottom: 32px; display: flex; align-items: center; justify-content: center; color: white; font-size: 80px; }
.song-info { text-align: center; margin-bottom: 40px; }
.song-info h2 { font-size: 28px; font-weight: 700; margin-bottom: 8px; }
.song-info p { font-size: 16px; color: var(--text-gray); }

.stage-speaking { display: none; flex-direction: column; align-items: center; padding: 0 24px; flex: 1; justify-content: center; }
.target-pinyin { font-size: 32px; font-weight: 700; color: var(--text-dark); margin-bottom: 12px; text-align: center; }
.target-meaning { font-size: 18px; color: var(--text-gray); margin-bottom: 40px; text-align: center; }

.mic-container { display: flex; flex-direction: column; align-items: center; margin-bottom: 40px; }
.btn-mic { width: 80px; height: 80px; border-radius: 50%; background-color: var(--kunkwan-white); border: 3px solid var(--border-light); color: var(--text-dark); font-size: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s ease; }
.btn-mic.recording { border-color: var(--kunkwan-red); background-color: var(--kunkwan-red); color: var(--kunkwan-white); animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4); } 70% { box-shadow: 0 0 0 20px rgba(211, 47, 47, 0); } 100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0); } }
.feedback-text { font-size: 16px; font-weight: 600; color: var(--kunkwan-red); margin-top: 16px; min-height: 24px; }
.btn-text { background: none; border: none; color: var(--text-gray); font-size: 14px; font-weight: 600; cursor: pointer; text-transform: uppercase; padding: 12px; }

/* --- 11. Practice Hub 卡片样式 --- */
.hub-container { display: flex; flex-direction: column; gap: 16px; margin-top: 10px; margin-bottom: 32px; }
.hub-card { display: flex; align-items: center; padding: 16px; background: var(--kunkwan-white); border: 2px solid var(--border-light); border-radius: 20px; text-decoration: none; color: var(--text-dark); transition: transform 0.1s ease; }
.hub-card:active { transform: scale(0.97); border-color: var(--kunkwan-red); background-color: rgba(211, 47, 47, 0.02); }
.hub-icon { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 24px; margin-right: 16px; flex-shrink: 0; }
.icon-class { background: rgba(211, 47, 47, 0.1); color: var(--kunkwan-red); }
.icon-song { background: rgba(59, 130, 246, 0.1); color: #3B82F6; }
.icon-progress { background: rgba(16, 185, 129, 0.1); color: #10B981; }
.icon-dialogue { background: rgba(245, 158, 11, 0.1); color: #F59E0B; }
.hub-text { flex: 1; display: flex; flex-direction: column; }
.hub-text h3 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.hub-text p { font-size: 13px; color: var(--text-gray); margin: 0; }
.hub-card .arrow { font-size: 16px; color: #9CA3AF; margin-left: 12px; }

/* --- 12. 关卡选择页 --- */
.header-bar { display: flex; align-items: center; padding: calc(20px + env(safe-area-inset-top, 0px)) 24px 20px; background: var(--kunkwan-white); border-bottom: 1px solid var(--border-light); position: sticky; top: 0; z-index: 10; }
.header-bar .back-btn { font-size: 20px; color: var(--text-dark); text-decoration: none; margin-right: 16px; cursor: pointer; }
.header-bar h2 { font-size: 18px; font-weight: 700; margin: 0; }
.level-list { padding: 24px; display: flex; flex-direction: column; gap: 20px; padding-bottom: 40px; overflow-y: auto; flex: 1; }
.level-card { display: flex; align-items: center; background: var(--kunkwan-white); border: 2px solid var(--border-light); border-radius: 24px; padding: 20px; text-decoration: none; color: var(--text-dark); }
.level-badge { width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; margin-right: 20px; flex-shrink: 0; background: #E5E7EB; color: #9CA3AF; }
.level-info { flex: 1; }
.level-info h3 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.level-info p { font-size: 13px; margin: 0; color: var(--text-gray); }


/* ========================================= */
/* --- 13. 关卡路线图 (横向铁路滑动 Style) --- */
/* ========================================= */
.top-stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 24px 12px;
    background: var(--kunkwan-white);
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 2px solid var(--border-light);
    font-weight: 700;
    font-size: 15px;
}
.stat-item { display: flex; align-items: center; gap: 6px; }
.stat-streak { color: #FF9600; } .stat-xp { color: #1CB0F6; } .stat-energy { color: #FF4B4B; }
.unit-header-card { background-color: var(--kunkwan-red); color: white; border-radius: 16px; padding: 20px; margin: 16px 24px; display: flex; justify-content: space-between; align-items: center; border-bottom: 4px solid #9E1010; }
.unit-header-card h3 { font-size: 14px; text-transform: uppercase; opacity: 0.9; margin-bottom: 4px; }
.unit-header-card h2 { font-size: 20px; font-weight: 800; line-height: 1.3; }
.unit-guide-btn { background: rgba(255,255,255,0.2); width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; color: white; cursor: pointer; text-decoration: none; flex-shrink: 0; }

/* Unit map P0 polish */
.unit-map-page {
    padding-bottom: 0;
    overflow: hidden !important;
    background-color: var(--kunkwan-white);
}
.unit-map-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
}
.unit-top-bar { gap: 10px; }
.unit-back {
    color: var(--text-dark); text-decoration: none; font-size: 20px;
    width: 30px; display: inline-flex; align-items: center; justify-content: center;
}
.unit-top-stats {
    display: flex; gap: 12px; font-weight: 800; font-size: 13px;
    justify-content: center; flex: 1;
}
.unit-stat { display: inline-flex; align-items: center; gap: 4px; }
.unit-stat--ticket { color: #F59E0B; }
.unit-stat--streak { color: #F59E0B; }
.unit-stat--xp { color: var(--kunkwan-red); }
.unit-selector { position: relative; flex-shrink: 0; }
.unit-selector select {
    border: none; background: #F3F4F6; padding: 6px 24px 6px 12px;
    border-radius: 100px; font-weight: 800; font-size: 12px;
    color: var(--text-dark); outline: none; cursor: pointer; max-width: 110px;
}
.unit-selector .fa-caret-down {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    font-size: 10px; color: #9CA3AF; pointer-events: none;
}

.unit-hero { align-items: flex-start; gap: 12px; }
.unit-hero__text { flex: 1; min-width: 0; }
.unit-progress { margin-top: 14px; }
.unit-progress__meta {
    display: flex; justify-content: space-between; align-items: baseline;
    font-size: 12px; font-weight: 700; opacity: 0.92; margin-bottom: 6px;
}
.unit-progress__track {
    height: 8px; border-radius: 999px; background: rgba(255,255,255,0.28); overflow: hidden;
}
.unit-progress__track i {
    display: block; height: 100%; width: 0%;
    background: #fff; border-radius: 999px;
    transition: width 0.45s ease;
}

.unit-map-hint {
    text-align: center; margin: 4px 24px 0; font-size: 12px;
    font-weight: 600; color: #9CA3AF;
}
.unit-footer-next {
    padding: 20px 24px 24px; text-align: center;
}
.unit-footer-next p {
    color: var(--text-gray); font-size: 14px; margin: 0 0 12px; font-weight: 600;
}
.unit-next-btn {
    background-color: var(--border-light) !important;
    color: var(--text-gray) !important;
    cursor: not-allowed;
}
.unit-next-btn i { margin-left: 8px; }
.unit-next-btn.is-unlocked {
    background-color: var(--text-dark) !important;
    color: var(--kunkwan-white) !important;
    cursor: pointer;
}
.unit-footer-next.is-ready p { color: var(--text-dark); font-weight: 700; }

.unit-continue-bar {
    position: relative;
    z-index: 40;
    flex-shrink: 0;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid #E5E7EB;
    box-shadow: 0 -8px 24px rgba(17, 24, 39, 0.06);
    box-sizing: border-box;
}
.unit-continue-bar[hidden] { display: none !important; }
.unit-map-page.has-continue-bar .unit-map-scroll {
    padding-bottom: 12px;
}
.unit-continue-bar__copy {
    flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
}
.unit-continue-bar__eyebrow {
    font-size: 11px; font-weight: 800; letter-spacing: 0.04em;
    text-transform: uppercase; color: #9CA3AF;
}
.unit-continue-bar__copy strong {
    font-size: 15px; font-weight: 800; color: #111827;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.unit-continue-bar__meta {
    font-size: 12px; font-weight: 700; color: #F59E0B;
}
.unit-continue-bar__btn {
    flex-shrink: 0; border: 0; border-radius: 999px;
    padding: 12px 18px; min-width: 108px;
    font-weight: 800; font-size: 14px; color: #fff; cursor: pointer;
    background: linear-gradient(135deg, #ef5350, #b71c1c);
    box-shadow: 0 8px 18px rgba(211, 47, 47, 0.28);
}

/* Start sheet */
.unit-start-sheet__handle {
    width: 40px; height: 4px; border-radius: 999px; background: #E5E7EB;
    margin: 0 auto 14px;
}
.unit-start-sheet__head {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
    margin-bottom: 8px;
}
.unit-start-sheet__eyebrow {
    margin: 0 0 4px; font-size: 11px; font-weight: 800;
    letter-spacing: 0.04em; text-transform: uppercase; color: #d32f2f;
}
.unit-start-sheet__head h3 {
    margin: 0; font-size: 22px; font-weight: 900; color: #111827; line-height: 1.25;
}
.unit-start-sheet__close {
    border: 0; background: #F3F4F6; width: 36px; height: 36px; border-radius: 50%;
    color: #6B7280; cursor: pointer; flex-shrink: 0;
}
.unit-start-sheet__mascot-wrap {
    display: flex; justify-content: center; margin: 4px 0 10px;
}
.unit-start-sheet__mascot {
    width: 96px; height: 96px; object-fit: contain;
    display: block;
}
.unit-start-sheet__cost {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    align-self: center; margin: 0 auto 8px;
    font-size: 28px; font-weight: 800; color: #F59E0B;
}
.unit-start-sheet__cost.is-free { color: #059669; }
.unit-start-sheet__copy {
    text-align: center; margin: 0 0 16px; font-size: 14px;
    font-weight: 600; color: #6B7280; line-height: 1.45;
}
.unit-start-sheet__song {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px; border-radius: 16px; background: #F0FDF4;
    margin-bottom: 16px; color: #166534;
}
.unit-start-sheet__song[hidden] { display: none !important; }
.unit-start-sheet__song > i { font-size: 18px; margin-top: 2px; color: #1DB954; }
.unit-start-sheet__song strong { display: block; font-size: 14px; font-weight: 800; margin-bottom: 2px; }
.unit-start-sheet__song span { display: block; font-size: 12px; font-weight: 600; opacity: 0.85; }
.unit-start-sheet__actions {
    display: flex; gap: 10px; margin-bottom: 10px;
}
.unit-start-sheet__secondary {
    flex: 1; padding: 14px; border-radius: 100px; background: var(--kunkwan-red);
    color: #fff; font-size: 14px; font-weight: 800; text-decoration: none;
    text-align: center; box-sizing: border-box;
    box-shadow: 0 8px 20px rgba(211, 47, 47, 0.28);
}
.unit-start-sheet__primary {
    flex: 1.2; padding: 14px; border-radius: 100px; border: none;
    background: #D97706; color: #fff; font-size: 15px; font-weight: 800;
    cursor: pointer; box-shadow: 0 8px 20px rgba(217, 119, 6, 0.28);
}
.unit-start-sheet__primary:disabled { opacity: 0.7; cursor: wait; }
.unit-start-sheet__ghost {
    border: 0; background: transparent; color: #9CA3AF;
    font-size: 13px; font-weight: 700; padding: 8px; cursor: pointer;
}

/* 允许横向滑动的容器 */
.horizontal-scroll-area {
    width: 100%;
    overflow-x: auto;
    background: linear-gradient(to bottom, #F0F9FF 0%, #F3F4F6 100%); /* 淡淡的天空背景色 */
    padding-bottom: 20px;
    scrollbar-width: none; /* 隐藏滚动条 */
}
.horizontal-scroll-area::-webkit-scrollbar { display: none; }

/* 横向地图布局 */
.railway-map {
    display: flex;
    align-items: flex-end;
    position: relative;
    padding: 100px 40px 40px 40px; /* 留出天空放花草和火车的空间 */
    gap: 70px; /* 车站之间的距离 */
    width: max-content; /* 内容有多长，轨道就有多长 */
    min-width: 100%;
}

/* 绘制真实的横向铁轨 (金属边框 + 木头枕木) */
.railway-map::after {
    content: '';
    position: absolute;
    bottom: 56px; /* 刚好穿过站牌按钮的底部 */
    left: 20px;
    right: 20px; /* 精准在最前和最后一关停止，不再超标 */
    height: 18px;
    background-color: transparent;
    background-image: repeating-linear-gradient(to right, #9CA3AF 0, #9CA3AF 6px, transparent 6px, transparent 28px);
    border-top: 4px solid #4B5563;
    border-bottom: 4px solid #4B5563;
    z-index: 0;
}

/* 车站节点包装 */
.station-wrapper {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* 路线节点 (圆形站牌按钮) */
.path-node {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
    cursor: pointer;
    transition: transform 0.1s;
    text-decoration: none;
    z-index: 10;
}
.path-node.is-finale { width: 80px; height: 80px; font-size: 32px; }
button.path-node {
    padding: 0;
    font: inherit;
    appearance: none;
    -webkit-appearance: none;
}
.path-node:active { transform: translateY(4px); }
.node-active { background-color: var(--kunkwan-red); border-bottom: 6px solid #9E1010; box-shadow: 0 0 0 6px rgba(211, 47, 47, 0.2); }
.node-current {
    background-color: var(--kunkwan-red);
    border-bottom: 6px solid #9E1010;
    animation: unitPulse 1.8s ease-in-out infinite;
}
.node-done {
    background-color: #22c55e;
    border-bottom: 6px solid #15803d;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
    color: #fff;
    font-size: 24px;
}
.node-done.is-finale { font-size: 30px; }
.node-locked { background-color: #E5E5E5; color: #AFAFAF; border-bottom: 6px solid #CECECE; cursor: not-allowed; }
.node-emoji { font-size: 32px; line-height: 1; }
.path-node.is-finale .node-emoji { font-size: 36px; }

.station-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-gray);
    margin-top: 4px;
    max-width: 88px;
    text-align: center;
    line-height: 1.25;
}
.station-label.is-current { color: var(--kunkwan-red); }
.station-label.is-done { color: #15803d; }
.station-label.is-locked { color: #9CA3AF; font-weight: 700; }

/* 动态横向小火车 */
.train-avatar {
    position: absolute;
    width: 100px;
    bottom: 75px; /* 刚好稳稳坐在铁轨上 */
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    pointer-events: none;
    animation: train-chug 1s infinite alternate ease-in-out; /* 模拟开动的轻微摇晃 */
}
@keyframes train-chug {
    0% { transform: translateX(-50%) translateY(0) rotate(0deg); }
    100% { transform: translateX(-50%) translateY(-3px) rotate(-3deg); }
}

/* 环境装饰 (花草树木) */
.scenery { position: absolute; font-size: 24px; z-index: 1; pointer-events: none; }

/* --- 14. 迷你音频播放器 --- */
.mini-audio-player { display: none; background: var(--kunkwan-white); border-radius: 16px; padding: 16px; margin: 0 24px 16px 24px; border: 1px solid var(--border-light); box-shadow: 0 4px 10px rgba(0,0,0,0.05); align-items: center; gap: 12px; }
.play-pause-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--kunkwan-red); color: white; border: none; font-size: 16px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.audio-progress-container { flex: 1; height: 6px; background: var(--border-light); border-radius: 3px; position: relative; }
.audio-progress-bar { height: 100%; width: 0%; background: var(--kunkwan-red); border-radius: 3px; transition: width 0.1s linear; }

/* --- 15. 对话练习界面 --- */
.dialogue-top-bar { display: flex; justify-content: space-between; align-items: center; padding: calc(16px + env(safe-area-inset-top, 0px)) 24px 16px; font-weight: 700; color: var(--text-dark); }
.chat-bubble-container { padding: 20px 24px; display: flex; flex-direction: column; align-items: center; }
.chat-bubble { background: var(--kunkwan-white); border: 2px solid var(--border-light); border-radius: 16px; padding: 20px; width: 100%; position: relative; margin-bottom: 24px; text-align: center; }
.chat-bubble::after { content: ''; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); border-width: 10px 10px 0; border-style: solid; border-color: var(--kunkwan-white) transparent transparent transparent; }
.chat-bubble::before { content: ''; position: absolute; bottom: -13px; left: 50%; transform: translateX(-50%); border-width: 12px 12px 0; border-style: solid; border-color: var(--border-light) transparent transparent transparent; }
.chat-pinyin { font-size: 14px; color: var(--text-gray); margin-bottom: 8px; min-height: 20px;}
.chat-hanzi { font-size: 24px; font-weight: 700; color: var(--text-dark); }
.dialogue-mascot { width: 120px; height: auto; margin-bottom: 40px; }
.dialogue-mic-btn { width: 80px; height: 80px; background: #1CB0F6; border-radius: 20px; border: none; border-bottom: 6px solid #1899D6; color: white; font-size: 32px; display: flex; align-items: center; justify-content: center; margin: 0 auto; cursor: pointer; }
.dialogue-mic-btn:active, .dialogue-mic-btn.recording { transform: translateY(4px); border-bottom-width: 2px; background: var(--kunkwan-red); border-color: #9E1010; }

/* ========================================= */
/* --- 16. 高级 UI 样式 (Lovable Style) --- */
/* ========================================= */

/* 渐变红 Header */
.gradient-header {
    background: linear-gradient(135deg, #E52D27 0%, #B31217 100%);
    color: white;
    padding: 40px 24px 80px 24px; /* 底部留出空间给卡片重叠 */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gradient-header h1 { font-size: 28px; font-weight: 800; margin-bottom: 4px; color: white; }
.gradient-header p { font-size: 14px; opacity: 0.9; margin: 0; color: white; }
.gradient-header .mascot { width: 80px; height: auto; }

/* 向上重叠的内容区 */
.overlap-content {
    margin-top: -40px; /* 负边距让内容向上移 */
    padding: 0 24px 100px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    z-index: 10;
    position: relative;
}

/* 顶部三联 Stats 卡片 (XP, Streak, Goal) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.stat-box {
    background: white; border-radius: 20px; padding: 16px 8px;
    text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    display: flex; flex-direction: column; align-items: center;
}
.stat-box i { font-size: 24px; margin-bottom: 12px; }
.stat-box h3 { font-size: 20px; font-weight: 800; margin-bottom: 2px; }
.stat-box p { font-size: 11px; color: var(--text-gray); font-weight: 600; text-transform: uppercase; margin: 0;}

/* 进度条卡片 */
.progress-card {
    background: white; border-radius: 20px; padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.progress-card-header { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 12px;}
.progress-card-header .pct { color: var(--kunkwan-red); }

/* 站点列表卡片 */
.stations-card {
    background: white; border-radius: 20px; padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.station-item {
    display: flex; align-items: center; margin-bottom: 16px;
}
.station-item:last-child { margin-bottom: 0; }
.station-num {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 14px; margin-right: 16px;
}
.num-done { background: #10B981; }
.num-active { background: var(--kunkwan-red); }
.num-locked { background: #E5E7EB; color: #9CA3AF; }
.station-name { flex: 1; font-weight: 600; font-size: 15px; }
.station-cn { font-size: 13px; color: var(--text-gray); }

/* 表单输入框 */
.input-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-dark); margin-bottom: 8px; text-transform: uppercase;}
.input-field {
    width: 100%; padding: 16px; border-radius: 12px; border: 1px solid var(--border-light);
    font-size: 16px; margin-bottom: 20px; background: #F9FAFB; outline: none;
}
.input-field:focus { border-color: var(--kunkwan-red); background: white; }

/* 状态 Badge */
.status-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 100px; font-size: 12px; font-weight: 700; margin-bottom: 16px;
}
.badge-active { background: #ECFDF5; color: #10B981; border: 1px solid #A7F3D0; }
.badge-locked { background: #FEF2F2; color: var(--kunkwan-red); border: 1px solid #FECACA; }

/* 按钮变体 */
.btn-outline {
    width: 100%; padding: 16px; border-radius: 100px; border: 2px solid var(--border-light);
    background: white; color: var(--text-dark); font-weight: 700; font-size: 16px; cursor: pointer;
}
.btn-outline:active { background: #F9FAFB; }

/* ========================================= */
/* --- 17. Song Library & Chat UI & Achievements --- */
/* ========================================= */

/* Song Library 卡片样式 */
.song-play-card { background: white; border-radius: 20px; padding: 24px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.song-card-label { font-size: 12px; font-weight: 800; color: var(--kunkwan-red); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; display: block; }
.song-card-content { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.song-card-content img { width: 60px; height: 60px; border-radius: 12px; background: #F3F4F6; object-fit: contain; padding: 4px; }
.song-card-text h3 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.song-card-text p { font-size: 14px; color: var(--text-gray); margin: 0; }


/* 聊天室 Header */
.chat-header { 
    background: linear-gradient(135deg, #E52D27 0%, #B31217 100%); 
    color: white; 
    padding: calc(20px + env(safe-area-inset-top, 0px)) 24px 30px 24px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    /* 已经删除了这里的底边圆角，让它变成正正的长方形 */
    position: sticky; 
    top: 0; 
    z-index: 50; 
    /* 加入一点点阴影让它和下方的聊天记录有层次感 */
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.chat-header-info { display: flex; align-items: center; gap: 12px; }
.chat-header-info img { width: 44px; height: 44px; border-radius: 50%; background: white; padding: 2px; object-fit: cover; }
.chat-header-info h3 { font-size: 18px; font-weight: 700; margin: 0; color: white; }
.chat-header-info p { font-size: 12px; opacity: 0.9; margin: 0; color: white; }

/* --- 升级版聊天气泡排版 --- */
.chat-container { display: flex; flex-direction: column; padding: 24px; padding-bottom: 150px; overflow-y: auto; flex: 1; }

.chat-row { display: flex; align-items: flex-end; margin-bottom: 20px; gap: 10px; width: 100%; }
.chat-row.user-row { justify-content: flex-end; }

/* 更大、更明显的头像框 */
.chat-avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: white; box-shadow: 0 4px 8px rgba(0,0,0,0.1); border: 2px solid white; flex-shrink: 0; }

/* 气泡尾巴对着头像：左下角直角 / 右下角直角 */
.chat-bubble-app { background: white; border-radius: 24px 24px 24px 4px; padding: 16px 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.06); max-width: 75%; position: relative; }
.chat-bubble-user { background: linear-gradient(135deg, #E52D27, #B31217); color: white; border-radius: 24px 24px 4px 24px; padding: 16px 20px; box-shadow: 0 4px 12px rgba(211,47,47,0.25); max-width: 75%; }

.chat-pinyin { font-size: 13px; margin-bottom: 4px; opacity: 0.85; }
.chat-hanzi { font-size: 20px; font-weight: 700; }
.chat-hint { background: #FEF3C7; color: #92400E; padding: 10px 24px; border-radius: 100px; font-size: 13px; font-weight: 700; text-align: center; margin: 8px auto 24px auto; width: fit-content; }

/* 聊天重播小喇叭按钮 */
.replay-btn { color: var(--kunkwan-red); font-size: 16px; margin-top: 12px; cursor: pointer; opacity: 0.8; display: flex; gap: 8px; align-items: center;}
.replay-btn:active { opacity: 0.5; }

/* 聊天室底部麦克风区 */
.chat-bottom-bar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: linear-gradient(to top, white 80%, rgba(255,255,255,0)); padding: 40px 24px 24px 24px; display: flex; flex-direction: column; align-items: center; z-index: 100; }
.big-mic-btn { width: 72px; height: 72px; border-radius: 50%; background: var(--kunkwan-red); color: white; border: none; font-size: 28px; display: flex; justify-content: center; align-items: center; box-shadow: 0 8px 16px rgba(211,47,47,0.3); transition: transform 0.2s; cursor: pointer; margin-bottom: 8px; }
.big-mic-btn.recording { animation: pulse 1.5s infinite; }

/* --- 升级版成就徽章区 --- */
.achievements-card { background: white; border-radius: 20px; padding: 24px 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); margin-top: 24px; margin-bottom: 100px; }
.achievements-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.achievement-badge { background: #FEF2F2; border-radius: 16px; padding: 16px 8px; display: flex; flex-direction: column; align-items: center; text-align: center; border: 1px solid #FEE2E2; }
.achievement-badge i { font-size: 28px; color: var(--kunkwan-red); margin-bottom: 10px; }
.achievement-badge span { font-size: 12px; font-weight: 700; color: var(--kunkwan-red); line-height: 1.3; }

/* 弹窗通用样式 */
        .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 200; display: none; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity 0.3s ease; }
        .modal-content { width: 100%; max-width: 480px; background: white; border-top-left-radius: 24px; border-top-right-radius: 24px; padding: 24px; box-sizing: border-box; transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94); display: flex; flex-direction: column; }
        .modal-overlay.show { opacity: 1; }
        .modal-overlay.show .modal-content { transform: translateY(0); }

/* Keep the exercise-done sheet inside the phone frame */
.shell-player #done-sheet.modal-overlay {
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    max-width: none;
    border-radius: inherit;
    z-index: 220;
}
.shell-player #done-sheet .modal-content {
    left: auto !important;
    right: auto !important;
    transform: translateY(100%);
    max-width: 100% !important;
    width: 100% !important;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
.shell-player #done-sheet.show .modal-content {
    transform: translateY(0);
}

/* ========================================= */
/* 电脑端 (Desktop) 适配优化：网页/平板宽屏模式 */
/* ========================================= */
/* Desktop = mobile phone frame (same UX as sample) */
/* ========================================= */
@media (min-width: 481px) {
    body {
        background: #dfe3ea !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 28px 16px !important;
        min-height: 100dvh;
        height: auto !important;
        overflow: auto !important;
    }

    .app-container,
    .mobile-container {
        width: 100% !important;
        max-width: 430px !important;
        height: min(900px, calc(100dvh - 56px)) !important;
        max-height: calc(100dvh - 56px) !important;
        min-height: 0 !important;
        border-radius: 28px !important;
        overflow: hidden !important;
        box-shadow:
            0 0 0 1px rgba(17, 24, 39, 0.06),
            0 24px 60px rgba(17, 24, 39, 0.16) !important;
        margin: 0 auto !important;
    }

    /* Pin tabs to the phone frame, not the browser window */
    html:not(.is-standalone) .bottom-nav-container,
    html:not(.is-standalone) .bottom-nav-container.shell-nav,
    html:not(.is-standalone) .app-container .bottom-nav-container.shell-nav {
        position: absolute !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        transform: none !important;
    }

    .modal-content {
        max-width: 430px !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%);
        width: 100%;
    }

    /* Action sheet lives inside .app-container — do not viewport-center it
       (translateX(-50%) alone shifts the sheet half off-screen). */
    .app-container .action-menu-content,
    .mobile-container .action-menu-content {
        left: auto !important;
        right: auto !important;
        transform: none !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    html:not(.is-standalone) .bottom-nav {
        justify-content: space-between !important;
        gap: 0 !important;
        border-bottom-left-radius: 28px !important;
        border-bottom-right-radius: 28px !important;
    }

    .nav-center-wrapper {
        position: absolute !important;
        top: -24px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    .mini-player,
    .unit-header-card,
    .hub-card,
    .overlap-content > *,
    .stats-grid,
    .song-listview,
    .song-list,
    .section-header,
    .chat-bottom-bar,
    .library-header,
    .top-header,
    .hero-banner,
    .action-menu-content {
        max-width: 100% !important;
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .chat-container {
        max-width: 100% !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .horizontal-scroll-area {
        width: 100% !important;
        min-height: 260px;
        overflow-x: auto !important;
    }

    /* CRITICAL: do NOT force railway-map to 100% — that cuts the train track after ~Day 3 */
    .app-container .railway-map {
        width: max-content !important;
        max-width: none !important;
        min-width: max-content !important;
        justify-content: flex-start !important;
    }

    .mini-player {
        bottom: 85px !important;
        width: calc(100% - 24px) !important;
        left: 50% !important;
        transform: translateX(-50%);
    }

    /* Song library + My Library: clear nav + center FAB (do not use the global 85px pin) */
    .app-container.shell-songs .mini-player,
    .app-container.shell-library .mini-player {
        bottom: calc(118px + env(safe-area-inset-bottom, 0px)) !important;
        left: 16px !important;
        right: 16px !important;
        width: auto !important;
        max-width: none !important;
        transform: none !important;
    }

    /* Speak stage fills the phone frame */
    .stage-speaking.speak-phone {
        min-height: 0;
    }
}

/* Pointer devices: click wording instead of tap */
@media (hover: hover) and (pointer: fine) {
    .speak-phone .status-pill:not(.is-listen):not(.is-ok):not(.is-bad) #feedback-text::before {
        content: none;
    }
}

@media (min-width: 481px) {
    .speak-phone .hint-tiny {
        font-size: 12px;
    }
}

/* --- Speak.html stage (red theme) --- */
.speak-rules {
    display: flex;
    flex-direction: column;
    padding: 28px 24px 24px;
    flex: 1;
    overflow-y: auto;
    background: #fff;
}
.speak-rules__hero { text-align: center; margin-bottom: 28px; }
.speak-rules__icon {
    width: 72px; height: 72px; margin: 0 auto 18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(180deg, #ef5350, #c62828); color: #fff; font-size: 28px;
    box-shadow: 0 12px 28px rgba(211, 47, 47, 0.28);
}
.speak-rules h2 { color: #111827; font-size: 26px; font-weight: 800; margin-bottom: 10px; }
.speak-rules__lead { color: #9ca3af; font-size: 15px; font-weight: 600; line-height: 1.5; margin: 0 auto; max-width: 320px; }
.speak-rules__steps { list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 0 0 24px; padding: 0; }
.speak-rules__steps li {
    display: flex; align-items: center; gap: 14px; padding: 14px 16px;
    background: #fff; border: 1px solid #e8eaef; border-radius: 16px;
    font-size: 14px; font-weight: 700; color: #111827;
}
.speak-rules__steps li span {
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(211, 47, 47, 0.1); color: #d32f2f;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; flex-shrink: 0;
}

.speak-section-complete {
    display: none; flex-direction: column; padding: 40px 24px; flex: 1;
    justify-content: center; align-items: center; text-align: center; background: #fff;
}
.speak-section-complete__badge {
    width: 88px; height: 88px; border-radius: 50%;
    background: linear-gradient(145deg, #fbbf24, #f59e0b); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 36px;
    margin-bottom: 22px; box-shadow: 0 14px 30px rgba(245, 158, 11, 0.35);
}
.speak-section-complete h2 { color: #111827; font-size: 28px; font-weight: 800; margin-bottom: 10px; }
.speak-section-complete p { color: #9ca3af; font-size: 16px; margin-bottom: 36px; }

/* Top bar — Speak style */
.speak-top {
    display: flex; align-items: center; gap: 12px;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 10px; background: #fff; flex-shrink: 0;
}
.speak-top .icon-btn {
    width: 40px; height: 40px; border: 0; border-radius: 50%;
    background: transparent; color: #6b7280; cursor: pointer;
    display: grid; place-items: center; font-size: 18px; flex-shrink: 0;
}
.speak-top .icon-btn:active { background: #f3f4f6; }
.speak-progress {
    flex: 1; height: 6px; background: #eef0f4; border-radius: 99px; overflow: hidden;
}
.speak-progress > i,
.speak-progress #bar-fill {
    display: block; height: 100%; width: 8%;
    background: #d32f2f; border-radius: 99px;
    transition: width .35s ease;
}
.speak-skip {
    border: 0; background: transparent; color: #9ca3af;
    font-weight: 700; font-size: 14px; cursor: pointer; padding: 8px;
    font-family: Inter, system-ui, sans-serif;
}

/* Main speaking stage */
.stage-speaking.speak-phone {
    display: none;
    flex-direction: column;
    align-items: stretch;
    flex: 1;
    min-height: 0;
    width: 100%;
    background: #eef1f4;
    font-family: Inter, system-ui, sans-serif;
    padding: 8px 14px 0;
}
.speak-phone .speak-card {
    position: relative;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    align-self: stretch;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 28px;
    box-shadow: 0 12px 32px rgba(17, 24, 39, 0.08);
    padding: 22px 16px 18px;
    overflow-x: hidden;
    overflow-y: auto;
}
.shell-player.result-pass .speak-card {
    box-shadow: 0 16px 36px rgba(31, 169, 113, 0.22);
}
.speak-phone .speak-stage-main {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px 12px;
    text-align: center;
    min-height: min-content;
    width: 100%;
    box-sizing: border-box;
}
.speak-phone .prompt-label,
.speak-phone .sentence,
.speak-phone .meaning,
.speak-phone .hear-row,
.speak-phone .status-pill,
.speak-phone .restart-row {
    flex-shrink: 0;
}
.speak-phone .prompt-label {
    font-size: clamp(13px, 3.6vw, 15px); font-weight: 700; color: #9ca3af; margin: 0 0 18px;
}
.speak-phone .sentence {
    display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; align-content: center;
    gap: 12px 10px; max-width: 100%; width: 100%; min-height: 0; line-height: 1.15;
}
.speak-phone .word {
    display: inline-flex; flex-direction: column; align-items: center;
    color: #c5c9d2; transition: color .18s ease, transform .18s ease;
    max-width: 100%;
}
.speak-phone .word .py {
    font-size: var(--py-size, clamp(22px, 8vw, 34px)); font-weight: 800; letter-spacing: .01em; margin-bottom: 6px; opacity: 1; line-height: 1.2;
    overflow-wrap: anywhere; text-align: center;
}
.speak-phone .word .hz {
    font-size: var(--hz-size, clamp(15px, 4.6vw, 20px)); font-weight: 700; letter-spacing: .02em; opacity: .9; line-height: 1.2;
    overflow-wrap: anywhere; text-align: center;
}
.speak-phone .word.now { color: #d32f2f; transform: translateY(-1px); }
.speak-phone .word.ok { color: #22c55e; }
.speak-phone .word.bad { color: #ef4444; }
.speak-phone .word.is-blank .py,
.speak-phone .word.is-blank .hz {
    color: transparent;
    letter-spacing: 0;
}
.speak-phone .word.is-blank .py {
    background: #e6e8ee;
    border-radius: 12px;
    min-height: 0.95em;
    padding: 0.12em 0.42em;
    box-sizing: border-box;
}
.speak-phone .word.is-blank .hz {
    border-bottom: none;
    min-width: 0;
    color: transparent;
}
.speak-phone .word-wrap {
    display: inline-flex; align-items: flex-end; gap: 1px;
}
.speak-phone .punct-col {
    display: inline-flex; flex-direction: column; align-items: flex-start;
    justify-content: flex-end; line-height: 1.15;
}
.speak-phone .punct {
    font-weight: 700; color: #9ca3af;
}
.speak-phone .punct-py {
    font-size: var(--py-size, clamp(20px, 7vw, 28px)); font-weight: 800; margin-bottom: 4px; line-height: 1.2;
}
.speak-phone .punct-hz {
    font-size: var(--hz-size, clamp(14px, 4.2vw, 18px)); font-weight: 600; opacity: .85; line-height: 1.2;
}

.speak-phone .listen-btn {
    margin-top: 22px; width: 52px; height: 52px; border-radius: 50%; border: 0;
    background: #fdecea; color: #d32f2f; font-size: 18px; cursor: pointer;
    display: grid; place-items: center;
    box-shadow: 0 6px 16px rgba(211, 47, 47, .12);
    transition: transform .15s ease, background .15s;
}
.speak-phone .listen-btn:active { transform: scale(.94); background: #f8d7d5; }
.speak-phone .listen-btn.playing { animation: speak-listen-pulse 1s ease infinite; }

.speak-phone .meaning {
    margin-top: 16px; font-size: var(--meaning-size, clamp(14px, 4.4vw, 18px)); font-weight: 700; color: #1f2937;
    line-height: 1.45; width: 100%; max-width: 100%;
}
.speak-phone .hear-row {
    display: flex; align-items: center; justify-content: center;
    gap: 36px; margin-top: 22px; width: 100%;
}
.speak-phone .hear-btn {
    display: inline-flex; align-items: center; gap: 8px;
    border: 0; background: transparent; color: #d32f2f;
    font-size: 16px; font-weight: 800; cursor: pointer;
    font-family: Inter, system-ui, sans-serif; padding: 6px 4px;
}
.speak-phone .hear-btn i { font-size: 18px; }
.speak-phone .hear-btn:disabled { color: #d1d5db; cursor: default; }
.speak-phone .hear-btn.playing { opacity: .55; }
.speak-phone #you-btn { display: none !important; }
.speak-phone .restart-row {
    display: flex; align-items: center; justify-content: center;
    gap: 18px; width: 100%;
}
.speak-phone .restart-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 0; background: #f3f4f6; color: #111827;
    border-radius: 999px; padding: 12px 22px;
    font-size: 16px; font-weight: 800; cursor: pointer;
    font-family: Inter, system-ui, sans-serif;
    box-shadow: inset 0 0 0 1px #e5e7eb;
}
.speak-phone .restart-btn:active { transform: scale(.98); }
.speak-phone .restart-mascot {
    width: 54px; height: 54px; object-fit: contain; border-radius: 50%;
    background: #e8f1ff;
}
.speak-phone #praise-ico { display: none; font-size: 14px; }
.speak-phone .status-pill.is-ok {
    background: #1fa971; color: #fff; border-radius: 12px;
}
.speak-phone .status-pill.is-ok #praise-ico { display: inline-block; }
.speak-phone .status-pill.is-ok .wave { display: none !important; }
.shell-player .result-banner { display: none !important; }
.speak-phone .meaning[hidden] { display: none !important; }

/* Never show raw user speech wording — Speak.html paints target words only */
.speak-phone .heard-live,
#heard-live,
#heard-hz,
#heard-py,
#live-transcript {
    display: none !important;
}

/* Compact top result banner (speak.html) */
.result-banner {
    display: none;
    margin: 0 16px 4px;
    padding: 10px 12px;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid #e8eaef;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    animation: speak-banner-in .35s cubic-bezier(.22,1,.36,1);
}
.result-banner.show { display: flex; }
.result-banner.is-happy {
    background: linear-gradient(135deg, #ecfdf5, #f8fafc);
    border-color: #bbf7d0;
}
.result-banner.is-sad {
    background: linear-gradient(135deg, #fff5f5, #f8fafc);
    border-color: #fecaca;
}
@keyframes speak-banner-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.mascot-stage {
    position: relative;
    width: 58px; height: 58px;
    flex-shrink: 0;
}
.mascot-stage .ring { position: absolute; inset: 0; transform: rotate(-90deg); }
.mascot-stage .ring circle { fill: none; stroke-width: 5; }
.mascot-stage .ring-bg { stroke: #e5e7eb; }
.mascot-stage .ring-fg {
    stroke: #22c55e; stroke-linecap: round;
    stroke-dasharray: 157.08; stroke-dashoffset: 157.08;
    transition: stroke-dashoffset .8s cubic-bezier(.22,1,.36,1);
}
.result-banner.is-sad .ring-fg { stroke: #d32f2f; }
.mascot-img {
    position: absolute; left: 50%; top: 50%;
    width: 40px; height: 40px; object-fit: contain;
    transform: translate(-50%, -50%);
    filter: drop-shadow(0 4px 8px rgba(0,0,0,.1));
}
.result-banner.show.is-happy .mascot-img {
    animation: speak-happy-bounce 1.5s ease-in-out infinite;
}
.result-banner.show.is-sad .mascot-img {
    animation: speak-sad-sway 2s ease-in-out infinite;
}
@keyframes speak-happy-bounce {
    0%, 100% { transform: translate(-50%, -50%); }
    50% { transform: translate(-50%, -56%); }
}
@keyframes speak-sad-sway {
    0%, 100% { transform: translate(-50%, -50%) rotate(-4deg); }
    50% { transform: translate(-50%, -48%) rotate(4deg); }
}
.result-meta { flex: 1; min-width: 0; text-align: left; }
.result-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 2px;
}
.result-banner .check {
    width: 22px; height: 22px; border-radius: 50%;
    display: grid; place-items: center; font-size: 11px; color: #fff; flex-shrink: 0;
}
.result-banner.is-happy .check { background: #22c55e; }
.result-banner.is-sad .check { background: #d32f2f; }
.result-pct { font-size: 22px; font-weight: 800; line-height: 1; }
.result-banner.is-happy .result-pct { color: #22c55e; }
.result-banner.is-sad .result-pct { color: #d32f2f; }
.result-title {
    font-size: 13px; font-weight: 800; color: #111827;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.result-retry { display: none !important; }
.shell-player.has-result .speak-stage-main {
    justify-content: flex-start;
    padding-top: 12px;
}
@media (prefers-reduced-motion: reduce) {
    .result-banner.show.is-happy .mascot-img,
    .result-banner.show.is-sad .mascot-img,
    .speak-wait__spin { animation: none; }
}

/* Short phones: keep pinyin, characters, and English on separate rows. */
@media (max-height: 740px) {
    .speak-phone.stage-speaking { padding-top: 4px; }
    .speak-phone .speak-card { padding: 14px 12px 10px; border-radius: 22px; }
    .speak-phone .speak-stage-main { padding: 4px 6px 8px; }
    .speak-phone .prompt-label { margin-bottom: 10px; }
    .speak-phone .status-pill.is-listen { margin-bottom: 12px; min-height: 34px; }
    .speak-phone .hear-row { margin-top: 12px; gap: 28px; }
    .speak-phone .restart-mascot { width: 44px; height: 44px; }
    .speak-phone .restart-btn { padding: 10px 18px; font-size: 15px; }
    .speak-phone .transport-btn { width: 56px; height: 56px; font-size: 20px; }
    .speak-phone .speak-transport { gap: 20px; margin: 0; }
    .speak-phone .dock { gap: 8px; padding: 4px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-height: 620px) {
    .speak-phone .transport-btn { width: 48px; height: 48px; font-size: 18px; }
    .speak-phone .speak-card { padding: 10px 10px 8px; }
    .speak-phone .meaning { margin-top: 10px; }
}

/* Practice stays upright. Landscape phones see a turn-around gate. */
.portrait-lock {
    display: none;
}
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
    .portrait-lock {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 10000;
        background: #fff;
        color: #111827;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 16px;
        text-align: center;
        padding: 24px;
        font-family: Inter, system-ui, sans-serif;
    }
    .portrait-lock i {
        font-size: 42px;
        color: #d32f2f;
    }
    .portrait-lock p {
        margin: 0;
        max-width: 260px;
        font-size: 18px;
        font-weight: 800;
        line-height: 1.4;
    }
}

.speak-phone .dock {
    padding: 8px 24px calc(22px + env(safe-area-inset-bottom, 0px));
    display: flex; flex-direction: column; align-items: center; gap: 14px; flex-shrink: 0;
}
.speak-phone .status-pill {
    min-height: 36px; padding: 8px 16px; border-radius: 999px;
    background: #f3f4f6; color: #6b7280; font-size: 14px; font-weight: 700;
    display: inline-flex; align-items: center; gap: 8px;
    border: 0; font-family: inherit; cursor: pointer;
}
.speak-phone .status-pill.is-listen {
    background: #d32f2f; color: #fff; border-radius: 10px;
    min-width: 132px; min-height: 40px; padding: 8px 16px;
    justify-content: center; margin-bottom: 22px;
    font-size: 15px; font-weight: 700; letter-spacing: 0;
}
.speak-phone .status-pill.is-ok { background: #ecfdf5; color: #059669; }
.speak-phone .status-pill.is-bad { background: #fef2f2; color: #dc2626; }
.speak-phone .wave {
    display: none; align-items: flex-end; gap: 3px; height: 14px;
}
.speak-phone .status-pill.is-listen .wave { display: none; }
.speak-phone .wave i {
    width: 3px; border-radius: 99px; background: #fff;
    animation: speak-wave-bar 0.9s ease-in-out infinite;
}
.speak-phone .wave i:nth-child(1) { height: 5px; animation-delay: 0s; }
.speak-phone .wave i:nth-child(2) { height: 12px; animation-delay: .12s; }
.speak-phone .wave i:nth-child(3) { height: 7px; animation-delay: .24s; }
.speak-phone .wave i:nth-child(4) { height: 14px; animation-delay: .08s; }
.speak-phone .wave i:nth-child(5) { height: 6px; animation-delay: .2s; }
.speak-wait {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.94);
    color: #111827;
    font-size: 16px;
    font-weight: 800;
}
.speak-wait[hidden] { display: none; }
.speak-wait__spin {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid #e5e7eb;
    border-top-color: #d32f2f;
    animation: speak-wait-spin 0.7s linear infinite;
}
@keyframes speak-wait-spin { to { transform: rotate(360deg); } }

.speak-phone .mic-wrap {
    position: relative; width: 92px; height: 92px; display: grid; place-items: center;
}
.speak-phone .mic-ring {
    position: absolute; inset: 0; border-radius: 50%;
    border: 2px solid rgba(211, 47, 47, .18); opacity: 0;
}
.speak-phone .mic {
    width: 76px; height: 76px; border-radius: 50%; border: 0;
    background: linear-gradient(180deg, #ef5350, #b71c1c);
    color: #fff; font-size: 28px; cursor: default;
    pointer-events: none;
    display: inline-flex; align-items: center; justify-content: center;
    box-shadow: 0 12px 28px rgba(211, 47, 47, .35);
    z-index: 1; padding: 0; line-height: 1;
}
.speak-phone .mic-wrap.rec .mic {
    background: #111827; box-shadow: 0 12px 28px rgba(17, 24, 39, .28);
}
.speak-phone .mic-wrap.rec .mic-ring { opacity: 1; animation: speak-ring-out 1.4s ease-out infinite; }
.speak-phone .mic-wrap.rec .mic-ring.r2 { animation-delay: .45s; }

.speak-phone .hint-tiny { font-size: 12px; font-weight: 600; color: #b0b5bf; margin: 0; }
.speak-phone .speak-transport {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
    width: 100%;
    margin: 4px 0 8px;
}
.speak-phone .transport-btn {
    width: 68px;
    height: 68px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #111827;
    box-shadow: 0 8px 22px rgba(17, 24, 39, 0.1);
    display: grid;
    place-items: center;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.speak-phone .transport-btn:active { transform: scale(0.96); }
.speak-phone .transport-btn:disabled {
    opacity: 0.28;
    cursor: default;
    box-shadow: none;
}
.speak-phone .transport-btn.is-pause {
    color: #d32f2f;
    font-size: 24px;
}
.speak-phone .transport-btn.is-play {
    color: #9ca3af;
    font-size: 24px;
}
.speak-phone .continue-btn {
    display: flex; border: 0; border-radius: 0; padding: 12px 16px;
    font-weight: 800; font-size: 13px; cursor: pointer; color: #9ca3af;
    background: transparent; box-shadow: none;
    letter-spacing: 0.14em; text-transform: uppercase;
    font-family: Inter, system-ui, sans-serif;
    width: 100%; justify-content: center; align-items: center;
}
.speak-phone .fail-actions {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}
.speak-phone .fail-retry {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 180px;
    border: 0;
    border-radius: 999px;
    padding: 14px 22px;
    background: #fff;
    color: #2563eb;
    font-size: 16px;
    font-weight: 800;
    box-shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
    cursor: pointer;
    font-family: Inter, system-ui, sans-serif;
}
.speak-phone .fail-skip {
    border: 0;
    background: transparent;
    color: #9ca3af;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 10px 16px;
    cursor: pointer;
    font-family: Inter, system-ui, sans-serif;
}
.speak-phone .mic-wrap,
.speak-phone .hint-tiny,
.speak-phone .fail-actions,
.speak-skip {
    display: none !important;
}
.shell-player.result-pass .speak-phone .status-pill,
.shell-player.result-fail .speak-phone .status-pill {
    display: inline-flex !important;
}

.speak-live-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

@keyframes speak-wave-bar {
    0%, 100% { transform: scaleY(.55); }
    50% { transform: scaleY(1); }
}
@keyframes speak-ring-out {
    0% { transform: scale(.85); opacity: .7; }
    100% { transform: scale(1.45); opacity: 0; }
}
@keyframes speak-listen-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(211,47,47,.25); }
    50% { box-shadow: 0 0 0 10px rgba(211,47,47,0); }
}

.speak-tip .modal-content {
    text-align: center; padding: 36px 24px;
    border-top-left-radius: 32px; border-top-right-radius: 32px;
}
.speak-tip__icon {
    width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 50%;
    background: rgba(211, 47, 47, 0.1); color: #d32f2f;
    display: flex; align-items: center; justify-content: center; font-size: 26px;
}
