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

:root {
  --bg: #f5f5f0;
  --surface: #ffffff;
  --border: #e0dfd8;
  --text: #1a1a18;
  --text-muted: #6b6b68;
  --primary: #185FA5;
  --primary-bg: #E6F1FB;
  --success: #0F6E56;
  --success-bg: #E1F5EE;
  --success-border: #5DCAA5;
  --danger: #993C1D;
  --danger-bg: #FAECE7;
  --danger-border: #F0997B;
  --radius: 12px;
  --radius-sm: 8px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.6; }
.screen { min-height: 100vh; }
.hidden { display: none !important; }

.auth-container { max-width: 400px; margin: 0 auto; padding: 3rem 1.5rem; text-align: center; }
.logo { font-size: 56px; margin-bottom: 0.5rem; }
h1 { font-size: 24px; font-weight: 600; margin-bottom: 0.25rem; }
.subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 2rem; }

.tab-buttons { display: flex; margin-bottom: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.tab-btn { flex: 1; padding: 10px; background: var(--surface); border: none; cursor: pointer; font-size: 14px; color: var(--text-muted); transition: all 0.15s; }
.tab-btn.active { background: var(--primary); color: white; font-weight: 500; }

.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 15px; background: var(--surface); color: var(--text); outline: none; transition: border-color 0.15s; }
.auth-form input:focus { border-color: var(--primary); }
.btn-primary { width: 100%; padding: 12px; background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 500; cursor: pointer; }
.btn-primary:hover { opacity: 0.9; }
.error-msg { color: var(--danger); font-size: 13px; min-height: 18px; }

.navbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 1.5rem; height: 56px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.nav-logo { font-size: 16px; font-weight: 600; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.xp-badge { font-size: 13px; font-weight: 500; color: var(--primary); background: var(--primary-bg); padding: 4px 10px; border-radius: 20px; }
.nav-user { font-size: 13px; color: var(--text-muted); }
.btn-logout { font-size: 13px; color: var(--text-muted); background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 5px 10px; cursor: pointer; }

.content-screen { max-width: 640px; margin: 0 auto; padding: 1.5rem; }
.welcome-banner { margin-bottom: 1.5rem; }
.welcome-banner h2 { font-size: 20px; font-weight: 600; }
.welcome-banner p { color: var(--text-muted); font-size: 14px; }

.mode-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 2rem; }
.mode-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1rem; cursor: pointer; text-align: center; transition: all 0.15s; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mode-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.mode-icon { font-size: 32px; }
.mode-card h3 { font-size: 15px; font-weight: 600; }
.mode-card p { font-size: 12px; color: var(--text-muted); }

.stats-section h3 { font-size: 15px; font-weight: 600; margin-bottom: 0.75rem; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.stat-num { font-size: 24px; font-weight: 600; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); }

.exercise-header { display: flex; align-items: center; gap: 12px; margin-bottom: 1.5rem; }
.exercise-header h2 { font-size: 18px; font-weight: 600; }
.btn-back { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--text-muted); }
.loading { text-align: center; padding: 3rem 1rem; color: var(--text-muted); font-size: 14px; }

.exercise-instruction { font-size: 14px; color: var(--text-muted); margin-bottom: 1rem; }
.exercise-prompt { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; font-size: 18px; font-weight: 500; margin-bottom: 1.25rem; text-align: center; }
.options-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 1rem; }
.option-btn { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; cursor: pointer; font-size: 15px; color: var(--text); transition: all 0.15s; }
.option-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-bg); }
.option-btn.correct { border-color: var(--success-border); background: var(--success-bg); color: var(--success); }
.option-btn.wrong { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }

.feedback { border-radius: var(--radius-sm); padding: 1rem 1.25rem; margin-top: 1rem; }
.feedback.success { background: var(--success-bg); border: 1px solid var(--success-border); }
.feedback.error { background: var(--danger-bg); border: 1px solid var(--danger-border); }
.feedback p { font-size: 14px; margin-bottom: 4px; }
.feedback .feedback-title { font-weight: 600; font-size: 15px; }
.feedback.success .feedback-title { color: var(--success); }
.feedback.error .feedback-title { color: var(--danger); }
.feedback .feedback-tip { color: var(--text-muted); font-size: 13px; }
.btn-next { width: 100%; margin-top: 1rem; padding: 12px; background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 500; cursor: pointer; }
.btn-next:hover { opacity: 0.9; }

.chat-messages { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; min-height: 300px; max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; margin-bottom: 1rem; }
.msg { max-width: 80%; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; line-height: 1.5; }
.msg-ai { background: var(--bg); border: 1px solid var(--border); color: var(--text); align-self: flex-start; }
.msg-user { background: var(--primary); color: white; align-self: flex-end; }
.chat-input-area { display: flex; gap: 8px; }
.chat-input-area input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--surface); color: var(--text); outline: none; }
.chat-input-area input:focus { border-color: var(--primary); }
.btn-send { padding: 10px 18px; background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; font-weight: 500; }
.chat-hint { font-size: 12px; color: var(--text-muted); margin-top: 0.5rem; text-align: center; }

/* Level system */
.level-section { margin-bottom: 1.5rem; }
.level-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.level-badge { font-size: 14px; font-weight: 600; color: var(--primary); }
.xp-next { font-size: 12px; color: var(--text-muted); }
.xp-bar-container { background: var(--border); border-radius: 4px; height: 8px; overflow: hidden; }
.xp-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.5s; width: 0%; }
.level-tag { font-size: 11px; background: var(--primary-bg); color: var(--primary); padding: 2px 8px; border-radius: 20px; font-weight: 500; white-space: nowrap; }

/* Chat mode toggle */
.chat-mode-toggle { display: flex; gap: 0; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.chat-mode-btn { flex: 1; padding: 8px; background: var(--surface); border: none; cursor: pointer; font-size: 14px; color: var(--text-muted); transition: all 0.15s; }
.chat-mode-btn.active { background: var(--primary); color: white; font-weight: 500; }

/* Voice area */
.voice-area { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 1rem 0; }
.mic-btn { display: flex; flex-direction: column; align-items: center; gap: 8px; background: var(--surface); border: 2px solid var(--border); border-radius: 50%; width: 100px; height: 100px; cursor: pointer; transition: all 0.2s; font-size: 13px; color: var(--text-muted); }
.mic-btn:hover { border-color: var(--primary); }
.mic-btn.listening { border-color: #D85A30; background: #FAECE7; animation: pulse 1s infinite; }
.mic-btn.listening .mic-icon { animation: none; }
.mic-icon { font-size: 32px; }
.voice-transcript { font-size: 14px; color: var(--text-muted); text-align: center; min-height: 20px; font-style: italic; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
