:root {
  --bg: #1a2230;
  --bg2: rgba(16, 21, 30, .72);
  --card: rgba(20, 26, 37, .66);
  --line: rgba(150, 175, 205, .18);
  --text: #eef1f6;
  --muted: #9aa5b8;
  --amber: #ff9a2e;
  --amber-soft: rgba(255, 154, 46, .14);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
/* Туманный фон в стиле робота */
body::before, body::after { content: ""; position: fixed; inset: -10%; z-index: -1; pointer-events: none; }
body::before {
  background:
    radial-gradient(60% 45% at 50% 38%, rgba(120, 146, 172, .55), transparent 70%),
    radial-gradient(45% 35% at 15% 70%, rgba(95, 120, 146, .45), transparent 70%),
    radial-gradient(45% 35% at 85% 65%, rgba(105, 130, 155, .45), transparent 70%),
    linear-gradient(180deg, #2b3a4f 0%, #3c5068 45%, #2a3646 80%, #1b222c 100%);
}
body::after {
  background:
    radial-gradient(30% 20% at 30% 30%, rgba(200, 215, 230, .10), transparent 70%),
    radial-gradient(35% 25% at 70% 50%, rgba(200, 215, 230, .08), transparent 70%),
    radial-gradient(25% 18% at 50% 80%, rgba(200, 215, 230, .07), transparent 70%),
    linear-gradient(0deg, rgba(10, 13, 18, .55) 0%, transparent 25%);
  animation: fog 28s ease-in-out infinite alternate;
}
@keyframes fog { to { transform: translate3d(4%, -2%, 0) scale(1.06); } }
.card, .lesson-card, .chatwrap { backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.hidden { display: none !important; }
h1 { font-size: clamp(24px, 4vw, 34px); margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: 22px; margin: 8px 0; }
h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 12px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }

button { font: inherit; cursor: pointer; border: 0; border-radius: 12px; }
button:disabled { cursor: not-allowed; opacity: .6; }
.primary { background: var(--amber); color: #1a1006; font-weight: 700; padding: 12px 20px; box-shadow: 0 6px 24px rgba(255,154,46,.25); }
.primary:hover:not(:disabled) { filter: brightness(1.08); }
.ghost { background: rgba(255,154,46,.06); color: #ffd9ae; padding: 8px 14px; border: 1.5px solid var(--amber); box-shadow: 0 0 12px rgba(255,154,46,.18); }
.ghost:hover { color: #fff; background: rgba(255,154,46,.16); box-shadow: 0 0 18px rgba(255,154,46,.35); }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; position: sticky; top: 0; backdrop-filter: blur(10px); background: rgba(16,21,30,.55); border-bottom: 1px solid var(--line); z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 12px var(--amber); }
.langs { display: flex; gap: 4px; background: var(--bg2); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.langs button { background: transparent; color: var(--muted); padding: 6px 10px; font-weight: 700; font-size: 13px; border-radius: 8px; }
.langs button.active { background: var(--amber); color: #1a1006; }

.screen { max-width: 1100px; margin: 0 auto; padding: 28px 20px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.narrow { max-width: 520px; margin: 6vh auto 0; }
label { display: block; margin: 14px 0; }
label span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
input, select { width: 100%; font: inherit; color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none; }
input:focus, select:focus { border-color: var(--amber); }

.maphead { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.lesson-card { text-align: left; background: var(--card); border: 1px solid var(--line); color: var(--text); padding: 16px; min-height: 120px; display: flex; flex-direction: column; gap: 6px; border-radius: 16px; transition: transform .15s, border-color .15s; }
.lesson-card:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--amber); }
.lesson-card .num { font-size: 12px; color: var(--muted); }
.lesson-card .ttl { font-weight: 700; flex: 1; }
.lesson-card .tag { font-size: 12px; color: var(--amber); }
.lesson-card.locked { opacity: .55; }
.lesson-card.locked .tag { color: var(--muted); }
.lesson-card.done { border-color: rgba(255,154,46,.5); background: linear-gradient(180deg, var(--amber-soft), var(--card)); }

.paywall { margin-top: 32px; background: linear-gradient(135deg, #2a1d10, var(--card)); border-color: rgba(255,154,46,.35); }
.plans { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
.plan { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
.plan span { color: var(--amber); font-weight: 700; }

/* Lesson */
.lesson { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 24px; align-items: start; }
.stage { position: sticky; top: 80px; text-align: center; }
.back { display: block; margin: 0 0 12px; }
.robot { position: relative; aspect-ratio: 9 / 16; max-height: 62vh; margin: 0 auto; border-radius: 24px; overflow: hidden; background: #3c5068; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.35), 0 0 40px rgba(255,154,46,.08); }
.robot video { width: 100%; height: 100%; object-fit: cover; display: none; }
.robot.has-video video { display: block; }
.robot.has-video .robot-fallback { display: none; }
.mood { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.55); color: var(--amber); padding: 4px 12px; border-radius: 99px; font-size: 13px; font-weight: 700; }
.mood:empty { display: none; }
.ai-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* Картинка робота, пока нет роликов */
.robot-fallback { position: absolute; inset: 0; }
.robot-fallback img { width: 100%; height: 100%; object-fit: cover; animation: bob 4s ease-in-out infinite; transform-origin: 50% 90%; }
.robot[data-mood="thinking"] .robot-fallback img { animation: dim 1.4s ease-in-out infinite; }
.robot[data-mood="happy"] .robot-fallback img { animation: hop .5s ease-in-out 3; }
.robot[data-mood="listening"] .robot-fallback img { transform: rotate(-2deg) scale(1.02); transition: transform .4s; }
.robot[data-mood="talking"] .robot-fallback img { animation: talk .6s ease-in-out infinite alternate; }
.robot[data-mood="wave"] .robot-fallback img { animation: hop .6s ease-in-out 2; }
@keyframes bob { 50% { transform: translateY(-4px) scale(1.005); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes dim { 50% { filter: brightness(.85); } }
@keyframes talk { to { transform: scale(1.015); filter: brightness(1.06); } }
@keyframes hop { 50% { transform: translateY(-14px); } }

.chatwrap { display: flex; flex-direction: column; height: calc(100vh - 140px); min-height: 460px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 82%; padding: 12px 16px; border-radius: 18px; line-height: 1.45; white-space: pre-wrap; animation: pop .2s ease-out; }
.bubble.bot { background: var(--bg2); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 6px; }
.bubble.user { background: var(--amber); color: #1a1006; align-self: flex-end; border-bottom-right-radius: 6px; font-weight: 500; }
.bubble.system { align-self: center; color: var(--muted); font-size: 14px; background: transparent; }
.bubble.typing { color: var(--muted); letter-spacing: 3px; }
.bubble.celebrate { color: var(--amber); font-weight: 800; font-size: 18px; }
@keyframes pop { from { transform: translateY(6px); opacity: 0; } }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--bg2); }
.composer input { flex: 1; }
.mic { background: var(--card); border: 1px solid var(--line); width: 48px; font-size: 20px; }
.mic.on { background: var(--amber); animation: pulse 1s infinite; }
.tools { display: flex; align-items: center; gap: 12px; padding: 8px 14px 12px; font-size: 13px; background: var(--bg2); }
.tools #status { order: 1; flex: 1; text-align: center; }
.tools .toggle { order: 2; margin-left: auto; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; }
.tools .toggle input { accent-color: var(--amber); }
.tools #btnStudio { order: 0; }
.toggle { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); }
.toggle input { width: auto; }

@media (max-width: 820px) {
  .lesson { grid-template-columns: 1fr; }
  .stage { position: relative; top: 0; }
  .robot { max-height: 38vh; }
  .chatwrap { height: 60vh; }
}

.onboard { text-align: left; }
.onboard .hero { display: block; width: 140px; aspect-ratio: 9/16; object-fit: cover; border-radius: 18px; margin: -70px auto 16px; box-shadow: 0 16px 40px rgba(0,0,0,.4), 0 0 30px rgba(255,154,46,.15); }
.narrow.onboard { margin-top: 12vh; }

/* ---------- Челендж дня ---------- */
.challenge-card { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; margin: 0 0 22px; padding: 16px 18px; border-radius: 18px; cursor: pointer; color: var(--text);
  background: linear-gradient(120deg, rgba(216,246,90,.16), rgba(255,154,46,.14)); border: 1.5px solid rgba(216,246,90,.55); box-shadow: 0 0 24px rgba(216,246,90,.12); transition: transform .15s, box-shadow .15s; }
.challenge-card:hover:not(.done) { transform: translateY(-2px); box-shadow: 0 0 34px rgba(216,246,90,.25); }
.challenge-card .ch-ico { font-size: 34px; filter: drop-shadow(0 0 8px rgba(216,246,90,.6)); }
.challenge-card .ch-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.challenge-card .ch-kicker { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #d8f65a; }
.challenge-card .ch-title { font-size: 19px; font-weight: 800; }
.challenge-card .ch-sub { font-size: 13px; opacity: .75; }
.challenge-card .ch-go { background: #d8f65a; color: #111; font-weight: 800; padding: 10px 16px; border-radius: 12px; white-space: nowrap; }
.challenge-card.done { cursor: default; border-color: rgba(255,255,255,.15); background: rgba(255,255,255,.04); box-shadow: none; }
.challenge-card.done .ch-go { background: rgba(216,246,90,.2); color: #d8f65a; }
.challenge-card.loading { opacity: .6; }

/* ---------- Рівні ---------- */
.level-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin: 26px 0 12px; }
.level-head .lv { font-weight: 900; font-size: 15px; padding: 6px 14px; border-radius: 999px; background: #ff9a2e; color: #111; }
.level-head.locked .lv { background: rgba(255,255,255,.12); color: var(--text); }
.level-head .lv-note { font-size: 14px; opacity: .85; }
.level-head .lv-bar { flex-basis: 100%; height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; max-width: 420px; }
.level-head .lv-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ff9a2e, #d8f65a); border-radius: 99px; }
