/* =========================================================
   AI English Coach · 白色主題 Light Theme
   ========================================================= */

/* ----- Reset & Base ----- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #fdfaf5;
    --bg-secondary: #fffefb;
    --bg-card: #ffffff;
    --bg-hover: #faf6ef;
    --border-color: #ede4d8;
    --text-primary: #3d3226;
    --text-secondary: #8b7a65;
    --text-muted: #bfb09a;
    --accent-blue: #a0b8d0;
    --accent-purple: #c8b0c8;
    --accent-green: #a0b898;
    --accent-orange: #d4a860;
    --accent-pink: #d4b0a8;
    --gradient-main: linear-gradient(135deg, #d4a860, #c89850);
    --gradient-warm: linear-gradient(135deg, #e0c080, #d4a860);
    --gradient-cool: linear-gradient(135deg, #a0b898, #a0b8d0);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.03);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.05);
    --shadow-glow: 0 0 20px rgba(200, 160, 100, 0.08);
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', 'Gaegu', 'ZCOOL KuaiLe', 'M PLUS Rounded 1c', 'PingFang SC', sans-serif;
    background: #fdfaf5;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    font-weight: 400;
    letter-spacing: 0;
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-blue); }

/* ----- Header ----- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    font-size: 2rem;
    animation: float 3s ease-in-out infinite;
}

.header-title {
    font-family: 'Gaegu', 'Nunito', cursive;
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #e8a850, #d4956c, #c88060);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.3;
    letter-spacing: 0.02em;
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.header-motto {
    text-align: center;
    font-size: 0.85rem;
    color: #8b6914;
    font-weight: 500;
    padding: 6px 18px;
    background: rgba(212, 168, 83, 0.1);
    border-radius: 20px;
    border: 1px solid rgba(212, 168, 83, 0.2);
    animation: pulse-glow 3s ease-in-out infinite;
    max-width: 400px;
}

.header-stats .stat-badge {
    font-size: 0.8rem;
    padding: 6px 14px;
    background: var(--bg-card);
    border-radius: 20px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

/* ----- Main Layout ----- */
.main-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    height: calc(100vh - 68px);
    gap: 0;
}

/* ----- Sidebar ----- */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    box-shadow: 1px 0 4px rgba(0,0,0,0.03);
    padding: 20px 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-title {
    font-size: 1rem;
    text-align: center;
    color: var(--text-primary);
}

.sidebar-title small,
.sidebar-label small {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.75rem;
}

.sidebar-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.sidebar-divider {
    height: 1px;
    background: var(--border-color);
    opacity: 0.5;
}

.scene-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scene-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.scene-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    transform: translateX(4px);
}

.scene-btn.active {
    background: linear-gradient(135deg, rgba(212, 168, 83, 0.15), rgba(200, 149, 108, 0.08));
    border-color: #d4a853;
    color: #5c3d1a;
    box-shadow: 0 0 20px rgba(212, 168, 83, 0.12);
}

.scene-icon { font-size: 1.5rem; }
.scene-name { font-size: 0.85rem; font-weight: 600; }
.scene-en { font-size: 0.7rem; color: var(--text-muted); }

/* Difficulty */
.difficulty-selector {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.diff-btn {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
    text-align: center;
}

.diff-btn:hover {
    background: var(--bg-hover);
}

.diff-btn.active {
    background: rgba(52, 211, 153, 0.15);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

/* Daily Challenge */
.daily-challenge {
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.1), rgba(239, 68, 68, 0.05));
    border: 1px solid rgba(251, 146, 60, 0.2);
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
}

.challenge-text {
    font-size: 0.85rem;
    color: var(--accent-orange);
    margin: 8px 0;
    line-height: 1.5;
}

.challenge-btn {
    padding: 8px 20px;
    background: var(--gradient-warm);
    border: none;
    border-radius: 20px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
}

.challenge-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(251, 146, 60, 0.4);
}

/* ----- Chat Area ----- */
.chat-area {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeInUp 0.4s ease;
}

.message.coach { align-self: flex-start; }
.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: var(--bg-card);
    flex-shrink: 0;
}

.message.user .msg-avatar {
    background: rgba(99, 102, 241, 0.2);
}

.msg-content {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    position: relative;
}

.message.coach .msg-content {
    border-top-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.message.user .msg-content {
    border-top-right-radius: 4px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.04));
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.msg-text p {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 4px;
}

.msg-text p:last-child { margin-bottom: 0; }
.msg-text p.en {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.msg-emotion {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(251, 146, 60, 0.1);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--accent-orange);
    border-left: 3px solid var(--accent-orange);
}

.msg-correction {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(52, 211, 153, 0.1);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-green);
    font-size: 0.8rem;
}

