/* ==========================================
   Ms. Smile English - Main Stylesheet
   ========================================== */

/* CSS Variables */
:root {
    --primary-color: #FF6B9D;
    --primary-light: #FFB8D0;
    --primary-dark: #E91E63;
    --teacher-theme: #f72585;
    --secondary-color: #4ECDC4;
    --accent-color: #FFE66D;
    --bg-color: #FFF5F7;
    --text-color: #333;
    --text-light: #666;
    --white: #fff;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 8px 25px rgba(0, 0, 0, 0.15);
    --radius: 20px;
    --radius-sm: 10px;
    --transition: all 0.3s ease;
}

#app-version {
    position: fixed;
    right: 8px;
    bottom: 6px;
    z-index: 9999;
    max-width: min(320px, calc(100vw - 16px));
    overflow: hidden;
    color: #999;
    font-size: 10px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

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

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-color) 0%, #fff 100%);
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
}

/* ==========================================
   Header
   ========================================== */
.app-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 2rem;
    animation: bounce 2s infinite;
}

.logo h1 {
    color: var(--white);
    font-size: 1.5rem;
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.floating-logout {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1200;
    background: #333;
    color: #fff;
    border: 0;
    border-radius: 999px;
    padding: 12px 18px;
    box-shadow: var(--shadow-hover);
    font-family: inherit;
    font-weight: 800;
    cursor: pointer;
}

.floating-logout:hover {
    background: var(--primary-dark);
}

/* ==========================================
   Buttons
   ========================================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn-lesson {
    background: var(--accent-color);
    color: var(--text-color);
}

.btn-stats {
    background: var(--white);
    color: var(--primary-dark);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    transition: var(--transition);
}

.btn-icon:hover {
    color: var(--primary-color);
}

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

.btn-record {
    background: var(--primary-color);
    color: var(--white);
    font-size: 1.1rem;
    padding: 15px 30px;
    border-radius: 50px;
}

.btn-record.recording {
    background: #ff4757;
    animation: pulse 1s infinite;
}

/* ==========================================
   Main Container
   ========================================== */
.main-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 80px);
}

/* ==========================================
   Teacher Section
   ========================================== */
.teacher-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.teacher-avatar {
    background: var(--white);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    width: 100%;
}

/* Animated Avatar */
.avatar-container {
    width: 150px;
    height: 180px;
    margin: 0 auto 15px;
    position: relative;
}

.avatar-face {
    width: 100px;
    height: 100px;
    background: #FDBCB4;
    border-radius: 50%;
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

.eyes {
    position: absolute;
    top: 35px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
}

.eye {
    width: 12px;
    height: 12px;
    background: #333;
    border-radius: 50%;
    animation: blink 4s infinite;
}

.eye::after {
    content: '';
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    right: 2px;
}

.smile {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 15px;
    border: 3px solid #333;
    border-top: none;
    border-radius: 0 0 30px 30px;
}

.blush {
    position: absolute;
    width: 15px;
    height: 10px;
    background: rgba(255, 107, 157, 0.4);
    border-radius: 50%;
    top: 50px;
}

.blush.left { left: 15px; }
.blush.right { right: 15px; }

.avatar-hair {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 60px;
    background: #8B4513;
    border-radius: 60px 60px 0 0;
    z-index: 1;
}

.avatar-hair::before {
    content: '';
    position: absolute;
    top: 20px;
    left: -10px;
    width: 40px;
    height: 80px;
    background: #8B4513;
    border-radius: 50%;
}

.avatar-hair::after {
    content: '';
    position: absolute;
    top: 20px;
    right: -10px;
    width: 40px;
    height: 80px;
    background: #8B4513;
    border-radius: 50%;
}

.avatar-body {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 70px;
    background: var(--primary-color);
    border-radius: 40px 40px 0 0;
}

.collar {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 15px;
    background: var(--white);
    border-radius: 0 0 15px 15px;
}

.teacher-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 5px;
}

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

.status-dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.quick-actions {
    width: 100%;
}

.action-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

/* ==========================================
   Chat Section
   ========================================== */
.chat-section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--secondary-color) 0%, #45B7AA 100%);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 250px);
    background: #FAFAFA;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 4px;
}

/* Messages */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

.message-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.message-ai .message-avatar {
    background: var(--primary-light);
}

.message-user .message-avatar {
    background: var(--secondary-color);
}

.message-content {
    background: var(--white);
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    max-width: 70%;
}

.message-ai .message-content {
    background: var(--white);
    border-bottom-left-radius: 4px;
}

.message-user {
    flex-direction: row-reverse;
}

.message-user .message-content {
    background: var(--primary-color);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 10px 0;
    padding-left: 20px;
}

.message-content li {
    margin-bottom: 5px;
}

/* Chat Input */
.chat-input-area {
    padding: 15px 20px;
    background: var(--white);
    border-top: 1px solid #eee;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
}

.mic-btn {
    background: #eee;
    color: var(--text-light);
}

.mic-btn:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.mic-btn.recording {
    background: #ff4757;
    color: var(--white);
    animation: pulse 1s infinite;
}

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

.send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

#messageInput {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #eee;
    border-radius: 25px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

#messageInput:focus {
    border-color: var(--primary-light);
}

/* Recording Indicator */
.recording-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    color: var(--primary-dark);
    font-weight: 600;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: #ff4757;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

/* ==========================================
   Modals
   ========================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    display: none;
    opacity: 0;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 20px 25px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.3rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
    min-width: 44px;
    min-height: 44px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    flex: 0 0 auto;
}

.modal-close:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    max-height: calc(85vh - 70px);
}

/* ==========================================
   Lesson Content
   ========================================== */
.loading-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

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

.lesson-content {
    animation: fadeIn 0.5s ease;
}

.lesson-section {
    margin-bottom: 25px;
    padding: 20px;
    background: #FAFAFA;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-color);
}

