/* ==========================================================
   ExamAI — стили
   Палитра: холодный светлый фон, синий и фиолетовый акценты
   ========================================================== */

:root {
  --bg: #F5F5FB;
  --surface: #FFFFFF;
  --border: #E7E8F3;
  --border-soft: rgba(23, 25, 51, 0.07);

  --ink: #14152B;
  --ink-soft: #57597A;
  --ink-faint: #9498AC;

  --blue: #3D4EC4;
  --blue-dark: #2C3A9C;
  --violet: #6F5EE8;
  --gold: #C9A24B;
  --gold-soft: #E7D3A1;

  --success: #1E9E62;
  --success-bg: #E6F7EE;
  --error: #D8434B;
  --error-bg: #FCEAEB;

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-card: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 1px rgba(23, 25, 51, 0.04), 0 3px 8px -4px rgba(23, 25, 51, 0.08), 0 20px 40px -20px rgba(44, 40, 130, 0.22);
  --shadow-elevated: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 2px 4px rgba(23, 25, 51, 0.06), 0 30px 54px -22px rgba(44, 40, 130, 0.32);
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

::selection { background: var(--violet); color: #fff; }

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--violet);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

input, select, textarea { transition: border-color 0.18s ease, box-shadow 0.18s ease; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--violet);
  box-shadow: 0 0 0 4px rgba(111, 94, 232, 0.15);
}

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--blue), var(--violet));
  border-radius: 999px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(var(--blue-dark), var(--violet)); }
html { scrollbar-color: var(--violet) transparent; scrollbar-width: thin; }

.stat-value, .result-score, .ring-percent, .level-name, .streak-badge,
.readiness-factor-value, .room-code-value, .exam-timer, .cal-month-label {
  font-variant-numeric: tabular-nums;
}

/* Мягкое фирменное свечение при наведении на кликабельные карточки —
   появляется в верхнем левом углу, добавляет ощущение "живого"
   интерфейса без резких эффектов */
.achievement-card, .subject-card, .exam-card, .tutor-card, .room-card {
  position: relative;
  overflow: hidden;
}
.achievement-card::before, .subject-card::before, .exam-card::before,
.tutor-card::before, .room-card::before {
  content: "";
  position: absolute;
  top: -40%;
  left: -20%;
  width: 60%;
  height: 180%;
  background: radial-gradient(circle, rgba(111, 94, 232, 0.16), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.achievement-card:hover::before, .subject-card:hover::before, .exam-card:hover::before,
.tutor-card:hover::before, .room-card:hover::before {
  opacity: 1;
}

h1, h2, h3,
.section-title,
.logo-text,
.result-score,
.exam-card-title,
.room-header-title,
.level-up-title {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

body { -webkit-font-smoothing: antialiased; position: relative; }

/* Тонкое фоновое свечение — два размытых пятна в цветах бренда,
   создают ощущение глубины, не отвлекая от контента */
body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.28;
  z-index: -1;
  pointer-events: none;
}
body::before {
  width: 420px;
  height: 420px;
  background: var(--blue);
  top: -140px;
  left: -120px;
  animation: blobFloatA 18s ease-in-out infinite;
}
body::after {
  width: 380px;
  height: 380px;
  background: var(--violet);
  top: 160px;
  right: -160px;
  animation: blobFloatB 22s ease-in-out infinite;
}

@keyframes blobFloatA {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(35px, 25px) scale(1.08); }
}
@keyframes blobFloatB {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-30px, -20px) scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
}

/* Третье, золотое пятно — совсем слабое, только для глубины внизу
   страницы, плюс тончайшее зерно по всей странице (не текстура из
   картинки, а SVG-шум прямо в CSS) — вместе они убирают ощущение
   плоского однотонного фона, которое обычно выдаёт "дешёвый" сайт */
#app::before {
  content: "";
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.14;
  z-index: -1;
  pointer-events: none;
  background: var(--gold);
  bottom: -220px;
  left: 30%;
}

.grain-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
}

.grain-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.025;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Едва заметное затемнение по краям экрана — глаз сам тянется к
   центру страницы, классический приём в дорогих интерфейсах */
.grain-overlay::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(20, 21, 43, 0.05) 100%);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select {
  font-family: inherit;
  font-size: 15px;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(245, 245, 251, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--gold), var(--violet));
  opacity: 0.6;
}

.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--violet), var(--blue));
  background-size: 220% 220%;
  animation: logoGradientShift 7s ease infinite;
  color: white;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  box-shadow: 0 3px 10px -2px rgba(61, 78, 196, 0.55), 0 0 0 2px rgba(201, 162, 75, 0.5);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes logoGradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .logo-mark { animation: none; }
}

