/* Bright, chunky, friendly. Light by default; follows Telegram's dark theme. */
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7785;
  --line: #e3e7ec;
  --line-strong: #cfd6de;

  --green: #2fb344;
  --green-dark: #23923a;
  --green-soft: #dcf5e1;
  --red: #ef4b55;
  --red-dark: #c9333d;
  --red-soft: #fde3e5;
  --blue: #2f8cf0;
  --blue-dark: #1f6fc4;
  --blue-soft: #dcecfd;
  --orange: #ff9a1f;
  --orange-soft: #fff0dc;
  --purple: #8b5cf6;
  --purple-soft: #ede6fe;
  --gold: #f5b700;

  --radius: 18px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

html.dark {
  --bg: #111820;
  --surface: #1a232d;
  --text: #eef2f6;
  --muted: #93a1b0;
  --line: #2a3643;
  --line-strong: #364453;
  --green-soft: #183a22;
  --red-soft: #432126;
  --blue-soft: #16304d;
  --orange-soft: #43301a;
  --purple-soft: #2c2346;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 800; }
.muted { color: var(--muted); }
.center { text-align: center; }
.spacer { height: 16px; }

/* ---- buttons: the 3D press is the signature of the look ---- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 12px 18px;
  border: none; border-radius: 16px;
  font-weight: 800; font-size: 16px; letter-spacing: .4px; text-transform: uppercase;
  background: var(--green); color: #fff;
  box-shadow: 0 4px 0 var(--green-dark);
  cursor: pointer; transition: transform .06s, box-shadow .06s, filter .15s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--green-dark); }
.btn:disabled { background: var(--line); color: var(--muted); box-shadow: 0 4px 0 var(--line-strong); cursor: default; }
.btn:disabled:active { transform: none; box-shadow: 0 4px 0 var(--line-strong); }
.btn.blue { background: var(--blue); box-shadow: 0 4px 0 var(--blue-dark); }
.btn.red { background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.btn.ghost { background: var(--surface); color: var(--blue); box-shadow: 0 4px 0 var(--line-strong); border: 2px solid var(--line-strong); }
.btn.ghost:active { box-shadow: 0 0 0 var(--line-strong); }
.btn + .btn { margin-top: 12px; }
.icon-btn { background: none; border: none; padding: 6px; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 18px; }
.chips { display: flex; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 999px; background: var(--surface);
  border: 2px solid var(--line); font-weight: 800; font-size: 15px;
}
.chip.fire { color: var(--orange); }
.chip.fire.off { color: var(--muted); filter: grayscale(1); }
.chip.xp { color: var(--gold); }
.hello { font-weight: 800; font-size: 20px; }

/* ---- cards ---- */
.card {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.card.tap { cursor: pointer; box-shadow: 0 4px 0 var(--line); transition: transform .06s, box-shadow .06s; }
.card.tap:active { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.emoji-badge {
  flex: none; width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center; font-size: 28px; background: var(--blue-soft);
}
.emoji-badge.green { background: var(--green-soft); }
.emoji-badge.orange { background: var(--orange-soft); }
.emoji-badge.purple { background: var(--purple-soft); }
.emoji-badge.red { background: var(--red-soft); }
.title { font-weight: 800; font-size: 17px; }
.sub { color: var(--muted); font-size: 14px; }
.chev { color: var(--line-strong); font-size: 22px; font-weight: 800; }

.bar { height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--green); transition: width .4s ease; position: relative; }
.bar > i::after { content: ""; position: absolute; left: 8px; right: 8px; top: 3px; height: 3px; border-radius: 3px; background: rgba(255,255,255,.35); }
.bar.gold > i { background: var(--gold); }
.bar.thin { height: 8px; }
.bar.thin > i::after { display: none; }

/* ---- daily goal ---- */
.goal { display: flex; align-items: center; gap: 14px; }
.goal .bar { flex: 1; }
.week { display: flex; justify-content: space-between; margin-top: 14px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 700; }
.day b { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--line); font-size: 15px; }
.day.on b { background: var(--orange); color: #fff; }
.day.today { color: var(--text); }

/* ---- hero call to action ---- */
.hero {
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px; color: #fff;
  background: linear-gradient(135deg, var(--green), #1fa38a);
  box-shadow: 0 4px 0 var(--green-dark);
}
.hero.blue { background: linear-gradient(135deg, var(--blue), #6a5cf6); box-shadow: 0 4px 0 var(--blue-dark); }
.hero .k { font-size: 13px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; opacity: .85; }
.hero .t { font-size: 20px; font-weight: 800; margin: 4px 0 14px; }
.hero .btn { background: #fff; color: var(--green-dark); box-shadow: 0 4px 0 rgba(0,0,0,.18); }
.hero.blue .btn { color: var(--blue-dark); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.tile {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; box-shadow: 0 4px 0 var(--line); transition: transform .06s, box-shadow .06s;
  display: flex; flex-direction: column; gap: 8px; min-height: 112px; position: relative;
}
.tile:active { transform: translateY(4px); box-shadow: 0 0 0 var(--line); }
.tile .emoji-badge { width: 44px; height: 44px; font-size: 24px; border-radius: 13px; }
.badge {
  position: absolute; top: 10px; right: 10px; min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 999px; background: var(--red); color: #fff; font-size: 13px; font-weight: 800;
  display: grid; place-items: center;
}
.section-title { font-size: 14px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin: 22px 4px 10px; }

/* ---- course path ---- */
.course-head { border-radius: var(--radius); padding: 16px; color: #fff; margin-bottom: 26px; background: var(--green); box-shadow: 0 4px 0 var(--green-dark); }
.course-head .sub { color: rgba(255,255,255,.85); }
.path { display: flex; flex-direction: column; align-items: center; gap: 18px; padding-bottom: 30px; }
.node-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.node {
  width: 72px; height: 72px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 30px; font-weight: 800; color: #fff; display: grid; place-items: center;
  background: var(--green); box-shadow: 0 6px 0 var(--green-dark);
  transition: transform .06s, box-shadow .06s; position: relative;
}
.node:active { transform: translateY(6px); box-shadow: 0 0 0 var(--green-dark); }
.node.locked { background: var(--line); color: var(--muted); box-shadow: 0 6px 0 var(--line-strong); }
.node.current { width: 84px; height: 84px; background: var(--blue); box-shadow: 0 6px 0 var(--blue-dark); animation: bob 1.8s ease-in-out infinite; }
.node.current::before {
  content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 4px solid var(--blue-soft);
}
.node-label { font-size: 13px; font-weight: 700; color: var(--muted); max-width: 220px; text-align: center; }
.node-wrap.current .node-label { color: var(--text); }
.start-bubble {
  background: var(--surface); color: var(--blue); border: 2px solid var(--line); font-weight: 800;
  font-size: 13px; letter-spacing: .5px; padding: 6px 12px; border-radius: 12px; text-transform: uppercase;
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* ---- lesson & quiz shell ---- */
.shell { display: flex; flex-direction: column; min-height: calc(100vh - 40px); }
.shell-top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.shell-top .bar { flex: 1; }
.shell-body { flex: 1; }
.shell-foot { position: sticky; bottom: 0; padding: 16px 0 calc(8px + env(safe-area-inset-bottom)); background: var(--bg); }
.timer { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--blue); }
.timer.low { color: var(--red); }

.lesson-card h2 { margin-bottom: 12px; }
.content p { margin: 0 0 12px; }
.content ul, .content ol { margin: 0 0 12px; padding-left: 22px; }
.content li { margin-bottom: 6px; }
.content code { font-family: var(--mono); font-size: .9em; background: var(--blue-soft); padding: 1px 6px; border-radius: 6px; }
.content pre, .qcode {
  font-family: var(--mono); font-size: 13.5px; line-height: 1.5;
  background: #17202a; color: #e6edf3; padding: 14px; border-radius: 14px; overflow-x: auto; margin: 0 0 12px;
  white-space: pre;
}
.content pre code { background: none; padding: 0; color: inherit; font-size: inherit; }

.qkind { font-size: 13px; font-weight: 800; letter-spacing: .5px; text-transform: uppercase; color: var(--purple); margin-bottom: 8px; }
.qtext { font-size: 19px; font-weight: 700; margin-bottom: 14px; white-space: pre-wrap; }
.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: 2px solid var(--line); border-radius: 16px;
  padding: 13px 14px; box-shadow: 0 4px 0 var(--line); cursor: pointer;
  transition: transform .06s, box-shadow .06s, border-color .1s, background .1s;
}
.opt:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }
.opt .key {
  flex: none; width: 30px; height: 30px; border-radius: 9px; border: 2px solid var(--line-strong);
  display: grid; place-items: center; font-size: 14px; font-weight: 800; color: var(--muted);
}
.opt .txt { flex: 1; white-space: pre-wrap; word-break: break-word; padding-top: 3px; }
.opt.sel { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 4px 0 var(--blue); }
.opt.sel .key { border-color: var(--blue); color: var(--blue); }
.opt.right { border-color: var(--green); background: var(--green-soft); box-shadow: 0 4px 0 var(--green); }
.opt.right .key { border-color: var(--green); background: var(--green); color: #fff; }
.opt.wrong { border-color: var(--red); background: var(--red-soft); box-shadow: 0 4px 0 var(--red); }
.opt.wrong .key { border-color: var(--red); background: var(--red); color: #fff; }
.opt[disabled] { cursor: default; }
.opt[disabled]:active { transform: none; }

/* feedback sheet after checking an answer */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
.sheet.ok { background: var(--green-soft); }
.sheet.bad { background: var(--red-soft); }
.sheet .inner { max-width: 528px; margin: 0 auto; }
.sheet h3 { font-size: 21px; font-weight: 800; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.sheet.ok h3 { color: var(--green-dark); }
.sheet.bad h3 { color: var(--red-dark); }
.sheet .expl { max-height: 32vh; overflow-y: auto; margin-bottom: 14px; font-size: 15px; white-space: pre-wrap; }
.sheet-pad { height: 260px; }
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ---- celebration / result ---- */
.celebrate { text-align: center; padding-top: 8vh; }
.celebrate .big { font-size: 84px; line-height: 1; margin-bottom: 14px; animation: pop .5s cubic-bezier(.3,1.6,.6,1); }
.celebrate h1 { font-size: 28px; margin-bottom: 8px; }
.stat-row { display: flex; gap: 10px; margin: 24px 0; }
.stat {
  flex: 1; border-radius: 16px; border: 2px solid var(--gold); overflow: hidden; background: var(--surface);
}
.stat .h { background: var(--gold); color: #fff; font-size: 12px; font-weight: 800; padding: 4px; text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 22px; font-weight: 800; padding: 10px 4px; }
.stat.green { border-color: var(--green); } .stat.green .h { background: var(--green); }
.stat.blue { border-color: var(--blue); } .stat.blue .h { background: var(--blue); }
.stat.orange { border-color: var(--orange); } .stat.orange .h { background: var(--orange); }
@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.topic-row { padding: 12px 0; border-bottom: 2px solid var(--line); cursor: pointer; }
.topic-row:last-child { border-bottom: none; }
.topic-row .row { margin-bottom: 8px; }
.pct { font-weight: 800; color: var(--muted); font-size: 14px; }

.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 8px; }
.exam-grid button {
  height: 38px; border-radius: 10px; border: 2px solid var(--line); background: var(--surface);
  font-weight: 800; font-size: 14px; cursor: pointer;
}
.exam-grid button.done { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.exam-grid button.here { border-color: var(--text); }

.empty { text-align: center; padding: 12vh 12px; }
.empty .big { font-size: 64px; margin-bottom: 12px; }
.loader { display: grid; place-items: center; min-height: 60vh; }
.loader::after {
  content: ""; width: 42px; height: 42px; border-radius: 50%;
  border: 5px solid var(--line); border-top-color: var(--green); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 120px);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 14px; font-weight: 700;
  transition: transform .25s ease; z-index: 20; max-width: 90vw; text-align: center;
}
#toast.show { transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
