.shufi-core{--shufi-ink:#3e1c0a;--shufi-paper:#fffdf7;--shufi-orange:#f5892a;font-family:Assistant,Heebo,Arial,sans-serif;color:var(--shufi-ink);direction:rtl}
.shufi-core *{box-sizing:border-box}
.shufi-core button,.shufi-core input{font:inherit}
.shufi-core button:focus-visible,.shufi-core a:focus-visible,.shufi-core input:focus-visible{outline:3px solid #175cd3;outline-offset:3px}
.shufi-pet{position:fixed;left:18px;bottom:20px;z-index:100001;width:116px;height:132px;pointer-events:none;transition:left 1.8s cubic-bezier(.25,.72,.25,1),top 1.8s cubic-bezier(.25,.72,.25,1)}
.shufi-pet.is-dragging,.shufi-pet.is-flung{transition:none}
.shufi-core.is-dismissed .shufi-pet{display:none}
.shufi-pet-shadow{position:absolute;left:24px;bottom:1px;width:68px;height:12px;border-radius:50%;background:rgba(45,23,11,.21);filter:blur(5px);animation:shufi-shadow 3.6s ease-in-out infinite}
.shufi-launcher{position:absolute;inset:0;display:flex;align-items:flex-end;justify-content:center;width:100%;height:100%;padding:0;border:0;background:transparent;color:inherit;cursor:grab;pointer-events:auto;touch-action:none;-webkit-tap-highlight-color:transparent}
.shufi-core .shufi-launcher,.shufi-core .shufi-launcher:hover,.shufi-core .shufi-launcher:focus,.shufi-core .shufi-launcher:active{background:transparent!important;border:0!important;box-shadow:none!important}
.shufi-pet.is-dragging .shufi-launcher{cursor:grabbing}
.shufi-launcher img{position:absolute;left:2px;bottom:0;display:block;width:112px;height:124px;object-fit:contain;image-rendering:pixelated;filter:drop-shadow(0 5px 4px rgba(61,31,10,.14));transform-origin:50% 87%;animation:shufi-idle 3.6s ease-in-out infinite;user-select:none;-webkit-user-drag:none}
.shufi-sprite{opacity:0}
.shufi-sprite-idle{opacity:1}
.shufi-pet[data-gesture="blink"] .shufi-sprite-idle,.shufi-pet[data-gesture="wave"] .shufi-sprite-idle{opacity:0}
.shufi-pet[data-gesture="blink"] .shufi-sprite-blink,.shufi-pet[data-gesture="wave"] .shufi-sprite-wave{opacity:1}
.shufi-pet[data-gesture="wave"] .shufi-sprite-wave{animation:shufi-wave .28s steps(2,end) infinite alternate}
.shufi-pet[data-gesture="look"] .shufi-sprite-idle{animation:shufi-look 1s steps(2,end) 1}
.shufi-pet[data-facing="left"] .shufi-launcher{transform:scaleX(-1)}
.shufi-pet.is-walking .shufi-launcher img{animation:shufi-step .38s ease-in-out infinite alternate}
.shufi-pet.is-walking .shufi-pet-shadow{animation:shufi-shadow-step .38s ease-in-out infinite alternate}
.shufi-pet.is-dragging .shufi-launcher img{animation:shufi-picked-up .5s ease-in-out infinite alternate}
.shufi-pet.is-flung .shufi-launcher img{animation:shufi-flung .45s ease-in-out infinite alternate}
.shufi-core[data-state=happy] .shufi-launcher img{animation:shufi-hop .45s ease-in-out 3}
.shufi-core[data-state=encourage] .shufi-launcher img{animation:shufi-nod 1s ease-in-out 2}
.shufi-core[data-state=think] .shufi-launcher img{animation:shufi-think 1.4s ease-in-out infinite alternate}
.shufi-pet-label{position:absolute;right:-70px;top:0;padding:6px 10px;border:1.5px solid var(--shufi-ink);border-radius:12px 12px 12px 3px;background:var(--shufi-paper);box-shadow:2px 2px 0 var(--shufi-ink);color:var(--shufi-ink);font-size:13px;font-weight:700;white-space:nowrap;opacity:0;transform:translateY(4px);transition:opacity .18s ease,transform .18s ease}
.shufi-pet:hover .shufi-pet-label,.shufi-launcher:focus-visible + .shufi-pet-label{opacity:1;transform:translateY(0)}
.shufi-panel{position:fixed;inset:auto auto 154px 18px;z-index:100002;display:flex;flex-direction:column;width:min(390px,calc(100vw - 32px));height:min(510px,calc(100dvh - 180px));min-height:260px;overflow:hidden;border:2px solid var(--shufi-ink);border-radius:20px;background:var(--shufi-paper);box-shadow:5px 6px 0 var(--shufi-ink)}
.shufi-panel[hidden]{display:none}
.shufi-header{display:flex;align-items:center;gap:10px;min-height:76px;padding:8px 14px;border-bottom:2px solid var(--shufi-ink);background:#fff0cf}
.shufi-header img{flex:none;width:56px;height:56px;object-fit:contain}
.shufi-header img{image-rendering:pixelated}
.shufi-header h2,.shufi-header p{margin:0}
.shufi-header h2{font-size:22px;line-height:1.2}
.shufi-header p{font-size:13px;line-height:1.4}
.shufi-close{margin-inline-start:auto;width:44px;height:44px;border:0;border-radius:10px;background:transparent;color:var(--shufi-ink);font-size:30px;cursor:pointer}
.shufi-dismiss{margin-inline-start:auto;min-height:36px;padding:5px 9px;border:1px solid #a77651;border-radius:9px;background:#fffaf0;color:var(--shufi-ink);font-size:12px;font-weight:700;white-space:nowrap;cursor:pointer}
.shufi-dismiss:hover{background:#ffe3b8}
.shufi-close{margin-inline-start:0;flex:none}
.shufi-restore{position:fixed;bottom:max(12px,env(safe-area-inset-bottom));left:12px;z-index:100003;display:flex;align-items:center;gap:6px;min-height:42px;padding:3px 9px 3px 5px;border:1.5px solid var(--shufi-ink);border-radius:12px;background:#fff7e7;color:var(--shufi-ink);box-shadow:2px 3px 0 var(--shufi-ink);font-size:13px;font-weight:700;cursor:pointer}
.shufi-restore[hidden]{display:none}
.shufi-restore img{width:28px;height:32px;object-fit:contain;image-rendering:pixelated}
.shufi-messages{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;padding:16px;display:flex;flex-direction:column;gap:12px;scroll-padding-bottom:16px}
.shufi-message{max-width:88%;padding:10px 13px;border:1.5px solid var(--shufi-ink);border-radius:14px;line-height:1.55;font-size:15px;white-space:pre-wrap;overflow-wrap:anywhere}
.shufi-message.is-bot{align-self:flex-start;background:#fff1d9}
.shufi-message.is-user{align-self:flex-end;background:#e7f3ff}
.shufi-message:has(.shufi-card){max-width:100%;width:100%;background:#fffdf7;white-space:normal}
.shufi-text{margin:0 0 8px;white-space:pre-wrap}
.shufi-text:last-child{margin-bottom:0}
.shufi-card{border:1px solid #b78b60;border-radius:12px;background:#fffaf0;padding:12px;margin:8px 0;direction:rtl}
.shufi-card-kicker{font-size:12px;font-weight:800;color:#96511c}
.shufi-card-title{margin:7px 0 11px;font-size:17px;line-height:1.5;direction:auto;unicode-bidi:plaintext}
.shufi-card-passage{padding:9px;margin:8px 0;background:#fff;border-radius:8px;max-height:140px;overflow:auto;white-space:pre-wrap;direction:auto;unicode-bidi:plaintext}
.shufi-card-options{display:grid;gap:7px}
.shufi-card-option{width:100%;padding:9px;text-align:start;border:1px solid #a57248;border-radius:9px;background:#fff;color:#3e1c0a;cursor:pointer;direction:ltr}
.shufi-card-option:hover:not(:disabled){background:#fff0d5}
.shufi-card-option.is-correct{background:#dcf8df;border-color:#26803b}
.shufi-card-option.is-wrong{background:#ffe1dc;border-color:#c24e3d}
.shufi-card-hints{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
.shufi-card-action{min-height:34px;padding:5px 9px;border:1px solid #96511c;border-radius:8px;background:#fff;color:#6b3413;font-size:13px;font-weight:700;cursor:pointer}
.shufi-card-action.is-used{background:#ffe4b2}
.shufi-card-hint-text{width:100%;margin:0;white-space:pre-wrap}
.shufi-card-explanation{margin-top:10px;padding:10px;border-radius:8px;background:#eaf6e8;white-space:pre-wrap}
.shufi-card-explanation[hidden]{display:none}
.shufi-card-explanation p{margin:7px 0}
.shufi-card-translation{font-size:19px;font-weight:700;margin:0 0 8px}
.shufi-card-sentence{direction:ltr;text-align:left;font-style:italic;background:#fff;padding:8px;border-radius:8px}
.shufi-card-mnemonic{padding:8px;background:#fff1d9;border-radius:8px}
.shufi-actions{display:flex;gap:8px;padding:8px 12px;overflow:auto}
.shufi-actions button{flex:none;min-height:44px;padding:7px 11px;border:1.5px solid var(--shufi-ink);border-radius:999px;background:#fff;color:var(--shufi-ink);font-size:14px;font-weight:700;cursor:pointer}
.shufi-actions button:hover{background:#ffe9b6}
.shufi-error{margin:0 12px 8px;color:#a52714;font-size:14px}
.shufi-error[hidden]{display:none}
.shufi-composer{display:flex;gap:8px;padding:10px 12px;border-top:1px solid #e9d6b8}
.shufi-composer input{flex:1;min-width:0;min-height:44px;padding:8px 12px;border:1.5px solid var(--shufi-ink);border-radius:10px;background:#fff;color:var(--shufi-ink);font-size:16px}
.shufi-composer button{min-width:56px;min-height:44px;padding:8px 10px;border:1.5px solid var(--shufi-ink);border-radius:10px;background:var(--shufi-orange);color:var(--shufi-ink);font-weight:700;cursor:pointer}
.shufi-composer button:disabled{opacity:.6;cursor:wait}
.shufi-composer .shufi-tool{min-width:38px;padding:6px;background:#fff;font-size:18px}
.shufi-composer .shufi-tool[hidden]{display:none}
.shufi-composer .shufi-tool.is-recording{background:#ffe0d4;border-color:#c24e3d}
.shufi-attachment-preview{display:flex;align-items:center;gap:9px;padding:6px 12px}
.shufi-attachment-preview[hidden]{display:none}
.shufi-attachment-preview img{width:44px;height:44px;object-fit:cover;border-radius:6px}
.shufi-attachment-preview button{padding:5px;border:1px solid #96511c;border-radius:6px;background:#fff}
.shufi-full{display:block;padding:8px 12px 12px;text-align:center;color:#6b3413;font-size:14px;font-weight:700;text-decoration:underline}
@keyframes shufi-idle{50%{transform:translateY(-5px) rotate(1.5deg)}}
@keyframes shufi-shadow{50%{transform:scale(.84);opacity:.65}}
@keyframes shufi-step{to{transform:translateY(-8px) rotate(3deg)}}
@keyframes shufi-shadow-step{to{transform:scale(.75);opacity:.6}}
@keyframes shufi-picked-up{to{transform:translateY(-7px) rotate(7deg) scale(1.04)}}
@keyframes shufi-flung{to{transform:rotate(13deg) translateY(-4px)}}
@keyframes shufi-wave{to{transform:rotate(7deg) translateY(-2px)}}
@keyframes shufi-look{30%{transform:rotate(-7deg) translateX(-3px)}70%{transform:rotate(5deg) translateX(2px)}}
@keyframes shufi-hop{50%{transform:translateY(-14px) scale(1.035)}}
@keyframes shufi-nod{50%{transform:rotate(5deg)}}
.shufi-core[data-state=rest] .shufi-header img{animation:shufi-breathe 3.2s ease-in-out infinite}
.shufi-core[data-state=listen] .shufi-header img{animation:shufi-listen 1.4s ease-in-out infinite alternate}
.shufi-core[data-state=think] .shufi-header img{animation:shufi-think 1.2s ease-in-out infinite alternate}
.shufi-core[data-state=speak] .shufi-header img{animation:shufi-speak .35s ease-in-out 3 alternate}
.shufi-core[data-state=happy] .shufi-header img{animation:shufi-happy .4s ease-in-out 2 alternate}
.shufi-core[data-state=encourage] .shufi-header img{animation:shufi-encourage 1.2s ease-in-out 2 alternate}
@keyframes shufi-breathe{50%{transform:scale(1.015,1.03)}}
@keyframes shufi-listen{to{transform:rotate(-4deg)}}
@keyframes shufi-think{to{transform:rotate(-5deg)}}
@keyframes shufi-speak{to{transform:translateY(-2px)}}
@keyframes shufi-happy{to{transform:translateY(-5px)}}
@keyframes shufi-encourage{to{transform:rotate(3deg)}}
@media(max-width:600px){.shufi-pet{width:94px;height:108px}.shufi-launcher img{width:92px;height:104px}.shufi-pet-shadow{left:20px;width:55px}.shufi-pet-label{display:none}.shufi-core.is-open .shufi-pet{visibility:hidden}.shufi-panel{inset:auto 0 0 0!important;width:100%;height:min(78dvh,680px);border-radius:20px 20px 0 0;border-bottom:0;box-shadow:0 -6px 20px #3e1c0a33;padding-bottom:env(safe-area-inset-bottom)}.shufi-panel:before{content:"";width:42px;height:4px;border-radius:4px;background:#ad8b6e;position:absolute;top:7px;left:calc(50% - 21px)}.shufi-header{padding-top:15px}}
@media(max-width:600px){.shufi-restore{bottom:max(76px,calc(env(safe-area-inset-bottom) + 12px))}}
@media(prefers-reduced-motion:reduce){.shufi-core .shufi-header img,.shufi-launcher img,.shufi-pet-shadow{animation:none!important}.shufi-pet,.shufi-pet-label{transition:none}}

/* The floating companion is desktop-only; the full tutor route stays responsive. */
@media (max-width: 900px) {
  #shufi-root.shufi-core { display: none !important; }
}
