:root{
  --bg:#F7F5F0;--surface:#FFFFFF;--primary:#4F7C82;--primary-soft:#E3EDEE;--primary-dark:#3E6469;
  --warm:#D9A45B;--warm-soft:#F6EBDA;--ok:#6B9E6F;--ok-soft:#E6F0E6;--warn:#D08A5A;--err:#C0645A;--err-soft:#F7E6E4;
  --text:#2B2F33;--muted:#6B7280;--border:#E5E1D8;
  --alg:#7A8FC4;--geo:#6FA8A0;--phy:#C48E6B;--eng:#A67FB8;--bio:#7FAF7A;--chem:#C79A5B;
  --r:12px;--shadow:0 1px 2px rgba(43,47,51,.04),0 4px 14px rgba(43,47,51,.06);
}
*{box-sizing:border-box}
html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--text);font:16px/1.5 Inter,"Segoe UI",Roboto,system-ui,sans-serif;-webkit-font-smoothing:antialiased}
a{color:var(--primary);text-decoration:none}
button{font:inherit}
.wrap{max-width:720px;margin:0 auto;padding:16px}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;border:0;border-radius:var(--r);padding:12px 18px;background:var(--primary);color:#fff;font-weight:600;cursor:pointer;min-height:44px}
.btn:hover{background:var(--primary-dark)}
.btn.ghost{background:var(--surface);color:var(--primary);border:1px solid var(--border)}
.btn.soft{background:var(--primary-soft);color:var(--primary-dark)}
.btn.icon{width:44px;height:44px;padding:0;border-radius:50%;font-size:20px}
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--r);padding:16px;box-shadow:var(--shadow)}
.muted{color:var(--muted)}
.small{font-size:14px}
h1{font-size:26px;margin:0 0 4px}
h2{font-size:17px;margin:20px 0 10px;color:var(--muted);font-weight:600;letter-spacing:.02em}
.row{display:flex;align-items:center;gap:12px}
.between{justify-content:space-between}
.chip{display:inline-flex;align-items:center;gap:6px;padding:6px 12px;border-radius:999px;font-size:14px;font-weight:500;background:var(--primary-soft);color:var(--primary-dark)}
.chip.ok{background:var(--ok-soft);color:#3F6B43}
.chip.warm{background:var(--warm-soft);color:#8A5E1E}
.streak{display:inline-flex;align-items:center;gap:6px;background:var(--warm-soft);color:#8A5E1E;padding:6px 12px;border-radius:999px;font-weight:600;font-size:14px}
.topbar{position:sticky;top:0;background:var(--bg);padding:12px 0;z-index:5;display:flex;align-items:center;gap:12px}
.topbar .title{font-weight:600}
.topbar .sub{font-size:13px;color:var(--muted)}
.back{width:40px;height:40px;border-radius:50%;border:1px solid var(--border);background:var(--surface);display:grid;place-items:center;font-size:18px;cursor:pointer}
.subjects{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:12px}
.subject{position:relative;overflow:hidden;background:var(--surface);border:1px solid var(--border);border-radius:var(--r);padding:16px 16px 16px 20px;cursor:pointer;box-shadow:var(--shadow);transition:transform .08s}
.subject:hover{transform:translateY(-1px)}
.subject::before{content:"";position:absolute;left:0;top:0;bottom:0;width:6px;background:var(--c)}
.subject .e{font-size:26px}
.subject .n{font-weight:600;margin-top:6px}
.subject .l{font-size:13px;color:var(--muted)}
.list{display:flex;flex-direction:column;gap:8px}
.item{display:flex;align-items:center;gap:12px;background:var(--surface);border:1px solid var(--border);border-radius:var(--r);padding:12px 14px}
.dot{width:10px;height:10px;border-radius:50%;background:var(--c)}
.item .t{font-weight:500}
.item .s{font-size:13px;color:var(--muted)}
.modes{display:flex;gap:8px;flex-wrap:wrap}
.footer-link{display:block;text-align:center;margin:28px 0 8px;color:var(--primary);font-weight:500}
/* chat */
.chat-page{display:flex;flex-direction:column;min-height:100dvh}
.feed{flex:1;display:flex;flex-direction:column;gap:10px;padding:8px 0 16px}
.msg{max-width:82%;padding:10px 14px;border-radius:16px;line-height:1.5;word-wrap:break-word}
.msg.kid{align-self:flex-end;background:var(--primary-soft);border-bottom-right-radius:4px}
.msg.tutor{align-self:flex-start;background:var(--surface);border:1px solid var(--border);border-bottom-left-radius:4px}
.msg img.att{max-width:220px;border-radius:10px;display:block;margin-bottom:6px}
.msg .math{font-family:"Cambria Math","Times New Roman",serif;font-size:1.05em}
.banner{align-self:center;max-width:92%;text-align:center;padding:10px 14px;border-radius:var(--r);font-size:14px}
.banner.ok{background:var(--ok-soft);color:#3F6B43}
.banner.warm{background:var(--warm-soft);color:#8A5E1E}
.banner.gray{background:#EDEBE5;color:var(--muted)}
.divider{align-self:center;font-size:12px;color:var(--muted);letter-spacing:.06em;text-transform:uppercase;padding:4px 0}
.composer{position:sticky;bottom:0;background:var(--bg);padding:8px 0 12px}
.composer .box{background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:8px;box-shadow:var(--shadow)}
.composer textarea{width:100%;border:0;resize:none;font:inherit;padding:8px;outline:0;min-height:44px;background:transparent}
.composer .tools{display:flex;align-items:center;gap:8px}
.composer .spacer{flex:1}
.thumbs{display:flex;gap:8px;padding:4px 8px 8px}
.thumb{position:relative;width:56px;height:56px;border-radius:8px;overflow:hidden;border:1px solid var(--border)}
.thumb img{width:100%;height:100%;object-fit:cover}
.thumb .x{position:absolute;top:2px;right:2px;width:18px;height:18px;border-radius:50%;background:rgba(43,47,51,.7);color:#fff;font-size:11px;display:grid;place-items:center;cursor:pointer}
.rec{display:flex;align-items:center;gap:10px;padding:8px 12px;color:var(--err);font-weight:500}
.rec .pulse{width:10px;height:10px;border-radius:50%;background:var(--err);animation:p 1s infinite}
@keyframes p{50%{opacity:.3}}
/* login */
.login{min-height:100dvh;display:grid;place-items:center;padding:16px}
.login .card{width:100%;max-width:380px;text-align:center}
.kids{display:flex;gap:12px;justify-content:center;margin:16px 0}
.kid-card{flex:1;border:2px solid var(--border);border-radius:var(--r);padding:14px 8px;cursor:pointer;background:var(--surface)}
.kid-card.active{border-color:var(--primary);background:var(--primary-soft)}
.kid-card .a{font-size:40px}
.kid-card .n{font-weight:600;margin-top:4px}
.kid-card .g{font-size:13px;color:var(--muted)}
.pin{width:100%;font-size:26px;letter-spacing:.5em;text-align:center;padding:12px;border:1px solid var(--border);border-radius:var(--r);outline:0}
.pin:focus{border-color:var(--primary)}
.error{color:var(--err);font-size:14px;margin-top:8px;min-height:20px}
/* progress */
.stats{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.stat{background:var(--surface);border:1px solid var(--border);border-radius:var(--r);padding:16px;text-align:center}
.stat .v{font-size:32px;font-weight:700;color:var(--primary-dark)}
.stat .l{font-size:13px;color:var(--muted)}
.chips{display:flex;flex-wrap:wrap;gap:8px}
@media (max-width:420px){.msg{max-width:90%}.wrap{padding:12px}}

/* иконки вместо эмодзи */
.subject .e svg{width:26px;height:26px;fill:none;stroke:var(--c);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.streak svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2;stroke-linejoin:round}
.logo{width:56px;height:56px;margin:0 auto 8px;border-radius:16px;background:var(--primary);color:#fff;font-weight:700;font-size:28px;display:grid;place-items:center}
.kid-card .a{width:56px;height:56px;margin:0 auto;border-radius:50%;background:var(--c);color:#fff;font-weight:700;font-size:24px;display:grid;place-items:center}
.btn.icon svg{display:block}

/* --- дополнения для живого интерфейса --- */
.hidden{display:none!important}
.msg p{margin:0 0 6px}.msg p:last-child{margin:0}
.msg ul,.msg ol{margin:4px 0;padding-left:20px}
.msg svg:not(.katex svg){max-width:100%;height:auto;display:block;margin:8px 0}
.msg .katex-display{margin:6px 0;overflow-x:auto;overflow-y:hidden;padding:2px 0}
.msg.error{align-self:flex-start;background:var(--err-soft);color:#7A3A34;border:1px solid #EAC8C4}
.msg .retry{display:inline-block;margin-top:6px;color:var(--primary);cursor:pointer;font-weight:500}
.typing{display:inline-flex;gap:4px;padding:4px 0}
.typing i{width:6px;height:6px;border-radius:50%;background:var(--muted);animation:t 1s infinite}
.typing i:nth-child(2){animation-delay:.2s}.typing i:nth-child(3){animation-delay:.4s}
@keyframes t{50%{opacity:.25}}
.btn:disabled{opacity:.5;cursor:default}
.btn.icon.rec-on{background:var(--err-soft);color:var(--err)}
.sheet{position:fixed;inset:0;background:rgba(43,47,51,.35);display:grid;place-items:end center;z-index:20}
.sheet .panel{background:var(--surface);border-radius:16px 16px 0 0;padding:16px;width:100%;max-width:720px}
.sheet .panel h3{margin:0 0 12px;font-size:17px}
.empty{color:var(--muted);font-size:14px;padding:8px 0}
.kid-card.active .a{box-shadow:0 0 0 3px var(--primary-soft)}
.pin.shake{animation:sh .3s}@keyframes sh{25%{transform:translateX(-6px)}75%{transform:translateX(6px)}}
