/* Тёмно-зелёная тема мини-приложения МЦКО */
:root {
  --bg: #07140f;
  --bg2: #0b1d16;
  --card: #10271d;
  --card2: #143126;
  --line: #1f4133;
  --text: #e8f5ee;
  --muted: #8db3a0;
  --accent: #34d17f;
  --accent-2: #1fa663;
  --accent-soft: rgba(52, 209, 127, .14);
  --good: #34d17f;
  --bad: #ff6b6b;
  --bad-soft: rgba(255, 107, 107, .14);
  --warn: #f2c14e;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 500px at 80% -10%, #12402c 0%, transparent 60%),
              radial-gradient(900px 400px at -10% 110%, #0f3524 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select { font: inherit; color: var(--text); }

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, rgba(7, 20, 15, .96), rgba(7, 20, 15, .82));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(52, 209, 127, .08);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; font-weight: 800; color: #04120b;
  background: linear-gradient(135deg, #5ef0a3, var(--accent-2));
  box-shadow: 0 6px 18px rgba(52, 209, 127, .35);
}
.brand-title { font-weight: 800; letter-spacing: .2px; }
.brand-sub { color: var(--muted); font-size: 12.5px; }
.grade-pill {
  padding: 7px 12px; border-radius: 999px; font-weight: 700; font-size: 13px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(52, 209, 127, .3);
}

.view { flex: 1; padding: 14px 16px calc(96px + var(--safe-bottom)); }

/* ---------- нижние вкладки ---------- */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; z-index: 6;
  width: 100%; max-width: 640px;
  display: flex; justify-content: space-around;
  padding: 8px 6px calc(8px + var(--safe-bottom));
  background: rgba(9, 24, 18, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabs button {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; border-radius: 12px; color: var(--muted); font-size: 11.5px; font-weight: 600;
}
.tabs button i { font-style: normal; font-size: 20px; filter: grayscale(.4); transition: transform .15s; }
.tabs button.active { color: var(--accent); background: var(--accent-soft); }
.tabs button.active i { filter: none; transform: translateY(-1px); }
.badge {
  position: absolute; top: 2px; right: calc(50% - 22px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; font-weight: 800;
}

/* ---------- общие блоки ---------- */
h1 { font-size: 22px; margin: 4px 0 4px; font-weight: 800; }
h2 { font-size: 17px; margin: 18px 0 10px; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }

.card {
  background: linear-gradient(180deg, var(--card), var(--bg2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.card.tap { transition: transform .12s, border-color .12s; }
.card.tap:active { transform: scale(.985); border-color: rgba(52, 209, 127, .45); }

.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #16492f 0%, #0f2e21 55%, #0b2019 100%);
  border: 1px solid rgba(52, 209, 127, .25); border-radius: 22px; padding: 18px;
}
.hero::after {
  content: "π  √  x²  ∑  %  ∞"; position: absolute; right: -8px; bottom: -6px;
  font-size: 34px; font-weight: 800; letter-spacing: 6px; color: rgba(94, 240, 163, .08); white-space: nowrap;
}
.hero .big { font-size: 28px; font-weight: 800; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 9px 14px; border-radius: 999px; font-weight: 700; font-size: 14px;
  background: var(--card); border: 1px solid var(--line); color: var(--muted);
}
.chip.on { background: var(--accent); color: #04120b; border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; border-radius: 14px; font-weight: 800;
  background: linear-gradient(135deg, #3fe08c, var(--accent-2)); color: #04120b;
  box-shadow: 0 8px 20px rgba(31, 166, 99, .35);
}
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.ghost { background: var(--card2); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.btn.danger { background: var(--bad-soft); color: var(--bad); box-shadow: none; border: 1px solid rgba(255, 107, 107, .35); }
.btn.sm { padding: 8px 12px; border-radius: 11px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.topic { display: flex; align-items: center; gap: 12px; }
.topic .ico {
  width: 44px; height: 44px; border-radius: 13px; flex: none; display: grid; place-items: center; font-size: 22px;
  background: var(--card2); border: 1px solid var(--line);
}
.topic .name { font-weight: 700; }
.topic .actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---------- задача ---------- */
.task-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dots i.cur { background: var(--warn); }
.dots i.ok { background: var(--good); }
.dots i.no { background: var(--bad); }
.task-text { font-size: 17px; line-height: 1.55; font-weight: 600; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.opt {
  padding: 14px 10px; border-radius: 14px; font-weight: 800; font-size: 17px; text-align: center;
  background: var(--card2); border: 1.5px solid var(--line);
}
.opt:active { border-color: var(--accent); }
.opt.right { background: var(--accent-soft); border-color: var(--good); color: var(--good); }
.opt.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.answer-row { display: flex; gap: 8px; margin-top: 14px; }
.input {
  flex: 1; min-width: 0; padding: 13px 14px; border-radius: 14px; font-size: 17px; font-weight: 700;
  background: var(--bg2); border: 1.5px solid var(--line); outline: none;
}
.input:focus { border-color: var(--accent); }
.verdict { margin-top: 14px; padding: 12px 14px; border-radius: 14px; font-weight: 800; }
.verdict.ok { background: var(--accent-soft); color: var(--good); }
.verdict.no { background: var(--bad-soft); color: var(--bad); }
.solution {
  margin-top: 10px; padding: 12px 14px; border-radius: 14px; background: var(--bg2);
  border: 1px dashed var(--line); font-size: 14.5px; color: #cfe8db;
}
.solution b { color: var(--text); }
.theory { font-size: 15px; line-height: 1.6; }
.theory b { color: #aef3cc; }

/* ---------- прогресс и статистика ---------- */
.bar { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent-2), #5ef0a3); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { text-align: center; padding: 12px 6px; }
.stat .v { font-size: 24px; font-weight: 800; color: var(--accent); }
.stat .l { font-size: 12px; color: var(--muted); }
.ring {
  --p: 0; width: 120px; height: 120px; border-radius: 50%; margin: 6px auto 10px; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0);
}
.ring > div { width: 94px; height: 94px; border-radius: 50%; background: var(--card); display: grid; place-items: center;
  font-size: 26px; font-weight: 800; }

.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--card2); border: 1px solid var(--line); color: var(--muted); }
.tag.good { color: var(--good); border-color: rgba(52, 209, 127, .4); }
.tag.bad { color: var(--bad); border-color: rgba(255, 107, 107, .4); }
.tag.warn { color: var(--warn); border-color: rgba(242, 193, 78, .4); }

.seg { display: flex; gap: 6px; padding: 4px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: none; }
.seg button { flex: 1 0 auto; padding: 9px 10px; border-radius: 10px; font-weight: 700; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--card2); color: var(--accent); }

.check { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px;
  background: var(--card2); border: 1px solid var(--line); }
.check.on { border-color: var(--accent); background: var(--accent-soft); }
.check .box { width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--line); flex: none;
  display: grid; place-items: center; font-weight: 900; color: #04120b; }
.check.on .box { background: var(--accent); border-color: var(--accent); }
.check .t { flex: 1; font-weight: 600; font-size: 14px; }

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button { width: 40px; height: 40px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line);
  font-size: 22px; font-weight: 800; }
.stepper .n { min-width: 36px; text-align: center; font-size: 22px; font-weight: 800; }

select.input { appearance: none; }
.empty { text-align: center; padding: 34px 10px; color: var(--muted); }
.empty .e { font-size: 42px; margin-bottom: 8px; }

.loader { display: flex; justify-content: center; gap: 8px; padding: 60px 0; }
.loader span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: b 1s infinite ease-in-out; }
.loader span:nth-child(2) { animation-delay: .15s; }
.loader span:nth-child(3) { animation-delay: .3s; }
@keyframes b { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-bottom)); transform: translateX(-50%); z-index: 20;
  max-width: 90%; padding: 11px 16px; border-radius: 14px; font-weight: 700;
  background: #1c4a34; border: 1px solid rgba(52, 209, 127, .4); box-shadow: var(--shadow);
}
.toast.err { background: #4a1c1c; border-color: rgba(255, 107, 107, .5); }
.fade { animation: fade .22s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- рисунки задач (демоверсии МЦКО) ---------- */
.figs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-top: 12px; }
.fig { background: #fff; border-radius: 12px; padding: 8px; text-align: center; min-width: 0; overflow: hidden; }
.fig img { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.fig .cap { color: #274236; font-size: 12px; font-weight: 700; margin-top: 4px; }
/* выбор своих фото учителем: превью и плитка «добавить» */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 72px; height: 72px; border-radius: 12px; overflow: hidden;
  background: var(--bg2); border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0; border: 0;
  border-radius: 50%; background: rgba(0, 0, 0, .65); color: #fff; font-size: 12px; line-height: 22px; }
.thumb.add { display: flex; align-items: center; justify-content: center; border-style: dashed;
  color: var(--accent); font-size: 28px; cursor: pointer; }
.context { margin-bottom: 12px; padding: 12px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line);
  font-size: 14.5px; line-height: 1.5; }
.context summary { cursor: pointer; font-weight: 800; color: var(--accent); }

/* ---------- мотивация: серия, достижения, рейтинг ---------- */
.streak-card { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.streak-card .flame { font-size: 40px; line-height: 1; }
.streak-card .big-n { font-size: 20px; font-weight: 800; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.ach { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; text-align: center;
  opacity: .45; filter: grayscale(1); }
.ach.got { opacity: 1; filter: none; border-color: var(--accent); }
.ach .i { font-size: 26px; }
.ach .t { font-weight: 800; font-size: 12.5px; margin-top: 4px; }
.ach .d { color: var(--muted); font-size: 11px; margin-top: 2px; line-height: 1.3; }
.board > div { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.board > div:last-child { border-bottom: 0; }
.board .me { color: var(--accent); font-weight: 800; }
.code { font-size: 20px; letter-spacing: 3px; }