.logo-text {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topnav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.auth-area { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.auth-user-btn {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-soft);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.auth-user-btn:hover { background: var(--surface); color: var(--ink); }

.auth-status-offline {
  font-size: 12px;
  color: var(--ink-faint);
  font-weight: 600;
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 19px;
  color: var(--ink);
  flex-shrink: 0;
}
.nav-toggle:hover { background: var(--surface); }

/* Ниже ~900px 8 пунктов меню больше не помещаются в одну строку —
   вместо некрасивого переноса на несколько строк показываем гамбургер,
   а сам список открываем как выпадающую панель под шапкой */
@media (max-width: 900px) {
  .nav-toggle { display: flex; }

  .topnav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 2px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px 14px;
    box-shadow: var(--shadow-card);
  }
  .topnav.open { display: flex; }

  .nav-link { width: 100%; text-align: left; padding: 11px 12px; }
}

.nav-link {
  position: relative;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover { background: var(--surface); color: var(--ink); }

.nav-link::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--blue), var(--violet));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}
.nav-link:hover::after { transform: scaleX(1); }

@media (max-width: 600px) {
  .nav-link { padding: 8px 10px; font-size: 13px; }
  .logo-text { display: none; }
}

/* ---------- Layout / screens ---------- */

#app {
  max-width: 1040px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.screen { display: none; }
.screen.active { display: block; animation: fadeUp 0.28s ease; }

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

/* Карточки в сетках появляются друг за другом с небольшой задержкой,
   а не все разом — так интерфейс ощущается более "живым" при каждом
   заходе на экран с предметами/достижениями/вариантами экзамена */
.subject-grid > *, .achievements-grid > *, .exam-grid > * {
  animation: fadeUp 0.4s ease backwards;
}
.subject-grid > *:nth-child(1), .achievements-grid > *:nth-child(1), .exam-grid > *:nth-child(1) { animation-delay: 0.02s; }
.subject-grid > *:nth-child(2), .achievements-grid > *:nth-child(2), .exam-grid > *:nth-child(2) { animation-delay: 0.06s; }
.subject-grid > *:nth-child(3), .achievements-grid > *:nth-child(3), .exam-grid > *:nth-child(3) { animation-delay: 0.10s; }
.subject-grid > *:nth-child(4), .achievements-grid > *:nth-child(4), .exam-grid > *:nth-child(4) { animation-delay: 0.14s; }
.subject-grid > *:nth-child(5), .achievements-grid > *:nth-child(5), .exam-grid > *:nth-child(5) { animation-delay: 0.18s; }
.subject-grid > *:nth-child(6), .achievements-grid > *:nth-child(6), .exam-grid > *:nth-child(6) { animation-delay: 0.22s; }
.subject-grid > *:nth-child(7), .achievements-grid > *:nth-child(7), .exam-grid > *:nth-child(7) { animation-delay: 0.26s; }
.subject-grid > *:nth-child(n+8), .achievements-grid > *:nth-child(n+8), .exam-grid > *:nth-child(n+8) { animation-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
  .subject-grid > *, .achievements-grid > *, .exam-grid > * { animation: none; }
}

.back-link {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 18px;
  padding: 6px 0;
}
.back-link:hover { color: var(--blue); }

.section-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}

.subsection-title {
  font-size: 16px;
  font-weight: 700;
  margin: 32px 0 14px;
}

/* ---------- Hero ---------- */

.hero {
  display: flex;
  align-items: center;
  gap: 40px;
  padding: 8px 4px 40px;
}

.hero-text { flex: 1; min-width: 0; }

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(120deg, rgba(61, 78, 196, 0.1), rgba(111, 94, 232, 0.1));
  border: 1px solid rgba(111, 94, 232, 0.2);
  color: var(--blue-dark);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 5px 14px;
  border-radius: 999px;
  margin: 0 0 16px;
}

.hero-text h1 {
  font-size: clamp(30px, 4.6vw, 44px);
  line-height: 1.14;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  background: linear-gradient(115deg, var(--ink) 40%, var(--blue) 75%, var(--violet));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

.hero-sub {
  font-size: 16.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 480px;
  margin: 0 0 28px;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-actions .btn { padding: 14px 26px; font-size: 15.5px; }

.hero-ring {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
  transition: transform 0.3s ease-out;
}

.ring-svg {
  width: 160px;
  height: 160px;
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 14px rgba(61, 78, 196, 0.3));
}

.ring-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 12;
}

.ring-fill {
  fill: none;
  stroke: url(#ringGradient);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 427;
  stroke-dashoffset: 427;
  transition: stroke-dashoffset 0.6s ease;
}

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ring-percent { font-size: 26px; font-weight: 800; }
.ring-caption { font-size: 12px; color: var(--ink-faint); margin-top: 2px; text-align: center; }

@media (max-width: 720px) {
  .hero { flex-direction: column-reverse; text-align: center; gap: 24px; }
  .hero-sub { margin-left: auto; margin-right: auto; }
  .hero-actions { justify-content: center; }
}

/* ---------- Buttons ---------- */

.btn {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--blue), var(--violet) 60%, var(--blue-dark));
  color: white;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 16px -6px rgba(61, 78, 196, 0.55);
}
.btn-primary:hover {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 10px 26px -8px rgba(61, 78, 196, 0.7);
  transform: translateY(-1.5px);
}

