﻿:root {
    --font-en: 'Inter', system-ui, sans-serif;
    --font-cn: 'Noto Sans SC', system-ui, sans-serif;
    --primary-gradient: linear-gradient(135deg, #4f46e5, #0ea5e9);
    --bg-app: #f1f5f9;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #0284c7;
    --success-color: #16a34a;
    --danger-color: #dc2626;
    --border-radius: 24px;
    --shadow-lg: 0 10px 40px -10px rgba(0, 0, 0, 0.1);
    --shadow-card: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --header-height: 60px;
    --bottom-nav-height: 80px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    overscroll-behavior: none;
}

body {
    font-family: var(--font-en);
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
}

/* ==================== Header ==================== */
.app-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    background: rgba(241, 245, 249, 0.85);
    backdrop-filter: blur(12px);
    z-index: 10;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.progress-badge {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.05);
    padding: 6px 12px;
    border-radius: 12px;
}

/* ==================== Top Bar: batch select + mode switch ==================== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 6px 24px;
    flex-shrink: 0;
}

.batch-select {
    padding: 10px 32px 10px 16px;
    border: none;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.04);
    font-family: var(--font-cn);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

/* Mode Switch */
.mode-switch {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.mode-btn {
    flex: 1;
    max-width: 160px;
    padding: 10px 20px;
    border: none;
    border-radius: 14px;
    font-family: var(--font-cn);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-secondary);
    transition: all 0.25s ease;
}

.mode-btn.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.mode-btn:active {
    transform: scale(0.96);
}

/* ==================== Progress Bar ==================== */
.progress-bar-container {
    height: 4px;
    background: rgba(0, 0, 0, 0.05);
    width: 100%;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary-gradient);
    transition: width 0.3s ease;
}

/* ==================== Mode Content ==================== */
.mode-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

/* ==================== Study Mode — Card Stage ==================== */
.card-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
    padding: 24px;
    overflow: hidden;
    gap: 20px;
}

.card-wrapper {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 3/4;
    position: relative;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* 3D Card Flip */
.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.35s ease;
    cursor: pointer;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 32px;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.card-back {
    transform: rotateY(180deg);
    background: linear-gradient(160deg, #ffffff, #f0f9ff);
}

/* Card Content: Front */
.word-display {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: var(--text-primary);
    line-height: 1.1;
}

.phonetic-display {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-family: 'Times New Roman', serif;
    margin-bottom: 40px;
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 8px;
}

.speak-btn {
    background: rgba(224, 242, 254, 0.5);
    border: none;
    color: var(--accent-color);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-bottom: 40px;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
}

.speak-btn:active {
    transform: scale(0.92);
    background: rgba(224, 242, 254, 0.8);
}

/* Learned Badge */
.learned-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #dcfce7;
    color: var(--success-color);
    font-family: var(--font-cn);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid #bbf7d0;
}

/* Card Content: Back */
.meaning-label,
.example-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #94a3b8;
    margin-bottom: 8px;
    font-weight: 700;
}

.meaning-display {
    font-family: var(--font-cn);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 32px;
    color: var(--text-primary);
}

.example-display {
    font-size: 1.5rem;
    line-height: 1.6;
    color: #334155;
    margin-bottom: 12px;
}

.example-cn {
    font-family: var(--font-cn);
    font-size: 1.2rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tap-hint {
    position: absolute;
    bottom: 24px;
    font-size: 0.8rem;
    color: #cbd5e1;
    font-family: var(--font-cn);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* ==================== Study Actions ==================== */
.study-actions {
    display: flex;
    justify-content: center;
}

.learn-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 28px;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    background: transparent;
    font-family: var(--font-cn);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.25s ease;
}

.learn-toggle-btn:active {
    transform: scale(0.96);
}

.learn-toggle-btn.is-learned {
    border-color: var(--success-color);
    background: #f0fdf4;
    color: var(--success-color);
}

.learn-toggle-btn.is-learned .learn-icon {
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    70% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* ==================== Study — Bottom Controls (two buttons) ==================== */
.controls {
    height: var(--bottom-nav-height);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 24px 24px;
    gap: 32px;
}

.ctrl-btn {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    border: none;
    background: #ffffff;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.ctrl-btn:active {
    background: #f1f5f9;
    transform: scale(0.92);
}

/* ==================== Study — Slide Animations ==================== */
.slide-out-left {
    animation: slideOutLeft 0.18s ease-in forwards;
}

.slide-out-right {
    animation: slideOutRight 0.18s ease-in forwards;
}

.slide-in-left {
    animation: slideInLeft 0.22s ease-out forwards;
}

.slide-in-right {
    animation: slideInRight 0.22s ease-out forwards;
}

@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(-100%); opacity: 0; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100%); opacity: 0; }
}