.msg-correction .corr-label {
    color: var(--accent-green);
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.msg-correction .corr-original {
    color: var(--text-muted);
    text-decoration: line-through;
}

.msg-correction .corr-corrected {
    color: var(--accent-green);
}

.msg-analysis-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.tag.fluency { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.tag.vocab { background: rgba(52, 211, 153, 0.15); color: var(--accent-green); }
.tag.pron { background: rgba(251, 146, 60, 0.15); color: var(--accent-orange); }
.tag.grammar { background: rgba(167, 139, 250, 0.15); color: var(--accent-purple); }

/* =========================================================
   INLINE ANALYSIS（用戶訊息下方即時分析）
   ========================================================= */
.inline-analysis {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: 0.75rem;
}
.inline-scores {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.inline-score {
    font-weight: 600;
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.inline-cefr {
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.7rem;
    color: #fff;
    margin-left: auto;
}
.inline-detail {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.68rem;
    color: var(--text-muted);
}

/* Grammar fixes inline */
.inline-grammar-fixes {
    margin-top: 8px;
    padding: 8px 10px;
    background: rgba(212, 160, 168, 0.1);
    border-left: 3px solid var(--accent-pink);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.inline-fix-title {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-pink);
    margin-bottom: 6px;
}
.grammar-fix-item {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.7rem;
    padding: 3px 0;
}
.grammar-fix-bad {
    color: #c0392b;
    text-decoration: line-through;
    font-weight: 500;
}
.grammar-fix-arrow {
    color: var(--text-muted);
    font-size: 0.7rem;
}
.grammar-fix-good {
    color: #27ae60;
    font-weight: 600;
}
.grammar-fix-reason {
    color: var(--text-muted);
    font-size: 0.65rem;
    font-style: italic;
    margin-left: 4px;
}

/* =========================================================
   INLINE FEEDBACK（輕量提示，唔打分）
   ========================================================= */
.inline-scorecard {
    margin-top: 8px;
    font-size: 0.75rem;
}

/* Errors section */
.isu-errors {
    padding: 8px 10px;
    background: #fdf8f5;
    border-left: 3px solid #e8c8b0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.isu-errors-title {
    font-weight: 600;
    font-size: 0.7rem;
    color: #b08060;
    margin-bottom: 4px;
}
.isu-error-item {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding: 2px 0;
    font-size: 0.72rem;
}
.isu-error-bad {
    color: #c07860;
    text-decoration: line-through;
}
.isu-error-arrow {
    color: var(--text-muted);
    font-size: 0.65rem;
}
.isu-error-fix {
    color: #5a8f6a;
    font-weight: 600;
}
.isu-error-why {
    color: #999;
    font-size: 0.65rem;
    font-style: italic;
}

/* Native version box */
.isu-native-placeholder {
    margin-top: 6px;
}
.isu-waiting {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-style: italic;
}
.isu-native-ok-hint {
    font-size: 0.7rem;
    color: #5a8f6a;
    font-weight: 500;
}
.isu-native-box {
    padding: 8px 10px;
    background: #f6faf7;
    border-left: 3px solid #a0c8a0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.isu-native-label {
    font-size: 0.68rem;
    color: #6a9a7a;
    font-weight: 600;
    margin-bottom: 4px;
}
.isu-native-text {
    font-size: 0.85rem;
    color: #2d3d2d;
    font-weight: 500;
    line-height: 1.5;
}

/* History error items */
.history-error-item {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    padding: 2px 0;
    font-size: 0.72rem;
}
.he-bad {
    color: #c07860;
    text-decoration: line-through;
}
.he-arrow {
    color: #aaa;
    font-size: 0.65rem;
}
.he-good {
    color: #5a8f6a;
    font-weight: 600;
}
.he-why {
    color: #999;
    font-size: 0.65rem;
    font-style: italic;
}

/* =========================================================
   HISTORY CORRECTION BOX（老師改文風格）
   ========================================================= */
.history-correction-box {
    padding: 10px 12px;
    background: #fdfaf6;
    border: 1px solid #e8e0d0;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}
.hcb-original, .hcb-corrected {
    margin-bottom: 6px;
}
.hcb-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.hcb-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
}
.hcb-original .hcb-text {
    color: #c0392b;
    text-decoration: line-through;
    text-decoration-color: rgba(192,57,43,0.3);
}
.hcb-corrected .hcb-text.hcb-good {
    color: #27ae60;
    text-decoration: none;
    font-weight: 600;
}
.hcb-details {
    padding-top: 6px;
    border-top: 1px dashed #e8e0d0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.hcb-fix {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #fff;
    border-radius: 12px;
    font-size: 0.7rem;
    border: 1px solid #e8e0d0;
}
.hcb-fix-bad {
    color: #c0392b;
    text-decoration: line-through;
}
.hcb-fix-arrow {
    color: #aaa;
}
.hcb-fix-good {
    color: #27ae60;
    font-weight: 600;
}
.hcb-fix-why {
    color: #999;
    font-size: 0.65rem;
}

/* Pronunciation in history */
.hcb-pron {
    margin-top: 8px; padding: 8px 10px;
    background: #f5f0ff; border-left: 3px solid #a0a0d0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.hcb-pron-title { font-size:0.68rem;font-weight:600;color:#6a6aaa;margin-bottom:4px; }
.hcb-pron-item { display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:2px 0;font-size:0.7rem; }
.hcb-pron-word { font-weight:600;color:#4a4a8a; }
.hcb-pron-phoneme { padding:1px 6px;background:rgba(160,160,208,0.15);border-radius:4px;font-size:0.65rem;color:#6a6aaa; }
.hcb-pron-tip { color:#888;font-size:0.65rem;font-style:italic; }
.hcb-pron-deep { background:#f5f0ff; border-color:#8a8ad0; }
.hcb-pron-ipa { font-family:monospace;padding:1px 6px;background:rgba(200,160,200,0.2);border-radius:4px;font-size:0.7rem;color:#6a4a8a;font-weight:600; }
.hcb-pron-said { font-size:0.65rem;color:#c07860; }

/* =========================================================
   PROGRESS ABILITY ANALYSIS（學習進度能力分析）
   ========================================================= */
.pa-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.pa-level-badge {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.pa-level-label {
    font-size: 1.3rem;
    font-weight: 800;
    color: #fff;
}
.pa-level-text {
    flex: 1;
}
.pa-level-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}
.pa-level-next {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.pa-section {
    margin-bottom: 14px;
    padding: 14px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}
.pa-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.pa-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.pa-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.pa-label {
    width: 130px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.pa-bar-wrap {
    flex: 1;
    height: 8px;
    background: #e8e4d8;
    border-radius: 4px;
    overflow: hidden;
}
.pa-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
}
.pa-val {
    width: 38px;
    font-weight: 700;
    font-size: 0.75rem;
    text-align: right;
    flex-shrink: 0;
}
.pa-empty {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
}
.pa-empty span { font-size: 2rem; }
.pa-empty p { font-size: 0.85rem; margin: 8px 0 4px; }
.pa-empty small { font-size: 0.7rem; }
.pa-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 14px;
}
.pa-tip {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 8px;
}
.pa-charts-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.pa-radar-wrap {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
}
.pa-radar-wrap canvas {
    max-width: 260px;
}
.pa-bars-wrap {
    flex: 1;
    min-width: 180px;
}
.pa-trend-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.pa-trend-section canvas {
    display: block;
    margin: 8px auto 0;
}

@media (max-width: 768px) {
    .pa-charts-row {
        flex-direction: column;
        align-items: center;
    }
    .pa-bars-wrap {
        width: 100%;
    }
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--accent-blue);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

.typing-label {
    margin-left: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Voice Controls */
.voice-controls {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.voice-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: var(--transition);
}

.status-dot.listening {
    background: var(--accent-green);
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.5);
    animation: pulse-dot 1s ease-in-out infinite;
}

.status-dot.processing {
    background: var(--accent-orange);
    box-shadow: 0 0 10px rgba(251, 146, 60, 0.5);
    animation: pulse-dot 0.6s ease-in-out infinite;
}

.voice-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

.mic-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.mic-btn:hover {
    border-color: var(--accent-blue);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.2);
}

.mic-btn:active,
.mic-btn.recording {
    border-color: var(--accent-green);
    background: rgba(52, 211, 153, 0.1);
    box-shadow: 0 0 40px rgba(52, 211, 153, 0.3);
    transform: scale(1.05);
}

.mic-btn.recording::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid var(--accent-green);
    animation: ripple 1.5s ease-out infinite;
}

.mic-icon { font-size: 1.8rem; }
.mic-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.mic-label small { display: block; }

.speak-btn, .clear-btn {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
}

.speak-btn:hover, .clear-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Transcript */
.transcript-box {
    padding: 12px 16px;
    background: rgba(52, 211, 153, 0.05);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: var(--radius-md);
    animation: fadeIn 0.3s ease;
}

.transcript-label {
    font-size: 0.75rem;
    color: var(--accent-green);
    margin-bottom: 6px;
}

.transcript-text {
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.transcript-confidence {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ----- Analysis Panel ----- */
.analysis-panel {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: -1px 0 4px rgba(0,0,0,0.03);
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-title {
    font-size: 1rem;
    text-align: center;
    color: var(--text-primary);
}

.panel-title small {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.7rem;
}

.panel-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.metric-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: var(--shadow-md);
}

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

.metric-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.metric-score {
    font-size: 1.1rem;
    font-weight: 800;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.metric-bar {
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.metric-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--gradient-main);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-fill.fluency { background: linear-gradient(90deg, #06b6d4, #3b82f6); }
.metric-fill.vocab { background: linear-gradient(90deg, #34d399, #10b981); }
.metric-fill.pron { background: linear-gradient(90deg, #fb923c, #f472b6); }
.metric-fill.grammar { background: linear-gradient(90deg, #a78bfa, #8b5cf6); }

.metric-level {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.metric-detail {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.metric-detail strong {
    color: var(--text-primary);
}

/* CEFR Badges */
.cefr-badges {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.cefr-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    border: 1px solid transparent;
    transition: var(--transition);
}

.cefr-badge.active {
    background: rgba(52, 211, 153, 0.15);
    color: var(--accent-green);
    border-color: var(--accent-green);
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.2);
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.achievement {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03);
    transition: var(--transition);
    cursor: default;
}

.achievement.unlocked {
    background: rgba(251, 146, 60, 0.1);
    border: 1px solid rgba(251, 146, 60, 0.2);
}

.achievement.unlocked .ach-icon {
    animation: bounce 0.6s ease;
}

.achievement.locked {
    opacity: 0.4;
    filter: grayscale(0.8);
}

.ach-icon { font-size: 1.2rem; }
.ach-name { font-size: 0.6rem; color: var(--text-muted); text-align: center; }
.achievement.unlocked .ach-name { color: var(--accent-orange); }

/* Emotion Feed */
.emotion-feed {
    margin-top: auto;
    padding-top: 8px;
}

.emotion-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(251, 146, 60, 0.08), rgba(244, 114, 182, 0.05));
    border: 1px solid rgba(251, 146, 60, 0.15);
    border-radius: var(--radius-md);
    animation: slideInRight 0.5s ease;
}

.emotion-icon { font-size: 1.3rem; }
.emotion-text {
    font-size: 0.8rem;
    color: var(--accent-orange);
    line-height: 1.4;
}

/* ----- Modal ----- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    animation: scaleIn 0.3s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.modal-header h2 { font-size: 1.2rem; }
.modal-header h3.en {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.modal-body {
    padding: 20px 24px;
}

.report-section {
    margin-bottom: 20px;
}

.report-section h3 {
    font-size: 0.95rem;
    color: var(--accent-blue);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.report-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.report-item {
    padding: 10px 14px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
}

.report-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

.report-item .value {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 4px;
}

.report-item .value.good { color: var(--accent-green); }
.report-item .value.fair { color: var(--accent-orange); }
.report-item .value.needs-work { color: #f87171; }

.report-suggestions {
    list-style: none;
    padding: 0;
}

.report-suggestions li {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(255,255,255,0.03);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    border-left: 3px solid var(--accent-purple);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
}

.modal-btn:hover {
    background: var(--bg-hover);
}

.modal-btn.primary {
    background: var(--gradient-main);
    border: none;
    font-weight: 600;
}

.modal-btn.primary:hover {
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
}

/* ----- Animations ----- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

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

/* Cat pet float animation */
.cat {
    animation: float 2s ease-in-out infinite;
}

@keyframes catFloat {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

@keyframes floatSlow {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-4px) rotate(3deg); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(232, 184, 120, 0.1); }
    50% { box-shadow: 0 0 25px rgba(232, 184, 120, 0.2); }
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes ripple {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-8px); }
}

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

@keyframes petWiggle {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-3deg) scale(1.05); }
    75% { transform: rotate(3deg) scale(1.05); }
}

@keyframes sparkle {
    0%, 100% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1); }
}

/* ----- Responsive ----- */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 180px 1fr 260px;
    }
}

@media (max-width: 768px) {
    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
    }

    .sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: row;
        flex-wrap: wrap;
        padding: 12px;
    }

    .scene-list {
        flex-direction: row;
    }

    .scene-btn {
        flex: 1;
    }

    .analysis-panel {
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .header-motto {
        display: none;
    }

    .achievements-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .report-grid {
        grid-template-columns: 1fr;
    }

    .mic-btn {
        width: 64px;
        height: 64px;
    }
}

/* ----- Smooth Entrance ----- */
body { animation: fadeIn 0.5s ease; }

/* ----- Highlight animation for new data ----- */
@keyframes highlightFlash {
    0% { background: rgba(99, 102, 241, 0.2); }
    100% { background: transparent; }
}

.highlight-new {
    animation: highlightFlash 1s ease;
}

/* =========================================================
   PET WIDGET — 寵物浮動小工具
   ========================================================= */
.pet-widget {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 500;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-lg);
}

.pet-widget:hover {
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
}

.pet-speech-bubble {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #fcd34d;
    border-radius: var(--radius-md);
    padding: 8px 14px;
    font-size: 0.75rem;
    color: #b45309;
    white-space: nowrap;
    max-width: 220px;
    margin-bottom: 8px;
    animation: fadeInUp 0.3s ease;
    box-shadow: var(--shadow-md);
}

.pet-speech-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #fcd34d;
}

.pet-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f5e8d8, #e8d5c0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border: 2px solid #d4a853;
    box-shadow: 0 2px 8px rgba(180,140,100,0.2);
}

.pet-emoji {
    font-size: 2.2rem;
    animation: petBounce 2s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.pet-status-mini {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.65rem;
    align-items: center;
}

.pet-hunger-bar-mini {
    width: 40px;
    height: 3px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.pet-hunger-fill {
    height: 100%;
    background: var(--accent-green);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.pet-coins-mini {
    font-size: 0.7rem;
    color: #b45309;
    font-weight: 600;
}

.pet-expand-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 4px;
}

.pet-expand-btn:hover { color: var(--text-primary); }

@keyframes petBounce {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    15% { transform: translateY(-10px) rotate(-2deg); }
    30% { transform: translateY(0) rotate(0deg); }
    45% { transform: translateY(-5px) rotate(2deg); }
    60% { transform: translateY(0) rotate(0deg); }
}

/* =========================================================
   PET PANEL — 寵物詳細面板
   ========================================================= */
.pet-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 600;
    animation: fadeIn 0.3s ease;
}

.pet-panel {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12);
    width: 420px;
    max-height: 85vh;
    overflow-y: auto;
    animation: scaleIn 0.3s ease;
}

.pet-panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #faf6ed;
    border-radius: 24px 24px 0 0;
}

.pet-panel-header h2 { font-size: 1.1rem; font-weight: 700; }

.pet-panel-body {
    padding: 20px 24px;
}

/* Pet Mini Shop */
.pet-mini-shop {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e8dcc8;
}
.pet-mini-shop-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}
.pet-mini-tab {
    flex: 1;
    padding: 6px 8px;
    background: #faf6ed;
    border: 1px solid #e8dcc8;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 600;
    color: #8b7355;
    transition: all 0.2s;
}
.pet-mini-tab.active {
    background: #e8b878;
    color: #fff;
    border-color: #d4a853;
}
.pet-mini-shop-grid {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.mini-shop-item {
    flex: 0 0 auto;
    min-width: 72px;
    text-align: center;
    padding: 10px 8px;
    background: #fffdf7;
    border: 1px solid #e8dcc8;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.mini-shop-item:hover { border-color: #e8b878; transform: translateY(-1px); }
.mini-shop-item.equipped { border-color: #10b981; background: #f0fdf4; }
.mini-shop-item.owned { border-color: #bbf7d0; }
.mini-shop-icon { font-size: 1.4rem; display: block; }
.mini-shop-name { font-size: 0.65rem; color: #5c4a32; font-weight: 600; }
.mini-shop-price { font-size: 0.65rem; color: #b45309; font-weight: 700; }
.mini-shop-badge { font-size: 0.6rem; color: #10b981; font-weight: 600; }
.mini-shop-badge.owned { color: #6366f1; }

/* ====== PET DOLLHOUSE ROOM ====== */
.pet-showcase {
    text-align: center;
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    margin-bottom: 20px;
    border: 4px solid #d4c4a8;
    box-shadow: 0 4px 20px rgba(120, 100, 70, 0.12);
    min-height: 320px;
    display: flex;
    flex-direction: column;
    background: #f5e8d4;
}

/* 房間牆壁 — 使用背景圖片 */
.pet-room-wall {
    flex: 1;
    background: url('../images/pets/room-bg.png') center/cover no-repeat;
    position: relative;
    padding: 30px 20px 10px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 240px;
}

/* 牆紙花紋 — 隱藏 */
.pet-room-wall::before { display: none; }

/* 窗戶 — 隱藏（背景圖已有）*/
.pet-room-window { display: none; }
}
/* 十字窗框 */
.pet-room-window::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: #d4c4a8;
    transform: translateY(-50%);
}
.pet-room-window::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 3px;
    background: #d4c4a8;
    transform: translateX(-50%);
}

/* 地板 */
.pet-room-floor { display: none; }
    height: 50px;
    background: linear-gradient(180deg, #e8d5b8 0%, #dcc8a8 40%, #d0b898 100%);
    position: relative;
    border-top: 2px solid #d4c4a8;
}

/* 地板木紋 */
.pet-room-floor::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 30px,
        rgba(180,150,120,0.1) 30px,
        rgba(180,150,120,0.1) 31px
    );
}

/* 寵物在房間中央 */
.pet-room-pet {
    position: relative;
    z-index: 3;
    margin-bottom: -10px;
}

.pet-room-pet-emoji {
    font-size: 5rem;
    display: block;
    animation: petWiggle 3s ease-in-out infinite;
    filter: drop-shadow(0 6px 12px rgba(120,100,70,0.2));
    transition: transform 0.2s ease;
}
.pet-room-pet-img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    display: block;
    animation: catFloat 2s ease-in-out infinite;
    filter: drop-shadow(0 6px 12px rgba(120,100,70,0.2));
    transition: transform 0.2s ease;
    cursor: pointer;
}
.pet-room-pet-img:active {
    transform: scale(1.2);
}

/* 寵物穿的衣服 */
.pet-room-outfit {
    position: absolute;
    top: -10px;
    right: -20px;
    font-size: 2rem;
    animation: floatSlow 2.5s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.12));
    z-index: 4;
}

/* 寵物腳下影子 */
.pet-room-shadow {
    width: 50px;
    height: 10px;
    background: rgba(150,120,90,0.2);
    border-radius: 50%;
    margin: -2px auto 0;
    animation: shadowPulse 2.5s ease-in-out infinite;
}

/* 家具擺放 */
.pet-room-furniture {
    position: absolute;
    font-size: 1.6rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    z-index: 3;
    animation: float 3s ease-in-out infinite;
}

/* 家具位置 */
.pet-furn-left { bottom: 30px; left: 25px; animation-delay: 0s; }
.pet-furn-right { bottom: 30px; right: 25px; animation-delay: 0.4s; }
.pet-furn-corner-tl { top: 85px; left: 18px; animation-delay: 0.8s; }
.pet-furn-corner-tr { top: 85px; right: 18px; animation-delay: 1.2s; }


.pet-name-display {
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 10px;
    color: #1e293b;
    position: relative;
    z-index: 1;
}

.pet-edit-name {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.85rem;
    margin-left: 6px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.pet-edit-name:hover { background: #e2e8f0; }

.pet-mood-display {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 6px;
    position: relative;
    z-index: 1;
}

.pet-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    background: #f8fafc;
    border-radius: 14px;
    padding: 14px;
    border: 1px solid #e2e8f0;
}

.pet-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.pet-bar-row span:first-child { width: 75px; font-weight: 600; }

.pet-bar {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

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

.pet-bar-fill.hunger { background: linear-gradient(90deg, #fbbf24, #34d399); }
.pet-bar-fill.intimacy { background: linear-gradient(90deg, #f472b6, #ef4444); }

.pet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.pet-actions .pet-action-btn {
    flex: 1 1 auto;
    min-width: 55px;
    font-size: 0.75rem;
    padding: 10px 8px;
}

.pet-action-btn {
    padding: 12px 14px;
    border-radius: 18px;
    border: 2px solid var(--border-color);
    background: #fffdf7;
    color: #5c4a32;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 700;
    transition: var(--transition);
    box-shadow: 0 2px 6px rgba(180,150,120,0.06);
    letter-spacing: 0.02em;
}

.pet-action-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 4px 14px rgba(180,150,120,0.12);
}
.pet-action-btn.feed { background: #f5fae8; border-color: #c8d8b0; color: #6b8a50; }
.pet-action-btn.feed:hover { background: #eef5dd; }
.pet-action-btn.talk { background: #fef8f0; border-color: #e8ccb0; color: #a07050; }
.pet-action-btn.talk:hover { background: #fdf2e4; }
.pet-action-btn.shop { background: #faf5fc; border-color: #d8c8e0; color: #806898; }
.pet-action-btn.shop:hover { background: #f5ecf8; }
.pet-action-btn.switch { background: #f5f8fc; border-color: #bcc8e0; color: #607898; }
.pet-action-btn.switch:hover { background: #eaf0f8; }
.pet-action-btn.pet-pet-btn { background: #fff5f5; border-color: #f0c8c8; color: #b06060; }
.pet-action-btn.pet-pet-btn:hover { background: #ffe8e8; }

/* =========================================================
   PET SELECTION — 寵物選擇
   ========================================================= */
.modal-sm { max-width: 480px; }
.modal-lg { max-width: 680px; }

.pet-select-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.pet-select-card {
    padding: 20px 16px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 18px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.pet-select-card:hover {
    border-color: var(--accent-purple);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.pet-select-card.active {
    border-color: #10b981;
    background: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.pet-select-icon {
    font-size: 2.8rem;
    display: block;
    margin-bottom: 8px;
}

.pet-select-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #1e293b;
}

.pet-select-name-en {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Pet lock states */
.pet-select-card.locked {
    opacity: 0.8;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: #f8fafc;
}

.pet-select-card.locked:hover {
    border-color: var(--accent-orange);
    opacity: 1;
}

.pet-select-card.owned {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.pet-select-card.free {
    background: #fefce8;
    border-color: #fde68a;
}

.lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 18px;
    transition: var(--transition);
}

.pet-select-card.locked:hover .lock-overlay {
    background: rgba(255,255,255,0.5);
}

.lock-icon {
    font-size: 1.5rem;
}

.lock-price {
    font-size: 0.85rem;
    font-weight: 700;
    color: #b45309;
}

.lock-price.cant-afford {
    color: #ef4444;
}

.lock-label {
    font-size: 0.65rem;
    color: #64748b;
}

.pet-badge {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 8px;
}

.pet-badge.active-badge {
    color: #166534;
    background: #dcfce7;
}

.pet-badge.owned-badge {
    color: #1e40af;
    background: #dbeafe;
}

.pet-badge.free-badge {
    color: #854d0e;
    background: #fef3c7;
}

/* =========================================================
   SHOP — 寵物商店
   ========================================================= */
.shop-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0;
}

.shop-tab {
    padding: 10px 18px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: var(--transition);
    border-radius: 10px 10px 0 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.shop-tab:hover { color: var(--text-primary); background: #f8fafc; }
.shop-tab.active {
    color: var(--accent-purple);
    background: #faf5ff;
    border-bottom-color: var(--accent-purple);
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.shop-item {
    padding: 16px 10px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.shop-item:hover {
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.shop-item.owned {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.shop-item.equipped {
    border-color: #10b981;
    background: #f0fdf4;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.shop-item-icon {
    font-size: 1.8rem;
    display: block;
}
.shop-item-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
.mini-shop-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.shop-item-name {
    font-size: 0.78rem;
    margin: 6px 0;
    color: #334155;
    font-weight: 600;
}

.shop-item-price {
    font-size: 0.72rem;
    color: #b45309;
    font-weight: 700;
}

.shop-item-badge {
    font-size: 0.65rem;
    color: #10b981;
    font-weight: 600;
}

/* =========================================================
   GAMES — 小遊戲
   ========================================================= */
.game-select-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.game-select-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 20px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.game-select-btn:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.game-select-btn .game-icon {
    font-size: 2rem;
}

.game-select-btn small {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Match game cards */
.match-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 16px 0;
}

.match-card {
    padding: 16px 8px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    font-weight: 600;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.match-card:hover { border-color: var(--accent-blue); }
.match-card.selected {
    border-color: var(--accent-purple);
    background: rgba(167,139,250,0.15);
}
.match-card.matched {
    border-color: #4ade80;
    background: rgba(74,222,128,0.15);
    cursor: default;
    pointer-events: none;
    animation: matchPop 0.5s ease forwards;
}
@keyframes matchPop {
    0% { border-color: #4ade80; background: rgba(74,222,128,0.2); opacity: 1; transform: scale(1); }
    40% { border-color: #22c55e; background: rgba(34,197,94,0.25); opacity: 1; transform: scale(1.05); }
    100% { border-color: #a8c898; background: transparent; opacity: 0; transform: scale(0.8); }
}

/* Fill game */
.fill-round {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

.fill-sentence {
    font-size: 1rem;
    margin-bottom: 10px;
}

.fill-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.fill-option {
    padding: 8px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.fill-option:hover { border-color: var(--accent-blue); }
.fill-option.correct {
    border-color: var(--accent-green);
    background: rgba(52,211,153,0.15);
}
.fill-option.wrong {
    border-color: #f87171;
    background: rgba(248,113,113,0.1);
}
.fill-option:disabled { pointer-events: none; opacity: 0.6; }

.fill-round-num { color: var(--text-muted); font-size: 0.8rem; }
.fill-hint { color: var(--text-muted); font-size: 0.75rem; margin-bottom: 8px; }

.fill-feedback {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    animation: fadeInUp 0.3s ease;
}
.fill-feedback.correct { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.fill-feedback.wrong { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.speed-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 1.1rem;
    text-align: center;
    margin: 8px 0;
}
.speed-input:focus { outline: none; border-color: #e8b878; }
.speed-submit {
    padding: 10px 28px;
    background: linear-gradient(135deg, #e8b878, #d4a853);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Scramble game */
.scramble-round {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    text-align: center;
}

.scramble-letters {
    font-size: 2rem;
    letter-spacing: 8px;
    font-weight: 700;
    margin: 12px 0;
    color: var(--accent-blue);
}

.scramble-input {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    text-align: center;
    width: 200px;
}

.scramble-submit {
    margin-left: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent-blue);
    color: white;
    cursor: pointer;
    font-weight: 600;
}

/* Quick fire */
.quickfire-round {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    text-align: center;
}

.quickfire-prompt {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 12px 0;
}

.quickfire-input {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    width: 250px;
    text-align: center;
}

/* Game result */
.game-result {
    text-align: center;
    padding: 30px;
}

.game-result-stars {
    font-size: 3rem;
    margin: 16px 0;
}

.game-result-score {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 8px 0;
}

.game-result-coins {
    font-size: 1rem;
    color: var(--accent-orange);
}

/* =========================================================
   SKITS — 短劇
   ========================================================= */
.skit-select-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.skit-select-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.skit-select-item:hover {
    border-color: var(--accent-purple);
}

.skit-select-icon { font-size: 1.8rem; }
.skit-select-info { flex: 1; }
.skit-select-name { font-size: 0.9rem; font-weight: 600; }
.skit-select-name-en { font-size: 0.75rem; color: var(--text-muted); }
.skit-select-diff { font-size: 0.7rem; }

.skit-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 30px 20px;
}

.skit-role-a, .skit-role-b {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-lg);
}

.skit-role-a { background: rgba(99,102,241,0.1); }
.skit-role-b { background: rgba(52,211,153,0.1); }

.skit-role-icon { font-size: 1.5rem; }
.skit-role-name { font-weight: 600; }

.skit-dialogue-box {
    padding: 16px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    max-width: 100%;
    font-size: 1rem;
    line-height: 1.6;
    min-height: 60px;
}

.skit-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

.skit-btn {
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.skit-btn.listen {
    background: var(--accent-green);
    color: #000;
}

.skit-btn.skip {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.skit-btn.listen:hover {
    box-shadow: 0 4px 16px rgba(52,211,153,0.3);
}

/* =========================================================
   SIDEBAR ACTIONS — 遊戲/短劇按鈕
   ========================================================= */
.sidebar-actions {
    display: flex;
    gap: 8px;
}

.sidebar-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
    text-align: center;
}

.sidebar-action-btn:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

.sidebar-action-btn.game:hover { border-color: var(--accent-blue); }
.sidebar-action-btn.skit:hover { border-color: var(--accent-purple); }

.vocab-big-btn {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 16px 10px;
    background: linear-gradient(135deg, #fef7e8, #fde8c0);
    border: 3px solid #e8b878;
    border-radius: 18px;
    color: #8b6914;
    cursor: pointer;
    font-weight: 800;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(200,160,100,0.15);
    animation: pulse-glow 3s ease-in-out infinite;
}
.vocab-big-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(200,160,100,0.25);
}
.vocab-big-btn small {
    font-size: 0.65rem;
    color: #a08050;
    font-weight: 400;
}

.sidebar-action-btn small {
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* =========================================================
   VOCAB TRACKER — 詞彙追蹤
   ========================================================= */
.vocab-tracker {
    padding: 8px 0;
}

.vocab-count {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 4px 0;
}

.vocab-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 8px 0;
}

.vocab-list .vocab-word {
    padding: 2px 8px;
    background: rgba(52,211,153,0.1);
    border-radius: 10px;
    font-size: 0.7rem;
    color: var(--accent-green);
}

.vocab-empty {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.vocab-milestone {
    margin: 8px 0;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.vocab-milestone strong {
    color: var(--accent-orange);
}

.milestone-bar {
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.05);
    border-radius: 2px;
    margin-top: 4px;
    overflow: hidden;
}

.milestone-fill {
    height: 100%;
    background: linear-gradient(90deg, #fb923c, #fbbf24);
    border-radius: 2px;
    transition: width 0.5s ease;
}

.vocab-streak {
    font-size: 0.75rem;
    color: var(--accent-orange);
}

/* =========================================================
   MODAL SIZE HELPERS
   ========================================================= */
.modal-sm { max-width: 480px; }
.modal-lg { max-width: 680px; }

/* =========================================================
   PET FURNITURE
   ========================================================= */
.pet-furniture {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.pet-furniture .section-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 6px;
}

.pet-furniture-icons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pet-furniture-icons span {
    font-size: 1.2rem;
}

/* =========================================================
   LANGUAGE SWITCHER — 語言切換
   ========================================================= */
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lang-switcher {
    display: flex;
    gap: 3px;
}

.lang-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1px solid transparent;
    background: var(--bg-card);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    padding: 0;
}

.lang-btn:hover { background: var(--bg-hover); transform: scale(1.1); }

.lang-btn.active {
    border-color: var(--accent-purple);
    background: rgba(167,139,250,0.2);
    box-shadow: 0 0 10px rgba(167,139,250,0.2);
}

/* =========================================================
   PHONE MODE — 電話模式按鈕
   ========================================================= */
.mode-toggle-btn {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.mode-toggle-btn:hover { border-color: var(--accent-green); }
.mode-toggle-btn.active {
    background: rgba(52,211,153,0.1);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

.mode-toggle-btn .mode-icon { font-size: 1.3rem; }

.phone-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid #8fbc8f;
    background: rgba(143,188,143,0.08);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6b9070;
}

.phone-btn:hover {
    box-shadow: 0 0 30px rgba(52,211,153,0.3);
    transform: scale(1.05);
}

.phone-btn.ringing {
    animation: phonePulse 1.5s ease-in-out infinite;
    border-color: #fbbf24;
}

@keyframes phonePulse {
    0%, 100% { box-shadow: 0 0 20px rgba(52,211,153,0.2); }
    50% { box-shadow: 0 0 50px rgba(52,211,153,0.5); transform: scale(1.08); }
}

.phone-btn.connected {
    border-color: var(--accent-green);
    background: rgba(52,211,153,0.15);
    animation: phoneConnected 3s ease-in-out infinite;
}

@keyframes phoneConnected {
    0%, 100% { box-shadow: 0 0 15px rgba(52,211,153,0.3); }
    50% { box-shadow: 0 0 40px rgba(52,211,153,0.5); }
}

.phone-btn .phone-icon { font-size: 1.8rem; }
.phone-btn .phone-label { font-size: 0.6rem; color: var(--text-secondary); }

/* Call timer */
.call-timer {
    font-size: 1.3rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--accent-green);
    background: #f0fdf4;
    padding: 6px 14px;
    border-radius: 12px;
    border: 2px solid #bbf7d0;
    animation: pulse-dot 1s ease-in-out infinite;
}

/* =========================================================
   IELTS EXAM BUTTON — 模擬考試掣
   ========================================================= */
.ielts-exam-btn {
    width: 100%;
    padding: 12px 10px;
    border-radius: var(--radius-md);
    border: 2px solid var(--accent-orange);
    background: rgba(251,146,60,0.1);
    color: var(--accent-orange);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: var(--transition);
    text-align: center;
}

.ielts-exam-btn:hover {
    background: rgba(251,146,60,0.2);
    box-shadow: 0 0 20px rgba(251,146,60,0.2);
    transform: translateY(-1px);
}

.ielts-exam-btn small {
    display: block;
    font-size: 0.6rem;
    font-weight: 400;
    opacity: 0.7;
    margin-top: 2px;
}

/* =========================================================
   PERSONA SELECTOR — AI 角色選擇
   ========================================================= */
.persona-section { margin-top: 4px; }

.persona-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.persona-btn {
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    transition: var(--transition);
    text-align: center;
    line-height: 1.3;
}

.persona-btn:hover { background: var(--bg-hover); }

.persona-btn.active {
    border-color: var(--accent-pink);
    background: rgba(244,114,182,0.1);
    color: var(--accent-pink);
}

.persona-btn small {
    display: block;
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* =========================================================
   VOICE SETTINGS — 語音設定
   ========================================================= */
.voice-settings-section { margin-top: 4px; }

.voice-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.voice-select-btn {
    flex: 1;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    transition: var(--transition);
    text-align: center;
}

.voice-select-btn:hover { background: var(--bg-hover); }

.voice-select-btn.active {
    border-color: var(--accent-pink);
    color: var(--accent-pink);
    background: rgba(244,114,182,0.1);
}

.speed-slider {
    margin-top: 4px;
}

.speed-slider input[type=range] {
    margin: 4px 0;
}

/* =========================================================
   ACCENT SETTINGS — 口音設定
   ========================================================= */
.accent-section { margin-top: 4px; }

.accent-selector {
    display: flex;
    gap: 6px;
}

.accent-btn {
    flex: 1;
    padding: 7px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    transition: var(--transition);
    text-align: center;
}

.accent-btn:hover { background: var(--bg-hover); }

.accent-btn.active {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(96,165,250,0.1);
}

.native-lang-select {
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.78rem;
    cursor: pointer;
    margin-top: 6px;
}

.native-lang-select:focus {
    outline: none;
    border-color: var(--accent-purple);
}

/* =========================================================
   MY WORLD — 我的世界面板
   ========================================================= */

/* =========================================================
   ONBOARDING — 首次教學
   ========================================================= */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    animation: fadeIn 0.3s ease;
}
.onboarding-card {
    background: #fffdf7;
    border: 2px solid #e8b878;
    border-radius: 24px;
    padding: 32px 28px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    animation: scaleIn 0.3s ease;
}
.onboarding-step {
    font-size: 0.7rem;
    color: #b8a890;
    margin-bottom: 8px;
}
.onboarding-title {
    font-size: 1.2rem;
    font-weight: 800;
    color: #5c4a32;
    margin-bottom: 10px;
    font-family: 'ZCOOL KuaiLe', sans-serif;
}
.onboarding-text {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.6;
    margin-bottom: 20px;
}
.onboarding-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.onboarding-btn {
    padding: 10px 28px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.onboarding-btn.next {
    background: linear-gradient(135deg, #e8b878, #d4a853);
    color: #fff;
}
.onboarding-btn.back {
    background: #f1f5f9;
    color: #64748b;
}
.onboarding-skip {
    margin-top: 14px;
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 0.75rem;
}

/* =========================================================
   GOOGLE LOGIN — 登入按鈕
   ========================================================= */
.login-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 6px 12px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.8rem;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.2;
}

.login-btn:hover {
    border-color: #4285f4;
    box-shadow: 0 2px 12px rgba(66, 133, 244, 0.2);
    transform: translateY(-1px);
}

.login-btn .login-icon { font-size: 1.3rem; }
.login-btn .login-text { font-size: 0.7rem; }
.login-btn .login-text small { font-size: 0.55rem; color: var(--text-muted); }

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #4285f4;
}

.user-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #1e293b;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 6px;
    transition: var(--transition);
}

.logout-btn:hover {
    background: #fee2e2;
}

/* Premium button */
.premium-btn {
    padding: 7px 14px;
    background: linear-gradient(135deg, #e8b878, #d4a853);
    border: none;
    border-radius: 16px;
    color: #fff;
    cursor: pointer;
    font-weight: 800;
    font-size: 0.75rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(212, 168, 83, 0.3);
}
.premium-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(212, 168, 83, 0.4);
}

.my-world-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 8px 14px;
    background: linear-gradient(135deg, #fef7e8, #fde8c0);
    border: 2px solid #e8b878;
    border-radius: 18px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.82rem;
    font-weight: 700;
    color: #8b6914;
    line-height: 1.2;
    box-shadow: 0 2px 8px rgba(180,150,120,0.1);
}

.my-world-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(200, 160, 100, 0.25);
}

.my-world-btn small {
    font-size: 0.6rem;
    font-weight: 400;
    color: #a08050;
}

.modal-xl {
    max-width: 900px;
    width: 92vw;
    max-height: 90vh;
}

.myworld-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 16px;
    padding-bottom: 0;
}

.myworld-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    border-radius: 10px 10px 0 0;
}

.myworld-tab:hover { color: var(--text-primary); background: #f8fafc; }
.myworld-tab.active {
    color: var(--accent-purple);
    border-bottom-color: var(--accent-purple);
    background: #faf5ff;
}

.myworld-content {
    min-height: 300px;
}

/* ---- 寵物展示 ---- */
.mw-pet-showcase {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mw-showcase-stage {
    border-radius: 28px;
    overflow: hidden;
    position: relative;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(180,150,120,0.1);
}

.mw-showcase-sky {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px 50px;
    position: relative;
}

/* 背景主題 — Cat & Soup 風格暖色調 */
.mw-bg-garden .mw-showcase-sky {
    background: linear-gradient(180deg, #f0f4e8 0%, #e4edd8 40%, #d0e0c0 80%, #c0d4a8 100%);
}
.mw-bg-beach .mw-showcase-sky {
    background: linear-gradient(180deg, #eaf0f8 0%, #e0e8f4 40%, #f8f0e0 80%, #e8d8b8 100%);
}
.mw-bg-space .mw-showcase-sky {
    background: linear-gradient(180deg, #3a3050 0%, #4a4060 50%, #585078 100%);
}
.mw-bg-cozy .mw-showcase-sky {
    background: linear-gradient(180deg, #faf4e8 0%, #f5e8d4 40%, #f0dcc0 80%, #e8d0b0 100%);
}
.mw-bg-forest .mw-showcase-sky {
    background: linear-gradient(180deg, #e0ece0 0%, #d0e0d0 40%, #bcd4b8 80%, #a8c898 100%);
}

.mw-showcase-pet-wrap {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mw-showcase-pet {
    font-size: 7rem;
    animation: petBounce 2.5s ease-in-out infinite;
    filter: drop-shadow(0 8px 16px rgba(120, 100, 70, 0.2));
    display: block;
    line-height: 1;
    transition: transform 0.2s ease;
    cursor: pointer;
}
.mw-showcase-pet:active {
    transform: scale(1.15);
    animation: petWiggle 0.6s ease-in-out infinite;
}

/* 寵物陰影（腳下） */
.mw-showcase-shadow {
    width: 60px;
    height: 12px;
    background: rgba(150, 130, 100, 0.2);
    border-radius: 50%;
    margin-top: -4px;
    animation: shadowPulse 2.5s ease-in-out infinite;
}

@keyframes shadowPulse {
    0%, 100% { transform: scaleX(1); opacity: 0.3; }
    50% { transform: scaleX(0.7); opacity: 0.15; }
}

.mw-showcase-outfit {
    position: absolute;
    top: -8px;
    right: -20px;
    font-size: 2rem;
    animation: floatSlow 2.5s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
    z-index: 3;
}

.mw-showcase-furniture {
    display: flex;
    gap: 16px;
    margin-top: 20px;
    z-index: 2;
}

.mw-furniture-icon {
    font-size: 1.8rem;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.08));
}

.mw-furniture-icon:nth-child(2) { animation-delay: 0.6s; }
.mw-furniture-icon:nth-child(3) { animation-delay: 1.2s; }
.mw-furniture-icon:nth-child(4) { animation-delay: 1.8s; }

.mw-showcase-ground {
    height: 28px;
    background: #c8d8b0;
    border-radius: 60% 60% 0 0;
    position: relative;
    z-index: 1;
    margin-top: -24px;
}

.mw-bg-beach .mw-showcase-ground { background: #e0d0a8; }
.mw-bg-space .mw-showcase-ground { background: #4a4060; }
.mw-bg-cozy .mw-showcase-ground { background: #d8ccb4; }
.mw-bg-forest .mw-showcase-ground { background: #90b880; }

.mw-pet-info {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
}

.mw-pet-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.mw-pet-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e293b;
}

.mw-pet-species {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mw-pet-mood {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 12px;
}

.mw-pet-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mw-stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: #64748b;
}

.mw-stat span:first-child {
    width: 70px;
    font-weight: 600;
}

.mw-stat-bar {
    flex: 1;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.mw-stat-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.mw-stat-fill.hunger { background: linear-gradient(90deg, #fbbf24, #34d399); }
.mw-stat-fill.intimacy { background: linear-gradient(90deg, #f472b6, #ef4444); }

.mw-coin-val { color: #b45309; font-weight: 700; }
.mw-practice-val { color: #1e40af; font-weight: 700; }

.mw-pet-background-label {
    margin-top: 12px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #f8fafc;
    padding: 6px 12px;
    border-radius: 8px;
}

/* ---- 戰利品 ---- */
.mw-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 8px;
}

.mw-stat-card {
    text-align: center;
    padding: 16px 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.mw-stat-icon {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 4px;
}

.mw-stat-num {
    font-size: 1.4rem;
    font-weight: 800;
    color: #1e293b;
    display: block;
}

.mw-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.mw-achievements {
    margin-top: 12px;
}

/* ---- Word Popover (點擊查字) ---- */
.word-popover {
    position: fixed;
    z-index: 2000;
    background: #fff;
    border: 2px solid #e8dcc8;
    border-radius: 16px;
    padding: 16px;
    min-width: 220px;
    max-width: 280px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    animation: fadeInUp 0.2s ease;
}
.word-popover-close {
    position: absolute;
    top: 6px; right: 10px;
    cursor: pointer;
    font-size: 1.2rem;
    color: #94a3b8;
}
.word-popover-word {
    font-size: 1.3rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 6px;
}
.word-popover-def {
    font-size: 0.82rem;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 10px;
}
.word-phonetic { font-size: 0.8rem; color: #94a3b8; }
.word-def-item { margin: 4px 0; }
.word-popover-actions {
    display: flex;
    gap: 8px;
}
.word-save-btn, .word-speak-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
}
.word-save-btn { background: #fef7e8; color: #92400e; border-color: #e8b878; }
.word-save-btn:hover { background: #fde8c0; }
.word-speak-btn { background: #f0f9ff; color: #1e40af; border-color: #bae6fd; }
.word-speak-btn:hover { background: #e0f2fe; }

/* Make words in chat subtly clickable */
.msg-text p, .msg-text div {
    cursor: default;
}
.msg-text p:hover, .msg-text div:hover {
    /* subtle indicator that words are interactive */
}

/* ---- 影片學習 ---- */
.video-learn-btn {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 10px;
    background: linear-gradient(135deg, #e8f0f8, #d0e0f0);
    border: 2px solid #8b9dc3;
    border-radius: 16px;
    color: #3b5998;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s;
}
.video-learn-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(139,157,195,0.2); }
.video-learn-btn small { font-size: 0.6rem; color: #5c7a9a; }
.video-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.video-card { cursor: pointer; border-radius: 14px; overflow: hidden; border: 1px solid #e8dcc8; transition: all 0.2s; }
.video-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.video-thumb { position: relative; }
.video-thumb img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.video-level { position: absolute; top: 6px; right: 6px; padding: 2px 8px; border-radius: 6px; font-size: 0.65rem; font-weight: 700; color: #fff; }
.video-level.beginner { background: #8fbc8f; }
.video-level.intermediate { background: #e8b878; }
.video-level.advanced { background: #c88060; }
.video-info { padding: 8px 10px; background: #fffdf7; }
.video-title { font-size: 0.78rem; font-weight: 600; color: #5c4a32; }
.video-player-wrap { grid-column: 1 / -1; }
.video-back-btn { margin-bottom: 10px; padding: 6px 16px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 10px; cursor: pointer; font-size: 0.8rem; }
.video-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 14px; }
.video-container iframe { position: absolute; top:0; left:0; width:100%; height:100%; }
.video-caption { text-align: center; font-size: 0.75rem; color: #94a3b8; margin-top: 8px; }
.video-meta { font-size: 0.65rem; color: #b8a890; display: block; margin-top: 2px; }
.lesson-analysis { margin-top: 16px; }
.lesson-analysis h3 { font-size: 0.95rem; color: #5c4a32; margin-bottom: 10px; }
.lesson-analysis h3 small { font-size: 0.7rem; color: #b8a890; font-weight: 400; }
.lesson-sentence { display: flex; align-items: flex-start; gap: 8px; padding: 8px 12px; background: #fffdf7; border: 1px solid #ede4d8; border-radius: 10px; margin-bottom: 6px; }
.lesson-en { flex: 1; font-size: 0.82rem; color: #3d3226; line-height: 1.5; }
.kw-highlight { background: #fef3c7; padding: 1px 4px; border-radius: 3px; font-weight: 700; color: #92400e; }
.lesson-ai-btn { padding: 4px 12px; background: #fef7e8; border: 1px solid #e8b878; border-radius: 8px; cursor: pointer; font-size: 0.7rem; font-weight: 600; color: #92400e; white-space: nowrap; transition: all 0.2s; }
.lesson-ai-btn:hover { background: #fde8c0; }
.lesson-phrase { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; margin-bottom: 6px; }
.lp-original { font-weight: 700; color: #166534; font-size: 0.85rem; }
.lp-meaning { font-size: 0.75rem; color: #5c4a32; }
.lp-example { font-size: 0.7rem; color: #94a3b8; font-style: italic; }

/* ---- 排行榜 ---- */
.mw-rank-badge {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, #fef7e8, #fde8c0);
    border: 2px solid #e8b878;
    border-radius: 20px;
    margin-bottom: 16px;
}
.mw-rank-icon { font-size: 3rem; }
.mw-rank-title { font-size: 1.3rem; font-weight: 800; color: #5c4a32; margin: 4px 0; }
.mw-rank-score { font-size: 0.9rem; color: #92400e; font-weight: 700; }
.mw-rank-stats { background: #fffdf7; border: 1px solid #e8dcc8; border-radius: 14px; padding: 12px 16px; margin-bottom: 12px; }
.mw-rank-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f0e8d8; font-size: 0.82rem; }
.mw-rank-row:last-child { border-bottom: none; }
.mw-rank-row span:first-child { color: #8b7355; }
.mw-rank-row span:last-child { color: #5c4a32; font-weight: 700; }
.mw-rank-next { text-align: center; font-size: 0.75rem; color: #b8a890; }

/* ---- 單詞庫 ---- */
.mw-vocab-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.mw-review-section {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 16px;
}

.mw-review-title {
    font-weight: 700;
    color: #92400e;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.mw-review-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mw-review-word {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 10px;
}

.mw-review-en {
    flex: 1;
    font-weight: 700;
    color: #1e293b;
    font-size: 0.9rem;
}

.mw-review-ok, .mw-review-no {
    padding: 5px 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.72rem;
    transition: all 0.2s;
}
.mw-review-ok { background: #dcfce7; color: #166534; }
.mw-review-ok:hover { background: #bbf7d0; }
.mw-review-no { background: #fee2e2; color: #991b1b; }
.mw-review-no:hover { background: #fecaca; }

.mw-vocab-list-title {
    font-weight: 700;
    color: #5c4a32;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.mw-vocab-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mw-vocab-word {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fffdf7;
    border: 1px solid #e8dcc8;
    border-radius: 12px;
    font-size: 0.78rem;
}

.mw-vocab-word.mastered {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.mw-vocab-en {
    font-weight: 700;
    color: #1e293b;
}

.mw-vocab-tr {
    color: #94a3b8;
    font-size: 0.7rem;
}

.mw-vocab-stage {
    font-size: 0.65rem;
    color: #b8a890;
    margin-left: auto;
}

/* Learning Path */
.learning-path-section {
    padding: 4px 0;
}
.lp-progress-bar {
    height: 8px;
    background: #f0e8d8;
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0 4px;
}
.lp-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #e8b878, #d4a853);
    border-radius: 4px;
    transition: width 0.6s ease;
}
.lp-progress-text {
    font-size: 0.65rem;
    color: #b8a890;
    font-weight: 600;
}
.lp-today-mission {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #fef7e8, #fde8c0);
    border: 1px solid #e8b878;
    border-radius: 12px;
}
.lp-mission-icon {
    font-size: 0.75rem;
    font-weight: 800;
    color: #92400e;
    background: #fef3c7;
    padding: 2px 8px;
    border-radius: 6px;
}
.lp-mission-text {
    font-size: 0.78rem;
    font-weight: 600;
    color: #5c4a32;
}

/* ---- 學習紀錄 ---- */
.mw-history-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.mw-history-search {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.85rem;
    background: #fff;
    color: #1e293b;
}

.mw-history-search:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.mw-history-filter {
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.85rem;
    background: #fff;
    color: #1e293b;
    cursor: pointer;
}

.mw-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.history-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 14px 16px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.history-card:hover {
    border-color: #c4b5fd;
    box-shadow: var(--shadow-md);
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 0.75rem;
}

.history-scene {
    font-weight: 600;
    color: #64748b;
}

.history-date {
    color: var(--text-muted);
}

.history-score {
    margin-left: auto;
    font-weight: 700;
    color: var(--accent-purple);
}

.history-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    margin-top: 6px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.history-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: #1e293b;
    padding: 10px 14px;
    background: #f8fafc;
    border-radius: 10px;
    border-left: 3px solid var(--accent-blue);
}
.history-text.ai-response {
    border-left-color: #10b981;
    background: #f0fdf4;
}

.history-errors {
    margin-top: 10px;
    padding: 10px 14px;
    background: #fef2f2;
    border-radius: 10px;
    border-left: 3px solid #ef4444;
}

.history-error-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #dc2626;
    display: block;
    margin-bottom: 6px;
}

.history-error-tag {
    display: inline-block;
    padding: 3px 10px;
    background: #fff;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    font-size: 0.72rem;
    color: #b91c1c;
    margin: 2px 4px 2px 0;
}

/* 紅色波浪底線 - 錯誤詞彙 */
.error-word {
    text-decoration: underline wavy #ef4444;
    text-underline-offset: 3px;
    color: #dc2626;
    cursor: pointer;
    position: relative;
}

.error-word:hover {
    background: #fef2f2;
    border-radius: 2px;
}

.error-word:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    white-space: nowrap;
    z-index: 10;
}

/* 分頁 */
.mw-history-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.mw-page-btn {
    padding: 8px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    color: #1e293b;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: var(--transition);
}

.mw-page-btn:hover:not(:disabled) {
    background: #f1f5f9;
    border-color: var(--accent-purple);
}

.mw-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mw-page-info {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.mw-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.mw-empty span { font-size: 3rem; display: block; margin-bottom: 10px; }
.mw-empty p { font-size: 1rem; margin-bottom: 4px; }
.mw-empty small { font-size: 0.75rem; }

/* ---- 學習進度儀表板 ---- */
.mw-progress-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background: #fffdf7;
    border-radius: 18px;
    border: 1px solid #e8dcc8;
}

.mw-level-badge {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.mw-level-label {
    font-size: 1.5rem;
    font-weight: 800;
}

.mw-level-name {
    font-size: 0.65rem;
    font-weight: 600;
}

.mw-level-info {
    flex: 1;
}

.mw-level-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #5c4a32;
}

.mw-level-next {
    font-size: 0.78rem;
    color: #b8a890;
    margin-top: 4px;
}

.mw-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.mw-stat-box {
    text-align: center;
    padding: 16px 8px;
    background: #fffdf7;
    border: 1px solid #e8dcc8;
    border-radius: 16px;
}

.mw-stat-num {
    font-size: 1.4rem;
    font-weight: 800;
    color: #5c4a32;
}

.mw-stat-desc {
    font-size: 0.68rem;
    color: #b8a890;
    margin-top: 4px;
}

.mw-progress-bar-wrap {
    background: #fffdf7;
    border: 1px solid #e8dcc8;
    border-radius: 16px;
    padding: 16px;
}

.mw-progress-bar-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: #5c4a32;
    margin-bottom: 8px;
}

.mw-progress-bar {
    height: 12px;
    background: #f0e8d8;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.mw-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #e8b878, #d4a853);
    border-radius: 6px;
    transition: width 0.8s ease;
}

.mw-progress-tip {
    font-size: 0.7rem;
    color: #c4b898;
    text-align: center;
}

/* ---- 手機響應 ---- */
@media (max-width: 768px) {
    .mw-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-xl {
        width: 96vw;
    }

    .mw-history-toolbar {
        flex-direction: column;
    }
}

/* =========================================================
   RESPONSIVE PET
   ========================================================= */
@media (max-width: 768px) {
    .pet-widget {
        bottom: 10px;
        right: 10px;
        padding: 8px 10px;
        gap: 6px;
    }
    .pet-avatar { width: 36px; height: 36px; }
    .pet-emoji { font-size: 1.3rem; }
    .pet-panel { width: 95vw; }
    .match-grid { grid-template-columns: repeat(3, 1fr); }
    .shop-grid { grid-template-columns: repeat(2, 1fr); }
    .skit-stage { padding: 16px 10px; }
}

/* =========================================================
   ENHANCED VOCAB (My World tab)
   ========================================================= */
.mw-vocab-header {
    text-align: center;
    margin-bottom: 16px;
}
.mw-vocab-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}
.mw-vocab-header h3 small {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}
.mw-vocab-lang-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin: 0;
}

.mw-vocab-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.mw-stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    text-align: center;
}
.mw-stat-num {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.mw-stat-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Review section */
.mw-review-section {
    background: linear-gradient(135deg, rgba(212, 168, 96, 0.08), rgba(200, 160, 100, 0.04));
    border: 1px solid rgba(212, 168, 96, 0.2);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 16px;
}
.mw-review-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-orange);
    margin-bottom: 10px;
}
.mw-review-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mw-review-word {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}
.mw-review-pair {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.mw-review-en {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}
.mw-review-tr {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.mw-review-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.mw-review-ok, .mw-review-no {
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.75rem;
    font-family: inherit;
    transition: var(--transition);
    background: var(--bg-primary);
    color: var(--text-secondary);
}
.mw-review-ok:hover {
    background: rgba(160, 184, 152, 0.15);
    border-color: var(--accent-green);
    color: var(--accent-green);
}
.mw-review-no:hover {
    background: rgba(212, 160, 168, 0.15);
    border-color: var(--accent-pink);
    color: var(--accent-pink);
}

/* Vocab search */
.mw-vocab-search {
    margin-bottom: 10px;
}
.mw-vocab-search-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-primary);
    font-family: inherit;
    transition: var(--transition);
}
.mw-vocab-search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(160, 184, 208, 0.15);
}

/* Vocab list */
.mw-vocab-list-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.mw-vocab-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 400px;
    overflow-y: auto;
}
.mw-vocab-word {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.mw-vocab-word:hover {
    border-color: var(--accent-blue);
}
.mw-vocab-word.mastered {
    border-left: 3px solid var(--accent-green);
    opacity: 0.85;
}
.mw-vocab-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}
.mw-vocab-en {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}
.mw-vocab-tr {
    font-size: 0.8rem;
    color: var(--accent-purple);
    font-weight: 500;
}
.mw-vocab-meta {
    display: flex;
    gap: 12px;
    font-size: 0.65rem;
}
.mw-vocab-stage {
    color: var(--text-muted);
}
.mw-vocab-source {
    color: var(--text-muted);
    font-style: italic;
}
.mw-vocab-word.mastered .mw-vocab-en {
    color: var(--accent-green);
}

.mw-empty p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

@media (max-width: 768px) {
    .mw-vocab-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .mw-review-word {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* =========================================================
   SETTINGS BUTTON (Header)
   ========================================================= */
.settings-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    font-family: inherit;
    line-height: 1.3;
    text-align: center;
}
.settings-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}
.settings-btn small {
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* =========================================================
   SETTINGS MODAL
   ========================================================= */
.settings-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 16px 20px;
}
.settings-group {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}
.settings-group-title {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}
.settings-group-title small {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}
.settings-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 6px;
}

/* Language grid */
.settings-lang-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.settings-lang-btn {
    padding: 8px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: var(--transition);
}
.settings-lang-btn:hover {
    background: var(--bg-hover);
}
.settings-lang-btn.active {
    background: rgba(160, 184, 208, 0.2);
    border-color: var(--accent-blue);
    color: var(--text-primary);
    font-weight: 600;
}

/* Select */
.settings-select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
}

/* Difficulty grid */
.settings-diff-grid {
    display: flex;
    gap: 8px;
}
.settings-diff-btn {
    flex: 1;
    padding: 10px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: var(--transition);
    text-align: center;
    line-height: 1.3;
}
.settings-diff-btn:hover {
    background: var(--bg-hover);
}
.settings-diff-btn.active {
    background: rgba(160, 184, 152, 0.2);
    border-color: var(--accent-green);
    color: var(--text-primary);
    font-weight: 600;
}
.settings-diff-btn small {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* Accent row */
.settings-accent-row {
    display: flex;
    gap: 8px;
}
.settings-accent-btn {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: var(--transition);
}
.settings-accent-btn:hover {
    background: var(--bg-hover);
}
.settings-accent-btn.active {
    background: rgba(212, 168, 96, 0.2);
    border-color: var(--accent-orange);
    color: var(--text-primary);
    font-weight: 600;
}

/* Persona grid */
.settings-persona-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.settings-persona-btn {
    padding: 10px 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: var(--transition);
    text-align: center;
    line-height: 1.3;
}
.settings-persona-btn:hover {
    background: var(--bg-hover);
}
.settings-persona-btn.active {
    background: rgba(200, 176, 200, 0.2);
    border-color: var(--accent-purple);
    color: var(--text-primary);
    font-weight: 600;
}
.settings-persona-btn small {
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* Voice row */
.settings-voice-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}
.settings-voice-btn {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: var(--transition);
}
.settings-voice-btn:hover {
    background: var(--bg-hover);
}
.settings-voice-btn.active {
    background: rgba(200, 176, 200, 0.2);
    border-color: var(--accent-purple);
    color: var(--text-primary);
    font-weight: 600;
}
.settings-speed {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.settings-speed label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.settings-speed strong {
    color: var(--text-primary);
}
.settings-speed input[type="range"] {
    width: 100%;
    accent-color: var(--accent-purple);
}

/* Save button */
#settingsSaveBtn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-weight: 700;
}

/* =========================================================
   SCENE PICKER (Header)
   ========================================================= */
.header-scene-picker {
    position: relative;
    z-index: 50;
}
.header-scene-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--text-primary);
    white-space: nowrap;
}
.header-scene-btn:hover {
    border-color: var(--accent-orange);
}
.header-scene-btn .scene-picker-icon {
    font-size: 1.2rem;
}
.header-scene-btn .scene-picker-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
    line-height: 1.3;
}
.header-scene-btn .scene-picker-label small {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 400;
}
.header-scene-btn .scene-picker-arrow {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.header-scene-btn.open .scene-picker-arrow {
    transform: rotate(180deg);
}

/* Scene dropdown */
.scene-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 220px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 200;
    animation: fadeIn 0.15s ease;
}
.scene-pick-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    color: var(--text-secondary);
    text-align: left;
    white-space: nowrap;
}
.scene-pick-item:last-child { border-bottom: none; }
.scene-pick-item:hover { background: var(--bg-hover); }
.scene-pick-item.active {
    background: rgba(212, 168, 96, 0.12);
    color: var(--text-primary);
}
.scene-pick-item .scene-icon { font-size: 1.2rem; }
.scene-pick-item .scene-name { font-size: 0.82rem; font-weight: 600; }
.scene-pick-item .scene-en { font-size: 0.68rem; color: var(--text-muted); margin-left: auto; }

@media (max-width: 768px) {
    .settings-persona-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =========================================================
   CURRICULUM SIDEBAR
   ========================================================= */
.curriculum-sidebar { padding: 6px 0; }
.cur-level-badge { display:inline-block;padding:3px 10px;border-radius:10px;font-size:0.7rem;font-weight:700;color:#fff;background:#a0c8a0;margin-bottom:4px; }
.cur-unit-name { font-size:0.85rem;font-weight:600;color:var(--text-primary);margin-bottom:8px; }
.cur-progress-mini { margin-bottom:8px; }
.cur-progress-bar { height:5px;background:#e8e4d8;border-radius:3px;overflow:hidden;margin-bottom:3px; }
.cur-progress-fill { height:100%;background:linear-gradient(90deg,#a0c8a0,#7a9a6a);border-radius:3px;transition:width .5s ease; }
.cur-progress-text { font-size:0.65rem;color:var(--text-muted); }
.cur-vocab-label { display:block;font-size:0.65rem;color:var(--text-muted);margin-bottom:3px; }
.cur-vocab-words { display:flex;flex-wrap:wrap;gap:3px; }
.cur-vocab-words span { padding:2px 7px;background:rgba(160,200,160,0.15);border-radius:8px;color:#5a8a5a;font-size:0.65rem;font-weight:500; }

/* =========================================================
   LESSONS SYSTEM（互動課程）
   ========================================================= */
.lesson-categories {
    display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}
.lesson-cat-btn {
    padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 20px; cursor: pointer; font-size: 0.78rem; font-family: inherit;
    color: var(--text-secondary); transition: var(--transition); white-space: nowrap;
}
.lesson-cat-btn:hover { background: var(--bg-hover); border-color: var(--accent-blue); }
.lesson-cat-btn.active { background: rgba(160,184,152,0.18); border-color: var(--accent-green); color: #5a8a5a; font-weight: 600; }

.lesson-grid { display: flex; flex-direction: column; gap: 8px; }
.lesson-card {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 16px; background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); cursor: pointer; transition: var(--transition);
}
.lesson-card:hover { border-color: var(--accent-blue); background: #fafaf7; }
.lesson-card-icon { font-size: 2rem; flex-shrink: 0; width: 44px; text-align: center; }
.lesson-card-body { flex: 1; min-width: 0; }
.lesson-card-title { font-size: 0.9rem; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; }
.lesson-card-summary { font-size: 0.75rem; color: var(--text-secondary); line-height: 1.4; margin-bottom: 4px; }
.lesson-card-meta { display: flex; align-items: center; gap: 6px; font-size: 0.68rem; color: var(--text-muted); }

/* Lesson detail */
.lesson-detail { padding: 4px 0; }
.lesson-detail-header {
    display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
    padding-bottom: 12px; border-bottom: 1px solid var(--border-color);
}
.lesson-detail-icon { font-size: 2rem; }
.lesson-detail-header h2 { font-size: 1.1rem; margin: 0; color: var(--text-primary); }
.lesson-detail-header .en { font-size: 0.75rem; color: var(--text-muted); margin: 2px 0 0; }

.lesson-section {
    margin-bottom: 16px; padding: 14px; background: var(--bg-card);
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
}
.lesson-section h3 { font-size: 0.85rem; color: var(--text-primary); margin-bottom: 10px; }
.lesson-section h3 small { font-size: 0.7rem; color: var(--text-muted); font-weight: 400; }
.lesson-content { font-size: 0.8rem; line-height: 1.8; color: var(--text-secondary); }
.lesson-content b { color: var(--text-primary); }

.lesson-vocab-list { display: flex; flex-wrap: wrap; gap: 6px; }
.lesson-vocab-tag {
    padding: 4px 10px; background: rgba(160,184,208,0.12); border-radius: 12px;
    font-size: 0.72rem; color: var(--accent-blue); font-weight: 500;
}

.lesson-phrase-card {
    padding: 8px 12px; margin-bottom: 6px; background: var(--bg-primary);
    border-radius: var(--radius-sm); border-left: 3px solid var(--accent-green);
}
.lpc-en { font-size: 0.82rem; font-weight: 600; color: var(--text-primary); }
.lpc-zh { font-size: 0.72rem; color: var(--text-secondary); margin-top: 2px; }
.lpc-note { font-size: 0.65rem; color: var(--accent-green); margin-top: 2px; font-style: italic; }

@media (max-width: 768px) {
    .lesson-categories { gap: 4px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
    .lesson-cat-btn { padding: 6px 12px; font-size: 0.7rem; flex-shrink: 0; }
    .lesson-card { padding: 10px 12px; gap: 10px; }
    .lesson-cat-btn { padding: 5px 10px; font-size: 0.7rem; }
}

/* =========================================================
   📱 RESPONSIVE — iPad & Mobile
   ========================================================= */

/* Sidebar toggle button (hidden on desktop) */
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px 8px;
    color: var(--text-primary);
    border-radius: 8px;
}

/* =========================================================
   MOBILE BOTTOM NAV
   ========================================================= */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 600;
    background: #fffefb;
    border-top: 1px solid var(--border-color);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: center;
}
.mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    font-family: inherit;
    color: var(--text-muted);
    transition: color 0.2s;
}
.mobile-nav-btn:active { color: var(--text-primary); }
.mobile-nav-icon { font-size: 1.3rem; }
.mobile-nav-label { font-size: 0.55rem; font-weight: 500; }

/* Center mic button */
.mobile-nav-btn.mic-trigger {
    position: relative;
    margin-top: -18px;
}
.mobile-mic-ring {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--gradient-main);
    box-shadow: 0 4px 16px rgba(212, 168, 96, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}
.mobile-mic-ring:active {
    transform: scale(0.92);
    box-shadow: 0 2px 8px rgba(212, 168, 96, 0.6);
}
.mobile-mic-icon {
    font-size: 1.4rem;
}
.mobile-nav-btn.mic-trigger .mobile-nav-label {
    margin-top: 2px;
}

/* iPad Pro (1024px+) — 縮窄 sidebar */
@media (max-width: 1199px) and (min-width: 769px) {
    .main-layout { grid-template-columns: 180px 1fr; }
    .sidebar { padding: 12px 10px; }
    .header { padding: 10px 14px; flex-wrap: wrap; gap: 6px; }
    .header-brand { gap: 6px; }
    .header-title { font-size: 1.1rem; }
    .header-subtitle { font-size: 0.65rem; }
    .settings-btn, .premium-btn, .my-world-btn { padding: 6px 8px; font-size: 0.7rem; }
    .header-scene-btn { padding: 6px 8px; }
    .stat-badge { font-size: 0.65rem; padding: 4px 10px; }
}

/* Safe area padding for notched phones */
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* iPad / Tablet (≤768px) — 單欄佈局，sidebar 可摺疊 */
@media (max-width: 768px) {
    .sidebar-toggle { display: block; }
    .mobile-nav { display: flex; }
    .pet-widget { bottom: 80px; }
    .header-scene-picker { display: none; }
    .main-layout { padding-bottom: 60px; }
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: calc(100vh - 56px);
    }

    /* Sidebar → overlay 左邊拉出 */
    .sidebar {
        position: fixed;
        top: 56px;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 85vw;
        z-index: 500;
        background: var(--bg-secondary);
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        flex-direction: column;
        overflow-y: auto;
        padding: 16px;
        gap: 14px;
        border-right: 1px solid var(--border-color);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 499;
        background: rgba(0,0,0,0.3);
    }
    .sidebar-backdrop.open { display: block; }
    .main-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: calc(100vh - 56px);
    }

    /* Sidebar → 水平快捷欄 */
    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px 10px;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        max-height: 100px;
    }
    .sidebar-divider { display: none; }
    .sidebar-label { font-size: 0.65rem; margin-bottom: 2px; }
    .sidebar-label small { display: none; }
    .daily-challenge { flex: 1; min-width: 140px; padding: 6px 8px; }
    .challenge-text { font-size: 0.7rem; margin: 2px 0; }
    .challenge-btn { padding: 4px 12px; font-size: 0.7rem; }
    .vocab-big-btn, .vocab-tracker { display: none; }
    .curriculum-sidebar { flex: 1; min-width: 120px; padding: 0; }
    .cur-unit-name { font-size: 0.72rem; margin-bottom: 2px; }
    .cur-vocab-words { display: none; }
    .ielts-exam-section { flex: 0; min-width: 100px; }
    .ielts-exam-btn { font-size: 0.7rem; padding: 6px 10px; }

    /* Header */
    .header {
        padding: 8px 10px;
        flex-wrap: wrap;
        gap: 4px;
        position: sticky;
        top: 0;
    }
    .header-brand { gap: 4px; }
    .header-icon { font-size: 1.4rem; }
    .header-title { font-size: 1rem; }
    .header-subtitle { display: none; }
    .header-right { gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
    .settings-btn, .premium-btn, .my-world-btn {
        padding: 5px 7px;
        font-size: 0.65rem;
        border-radius: 8px;
    }
    .settings-btn small, .my-world-btn small { display: none; }
    .login-btn { padding: 5px 7px; }
    .login-text small { display: none; }
    .stat-badge { font-size: 0.6rem; padding: 3px 7px; }
    .header-scene-btn { padding: 5px 7px; font-size: 0.7rem; }
    .header-scene-btn .scene-picker-label { font-size: 0.65rem; }

    /* Chat area */
    .chat-messages { padding: 12px; gap: 10px; }
    .message { max-width: 92%; }
    .msg-avatar { width: 30px; height: 30px; font-size: 1rem; }
    .msg-text p { font-size: 0.8rem; }
    .msg-text p.en { font-size: 0.75rem; }

    /* Voice controls */
    .voice-controls { padding: 10px 12px; gap: 8px; }
    .voice-buttons { gap: 8px; }
    .mic-btn { width: 62px; height: 62px; }
    .mic-icon { font-size: 1.5rem; }
    .mic-label { font-size: 0.55rem; }
    .speak-btn, .clear-btn { padding: 8px 12px; font-size: 0.7rem; }
    .mode-toggle-btn { padding: 6px 8px; font-size: 0.65rem; }
    .phone-btn { padding: 6px 10px; }

    /* Scene picker dropdown */
    .scene-picker-dropdown {
        right: 0;
        left: auto;
        min-width: 180px;
    }
    .scene-pick-item { padding: 8px 10px; }
    .scene-pick-item .scene-name { font-size: 0.72rem; }
    .scene-pick-item .scene-en { font-size: 0.6rem; }

    /* Modals full screen */
    .modal-content {
        width: 95vw;
        max-width: 95vw;
        max-height: 90vh;
        border-radius: 14px;
    }
    .modal-header { padding: 14px 16px; }
    .modal-header h2 { font-size: 1rem; }
    .modal-body { padding: 12px 14px; }
    .modal-xl { width: 96vw; max-width: 96vw; }

    /* Settings */
    .settings-body { padding: 10px 12px; gap: 12px; }
    .settings-group { padding: 10px 12px; }
    .settings-persona-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-lang-grid { gap: 4px; }
    .settings-lang-btn { padding: 6px 10px; font-size: 0.7rem; }

    /* My World */
    .myworld-tabs { flex-wrap: wrap; gap: 3px; }
    .myworld-tab { font-size: 0.68rem; padding: 6px 10px; }

    /* Pet widget */
    .pet-widget {
        bottom: 8px;
        right: 8px;
        padding: 6px 8px;
        gap: 4px;
    }
    .pet-avatar { width: 30px; height: 30px; }
    .pet-emoji { font-size: 1.1rem; }
    .pet-panel { width: 95vw; }
    .pet-panel-body { padding: 10px; }

    /* Charts */
    .pa-charts-row { flex-direction: column; align-items: center; }
    .pa-bars-wrap { width: 100%; }
    .pa-radar-wrap canvas { max-width: 200px; }

    /* History */
    .mw-history-toolbar { flex-direction: column; gap: 6px; }
    .mw-history-search, .mw-history-filter { width: 100%; }

    /* Games/Skits */
    .game-select-grid { grid-template-columns: repeat(2, 1fr); }
    .match-grid { grid-template-columns: repeat(3, 1fr); }
    .shop-grid { grid-template-columns: repeat(2, 1fr); }
    .skit-stage { padding: 12px 8px; }
    .skit-dialogue-box { font-size: 0.8rem; }

    /* Progress */
    .mw-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .pa-stats-grid { grid-template-columns: repeat(2, 1fr); }

    /* Vocab */
    .mw-vocab-stats { grid-template-columns: repeat(2, 1fr); }
    .mw-review-word { flex-direction: column; align-items: flex-start; }
    .mw-vocab-list { max-height: 250px; }

    /* Pet panel */
    .pet-actions { flex-wrap: wrap; gap: 4px; }
    .pet-action-btn { padding: 6px 10px; font-size: 0.7rem; }
}

/* Phone (≤480px) — 極簡：只有對話 + 一個掣 */
@media (max-width: 480px) {
    html { font-size: 14px; }
    body { background: #fdfaf5; }

    .main-layout {
        display: flex;
        flex-direction: column;
        height: 100dvh;
        padding-bottom: 0;
    }

    /* === Header: 一條幼線，只顯示場景名 + menu === */
    .header {
        padding: 6px 12px;
        gap: 6px;
        flex-shrink: 0;
        background: #fffefb;
        border-bottom: 1px solid var(--border-color);
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    .header-brand { gap: 4px; flex: 1; min-width: 0; }
    .header-icon { font-size: 1.1rem; display: none; }
    .header-title { font-size: 0.85rem; white-space: nowrap; }
    .header-subtitle { display: none; }

    /* Hide EVERYTHING in header-right */
    .header-right { display: none; }

    /* Show only: hamburger */
    .sidebar-toggle {
        display: block;
        font-size: 1.2rem;
        padding: 2px 6px;
    }

    /* Scene indicator as a simple pill in header */
    .header-scene-picker {
        display: flex !important;
        margin: 0 6px;
    }
    .header-scene-btn {
        padding: 3px 8px;
        border-radius: 12px;
        font-size: 0.7rem;
        gap: 4px;
        border: none;
        background: rgba(212,168,96,0.1);
    }
    .header-scene-btn .scene-picker-icon { font-size: 1rem; }
    .header-scene-btn .scene-picker-label { font-size: 0.68rem; }
    .header-scene-btn .scene-picker-label small { font-size: 0.55rem; }
    .header-scene-btn .scene-picker-arrow { font-size: 0.55rem; }

    /* === Sidebar overlay === */
    .sidebar {
        top: 44px;
        width: 280px;
        max-width: 85vw;
        padding: 14px;
        gap: 12px;
        border-radius: 0 12px 12px 0;
        box-shadow: 8px 0 30px rgba(0,0,0,0.15);
    }

    /* === Chat: full space === */
    .chat-area {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    .chat-messages {
        flex: 1;
        padding: 10px 12px;
        gap: 10px;
        overflow-y: auto;
    }
    .message { max-width: 90%; }
    .message.coach { max-width: 86%; }
    .msg-avatar { width: 28px; height: 28px; font-size: 1rem; flex-shrink: 0; }
    .msg-content { padding: 8px 12px; }
    .msg-text p { font-size: 0.82rem; line-height: 1.5; margin-bottom: 2px; }
    .msg-text p.en { font-size: 0.76rem; }

    /* === Voice area: just the mic === */
    .voice-controls {
        padding: 8px 10px 12px;
        flex-shrink: 0;
        background: transparent;
        border-top: none;
    }
    .voice-status { display: none; }
    .transcript-box { margin: 0 0 6px; padding: 6px 10px; font-size: 0.75rem; border-radius: 10px; }

    .voice-buttons {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    /* Only show mic + 1 small clear button */
    .mic-btn {
        width: 56px;
        height: 56px;
        border-width: 2px;
        flex-shrink: 0;
    }
    .mic-icon { font-size: 1.5rem; }
    .mic-label { font-size: 0.5rem; display: block; }
    .speak-btn { padding: 8px 12px; font-size: 0.7rem; border-radius: 16px; }
    .clear-btn { padding: 6px 8px; font-size: 0.65rem; border-radius: 16px; border: none; background: transparent; color: var(--text-muted); }
    .mode-toggle-btn, .phone-btn { display: none; }

    /* === Bottom nav: hide it === */
    .mobile-nav { display: none !important; }

    /* === Pet: tiny floating ball, bottom right above mic === */
    .pet-widget {
        bottom: 76px;
        right: 10px;
        padding: 4px;
        gap: 0;
        border-radius: 20px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.08);
        background: rgba(255,255,255,0.9);
    }
    .pet-status-mini { display: none; }
    .pet-coins-mini { display: none; }
    .pet-speech-bubble { display: none !important; }
    .pet-avatar { width: 32px; height: 32px; }
    .pet-emoji { font-size: 1.3rem; }
    .pet-expand-btn { display: none; }
    .pet-widget:active { transform: scale(0.9); }

    /* === Modals: fullscreen === */
    .modal-content {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .modal-header { padding: 14px 16px; }
    .modal-header h2 { font-size: 1rem; }
    .modal-close { font-size: 1.3rem; }
    .modal-body { padding: 12px 14px; }

    /* Scene dropdown */
    .scene-picker-dropdown {
        position: fixed;
        top: 44px;
        left: 8px;
        right: 8px;
        border-radius: 14px;
        box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    }
    .scene-pick-item { padding: 12px 14px; }
    .scene-pick-item .scene-name { font-size: 0.85rem; }

    /* Hide misc */
    .stat-badge, .xp-badge, .premium-btn, .login-btn { display: none !important; }

    /* Misc compact */
    .game-select-grid { grid-template-columns: 1fr 1fr; }
    .match-grid { grid-template-columns: repeat(2, 1fr); }
    .settings-persona-grid { grid-template-columns: 1fr 1fr; }
    .mw-stats-grid, .pa-stats-grid, .mw-vocab-stats { grid-template-columns: 1fr 1fr; }
    .pa-charts-row { flex-direction: column; }
    .pa-radar-wrap canvas { max-width: 160px; }
    .pet-panel { width: 100vw; }
}
