/* ============================================
   FluentMaster - Main Stylesheet
   Premium English Learning App
   ============================================ */

:root {
    --primary: #6C63FF;
    --primary-dark: #5A52D5;
    --primary-light: #8B83FF;
    --secondary: #10B981;
    --secondary-dark: #059669;
    --accent: #F59E0B;
    --danger: #EF4444;
    --danger-light: #FCA5A5;
    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --bg-dark: #0F172A;
    --text: #1E293B;
    --text-secondary: #64748B;
    --text-light: #94A3B8;
    --border: #E2E8F0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --header-height: 56px;
    --bottom-nav-height: 64px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Nunito', 'Inter', sans-serif;
}

/* Dark Mode */
body.dark-mode {
    --bg: #0F172A;
    --bg-card: #1E293B;
    --text: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-light: #64748B;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
}

/* ============= RESET ============= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea, select { font-family: inherit; font-size: 1rem; }
img { max-width: 100%; display: block; }

/* ============= SPLASH SCREEN ============= */
.splash-screen {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #6C63FF 0%, #8B5CF6 50%, #A78BFA 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.splash-screen.hide {
    opacity: 0;
    transform: scale(1.1);
    pointer-events: none;
}

.splash-content {
    text-align: center;
    color: white;
}

.splash-logo {
    width: 100px;
    height: 100px;
    background: rgba(255,255,255,0.2);
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 3rem;
    animation: pulse-splash 2s ease infinite;
}

@keyframes pulse-splash {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.splash-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.splash-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}

.splash-loader {
    width: 200px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
}

.loader-bar {
    width: 40%;
    height: 100%;
    background: white;
    border-radius: 2px;
    animation: loader-move 1.5s ease infinite;
}

@keyframes loader-move {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* ============= APP LAYOUT ============= */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* ============= HEADER ============= */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: var(--text);
    font-size: 1.1rem;
    transition: var(--transition);
}

.header-btn:hover { background: var(--border); }

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
}

.header-logo i { font-size: 1.3rem; }

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

.header-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    font-size: 0.9rem;
}

.header-stat i {
    font-size: 1rem;
}

#header-streak i { color: #F59E0B; }
#header-xp i { color: var(--primary); }

.header-level-badge {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
}

#level-badge { color: white; }

/* ============= SIDE MENU ============= */
.side-menu-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.side-menu-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.side-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100%;
    background: var(--bg-card);
    z-index: 300;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.side-menu.active { left: 0; }

.side-menu-header {
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
    color: white;
    text-align: center;
}

.user-avatar {
    width: 64px;
    height: 64px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
    font-size: 1.5rem;
}

.side-menu-header h3 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.side-menu-header p {
    font-size: 0.85rem;
    opacity: 0.9;
}

.side-menu-list {
    list-style: none;
    padding: 0.5rem 0;
    flex: 1;
}

.side-menu-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 1.5rem;
    color: var(--text);
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.side-menu-list li:hover,
.side-menu-list li.active {
    background: var(--primary);
    color: white;
}

.side-menu-list li i {
    width: 24px;
    text-align: center;
    font-size: 1rem;
}

.side-menu-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

.btn-reset {
    width: 100%;
    padding: 10px;
    color: var(--danger);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-reset:hover { background: rgba(239,68,68,0.1); }

/* ============= MAIN CONTENT ============= */
.main-content {
    margin-top: var(--header-height);
    padding-bottom: calc(var(--bottom-nav-height) + 16px);
    min-height: calc(100vh - var(--header-height));
    flex: 1;
}

.page {
    display: none;
    padding: 1rem;
    animation: fadeInUp 0.3s ease;
}

.page.active { display: block; }

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

/* ============= BOTTOM NAV ============= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    color: var(--text-light);
    font-size: 0.7rem;
    font-weight: 600;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    position: relative;
}

.nav-item i { font-size: 1.2rem; }

.nav-item.active {
    color: var(--primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
}

/* ============= BUTTONS ============= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 4px 12px rgba(108,99,255,0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(108,99,255,0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: white;
}

.btn-ghost {
    color: var(--text-secondary);
    padding: 10px 16px;
}

.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.05rem;
    border-radius: var(--radius-lg);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text);
    font-size: 1.1rem;
    transition: var(--transition);
}

.btn-icon:hover { background: var(--border); }

.btn-round {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 1.3rem;
    padding: 0;
}

/* ============= WELCOME PAGE ============= */
.welcome-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    padding: 1rem 0;
}