.btn-primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -75%;
  width: 45%;
  height: 100%;
  background: linear-gradient(115deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: skewX(-20deg);
  transition: left 0.55s ease;
  pointer-events: none;
}
.btn-primary:hover::after { left: 130%; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
  color: var(--ink);
  border: 1px solid var(--border-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.btn-ghost:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: rgba(255, 255, 255, 0.85);
  transform: translateY(-1px);
}

.btn-danger { color: var(--error); }
.btn-danger:hover { border-color: var(--error); color: var(--error); }

.btn-small { padding: 9px 16px; font-size: 14px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none !important; }

/* ---------- Задание дня ---------- */

.daily-task-card {
  background: linear-gradient(135deg, #EEF0FC, #F6F1FC);
  border: 1.5px solid var(--violet);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

.daily-task-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.daily-task-badge { font-size: 13px; font-weight: 800; color: var(--violet); }
.daily-task-sub { font-size: 12.5px; font-weight: 700; color: var(--ink-faint); }
.daily-task-done { font-size: 13px; font-weight: 700; color: var(--success); }

.daily-task-question { font-size: 16px; font-weight: 700; margin: 0 0 14px; line-height: 1.4; }

.daily-task-answer { display: flex; flex-direction: column; gap: 8px; }

.daily-task-feedback { margin-top: 14px; }
.daily-task-xp { font-weight: 800; color: var(--blue); margin: 8px 0 0; font-size: 13.5px; }

/* ---------- Continue block ---------- */

.continue-block { margin-bottom: 36px; }

.continue-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.continue-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px -14px rgba(30, 33, 48, 0.18);
}

.continue-eyebrow { font-size: 12.5px; color: var(--ink-faint); margin: 0 0 4px; font-weight: 600; }
.continue-title { font-size: 15.5px; font-weight: 700; margin: 0; }

/* ---------- Level card (XP, level, streak) ---------- */

.level-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.level-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px -14px rgba(30, 33, 48, 0.18);
}

.level-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.level-name { font-size: 15px; font-weight: 800; margin: 0 0 4px; }
.level-xp-text { font-size: 12.5px; color: var(--ink-faint); margin: 0; font-weight: 600; }

.streak-badge {
  flex-shrink: 0;
  background: #FFF4EA;
  color: #B45309;
  font-size: 13px;
  font-weight: 800;
  padding: 7px 12px;
  border-radius: 999px;
  white-space: nowrap;
  animation: streakGlow 2.6s ease-in-out infinite;
}

@keyframes streakGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(217, 119, 6, 0); }
  50% { box-shadow: 0 0 12px rgba(217, 119, 6, 0.35); }
}

.level-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.level-bar-fill {
  position: relative;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--violet));
  border-radius: 4px;
  transition: width 0.5s ease;
  overflow: hidden;
}

.level-bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: barShimmer 2.2s ease-in-out infinite;
}

@keyframes barShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ---------- Week streak calendar ---------- */

.week-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 28px;
}

.day-cell {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 4px;
  text-align: center;
}

.day-cell.done { border-color: var(--success); background: var(--success-bg); }
.day-cell.missed { color: var(--ink-faint); }
.day-cell.future { border-style: dashed; color: var(--ink-faint); }

.day-cell-label { display: block; font-size: 11px; font-weight: 700; color: var(--ink-faint); margin-bottom: 6px; }
.day-cell-icon { display: block; font-size: 15px; }

/* ---------- Result screen extras: XP + level up ---------- */

.result-xp {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--blue);
  margin: 0 0 18px;
}

.level-up-banner {
  background: linear-gradient(135deg, #EEF0FC, #F3EEFC);
  border: 1px solid var(--violet);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 0 0 20px;
  animation: popIn 0.35s ease;
}

.level-up-title { font-size: 16px; font-weight: 800; margin: 0 0 4px; color: var(--violet); }
.level-up-text { font-size: 13.5px; color: var(--ink-soft); margin: 0; }

@keyframes popIn {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.achievement-banner {
  background: linear-gradient(135deg, #FFF4EA, #FEF9E7);
  border-color: #D97706;
}
.achievement-banner .level-up-title { color: #B45309; }

/* ---------- Achievements ---------- */

.achievements-link-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease;
}
.achievements-link-card:hover { border-color: var(--blue); }

.achievements-link-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-faint);
}

.achievements-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.achievements-header .section-title { margin: 0; }

.achievements-count-badge {
  background: linear-gradient(120deg, rgba(61, 78, 196, 0.1), rgba(111, 94, 232, 0.1));
  border: 1px solid rgba(111, 94, 232, 0.18);
  color: var(--blue-dark);
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.achievement-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.achievement-card:hover { transform: translateY(-2px); }

.achievement-card.locked { opacity: 0.55; }

.achievement-card.earned {
  position: relative;
  overflow: hidden;
  border-color: #D97706;
  background: #FFFAF0;
  box-shadow: 0 8px 20px -10px rgba(217, 119, 6, 0.4);
}

.achievement-card.earned::after {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  animation: achievementShine 3.2s ease-in-out infinite;
}

@keyframes achievementShine {
  0% { left: -60%; }
  40%, 100% { left: 140%; }
}

.achievement-icon { display: block; font-size: 28px; margin-bottom: 8px; }
.achievement-name { font-size: 13.5px; font-weight: 800; margin: 0 0 4px; }
.achievement-desc { font-size: 12px; color: var(--ink-soft); margin: 0; line-height: 1.4; }
.achievement-date { display: block; font-size: 11px; color: var(--ink-faint); margin-top: 8px; font-weight: 600; }

/* ---------- Profile card (grade picker) ---------- */

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

.profile-eyebrow { font-size: 12.5px; font-weight: 700; color: var(--ink-faint); margin: 0 0 4px; }
.profile-hint { font-size: 14.5px; font-weight: 600; margin: 0 0 14px; }

.grade-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.grade-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-soft);
}

