/* Радуга учёбы — один стиль для 2 класса, 5 класса и общего входа.
   Claymorphism: индиго #4F46E5, бумага #EEF2FF, действие #EA580C.
   Заголовки Rubik, текст Nunito: оба читают кириллицу. */

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; }
button { border: 0; font: inherit; color: inherit; background: none; }

:root {
  --ink: #1e1b4b;
  --muted: #475569;
  --line: #c7d2fe;
  --purple: #4f46e5;
  --lav: #e0e7ff;
  --paper: #eef2ff;
  --mint: #dcf6ec;
  --yellow: #fff0bd;
  --peach: #ffe5d5;
  --sky: #dcefff;
  --sky-ink: #1e4e78;
  --accent: #ea580c;
  --on-accent: #1c0a00;
  --shadow: 0 8px 0 #e0e7ff, 0 16px 28px rgba(79, 70, 229, 0.1);
  --radius: 22px;
}

body {
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 8% -10%, #e0e7ff 0%, transparent 58%),
    radial-gradient(700px 380px at 110% 0%, #ffedd5 0%, transparent 52%),
    var(--paper);
  font-family: Nunito, Arial, sans-serif;
}

h1, h2, h3,
.brand,
.welcome h1,
.page-intro h1,
.section-heading h2,
.lesson-card h3,
.lesson-hero h1,
.stage h2,
.game-q,
.game-head h3,
.test-head h2,
.test-result h3,
.big-score strong,
.goal-ring b,
.mastery-ring b,
.flash-card b,
.library-title {
  font-family: Rubik, Nunito, sans-serif;
}

button, a, .chip, .nav-item, .tab-item, .pick, .subject-row, .material-card, .game-card, .lesson-card {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 3px;
}

.sidebar {
  background: #fff;
  border-right: 3px solid var(--line);
}

.brand-mark,
.study-avatar,
.assistant-fab,
.mem-card:not(.open) {
  background: var(--purple);
  color: #fff;
}

.brand-mark {
  border-radius: 14px;
  box-shadow: 0 4px 0 #3730a3, inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.nav-item {
  border-radius: 16px;
  min-height: 44px;
}

.nav-item.active,
.nav-item:hover,
.tab-item.active,
.chip.active {
  background: var(--lav);
  color: var(--purple);
}

.side-label,
.eyebrow {
  font-size: 12px;
  letter-spacing: 0.08em;
}

.streak-card {
  background: #ffedd5;
  border: 3px solid #fdba74;
  border-radius: 18px;
  box-shadow: 0 4px 0 #fed7aa;
}

.streak-card small { color: #9a3412; }

.help-link {
  background: var(--lav);
  color: var(--purple);
  border-radius: 16px;
  min-height: 44px;
}

.topbar { border-bottom: 3px solid var(--line); }

.welcome,
.stage,
.subject-row,
.material-card,
.today-card,
.game-host,
.test-head,
.test-q,
.practice-card,
.big-score,
.week,
.lesson-step,
.search-box,
.finish-card,
.test-result,
.achievement-row {
  background: #fff;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.welcome { overflow: hidden; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  position: relative;
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}

.search-icon {
  color: var(--purple);
  font-weight: 800;
  flex-shrink: 0;
}

.search-results {
  position: absolute;
  left: 8px;
  right: 8px;
  top: calc(100% + 8px);
  z-index: 6;
  background: #fff;
  border: 3px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.lesson-card,
.game-card {
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.75), 0 8px 0 rgba(30, 27, 75, 0.06);
}

.primary-btn,
.study-actions .study-next {
  background: var(--accent);
  color: var(--on-accent);
  border: 3px solid #c2410c;
  border-radius: 16px;
  box-shadow: 0 4px 0 #9a3412;
  min-height: 44px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-form button:not(#speakButton):not(#micButton) {
  background: var(--accent);
  color: var(--on-accent);
}

.primary-btn:active,
.study-actions .study-next:active,
.pick:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #9a3412;
}

.primary-btn:disabled {
  transform: none;
  box-shadow: none;
}

.ghost-btn,
.chip,
.back-button {
  border-radius: 16px;
}

.ghost-btn {
  border: 3px solid var(--line);
  background: #fff;
  min-height: 44px;
  color: var(--ink);
}

.chip {
  border: 3px solid var(--line);
  background: #fff;
  color: #334155;
  min-height: 40px;
}

.text-button,
.back-button,
.link-btn,
.teacher-note,
.study-live,
.goal-text,
.goal-ring b,
.goal-ring small,
.mastery-ring b {
  color: var(--purple);
}

.goal-ring {
  background: conic-gradient(var(--purple) calc(var(--p) * 1%), var(--lav) 0);
}

.goal-ring::before { background: #fff; }

.stars-count,
.welcome h1 span,
.game-stars { color: var(--accent); }

.assistant-fab {
  border: 3px solid #3730a3;
  box-shadow: 0 6px 0 #3730a3;
  border-radius: 999px;
}

.assistant-panel,
.study-dock {
  border: 3px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.assistant-head,
.bubble.luna,
.summary-stage,
.practice-card { background: #eef2ff; }

.bubble.luna { color: #312e81; }

.tabbar {
  border-top: 3px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.toast {
  background: var(--ink);
  border-radius: 16px;
  pointer-events: none;
}

.stage.study-focus {
  outline: 3px solid var(--purple);
  box-shadow: 0 0 0 6px rgba(79, 70, 229, 0.16);
}

.study-card-btn,
.study-mini,
.study-start {
  border: 3px solid var(--line);
  background: var(--lav);
  color: #312e81;
}

.place-visual .ten { background: var(--purple); }

.quiz-option:focus-visible,
.test-option:focus-visible,
.chip:focus-visible,
.nav-item:focus-visible {
  outline: 3px solid var(--purple);
  outline-offset: 2px;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .lesson-card,
  .game-card,
  .subject-row,
  .material-card,
  .pick,
  .nav-item,
  .primary-btn {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  }

  .lesson-card:hover,
  .game-card:hover,
  .subject-row:hover,
  .material-card:hover,
  .pick:hover {
    transform: translateY(-3px);
  }
}

@media (max-width: 900px) {
  .topbar { background: rgba(238, 242, 255, 0.94); }
  .toc { background: rgba(238, 242, 255, 0.94); }
}

@media (prefers-reduced-motion: reduce) {
  .primary-btn:active,
  .pick:active,
  .lesson-card:hover,
  .game-card:hover,
  .subject-row:hover,
  .material-card:hover {
    transform: none;
  }
}

/* ——— общий вход ——— */
body.gate {
  min-height: 100%;
}

body.gate main {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(860px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

body.gate .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  font-size: 14px;
  letter-spacing: -0.4px;
  line-height: 1.05;
}

body.gate .brand b { color: var(--purple); }

body.gate .mark {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--purple);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 18px;
  border: 3px solid #3730a3;
  box-shadow: 0 4px 0 #3730a3, inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

body.gate h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 52px);
  letter-spacing: -1.4px;
  line-height: 1.02;
  max-width: 14ch;
}

body.gate .lead {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.45;
  max-width: 36ch;
}

body.gate .choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 34px;
}

body.gate .pick {
  position: relative;
  overflow: hidden;
  min-height: 240px;
  border: 3px solid #fff;
  border-radius: 28px;
  padding: 26px 24px;
  text-align: left;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  box-shadow: var(--shadow);
}

body.gate .pick:focus-visible { outline: 3px solid var(--purple); outline-offset: 3px; }
body.gate .mint { background: var(--mint); border-color: #86efac; }
body.gate .sky { background: var(--sky); border-color: #7dd3fc; }

body.gate .avatar {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-family: Rubik, Nunito, sans-serif;
  font-weight: 800;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.82);
  border: 3px solid #fff;
}

body.gate .mint .avatar { color: #166534; }
body.gate .sky .avatar { color: var(--sky-ink); }

body.gate .name {
  margin-top: auto;
  font-size: 32px;
  letter-spacing: -1px;
  font-weight: 800;
}

body.gate .grade {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 800;
  color: #334155;
}

body.gate .watermark {
  position: absolute;
  right: 12px;
  bottom: -18px;
  font-family: Rubik, Nunito, sans-serif;
  font-weight: 800;
  font-size: 140px;
  line-height: 1;
  letter-spacing: -6px;
  opacity: 0.14;
  pointer-events: none;
}

body.gate .mint .watermark { color: #166534; }
body.gate .sky .watermark { color: var(--sky-ink); }

body.gate dialog {
  border: 3px solid var(--line);
  padding: 0;
  border-radius: 28px;
  width: min(420px, calc(100% - 28px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  box-shadow: var(--shadow);
  color: var(--ink);
  background: #fff;
}

body.gate dialog::backdrop { background: rgba(30, 27, 75, 0.42); }
body.gate .sheet { position: relative; padding: 26px 24px 22px; }

body.gate .sheet h2 {
  margin: 0;
  font-size: 26px;
  letter-spacing: -0.8px;
}

body.gate .sheet p {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 16px;
}

body.gate .slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 22px 0 8px;
}

body.gate .slot {
  height: 64px;
  border-radius: 16px;
  border: 3px solid var(--line);
  background: var(--paper);
  display: grid;
  place-items: center;
  font-family: Rubik, Nunito, sans-serif;
  font-size: 28px;
  font-weight: 800;
}

body.gate .slot.on { background: var(--lav); color: var(--purple); border-color: #a5b4fc; }

body.gate .slots.shake { animation: raduga-shake 0.36s linear; }

@keyframes raduga-shake {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

body.gate .err {
  min-height: 22px;
  margin: 0 0 12px;
  color: #b91c1c;
  font-size: 14px;
  font-weight: 800;
}

body.gate .keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

body.gate .keys button {
  height: 58px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff;
  font-family: Rubik, Nunito, sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  box-shadow: 0 3px 0 #e0e7ff;
}

body.gate .keys button:hover { background: var(--lav); }
body.gate .keys button:active { transform: translateY(2px); box-shadow: none; }
body.gate .keys button:disabled { opacity: 0.45; cursor: default; transform: none; }

body.gate .close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  font-size: 22px;
  color: #334155;
}

@media (max-width: 680px) {
  body.gate .choices { grid-template-columns: 1fr; }
  body.gate .pick { min-height: 168px; }
  body.gate .name { margin-top: 18px; }
  body.gate h1 { max-width: none; }
}
