:root {
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --bg-card: #162033;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.18);
  --accent: #3b82f6;
  --accent-2: #8b5cf6;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* === THEME 1: KIDS (Миша — тёмная игровая / кибер) === */
html[data-theme="kids"] {
  --bg: #080d18;
  --bg-elevated: #111a2e;
  --bg-card: #0f172a;
  --text: #f8fafc;
  --text-muted: #93c5fd;
  --border: rgba(34, 211, 238, 0.28);
  --accent: #06b6d4;
  --accent-2: #10b981;
  --accent-soft: rgba(6, 182, 212, 0.18);
  --radius: 20px;
  --shadow: 0 0 24px rgba(6, 182, 212, 0.14);
}
html[data-theme="kids"][data-mode="light"] {
  --bg: #ecfeff;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --text: #0f172a;
  --text-muted: #0369a1;
  --border: rgba(6, 182, 212, 0.3);
  --shadow: 0 8px 24px rgba(6, 182, 212, 0.12);
}

/* === THEME 2: TEEN (Маша — светло-пастельная эстетик + тёмный режим) === */
html[data-theme="teen"][data-mode="light"] {
  --bg: #faf7ff;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --text: #1e1b2e;
  --text-muted: #6b6285;
  --border: rgba(139, 92, 246, 0.18);
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --accent-soft: rgba(139, 92, 246, 0.12);
  --radius: 22px;
  --shadow: 0 10px 28px rgba(139, 92, 246, 0.1);
}
html[data-theme="teen"][data-mode="dark"] {
  --bg: #120f1c;
  --bg-elevated: #1d182e;
  --bg-card: #181426;
  --text: #f5f3ff;
  --text-muted: #a79ec4;
  --border: rgba(167, 139, 250, 0.22);
  --accent: #a78bfa;
  --accent-2: #f472b6;
  --accent-soft: rgba(167, 139, 250, 0.16);
  --radius: 22px;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

/* === THEME 3: ADULT (Ким и Марина — чистый минимализм) === */
html[data-theme="adult"][data-mode="light"] {
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-2: #4f46e5;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --radius: 14px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}
html[data-theme="adult"][data-mode="dark"] {
  --bg: #0b1120;
  --bg-elevated: #111827;
  --bg-card: #131c2e;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.16);
  --accent: #3b82f6;
  --accent-2: #6366f1;
  --accent-soft: rgba(59, 130, 246, 0.15);
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.loading-screen {
  min-height: 80dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-muted);
}

.logo-badge {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
}
.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Tabs */
.tabs {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.tab-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.15s ease;
}
.tab-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}
.btn-ghost {
  background: transparent;
}
.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
}

/* Login screen */
.login-wrap {
  max-width: 620px;
  margin: 36px auto 0;
}
.login-header {
  text-align: center;
  margin-bottom: 24px;
}
.login-header .logo-badge {
  margin: 0 auto 14px;
  width: 64px;
  height: 64px;
  font-size: 28px;
}
.login-header h1 {
  margin: 0 0 6px;
  font-size: 26px;
}
.login-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}
.net-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.profiles-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.14s ease, border-color 0.15s ease;
  color: var(--text);
}
.profile-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.profile-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow);
}
.avatar-circle {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
}
.profile-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}
.profile-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.password-panel {
  margin-top: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.field label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}
.input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.input:focus {
  border-color: var(--accent);
}
.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin: 6px 0 10px;
}

/* Dashboard Cards */
.hero-card {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.hero-title {
  margin: 0 0 6px;
  font-size: 22px;
}
.hero-sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.stat-value {
  font-size: 20px;
  font-weight: 800;
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  overflow: hidden;
  margin-top: 12px;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.chip {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.card h3 {
  margin: 0;
  font-size: 17px;
}
.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.badge-ok {
  background: rgba(16, 185, 129, 0.16);
  color: var(--success);
}
.badge-warn {
  background: rgba(245, 158, 11, 0.16);
  color: var(--warning);
}

.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 22px 0 12px;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 6px;
}
.inline-form .input {
  flex: 1 1 160px;
  padding: 8px 11px;
  font-size: 14px;
}

.toast {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--accent);
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
  z-index: 1000;
}

@media (max-width: 680px) {
  .grid-2 { grid-template-columns: 1fr; }
  .profiles-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .hero-title { font-size: 19px; }
}

/* === Stage 2: Interactive learning UI === */
.card-clickable {
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.15s ease;
}
.card-clickable:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.back-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.flashcard {
  background: linear-gradient(155deg, var(--bg-card), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
}
.fc-word {
  font-size: 32px;
  font-weight: 800;
  margin: 8px 0 6px;
  line-height: 1.2;
}
.fc-ipa {
  font-size: 16px;
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-bottom: 14px;
}
.audio-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.fc-answer {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
  text-align: left;
}
.fc-translation {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
}
.fc-example {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.45;
}
.fc-example-ru {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}
.fsrs-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}
.fsrs-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-weight: 700;
  font-size: 14px;
}
.fsrs-btn small {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}
.fsrs-btn[data-rating="1"] { border-color: rgba(239, 68, 68, 0.5); }
.fsrs-btn[data-rating="2"] { border-color: rgba(245, 158, 11, 0.5); }
.fsrs-btn[data-rating="3"] { border-color: rgba(16, 185, 129, 0.6); }
.fsrs-btn[data-rating="4"] { border-color: rgba(59, 130, 246, 0.6); }

/* Quiz / Placement */
.quiz-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  max-width: 700px;
  margin: 0 auto;
}
.passage-box {
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.55;
  margin: 12px 0 16px;
}
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.option-btn {
  text-align: left;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: 0.12s ease;
}
.option-btn:hover { border-color: var(--accent); }
.option-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.option-btn.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.16);
}
.option-btn.wrong {
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.16);
}

/* Lesson rules & clickable words */
.rule-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.rule-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 10px;
  color: var(--accent);
}
.word-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.word-pill {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.word-pill:hover { border-color: var(--accent); }
.story-para {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  font-size: 16px;
  line-height: 1.5;
}
.lesson-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 8px;
  cursor: pointer;
}
.lesson-row:hover { border-color: var(--accent); }

/* === Stage 3: Live Voice Chat & Shadowing === */
.voice-controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.select-input {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
}
.chat-feed {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 220px;
  max-height: 50dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}
.msg-bubble {
  max-width: 86%;
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.45;
}
.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}
.msg-assistant {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.subtitle-hidden {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mic-dock {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.mic-btn {
  width: 100%;
  max-width: 340px;
  padding: 16px 22px;
  border-radius: 999px;
  border: 0;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease;
}
.mic-btn.recording {
  background: linear-gradient(135deg, #ef4444, #f97316);
  animation: pulseMic 1.2s infinite;
}
@keyframes pulseMic {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* === Stage 4: Rewards Shop & 14-day Activity Calendar === */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: 4px;
  margin: 10px 0 6px;
}
.cal-day {
  border-radius: 6px;
  padding: 5px 2px;
  text-align: center;
  font-size: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.cal-day.lvl-1 {
  background: rgba(16, 185, 129, 0.22);
  border-color: rgba(16, 185, 129, 0.45);
  color: var(--text);
}
.cal-day.lvl-2 {
  background: rgba(16, 185, 129, 0.55);
  border-color: var(--success);
  color: #fff;
  font-weight: 700;
}
.reward-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.reward-icon {
  font-size: 26px;
  line-height: 1;
}
@media (max-width: 680px) {
  .cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