.grade-btn.active { border-color: var(--blue); background: #EEF0FC; color: var(--blue); }

/* ---------- Text link (e.g. "show all subjects") ---------- */

.text-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--blue);
}
.text-link:hover { color: var(--blue-dark); }

/* ---------- Subject categories (full subject picker) ---------- */

.subject-category { margin-bottom: 28px; }
.subject-category:last-child { margin-bottom: 0; }

.category-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-faint);
  text-transform: none;
  margin: 0 0 12px;
}

/* ---------- Subject cards ---------- */

.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.subject-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.subject-card:hover {
  border-color: var(--blue);
  transform: translateY(-3px);
  box-shadow: 0 14px 26px -12px rgba(61, 78, 196, 0.3);
}

.subject-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: white;
}

.subject-name { font-size: 16px; font-weight: 700; }
.subject-meta { font-size: 13px; color: var(--ink-faint); }

/* ---------- Exam cards ---------- */

.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  max-width: 500px;
}

.exam-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 28px 20px;
  text-align: left;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.exam-card:hover {
  border-color: var(--violet);
  transform: translateY(-3px);
  box-shadow: 0 14px 26px -12px rgba(124, 111, 240, 0.3);
}

.exam-card-title { display: block; font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.exam-card-sub { display: block; font-size: 13.5px; color: var(--ink-faint); }

/* ---------- Trainer ---------- */

.trainer-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.trainer-eyebrow { font-size: 13px; font-weight: 700; color: var(--violet); margin: 0 0 4px; }
.trainer-progress-text { font-size: 13.5px; color: var(--ink-faint); margin: 0; }
.trainer-score { font-size: 14px; font-weight: 700; color: var(--ink-soft); }

.progress-bar-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 24px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--violet));
  border-radius: 3px;
  transition: width 0.35s ease;
  width: 0%;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-card);
}

.question-number {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-faint);
  margin: 0 0 8px;
}

.question-text {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.4;
  margin: 0 0 22px;
}

.frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  font-size: 0.82em;
  line-height: 1.15;
  margin: 0 1px;
  transform: translateY(0.1em);
}
.frac-num {
  padding: 0 3px 1px;
  border-bottom: 1.5px solid currentColor;
}
.frac-den {
  padding: 1px 3px 0;
}

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

.option-btn {
  text-align: left;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.option-btn:hover { border-color: var(--blue); }

.option-btn.selected {
  border-color: var(--blue);
  background: #EEF0FC;
}

.option-btn.correct {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.option-btn.incorrect {
  border-color: var(--error);
  background: var(--error-bg);
  color: var(--error);
}

.option-btn:disabled { cursor: default; }

.short-answer-input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
}
.short-answer-input:focus { border-color: var(--violet); outline: none; box-shadow: 0 0 0 4px rgba(111, 94, 232, 0.15); }
.short-answer-input.correct { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.short-answer-input.incorrect { border-color: var(--error); background: var(--error-bg); color: var(--error); }
.short-answer-input:disabled { cursor: default; }

.feedback {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  background: #F4F5FA;
}

.feedback-result { font-weight: 800; margin: 0 0 6px; font-size: 15px; }
.feedback-explain { margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--ink-soft); }

.question-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* ---------- Result screen ---------- */

.result-card {
  max-width: 420px;
  margin: 40px auto 0;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 40px 28px;
  box-shadow: var(--shadow-card);
}

.result-eyebrow { font-size: 13px; font-weight: 700; color: var(--ink-faint); margin: 0 0 12px; }
.result-score { font-size: 40px; font-weight: 800; margin: 0 0 8px; }
.result-caption { font-size: 15px; color: var(--ink-soft); margin: 0 0 28px; }
.result-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Progress screen ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px -14px rgba(30, 33, 48, 0.18);
}

.stat-value { font-size: 26px; font-weight: 800; margin: 0 0 4px; }
.stat-label { font-size: 13px; color: var(--ink-faint); margin: 0; }

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

.subject-progress-row {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.spr-top { display: flex; justify-content: space-between; font-size: 14.5px; font-weight: 700; margin-bottom: 8px; }
.spr-top span:last-child { color: var(--ink-faint); font-weight: 600; }

.spr-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.spr-fill { height: 100%; background: var(--blue); border-radius: 3px; }

/* ---------- Plan screen ---------- */

.plan-intro { color: var(--ink-soft); font-size: 15px; max-width: 560px; margin: 0 0 24px; line-height: 1.5; }

.plan-form {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 460px;
  box-shadow: var(--shadow-card);
}

.plan-label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 16px 0 8px; }
.plan-label:first-child { margin-top: 0; }

.plan-toggle { display: flex; gap: 8px; }

.toggle-btn {
  flex: 1;
  padding: 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-soft);
}

.toggle-btn {
  transition: border-color 0.15s ease, background 0.2s ease, color 0.15s ease, transform 0.1s ease;
}
.toggle-btn.active {
  border-color: transparent;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(61, 78, 196, 0.5);
}

