.copilot-dock.companion-hidden{display:none!important}
.copilot-dock .social-close{display:block!important;flex-shrink:0;min-width:32px;min-height:32px}
.copilot-dock .social-heading{grid-template-columns:44px minmax(0,1fr) auto 32px}
.copilot-dock .social-heading #companionAvatar{grid-column:1;grid-row:1/3}
.copilot-dock .social-heading>div:nth-child(2){grid-column:2;grid-row:1;min-width:0}
.copilot-dock #socialName{flex:none;white-space:nowrap}
.copilot-dock .social-heading .social-stats{grid-column:2;grid-row:2;flex-wrap:wrap;gap:4px 10px}
.copilot-dock .social-heading .chat-expand{grid-column:3;grid-row:1/3}
.copilot-dock .social-heading .social-close{grid-column:4;grid-row:1/3;width:32px;height:32px;border:1px solid var(--line);background:var(--surface2);font-size:22px}
.chat-question-actions{display:inline-flex;align-items:center;gap:6px;max-width:100%;min-width:0}
.chat-question-actions [data-chat-suggestion]{min-width:0;flex:0 1 auto}
.chat-media-tools{display:flex;align-items:center;flex-wrap:wrap;gap:10px;font-size:12px;padding:6px 0}
.chat-media-tools button{font:inherit;padding:6px 10px;background:var(--surface2);color:var(--ink);border:1px solid var(--line);border-radius:5px;cursor:pointer}
.copilot-dock #chatPickImage{width:auto;height:auto;min-height:32px;flex:none;white-space:nowrap}
.chat-media-tools small{color:var(--muted);flex-basis:100%}
.chat-media-tools:not(:has(small:not(:empty))){display:none}
.chat-image-previews{display:flex;gap:8px;flex-wrap:wrap}
.chat-image-previews:empty{display:none}
.chat-image-previews>span{position:relative;display:block}
.chat-image-previews img{width:70px;height:70px;object-fit:contain;border:1px solid var(--line);border-radius:4px}
.chat-image-previews button{position:absolute;top:0;right:0;min-width:24px;min-height:24px;cursor:pointer}
.social-message .chat-sent-image{max-width:100%;max-height:180px;object-fit:contain;display:block;margin-top:8px;border-radius:5px}
.journey-body .j-focus-card .j-button.primary.submission-entry{display:block;width:100%;margin:16px 0;background:#f2cf63;color:#344b50;border-color:#b18b32}
@media(max-width:700px){.copilot-dock:not(.mobile-chat-open) .chat-media-tools,.copilot-dock:not(.mobile-chat-open) .chat-image-previews{display:none}}
@media(max-width:700px){.copilot-dock.mobile-chat-open .social-heading{grid-template-columns:36px minmax(0,1fr) 32px}.copilot-dock.mobile-chat-open .social-heading .social-close{grid-column:3}}

/* 展开聊天时给面板独立空间，避免背景控件露出半截。 */
@media(max-width:700px){
 body:has(.copilot-dock.mobile-chat-open:not(.companion-hidden):not(.chat-collapsed)) :is(.topbar,.player-card,.shortcuts,.shop-journal,.quest-peek,.main-actions,.npc-anchor){visibility:hidden;pointer-events:none;}
 .copilot-dock.mobile-chat-open{top:max(12px,env(safe-area-inset-top));bottom:calc(max(12px,env(safe-area-inset-bottom)) + var(--keyboard-offset,0px));left:12px;right:12px;width:auto;height:auto;max-height:none;z-index:36;padding:12px;}
 .copilot-dock.mobile-chat-open .social-heading #companionAvatar{width:34px;height:40px;object-fit:cover;}
 .copilot-dock.mobile-chat-open .social-message .message-content{padding:11px 12px;font-size:13px;line-height:1.8;}
 .copilot-dock.mobile-chat-open .social-messages{gap:14px;}
 .copilot-dock.mobile-chat-open .social-heading .social-close{width:36px;height:36px;}
}
@media(min-width:701px){
 .copilot-dock{top:104px;bottom:20px;width:clamp(360px,34vw,480px);height:auto;max-height:none;}
 .copilot-dock.chat-expanded{top:104px;bottom:20px;width:min(720px,calc(100vw - 48px));}
 body:has(.copilot-dock.chat-expanded:not(.companion-hidden):not(.chat-collapsed)) .quest-peek{visibility:hidden;pointer-events:none;}
 body:has(.copilot-dock.chat-expanded:not(.companion-hidden):not(.chat-collapsed)) :is(.player-card,.shortcuts,.shop-journal,.main-actions,.npc-anchor){visibility:hidden;pointer-events:none;}
}

@media(min-width:701px){
 .copilot-dock.chat-collapsed{display:none;}
 .copilot-dock.chat-collapsed :is(.social-heading,.social-messages,.copilot-status,.copilot-compose-toolbar,.copilot-companion-tools,.chat-media-tools,.chat-image-previews){display:none;}
 .copilot-dock.chat-collapsed .copilot-compose{display:contents;}
 .copilot-dock.chat-collapsed #copilotHistory{display:block;width:44px;height:48px;}
}

/* 桌面伙伴常驻右侧，边缘把手切换居中阅读。 */
@media(min-width:701px){
 .copilot-dock{right:24px;top:auto;bottom:24px;width:clamp(340px,29vw,420px);height:clamp(380px,60svh,600px);max-height:calc(100svh - 270px);overflow:visible;}
 .copilot-dock .social-heading{position:static;grid-template-columns:44px minmax(0,1fr);}
 .copilot-dock .social-heading .social-close{display:none!important;}
 .copilot-dock .social-heading .chat-expand{position:absolute;left:-25px;top:50%;transform:translateY(-50%);display:grid;place-items:center;width:24px;height:64px;min-width:24px;padding:0;border:1px solid #26334350;border-right:0;border-radius:7px 0 0 7px;background:#fff9e980;backdrop-filter:blur(6px);box-shadow:-2px 2px 0 #26334318;font-size:0;opacity:.65;z-index:3;transition:opacity .15s,background .15s;}
 .copilot-dock .chat-expand:before{content:'';position:absolute;left:50%;top:50%;width:7px;height:7px;border-left:2px solid var(--ink);border-bottom:2px solid var(--ink);transform:translate(-25%,-50%) rotate(45deg);}
 .copilot-dock .chat-expand:hover,.copilot-dock .chat-expand:focus-visible{opacity:1;background:#fff9e9dd;}
 .copilot-dock.chat-expanded{left:50%;right:auto;top:104px;bottom:24px;transform:translateX(-50%);width:min(800px,calc(100vw - 96px));height:auto;max-height:none;z-index:16;}
 .copilot-dock.chat-expanded .chat-expand:before{transform:translate(-75%,-50%) rotate(225deg);}
}

/* 桌面右栏对齐，场景在左右工具区之间取景。 */
@media(min-width:701px){
 .game-shell{--agent-width:clamp(340px,29vw,420px);}
 .quest-peek{right:24px;top:132px;width:var(--agent-width);min-height:94px;padding:16px 18px;}
 .copilot-dock:not(.chat-expanded){top:244px;bottom:auto;width:var(--agent-width);height:clamp(380px,60svh,600px);max-height:calc(100svh - 272px);padding:14px;}
 .copilot-dock:not(.chat-expanded) .social-heading{padding-bottom:10px;}
 .copilot-dock:not(.chat-expanded) .social-message .message-content{font-size:12px;line-height:1.8;padding:10px 12px;}
 .copilot-dock:not(.chat-expanded) .social-messages{min-height:0;padding:10px 0;gap:12px;}
 .copilot-dock:not(.chat-expanded) .copilot-compose{gap:6px;padding-top:8px;}
 .copilot-dock:not(.chat-expanded) .copilot-suggestions{flex-wrap:nowrap;overflow-x:auto;scrollbar-width:thin;padding-bottom:3px;}
 .copilot-dock:not(.chat-expanded) .copilot-suggestions>small{display:none;}
 .copilot-dock:not(.chat-expanded) .copilot-compose .copilot-suggestions button{flex-shrink:0;max-width:230px;white-space:nowrap;min-height:30px;padding:5px 9px;font-size:10px;}
 .copilot-dock:not(.chat-expanded) .copilot-compose-toolbar{gap:8px;}
 .scene-framing{left:calc((100vw - var(--agent-width) + 180px)/2);width:calc(100vw - var(--agent-width) - 280px);height:min(80svh,760px);top:45%;}
 .scene-framing-content{inset:0;}
 .player-card{top:132px;}
 .save-footer{right:24px;bottom:5px;font-size:9px;}
}
@media(min-width:701px) and (max-width:1100px){
 .scene-framing{left:calc((100vw - var(--agent-width) + 140px)/2);width:calc(100vw - var(--agent-width) - 240px);}
 .quest-peek{top:125px;min-height:94px;}
}

@media(min-width:701px){.main-actions.mail-actions{left:calc((100vw - var(--agent-width) + 180px)/2);right:auto;transform:translateX(-50%);}}
@media(min-width:701px) and (max-width:1100px){.main-actions.mail-actions{left:calc((100vw - var(--agent-width) + 140px)/2);}}

/* 背包占用右侧工作区时，暂时隐藏任务卡和伙伴面板。 */
body:has(.backpack:not([hidden])) :is(.quest-peek,.copilot-dock){visibility:hidden;pointer-events:none;}