.lesson-section h3 {
    color: var(--primary-dark);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

/* Vocabulary Cards */
.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.vocab-card {
    background: var(--white);
    padding: 15px;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: var(--transition);
}

.vocab-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.vocab-word {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.vocab-ipa {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 5px 0;
}

.vocab-meaning {
    color: var(--text-color);
    font-weight: 600;
    margin-bottom: 8px;
}

.vocab-example {
    color: var(--text-light);
    font-size: 0.9rem;
    font-style: italic;
}

.speak-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

.speak-btn:hover {
    color: var(--primary-dark);
    transform: scale(1.1);
}

/* Sentence Cards */
.sentence-card {
    background: var(--white);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.sentence-en {
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 5px;
}

.sentence-vn {
    color: var(--text-light);
}

.sentence-situation {
    font-size: 0.85rem;
    color: var(--primary-color);
    margin-top: 8px;
}

/* Dialogue */
.dialogue-container {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.dialogue-line {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #eee;
}

.dialogue-line:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.speaker {
    width: 35px;
    height: 35px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary-dark);
    flex-shrink: 0;
}

.dialogue-content {
    flex: 1;
}

.dialogue-en {
    font-weight: 600;
    margin-bottom: 5px;
}

.dialogue-vn {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Practice Section */
.practice-list {
    list-style: none;
}

.practice-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: var(--white);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.practice-text {
    font-weight: 600;
    flex: 1;
}

.practice-actions {
    display: flex;
    gap: 10px;
}

/* Exercise */
.exercise-container {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.exercise-question {
    font-weight: 700;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

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

.exercise-option {
    padding: 12px 15px;
    background: #f5f5f5;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.exercise-option:hover {
    border-color: var(--primary-light);
    background: #fff;
}

.exercise-option.correct {
    border-color: #2ecc71;
    background: #d5f4e6;
}

.exercise-option.wrong {
    border-color: #e74c3c;
    background: #fadbd8;
}

/* ==========================================
   Stats
   ========================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: linear-gradient(135deg, #fff 0%, #f8f8f8 100%);
    padding: 20px;
    border-radius: var(--radius-sm);
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

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

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

.mistakes-section {
    background: #fff9f9;
    padding: 20px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-color);
}

.mistakes-section h3 {
    color: var(--primary-dark);
    margin-bottom: 15px;
}

#mistakesList {
    list-style: none;
}

#mistakesList li {
    padding: 10px;
    background: var(--white);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mistake-count {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ==========================================
   Speaking Practice
   ========================================== */
.speaking-content {
    text-align: center;
}

.instruction {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 20px;
}

.practice-sentence {
    background: #f8f8f8;
    padding: 25px;
    border-radius: var(--radius-sm);
    margin-bottom: 25px;
}

#practiceText {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 15px;
}

.speaking-controls {
    margin-bottom: 25px;
}

.speaking-result {
    background: #f8f8f8;
    padding: 20px;
    border-radius: var(--radius-sm);
}

.result-correct {
    color: #2ecc71;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.result-wrong {
    color: #e74c3c;
    font-weight: 700;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.result-feedback {
    color: var(--text-light);
}

/* ==========================================
   Toast Notification
   ========================================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: var(--white);
    padding: 15px 25px;
    border-radius: 50px;
    box-shadow: var(--shadow-hover);
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================
   Utilities
   ========================================== */
.hidden {
    display: none !important;
}

.pulse {
    animation: pulse 2s infinite;
}

/* ==========================================
   Animations
   ========================================== */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

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

@keyframes blink {
    0%, 96%, 100% { transform: scaleY(1); }
    98% { transform: scaleY(0.1); }
}

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

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

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

/* ==========================================
   Responsive
   ========================================== */
@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
    }
    
    .teacher-section {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .teacher-avatar {
        flex: 1;
        min-width: 250px;
    }
    
    .quick-actions {
        flex: 1;
        min-width: 200px;
    }
    
    .action-btn {
        height: 100%;
    }
}

@media (max-width: 600px) {
    .app-header {
        flex-direction: column;
        gap: 10px;
        padding: 10px 15px;
    }
    
    .logo h1 {
        font-size: 1.2rem;
    }
    
    .main-container {
        padding: 10px;
    }
    
    .chat-messages {
        max-height: calc(100vh - 280px);
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .vocab-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    /* Mobile touch improvements */
    .btn, .input-btn, .action-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .mic-btn {
        width: 50px;
        height: 50px;
    }
    
    .mic-btn i {
        font-size: 1.4rem;
    }
    
    /* Chat full width on mobile */
    .message-content {
        max-width: 95%;
    }
    
    /* Compact header on mobile */
    .header-actions {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .btn-profile {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
    
    /* Onboarding form mobile */
    .onboarding-form .form-group label {
        font-size: 0.9rem;
    }
    
    .onboarding-form input,
    .onboarding-form select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ==========================================
   Roleplay Styles
   ========================================== */
.btn-roleplay {
    background: #9b59b6;
    color: var(--white);
}

.btn-roleplay:hover {
    background: #8e44ad;
}

.roleplay-content {
    max-width: 700px;
}

.roleplay-setup .subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 20px;
    font-size: 1.1rem;
}

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

.role-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-sm);
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.role-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.role-btn.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.role-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.role-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-color);
    margin-bottom: 4px;
}

.role-desc {
    font-size: 0.75rem;
    color: var(--text-light);
}

.situation-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
}

/* Active Roleplay */
.active-roleplay {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.roleplay-info {
    text-align: center;
    padding: 10px;
    background: #f8f8f8;
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--primary-dark);
}

.roleplay-messages {
    flex: 1;
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    background: #fafafa;
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
}

.roleplay-message {
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

.roleplay-message.ai {
    text-align: left;
}

.roleplay-message.user {
    text-align: right;
}

.roleplay-message-bubble {
    display: inline-block;
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
}

.roleplay-message.ai .roleplay-message-bubble {
    background: var(--white);
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.roleplay-message.user .roleplay-message-bubble {
    background: var(--primary-color);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.roleplay-message-avatar {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.roleplay-analysis {
    background: #fff9f9;
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
    animation: slideUp 0.3s ease;
}

.analysis-title {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.analysis-section {
    margin: 10px 0;
    padding: 10px;
    background: var(--white);
    border-radius: 8px;
}

.analysis-label {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.analysis-content {
    color: var(--text-color);
}

.emotion-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.emotion-tag {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.emotion-tag.confident {
    background: #d4edda;
    color: #155724;
}

.emotion-tag.hesitant {
    background: #fff3cd;
    color: #856404;
}

.emotion-tag.friendly {
    background: #d1ecf1;
    color: #0c5460;
}

.emotion-tag.polite {
    background: #e2e3e5;
    color: #383d41;
}

.emotion-tag.unclear {
    background: #f8d7da;
    color: #721c24;
}

.emotion-tag.neutral {
    background: #e9ecef;
    color: #495057;
}

.naturalness-score {
    display: flex;
    align-items: center;
    gap: 10px;
}

.naturalness-stars {
    font-size: 1.2rem;
}

.roleplay-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.roleplay-controls .btn {
    flex: 1;
    min-width: 140px;
    justify-content: center;
}

/* Mobile responsive for roleplay */
@media (max-width: 768px) {
    .role-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .role-btn {
        padding: 12px 8px;
    }
    
    .role-icon {
        font-size: 1.5rem;
    }
    
    .role-name {
        font-size: 0.8rem;
    }
    
    .role-desc {
        font-size: 0.7rem;
    }
    
    .roleplay-messages {
        max-height: 300px;
    }
    
    .roleplay-message-bubble {
        max-width: 90%;
        padding: 10px 12px;
    }
    
    .roleplay-controls .btn {
        min-width: 120px;
        font-size: 0.85rem;
        padding: 10px;
    }
}

@media (max-width: 400px) {
    .role-grid {
        grid-template-columns: 1fr;
    }
    
    .roleplay-controls {
        flex-direction: column;
    }
    
    .roleplay-controls .btn {
        width: 100%;
    }
}

/* ==========================================
   Situation Advisor Styles
   ========================================== */
.btn-situation {
    background: #e74c3c;
    color: var(--white);
}

.btn-situation:hover {
    background: #c0392b;
}

.situation-content {
    max-width: 700px;
}

.situation-input-section .subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 20px;
    font-size: 1.1rem;
}

#situationInput {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}

#situationInput:focus {
    border-color: var(--primary-color);
    outline: none;
}

.situation-examples {
    margin-top: 20px;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

/* ==========================================
   Auth Styles
   ========================================== */
.btn-login {
    background: #3498db;
    color: white;
}

.btn-login:hover {
    background: #2980b9;
}

.btn-register {
    background: #27ae60;
    color: white;
}

.btn-register:hover {
    background: #219a52;
}

.btn-logout {
    background: #95a5a6;
    color: white;
}

.btn-logout:hover {
    background: #7f8c8d;
}

/* ==========================================
   User Badge & Freemium Styles
   ========================================== */
.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-right: 10px;
}

.user-badge i {
    font-size: 1.1rem;
}

.guest-badge {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.user-badge {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

.limit-modal .modal-content {
    max-width: 500px;
}

.limit-info {
    text-align: center;
    padding: 20px 0;
}

.limit-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.limit-info h3 {
    color: #2c3e50;
    margin-bottom: 20px;
}

.limit-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: var(--radius-md);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.stat-label {
    font-weight: 500;
    color: var(--text-light);
}

.stat-value {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.limit-message {
    font-size: 1rem;
    color: #555;
    margin: 20px 0;
    line-height: 1.6;
}

.benefits-list {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    text-align: left;
}

.benefits-list li {
    padding: 8px 0;
    color: #2c3e50;
    font-size: 0.95rem;
}

.limit-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.limit-actions .btn-block {
    width: 100%;
    justify-content: center;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-light);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
}

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

/* ==========================================
   Avatar Animations & TTS
   ========================================== */

/* Avatar Container */
.avatar-container {
    position: relative;
    width: 150px;
    height: 150px;
    transition: transform 0.3s ease;
}

/* Blinking Animation */
@keyframes blink {
    0%, 90%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.1); }
}

.eye {
    animation: blink 4s infinite;
}

.eye.left {
    animation-delay: 0s;
}

.eye.right {
    animation-delay: 0.1s;
}

/* Nodding Animation */
@keyframes nod {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(3px) rotate(1deg); }
    75% { transform: translateY(-2px) rotate(-1deg); }
}

.avatar-container.nodding {
    animation: nod 2s ease-in-out infinite;
}

/* Talking Animation - Mouth */
@keyframes mouthTalk {
    0%, 100% { 
        height: 8px; 
        border-radius: 0 0 20px 20px;
    }
    25% { 
        height: 20px; 
        border-radius: 0 0 25px 25px;
    }
    50% { 
        height: 12px; 
        border-radius: 0 0 20px 20px;
    }
    75% { 
        height: 18px; 
        border-radius: 0 0 25px 25px;
    }
}

.mouth {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 8px;
    background: #e74c3c;
    border-radius: 0 0 20px 20px;
    transition: all 0.1s ease;
    overflow: hidden;
}

.mouth-inner {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60%;
    background: #c0392b;
    border-radius: 0 0 15px 15px;
}

/* Talking state */
.avatar-container.talking {
    transform: scale(1.02);
}

.avatar-container.talking .mouth {
    animation: mouthTalk 0.3s infinite;
}

/* Pulse effect when talking */
@keyframes pulse-ring {
    0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(231, 76, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

.avatar-container.talking::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
    animation: pulse-ring 1.5s ease-out infinite;
    z-index: -1;
}

/* Speech Status Indicator */
.speech-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border-radius: 20px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}

.speech-status.hidden {
    display: none;
}

/* Sound Wave Animation */
@keyframes soundWave {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

.sound-wave {
    animation: soundWave 0.5s ease infinite;
}

/* TTS Controls */
.tts-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    justify-content: center;
}

.btn-tts {
    background: rgba(255,255,255,0.9);
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.btn-tts:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-tts:active {
    transform: scale(0.95);
}

.btn-tts:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-tts-listen {
    color: #3498db;
}

.btn-tts-speak {
    color: #27ae60;
}

/* Voice Selector */
.voice-selector {
    margin-top: 15px;
    padding: 10px;
    background: rgba(255,255,255,0.9);
    border-radius: var(--radius-sm);
}

.voice-selector label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 5px;
    display: block;
}

.voice-selector select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Responsive Avatar */
@media (max-width: 768px) {
    .avatar-container {
        width: 120px;
        height: 120px;
    }
    
    .tts-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-tts {
        width: 100%;
        justify-content: center;
    }
}

/* Accessibility - Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .eye,
    .avatar-container.nodding,
    .avatar-container.talking .mouth,
    .sound-wave,
    .avatar-container.talking::after {
        animation: none;
    }
    
    .avatar-container.talking {
        transform: none;
    }
}

.btn-dashboard {
    background: #9b59b6;
    color: white;
}

.btn-dashboard:hover {
    background: #8e44ad;
}

.btn-plans {
    background: #16a085;
    color: #fff;
}

.btn-plans:hover {
    background: #138a72;
}

.btn-roadmap {
    background: #2f80ed;
    color: #fff;
}

.btn-roadmap:hover {
    background: #2568c7;
}

.roadmap-content {
    max-width: 1080px;
    width: min(1080px, calc(100vw - 18px));
}

.roadmap-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.roadmap-levels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.roadmap-level-card,
.roadmap-unit,
.roadmap-lesson-view,
.placement-question,
.placement-result {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.roadmap-level-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    min-height: 220px;
    border-color: #dce6f2;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
}

.roadmap-level-card.locked,
.roadmap-unit.locked,
.roadmap-lesson.locked {
    opacity: 0.62;
}

.roadmap-level-card.completed {
    border-color: #10b981;
}

.roadmap-level-card.selected {
    border-color: #2f80ed;
    box-shadow: 0 12px 26px rgba(47, 128, 237, 0.16);
}

.roadmap-level-top,
.roadmap-unit-header,
.speaking-line-actions,
.audio-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.roadmap-level-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: #e8f2ff;
    color: #1d4ed8;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
}

.roadmap-status-pill {
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 800;
    background: #eef2f7;
    color: #475569;
}

.roadmap-status-pill.completed {
    background: #dcfce7;
    color: #166534;
}

.roadmap-status-pill.unlocked {
    background: #dbeafe;
    color: #1d4ed8;
}

.roadmap-dashboard-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.daily-retention-card {
    grid-column: 1 / -1;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
    padding: 12px 14px;
    font-weight: 900;
    animation: rewardPop 0.45s ease;
}

.roadmap-stat,
.roadmap-badges {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
}

.roadmap-stat {
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.roadmap-stat:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.roadmap-stat strong {
    display: block;
    font-size: 1.3rem;
    color: #0f172a;
}

.roadmap-stat span,
.roadmap-badges span {
    color: #64748b;
    font-size: 0.85rem;
}

.roadmap-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-content: center;
}

.roadmap-level-card h3,
.roadmap-detail h3,
.roadmap-unit h4 {
    margin-bottom: 6px;
    color: #2c3e50;
}

.roadmap-meta,
.roadmap-percent,
.roadmap-lesson small {
    color: #666;
    font-size: 0.9rem;
}

.roadmap-progress {
    height: 8px;
    border-radius: 99px;
    background: #edf2f7;
    overflow: hidden;
    margin-top: 10px;
}

.roadmap-progress span {
    display: block;
    height: 100%;
    background: #2f80ed;
}

.roadmap-detail {
    margin-top: 18px;
}

.roadmap-unit {
    margin-bottom: 12px;
    background: #f9fafb;
}

.roadmap-lessons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.roadmap-lesson {
    border: 1px solid #d8dee9;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
    text-align: left;
    cursor: pointer;
    min-height: 86px;
    display: grid;
    grid-template-columns: 24px 1fr;
    gap: 6px 8px;
    align-items: start;
}

.roadmap-lesson.completed {
    border-color: #10b981;
    background: #ecfdf5;
}

.roadmap-lesson[disabled],
.roadmap-level-card .btn[disabled] {
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.roadmap-lesson small {
    grid-column: 2;
}

.roadmap-vocab {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.roadmap-vocab > div,
.roadmap-quiz {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
}

.placement-question {
    margin-bottom: 10px;
}

.placement-question label {
    display: inline-flex;
    gap: 6px;
    margin: 8px 12px 0 0;
}

.roadmap-ai-explanation {
    margin-top: 14px;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #b7d7ff;
    background: #eef6ff;
}

.roadmap-ai-explanation pre {
    white-space: pre-wrap;
    margin: 8px 0 0;
    font-family: inherit;
}

.alphabet-practice-card {
    border-color: #c7d2fe;
    background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
}

.alphabet-helper {
    margin: 0 0 12px;
    color: #475569;
    font-size: 0.95rem;
}

.kana-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.kana-card {
    display: grid;
    gap: 5px;
    align-content: start;
    min-height: 150px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.kana-card strong {
    font-size: 2.5rem;
    line-height: 1;
    color: #0f172a;
}

.kana-card span {
    font-weight: 800;
    color: #2563eb;
}

.kana-card small,
.kana-card em,
.kana-prompt em,
.writing-practice small {
    color: #64748b;
}

.kana-card em {
    min-height: 34px;
    font-style: normal;
}

.alphabet-game {
    display: grid;
    gap: 10px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #eff6ff;
    padding: 12px;
    margin-bottom: 14px;
}

.alphabet-game-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.kana-prompt {
    display: grid;
    grid-template-columns: 58px 1fr;
    gap: 8px 12px;
    align-items: center;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.kana-symbol {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #f8fafc;
    color: #0f172a;
    font-size: 2rem;
    font-weight: 900;
}

.kana-choices {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.kana-choice {
    min-height: 42px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    padding: 8px 14px;
    cursor: pointer;
    font-weight: 800;
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.kana-choice:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: #2563eb;
}

.kana-choice.correct {
    border-color: #16a34a;
    background: #dcfce7;
    color: #166534;
}

.kana-choice.wrong {
    border-color: #f97316;
    background: #ffedd5;
    color: #9a3412;
}

.kana-prompt em {
    grid-column: 2;
    font-style: normal;
}

.writing-practice {
    display: grid;
    gap: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.writing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.writing-grid > div {
    display: grid;
    gap: 10px;
    border-radius: 8px;
    background: #f8fafc;
    padding: 12px;
}

.writing-letter-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.writing-letter-head span {
    font-size: 2rem;
    font-weight: 900;
}

.writing-letter-head strong {
    color: #2563eb;
    font-size: 0.95rem;
}

.writing-letter-head em {
    flex-basis: 100%;
    color: #64748b;
    font-size: 0.86rem;
    font-style: normal;
    font-weight: 700;
}

.kana-stroke-panel {
    display: grid;
    gap: 10px;
}

.kana-stroke-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.kana-stroke-panel-head span,
.kana-stroke-panel-head em {
    color: #2563eb;
    font-size: 0.82rem;
    font-style: normal;
    font-weight: 900;
}

.kana-stroke-panel-head button {
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 900;
    padding: 6px 10px;
    transition: transform 0.15s ease, background 0.15s ease;
}

.kana-stroke-panel-head button:hover {
    background: #dbeafe;
    transform: translateY(-1px);
}

.kana-stroke-svg {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: block;
    overflow: hidden;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    background:
        linear-gradient(90deg, transparent calc(50% - 1px), #bae6fd 50%, transparent calc(50% + 1px)),
        linear-gradient(0deg, transparent calc(50% - 1px), #bae6fd 50%, transparent calc(50% + 1px)),
        #fff;
}

.kana-stroke-grid-line {
    stroke: #bae6fd;
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.kana-stroke-path {
    fill: none;
    stroke: var(--stroke-color);
    stroke-width: 5.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.9;
    filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.08));
}

.kana-stroke-number {
    fill: #fff;
    font-size: 10px;
    font-weight: 900;
    text-anchor: middle;
}

.kana-stroke-number-bg {
    filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.15));
}

.kana-stroke-panel.is-replaying .kana-stroke-path {
    animation: kanaStrokeReplay 0.55s ease both;
    animation-delay: var(--stroke-delay);
    stroke-dasharray: 180;
    stroke-dashoffset: 180;
}

.kana-stroke-placeholder {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 180px;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    background:
        linear-gradient(90deg, transparent calc(50% - 1px), #bae6fd 50%, transparent calc(50% + 1px)),
        linear-gradient(0deg, transparent calc(50% - 1px), #bae6fd 50%, transparent calc(50% + 1px)),
        #fff;
}

.kana-stroke-placeholder span {
    color: rgba(15, 23, 42, 0.24);
    font-size: 4.75rem;
    font-weight: 900;
    line-height: 1;
}

.kana-stroke-placeholder small {
    position: absolute;
    bottom: 10px;
    color: #64748b;
    font-size: 0.74rem;
    font-weight: 800;
}

@keyframes kanaStrokeReplay {
    to {
        stroke-dashoffset: 0;
    }
}

.stroke-order-box {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    padding: 8px;
}

.stroke-visual-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 8px;
}

.stroke-visual-card {
    display: grid;
    gap: 4px;
}

.stroke-guide-grid {
    position: relative;
    min-height: 96px;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    overflow: hidden;
    background:
        linear-gradient(90deg, transparent calc(50% - 1px), #bae6fd 50%, transparent calc(50% + 1px)),
        linear-gradient(0deg, transparent calc(50% - 1px), #bae6fd 50%, transparent calc(50% + 1px)),
        #fff;
}

.stroke-svg {
    width: 100%;
    min-height: 96px;
    display: block;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    background: #fff;
}

.stroke-grid-line {
    stroke: #bae6fd;
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.stroke-path {
    fill: none;
    stroke: var(--stroke-color);
    stroke-width: 9;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 1px 1px rgba(15, 23, 42, 0.16));
}

.stroke-number {
    font-size: 13px;
    font-weight: 900;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 3px;
}

.stroke-end-dot {
    fill: #f59e0b;
}

.stroke-ghost {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #111827;
    font-size: 3rem;
    font-weight: 900;
    line-height: 1;
}

.stroke-cumulative {
    position: absolute;
    left: 6px;
    top: 5px;
    color: #ef4444;
    font-size: 0.72rem;
    font-weight: 900;
}

.stroke-guide-safe .stroke-ghost {
    color: rgba(15, 23, 42, 0.18);
}

.stroke-safe-label {
    position: absolute;
    left: 6px;
    right: 6px;
    bottom: 6px;
    color: #475569;
    font-size: 0.68rem;
    font-weight: 800;
    text-align: center;
}

.stroke-dot {
    position: absolute;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 900;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.16);
}

.stroke-dot-1 {
    left: 10px;
    top: 10px;
    background: #ef4444;
}

.stroke-dot-2 {
    right: 10px;
    top: 12px;
    background: #22c55e;
}

.stroke-dot-3 {
    right: 12px;
    bottom: 10px;
    background: #0ea5e9;
}

.stroke-dot-4 {
    left: 12px;
    bottom: 10px;
    background: #a855f7;
}

.stroke-visual-card small {
    text-align: center;
    color: #475569;
    font-size: 0.74rem;
    font-weight: 800;
}

.stroke-order-title {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
}

.stroke-order-title span {
    color: #0f172a;
    font-size: 0.88rem;
    font-weight: 900;
}

.stroke-order-title em {
    color: #2563eb;
    font-size: 0.78rem;
    font-style: normal;
    font-weight: 900;
}

.stroke-order-box ol {
    margin: 0;
    padding-left: 18px;
}

.stroke-order-box li {
    color: #475569;
    font-size: 0.84rem;
    line-height: 1.35;
    margin: 3px 0;
}

@media (max-width: 560px) {
    .kana-prompt {
        grid-template-columns: 1fr;
    }

    .kana-prompt em {
        grid-column: 1;
    }

    .kana-symbol {
        width: 100%;
    }

    .writing-grid {
        grid-template-columns: 1fr;
    }

    .stroke-visual-strip {
        grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    }

    .stroke-guide-grid {
        min-height: 92px;
    }

    .stroke-svg {
        min-height: 92px;
    }

    .stroke-ghost {
        font-size: 2.65rem;
    }
}

.skeleton-card {
    overflow: hidden;
}

.skeleton-line {
    height: 14px;
    border-radius: 999px;
    background: linear-gradient(90deg, #eef2f7, #f8fafc, #eef2f7);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
}

.skeleton-line.wide {
    width: 85%;
}

.skeleton-line.short {
    width: 45%;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.speaking-practice-panel,
.speaking-line {
    display: grid;
    gap: 12px;
}

.speaking-line {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
    background: #fff;
}

.roadmap-speaking-score {
    display: inline-block;
    margin: 8px 0;
    padding: 6px 12px;
    border-radius: 999px;
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: 800;
}

.celebration-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0;
    transition: opacity 0.18s ease;
    padding: 18px;
}

.celebration-overlay.show {
    opacity: 1;
}

.celebration-card {
    position: relative;
    width: min(420px, 100%);
    border-radius: 8px;
    background: #fff;
    padding: 24px 20px 20px;
    text-align: center;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.25);
    animation: popIn 0.28s ease;
}

.celebration-close {
    position: absolute;
    top: 8px;
    right: 10px;
}

.celebration-burst,
.badge-pop {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 900;
    animation: rewardPop 0.7s ease;
}

.celebration-burst {
    background: #dcfce7;
    color: #166534;
}

.badge-pop {
    margin-top: 12px;
    background: #fef3c7;
    color: #92400e;
}

.celebration-card h3 {
    margin: 14px 0 6px;
}

.celebration-card p {
    color: #475569;
}

.celebration-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.celebration-stats span {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    color: #64748b;
}

.celebration-stats strong {
    display: block;
    color: #0f172a;
    font-size: 1.3rem;
}

@keyframes rewardPop {
    0% { transform: scale(0.75); opacity: 0; }
    55% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.profile-help-text {
    color: #6b7280;
    margin: 0 0 12px;
}

.family-invite-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.family-invite-row input {
    min-height: 44px;
    border: 1px solid #d8dee8;
    border-radius: 8px;
    padding: 0 12px;
    font: inherit;
}

.family-members-list {
    display: grid;
    gap: 10px;
}

.family-capacity {
    background: #eef6ff;
    color: #1f4f8f;
    border-radius: 8px;
    padding: 10px 12px;
    font-weight: 700;
}

.family-member-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    background: #fff;
}

.family-member-row div {
    display: grid;
    gap: 2px;
}

.family-member-row span,
.family-member-row small {
    color: #6b7280;
}

.speaking-result audio {
    width: 100%;
    margin: 10px 0;
}

.lesson-app-card {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 14px;
    background: #fff;
    margin-bottom: 12px;
}

.lesson-progress-shell {
    display: grid;
    gap: 6px;
    margin: 10px 0 14px;
}

.lesson-progress-label {
    display: flex;
    justify-content: space-between;
    color: #64748b;
    font-size: 0.86rem;
    font-weight: 800;
}

.lesson-progress-label strong {
    color: #0f172a;
}

.lesson-progress-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}

.lesson-progress-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22c55e, #3b82f6);
    transition: width 0.45s ease;
}

.lesson-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    color: #0f172a;
}

.lesson-section-header h4 {
    margin: 0;
}

.vocab-tile {
    display: grid;
    gap: 5px;
    min-height: 136px;
}

.vocab-tile span {
    color: #475569;
    font-weight: 700;
}

.bilingual-vn {
    display: block;
    margin-top: 4px;
    color: #64748b;
    font-size: 0.92rem;
    line-height: 1.35;
}

.skill-focus-card {
    display: grid;
    gap: 10px;
}

.skill-passage {
    padding: 12px 14px;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    line-height: 1.6;
}

.skill-question-list {
    display: grid;
    gap: 8px;
    padding-left: 20px;
}

.skill-question-list em {
    display: block;
    color: #475569;
    font-size: 0.9rem;
}

.writing-sentence-bank {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid #dbeafe;
    border-radius: 8px;
    background: #eff6ff;
}

.writing-sentence-bank p {
    margin: 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: #fff;
    color: #1e293b;
}

.jp-reading,
.jp-example-reading {
    display: block;
    margin-top: 4px;
    color: #2563eb;
    font-size: 0.92rem;
    line-height: 1.35;
    font-weight: 700;
}

.jp-token-line {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: flex-start;
    vertical-align: middle;
}

.jp-token {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.15;
    min-width: 1.4em;
}

.jp-token-text {
    color: #2f2f2f;
    font-size: 1.04em;
}

.jp-token-reading {
    margin-top: 4px;
    color: #2563eb;
    font-size: 0.78em;
    font-weight: 800;
    white-space: nowrap;
}

.jp-stacked-line {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    vertical-align: middle;
}

.jp-main-text {
    color: #2f2f2f;
}

.jp-reading-inline {
    color: #2563eb;
    font-size: 0.86em;
    font-weight: 800;
}

.jp-translation,
.jp-example-translation {
    display: block;
    margin-top: 4px;
    color: #475569;
    font-size: 0.92rem;
    line-height: 1.35;
}

.jp-example-reading,
.jp-example-translation {
    font-size: 0.86rem;
}

.jp-pattern-line .jp-translation,
.jp-dialogue-line .jp-translation,
.speaking-line .jp-translation {
    width: 100%;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px dashed #e2e8f0;
    color: #334155;
    font-size: 0.95rem;
    font-weight: 700;
}

.pattern-line,
.dialogue-app-line {
    padding: 10px;
    border-radius: 8px;
    background: #f8fafc;
    margin-bottom: 8px;
}

.jp-pattern-line > span,
.jp-dialogue-line > span {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
}

.mission-panel,
.continue-card {
    grid-column: 1 / -1;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
}

.mission-panel h4 {
    margin-bottom: 8px;
}

.mission-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(110px, 1fr);
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid #f1f5f9;
}

.mission-row:first-of-type {
    border-top: 0;
}

.mission-row.done strong::after {
    content: " done";
    color: #16a34a;
    font-size: 0.75rem;
    margin-left: 6px;
}

.mission-row span,
.continue-card span {
    display: block;
    color: #64748b;
    font-size: 0.84rem;
}

.continue-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    align-items: center;
}

.continue-card span {
    grid-column: 1;
}

.continue-card button {
    grid-row: 1 / span 2;
    grid-column: 2;
}

.speech-compare {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}

.speech-compare span {
    border-radius: 6px;
    padding: 2px 6px;
    font-weight: 800;
}

.speaking-feedback-message {
    display: inline-block;
    margin: 6px 0 10px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    padding: 7px 12px;
    font-weight: 900;
}

.word-ok {
    background: #dcfce7;
    color: #166534;
}

.word-missing {
    background: #fff1f2;
    color: #991b1b;
    text-decoration: underline;
    text-decoration-color: #ef4444;
    text-decoration-thickness: 3px;
    text-underline-offset: 4px;
}

.word-wrong {
    background: #ffedd5;
    color: #9a3412;
}

.grammar-hints {
    display: grid;
    gap: 6px;
    margin: 10px 0;
    padding: 12px;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    background: #fff7ed;
    color: #7c2d12;
}

.grammar-hints strong {
    color: #9a3412;
}

.grammar-hints span {
    font-weight: 800;
}

.grammar-hints p {
    margin: 0;
}

.speaking-score-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.speaking-score-grid div {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.speaking-score-grid strong {
    display: block;
    font-size: 1.25rem;
    color: #1d4ed8;
}

.speaking-score-grid span {
    color: #64748b;
    font-size: 0.78rem;
}

.record-countdown {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    margin: 0 auto 10px;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 2rem;
    font-weight: 900;
    animation: popIn 0.45s ease;
}

.record-hint {
    text-align: center;
    color: #64748b;
    font-weight: 800;
}

.record-waveform {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.record-waveform span {
    width: 8px;
    height: 24px;
    border-radius: 999px;
    background: #ef4444;
    animation: wavePulse 0.7s infinite ease-in-out;
}

.record-waveform span:nth-child(2) { animation-delay: 0.1s; }
.record-waveform span:nth-child(3) { animation-delay: 0.2s; }
.record-waveform span:nth-child(4) { animation-delay: 0.3s; }
.record-waveform span:nth-child(5) { animation-delay: 0.4s; }

@keyframes wavePulse {
    0%, 100% { transform: scaleY(0.45); }
    50% { transform: scaleY(1.6); }
}

@keyframes popIn {
    from { transform: scale(0.85); opacity: 0.4; }
    to { transform: scale(1); opacity: 1; }
}

.learning-profile-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.profile-level-card,
.profile-metric,
.profile-badges {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    padding: 12px;
}

.profile-level-card {
    grid-column: 1 / -1;
}

.profile-level-card span,
.profile-metric span {
    display: block;
    color: #64748b;
    font-size: 0.8rem;
}

.profile-level-card strong,
.profile-metric strong {
    display: block;
    font-size: 1.35rem;
    color: #0f172a;
    text-transform: capitalize;
}

.profile-badges {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.plan-checkout-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr);
    gap: 18px;
}

.plan-picker,
.payment-info-card,
.selected-plan-detail,
.payment-result {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    background: #fff;
}

.plan-picker h3,
.payment-info-card h3 {
    margin-bottom: 12px;
    color: #2c3e50;
}

.selected-plan-detail {
    margin: 12px 0;
    background: #f8f9fa;
    line-height: 1.7;
}

.plan-price {
    color: #e74c3c;
    font-size: 1.4rem;
    font-weight: 800;
}

.payment-info-card {
    line-height: 1.8;
    background: #f9fafb;
}

.payment-info-card p,
.payment-hint {
    color: #666;
    margin-top: 12px;
}

.payment-result {
    margin-top: 14px;
    background: #ecfdf5;
    border-color: #10b981;
}

.payment-result code {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 6px;
    background: #fff;
    color: #b91c1c;
    font-weight: 800;
}

.payment-qr-card {
    margin: 14px 0;
    padding: 14px;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    background: #ffffff;
    text-align: center;
}

.payment-qr-title {
    font-weight: 800;
    color: #166534;
    margin-bottom: 8px;
}

.payment-qr-card img {
    width: min(260px, 100%);
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
}

.payment-qr-note {
    margin-top: 8px;
    color: #64748b;
    font-size: 0.92rem;
}

.auth-form {
    max-width: 400px;
    margin: 0 auto;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.auth-form input,
.auth-form select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
}

.auth-form input:focus,
.auth-form select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.auth-form .btn-block {
    width: 100%;
    justify-content: center;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--text-light);
}

.auth-switch a {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    width: auto;
}

/* ==========================================
   Dashboard Styles
   ========================================== */
.dashboard-content {
    max-width: 500px;
}

.dashboard-section {
    background: #f8f9fa;
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.dashboard-section h3 {
    margin-bottom: 15px;
    color: var(--text-color);
}

.streak-display {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 5px;
}

.streak-number {
    font-size: 3rem;
    font-weight: 700;
    color: #e74c3c;
}

.streak-label {
    font-size: 1.2rem;
    color: var(--text-light);
}

.streak-sub {
    color: var(--text-light);
    font-size: 0.9rem;
}

.dashboard-stats {
    margin: 0;
    padding: 0;
}

.dashboard-stats .stat-card {
    padding: 15px;
}

.dashboard-stats .stat-icon {
    font-size: 1.5rem;
}

.dashboard-stats .stat-value {
    font-size: 1.8rem;
}

.dashboard-stats .stat-label {
    font-size: 0.85rem;
}

.scores-display {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.score-label {
    width: 80px;
    font-weight: 600;
    color: var(--text-color);
}

.score-bar {
    flex: 1;
    height: 12px;
    background: #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

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

.score-value {
    width: 60px;
    text-align: right;
    font-weight: 600;
    color: var(--primary-color);
}

.errors-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.error-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border-radius: var(--radius-sm);
    border-left: 4px solid #e74c3c;
}

.error-text {
    font-weight: 600;
    color: var(--text-color);
}

.error-count {
    background: #e74c3c;
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.situations-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.situation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: white;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-color);
}

.situation-date {
    font-size: 0.8rem;
    color: var(--text-light);
}

.empty-text {
    color: var(--text-light);
    text-align: center;
    font-style: italic;
}

/* User greeting in header */
.user-greeting {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    background: rgba(255,255,255,0.2);
    border-radius: 20px;
    color: white;
    font-weight: 500;
}

.user-greeting i {
    font-size: 1.2rem;
}

/* ==========================================
   Toast Notification
   ========================================== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--text-color);
    color: white;
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

.toast.hidden {
    display: none;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.example-chip {
    padding: 8px 15px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.example-chip:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.situation-result {
    animation: fadeIn 0.3s ease;
}

.situation-analysis {
    background: #f8f9fa;
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 20px;
}

.analysis-block {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-color);
}

.analysis-block.situation {
    border-left-color: #3498db;
}

.analysis-block.solution {
    border-left-color: #27ae60;
}

.analysis-block.simple {
    border-left-color: #f39c12;
}

.analysis-block.natural {
    border-left-color: #9b59b6;
}

.analysis-block.cultural {
    border-left-color: #e74c3c;
}

.analysis-block.practice {
    border-left-color: #1abc9c;
    background: #e8f8f5;
}

.analysis-header {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.analysis-content {
    color: var(--text-color);
    line-height: 1.6;
}

.analysis-content .vi-text {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 5px;
}

.analysis-content .en-text {
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 1.1rem;
    padding: 10px;
    background: #fff9f9;
    border-radius: 6px;
    margin: 8px 0;
}

.speak-btn-inline {
    padding: 5px 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    margin-left: 10px;
}

.situation-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.situation-controls .btn {
    flex: 1;
    min-width: 150px;
    justify-content: center;
}

.situation-practice {
    animation: slideUp 0.3s ease;
}

.practice-prompt {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: var(--radius-sm);
    text-align: center;
    margin-bottom: 20px;
}

.practice-prompt p {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.situation-practice-feedback {
    margin-top: 15px;
    padding: 15px;
    background: #fff9f9;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary-color);
}

/* Mobile responsive for situation advisor */
@media (max-width: 768px) {
    .situation-content {
        max-width: 100%;
    }
    
    .example-chips {
        justify-content: center;
    }
    
    .situation-controls .btn {
        min-width: 120px;
        font-size: 0.85rem;
    }
    
    .analysis-block {
        padding: 12px;
    }
}

/* ==========================================
   Onboarding Form Styles
   ========================================== */
.onboarding-content {
    max-width: 500px;
}

.onboarding-content .subtitle {
    color: var(--text-light);
    margin-top: 5px;
    font-size: 1rem;
}

.onboarding-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
}

.form-group input,
.form-group select {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--teacher-theme, var(--primary-color));
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-hint {
    color: var(--text-light);
    font-size: 0.84rem;
    line-height: 1.35;
}

.language-select {
    background-color: var(--white);
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-secondary {
    background: #e0e0e0;
    color: var(--text-color);
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.payment-confirm-btn {
    margin: 14px 0;
    min-height: 52px;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 8px 18px rgba(22, 163, 74, 0.18);
}

.more-menu-wrap {
    position: relative;
}

.btn-more {
    background: #ffffff;
    color: var(--primary-dark);
}

.more-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
    z-index: 1200;
    display: grid;
    gap: 8px;
}

.more-menu-panel .btn {
    width: 100%;
    min-height: 44px;
    justify-content: flex-start;
    color: #0f172a;
    background: #f8fafc;
}

/* Profile Button */
.btn-profile {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-profile:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==========================================
   TTS Controls
   ========================================== */
.tts-control {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f8f8f8;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.tts-control label {
    font-weight: 600;
    color: var(--text-light);
}

.tts-control select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: inherit;
    background: var(--white);
}

/* Speak button in messages */
.speak-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: var(--transition);
    font-size: 1rem;
    margin-left: 10px;
}

.speak-btn:hover {
    background: var(--primary-light);
}

.speak-btn.speaking {
    color: var(--secondary-color);
    animation: pulse 1s infinite;
}

/* ==========================================
   Speech Recognition
   ========================================== */
.mic-btn.recording {
    background: #e74c3c;
    color: var(--white);
    animation: pulse 1.5s infinite;
}

.mic-btn.recording:hover {
    background: #c0392b;
}

.recording-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    color: #e74c3c;
    font-weight: 600;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: #e74c3c;
    border-radius: 50%;
    animation: blink 1s infinite;
}

/* Pronunciation Feedback */
.pronunciation-feedback {
    background: #fff9f9;
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
}

.pronunciation-feedback .feedback-title {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 10px;
}

.pronunciation-feedback .feedback-item {
    margin: 8px 0;
    padding: 8px;
    background: var(--white);
    border-radius: 5px;
}

.pronunciation-feedback .missing {
    color: #e74c3c;
}

.pronunciation-feedback .correct {
    color: #2ecc71;
}

.pronunciation-feedback .suggestion {
    color: #3498db;
    font-style: italic;
}

/* ==========================================
   Mobile Responsive - Additional
   ========================================== */
@media (max-width: 768px) {
    /* Teacher section full width */
    .teacher-section {
        flex-direction: column;
    }
    
    .teacher-avatar,
    .quick-actions {
        width: 100%;
        min-width: auto;
    }
    
    /* Chat section full width */
    .chat-section {
        width: 100%;
    }
    
    /* Larger touch targets */
    .input-container {
        padding: 8px;
    }
    
    #messageInput {
        font-size: 16px; /* Prevent iOS zoom */
    }
    
    /* Modal improvements */
    .modal-content {
        margin: 8px;
        width: calc(100% - 16px);
        max-height: calc(100dvh - 16px);
        border-radius: 18px;
    }

    .modal-header {
        padding: 14px 16px;
        align-items: flex-start;
        gap: 10px;
    }

    .modal-header h2 {
        font-size: 1.25rem;
        line-height: 1.25;
    }

    .modal-body {
        padding: 16px;
        max-height: calc(100dvh - 88px);
        padding-bottom: calc(96px + env(safe-area-inset-bottom));
    }
    
    /* Form improvements */
    .onboarding-form {
        gap: 12px;
    }
    
    .form-group input,
    .form-group select {
        padding: 14px 12px;
    }
    
    /* Header compact */
    .logo h1 {
        font-size: 1.1rem;
    }
    
    .header-actions .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .plan-checkout-grid {
        grid-template-columns: 1fr;
    }

    .app-header {
        padding: 10px 12px;
        align-items: flex-start;
    }

    .header-actions {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 900;
        background: #ffffff;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -8px 20px rgba(15, 23, 42, 0.08);
        display: flex;
        gap: 8px;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
    }

    .header-actions .btn,
    .header-actions .user-badge,
    .header-actions .guest-badge {
        flex: 0 0 82px;
        min-height: 54px;
        padding: 7px 8px;
        justify-content: center;
        border-radius: 8px;
        font-size: 0.72rem;
        white-space: normal;
        line-height: 1.15;
        scroll-snap-align: start;
    }

    .more-menu-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 70px;
        top: auto;
        min-width: 0;
    }

    .main-container {
        padding-bottom: calc(112px + env(safe-area-inset-bottom));
    }

    #app-version {
        display: none;
    }

    .roadmap-dashboard-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mission-row,
    .continue-card {
        grid-template-columns: 1fr;
    }

    .continue-card button,
    .continue-card span {
        grid-column: 1;
        grid-row: auto;
    }

    .speaking-score-grid,
    .learning-profile-summary {
        grid-template-columns: 1fr;
    }

    .roadmap-levels,
    .roadmap-lessons {
        grid-template-columns: 1fr;
    }

    .roadmap-content {
        width: calc(100% - 16px);
    }

    .roadmap-level-card,
    .roadmap-unit,
    .roadmap-lesson-view,
    .lesson-app-card {
        padding: 12px;
    }

    .roadmap-vocab {
        grid-template-columns: 1fr;
    }

    .family-invite-row {
        grid-template-columns: 1fr;
    }

    .family-member-row {
        align-items: stretch;
        flex-direction: column;
    }

    .speaking-line-actions .btn,
    .audio-toolbar .btn {
        flex: 1 1 130px;
        min-height: 46px;
        justify-content: center;
    }
    
    /* Stats grid */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 15px;
    }
}

@media (max-width: 400px) {
    /* Extra small screens */
    .logo-icon {
        font-size: 1.5rem;
    }
    
    .logo h1 {
        font-size: 1rem;
    }
    
    .header-actions {
        gap: 5px;
    }
    
    .header-actions .btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .message-content {
        max-width: 100%;
    }
}
