/* ============================================================
   Languana CSS v2 - Full UX Redesign
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700&family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,400&display=swap');

:root {
  --bg: #FBF8F4;
  --bg-card: #FFFFFF;
  --bg-chat: #F3EDE4;
  --text: #1A1612;
  --text-muted: #7A7067;
  --text-light: #A89E94;
  --accent: #D4622B;
  --accent-hover: #BF5522;
  --accent-soft: #FCEEE5;
  --green: #3A8F5C;
  --green-soft: #E6F4EC;
  --blue: #3B6DB5;
  --blue-soft: #E8EFF8;
  --red: #C44536;
  --red-soft: #FCEAE8;
  --purple: #9B5FB5;
  --purple-soft: #F3ECF7;
  --border: #E8E0D6;
  --shadow-sm: 0 1px 3px rgba(26,22,18,0.06);
  --shadow-md: 0 4px 12px rgba(26,22,18,0.08);
  --shadow-lg: 0 8px 30px rgba(26,22,18,0.12);
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --max-w: 480px;
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* ---- App Shell ---- */
#app { max-width: var(--max-w); margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; position: relative; }
.view { display: none; flex-direction: column; flex: 1; }
.view.active { display: flex; }
.tab-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ---- Header ---- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--bg-card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.app-header h1 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; color: var(--accent); letter-spacing: -0.02em; }
.header-points {
  display: flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent);
  font-weight: 600; font-size: 0.875rem; padding: 6px 12px; border-radius: var(--radius-pill); cursor: pointer;
}
.header-points .coin { width: 18px; height: 18px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: white; font-size: 0.65rem; font-weight: 700; }

/* ---- Bottom Nav ---- */
.bottom-nav { display: flex; background: var(--bg-card); border-top: 1px solid var(--border); position: sticky; bottom: 0; z-index: 100; }
.bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px; font-size: 0.6rem; font-weight: 500; color: var(--text-muted); transition: color var(--transition);
}
.bottom-nav button.active { color: var(--accent); }
.bottom-nav button svg { width: 20px; height: 20px; }

/* ---- Auth ---- */
.auth-view { justify-content: center; align-items: center; padding: 32px 24px; text-align: center; }
.auth-logo { font-family: var(--font-display); font-size: 2.5rem; font-weight: 700; color: var(--accent); margin-bottom: 4px; letter-spacing: -0.03em; }
.auth-tagline { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 36px; }
.auth-form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.auth-form input { width: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); transition: border-color var(--transition); }
.auth-form input:focus { outline: none; border-color: var(--accent); }
.auth-toggle { margin-top: 16px; font-size: 0.875rem; color: var(--text-muted); }
.auth-toggle a { font-weight: 600; }
.auth-error { color: var(--red); font-size: 0.85rem; min-height: 1.2em; }

/* ---- Onboarding ---- */
.onboard-view { padding: 32px 24px; gap: 24px; }
.onboard-view h2 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; }
.onboard-view p { color: var(--text-muted); font-size: 0.95rem; }
.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option-card { padding: 16px; border: 2px solid var(--border); border-radius: var(--radius); text-align: center; font-weight: 500; font-size: 0.95rem; cursor: pointer; transition: all var(--transition); background: var(--bg-card); }
.option-card:hover { border-color: var(--text-light); }
.option-card.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.option-card .emoji { font-size: 1.5rem; display: block; margin-bottom: 6px; }