.plan-select, .plan-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

select.plan-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%236F5EE8' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.plan-form .btn { width: 100%; margin-top: 24px; }

.plan-output { margin-top: 28px; display: flex; flex-direction: column; gap: 12px; max-width: 640px; }

.plan-week {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.plan-week-title { font-weight: 800; font-size: 14.5px; margin: 0 0 8px; color: var(--violet); }
.plan-week ul { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.7; color: var(--ink-soft); }

/* ---------- Tutors (репетиторы) ---------- */

.tutors-controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.tutors-city-field { flex: 2; min-width: 220px; }
.tutors-sort-field { flex: 1; min-width: 180px; }

.tutors-count {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-faint);
  margin: 0 0 16px;
}

.tutors-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .tutors-layout { grid-template-columns: 1fr; }
}

.tutors-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tutors-empty {
  color: var(--ink-soft);
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 20px;
}

.tutors-map-panel {
  position: sticky;
  top: 90px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  height: 460px;
}

@media (max-width: 900px) {
  .tutors-map-panel { position: static; height: 280px; }
}

.tutors-map { width: 100%; height: 100%; background: var(--bg); }

.tutors-map-fallback {
  padding: 24px 20px;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* Всплывающая карточка репетитора на карте (поверх стилей Leaflet) */
.leaflet-popup-content-wrapper { border-radius: var(--radius-sm); box-shadow: var(--shadow-card); }
.leaflet-popup-content { font-family: "Manrope", sans-serif; margin: 12px 14px; }
.tutor-popup-name { font-weight: 800; font-size: 13.5px; margin: 0 0 4px; }
.tutor-popup-meta { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 2px; }

.tutor-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.tutor-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow: 0 14px 26px -12px rgba(61, 78, 196, 0.25);
}

.tutor-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.tutor-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
  color: white;
}

.tutor-name { font-size: 15.5px; font-weight: 800; margin: 0 0 3px; }
.tutor-rating { font-size: 13px; font-weight: 700; color: #B45309; margin: 0; }
.tutor-reviews { font-weight: 600; color: var(--ink-faint); }

.tutor-meta {
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0 0 4px;
}

.tutor-formats {
  font-size: 12.5px;
  color: var(--ink-faint);
  font-weight: 600;
  margin: 8px 0 0;
}

.tutor-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* ---------- Пробники (экзаменационный режим) ---------- */

.exam-info-facts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin: 20px 0;
}

.exam-info-fact { display: flex; justify-content: space-between; font-size: 14px; }
.exam-info-fact span { color: var(--ink-soft); }
.exam-info-fact strong { font-weight: 800; }

.exam-run-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  position: sticky;
  top: 76px;
  z-index: 10;
  background: var(--bg);
  padding: 10px 0;
}

.exam-timer {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 8px 20px;
  box-shadow: var(--shadow-card);
}

.exam-timer.exam-timer-low {
  color: var(--error);
  border-color: var(--error);
  animation: streakGlow 1s ease-in-out infinite;
}

.exam-nav-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.exam-nav-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink-soft);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.exam-nav-btn:hover { transform: translateY(-1px); }
.exam-nav-btn.answered { border-color: var(--blue); background: #EEF0FC; color: var(--blue); }
.exam-nav-btn.current { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(124, 111, 240, 0.2); color: var(--violet); }

.exam-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 640px;
  margin: 28px auto 0;
}

