/* ============ 基础重置 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #4F46E5;
    --primary-light: #818CF8;
    --primary-dark: #3730A3;
    --accent: #06B6D4;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --bg: #F8FAFC;
    --card: #FFFFFF;
    --text: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --radius: 16px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.04), 0 10px 24px rgba(0,0,0,0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.6;
}

#app {
    max-width: 640px;
    margin: 0 auto;
    padding-bottom: 40px;
}

.hidden { display: none !important; }

.section { animation: fadeIn 0.35s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============ 首页 Hero ============ */
.hero {
    position: relative;
    border-radius: 0 0 32px 32px;
    overflow: hidden;
    margin-bottom: 24px;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 50%, #06B6D4 100%);
}

.hero-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(255,255,255,0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255,255,255,0.1) 0%, transparent 50%);
}

.hero-content {
    position: relative;
    padding: 48px 24px 40px;
    text-align: center;
    color: #fff;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -1px;
}

.logo-text {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.hero h1 {
    font-size: 20px;
    font-weight: 600;
    opacity: 0.95;
    margin-bottom: 8px;
}

.hero-subtitle {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.hero-desc {
    font-size: 14px;
    opacity: 0.75;
}

/* ============ 通用组件 ============ */
.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    margin: 0 20px 14px;
}

.title-icon {
    font-size: 20px;
}

/* ============ 使用步骤 ============ */
.browser-tip {
    margin: 0 16px 16px;
    background: linear-gradient(135deg, #EEF2FF, #E0E7FF);
    border: 1px solid #C7D2FE;
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.browser-tip-icon {
    font-size: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.browser-tip-content strong {
    font-size: 15px;
    color: #312E81;
}

.browser-tip-content p {
    font-size: 13px;
    color: #4338CA;
    margin-top: 4px;
    line-height: 1.5;
}

.browser-tip-content .browser-tip-sub {
    color: #6366F1;
    font-size: 12px;
    margin-top: 6px;
}

.steps-card {
    margin: 0 16px 24px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.steps-card .section-title {
    margin: 0 0 16px;
}

.steps {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.step {
    display: flex;
    align-items: center;
    gap: 14px;
}

.step-num {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
}

.step-info { flex: 1; }

.step-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.step-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============ 分类卡片 ============ */
.category-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 0 16px 24px;
}

.cat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.cat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.cat-card.topic::before { background: linear-gradient(90deg, #4F46E5, #818CF8); }
.cat-card.reading::before { background: linear-gradient(90deg, #06B6D4, #10B981); }

.cat-card:hover, .cat-card:active {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.cat-card-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 12px;
}

.cat-card.topic .cat-card-icon { background: #EEF2FF; }
.cat-card.reading .cat-card-icon { background: #ECFDF5; }

.cat-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.cat-card-count {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============ 评分说明 ============ */
.info-card {
    margin: 0 16px 24px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.info-card .section-title {
    margin: 0 0 16px;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.info-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.info-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
}

.accuracy-icon { background: linear-gradient(135deg, #4F46E5, #818CF8); }
.completeness-icon { background: linear-gradient(135deg, #06B6D4, #22D3EE); }
.fluency-icon { background: linear-gradient(135deg, #10B981, #34D399); }

.info-body { flex: 1; }

.info-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-weight {
    font-size: 11px;
    font-weight: 700;
    background: #F1F5F9;
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
}

.info-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 3px;
    line-height: 1.5;
}

/* ============ 首页底部 ============ */
.home-footer {
    margin: 0 16px;
}

.footer-tips {
    background: #FFFBEB;
    border: 1px solid #FEF3C7;
    border-radius: var(--radius);
    padding: 16px 20px;
}

.footer-tips p {
    font-size: 14px;
    margin-bottom: 8px;
    color: #92400E;
}

.footer-tips ul {
    list-style: none;
    font-size: 13px;
    color: #A16207;
    line-height: 1.8;
}

.footer-tips li::before {
    content: "\2022";
    color: #D97706;
    margin-right: 8px;
}

/* ============ 导航栏 ============ */
.top-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    font-size: 15px;
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
    padding: 6px 0;
}

.back-arrow { font-size: 18px; }

.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.btn-nav {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    color: var(--primary);
    cursor: pointer;
    white-space: nowrap;
}

.btn-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-nav:not(:disabled):hover {
    background: var(--primary);
    color: #fff;
}

.practice-badge {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    background: #F1F5F9;
    padding: 5px 14px;
    border-radius: 20px;
}

/* ============ 音频列表页头部 ============ */
.list-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 20px;
    background: var(--card);
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.list-header-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.list-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.list-header-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ============ 音频列表 ============ */
.audio-list {
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.audio-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform 0.15s, box-shadow 0.15s;
    border: 1.5px solid transparent;
}

.audio-item:hover, .audio-item:active {
    transform: translateX(4px);
    border-color: var(--primary-light);
    box-shadow: var(--shadow-lg);
}

.audio-item-num {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.audio-item-name {
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
}

.audio-item-arrow {
    color: var(--text-muted);
    font-size: 18px;
}

/* ============ 练习流程指示器 ============ */
.flow-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 20px 16px 12px;
}

.flow-step {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.3s;
}

.flow-step.active { color: var(--primary); }
.flow-step.done { color: var(--success); }

.flow-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: background 0.3s;
}

.flow-step.active .flow-dot { background: var(--primary); }
.flow-step.done .flow-dot { background: var(--success); }

.flow-line {
    width: 32px;
    height: 2px;
    background: var(--border);
    margin: 0 8px;
}

/* ============ 练习卡片 ============ */
.practice-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin: 0 16px 12px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.card-tag {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.card-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.ref-text {
    font-size: 15px;
    line-height: 2;
    color: #374151;
    max-height: 240px;
    overflow-y: auto;
    padding: 12px 16px;
    background: #F8FAFC;
    border-radius: 10px;
    border: 1px solid #E2E8F0;
    white-space: pre-line;
}

/* 翻译切换开关 */
.translation-toggle {
    margin: 12px 0 0;
    display: flex;
    align-items: center;
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    user-select: none;
}

.toggle-label input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 40px;
    height: 22px;
    background: #CBD5E1;
    border-radius: 11px;
    transition: background 0.3s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-label input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle-label input:checked + .toggle-slider::after {
    transform: translateX(18px);
}

/* 中文翻译 */
.ref-translation {
    font-size: 14px;
    line-height: 1.9;
    color: #6B7280;
    padding: 12px 16px;
    background: #FFFBEB;
    border-radius: 10px;
    border: 1px solid #FEF3C7;
    margin-top: 10px;
    white-space: pre-line;
}

.ref-translation.hidden {
    display: none;
}

.practice-card audio {
    width: 100%;
    height: 44px;
    border-radius: 8px;
}

/* ============ 录音 ============ */
.record-card {
    border: 2px dashed var(--border);
    box-shadow: none;
    transition: border-color 0.3s;
}

.record-card.is-recording {
    border-color: var(--danger);
    background: #FFF5F5;
}

.record-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
}

.audio-loading-tip {
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: #EA580C;
    background: #FFF7ED;
    border: 2px solid #FB923C;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 12px;
    animation: pulse-loading 1.5s ease-in-out infinite;
}

.audio-loading-tip.loaded {
    color: #16A34A;
    background: #F0FDF4;
    border-color: #4ADE80;
    font-size: 14px;
    animation: none;
}

@keyframes pulse-loading {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.audio-loading-tip.hidden {
    display: none;
}

.record-browser-tip {
    text-align: center;
    font-size: 11px;
    color: #9CA3AF;
    margin-top: 8px;
    line-height: 1.5;
}

.file-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 0;
}

.btn-upload {
    cursor: pointer;
}

.upload-tip {
    margin-top: 12px;
    font-size: 13px;
    color: #6B7280;
    text-align: center;
    line-height: 1.6;
}

.btn-record {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 14px 36px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-record:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.btn-record.recording {
    background: linear-gradient(135deg, #EF4444, #F87171);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50%      { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); }
}

.record-icon {
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    display: inline-block;
    transition: border-radius 0.2s;
}

.btn-record.recording .record-icon {
    border-radius: 3px;
    width: 14px;
    height: 14px;
}

.timer {
    font-size: 28px;
    font-weight: 700;
    color: var(--danger);
    font-variant-numeric: tabular-nums;
    margin-top: 12px;
    letter-spacing: 2px;
}

/* ============ 提交评分 ============ */
.btn-score {
    display: block;
    width: calc(100% - 32px);
    margin: 8px 16px 16px;
    background: linear-gradient(135deg, var(--success), #34D399);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 16px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
    transition: transform 0.2s;
}

.btn-score:hover { transform: translateY(-1px); }

.btn-score:disabled {
    background: #CBD5E1;
    box-shadow: none;
    cursor: not-allowed;
}

/* ============ 评分结果 - 总分 ============ */
.result-hero {
    position: relative;
    border-radius: 0 0 28px 28px;
    overflow: hidden;
    margin-bottom: 16px;
}

.result-hero-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #4F46E5, #7C3AED, #06B6D4);
}

.result-hero-content {
    position: relative;
    padding: 32px 24px;
    text-align: center;
    color: #fff;
}

.result-label {
    font-size: 14px;
    opacity: 0.8;
    margin-bottom: 16px;
    font-weight: 500;
}

.score-ring {
    position: relative;
    width: 140px;
    height: 140px;
    margin: 0 auto 16px;
}

.score-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: rgba(255,255,255,0.15);
    stroke-width: 8;
}

.ring-fill {
    fill: none;
    stroke: #fff;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 326.73;
    stroke-dashoffset: 326.73;
    transition: stroke-dashoffset 1.2s ease;
}

.ring-score {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 44px;
    font-weight: 800;
}

.result-comment {
    font-size: 16px;
    font-weight: 600;
    opacity: 0.9;
}

/* ============ 分项得分条 ============ */
.sub-scores-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    margin: 0 16px 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sub-score-item { }

.sub-score-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.sub-score-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.sub-score-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}

.sub-score-bar {
    width: 100%;
    height: 8px;
    background: #F1F5F9;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease;
}

.accuracy-bar { background: linear-gradient(90deg, #4F46E5, #818CF8); }
.completeness-bar { background: linear-gradient(90deg, #06B6D4, #22D3EE); }
.fluency-bar { background: linear-gradient(90deg, #10B981, #34D399); }

/* ============ 单词对比 ============ */
.word-details {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 14px;
    line-height: 2.2;
}

.word-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: transform 0.15s;
}

.word-tag:hover { transform: scale(1.05); }

.word-tag.correct { background: #ECFDF5; color: #065F46; }
.word-tag.partial { background: #FFFBEB; color: #92400E; }
.word-tag.wrong   { background: #FEF2F2; color: #991B1B; text-decoration: line-through; }
.word-tag.missed  { background: #F1F5F9; color: #94A3B8; text-decoration: line-through; font-style: italic; }
.word-tag.extra   { background: #EEF2FF; color: #4338CA; font-style: italic; }

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: 12px;
    color: var(--text-muted);
}

.legend-item { display: flex; align-items: center; gap: 5px; }

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot.correct { background: #10B981; }
.dot.partial { background: #F59E0B; }
.dot.wrong   { background: #EF4444; }
.dot.missed  { background: #CBD5E1; }

/* ============ 再来一次 ============ */
.btn-retry {
    display: block;
    width: calc(100% - 32px);
    margin: 8px 16px 24px;
    background: var(--card);
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 14px;
    padding: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-retry:hover {
    background: #EEF2FF;
}

/* ============ 加载遮罩 ============ */
.loading {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-card {
    background: var(--card);
    border-radius: 20px;
    padding: 40px 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    min-width: 260px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #E2E8F0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.loading-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* ============ 响应式 ============ */
@media (max-width: 420px) {
    .hero-content { padding: 36px 20px 32px; }
    .hero h1 { font-size: 18px; }
    .logo-text { font-size: 20px; }
    .category-cards { gap: 10px; }
    .cat-card { padding: 20px 12px; }
    .cat-card-icon { width: 48px; height: 48px; font-size: 24px; }
    .practice-card { margin: 0 12px 10px; padding: 14px 16px; }
    .sub-scores-card { margin: 0 12px 10px; }
}

@media (min-width: 641px) {
    .hero { border-radius: 0 0 32px 32px; margin: 0 -16px 24px; }
    #app { padding: 0 16px 40px; }
}