/* ---- HOME DASHBOARD ---- */
.home-scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.home-welcome { background: linear-gradient(135deg, var(--accent) 0%, #E07A42 100%); border-radius: var(--radius-lg); padding: 24px 20px; color: white; }
.home-greeting h2 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; margin-bottom: 2px; }
.home-sub { opacity: 0.85; font-size: 0.85rem; }
.home-stats-row { display: flex; gap: 8px; margin-top: 18px; }
.home-stat { flex: 1; background: rgba(255,255,255,0.18); border-radius: var(--radius); padding: 10px 8px; text-align: center; }
.home-stat-num { display: block; font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.home-stat-label { font-size: 0.65rem; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.05em; }

.section-title { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }

.continue-card {
  background: var(--bg-card); border-radius: var(--radius-lg); padding: 16px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 14px; cursor: pointer; border: 2px solid transparent; transition: all var(--transition);
}
.continue-card:hover { border-color: var(--accent-soft); box-shadow: var(--shadow-md); }
.continue-card .cc-avatar { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; color: white; flex-shrink: 0; }
.continue-card .cc-info { flex: 1; min-width: 0; }
.continue-card .cc-name { font-weight: 600; font-size: 0.95rem; }
.continue-card .cc-preview { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.continue-card .cc-time { font-size: 0.7rem; color: var(--text-light); margin-top: 2px; }
.continue-card .cc-arrow { color: var(--accent); font-size: 1.2rem; flex-shrink: 0; }

.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: all var(--transition); border: 1px solid transparent;
}
.recent-item:hover { border-color: var(--accent-soft); }
.recent-item .ri-avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 1rem; font-weight: 700; color: white; flex-shrink: 0; }
.recent-item .ri-info { flex: 1; min-width: 0; }
.recent-item .ri-name { font-weight: 600; font-size: 0.85rem; }
.recent-item .ri-preview { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item .ri-meta { font-size: 0.65rem; color: var(--text-light); flex-shrink: 0; text-align: right; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.quick-action {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px;
  background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: all var(--transition); border: 1px solid transparent;
}
.quick-action:hover { border-color: var(--accent-soft); box-shadow: var(--shadow-md); }
.qa-icon { font-size: 1.5rem; }
.qa-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }

.home-empty { text-align: center; padding: 32px 16px; background: var(--bg-card); border-radius: var(--radius-lg); }
.home-empty h3 { font-family: var(--font-display); font-size: 1.1rem; margin-top: 8px; }
.home-empty p { color: var(--text-muted); font-size: 0.85rem; margin-top: 6px; }
.emoji-big { font-size: 2.5rem; }

/* ---- FRIENDS ---- */
.friends-scroll { flex: 1; overflow-y: auto; padding: 16px; }
.friends-header { margin-bottom: 16px; }
.friends-header h2 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; margin-bottom: 10px; }
.language-filter { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.lang-pill {
  padding: 6px 14px; border-radius: var(--radius-pill); font-size: 0.8rem; font-weight: 600;
  background: var(--bg-card); border: 1px solid var(--border); white-space: nowrap; transition: all var(--transition);
}
.lang-pill.active { background: var(--accent); color: white; border-color: var(--accent); }

.char-list { display: flex; flex-direction: column; gap: 10px; }
.char-card {
  display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--bg-card);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); cursor: pointer;
  transition: all var(--transition); border: 2px solid transparent;
}
.char-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent-soft); }
.char-avatar { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; color: white; flex-shrink: 0; }
.char-avatar.c1 { background: #D4622B; } .char-avatar.c2 { background: #3A8F5C; }
.char-avatar.c3 { background: #3B6DB5; } .char-avatar.c4 { background: #9B5FB5; }
.char-avatar.c5 { background: #7A7067; }
.char-info { flex: 1; min-width: 0; }
.char-info h3 { font-size: 1rem; font-weight: 600; margin-bottom: 2px; }
.char-info p { font-size: 0.8rem; color: var(--text-muted); line-height: 1.35; }
.char-info .char-vibe { display: inline-block; font-size: 0.65rem; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: var(--radius-pill); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.char-info .char-preview { font-size: 0.75rem; color: var(--text-light); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-style: italic; }

/* ---- CHAT ---- */
.chat-view { flex: 1; }
.chat-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.chat-header .back-btn { font-size: 1.25rem; color: var(--text-muted); padding: 4px; }
.chat-header .char-avatar { width: 38px; height: 38px; font-size: 1rem; }
.chat-header-info { flex: 1; }
.chat-header-info h3 { font-size: 0.95rem; font-weight: 600; }
.chat-header-info p { font-size: 0.75rem; color: var(--text-muted); }
.chat-info-btn { font-size: 1.3rem; color: var(--text-muted); padding: 4px 8px; transition: color var(--transition); }
.chat-info-btn:hover { color: var(--accent); }

.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--bg-chat); }
.message { max-width: 82%; padding: 10px 14px; border-radius: 16px; font-size: 0.95rem; line-height: 1.45; animation: msgIn 0.25s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.message.character { background: var(--bg-card); border-bottom-left-radius: 4px; align-self: flex-start; box-shadow: var(--shadow-sm); }
.message.user { background: var(--accent); color: white; border-bottom-right-radius: 4px; align-self: flex-end; }
.message .word { cursor: pointer; border-radius: 3px; padding: 0 1px; transition: background var(--transition); }
.message .word:hover { background: rgba(212,98,43,0.15); }
.message .word.translated { color: var(--accent); font-weight: 600; position: relative; }
.message .word.translated::after {
  content: attr(data-translation); position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white; font-size: 0.7rem; font-weight: 400; padding: 3px 8px; border-radius: 6px;
  white-space: nowrap; pointer-events: none; animation: tooltipIn 0.15s ease;
}
@keyframes tooltipIn { from { opacity: 0; transform: translateX(-50%) translateY(4px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.chat-input-area { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--bg-card); border-top: 1px solid var(--border); }
.chat-input-area input { flex: 1; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--bg); font-size: 0.95rem; }
.chat-input-area input:focus { outline: none; border-color: var(--accent); }
.send-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: white; display: flex; align-items: center; justify-content: center; transition: background var(--transition); flex-shrink: 0; }
.send-btn:hover { background: var(--accent-hover); }

.typing-indicator { align-self: flex-start; background: var(--bg-card); padding: 10px 16px; border-radius: 16px; border-bottom-left-radius: 4px; display: none; gap: 4px; box-shadow: var(--shadow-sm); }
.typing-indicator.show { display: flex; }
.typing-dot { width: 7px; height: 7px; background: var(--text-light); border-radius: 50%; animation: typingBounce 1.2s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* ---- CHARACTER INFO ---- */
.charinfo-scroll { flex: 1; overflow-y: auto; padding: 16px; }
.charinfo-back { font-size: 0.85rem; color: var(--accent); font-weight: 600; margin-bottom: 16px; display: inline-block; }
.charinfo-header { text-align: center; margin-bottom: 24px; }
.char-avatar-lg { width: 80px; height: 80px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: white; margin: 0 auto 12px; }
.charinfo-header h2 { font-family: var(--font-display); font-size: 1.4rem; }
.ci-meta { color: var(--text-muted); font-size: 0.9rem; }
.charinfo-section { margin-bottom: 20px; padding: 16px; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.charinfo-section h4 { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.charinfo-section p { font-size: 0.9rem; line-height: 1.5; color: var(--text); }
.ci-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.ci-tag { padding: 4px 12px; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 500; }
.ci-vibe-note { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 10px; }

/* ---- VIBE SELECTOR ---- */
.vibe-selector { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vibe-btn {
  padding: 10px; border: 2px solid var(--border); border-radius: var(--radius); font-size: 0.85rem;
  font-weight: 500; text-align: center; transition: all var(--transition); background: var(--bg-card);
}
.vibe-btn:hover { border-color: var(--text-light); }
.vibe-btn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ---- QUIZ ---- */
.quiz-view { padding: 24px 16px; gap: 20px; overflow-y: auto; }
.quiz-view h2 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }
.quiz-stats { display: flex; gap: 12px; }
.quiz-stat { flex: 1; text-align: center; padding: 14px; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.quiz-stat .num { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.quiz-stat .label { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.quiz-card { background: var(--bg-card); border-radius: var(--radius-lg); padding: 28px 20px; box-shadow: var(--shadow-md); text-align: center; }
.quiz-word { font-family: var(--font-display); font-size: 2rem; font-weight: 700; margin-bottom: 8px; }
.quiz-prompt { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 24px; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option { width: 100%; padding: 14px 20px; border: 2px solid var(--border); border-radius: var(--radius); font-size: 1rem; font-weight: 500; text-align: left; transition: all var(--transition); background: var(--bg-card); }
.quiz-option:hover { border-color: var(--text-light); }
.quiz-option.correct { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.quiz-option.wrong { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.quiz-empty { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.quiz-empty .emoji { font-size: 2.5rem; margin-bottom: 12px; }

/* ---- STORE ---- */
.store-view { padding: 24px 16px; gap: 16px; overflow-y: auto; }
.store-view h2 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; }
.store-balance { text-align: center; padding: 24px; background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.store-balance .num { font-family: var(--font-display); font-size: 2.5rem; font-weight: 700; color: var(--accent); }
.store-balance .label { font-size: 0.85rem; color: var(--text-muted); }
.store-packages { display: flex; flex-direction: column; gap: 10px; }
.store-package { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 2px solid transparent; transition: all var(--transition); cursor: pointer; }
.store-package:hover { border-color: var(--accent-soft); box-shadow: var(--shadow-md); }
.pkg-points { font-weight: 600; font-size: 1.05rem; }
.pkg-price { background: var(--accent); color: white; padding: 8px 18px; border-radius: var(--radius-pill); font-weight: 600; font-size: 0.9rem; }

/* ---- PROFILE ---- */
.profile-scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 20px; }
.profile-header { text-align: center; padding: 24px 16px; background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.profile-avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: white; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; margin: 0 auto 10px; }
.profile-header h2 { font-family: var(--font-display); font-size: 1.3rem; }
.profile-email { color: var(--text-muted); font-size: 0.85rem; }

.profile-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.profile-stat-card { text-align: center; padding: 16px 8px; background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.ps-num { display: block; font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.ps-label { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.profile-section { background: var(--bg-card); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow-sm); }
.profile-section h3 { font-family: var(--font-display); font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.profile-note { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 10px; }

.profile-lang-card { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.plc-flag { font-size: 1.5rem; }
.plc-name { font-weight: 600; flex: 1; }
.plc-badge { font-size: 0.7rem; font-weight: 600; background: var(--green-soft); color: var(--green); padding: 3px 10px; border-radius: var(--radius-pill); }

.vocab-summary p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 10px; }
.vocab-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow: hidden; }
.vocab-list.expanded { max-height: none; }
.vocab-word { padding: 4px 12px; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-pill); font-size: 0.75rem; font-weight: 500; }

.btn-logout { width: 100%; padding: 14px; background: none; border: 1px solid var(--red); color: var(--red); border-radius: var(--radius); font-weight: 600; font-size: 0.95rem; transition: all var(--transition); }
.btn-logout:hover { background: var(--red-soft); }

/* ---- Buttons ---- */
.btn-primary { width: 100%; padding: 14px 24px; background: var(--accent); color: white; font-weight: 600; font-size: 1rem; border-radius: var(--radius); transition: background var(--transition); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { width: 100%; padding: 14px 24px; background: var(--bg); color: var(--text); font-weight: 600; font-size: 1rem; border: 1px solid var(--border); border-radius: var(--radius); transition: all var(--transition); }
.btn-secondary:hover { background: var(--border); }

/* ---- Utilities ---- */
.hidden { display: none !important; }
.translate-popup { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--text); color: white; padding: 10px 20px; border-radius: var(--radius); font-size: 0.9rem; font-weight: 500; box-shadow: var(--shadow-lg); z-index: 200; display: none; animation: popupIn 0.2s ease; max-width: calc(var(--max-w) - 48px); text-align: center; }
.translate-popup.show { display: block; }
@keyframes popupIn { from { opacity: 0; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.translate-popup .cost { color: var(--accent-soft); font-size: 0.75rem; margin-top: 2px; }

.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); background: var(--green); color: white; padding: 10px 20px; border-radius: var(--radius-pill); font-size: 0.85rem; font-weight: 600; z-index: 300; display: none; animation: toastIn 0.3s ease; }
.toast.error { background: var(--red); }
.toast.show { display: block; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
/* ============================================================
   PHASE 1.5 CSS ADDITIONS
   Append to bottom of existing app.css
   Uses existing design tokens throughout.
   ============================================================ */

/* -- LEVEL PROGRESS CARD (Home dashboard) -- */
.level-progress-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.lp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.lp-tier-badge {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  color: white;
  background: var(--text-light);
}
.lp-tier-badge.tier-echo { background: var(--accent); }
.lp-tier-badge.tier-builder { background: var(--green); }
.lp-tier-badge.tier-speaker { background: var(--blue); }
.lp-tier-badge.tier-native { background: var(--purple); }
.lp-level-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.lp-level-title {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 4px;
}
.lp-bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.lp-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #E07A42);
  border-radius: 4px;
  transition: width 0.5s ease;
  min-width: 2px;
}
.lp-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* -- VOCABULARY DICTIONARY (Profile tab) -- */
.vocab-controls {
  margin-bottom: 12px;
}
.vocab-search-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 8px;
  outline: none;
  background: var(--bg);
  font-family: var(--font-body);
  transition: border-color var(--transition);
}
.vocab-search-input:focus {
  border-color: var(--accent);
}
.vocab-sort-row {
  display: flex;
  gap: 6px;
}
.vocab-sort-btn {
  flex: 1;
  padding: 7px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
}
.vocab-sort-btn:hover { border-color: var(--text-light); }
.vocab-sort-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.vocab-dict {
  max-height: 400px;
  overflow-y: auto;
}
.vocab-dict::-webkit-scrollbar { width: 4px; }
.vocab-dict::-webkit-scrollbar-track { background: transparent; }
.vocab-dict::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.vocab-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.vocab-row:last-child { border-bottom: none; }
.vr-words {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.vr-target {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.vr-native {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.vr-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.vr-strength {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.vr-date {
  font-size: 0.65rem;
  color: var(--text-light);
}
.vocab-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
}

/* -- OUR STORY (Character info panel) -- */
.ci-our-story {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
}
.ci-our-story p {
  margin-bottom: 10px;
}
.ci-our-story p:last-child { margin-bottom: 0; }
.ci-story-loading,
.ci-story-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* -- LEVEL-UP CELEBRATION MODAL -- */
.levelup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(26,22,18,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.levelup-overlay.show {
  opacity: 1;
  pointer-events: auto;
}
.levelup-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  transform: scale(0.85);
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1);
  box-shadow: var(--shadow-lg);
}
.levelup-overlay.show .levelup-card {
  transform: scale(1);
}
.levelup-emoji {
  font-size: 3.5rem;
  margin-bottom: 8px;
}
.levelup-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}
.levelup-detail {
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 4px;
}
.levelup-tier {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  display: inline-block;
  color: white;
  margin-top: 4px;
}
.levelup-tier.tier-echo { background: var(--accent); }
.levelup-tier.tier-builder { background: var(--green); }
.levelup-tier.tier-speaker { background: var(--blue); }
.levelup-tier.tier-native { background: var(--purple); }
