*{box-sizing:border-box}html,body{height:100%;margin:0;overflow:hidden}body{height:100dvh;background:#09101e;color:#eff6ff;font-family:system-ui,sans-serif;display:flex;flex-direction:column;overscroll-behavior:none}header{height:55px;flex:none;padding:14px 5vw;border-bottom:1px solid #263b56;display:flex;justify-content:space-between;align-items:center}header strong{font-size:21px;letter-spacing:2px;color:white}header span{color:#48c8ff;margin-left:8px}small{font-size:10px;color:#a2bad0;letter-spacing:.5px}main{width:100%;flex:1;min-height:0;display:flex;flex-direction:column;max-width:1100px;margin:auto;overflow:hidden}#stage{flex:1;min-height:0;position:relative;background:radial-gradient(ellipse at center,#20496e,#09101e 76%)}canvas{width:100%;height:100%;display:block;position:absolute}#status{position:absolute;bottom:12px;left:50%;transform:translateX(-50%);font-size:12px;color:#a9d3e6;max-width:94%;text-align:center;min-height:18px}.chat{flex:none;min-height:115px;max-height:40%;background:#0c192b;border-top:1px solid #294861;padding:18px max(18px,6vw) calc(13px + env(safe-area-inset-bottom));overflow:hidden;display:flex;flex-direction:column;justify-content:center}#ask-form{width:100%;display:flex;gap:10px;align-items:center;margin:0}#question{flex:1;min-width:0;width:0;border:1px solid #46677e;border-radius:28px;background:#142a40;color:white;padding:14px 18px;font:16px system-ui,sans-serif;outline:none}#question:focus{border-color:#52c9ff}#send{flex:none;width:47px;height:47px;padding:0;border-radius:50%;background:#249fd8;color:white;font-size:28px;line-height:1;cursor:pointer}button{border:1px solid #3d7299;background:#173753;color:white;border-radius:10px;padding:8px 13px;font:inherit;cursor:pointer}button:disabled{opacity:.45;cursor:default}.tiny{text-align:center;margin:10px 0 0;color:#92afc2;font-size:11px}.sr-only{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}#audio-fallback{display:flex;justify-content:center;gap:10px;margin-top:7px}#audio-fallback[hidden],#tv-player[hidden],#answer-audio[hidden],#voice[hidden],#chips[hidden],#video-offer[hidden]{display:none}#answer-audio{width:100%;height:35px}#tv-player{position:absolute;inset:8px;display:flex;flex-direction:column;justify-content:safe center;align-items:center;gap:8px;z-index:4;overflow:auto}#tv-mount{background:#021423;overflow:hidden;border-radius:16px;box-shadow:0 0 20px #36d2ff66;width:100%;max-width:640px;aspect-ratio:16/9;min-width:200px;min-height:200px;flex-shrink:0;position:relative}#tv-mount iframe{width:100%;height:100%;border:0;display:block}.tvbar{display:flex;gap:8px;align-items:center;justify-content:center;background:#09101e;padding:6px;border-radius:12px;flex-wrap:wrap}.tvbar a{color:#6ad2ff;font-size:11px}.tvbar #tv-note{font-size:11px;flex-basis:100%;text-align:center;color:#b9d0df}#stage.tv-active #status{display:none}@media(max-height:480px){header{height:36px;padding:4px 18px}.chat{min-height:84px;padding:8px 16px}.tiny{margin-top:5px}}@media(min-width:780px){.chat{padding-left:20%;padding-right:20%;min-height:130px}}

body{position:fixed;top:var(--visual-top,0);left:var(--visual-left,0);width:var(--visual-width,100%);height:var(--visual-height,100dvh)}#actor{touch-action:none;cursor:grab}#actor:active{cursor:grabbing}#inspect-back{position:absolute;top:12px;left:14px;z-index:3;border-radius:50%;width:36px;height:36px;padding:0;background:#0a1d2bdc;font-size:20px}#inspect-back[hidden]{display:none}.keyboard-open header{height:37px;padding:5px 18px}.keyboard-open .chat{min-height:75px;padding:8px 15px}.keyboard-open .chat .tiny{margin:6px 0 0;font-size:10px}.keyboard-open #status{bottom:4px}.keyboard-open #stage{min-height:65px}.keyboard-open #question{padding:11px 15px}.keyboard-open #send{width:43px;height:43px}

#last-question{align-self:flex-end;max-width:100%;margin:0 0 9px;padding:8px 13px;border-radius:14px 14px 4px 14px;background:#183c58;color:#ecf8ff;font-size:14px;line-height:1.25;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow-wrap:anywhere}#last-question[hidden]{display:none}.keyboard-open #last-question{font-size:12px;padding:5px 9px;margin-bottom:5px;-webkit-line-clamp:1}.chat{max-height:52%}#answer.visible-answer{position:static!important;width:auto;height:auto;clip:auto;white-space:normal;margin:5px 0 0;padding:5px;color:#bdd9ed;font-size:12px;max-height:3.6em;overflow:hidden;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical}

/* Keep the character on screen while media plays. Explicit expansion is optional. */
#resource-dock{position:absolute;top:10px;right:10px;z-index:3;display:flex;flex-direction:column;gap:5px;max-width:46%}#resource-dock[hidden]{display:none}#resource-dock a{display:block;color:#b5eeff;background:#10283ce8;border:1px solid #3e7998;padding:7px 10px;border-radius:15px;font-size:12px;text-decoration:none;white-space:nowrap}#stage.tv-active:not(.tv-expanded) #tv-player{inset:auto 8px 8px auto;width:min(56%,440px);overflow:visible;gap:4px;justify-content:flex-end}#stage.tv-active:not(.tv-expanded) #tv-mount{width:100%;height:auto;min-width:0;min-height:0;aspect-ratio:16/9}#stage.tv-active:not(.tv-expanded) .tvbar{font-size:10px;padding:3px;gap:4px}#stage.tv-active:not(.tv-expanded) .tvbar button{font-size:10px;padding:4px 6px}#stage.tv-active:not(.tv-expanded) .tvbar #tv-note{display:none}#stage.tv-active:not(.tv-expanded) #status{display:none}#stage.tv-expanded #resource-dock{display:none}.keyboard-open #resource-dock{display:none}
#stage #actor{left:0;top:0;transition:width .35s ease,height .35s ease,top .35s ease}
#stage.resource-active:not(.tv-expanded) #actor,#stage.tv-active:not(.tv-expanded) #actor{width:43%;height:100%}
#stage.resource-active:not(.tv-expanded) #status{left:21%;max-width:41%;font-size:10px}
#resource-dock{top:12px;right:10px;bottom:12px;width:53%;max-width:none;padding:12px;gap:10px;background:linear-gradient(160deg,#17334ceb,#0b1b2dee);border:1px solid #376582;border-radius:16px;overflow:hidden;justify-content:center}
#resource-links{display:flex;flex-direction:column;gap:8px;min-height:0}#resource-links a{white-space:normal;overflow-wrap:anywhere;font-size:clamp(12px,2.5vw,15px);text-align:left;border-radius:10px}#resource-close{position:absolute;top:4px;right:5px;width:28px;height:28px;padding:0;border-radius:50%;font-size:19px;line-height:1}#resource-dock.article-open{justify-content:flex-start;padding-top:34px}#article-view{border:0;border-radius:10px;width:100%;flex:1;min-height:0;background:#0c192b}#article-view[hidden]{display:none}#stage.tv-active #resource-dock{display:none}#stage.tv-active:not(.tv-expanded) #tv-player{top:0;bottom:0;right:8px;justify-content:center;width:54%;max-width:540px}#stage.tv-active:not(.tv-expanded) #tv-player .tvbar{max-width:100%}
.keyboard-open #resource-dock{display:none}.keyboard-open #stage.resource-active:not(.tv-expanded) #actor{width:100%}
@media(prefers-reduced-motion:reduce){#stage #actor{transition:none}}
@media(max-width:420px){#resource-dock{padding:8px;right:6px;width:54%;border-radius:11px}#resource-links a{padding:7px 8px}#stage.tv-active:not(.tv-expanded) .tvbar a{font-size:9px}}
#pet-dock{position:absolute;top:9px;left:8px;z-index:5;width:30px;height:30px;border-radius:50%;padding:0;font-size:16px;background:#10283cbd}#pet-dock[hidden],#stage.tv-expanded #pet-dock,.keyboard-open #pet-dock{display:none}
#stage #actor{transition:left .35s ease,width .35s ease,height .35s ease}
#stage.pet-right.resource-active:not(.tv-expanded) #actor,#stage.pet-right.tv-active:not(.tv-expanded) #actor{left:57%}#stage.pet-right.resource-active:not(.tv-expanded) #status{left:78.5%}#stage.pet-right #resource-dock,#stage.pet-right.tv-active:not(.tv-expanded) #tv-player{right:auto;left:8px}#stage.pet-right #pet-dock{left:auto;right:8px}.keyboard-open #stage.pet-right #actor{left:0}

/* Full-screen reader and physical TV camera presentation. */
#article-reader{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:env(safe-area-inset-top) 0 env(safe-area-inset-bottom);border:0;background:#0c192b;color:#eff6ff;z-index:20;overflow:hidden}
#article-reader[open]{display:flex;flex-direction:column}#article-reader::backdrop{background:#09101e}#reader-bar{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid #294861;gap:10px;flex:none}#reader-bar strong{font-size:17px}#reader-close{flex:none}#article-reader #article-view{flex:1;width:100%;min-height:0;border:0;border-radius:0;background:#0c192b}
#stage.tv-expanded #actor{left:0;width:100%;height:100%}#stage.tv-expanded #tv-player{inset:0;width:100%;max-width:none;overflow:hidden;display:block;background:transparent;pointer-events:none}
#stage.tv-expanded #tv-player[hidden]{display:none}#stage.tv-expanded #tv-mount{position:absolute;top:10%;left:5%;width:90%;min-width:200px;min-height:200px;max-width:none;border-radius:10px;box-shadow:0 0 10px #1d8fb744;pointer-events:auto}
#stage.tv-expanded .tvbar{position:absolute;left:50%;bottom:6px;transform:translateX(-50%);width:max-content;max-width:94%;pointer-events:auto;gap:6px;padding:5px}
#stage.tv-expanded #tv-note{display:none}#tv-expand[hidden]{display:none}
#idle-suggestion{position:absolute;bottom:36px;left:50%;transform:translateX(-50%);z-index:3;max-width:85%;padding:8px 14px;border-radius:20px;background:#142b40eb;border:1px solid #3e7998;color:#d3f5ff;font-size:13px;text-align:center}
#idle-suggestion[hidden],.keyboard-open #idle-suggestion,#stage.tv-active #idle-suggestion,#stage.resource-active #idle-suggestion{display:none}

/* The live 3D television and native YouTube player share the projected display.
   A narrow noninteractive rim conceals only the seam; native controls stay inset. */
#stage.tv-expanded #tv-mount{--tv-rim:4px;isolation:isolate;overflow:hidden;border-radius:clamp(9px,2vw,22px);background:#071a2a;box-shadow:none;min-width:206px;min-height:206px}
#stage.tv-expanded #tv-mount iframe{position:absolute;inset:var(--tv-rim);width:calc(100% - 2 * var(--tv-rim));height:calc(100% - 2 * var(--tv-rim));min-width:200px;min-height:200px;border:0;border-radius:inherit;z-index:1;background:#061421}
#stage.tv-expanded #tv-mount::after{content:"";position:absolute;inset:0;z-index:2;border-radius:inherit;border:var(--tv-rim) solid #103c60;box-shadow:inset 0 0 0 1px #72c0dc,0 0 0 1px #08283f;pointer-events:none}
#stage.tv-expanded #tv-mount.screen-tracked::before{content:"";position:absolute;inset:0;border-radius:inherit;z-index:0;background:linear-gradient(130deg,#245c7b,#062438 44%,#2b719c);pointer-events:none}

/* Expanding content window: never take over the whole viewport. */
#resource-dock:not(.article-open){top:50%;bottom:auto;transform:translateY(-50%);height:auto;min-height:0;padding:32px 12px 12px;max-height:90%;width:min(48%,340px)}
#resource-dock[hidden],#article-reader[hidden]{display:none!important}
#article-reader{position:absolute;top:50%;left:auto;right:12px;bottom:auto;transform:translateY(-50%);margin:0;padding:0;z-index:4;width:min(65%,650px);height:min(var(--reader-content-height,620px),calc(100% - 24px));max-width:none;max-height:none;border:1px solid #40728e;border-radius:18px;box-shadow:0 10px 35px #0007;display:flex;flex-direction:column;overflow:hidden;animation:reader-expand .25s ease-out}
#reader-bar{padding:9px 12px}#reader-bar strong{font-size:15px}#reader-close{padding:6px 12px}#article-reader #article-view{flex:1;height:100%;min-height:0}
#stage.article-active #actor{width:33%;left:0;height:100%;top:0}#stage.article-active #status{left:16%;max-width:29%;bottom:10px}#stage.article-active #resource-dock,#stage.article-active #pet-dock{display:none}#stage.article-active #idle-suggestion{display:none}
#stage.pet-right.article-active #actor{left:67%}#stage.pet-right.article-active #article-reader{left:12px;right:auto}#stage.pet-right.article-active #status{left:83%}
@keyframes reader-expand{from{opacity:.4;transform:translateY(-50%) scale(.9)}to{opacity:1;transform:translateY(-50%) scale(1)}}
@media(max-width:590px){
#stage.article-active #actor,#stage.pet-right.article-active #actor{width:100%;height:30%;left:0;top:0}
#stage.article-active #status{display:none}
#stage.article-active #article-reader,#stage.pet-right.article-active #article-reader{inset:auto 8px 8px;transform:none;width:auto;height:min(var(--reader-content-height,620px),calc(70% - 12px));border-radius:14px;animation:reader-mobile-expand .25s ease-out}
#resource-dock:not(.article-open){width:50%;padding:29px 8px 9px}
}
@keyframes reader-mobile-expand{from{opacity:.4;transform:translateY(12px)}to{opacity:1;transform:none}}
@media(prefers-reduced-motion:reduce){#article-reader{animation:none!important}}
#stage.tv-expanded #tv-mount{border-radius:var(--tv-corner,clamp(20px,3.3vw,40px))}
#stage.tv-expanded #tv-mount iframe{border-radius:max(12px,calc(var(--tv-corner,25px) - var(--tv-rim)))}

/* Generated text remains readable if temporary voice is unavailable. */
#answer.visible-answer.generated-text{position:static!important;width:auto;height:auto;clip:auto;white-space:normal;display:block;-webkit-line-clamp:unset;max-height:min(24vh,12em);overflow:auto;font-size:14px;line-height:1.4;padding:8px;margin:5px 0 0;color:#bdd9ed}

/* Transparent HUD-style panels; dark text backing only where needed for contrast. */
#resource-dock{background:linear-gradient(155deg,#17334c48,#0b1b2d66);border-color:#70adca74;box-shadow:0 7px 22px #03131e44;backdrop-filter:none}
#resource-links a{background:#112a40a0;border-color:#70adca66;color:#e4faff;text-shadow:0 1px 2px #071b2b}
#article-reader{background:linear-gradient(145deg,#0c223a9e,#0a192bbd);border-color:#70adca74;box-shadow:0 8px 28px #0005;backdrop-filter:none}
#reader-bar{background:#10283e70;border-color:#70adca55}#article-reader #article-view{background:transparent}
#stage.article-active #actor{z-index:0}#stage #actor{object-fit:contain}
.related-title{color:#d5f2ff;font-size:13px;font-weight:650;padding:1px 4px}.related-topic{display:block;text-align:left;border:1px solid #70adca66;border-radius:10px;background:#112a40a0;color:#e4faff;text-shadow:0 1px 2px #071b2b;font-size:clamp(12px,2.4vw,15px);padding:8px 10px;width:100%;white-space:normal}.related-topic:focus-visible{outline:2px solid #7bd4fc}

/* Immediate original Hernio artwork while the unchanged 3D model downloads. */
#actor-poster{position:absolute;left:0;top:0;width:100%;height:100%;object-fit:contain;object-position:center;padding:8px 16px 25px;pointer-events:none;transition:opacity .18s ease,left .35s ease,width .35s ease,height .35s ease}
#stage.actor-ready #actor-poster{opacity:0;visibility:hidden}
#stage.resource-active:not(.tv-expanded) #actor-poster,#stage.tv-active:not(.tv-expanded) #actor-poster{width:43%}
#stage.pet-right.resource-active:not(.tv-expanded) #actor-poster,#stage.pet-right.tv-active:not(.tv-expanded) #actor-poster{left:57%}
#stage.article-active #actor-poster{width:33%}#stage.pet-right.article-active #actor-poster{left:67%}
@media(max-width:590px){#stage.article-active #actor-poster,#stage.pet-right.article-active #actor-poster{left:0;width:100%;height:30%;padding:4px}}
#stage.tv-expanded #actor-poster{left:0;width:100%;height:100%}
@media(prefers-reduced-motion:reduce){#actor-poster{transition:none}}

/* Chat-first layout: Hernio remains anchored above a compact conversation. */
header{height:47px;padding:10px 5vw}header strong{font-size:19px}
main{max-width:900px;background:#0a1422}
#stage{flex:0 0 clamp(180px,37dvh,355px);min-height:0;border-bottom:1px solid #203c52;transition:flex-basis .28s ease;overflow:hidden;background:radial-gradient(ellipse at 50% 55%,#244c6d,#0b1727 76%)}
#stage #actor{width:100%;height:100%;left:0;top:0}
#status{bottom:8px;font-size:11px;color:#b7d7e7}
#conversation{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:15px clamp(15px,4vw,34px) 20px;display:flex;flex-direction:column;gap:12px;background:linear-gradient(#0a1422,#0b1829)}
#current-turn,.history-turn{display:flex;flex-direction:column;gap:10px}
#message-history{display:flex;flex-direction:column;gap:16px}
#message-history:empty{display:none}
#last-question,.question-bubble{align-self:flex-end;max-width:84%;border-radius:18px 18px 4px 18px;margin:0;padding:12px 15px;background:#235c81;color:#f4f9ff;font-size:15px;line-height:1.4;overflow-wrap:anywhere;display:block}
#last-question[hidden]{display:none}
#assistant-message{align-self:flex-start;display:flex;flex-direction:column;width:min(90%,650px);gap:8px}
.answer-bubble,#answer.answer-bubble,#answer.visible-answer,#answer.visible-answer.generated-text{position:static!important;clip:auto!important;width:auto;height:auto;white-space:pre-wrap;display:block;max-height:none;overflow:visible;margin:0;padding:12px 15px;color:#e5f0fa;background:#14263a;border:1px solid #28465e;border-radius:4px 18px 18px 18px;font-size:15px;line-height:1.5;overflow-wrap:anywhere;align-self:flex-start}
.history-turn .answer-bubble{max-width:min(90%,650px)}
#conversation #resource-dock{position:static;transform:none;width:auto;max-width:100%;height:auto;min-height:0;max-height:none;inset:auto;padding:0;display:block;background:transparent;border:0;box-shadow:none;border-radius:0;overflow:visible}
#conversation #resource-dock[hidden]{display:none!important}
#conversation #resource-links{display:flex;flex-direction:row;flex-wrap:wrap;gap:6px}
#conversation #resource-links a,#conversation .related-topic{display:block;width:auto;max-width:100%;white-space:normal;border-radius:14px;padding:8px 11px;background:#19344b;color:#c5ebff;font-size:13px}
#conversation .related-title{width:100%;padding:3px 0}
#conversation #resource-close{display:none}
.chat{flex:none;min-height:0;max-height:none;padding:12px clamp(15px,4vw,34px) calc(12px + env(safe-area-inset-bottom));background:#0d1b2d;border-top:1px solid #294861}
#ask-form{gap:9px}#question{background:#13283d;border-radius:24px;padding:12px 16px}#send{height:44px;width:44px}#audio-fallback{margin:6px 0 0}
#stage.tv-active,#stage.article-active{flex:1 1 62%;min-height:240px}
main:has(#stage.tv-active) #conversation,main:has(#stage.article-active) #conversation{flex:0 1 120px;max-height:120px;padding-top:8px;padding-bottom:8px}
#stage.article-active #actor{width:33%}
#stage.pet-right.article-active #actor{left:67%}
#stage.tv-expanded #actor{width:100%;left:0}
.keyboard-open #stage{flex-basis:clamp(85px,23dvh,155px)!important;min-height:75px!important}.keyboard-open #conversation{min-height:52px;max-height:none;flex:1 1 auto!important}.keyboard-open header{height:32px;padding:4px 13px}.keyboard-open .chat{padding:7px 10px}
@media(max-width:590px){#stage{flex-basis:clamp(160px,35dvh,285px)}#stage.article-active #actor,#stage.pet-right.article-active #actor{width:100%;height:30%;left:0}#conversation{padding:12px 13px 14px}.chat{padding:9px 12px calc(9px + env(safe-area-inset-bottom))}.answer-bubble,#answer.answer-bubble{font-size:14px}#assistant-message{width:94%}}
@media(prefers-reduced-motion:reduce){#stage{transition:none}}

/* One continuous scene: audio, chat and content flow through the same surface. */
main{background:radial-gradient(ellipse at 50% 15%,#244c6d 0%,#12253b 35%,#0b1829 72%)}
#stage{background:transparent;border-bottom:0;transition:flex-basis .42s cubic-bezier(.2,.7,.2,1),min-height .42s cubic-bezier(.2,.7,.2,1)}
#stage::after{content:"";position:absolute;inset:auto 0 0;height:30px;background:linear-gradient(transparent,#10223955);pointer-events:none}
#conversation{background:transparent;transition:flex-basis .42s cubic-bezier(.2,.7,.2,1),max-height .42s cubic-bezier(.2,.7,.2,1);max-height:100dvh;padding-top:5px}
#assistant-message{animation:conversation-in .25s ease both}
#answer.answer-bubble,#answer.visible-answer,#answer.visible-answer.generated-text{background:#14263acc;border:0;box-shadow:0 3px 12px #06142330}
.chat{background:linear-gradient(transparent,#0d1b2d 25%);border-top:0}
#article-reader{border:0;box-shadow:0 6px 28px #04132355}
@keyframes conversation-in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.keyboard-open #stage{transition:none!important}
@media(prefers-reduced-motion:reduce){#stage,#conversation{transition:none!important}#assistant-message{animation:none}}
/* The character's space continues into the conversation; no visible horizontal seam. */
header{border-bottom:0;background:#0a1422}
#stage:not(.tv-active):not(.article-active){overflow:visible;z-index:2}
#stage:not(.tv-active):not(.article-active) #actor{height:calc(100% + 12px)}
#stage:after{display:none}
#stage #actor{transition:width .42s cubic-bezier(.2,.7,.2,1),height .42s cubic-bezier(.2,.7,.2,1),left .42s cubic-bezier(.2,.7,.2,1),top .42s cubic-bezier(.2,.7,.2,1)}
#conversation{position:relative;z-index:1;padding-top:14px}
#status{background:#0e203144;border-radius:12px;padding:2px 6px}
.keyboard-open #stage:not(.tv-active):not(.article-active) #actor{height:100%}
@media(prefers-reduced-motion:reduce){#stage #actor{transition:none}}

/* Swipe the 3D companion itself to roam over the conversation. Compact footprint,
   bounded to the usable page, never over the input. Media returns to home first. */
#stage.actor-roaming:not(.tv-active):not(.article-active) #actor{z-index:5;left:var(--roam-x,0px);top:var(--roam-y,0px);width:clamp(100px,35vw,200px);height:clamp(125px,24dvh,205px);filter:drop-shadow(0 4px 8px #0005)}
#stage.actor-dragging #actor{transition:none!important;cursor:grabbing}
#actor-home{position:absolute;z-index:6;top:8px;right:12px;font-size:20px;width:35px;height:35px;padding:0;border-radius:50%;background:#112d45b8}
#actor-home[hidden]{display:none}
#stage.actor-roaming #status{opacity:.65}
.keyboard-open #stage.actor-roaming:not(.tv-active):not(.article-active) #actor{height:clamp(80px,22dvh,122px);width:clamp(84px,30vw,126px)}
/* Mobile conversation starts in a compact keyboard-ready geometry and stays there.
   The keyboard only reduces the scrollable conversation, not the character/header. */
@media(max-width:590px){
 body{height:var(--visual-height,100dvh);max-height:var(--visual-height,100dvh)}
 header,.keyboard-open header{height:40px;padding:5px 13px}
 main{width:100%;margin:0 auto;flex:1 1 0;min-height:0;height:calc(var(--visual-height,100dvh) - 40px);max-height:calc(var(--visual-height,100dvh) - 40px)}
 #stage:not(.article-active):not(.tv-active),.keyboard-open #stage:not(.article-active):not(.tv-active){flex:0 0 130px!important;min-height:0!important;transition:none!important}
 #stage:not(.tv-active):not(.article-active) #actor,.keyboard-open #stage:not(.tv-active):not(.article-active) #actor{height:100%;transition:none}
 #conversation,.keyboard-open #conversation{flex:1 1 0!important;min-height:0;max-height:none;transition:none!important;padding:10px 13px}
 .chat,.keyboard-open .chat{flex:0 0 auto;min-height:0;max-height:none;padding:7px 12px calc(7px + env(safe-area-inset-bottom));overflow:visible}
 #ask-form{min-height:44px}
 #question,.keyboard-open #question{font-size:16px;padding:10px 14px}
 #status{font-size:10px;bottom:1px;white-space:nowrap;max-width:90%;overflow:hidden;text-overflow:ellipsis;min-height:0;background:none}
 #stage.actor-roaming:not(.tv-active):not(.article-active) #actor{height:clamp(95px,22dvh,155px);width:clamp(84px,30vw,132px)}
 #stage.article-active,#stage.tv-active{flex:1 1 62%;min-height:190px;transition:none}
 main:has(#stage.tv-active) #conversation,main:has(#stage.article-active) #conversation{flex:0 1 100px!important;max-height:100px}
}
#video-options-inline{display:flex;flex-wrap:wrap;gap:6px}
#video-options-inline[hidden],#tv-next[hidden]{display:none}
#video-options-inline button{max-width:100%;text-align:left;border-radius:14px;background:#19344b;color:#c5ebff;white-space:normal;font-size:13px;padding:8px 11px}
#tv-next{background:#235c81;color:#f4f9ff}

/* Live digital companion: a transparent overlay on the scrolling conversation,
   not a separate upper viewport. Only media/reading deliberately expands. */
body{--host-height:clamp(210px,31dvh,310px)}
header{position:absolute;inset:0 0 auto;z-index:7;pointer-events:none;background:transparent}
header strong{font-size:16px}
main{position:relative;height:100%;max-height:100%;flex:1 1 0}
#stage:not(.tv-active):not(.article-active){position:absolute!important;inset:0 0 auto!important;height:var(--host-height)!important;flex:none!important;min-height:0!important;pointer-events:none;overflow:visible;z-index:5;background:transparent}
#stage:not(.tv-active):not(.article-active)::before{content:'';position:absolute;inset:0;background:linear-gradient(#101e31e8 0%,#10223682 24%,transparent 95%);pointer-events:none}
#stage:not(.tv-active):not(.article-active) #actor{top:12px;left:22%;width:56%;height:calc(100% - 12px);pointer-events:auto;filter:drop-shadow(0 6px 7px #010a1566);transition:none}
#stage:not(.tv-active):not(.article-active) #status{bottom:0;pointer-events:none;white-space:nowrap;max-width:90%;overflow:hidden;text-overflow:ellipsis;background:#0f213575;opacity:.75;font-size:10px}
#stage #actor-home,#stage #idle-suggestion,#stage #inspect-back{pointer-events:auto}
#stage:not(.tv-active):not(.article-active) #idle-suggestion{bottom:8px;right:10px;left:auto;max-width:38%;z-index:6;font-size:11px;padding:7px 9px}
#conversation{padding-top:var(--host-height);flex:1 1 0;scroll-padding:var(--host-height) 0 0;min-height:0}
main:has(#stage.tv-active),main:has(#stage.article-active){padding-top:40px}
main:has(#stage.tv-active) #conversation,main:has(#stage.article-active) #conversation{padding-top:8px;scroll-padding:0}
#stage.actor-roaming:not(.tv-active):not(.article-active)::before{opacity:.42}
#stage.actor-roaming:not(.tv-active):not(.article-active) #actor{left:var(--roam-x,0px);top:var(--roam-y,0px);width:clamp(138px,39vw,235px);height:clamp(170px,27dvh,240px);pointer-events:auto}
#stage.actor-roaming #status{opacity:0}
#stage.actor-roaming #actor-home{pointer-events:auto;top:41px}
#portal-effect{position:absolute;z-index:7;pointer-events:none;width:clamp(75px,25vw,150px);aspect-ratio:1;transform:translate(-50%,-50%);border-radius:50%;border:2px solid #9cf3ff;box-shadow:0 0 18px #66d9ff,0 0 35px #1f83e6,inset 0 0 14px #58d9ff;background:radial-gradient(ellipse at center,#06132d 10%,#1355a966 48%,#58c8ff90 72%,transparent 76%);opacity:0}
#portal-effect[hidden]{display:none!important}#stage.portal-moving #actor{pointer-events:none}
@media(max-width:590px){
 body{--host-height:clamp(165px,calc(var(--visual-height,100dvh) - 170px),225px)}
 header,.keyboard-open header{height:36px;padding:6px 12px}
 main{height:var(--visual-height,100dvh);max-height:var(--visual-height,100dvh)}
 #stage:not(.article-active):not(.tv-active),.keyboard-open #stage:not(.article-active):not(.tv-active){height:var(--host-height)!important;flex:none!important}
 #stage:not(.article-active):not(.tv-active) #actor,.keyboard-open #stage:not(.article-active):not(.tv-active) #actor{height:calc(100% - 12px);left:21%;width:58%;top:12px}
 #conversation,.keyboard-open #conversation{padding-top:var(--host-height);scroll-padding:var(--host-height) 0 0}
 #stage.actor-roaming:not(.tv-active):not(.article-active) #actor,.keyboard-open #stage.actor-roaming:not(.tv-active):not(.article-active) #actor{left:var(--roam-x,0px);top:var(--roam-y,0px);width:clamp(120px,38vw,170px);height:clamp(145px,26dvh,195px)}
 main:has(#stage.tv-active),main:has(#stage.article-active){padding-top:37px}
}
@media(prefers-reduced-motion:reduce){#portal-effect{display:none!important}}

/* No stage seam or visual status caption beneath the companion. */
header,#stage,#conversation,.chat{border:0!important}
#stage:not(.tv-active):not(.article-active)::before,#stage:not(.tv-active):not(.article-active)::after{display:none!important;content:none!important}
#stage{background:transparent!important}
#stage #status{position:absolute!important;width:1px!important;height:1px!important;min-height:0!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;clip-path:inset(50%)!important;white-space:nowrap!important;border:0!important;background:none!important}
#stage.actor-roaming #status{opacity:1}

#stage.tv-expanded #tv-mount video{position:absolute;inset:var(--tv-rim);width:calc(100% - 2 * var(--tv-rim));height:calc(100% - 2 * var(--tv-rim));object-fit:contain;border-radius:max(12px,calc(var(--tv-corner,25px) - var(--tv-rim)));background:#061421;z-index:1}#youtube-link[hidden]{display:none!important}

/* The idle suggestion is a prompt, not a forced animation. */
body:not(.lab-preview) #stage:not(.tv-active):not(.article-active) #idle-suggestion:not([hidden]){display:block;min-height:40px;max-width:min(88%,340px);font-size:13px;white-space:normal;left:50%;right:auto;transform:translateX(-50%);bottom:7px;background:#153b56f2;border:1px solid #6acfe9;color:#e9f9ff;z-index:8}
body:not(.lab-preview).keyboard-open #stage:not(.tv-active):not(.article-active) #idle-suggestion:not([hidden]){bottom:3px;min-height:32px;font-size:12px;padding:6px 10px}

/* Keep the complete rectangular YouTube viewport INSIDE the rounded physical TV.
   A rectangular inset greater than (1-1/sqrt(2)) of the corner radius fits all
   four image/control corners within the rounded rim. Do not impose 200px
   minimums that force the iframe past the visible bounds on short iPhones. */
#stage.tv-expanded #tv-mount {
  --tv-content-inset:max(8px,calc(var(--tv-rim,4px) + var(--tv-corner,25px) * .30 + 2px));
  min-width:0;min-height:0;
  max-width:calc(100% - 8px);max-height:calc(100% - 48px);
}
#stage.tv-expanded #tv-mount iframe,
#stage.tv-expanded #tv-mount video {
  position:absolute;
  inset:var(--tv-content-inset);
  width:calc(100% - 2 * var(--tv-content-inset));
  height:calc(100% - 2 * var(--tv-content-inset));
  min-width:0;min-height:0;max-width:none;max-height:none;
  border:0;border-radius:0;object-fit:contain;
  background:#061421;
}
/* Even the compact preview is contained: clip the bezel, never the media. */
#stage.tv-active:not(.tv-expanded) #tv-mount iframe,
#stage.tv-active:not(.tv-expanded) #tv-mount video {
  position:absolute;inset:6px;
  width:calc(100% - 12px);height:calc(100% - 12px);
  min-width:0;min-height:0;max-width:none;max-height:none;
  border-radius:0;object-fit:contain;
}

/* YouTube's preview artwork uses cover internally; an inset alone is insufficient
   when the physical abdominal TV is not 16:9. Give the actual iframe a 16:9
   viewport, letterbox it inside the bezel, and leave native videos untouched. */
#stage.tv-active #tv-mount {container-type:size}
#stage.tv-active:not(.tv-expanded) #tv-mount {--tv-content-inset:6px}
#stage.tv-active #tv-mount > iframe {
  position:absolute;inset:50% auto auto 50%;
  transform:translate(-50%,-50%);
  width:min(calc(100cqw - 2 * var(--tv-content-inset)),calc((100cqh - 2 * var(--tv-content-inset)) * 1.7777777778));
  height:min(calc(100cqh - 2 * var(--tv-content-inset)),calc((100cqw - 2 * var(--tv-content-inset)) * .5625));
  aspect-ratio:16/9;
  min-width:0;min-height:0;max-width:none;max-height:none;
  border:0;border-radius:0;background:#061421;
}
#stage.tv-active:not(.tv-expanded) #tv-mount > iframe {
  inset:50% auto auto 50%;transform:translate(-50%,-50%);
  width:min(calc(100cqw - 12px),calc((100cqh - 12px) * 1.7777777778));
  height:min(calc(100cqh - 12px),calc((100cqw - 12px) * .5625));
}
/* No-model fallback uses a matching widescreen bezel, too. */
#stage.tv-expanded #tv-mount:not(.screen-tracked):has(> iframe) {
  height:auto;aspect-ratio:1.7;
}

/* The DOM player is physically behind the live Studio actor. The WebGL
   depth-only screen aperture preserves real hand and bezel occlusion. */
#stage.tv-expanded.tv-physical-aperture #tv-player {z-index:auto;overflow:visible}
#stage.tv-expanded.tv-physical-aperture #tv-mount {z-index:1;background:#061421;box-shadow:none}
#stage.tv-expanded.tv-physical-aperture #tv-mount::after,
#stage.tv-expanded.tv-physical-aperture #tv-mount::before {display:none}
#stage.tv-expanded.tv-physical-aperture #actor {z-index:3;pointer-events:none;filter:none}
#stage.tv-expanded.tv-physical-aperture .tvbar {z-index:5;pointer-events:auto}
/* Fit every native YouTube control inside the real rounded screen polygon,
   rather than allowing any corner to protrude through transparent WebGL. */
#stage.tv-expanded.tv-physical-aperture #tv-mount > iframe {
  width:var(--tv-fit-w,min(calc(100cqw - 2 * var(--tv-content-inset)),calc((100cqh - 2 * var(--tv-content-inset)) * 1.7777777778)));
  height:var(--tv-fit-h,min(calc(100cqh - 2 * var(--tv-content-inset)),calc((100cqw - 2 * var(--tv-content-inset)) * .5625)));
}

/* The two interactive anatomy players use the same physical OLED aperture as
   video. The rectangular controls are entirely inside the rounded silhouette.
   No separate floating player or relative-positioned navigation bar. */
#stage.tv-expanded #tv-mount > .tv-inline-animation {
  position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);
  width:var(--tv-fit-w,min(calc(100cqw - 2 * var(--tv-content-inset)),calc((100cqh - 2 * var(--tv-content-inset)) * 1.7777777778)));
  height:var(--tv-fit-h,min(calc(100cqh - 2 * var(--tv-content-inset)),calc((100cqw - 2 * var(--tv-content-inset)) * .5625)));
  max-width:100%;max-height:100%;min-width:0;min-height:0;
  overflow:hidden;z-index:1;background:#081d2c;
}
#stage.tv-expanded #tv-mount:not(.screen-tracked):has(> .tv-inline-animation){height:auto;aspect-ratio:16/9}
#stage.tv-expanded .tvbar{position:absolute;left:50%;right:auto;top:auto;bottom:6px;transform:translateX(-50%);width:max-content;max-width:94%;display:flex;justify-content:center;align-items:center;z-index:5}
#stage.tv-expanded.tv-interactive #tv-expand{display:none!important}
#stage.tv-expanded.tv-interactive #tv-note,#stage.tv-expanded.tv-error #tv-note{display:block;font-size:11px;line-height:1.2;max-width:100%;overflow-wrap:anywhere}
#stage.tv-expanded .tvbar button{min-width:64px;text-align:center}
.tv-inline-fallback{display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;gap:4px;padding:6px;color:white;font-size:11px}
.tv-inline-fallback button{max-width:100%;font-size:11px;padding:4px 6px}

#actor-startup{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;pointer-events:none;z-index:1;opacity:1;transition:opacity .16s ease}#stage.actor-ready #actor-startup{opacity:0;visibility:hidden}#stage:not(.actor-ready) #actor{opacity:1}@media(prefers-reduced-motion:reduce){#actor-startup{transition:none}}