@keyframes slideInLeft {
    from { transform: translateX(-24px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(24px); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ==================== Phase Banner ==================== */
.phase-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 10px 24px;
    background: var(--bg-app);
    flex-shrink: 0;
}

.phase-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e2e8f0;
    transition: all 0.4s ease;
}

.phase-dot.active {
    background: var(--primary-gradient);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.phase-dot.done {
    background: var(--success-color);
}

.phase-line {
    width: 28px;
    height: 2px;
    background: #e2e8f0;
    margin: 0 4px;
    transition: background 0.4s ease;
}

.phase-line.done {
    background: var(--success-color);
}

.phase-label {
    margin-left: 12px;
    font-family: var(--font-cn);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ==================== Dictation Stage ==================== */
.dictation-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 24px;
    overflow-y: auto;
    gap: 16px;
}

/* Dictation Card (shared by phase 1 & 2) */
.dictation-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
    animation: fadeInUp 0.35s ease;
}

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

/* ═══════════ Phase 1: Dictating ═══════════ */
.dictation-progress {
    font-family: var(--font-cn);
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
    background: #f1f5f9;
    padding: 6px 20px;
    border-radius: 12px;
}

.dictation-question {
    background: #f8fafc;
    border-radius: 16px;
    padding: 28px 24px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.dictation-meaning {
    font-family: var(--font-cn);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

.dictation-example {
    font-family: var(--font-cn);
    font-size: 1.05rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.dictation-speak-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border: none;
    border-radius: 12px;
    background: rgba(224, 242, 254, 0.6);
    color: var(--accent-color);
    font-family: var(--font-cn);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.dictation-speak-btn:active {
    transform: scale(0.95);
    background: rgba(224, 242, 254, 0.9);
}

.dictation-hint {
    font-family: var(--font-cn);
    font-size: 0.85rem;
    color: #94a3b8;
}

.next-word-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: var(--primary-gradient);
    color: white;
    font-family: var(--font-cn);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
    transition: all 0.25s;
}

.next-word-btn:active {
    transform: scale(0.97);
}

/* ═══════════ Phase 2: Correcting ═══════════ */
.dictation-answer-block {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.answer-word {
    font-size: 2.5rem;
    font-weight: 800;
    color: #166534;
    line-height: 1.2;
}

.answer-phonetic {
    font-size: 1.1rem;
    font-family: 'Times New Roman', serif;
    color: #4ade80;
}

.answer-meaning {
    font-family: var(--font-cn);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.answer-example {
    font-size: 1.2rem;
    color: #334155;
    margin-top: 4px;
}

.answer-example-cn {
    font-family: var(--font-cn);
    font-size: 1.05rem;
    color: var(--text-secondary);
}

.correcting-hint {
    font-family: var(--font-cn);
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Correct / Wrong Buttons */
.dictation-result {
    display: flex;
    gap: 16px;
    width: 100%;
}

.correct-btn,
.wrong-btn {
    flex: 1;
    padding: 14px 12px;
    border: none;
    border-radius: 14px;
    font-family: var(--font-cn);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.correct-btn {
    background: #dcfce7;
    color: var(--success-color);
    border: 1px solid #bbf7d0;
}

.correct-btn:active {
    background: #bbf7d0;
    transform: scale(0.96);
}

.wrong-btn {
    background: #fef2f2;
    color: var(--danger-color);
    border: 1px solid #fecaca;
}

.wrong-btn:active {
    background: #fecaca;
    transform: scale(0.96);
}

/* ==================== Phase 3: Summary + Wrong Review ==================== */
.dictation-summary {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-card);
    padding: 36px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: fadeInUp 0.4s ease;
}

.summary-icon {
    font-size: 3rem;
}

.summary-title {
    font-family: var(--font-cn);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
}

.summary-divider {
    width: 48px;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

.summary-stats {
    display: flex;
    gap: 24px;
    width: 100%;
    justify-content: center;
    padding: 12px 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-primary);
}

.stat-label {
    font-family: var(--font-cn);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-correct .stat-value { color: var(--success-color); }
.stat-wrong .stat-value { color: var(--danger-color); }

/* ═══════════ Wrong Word Review Cards ═══════════ */
.wrong-review {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wrong-review-title {
    font-family: var(--font-cn);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--danger-color);
    text-align: center;
    letter-spacing: 2px;
}

.wrong-review-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wrong-review-card {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
    animation: fadeInUp 0.3s ease;
}

.wrong-review-word {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--danger-color);
    line-height: 1.2;
}

.wrong-review-phonetic {
    font-size: 0.95rem;
    font-family: 'Times New Roman', serif;
    color: #f87171;
}

.wrong-review-meaning {
    font-family: var(--font-cn);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 2px;
}

.wrong-review-example {
    font-size: 1.05rem;
    color: #334155;
}

.wrong-review-example-cn {
    font-family: var(--font-cn);
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.wrong-review-speak {
    margin-top: 6px;
    padding: 6px 16px;
    border: none;
    border-radius: 10px;
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger-color);
    font-family: var(--font-cn);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.wrong-review-speak:active {
    background: rgba(220, 38, 38, 0.15);
    transform: scale(0.96);
}

.wrong-review-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.wrong-review-view {
    padding: 6px 16px;
    border: none;
    border-radius: 10px;
    background: var(--primary-gradient);
    color: white;
    font-family: var(--font-cn);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.wrong-review-view:active {
    transform: scale(0.96);
}

/* ==================== Summary Actions ==================== */
.summary-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 8px;
}

.summary-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    font-family: var(--font-cn);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s;
}

.summary-btn:active {
    transform: scale(0.97);
}

.summary-btn.primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.summary-btn.secondary {
    background: #f1f5f9;
    color: var(--text-primary);
}

.summary-btn.secondary:active {
    background: #e2e8f0;
}

/* ==================== Dictation Empty State ==================== */
.dictation-empty {
    width: 100%;
    max-width: 340px;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 48px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.empty-icon {
    font-size: 3.5rem;
}

.empty-title {
    font-family: var(--font-cn);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.empty-desc {
    font-family: var(--font-cn);
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ==================== Dictation Source Selector ==================== */
.dictation-source {
    flex-shrink: 0;
    padding: 16px 24px;
}

.source-title {
    font-family: var(--font-cn);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    text-align: center;
}

.source-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
    margin: 0 auto;
}

.source-option-btn {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    background: white;
    font-family: var(--font-cn);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    text-align: center;
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
}

.source-option-btn:active {
    transform: scale(0.97);
}

.source-option-btn.recommended {
    border-color: var(--accent-color);
    background: #f0f9ff;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.15);
}

.source-option-btn .source-badge {
    display: inline-block;
    font-size: 0.7rem;
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 6px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ==================== Responsive: short viewports (phone landscape) ==================== */
@media (max-height: 450px) {
    .card-stage {
        padding: 6px 16px;
        gap: 6px;
    }
    .controls { height: auto; padding: 4px 16px 8px; }
    .learn-toggle-btn { padding: 6px 16px; font-size: 0.8rem; }
    .app-header { height: 40px; }
    .top-bar { padding: 2px 12px; }
    .mode-btn { padding: 5px 12px; font-size: 0.8rem; }
    .batch-select { padding: 5px 24px 5px 10px; font-size: 0.8rem; }
}
