:root{--app-height:100dvh;--tg-top-overlay-offset:12px;--tg-bg-color:#070b14;--tg-text-color:#e8edf6;--tg-hint-color:#94a1b5;--tg-button-color:#5b7fff;--surface:rgba(15,21,36,.84);--surface-strong:#111a2d;--border-soft:hsla(0,0%,100%,.08);--assistant-grad-start:#161f35;--assistant-grad-end:#121a2c;--user-grad-start:#536dff;--user-grad-end:#5a42ea}*{box-sizing:border-box}body,html{height:100%;margin:0;padding:0;overflow:hidden;overflow-x:hidden;text-size-adjust:100%;background:radial-gradient(circle at 18% 15%,#162540 0,#070b14 48%),radial-gradient(circle at 82% 8%,#2f2550 0,rgba(7,11,20,0) 38%),var(--tg-bg-color);color:var(--tg-text-color);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.app-shell,body,html{width:100%;max-width:100vw}.app-shell{height:var(--app-height);position:relative;overflow:hidden}.bg-orb{position:absolute;filter:blur(48px);opacity:.35;pointer-events:none}.bg-orb-left{width:260px;height:260px;background:#2f65ff;top:-80px;left:-70px}.bg-orb-right{width:280px;height:280px;background:#8c3bff;top:4%;right:-100px}.chat-shell{position:relative;z-index:1;width:100%;max-width:860px;margin:0 auto;height:var(--app-height);display:flex;flex-direction:column;gap:14px;padding:calc(env(safe-area-inset-top) + var(--tg-top-overlay-offset)) 12px max(12px,env(safe-area-inset-bottom));overflow-x:hidden}.onboarding-shell{justify-content:center;align-items:center}.is-telegram-miniapp .messages{padding-top:14px}.chat-header{position:-webkit-sticky;position:sticky;top:max(8px,env(safe-area-inset-top));z-index:20;display:flex;justify-content:space-between;align-items:flex-start;gap:12px;padding:12px 14px;border-radius:18px;border:1px solid var(--border-soft);background:rgba(10,14,24,.72);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px)}.header-spacer{min-height:30px}.mode-pill{flex-shrink:0;border-radius:999px;padding:6px 10px;font-size:.75rem;color:#d7e5ff;border:1px solid rgba(120,160,255,.35);background:rgba(37,74,176,.42)}.messages{flex:1 1;overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;-webkit-overflow-scrolling:touch;touch-action:pan-y;padding:4px 2px 10px;display:flex;flex-direction:column;gap:14px}.tg-loading-lock,.tg-loading-lock body{overscroll-behavior-y:none!important}.tg-loading-lock .app-shell,.tg-loading-lock .chat-shell,.tg-loading-lock .messages{touch-action:none!important}.message-row{display:flex;align-items:flex-end}.message-user{justify-content:flex-end}.message-assistant{justify-content:flex-start}.message-content{display:flex;flex-direction:column;max-width:min(86%,680px);gap:0}.message-user .message-content{align-items:flex-end;max-width:min(78%,560px)}.message-bubble{border-radius:18px;padding:13px 14px;line-height:1.56;border:1px solid var(--border-soft);box-shadow:0 10px 28px rgba(0,0,0,.22)}.message-user .message-bubble{background:linear-gradient(145deg,#4459c9,#4d56bb);border-color:rgba(170,188,255,.22);color:#fff}.message-assistant .message-bubble{background:linear-gradient(145deg,var(--assistant-grad-start),var(--assistant-grad-end))}.text-block{margin:0;white-space:pre-wrap;font-size:.97rem}.blocks{display:flex;flex-direction:column;gap:14px}.math-block-center{display:flex;justify-content:center}.math-block-center,.math-block-scroll{overflow-x:auto;overflow-y:hidden;border-radius:12px;padding:7px 6px;background:hsla(0,0%,100%,.045);border:1px solid hsla(0,0%,100%,.08);box-shadow:inset 0 1px 1px hsla(0,0%,100%,.03)}.math-block-scroll{display:block;text-align:left}.math-block-center::-webkit-scrollbar,.math-block-scroll::-webkit-scrollbar{height:5px}.math-block-center::-webkit-scrollbar-thumb,.math-block-scroll::-webkit-scrollbar-thumb{background:rgba(164,183,232,.35);border-radius:999px}.math-block-content{width:max-content;max-width:none;transform-origin:top left;flex:0 0 auto}.math-block-center .math-block-content{transform-origin:top center}.math-inline{display:inline-flex;margin:0 .12em;vertical-align:-.07em}.math-inline .katex{line-height:1}.math-fallback{color:#ff8080;font-size:.92rem}.image-block{max-width:100%;border-radius:12px;border:1px solid var(--border-soft)}.text-flow{margin:0;line-height:1.58;font-size:.94rem}.text-flow,.text-inline{white-space:pre-wrap}.heading-block{margin:2px 0 0;letter-spacing:.01em}.heading-h2{font-size:1.06rem;font-weight:700}.heading-h3{font-size:.96rem;font-weight:650;color:#d8e3ff;letter-spacing:.005em}.heading-inline-text{white-space:pre-wrap}.step-block{border:1px solid rgba(142,164,214,.1);border-radius:12px;padding:8px 10px;background:rgba(14,21,37,.22)}.step-title{margin:0 0 6px;font-size:.9rem;color:#acc3ff;font-weight:680;text-transform:none;letter-spacing:.015em}.step-content{display:flex}.step-content .blocks{width:100%;gap:10px}.step-content .math-block-center,.step-content .math-block-scroll{background:hsla(0,0%,100%,.03);border-color:hsla(0,0%,100%,.065)}.composer{position:-webkit-sticky;position:sticky;bottom:max(8px,env(safe-area-inset-bottom));display:flex;align-items:center;gap:8px;padding:5px;border-radius:22px;background:rgba(11,17,29,.88);border:1px solid rgba(127,147,192,.18);-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px)}.composer-left{position:relative;flex-shrink:0}.composer-field{flex:1 1;height:40px;display:flex;align-items:center;border-radius:18px;background:rgba(18,27,44,.82);border:1px solid rgba(123,147,201,.22);transition:border-color .2s ease,box-shadow .2s ease;position:relative}.composer-field:focus-within{border-color:rgba(140,170,255,.7);box-shadow:0 0 0 2px rgba(91,127,255,.22)}.composer input{width:100%;border:none;border-radius:18px;background:transparent;color:var(--tg-text-color);padding:0 14px;font-size:16px;line-height:40px;outline:none;height:40px}.composer input::placeholder{color:rgba(175,190,220,.72)}.attach-button{border:1px solid rgba(119,146,203,.28);width:38px;height:38px;border-radius:999px;display:grid;place-items:center;background:rgba(24,36,58,.82);color:#d8e4ff;cursor:pointer;transition:transform .16s ease,opacity .16s ease,border-color .16s ease}.attach-button svg{width:18px;height:18px;fill:currentColor}.attach-button:hover{transform:translateY(-1px);border-color:rgba(145,173,236,.5)}.action-button{border:none;width:38px;height:38px;border-radius:999px;display:grid;place-items:center;background:linear-gradient(145deg,#6a8df4,#4f6cdf);color:#fff;cursor:pointer;box-shadow:0 8px 16px rgba(58,97,227,.28);transition:transform .16s ease,opacity .16s ease,box-shadow .16s ease}.action-button svg{width:18px;height:18px;fill:currentColor}.action-button:hover{transform:translateY(-1px) scale(1.02);box-shadow:0 10px 18px rgba(58,97,227,.36)}.action-button.voice-mode{box-shadow:0 0 0 2px rgba(108,143,255,.18),0 8px 16px rgba(58,97,227,.32)}.action-button.voice-mode:not(:disabled){animation:voice-pulse 1.6s ease-in-out infinite}.action-button.recording{background:linear-gradient(145deg,#ff4e63,#db2b45);box-shadow:0 0 0 2px rgba(255,99,126,.22),0 10px 20px rgba(219,43,69,.36)}.action-button:disabled,.attach-button:disabled{opacity:.5;cursor:not-allowed;transform:none}.action-button:disabled{box-shadow:none}@keyframes voice-pulse{0%,to{box-shadow:0 0 0 2px rgba(108,143,255,.18),0 8px 16px rgba(58,97,227,.32)}50%{box-shadow:0 0 0 4px rgba(108,143,255,.24),0 10px 18px rgba(58,97,227,.4)}}.error-line{color:#ffabb3;margin:0 2px;font-size:.9rem}.pending-attachments{display:flex;flex-direction:column;gap:8px}.pending-item{display:flex;align-items:center;gap:10px;border:1px solid rgba(119,146,203,.28);border-radius:12px;background:rgba(18,27,44,.72);padding:8px}.pending-item-image{width:42px;height:42px;object-fit:cover;border-radius:8px;border:1px solid hsla(0,0%,100%,.12)}.pending-item-file-icon{width:42px;height:42px;border-radius:8px;display:grid;place-items:center;background:rgba(38,55,92,.72);border:1px solid rgba(132,164,236,.26)}.pending-item-meta{min-width:0;flex:1 1}.pending-item-name{font-size:.82rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.pending-item-info{font-size:.74rem;color:var(--tg-hint-color)}.pending-item-remove{border:1px solid hsla(0,0%,100%,.15);background:rgba(41,57,94,.72);color:#fff;width:24px;height:24px;border-radius:999px;cursor:pointer}.profile-card{border:1px solid var(--border-soft);border-radius:18px;background:rgba(16,24,40,.68);padding:16px 14px;max-width:760px;width:100%;margin:0 auto;text-align:center}.profile-card h2{margin:0;font-size:1.04rem}.profile-card p{margin:8px 0 12px;color:var(--tg-hint-color);font-size:.9rem;text-align:center}.profile-label{margin:12px 0 8px;color:#c9d7f9;font-size:.85rem;font-weight:650}.profile-selected-line{margin:2px 0 10px;color:#d7e4ff;font-size:.86rem;text-align:center}.chip-grid{display:flex;flex-wrap:wrap;gap:8px;justify-content:center}.chip{border:1px solid rgba(119,146,203,.36);background:rgba(34,47,77,.7);color:#dce6ff;border-radius:999px;padding:7px 11px;font-size:.8rem;cursor:pointer}.chip.active{border-color:rgba(140,170,255,.72);background:rgba(63,91,156,.85)}.grade-grid{display:flex;flex-wrap:wrap;justify-content:center;gap:8px}.grade-chip{border:1px solid rgba(119,146,203,.36);background:rgba(34,47,77,.7);color:#dce6ff;border-radius:10px;width:54px;padding:7px 0;font-size:.85rem;cursor:pointer}.grade-chip.active{border-color:rgba(140,170,255,.72);background:rgba(63,91,156,.85)}.profile-submit{width:100%;border:none;border-radius:12px;background:linear-gradient(145deg,#6a8df4,#4f6cdf);color:#fff;font-size:.92rem;font-weight:650;padding:10px 12px;cursor:pointer}.profile-submit:disabled{opacity:.5;cursor:not-allowed}.profile-actions{margin-top:14px;display:grid;grid-template-columns:112px 1fr;grid-gap:10px;gap:10px;max-width:360px;margin-left:auto;margin-right:auto}.profile-back{border:1px solid rgba(119,146,203,.42);border-radius:12px;background:rgba(34,47,77,.7);color:#dce6ff;font-size:.88rem;cursor:pointer}.profile-active-bar{display:flex;align-items:center;justify-content:flex-start;gap:12px;border:1px solid rgba(119,146,203,.26);border-radius:12px;padding:8px 10px;background:rgba(20,30,48,.55);font-size:.84rem;color:#dce6ff;position:-webkit-sticky;position:sticky;top:0;z-index:12}.is-telegram-miniapp .profile-active-bar{top:clamp(52px,8vh,74px)}.profile-active-bar button{border:1px solid rgba(119,146,203,.42);background:rgba(34,47,77,.72);color:#dce6ff;border-radius:999px;padding:6px 11px;font-size:.76rem;cursor:pointer;white-space:nowrap}.empty-state{margin:auto;width:min(100%,600px);text-align:center;padding:22px 16px;border-radius:18px;border:1px solid var(--border-soft);background:rgba(16,24,40,.58)}.empty-state h2{margin:0;font-size:1.05rem}.empty-state p{margin:8px 0 0;color:var(--tg-hint-color);font-size:.92rem}.suggestions{margin-top:14px;display:flex;flex-wrap:wrap;gap:8px;justify-content:center}.suggestions button{border:1px solid rgba(119,146,203,.36);background:rgba(34,47,77,.7);color:#dce6ff;border-radius:999px;padding:8px 11px;font-size:.8rem;cursor:pointer}.typing-indicator{width:-moz-fit-content;width:fit-content;display:flex;align-items:center;gap:4px;padding:9px 12px;border-radius:999px;background:rgba(19,29,46,.82);border:1px solid var(--border-soft)}.typing-indicator span{width:6px;height:6px;border-radius:999px;background:#9db7ff;animation:typing-bounce 1.2s ease-in-out infinite}.typing-indicator span:nth-child(2){animation-delay:.15s}.typing-indicator span:nth-child(3){animation-delay:.3s}.file-block{display:flex;align-items:center;gap:8px;border:1px solid rgba(132,164,236,.22);border-radius:10px;background:rgba(28,43,76,.52);padding:8px 10px}.file-block-icon{font-size:1.05rem}.file-block-meta{min-width:0}.file-block-name{font-size:.84rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.file-block-info{font-size:.74rem;color:var(--tg-hint-color)}.audio-message-block{display:flex;align-items:center;gap:8px;border:1px solid rgba(132,164,236,.26);border-radius:12px;background:rgba(28,43,76,.62);padding:7px 9px}.audio-play-button{border:none;width:30px;height:30px;border-radius:999px;background:rgba(95,126,255,.95);color:#fff;display:grid;place-items:center;cursor:pointer}.audio-play-button svg{width:15px;height:15px;fill:currentColor}.audio-wave{flex:1 1;height:24px;display:flex;align-items:flex-end;gap:2px}.audio-wave-bar{width:3px;border-radius:999px;background:rgba(181,199,243,.4)}.audio-wave-bar.active{background:#dce7ff}.audio-time{font-size:.75rem;color:#d2dffb;min-width:38px;text-align:right}@keyframes typing-bounce{0%,80%,to{transform:translateY(0);opacity:.4}40%{transform:translateY(-3px);opacity:1}}@media (max-width:640px){.chat-shell{padding-inline:8px}.chat-header{border-radius:14px;padding:10px 11px}.message-content{max-width:calc(100% - 38px)}.message-bubble{border-radius:14px;padding:11px 12px}.composer{padding:5px;border-radius:18px}.action-button,.attach-button{width:36px;height:36px}}