.exam-breakdown-item {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.exam-breakdown-item.correct { border-left-color: var(--success); }
.exam-breakdown-item.incorrect { border-left-color: var(--error); }

.exam-breakdown-head { font-size: 12.5px; font-weight: 700; color: var(--ink-faint); margin: 0 0 6px; }
.exam-breakdown-question { font-size: 14.5px; font-weight: 700; margin: 0 0 8px; }
.exam-breakdown-answer { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 8px; line-height: 1.6; }
.exam-breakdown-explain { font-size: 13.5px; color: var(--ink-soft); margin: 0; line-height: 1.5; }

.exam-topics-block {
  background: #FFF4EA;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin: 0 0 20px;
  text-align: left;
}
.exam-topics-title { font-weight: 800; font-size: 14px; margin: 0 0 4px; color: #B45309; }
.exam-topics-list { font-size: 13.5px; color: var(--ink-soft); margin: 0; }

/* ---------- Журнал ошибок ---------- */

.mistake-subject-group { margin-bottom: 28px; }

.mistake-subject-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.mistake-item {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 10px;
}

.mistake-item-head { font-size: 12px; font-weight: 700; color: var(--ink-faint); margin: 0 0 6px; }
.mistake-item-question { font-size: 14.5px; font-weight: 700; margin: 0 0 8px; }
.mistake-item-answer { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 8px; line-height: 1.6; }
.mistake-item-explain { font-size: 13.5px; color: var(--ink-soft); margin: 0; line-height: 1.5; }

@media (max-width: 600px) {
  .exam-run-head { top: 60px; }
  .exam-timer { font-size: 18px; padding: 7px 16px; }
  .exam-nav-btn { width: 34px; height: 34px; font-size: 12.5px; }
  .question-actions #examBackBtn { order: 1; }
  .question-actions #examSkipBtn { order: 2; }
  .question-actions #examNextBtn { order: 0; width: 100%; }
}

/* ---------- Регистрация / вход / профиль ---------- */

.auth-error {
  background: var(--error-bg);
  color: var(--error);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-top: 16px;
}

.auth-success {
  background: var(--success-bg);
  color: var(--success);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-top: 16px;
}

.auth-subjects-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.subject-pill.active { border-color: var(--blue); background: #EEF0FC; color: var(--blue); }

.profile-view-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.profile-view-head { display: flex; align-items: center; gap: 16px; }
.profile-view-name { font-size: 18px; font-weight: 800; margin: 0 0 4px; }
.profile-view-email { font-size: 13.5px; color: var(--ink-faint); margin: 0; }

/* ---------- ИИ-репетитор (чат) ---------- */

.ai-context-chip {
  display: none;
  align-items: center;
  gap: 6px;
  background: #EEF0FC;
  color: var(--blue-dark);
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.ai-not-configured {
  background: #FFF4EA;
  border: 1px solid #D97706;
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.ai-not-configured-title { font-weight: 800; font-size: 14.5px; margin: 0 0 6px; color: #B45309; }
.ai-not-configured-text { font-size: 13.5px; color: var(--ink-soft); margin: 0; line-height: 1.55; }
.ai-not-configured-text code {
  background: rgba(30, 33, 48, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
}

.ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.ai-quick-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-soft);
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.ai-quick-btn:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); transform: translateY(-1px); }
.ai-quick-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ai-chat {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px;
  min-height: 260px;
  max-height: 480px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.ai-chat-empty {
  margin: auto;
  color: var(--ink-faint);
  font-size: 14px;
  text-align: center;
  max-width: 320px;
}

.ai-msg { display: flex; }
.ai-msg-user { justify-content: flex-end; }
.ai-msg-assistant { justify-content: flex-start; }

.ai-msg-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.ai-msg-user .ai-msg-bubble {
  background: linear-gradient(135deg, var(--blue), var(--violet));
  color: white;
  border-bottom-right-radius: 4px;
}

.ai-msg-assistant .ai-msg-bubble {
  background: #F4F5FA;
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.ai-typing { display: flex; gap: 4px; padding: 14px 16px; }
.ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-faint);
  animation: aiTypingBounce 1.1s ease-in-out infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.15s; }
.ai-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aiTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.ai-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.ai-input {
  flex: 1;
  resize: none;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14.5px;
  background: var(--surface);
  min-height: 46px;
  max-height: 140px;
}
.ai-input:focus { border-color: var(--violet); outline: none; box-shadow: 0 0 0 4px rgba(111, 94, 232, 0.15); }
.ai-input:disabled { background: var(--bg); color: var(--ink-faint); }

.ai-exercise-form {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  margin-bottom: 18px;
}

.ai-exercise-form-actions { display: flex; gap: 12px; margin-top: 22px; }
.ai-exercise-form-actions .btn { flex: 1; }

.ai-exercise-panel { margin-bottom: 18px; }
.ai-exercise-panel .question-card { animation: fadeUp 0.25s ease; }

@media (max-width: 600px) {
  .ai-msg-bubble { max-width: 88%; }
  .ai-quick-btn { padding: 8px 13px; font-size: 13px; }
}

/* ---------- AI info screen ---------- */

.ai-info-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 26px;
  max-width: 640px;
  box-shadow: var(--shadow-card);
}
.ai-info-card h3 { font-size: 15.5px; margin: 20px 0 10px; }
.ai-info-card h3:first-child { margin-top: 0; }
.ai-info-card ul { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.7; color: var(--ink-soft); }
.ai-info-card p { font-size: 14.5px; line-height: 1.6; color: var(--ink-soft); margin: 0; }

/* ---------- Мой путь (карта тем) ---------- */

.path-map {
  max-width: 640px;
  margin: 0 auto;
}

.path-node-wrap {
  position: relative;
  padding-left: 34px;
  padding-bottom: 20px;
}
.path-node-wrap:last-child { padding-bottom: 0; }

.path-node-wrap::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 26px;
  bottom: -20px;
  width: 2px;
  background: var(--border);
}
.path-node-wrap:last-child::before { display: none; }

.path-node-dot {
  position: absolute;
  left: 0;
  top: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--ink-faint);
  box-sizing: border-box;
  z-index: 1;
}
.path-node-dot.status-in_progress { border-color: var(--blue); background: #EEF0FC; }
.path-node-dot.status-needs_review { border-color: #D97706; background: #FFF4EA; }
.path-node-dot.status-mastered { border-color: var(--success); background: var(--success-bg); }

.path-node {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.path-node:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }

.path-node-name {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 4px;
  color: var(--ink);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.path-node-meta { font-size: 12.5px; color: var(--ink-soft); margin: 0; }

.path-node-status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.path-node-status-pill.status-not_started { background: #EEF0F5; color: var(--ink-faint); }
.path-node-status-pill.status-in_progress { background: #EEF0FC; color: var(--blue); }
.path-node-status-pill.status-needs_review { background: #FFF4EA; color: #B45309; }
.path-node-status-pill.status-mastered { background: var(--success-bg); color: var(--success); }

@media (max-width: 600px) {
  .path-node-wrap { padding-left: 28px; }
  .path-node-dot { width: 20px; height: 20px; }
  .path-node-wrap::before { left: 9px; top: 22px; }
}

/* ---------- Решить по фото ---------- */

.photo-upload-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  margin-bottom: 20px;
  max-width: 560px;
}

.photo-upload-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.photo-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
}

.photo-preview-wrap { margin-top: 18px; text-align: center; }

.photo-preview-img {
  max-width: 100%;
  max-height: 360px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  display: block;
  margin: 0 auto 10px;
}

.photo-error {
  color: var(--error);
  background: var(--error-bg);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13.5px;
  margin-top: 14px;
}

.photo-result { max-width: 640px; }

.photo-warning {
  background: #FFF4EA;
  border: 1px solid #D97706;
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.photo-warning-title { font-weight: 800; color: #B45309; margin: 0 0 6px; }

.photo-subject-badge {
  display: inline-block;
  background: linear-gradient(120deg, rgba(61, 78, 196, 0.1), rgba(111, 94, 232, 0.1));
  border: 1px solid rgba(111, 94, 232, 0.18);
  color: var(--blue-dark);
  font-weight: 700;
  font-size: 12.5px;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 14px;
  text-transform: capitalize;
}

.photo-steps-list { margin: 0; padding-left: 20px; font-size: 14.5px; line-height: 1.8; color: var(--ink-soft); }
.photo-steps-list li { margin-bottom: 6px; }

.photo-answer-card {
  background: linear-gradient(135deg, #EEF0FC, #F3EEFC);
  border: 1px solid var(--violet);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin: 16px 0;
}
.photo-answer-label { font-size: 12px; font-weight: 700; color: var(--violet); margin: 0 0 4px; text-transform: uppercase; letter-spacing: 0.03em; }
.photo-answer-text { font-size: 17px; font-weight: 700; margin: 0; color: var(--ink); }

.photo-followup-actions { flex-wrap: wrap; }

@media (max-width: 600px) {
  .photo-upload-actions { flex-direction: column; }
  .photo-upload-btn { width: 100%; }
  .photo-preview-img { max-height: 260px; }
}

/* ---------- Повторение ---------- */

.review-storage-note {
  background: #FFF4EA;
  border: 1px solid #D97706;
  color: #B45309;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
}

#reviewStats { margin-bottom: 24px; }

.review-card { max-width: 560px; }

.review-hint {
  background: #EEF0FC;
  color: var(--blue);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin: 0 0 16px;
}

.review-grade-actions { flex-wrap: wrap; }

.review-extra {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-top: 18px;
}
.review-extra-title { font-weight: 800; font-size: 14px; margin: 0 0 10px; color: var(--violet); }

/* ---------- Мой календарь ---------- */

.cal-weekday-toggle { flex-wrap: wrap; }

.cal-overdue-banner {
  background: linear-gradient(135deg, #EEF0FC, #F3EEFC);
  border: 1px solid var(--violet);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.cal-overdue-title { font-weight: 800; margin: 0 0 6px; color: var(--violet); }
.cal-overdue-text { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 12px; }

#calWidgets { margin-bottom: 24px; }

.cal-session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.cal-session-item.done { border-color: var(--success); background: var(--success-bg); }
.cal-session-item.rescheduled { opacity: 0.65; }
.cal-session-title { font-weight: 700; font-size: 14.5px; margin: 0 0 4px; }
.cal-session-meta { font-size: 12.5px; color: var(--ink-soft); margin: 0; }
.cal-session-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cal-month-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}
.cal-month-label { font-weight: 800; font-size: 16px; min-width: 160px; text-align: center; margin: 0; }

.cal-weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-faint);
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}

.cal-day {
  aspect-ratio: 1;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
  padding: 4px;
}
.cal-day.empty { visibility: hidden; cursor: default; }
.cal-day:hover { border-color: var(--blue); }
.cal-day.today { border-color: var(--blue); border-width: 2px; }
.cal-day.selected { background: #EEF0FC; border-color: var(--blue); }
.cal-day.exam-day { border-color: var(--violet); background: linear-gradient(135deg, #EEF0FC, #F3EEFC); }

.cal-day-number { font-size: 13px; font-weight: 700; }
.cal-day-exam-label { font-size: 8.5px; font-weight: 800; color: var(--violet); text-transform: uppercase; }
.cal-day-dots { display: flex; gap: 2px; }

.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-faint); }
.cal-dot.planned { background: var(--blue); }
.cal-dot.done { background: var(--success); }
.cal-dot.rescheduled { background: #D97706; }

@media (max-width: 600px) {
  .cal-day-number { font-size: 11.5px; }
  .cal-day-exam-label { display: none; }
  .cal-session-actions { width: 100%; flex-direction: column; }
  .cal-session-actions .btn { width: 100%; }
}

/* ---------- Моя готовность к экзамену ---------- */

.readiness-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
  margin-bottom: 22px;
  max-width: 680px;
  text-align: left;
}

.readiness-card-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.readiness-card-title { font-size: 17px; font-weight: 800; margin: 0 0 4px; }
.readiness-card-sub { font-size: 13.5px; color: var(--ink-soft); margin: 0; }

.readiness-ring-wrap { position: relative; width: 90px; height: 90px; flex-shrink: 0; }
.readiness-ring-svg { width: 90px; height: 90px; transform: rotate(-90deg); }
.readiness-ring-track { fill: none; stroke: var(--border); stroke-width: 8; }
.readiness-ring-fill {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 226;
  stroke-dashoffset: 226;
  transition: stroke-dashoffset 0.6s ease;
}
.readiness-ring-fill.low { stroke: var(--error); }
.readiness-ring-fill.mid { stroke: #D97706; }
.readiness-ring-fill.high { stroke: var(--success); }
.readiness-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
}

.readiness-section-title { font-size: 13px; font-weight: 800; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.03em; margin: 20px 0 10px; }
.readiness-section-title:first-of-type { margin-top: 4px; }

.readiness-factors { display: flex; flex-direction: column; gap: 12px; }
.readiness-factor-row { display: grid; grid-template-columns: 1fr 2fr auto; align-items: center; gap: 10px; }
.readiness-factor-label { font-size: 13.5px; color: var(--ink); }
.readiness-factor-weight { color: var(--ink-faint); font-weight: 400; }
.readiness-factor-row .progress-bar-track { margin-bottom: 0; }
.readiness-factor-value { font-size: 13.5px; font-weight: 800; min-width: 28px; text-align: right; }

.readiness-trend { display: flex; align-items: flex-end; gap: 8px; height: 90px; }
.readiness-trend-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.readiness-trend-bar { width: 100%; max-width: 28px; min-height: 4px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, var(--violet), var(--blue)); transition: height 0.3s ease; }
.readiness-trend-bar.empty { background: var(--border); }
.readiness-trend-label { font-size: 10.5px; color: var(--ink-faint); font-weight: 700; }

.readiness-strengths-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.readiness-topic-list { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.7; color: var(--success); }
.readiness-topic-list.warn { color: #B45309; }

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

.readiness-insufficient { font-weight: 700; font-size: 15px; margin: 0 0 8px; }

@media (max-width: 600px) {
  .readiness-strengths-grid { grid-template-columns: 1fr; }
  .readiness-factor-row { grid-template-columns: 1fr; gap: 4px; }
  .readiness-factor-value { text-align: left; }
  .readiness-actions .btn { width: 100%; white-space: normal; text-align: center; line-height: 1.4; }
}

/* ---------- Учебные комнаты ---------- */

.room-mode-hint { font-size: 13px; color: var(--ink-soft); margin: 8px 0 18px; }

.room-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 18px 0 0;
  cursor: pointer;
  line-height: 1.5;
}
.room-checkbox-row input { margin-top: 3px; flex-shrink: 0; width: 16px; height: 16px; }

.room-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 12px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.room-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.room-card-title { font-weight: 800; font-size: 15px; margin: 0 0 4px; }
.room-card-meta { font-size: 12.5px; color: var(--ink-soft); margin: 0; }

.room-header {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  margin-bottom: 22px;
  text-align: left;
}
.room-header-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.room-header-title { font-size: 19px; font-weight: 800; margin: 0 0 6px; }
.room-header-meta { font-size: 13px; color: var(--ink-soft); margin: 0; }

.room-badge {
  display: inline-block;
  background: linear-gradient(120deg, rgba(61, 78, 196, 0.1), rgba(111, 94, 232, 0.1));
  border: 1px solid rgba(111, 94, 232, 0.18);
  color: var(--blue-dark);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 10px;
  border-radius: 999px;
  margin-right: 6px;
}

.room-code-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.room-code-value { font-family: monospace; font-size: 18px; font-weight: 800; letter-spacing: 0.08em; color: var(--violet); }

.room-timer {
  font-weight: 800;
  color: var(--blue);
  font-size: 14px;
}
.room-timer.room-timer-low { color: var(--error); }

.room-progress-block {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 22px;
  margin-bottom: 22px;
  text-align: left;
}

.room-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.room-member-row:last-child { border-bottom: none; }
.room-member-name { font-weight: 700; font-size: 14px; }
.room-member-name.me::after { content: " (ты)"; font-weight: 400; color: var(--ink-faint); }
.room-member-stats { font-size: 13px; color: var(--ink-soft); }
.room-member-stats.hidden-note { color: var(--ink-faint); font-style: italic; }
.room-member-actions { display: flex; gap: 8px; }

.room-report-form {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 10px;
}

@media (max-width: 600px) {
  .room-header-top { flex-direction: column; }
  .room-code-box { flex-direction: column; align-items: flex-start; }
  .room-member-row { flex-direction: column; align-items: flex-start; }
}

/* ---------- Подвал сайта ---------- */

.site-footer {
  border-top: 1px solid var(--border-soft);
  margin-top: 40px;
  padding: 36px 20px 44px;
}

.site-footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.site-footer-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }

.site-footer-text {
  font-size: 13.5px;
  color: var(--ink-soft);
  max-width: 420px;
  margin: 0;
  line-height: 1.5;
}

.site-footer-copy {
  font-size: 12px;
  color: var(--ink-faint);
  margin: 6px 0 0;
}
