:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-card: rgba(30, 30, 50, 0.6);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-hover: rgba(255, 255, 255, 0.1);
    
    --text-primary: #ffffff;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b8a;
    
    --border-color: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(99, 102, 241, 0.5);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Animated Background */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s infinite ease-in-out;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    top: -200px;
    left: -200px;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    bottom: -150px;
    right: -150px;
    animation-delay: 7s;
}

.orb-3 {
    width: 350px;
    height: 350px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

/* Hide API key modal by default - keys are in config.js */
#apiKeyModal {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

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

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 600px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

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

.modal-content h2 {
    margin-bottom: 10px;
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.modal-content input {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.modal-content input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Onboarding */
.onboarding {
    text-align: center;
    max-width: 700px;
}

.onboarding-step {
    animation: fadeIn 0.3s ease;
}

.onboarding-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

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

.onboarding-step h2 {
    font-size: 32px;
    margin-bottom: 10px;
}

.onboarding-step p {
    font-size: 18px;
    margin-bottom: 30px;
}

.language-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 30px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

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

.language-item:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.language-item.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    box-shadow: var(--shadow-glow);
}

.language-item .flag {
    font-size: 32px;
}

.language-item .name {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.onboarding-nav {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* Level Selection */
.level-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.level-option {
    padding: 24px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.level-option:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.level-option.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    box-shadow: var(--shadow-glow);
}

.level-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.level-option h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.level-option p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 14px 28px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

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

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

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

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

/* App Container */
.app-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-icon {
    font-size: 28px;
}

.language-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.language-info .flag {
    font-size: 20px;
}

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

.stats {
    display: flex;
    gap: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    min-width: 80px;
}

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

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
    gap: 20px;
}

/* Progress Section */
.progress-section {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--bg-secondary);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 10px;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.progress-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Course Plan Section */
.course-plan-section {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.course-plan-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 800px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.course-plan-header {
    text-align: center;
    margin-bottom: 30px;
}

.course-plan-header h2 {
    font-size: 32px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.course-plan-subtitle {
    color: var(--text-secondary);
    font-size: 18px;
}

.course-plan-content {
    margin: 30px 0;
    min-height: 200px;
}

.loading-course {
    text-align: center;
    padding: 40px;
}

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

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

.course-plan-list {
    list-style: none;
    padding: 0;
}

.course-plan-item {
    padding: 20px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
    transition: var(--transition);
}

.course-plan-item:hover {
    border-color: var(--primary);
    transform: translateX(4px);
}

.course-plan-item h3 {
    font-size: 20px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.course-plan-item .lesson-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.course-plan-item p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.course-plan-actions {
    text-align: center;
    margin-top: 30px;
}

/* Chat Container */
.chat-container {
    flex: 1;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 500px;
    max-height: calc(100vh - 300px);
}

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

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

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 10px;
}

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

.welcome-message {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.welcome-avatar {
    font-size: 48px;
    flex-shrink: 0;
}

.welcome-content h3 {
    margin-bottom: 8px;
    font-size: 20px;
}

.welcome-content p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.welcome-hint {
    margin-top: 12px;
    padding: 12px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.message {
    display: flex;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

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

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.message.ai .message-avatar {
    background: linear-gradient(135deg, var(--secondary), var(--accent));
}

.message-content {
    flex: 1;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    max-width: 70%;
}

.message.user .message-content {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.message.ai .message-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.message-text {
    color: var(--text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Input Area */
.input-area {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.voice-btn {
    flex-shrink: 0;
}

.voice-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
}

#messageInput {
    flex: 1;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    transition: var(--transition);
}

#messageInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.send-btn {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-hint {
    margin-top: 8px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* Achievement Popup */
.achievement-popup {
    position: fixed;
    top: 100px;
    right: 24px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: none;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideInRight 0.5s ease;
}

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

.achievement-popup.show {
    display: flex;
}

.achievement-icon {
    font-size: 48px;
}

.achievement-title {
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 4px;
}

.achievement-desc {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Sidebar */
.sidebar {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-left: 1px solid var(--border-color);
    z-index: 200;
    transition: right 0.3s ease;
    overflow-y: auto;
}

.sidebar.open {
    right: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-content {
    padding: 20px;
}

.achievements-section h4 {
    margin-bottom: 16px;
    font-size: 18px;
}

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

.achievement-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.achievement-item.unlocked {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.achievement-emoji {
    font-size: 24px;
}

.achievement-name {
    color: var(--text-primary);
}

.achievement-item.locked .achievement-name {
    color: var(--text-muted);
}

/* Pricing */
.pricing-preview {
    margin: 30px 0;
}

.pricing-card {
    background: var(--bg-secondary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
}

.pricing-badge {
    display: inline-block;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.pricing-amount {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pricing-after {
    color: var(--text-secondary);
    font-size: 14px;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.pricing-option {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    transition: var(--transition);
}

.pricing-option:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.pricing-option.featured {
    border-color: var(--primary);
    border-width: 2px;
}

.pricing-option .pricing-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
}

.pricing-header h3 {
    font-size: 24px;
    margin-bottom: 12px;
}

.pricing-price {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pricing-price span {
    font-size: 18px;
    color: var(--text-secondary);
}

.pricing-savings {
    color: var(--success);
    font-size: 14px;
    margin-bottom: 20px;
}

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

.pricing-features li {
    padding: 8px 0;
    color: var(--text-secondary);
}

.pricing-note {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 20px;
}

/* Responsive Design - Mobile & Tablet */

/* iPad Pro and large tablets (1024px and up) */
@media (max-width: 1024px) {
    .main-content {
        padding: 20px;
    }
    
    .course-plan-card {
        padding: 30px;
    }
    
    .chat-container {
        max-height: calc(100vh - 280px);
    }
}

/* iPad and medium tablets (768px - 1023px) */
@media (max-width: 1023px) and (min-width: 768px) {
    .header {
        padding: 14px 20px;
    }
    
    .header-left {
        gap: 16px;
    }
    
    .logo {
        font-size: 22px;
    }
    
    .stats {
        gap: 12px;
    }
    
    .stat-item {
        padding: 10px 12px;
        min-width: 70px;
    }
    
    .stat-value {
        font-size: 18px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .language-selection-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }
    
    .level-selection {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 16px;
    }
    
    .course-plan-card {
        padding: 30px;
    }
    
    .course-plan-header h2 {
        font-size: 28px;
    }
    
    .chat-container {
        padding: 20px;
        max-height: calc(100vh - 300px);
    }
    
    .message-content {
        max-width: 75%;
        padding: 12px 16px;
    }
    
    .input-area {
        padding: 16px;
    }
}

/* Mobile devices (iPhone and small tablets) - 767px and below */
@media (max-width: 767px) {
    /* Body and base */
    body {
        font-size: 16px;
        -webkit-text-size-adjust: 100%;
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    }
    
    /* Header - Stack vertically on mobile */
    .header {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
        position: sticky;
        top: 0;
    }
    
    .header-left {
        width: 100%;
        justify-content: space-between;
        gap: 12px;
    }
    
    .logo {
        font-size: 20px;
    }
    
    .logo-icon {
        font-size: 24px;
    }
    
    .language-info {
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .language-info .flag {
        font-size: 18px;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .stats {
        width: 100%;
        justify-content: space-between;
        gap: 8px;
    }
    
    .stat-item {
        flex: 1;
        padding: 10px 8px;
        min-width: auto;
    }
    
    .stat-icon {
        font-size: 18px;
    }
    
    .stat-value {
        font-size: 18px;
    }
    
    .stat-label {
        font-size: 11px;
    }
    
    /* Main content */
    .main-content {
        padding: 16px;
        gap: 16px;
    }
    
    /* Modal improvements for mobile */
    .modal {
        padding: 16px;
        align-items: flex-start;
        padding-top: 20px;
    }
    
    .modal-content {
        padding: 24px 20px;
        max-width: 100%;
        border-radius: var(--radius-lg);
        max-height: calc(100vh - 40px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .modal-content h2 {
        font-size: 24px;
    }
    
    /* Onboarding */
    .onboarding-step h2 {
        font-size: 24px;
    }
    
    .onboarding-step p {
        font-size: 16px;
    }
    
    .onboarding-icon {
        font-size: 48px;
    }
    
    .language-selection-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 10px;
        max-height: 350px;
        padding: 8px;
    }
    
    .language-item {
        padding: 12px 8px;
        gap: 6px;
    }
    
    .language-item .flag {
        font-size: 28px;
    }
    
    .language-item .name {
        font-size: 13px;
    }
    
    /* Level selection */
    .level-selection {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .level-option {
        padding: 20px;
    }
    
    .level-icon {
        font-size: 40px;
    }
    
    .level-option h3 {
        font-size: 18px;
    }
    
    /* Buttons - larger touch targets */
    .btn-primary, .btn-secondary {
        padding: 16px 24px;
        font-size: 16px;
        min-height: 48px; /* iOS recommended touch target */
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    }
    
    .btn-icon {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }
    
    /* Progress section */
    .progress-section {
        padding: 16px;
    }
    
    /* Course plan */
    .course-plan-card {
        padding: 20px;
    }
    
    .course-plan-header h2 {
        font-size: 24px;
    }
    
    .course-plan-subtitle {
        font-size: 16px;
    }
    
    .course-plan-item {
        padding: 16px;
    }
    
    .course-plan-item h3 {
        font-size: 18px;
    }
    
    /* Chat container */
    .chat-container {
        padding: 16px;
        min-height: 400px;
        max-height: calc(100vh - 250px);
        border-radius: var(--radius-md);
    }
    
    .chat-messages {
        padding: 8px;
        gap: 12px;
        -webkit-overflow-scrolling: touch;
    }
    
    .message {
        gap: 10px;
    }
    
    .message-avatar {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .message-content {
        max-width: 80%;
        padding: 12px 14px;
        font-size: 15px;
    }
    
    .message-text {
        font-size: 15px;
        line-height: 1.5;
    }
    
    .welcome-message {
        padding: 16px;
        flex-direction: column;
        text-align: center;
    }
    
    .welcome-avatar {
        font-size: 40px;
    }
    
    .welcome-content h3 {
        font-size: 18px;
    }
    
    /* Input area */
    .input-area {
        padding: 16px;
        border-radius: var(--radius-md);
    }
    
    .input-container {
        gap: 10px;
    }
    
    #messageInput {
        padding: 12px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 48px;
        max-height: 100px;
        border-radius: var(--radius-md);
    }
    
    .send-btn, .voice-btn {
        width: 48px;
        height: 48px;
        min-width: 48px;
        min-height: 48px;
    }
    
    .input-hint {
        font-size: 11px;
        margin-top: 6px;
    }
    
    /* Achievement popup */
    .achievement-popup {
        top: 80px;
        right: 16px;
        left: 16px;
        padding: 16px;
        max-width: calc(100% - 32px);
    }
    
    .achievement-icon {
        font-size: 40px;
    }
    
    .achievement-title {
        font-size: 16px;
    }
    
    .achievement-desc {
        font-size: 13px;
    }
    
    /* Sidebar */
    .sidebar {
        width: 100%;
        right: -100%;
    }
    
    /* Pricing */
    .pricing-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .pricing-option {
        padding: 20px;
    }
    
    .pricing-header h3 {
        font-size: 20px;
    }
    
    .pricing-price {
        font-size: 32px;
    }
    
    /* Auth modal */
    .auth-modal {
        max-width: 100%;
    }
    
    .auth-header h2 {
        font-size: 24px;
    }
    
    .social-btn {
        padding: 16px 20px;
        font-size: 15px;
        min-height: 48px;
    }
    
    .email-auth input {
        padding: 16px 18px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 48px;
    }
    
    /* User info */
    .user-info {
        padding: 6px 12px;
    }
    
    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
    
    .user-name {
        font-size: 13px;
    }
    
    /* Navigation buttons */
    .onboarding-nav {
        flex-direction: column;
        gap: 10px;
    }
    
    .onboarding-nav .btn-primary,
    .onboarding-nav .btn-secondary {
        width: 100%;
    }
}

/* iPhone specific (small screens) */
@media (max-width: 480px) {
    .header {
        padding: 10px 12px;
    }
    
    .logo {
        font-size: 18px;
    }
    
    .main-content {
        padding: 12px;
    }
    
    .language-selection-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
    }
    
    .language-item {
        padding: 10px 6px;
    }
    
    .language-item .flag {
        font-size: 24px;
    }
    
    .language-item .name {
        font-size: 12px;
    }
    
    .stat-item {
        padding: 8px 6px;
    }
    
    .stat-value {
        font-size: 16px;
    }
    
    .stat-label {
        font-size: 10px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .chat-container {
        padding: 12px;
        max-height: calc(100vh - 220px);
    }
    
    .modal-content {
        padding: 20px 16px;
    }
    
    .course-plan-card {
        padding: 16px;
    }
    
    .course-plan-header h2 {
        font-size: 20px;
    }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Prevent text size adjustment on orientation change */
    html {
        -webkit-text-size-adjust: 100%;
    }
    
    /* Better scrolling on iOS */
    .chat-messages,
    .language-selection-grid,
    .modal-content {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix for iOS input zoom */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea {
        font-size: 16px !important;
    }
    
    /* Safe area for notched devices */
    .header {
        padding-top: max(16px, env(safe-area-inset-top));
    }
    
    .input-area {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* Landscape orientation on mobile */
@media (max-width: 767px) and (orientation: landscape) {
    .header {
        padding: 10px 16px;
    }
    
    .stats {
        gap: 6px;
    }
    
    .stat-item {
        padding: 8px 6px;
    }
    
    .chat-container {
        max-height: calc(100vh - 180px);
    }
    
    .main-content {
        padding: 12px;
    }
}

/* Touch device optimizations (iOS & Android) */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .language-item,
    .level-option {
        min-height: 60px;
    }
    
    /* Remove hover effects, add active states */
    .language-item:hover,
    .level-option:hover {
        transform: none;
    }
    
    .language-item:active,
    .level-option:active {
        transform: scale(0.98);
        opacity: 0.8;
    }
    
    .btn-primary:active,
    .btn-secondary:active {
        transform: scale(0.98);
    }
}

/* Android-specific optimizations */
@supports (-webkit-appearance: none) and (not (-webkit-touch-callout: none)) {
    /* Android Chrome/WebView */
    body {
        -webkit-font-smoothing: antialiased;
        text-rendering: optimizeLegibility;
    }
    
    /* Better scrolling on Android */
    .chat-messages,
    .language-selection-grid,
    .modal-content {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    
    /* Fix for Android input zoom */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea {
        font-size: 16px !important;
    }
    
    /* Better touch feedback on Android */
    .btn-primary:active,
    .btn-secondary:active,
    .btn-icon:active {
        background-color: rgba(99, 102, 241, 0.2);
    }
    
    .language-item:active,
    .level-option:active {
        background-color: rgba(99, 102, 241, 0.15);
    }
}

/* Android Chrome specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    /* Fix for Android Chrome viewport issues */
    html {
        height: -webkit-fill-available;
    }
    
    body {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
    
    /* Better text rendering on Android */
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Samsung Internet browser fixes */
@supports (-webkit-tap-highlight-color: transparent) {
    /* Remove tap highlight on Samsung Internet */
    * {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    }
    
    a, button, .language-item, .level-option {
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.3);
    }
}

/* Android tablets (7-10 inches) */
@media (min-width: 600px) and (max-width: 1024px) and (orientation: portrait) {
    .language-selection-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .level-selection {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats {
        gap: 16px;
    }
    
    .stat-item {
        min-width: 90px;
    }
}

/* Android phones - various sizes */
@media (max-width: 599px) {
    /* Extra small Android phones */
    .header {
        padding: 10px 12px;
    }
    
    .main-content {
        padding: 12px;
    }
    
    .chat-container {
        padding: 12px;
    }
    
    .modal-content {
        padding: 20px 16px;
    }
}

/* High DPI Android devices */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Better rendering on high DPI screens */
    .logo,
    .onboarding-icon,
    .level-icon,
    .achievement-icon {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Android landscape orientation */
@media (max-width: 767px) and (orientation: landscape) {
    .header {
        padding: 8px 16px;
        flex-direction: row;
        gap: 12px;
    }
    
    .header-left {
        flex: 1;
    }
    
    .stats {
        gap: 8px;
    }
    
    .stat-item {
        padding: 8px 10px;
        min-width: 65px;
    }
    
    .main-content {
        padding: 12px;
    }
    
    .chat-container {
        max-height: calc(100vh - 160px);
        min-height: 300px;
    }
    
    .language-selection-grid {
        max-height: 250px;
    }
    
    .modal-content {
        max-height: calc(100vh - 20px);
    }
}

/* Fix for Android keyboard appearing */
@media (max-width: 767px) {
    /* Prevent layout shift when keyboard appears */
    .input-area {
        position: sticky;
        bottom: 0;
        z-index: 10;
    }
    
    /* Adjust chat height when keyboard is visible */
    .chat-container {
        padding-bottom: 8px;
    }
    
    /* Ensure input stays visible */
    #messageInput {
        font-size: 16px; /* Prevents zoom on Android Chrome */
    }
}

/* Android Chrome address bar fix */
@media (max-width: 767px) {
    /* Account for Android Chrome address bar */
    .app-container {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
    
    .chat-container {
        /* Use calc to account for dynamic viewport */
        max-height: calc(100vh - 200px);
        max-height: calc(100dvh - 200px); /* Dynamic viewport height */
    }
}

/* Material Design inspired touch feedback for Android */
@media (hover: none) and (pointer: coarse) {
    .btn-primary,
    .btn-secondary,
    .btn-icon,
    .language-item,
    .level-option {
        position: relative;
        overflow: hidden;
    }
    
    .btn-primary::after,
    .btn-secondary::after,
    .btn-icon::after,
    .language-item::after,
    .level-option::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.3);
        transform: translate(-50%, -50%);
        transition: width 0.3s, height 0.3s;
    }
    
    .btn-primary:active::after,
    .btn-secondary:active::after,
    .btn-icon:active::after,
    .language-item:active::after,
    .level-option:active::after {
        width: 300px;
        height: 300px;
    }
}

/* Fix for Android WebView (in-app browsers) */
@media (max-width: 767px) {
    /* Ensure proper rendering in WebView */
    html {
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    
    /* Better font rendering */
    body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    }
}

/* Android specific scrollbar styling */
@media (max-width: 767px) {
    .chat-messages::-webkit-scrollbar,
    .language-selection-grid::-webkit-scrollbar,
    .modal-content::-webkit-scrollbar {
        width: 6px;
    }
    
    .chat-messages::-webkit-scrollbar-thumb,
    .language-selection-grid::-webkit-scrollbar-thumb,
    .modal-content::-webkit-scrollbar-thumb {
        background: var(--primary);
        border-radius: 3px;
    }
    
    .chat-messages::-webkit-scrollbar-track,
    .language-selection-grid::-webkit-scrollbar-track,
    .modal-content::-webkit-scrollbar-track {
        background: transparent;
    }
}

/* Authentication Modal */
.auth-modal {
    max-width: 480px;
}

.auth-container {
    width: 100%;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h2 {
    font-size: 28px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.social-login-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.social-btn {
    width: 100%;
    padding: 14px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.social-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.social-btn:hover::before {
    left: 100%;
}

.social-btn:hover {
    border-color: var(--border-hover);
    background: var(--bg-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.social-btn svg {
    flex-shrink: 0;
}

.google-btn:hover {
    border-color: #4285F4;
    background: rgba(66, 133, 244, 0.1);
}

.twitter-btn {
    color: #1DA1F2;
}

.twitter-btn:hover {
    border-color: #1DA1F2;
    background: rgba(29, 161, 242, 0.1);
}

.linkedin-btn {
    color: #0077B5;
}

.linkedin-btn:hover {
    border-color: #0077B5;
    background: rgba(0, 119, 181, 0.1);
}

.instagram-btn {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    border: none;
    color: white;
}

.instagram-btn:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.facebook-btn {
    color: #1877F2;
}

.facebook-btn:hover {
    border-color: #1877F2;
    background: rgba(24, 119, 242, 0.1);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 24px 0;
    text-align: center;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-divider span {
    padding: 0 16px;
    color: var(--text-muted);
    font-size: 14px;
}

.email-auth {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.email-auth input {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    transition: var(--transition);
}

.email-auth input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.auth-switch {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 8px;
}

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

.auth-switch a:hover {
    color: var(--secondary);
    text-decoration: underline;
}

.auth-view {
    animation: fadeIn 0.3s ease;
}

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

/* User Info in Header */
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.user-info:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.logout-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.logout-btn:hover {
    border-color: var(--error);
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}