.welcome-hero {
    margin-bottom: 2rem;
}

.welcome-icon-big {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary), #A78BFA);
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    margin: 0 auto 1.5rem;
    box-shadow: 0 10px 30px rgba(108,99,255,0.3);
}

.welcome-hero h1 {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary), #A78BFA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-hero p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.welcome-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 2rem;
}

.welcome-feature {
    background: var(--bg-card);
    padding: 1.25rem 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.welcome-feature i {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.welcome-feature h3 {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.welcome-feature p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.welcome-name-input {
    margin-bottom: 1.5rem;
}

.welcome-name-input label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.welcome-name-input input {
    width: 100%;
    max-width: 300px;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 1rem;
    text-align: center;
    transition: var(--transition);
}

.welcome-name-input input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.welcome-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.welcome-actions .btn { width: 100%; max-width: 320px; }

/* ============= PLACEMENT TEST ============= */
.placement-container {
    max-width: 600px;
    margin: 0 auto;
}

.placement-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.placement-header h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.placement-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.placement-progress {
    margin-bottom: 0.5rem;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: width 0.4s ease;
    width: 0%;
}

#placement-progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.placement-question-area {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    min-height: 300px;
}

.pq-category {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.pq-question {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.pq-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pq-option {
    padding: 14px 16px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    text-align: left;
    transition: var(--transition);
    color: var(--text);
    cursor: pointer;
}

.pq-option:hover {
    border-color: var(--primary);
    background: rgba(108,99,255,0.05);
}

.pq-option.selected {
    border-color: var(--primary);
    background: rgba(108,99,255,0.1);
    color: var(--primary);
    font-weight: 600;
}

.pq-option.correct {
    border-color: var(--secondary);
    background: rgba(16,185,129,0.1);
    color: var(--secondary);
}

.pq-option.wrong {
    border-color: var(--danger);
    background: rgba(239,68,68,0.1);
    color: var(--danger);
}

.placement-nav {
    text-align: center;
    margin-top: 1rem;
}

/* ============= RESULT PAGE ============= */
.result-container {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.result-celebration {
    padding: 2rem 0;
    position: relative;
}

.result-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #F59E0B, #D97706);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    margin: 0 auto 1rem;
    animation: bounce-in 0.6s ease;
}

@keyframes bounce-in {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.result-level-display {
    margin: 1.5rem 0;
}

.result-level {
    display: block;
    font-size: 4rem;
    font-weight: 900;
    font-family: var(--font-display);
    background: linear-gradient(135deg, var(--primary), #A78BFA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-level-name {
    display: block;
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.result-description {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.result-breakdown {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 2rem;
}

.rb-item {
    background: var(--bg);
    padding: 12px 8px;
    border-radius: var(--radius-sm);
}

.rb-item .rb-score {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.rb-item .rb-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: block;
}

/* ============= HOME DASHBOARD ============= */
.home-container {
    max-width: 600px;
    margin: 0 auto;
}

.home-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
    border: 1px solid var(--border);
}

.daily-goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.daily-goal-header h3 {
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.daily-goal-header h3 i { color: var(--accent); }
.daily-goal-header span { font-size: 0.9rem; color: var(--text-secondary); }

.daily-goal-bar {
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
}

.daily-goal-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), #34D399);
    border-radius: 5px;
    transition: width 0.5s ease;
    width: 0%;
}

.home-section {
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.quick-action-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
    text-align: left;
    width: 100%;
    color: var(--text);
}

.quick-action-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.qa-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.qa-text {
    flex: 1;
}

.qa-text strong { display: block; font-size: 0.9rem; }
.qa-text span { font-size: 0.8rem; color: var(--text-secondary); }

.quick-action-card > i:last-child {
    color: var(--text-light);
    font-size: 0.8rem;
}

/* Skills Grid */
.skills-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.skill-card {
    background: var(--bg-card);
    padding: 12px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.skill-icon {
    font-size: 1.2rem;
    color: var(--primary);
    margin-bottom: 6px;
}

.skill-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 6px;
}

.skill-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.skill-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.achievements-preview {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    padding: 1rem;
}

/* ============= LESSONS PATH ============= */
.lessons-container {
    max-width: 600px;
    margin: 0 auto;
}

.lessons-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.lessons-header h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.level-selector {
    display: flex;
    gap: 4px;
    justify-content: center;
    background: var(--border);
    padding: 4px;
    border-radius: var(--radius);
    flex-wrap: wrap;
}

.level-tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: var(--transition);
    min-width: 44px;
}

.level-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow);
}

.level-tab.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.lessons-path {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 1rem 0;
}

.lesson-node {
    width: 100%;
    max-width: 360px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 2px solid var(--border);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.lesson-node:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
}

.lesson-node.completed {
    border-color: var(--secondary);
}

.lesson-node.current {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.lesson-node.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.lesson-node.locked:hover { transform: none; }

.lesson-node-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.lesson-node.completed .lesson-node-icon {
    background: linear-gradient(135deg, var(--secondary), #34D399);
}

.lesson-node.locked .lesson-node-icon {
    background: var(--text-light);
}

.lesson-node-info {
    flex: 1;
}

.lesson-node-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.lesson-node-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.lesson-node-badge {
    font-size: 1.2rem;
}

.lesson-node.completed .lesson-node-badge::after { content: '✅'; }
.lesson-node.current .lesson-node-badge::after { content: '▶️'; }
.lesson-node.locked .lesson-node-badge::after { content: '🔒'; }

/* Connector lines */
.lesson-connector {
    width: 2px;
    height: 20px;
    background: var(--border);
    margin: -8px 0;
}

/* ============= ACTIVE LESSON ============= */
.active-lesson-container {
    max-width: 600px;
    margin: 0 auto;
}

.lesson-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.lesson-progress-wrapper { flex: 1; }

.lesson-progress-bar {
    height: 10px;
    background: var(--border);
    border-radius: 5px;
    overflow: hidden;
}

.lesson-hearts {
    display: flex;
    gap: 4px;
    color: var(--danger);
    font-size: 1.1rem;
}

.lesson-hearts .lost { color: var(--text-light); }

.lesson-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    min-height: 350px;
}

.exercise-type {
    display: inline-block;
    background: rgba(108,99,255,0.1);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.exercise-instruction {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.exercise-prompt {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.exercise-prompt .highlight {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-style: wavy;
    cursor: pointer;
}

/* Answer Options */
.answer-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.answer-option {
    padding: 14px 16px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    text-align: left;
    transition: var(--transition);
    color: var(--text);
}

.answer-option:hover { border-color: var(--primary-light); }
.answer-option.selected { border-color: var(--primary); background: rgba(108,99,255,0.08); }
.answer-option.correct { border-color: var(--secondary); background: rgba(16,185,129,0.1); color: var(--secondary-dark); }
.answer-option.wrong { border-color: var(--danger); background: rgba(239,68,68,0.1); }

/* Text Input Exercise */
.exercise-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.05rem;
    background: var(--bg);
    color: var(--text);
    transition: var(--transition);
}

.exercise-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.exercise-submit {
    margin-top: 1rem;
    width: 100%;
}

/* Word Bank */
.word-bank {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 1rem;
}

.word-chip {
    padding: 8px 16px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    color: var(--text);
}

.word-chip:hover { border-color: var(--primary); }
.word-chip.used { opacity: 0.3; pointer-events: none; }

.word-answer-area {
    min-height: 50px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1rem;
}

.word-answer-chip {
    padding: 6px 14px;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.word-answer-chip:hover { background: var(--danger); }

/* Lesson Feedback Bar */
.lesson-feedback {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.feedback-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 1.25rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    text-align: center;
}

.feedback-content.correct {
    background: #ECFDF5;
    border-top: 3px solid var(--secondary);
}

.feedback-content.wrong {
    background: #FEF2F2;
    border-top: 3px solid var(--danger);
}

body.dark-mode .feedback-content.correct { background: #064E3B; }
body.dark-mode .feedback-content.wrong { background: #7F1D1D; }

.feedback-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.feedback-content.correct .feedback-icon { color: var(--secondary); }
.feedback-content.wrong .feedback-icon { color: var(--danger); }

#feedback-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.25rem; }
#feedback-text { font-size: 0.9rem; color: var(--text-secondary); margin-bottom: 1rem; }

/* ============= LESSON COMPLETE ============= */
.lesson-complete-container {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
    padding: 2rem 0;
}

.lc-star-burst {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #F59E0B, #FBBF24);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    margin: 0 auto 1rem;
    animation: bounce-in 0.6s ease;
}

.lc-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 1.5rem 0;
}

.lc-stat {
    text-align: center;
}

.lc-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

.lc-stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.lc-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.lc-actions .btn { width: 100%; max-width: 300px; }

/* ============= PRACTICE PAGE ============= */
.practice-container, .listening-container {
    max-width: 600px;
    margin: 0 auto;
}

.practice-container h2, .listening-container h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.practice-modes, .listening-modes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.practice-card {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.practice-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.pc-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    margin: 0 auto 0.75rem;
}

.practice-card h3 { font-size: 0.9rem; margin-bottom: 0.25rem; }
.practice-card p { font-size: 0.75rem; color: var(--text-secondary); }

/* Practice Active */
.practice-active-container, .listening-active-container {
    max-width: 600px;
    margin: 0 auto;
}

.practice-top-bar, .listening-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.practice-top-bar h3, .listening-top-bar h3 {
    flex: 1;
    font-size: 1.1rem;
}

.practice-score, #listening-score {
    font-weight: 700;
    color: var(--primary);
}

.practice-area, .listening-area {
    min-height: 300px;
}

/* ============= FLASHCARD ============= */
.flashcard-container {
    perspective: 1000px;
    margin: 2rem auto;
    max-width: 340px;
}

.flashcard {
    width: 100%;
    height: 220px;
    position: relative;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
    cursor: pointer;
}

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

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.flashcard-front {
    background: linear-gradient(135deg, var(--primary), #8B5CF6);
    color: white;
}

.flashcard-back {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    transform: rotateY(180deg);
}

.flashcard-word {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.flashcard-hint {
    font-size: 0.9rem;
    opacity: 0.8;
}

.flashcard-translation {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.flashcard-example {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

.flashcard-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.fc-btn {
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.fc-btn-wrong { background: rgba(239,68,68,0.1); color: var(--danger); }
.fc-btn-correct { background: rgba(16,185,129,0.1); color: var(--secondary); }

.fc-progress {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ============= CONVERSATION ============= */
.conversation-container {
    max-width: 600px;
    margin: 0 auto;
}

.conversation-container h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.scenario-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.scenario-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.scenario-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-md);
}

.scenario-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.scenario-info h3 { font-size: 0.95rem; margin-bottom: 2px; }
.scenario-info p { font-size: 0.8rem; color: var(--text-secondary); }

.scenario-level {
    margin-left: auto;
    padding: 4px 10px;
    background: rgba(108,99,255,0.1);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Active Conversation */
.conv-active-container {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height) - var(--bottom-nav-height) - 32px);
}

.conv-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.conv-partner {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.conv-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
}

.conv-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.conv-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    line-height: 1.5;
    animation: fadeInUp 0.3s ease;
}

.conv-message.bot {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.conv-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-bottom-right-radius: 4px;
}

.conv-message.system {
    align-self: center;
    background: rgba(245,158,11,0.1);
    color: var(--accent);
    font-size: 0.85rem;
    text-align: center;
    border-radius: 20px;
    padding: 8px 16px;
}

.conv-message .translation {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 6px;
    font-style: italic;
}

.conv-input-area {
    flex-shrink: 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.conv-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.suggestion-chip {
    padding: 6px 14px;
    background: rgba(108,99,255,0.1);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.suggestion-chip:hover { background: var(--primary); color: white; }

.conv-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.conv-input-row input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 24px;
    background: var(--bg);
    color: var(--text);
    font-size: 0.95rem;
}

.conv-input-row input:focus {
    outline: none;
    border-color: var(--primary);
}

.mic-btn {
    background: var(--danger) !important;
    color: white !important;
    width: 44px;
    height: 44px;
}

.mic-btn.recording {
    animation: pulse-record 1s ease infinite;
    box-shadow: 0 0 0 4px rgba(239,68,68,0.3);
}

@keyframes pulse-record {
    0%, 100% { box-shadow: 0 0 0 4px rgba(239,68,68,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(239,68,68,0.1); }
}

.send-btn {
    background: var(--primary) !important;
    color: white !important;
    width: 44px;
    height: 44px;
}

/* ============= VOCABULARY ============= */
.vocab-container {
    max-width: 600px;
    margin: 0 auto;
}

.vocab-container h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.vocab-stats-bar {
    display: flex;
    justify-content: space-around;
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.vocab-stat { text-align: center; }
.vocab-stat strong { display: block; font-size: 1.3rem; color: var(--primary); }
.vocab-stat span { font-size: 0.75rem; color: var(--text-secondary); }

.vocab-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1rem;
}

.vocab-cat-btn {
    padding: 6px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.vocab-cat-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.vocab-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}

.vocab-search i { color: var(--text-light); }

.vocab-search input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text);
    outline: none;
}

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

.vocab-word-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 12px 14px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.vocab-word-item:hover { border-color: var(--primary-light); }

.vw-word { flex: 1; font-weight: 600; }
.vw-translation { color: var(--text-secondary); font-size: 0.9rem; }
.vw-speak {
    color: var(--primary);
    font-size: 1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}
.vw-speak:hover { background: rgba(108,99,255,0.1); }

.vw-mastery {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.vw-mastery.new { background: var(--text-light); }
.vw-mastery.learning { background: var(--accent); }
.vw-mastery.mastered { background: var(--secondary); }

/* ============= PRONUNCIATION ============= */
.pronunciation-container {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

.pronunciation-container h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.pron-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-lg);
    margin: 1.5rem 0;
    border: 1px solid var(--border);
}

.pron-word {
    font-size: 2.5rem;
    font-weight: 800;
    font-family: var(--font-display);
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.pron-phonetic {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-style: italic;
}

.pron-translation {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 1.5rem;
}

.pron-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.pron-rec-btn {
    background: var(--danger) !important;
    box-shadow: 0 4px 12px rgba(239,68,68,0.3);
}

.pron-rec-btn.recording {
    animation: pulse-record 1s ease infinite;
}

.pron-result {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius);
    animation: fadeInUp 0.3s ease;
}

.pron-result.good {
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.3);
}

.pron-result.bad {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
}

.pron-result-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.pron-user-said { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.5rem; }

.pron-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
}

#pron-counter { font-weight: 600; color: var(--text-secondary); }

.pron-category-select {
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.pron-category-select label { font-weight: 600; font-size: 0.9rem; }

.pron-category-select select {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
}

/* ============= READING ============= */
.reading-container {
    max-width: 600px;
    margin: 0 auto;
}

.reading-container h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.reading-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reading-item {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.reading-item:hover { box-shadow: var(--shadow-md); transform: translateX(4px); }

.reading-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.5rem;
}

.reading-item h3 { font-size: 1rem; }

.reading-item-level {
    padding: 2px 10px;
    background: rgba(108,99,255,0.1);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.reading-item p { font-size: 0.85rem; color: var(--text-secondary); }

.reading-item-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

/* Active Reading */
.reading-active-container {
    max-width: 650px;
    margin: 0 auto;
}

.reading-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.reading-top-bar h3 { flex: 1; font-size: 1.1rem; }

.reading-text {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    line-height: 1.8;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.reading-text .clickable-word {
    cursor: pointer;
    border-bottom: 1px dashed var(--text-light);
    transition: var(--transition);
}

.reading-text .clickable-word:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.reading-questions {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.rq-question {
    margin-bottom: 1.25rem;
}

.rq-question h4 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

/* ============= WRITING ============= */
.writing-container {
    max-width: 600px;
    margin: 0 auto;
}

.writing-container h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.writing-prompts {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.writing-prompt-card {
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.writing-prompt-card:hover { border-color: var(--primary-light); transform: translateX(4px); }

.wp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.wp-type {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(108,99,255,0.1);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
}

.writing-prompt-card h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.writing-prompt-card p { font-size: 0.8rem; color: var(--text-secondary); }

/* Active Writing */
.writing-active-container {
    max-width: 650px;
    margin: 0 auto;
}

.writing-top-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.writing-prompt-display {
    background: linear-gradient(135deg, rgba(108,99,255,0.05), rgba(139,92,246,0.05));
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid rgba(108,99,255,0.2);
    margin-bottom: 1rem;
}

.writing-prompt-display h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.writing-prompt-display p { font-size: 0.9rem; color: var(--text-secondary); }

.writing-area textarea {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 160px;
    transition: var(--transition);
}

.writing-area textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

.writing-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
}

#writing-word-count { color: var(--text-secondary); font-size: 0.85rem; }

.writing-feedback {
    margin-top: 1rem;
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    animation: fadeInUp 0.3s ease;
}

.wf-score {
    display: inline-block;
    padding: 6px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border-radius: 20px;
    font-weight: 700;
    margin-bottom: 1rem;
}

.wf-section { margin-bottom: 1rem; }
.wf-section h4 { font-size: 0.9rem; margin-bottom: 0.5rem; color: var(--primary); }
.wf-section p { font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }

.wf-correction {
    padding: 8px 12px;
    background: rgba(239,68,68,0.05);
    border-left: 3px solid var(--danger);
    border-radius: 0 8px 8px 0;
    margin-bottom: 0.5rem;
}

.wf-correction .wrong-text { text-decoration: line-through; color: var(--danger); }
.wf-correction .correct-text { color: var(--secondary); font-weight: 600; }

/* ============= ACHIEVEMENTS ============= */
.achievements-container {
    max-width: 600px;
    margin: 0 auto;
}

.achievements-container h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.achievements-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.achievement-card {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.achievement-card.unlocked {
    border-color: #F59E0B;
    background: linear-gradient(135deg, rgba(245,158,11,0.05), rgba(217,119,6,0.05));
}

.achievement-card.locked { opacity: 0.5; }

.ach-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.achievement-card h4 { font-size: 0.85rem; margin-bottom: 0.25rem; }
.achievement-card p { font-size: 0.7rem; color: var(--text-secondary); }

/* ============= STATS ============= */
.stats-container {
    max-width: 600px;
    margin: 0 auto;
}

.stats-container h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.stats-overview {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-align: center;
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    font-family: var(--font-display);
}

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

.stats-chart-section {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.stats-chart-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.weekly-chart {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 120px;
    padding: 0 0.5rem;
}

.wc-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.wc-bar {
    width: 28px;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(to top, var(--primary), var(--primary-light));
    transition: height 0.5s ease;
    min-height: 4px;
}

.wc-day {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.wc-value {
    font-size: 0.65rem;
    color: var(--text-light);
}

.radar-chart {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.radar-skill {
    display: flex;
    align-items: center;
    gap: 8px;
    width: calc(50% - 4px);
}

.radar-skill-name {
    font-size: 0.8rem;
    font-weight: 600;
    width: 70px;
    text-align: right;
}

.radar-skill-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.radar-skill-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    transition: width 0.5s ease;
}

/* ============= SETTINGS ============= */
.settings-container {
    max-width: 600px;
    margin: 0 auto;
}

.settings-container h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.settings-group {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.settings-group h3 {
    font-size: 0.95rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

.setting-item {
    margin-bottom: 1rem;
}

.setting-item:last-child { margin-bottom: 0; }

.setting-item label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.setting-item input[type="text"],
.setting-item select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
}

.setting-item input[type="range"] {
    width: calc(100% - 50px);
    vertical-align: middle;
}

#speech-rate-value {
    display: inline-block;
    width: 40px;
    text-align: right;
    font-weight: 600;
    font-size: 0.9rem;
}

.toggle-setting {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-setting label { margin-bottom: 0; }

.toggle {
    width: 48px;
    height: 26px;
    background: var(--border);
    border-radius: 13px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    flex-shrink: 0;
}

.toggle.active { background: var(--primary); }

.toggle-slider {
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.toggle.active .toggle-slider { left: 24px; }

.settings-group .btn {
    width: 100%;
    margin-top: 0.5rem;
}

/* ============= TOAST ============= */
.toast-container {
    position: fixed;
    top: calc(var(--header-height) + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
    pointer-events: all;
    border: 1px solid var(--border);
}

.toast.success { border-left: 4px solid var(--secondary); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }
.toast.warning { border-left: 4px solid var(--accent); }

.toast.hiding { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--secondary); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--primary); }

.toast-text { flex: 1; font-size: 0.9rem; }

/* ============= MODAL ============= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.3s ease;
    text-align: center;
}

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

.modal-content h3 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.modal-content p { color: var(--text-secondary); margin-bottom: 1.5rem; }

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ============= MATCHING GAME ============= */
.matching-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 1rem 0;
}

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

.match-card.selected {
    border-color: var(--primary);
    background: rgba(108,99,255,0.1);
}

.match-card.matched {
    border-color: var(--secondary);
    background: rgba(16,185,129,0.1);
    pointer-events: none;
}

.match-card.wrong {
    border-color: var(--danger);
    background: rgba(239,68,68,0.1);
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ============= WORD SCRAMBLE ============= */
.scramble-display {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 8px;
    color: var(--primary);
    text-align: center;
    margin: 1.5rem 0;
    font-family: var(--font-display);
}

.scramble-input {
    text-align: center;
    font-size: 1.2rem;
    letter-spacing: 4px;
    text-transform: uppercase;
}

/* ============= DICTATION ============= */
.dictation-play-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem auto;
    box-shadow: 0 4px 16px rgba(108,99,255,0.3);
    transition: var(--transition);
}

.dictation-play-btn:hover {
    transform: scale(1.05);
}

/* ============= RESPONSIVE ============= */
@media (max-width: 380px) {
    .welcome-features {
        grid-template-columns: 1fr;
    }
    
    .practice-modes, .listening-modes {
        grid-template-columns: 1fr;
    }
    
    .achievements-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 768px) {
    .main-content {
        max-width: 700px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .practice-modes, .listening-modes {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .achievements-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    .app-container {
        min-height: -webkit-fill-available;
    }
}

/* Hide scrollbar but allow scrolling */
.conv-messages::-webkit-scrollbar,
.side-menu::-webkit-scrollbar {
    width: 0;
}

/* Selection color */
::selection {
    background: rgba(108,99,255,0.2);
}
