:root {
  --bg: #f5f6fb;
  --card: #ffffff;
  --ink: #1f2240;
  --muted: #6b6f8f;
  --line: #e2e4f0;
  --accent: #4f46e5;
  --accent-soft: #eceafd;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --mid: #f59e0b;
  --mid-soft: #fef3c7;
  --hl: #fff3b0;
  --cw: 36px;
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 680px; margin: 0 auto; padding: 0 16px 32px; }
.loading { text-align: center; color: var(--muted); margin-top: 40vh; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 22px; margin: 18px 0 8px; }
h3 { font-size: 18px; margin: 16px 0 6px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; background: var(--bg);
}
.top h1 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--card); text-decoration: none; font-size: 22px; color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.stars { font-weight: 700; background: var(--card); padding: 6px 12px; border-radius: 999px; box-shadow: 0 1px 2px rgba(0,0,0,.06); white-space: nowrap; }
.net { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.net.off { background: var(--bad); }

/* ---------- карточки ---------- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 1px 3px rgba(20,20,60,.07); margin: 12px 0;
}
.tiles { display: grid; gap: 12px; margin: 12px 0; }
.tile {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  background: var(--card); border: 2px solid transparent; border-radius: var(--radius);
  padding: 14px 16px; text-decoration: none; color: var(--ink);
  box-shadow: 0 1px 3px rgba(20,20,60,.07);
}
.tile:active { transform: scale(.98); }
.tile.star { border-color: var(--accent); }
.tile .ico { font-size: 30px; width: 44px; text-align: center; flex: none; }
.tile .tt { font-weight: 700; display: block; }
.tile .ts { color: var(--muted); font-size: 14px; display: block; }
.tile .badge { margin-left: auto; font-size: 13px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tile .badge.ok { background: var(--ok-soft); color: var(--ok); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.grid2 .tile { flex-direction: column; align-items: flex-start; gap: 4px; }

.btn {
  display: inline-block; border: 0; border-radius: 14px; padding: 13px 20px;
  background: var(--accent); color: #fff; font-weight: 700; text-decoration: none; text-align: center;
}
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.wide { display: block; width: 100%; margin-top: 10px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row .btn { flex: 1; }
input.text {
  width: 100%; font: inherit; font-size: 20px; padding: 12px 14px; border-radius: 12px;
  border: 2px solid var(--line); background: #fff; color: var(--ink);
}
input.text:focus { outline: none; border-color: var(--accent); }
.hello { font-size: 26px; font-weight: 800; margin: 24px 0 4px; }
.stat { display: flex; gap: 10px; flex-wrap: wrap; }
.stat div { background: var(--card); border-radius: 12px; padding: 8px 12px; font-size: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.stat b { font-size: 18px; }

/* ---------- вопрос ---------- */
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 4px 0 12px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.q { background: var(--card); border-radius: var(--radius); padding: 18px 16px; box-shadow: 0 1px 3px rgba(20,20,60,.07); }
.q .big { font-size: 34px; font-weight: 800; text-align: center; margin: 6px 0; letter-spacing: .5px; }
.q .task { font-size: 19px; }
.answer {
  min-height: 60px; margin: 12px 0 0; border-radius: 14px; border: 3px solid var(--line);
  display: flex; align-items: center; justify-content: center; font-size: 34px; font-weight: 800; background: #fff;
}
.answer.empty::after { content: "?"; color: #c7c9dd; }
.answer.ok { border-color: var(--ok); background: var(--ok-soft); }
.answer.bad { border-color: var(--bad); background: var(--bad-soft); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.fb { border-radius: 14px; padding: 12px 14px; margin-top: 12px; font-size: 16px; }
.fb.ok { background: var(--ok-soft); }
.fb.bad { background: var(--bad-soft); }
.fb.info { background: var(--accent-soft); }
.fb b { font-weight: 800; }
.choices { display: grid; gap: 10px; margin-top: 14px; }
.choices.ops { grid-template-columns: repeat(4, 1fr); }
.choice {
  border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 14px; font-size: 20px; font-weight: 700;
}
.choices.ops .choice { font-size: 30px; padding: 10px 0; }
.choice.ok { border-color: var(--ok); background: var(--ok-soft); }
.choice.bad { border-color: var(--bad); background: var(--bad-soft); }
.choice:disabled { cursor: default; }

/* ---------- цифровая клавиатура ---------- */
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.pad button {
  height: 58px; border: 0; border-radius: 14px; background: var(--card); font-size: 26px; font-weight: 700;
  box-shadow: 0 2px 0 var(--line);
}
.pad button:active { transform: translateY(2px); box-shadow: none; }
.pad .go { background: var(--accent); color: #fff; box-shadow: 0 2px 0 #3730a3; }
.pad .del { background: #eef0f7; }

/* ---------- картинки ---------- */
.groups { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.group { border: 2px dashed #c7c9ec; border-radius: 12px; padding: 6px; display: flex; flex-wrap: wrap; gap: 2px; max-width: 108px; justify-content: center; background: #fafaff; }
.group span, .pile span { font-size: 22px; line-height: 1.1; }
.pile { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; margin: 10px auto; max-width: 320px; }
.arr { display: inline-grid; gap: 5px; margin: 10px auto; padding: 8px; background: #fafaff; border-radius: 12px; }
.arr i { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); display: block; }
.arr i.b { background: var(--mid); }
.center { text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: var(--accent-soft); border-radius: 10px; padding: 4px 9px; font-weight: 700; font-size: 15px; }
.chip.now { background: var(--accent); color: #fff; }
.chip.ok { background: var(--ok-soft); color: #166534; }
.tip { background: var(--mid-soft); border-radius: 14px; padding: 12px 14px; margin: 10px 0; }

/* ---------- таблица-карта ---------- */
.mgrid { display: grid; grid-template-columns: 26px repeat(8, 1fr); gap: 3px; max-width: 420px; margin: 8px 0; }
.mgrid div { aspect-ratio: 1; display: grid; place-items: center; border-radius: 6px; font-size: 12px; font-weight: 700; }
.mgrid .h { background: none; color: var(--muted); font-size: 14px; }
.m-none { background: #eceef5; color: #a3a6c2; }
.m-bad { background: #fecaca; color: #991b1b; }
.m-mid { background: #fde68a; color: #92400e; }
.m-good { background: #86efac; color: #14532d; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.legend .l-none::before { background: #eceef5; } .legend .l-bad::before { background: #fecaca; }
.legend .l-mid::before { background: #fde68a; } .legend .l-good::before { background: #86efac; }

/* ---------- столбик ---------- */
.colwrap { background: var(--card); border-radius: var(--radius); padding: 14px 8px; box-shadow: 0 1px 3px rgba(20,20,60,.07); overflow-x: auto; }
.cg { display: grid; justify-content: center; margin: 0 auto; width: max-content;
  background-image: linear-gradient(#e8ecf6 1px, transparent 1px), linear-gradient(90deg, #e8ecf6 1px, transparent 1px);
  background-size: var(--cw) var(--cw); border: 1px solid #e8ecf6; }
.c { width: var(--cw); height: var(--cw); position: relative; display: grid; place-items: center; font-size: 25px; font-weight: 600; font-variant-numeric: tabular-nums; }
.c .sup { position: absolute; top: -3px; right: 2px; font-size: 13px; color: var(--bad); font-weight: 800; }
.c.ul { box-shadow: inset 0 -2.5px 0 var(--ink); }
.c.bl { box-shadow: inset 2.5px 0 0 var(--ink); }
.c.bl.ul { box-shadow: inset 2.5px 0 0 var(--ink), inset 0 -2.5px 0 var(--ink); }
.c.op { color: var(--muted); }
.c.opd { transform: translateY(55%); color: var(--muted); }
.c.hl { background: var(--hl); }
.c.pid { color: var(--accent); }
.c.pid::after { content: ""; position: absolute; left: 3px; right: 3px; bottom: 2px; border-bottom: 2px dotted var(--accent); }
.c.act { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; animation: blink 1.2s infinite; }
@keyframes blink { 50% { outline-color: transparent; } }
.c.qd { color: var(--accent); font-weight: 800; }
.c.opu { transform: translateY(-50%); color: var(--muted); }
.c.new { color: var(--ok); }
.c.dot { color: #b6b9d6; }
.prompt { font-size: 18px; margin: 12px 0 0; min-height: 52px; }
.prompt b { color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); margin: 6px 0; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

.done-ico { font-size: 56px; text-align: center; margin-top: 18px; }
.list { margin: 6px 0; padding-left: 20px; }
.list li { margin: 4px 0; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 28px; font-weight: 800; letter-spacing: 3px; background: var(--accent-soft); padding: 6px 14px; border-radius: 10px; display: inline-block; }
.err { color: var(--bad); }

@media (min-width: 560px) {
  :root { --cw: 42px; }
  .c { font-size: 28px; }
  .pad button { height: 62px; }
}
