/* Conversation workspace. Existing creation tools keep their IDs and behavior. */
.stage-header{flex-wrap:wrap;gap:var(--space-100)}
.stage-header #stage-title{max-width:240px}
.stage-header #appearance-open{border:1px solid var(--border-input);border-radius:var(--radius-md);padding:var(--space-75) var(--space-100);color:var(--text);min-height:40px}
.stage-header #appearance-open:hover{border-color:var(--accent);color:var(--accent)}
.stage-header #dialogue-mode{background:var(--accent);color:var(--base);border-color:var(--accent)}
.stage-header #saved-avatars-open{margin-left:auto}
.stage-header:has(.stage-label:not([hidden])) #saved-avatars-open{margin-left:0}
.stage-header #immersive{display:none}
.dialogue-panel{display:none}
.creation-ready{display:flex;gap:var(--space-200);align-items:center;justify-content:space-between;padding:var(--space-200) var(--space-300);border-top:1px solid var(--line);font:var(--type-caption);color:var(--muted)}
.creation-ready:has(#ready-chat[hidden]){display:none}
.welcome-actions{display:flex;gap:var(--space-100);justify-content:center;margin-top:var(--space-200);pointer-events:auto}
.speech-indicator{position:absolute;left:var(--space-300);top:var(--space-300);display:none;align-items:center;gap:var(--space-100);font:var(--type-caption);color:var(--accent);z-index:3;max-width:calc(100% - 48px);pointer-events:none}
.speech-indicator button{pointer-events:auto}
.viewport.has-speech .speech-indicator{display:flex}
.sound-bars{display:flex;align-items:center;gap:2px;height:16px;flex:none}
.sound-bars i{display:block;width:2px;height:4px;background:var(--accent);transform:scaleY(calc(1 + var(--speech-level,0)*3));transform-origin:center}
.sound-bars i:nth-child(2),.sound-bars i:nth-child(3){height:8px}
.stage-caption{display:none;position:absolute;bottom:var(--space-400);left:var(--space-400);right:var(--space-400);background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-md);padding:var(--space-200);pointer-events:auto;z-index:3}
.stage-caption>span{font:var(--type-caption);color:var(--accent)}
.stage-caption p{margin-top:var(--space-100);max-height:96px;overflow:auto;font:var(--type-body);white-space:pre-wrap;overflow-wrap:anywhere}
.side-drawer{position:fixed;inset:0 0 0 auto;margin:0;max-height:100dvh;height:100dvh;width:420px;max-width:100%;border-radius:0;padding:var(--space-300);overflow-y:auto}
.side-drawer .dialog-heading{position:sticky;top:calc(-1 * var(--space-300));background:var(--surface);z-index:2;padding:var(--space-100) 0}
.side-drawer .field-label{margin-top:var(--space-300)}
.side-drawer .appearance-controls{margin-top:var(--space-300)}
.side-drawer .controls-heading{display:none}
.side-drawer .preview-controls{display:flex;flex-direction:column;padding:0;border:0;gap:var(--space-300)}
.side-drawer .viewport-tools{width:100%;justify-content:flex-start}
.side-drawer .small-control{width:100%;max-width:none;flex:none}
.side-drawer .small-control input{width:100%;height:32px}
.side-drawer .preview-hint{padding:var(--space-200) 0}
.side-drawer .expression-controls{padding:var(--space-200) 0;display:flex;flex-direction:column;align-items:flex-start}
.side-drawer .expression-controls>span{margin:0}
.side-drawer .expression-controls label{width:100%;white-space:nowrap}
.side-drawer .expression-controls input[type=range]{width:auto;flex:1;min-width:0}
.side-drawer .voice-details{border-top:1px solid var(--line);padding-top:var(--space-200);margin-top:var(--space-300)}
.side-drawer blockquote{margin:var(--space-200) 0;padding:var(--space-200);background:var(--raised);border-left:2px solid var(--accent);font:var(--type-body)}
.side-drawer input:not([type=checkbox]),.side-drawer audio{width:100%}
.side-drawer .check-label{display:flex;align-items:flex-start;gap:var(--space-100);margin:var(--space-200) 0;font:var(--type-caption)}
.side-drawer summary{cursor:pointer;font:var(--type-title)}
.side-drawer .primary-button{margin-top:var(--space-200)}
.history-row{flex-wrap:wrap;cursor:default}
.history-info{flex:1;min-width:160px}
.history-buttons{display:flex;gap:var(--space-100);margin-left:auto}
.history-buttons .secondary-button{font:var(--type-caption)}

body.conversation-mode{height:var(--app-height,100dvh);overflow:hidden;display:flex;flex-direction:column;padding:0}
.conversation-mode .topbar{flex:none;width:calc(100% - 48px);margin:var(--space-200) auto var(--space-100);padding:var(--space-100) var(--space-200)}
.conversation-mode main{flex:1;min-height:0;width:100%;max-width:1664px;margin:0 auto;padding:var(--space-100) var(--space-300) var(--space-200);display:flex;flex-direction:column}
.conversation-mode .setup,.conversation-mode .process,.conversation-mode .assets-section,.conversation-mode .page-heading,.conversation-mode footer,.conversation-mode .creation-ready{display:none}
.conversation-mode #notice{flex:none;max-height:64px;overflow:auto;margin:0 0 var(--space-100)}
.conversation-mode .studio-grid{flex:1;min-height:0;display:block}
.conversation-mode .stage{height:100%;display:grid;grid-template-columns:minmax(0,1fr) minmax(360px,38%);grid-template-rows:auto minmax(0,1fr);align-items:stretch;overflow:hidden}
.conversation-mode .stage-header{grid-column:1/-1;grid-row:1;padding:var(--space-100) var(--space-200);min-height:56px}
.conversation-mode .stage-header #immersive{display:block}
.conversation-mode .stage-header #dialogue-mode{display:none}
.conversation-mode .viewport{grid-column:1;grid-row:2;min-height:0;height:auto;min-width:0;flex:initial}
.conversation-mode .speech-indicator{display:flex}
.conversation-mode .viewport::after{content:'';position:absolute;inset:0;pointer-events:none;z-index:2;border:1px solid var(--accent);opacity:calc(var(--speech-level,0)*.5)}
.conversation-mode .stage-bottom{font:var(--type-caption);opacity:.65}
.conversation-mode .dialogue-panel{grid-column:2;grid-row:2;min-height:0;display:flex;flex-direction:column;gap:0;margin:0;padding:var(--space-200);border:0;border-left:1px solid var(--line);border-radius:0;overflow:hidden;background:var(--surface)}
.dialogue-panel .panel-heading{margin-bottom:var(--space-200);flex:none}
.dialogue-panel .panel-heading .eyebrow{font-size:12px;line-height:16px;margin-bottom:var(--space-50)}
.dialogue-panel h2{font:var(--type-title)}
.voice-toolbar{flex:none;gap:var(--space-100);margin:0;display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center}
.voice-toolbar #voice-open{display:inline-flex;align-items:center;justify-content:center;gap:var(--space-75);padding:var(--space-100) var(--space-200);min-height:40px;background:var(--accent);color:var(--base);border:1px solid var(--accent);border-radius:var(--radius-md);font:var(--type-body);font-weight:500;white-space:nowrap}
.voice-toolbar #voice-open:hover{background:var(--text);border-color:var(--text)}
.voice-toolbar #voice-open svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.voice-toolbar select{min-width:100px;width:100%;font:var(--type-caption);min-height:40px}
.voice-toolbar .check-label{grid-column:1/-1;font:var(--type-caption);display:flex;align-items:center;gap:var(--space-50);white-space:nowrap}
.identity-note{font:var(--type-caption);color:var(--muted);margin:var(--space-100) 0 var(--space-200)}
.chat-scroll{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--line) transparent;padding-right:var(--space-50)}
.dialogue-panel .chat-messages{max-height:none;overflow:visible;gap:var(--space-200);padding-bottom:var(--space-100)}
.chat-empty{padding:var(--space-700) var(--space-200);font:var(--type-title);text-align:center;color:var(--text)}
.chat-empty span{display:block;margin-top:var(--space-100);font:var(--type-body);color:var(--muted)}
.chat-message{padding:var(--space-200);background:transparent;border-color:transparent}
.chat-message.assistant{padding-left:var(--space-75)}
.chat-message.user{margin-left:var(--space-300);background:var(--raised);border-color:transparent}
.chat-message p{line-height:24px;margin:var(--space-100) 0}
.chat-message .message-status{display:block;font:var(--type-caption);color:var(--muted);overflow-wrap:anywhere}
.chat-message .message-status.failed{color:var(--error)}
.message-actions{display:flex;align-items:center;gap:var(--space-100);flex-wrap:wrap;margin-top:var(--space-100)}
.message-actions button,.message-more summary{font:var(--type-caption);min-height:32px}
.message-play{color:var(--accent)}
.message-more{margin-left:auto;position:relative;font:var(--type-caption)}
.message-more summary{cursor:pointer;list-style:none;display:flex;align-items:center;color:var(--muted)}
.message-more .message-regenerate{display:block;text-align:right;max-width:180px}
.saved-voice{display:block;font:var(--type-caption);color:var(--muted);margin-top:var(--space-50)}
.saved-voice:empty{display:none}
.message-player audio{height:40px;width:100%;margin:var(--space-100) 0 0}
.conversation-status{display:flex;flex-wrap:wrap;justify-content:space-between;gap:var(--space-50);flex:none;font:var(--type-caption);color:var(--muted);padding:var(--space-100) 0;min-height:32px}
#speech-queue{color:var(--accent)}
.dialogue-panel #dialogue-error{flex:none;max-height:80px;overflow:auto;font:var(--type-caption);margin:var(--space-50) 0}
#chat-form{flex:none;border:1px solid var(--border-input);border-radius:var(--radius-md);background:var(--base);padding:var(--space-100)}
#chat-form:focus-within{border-color:var(--accent)}
#chat-input{border:0;background:transparent;resize:none;min-height:48px;max-height:120px;padding:var(--space-50);box-shadow:none;font:var(--type-body)}
#chat-input:focus{outline:none}
.chat-actions{display:flex;align-items:center;gap:var(--space-100);flex-wrap:wrap;margin-top:var(--space-100)}
#chat-form .chat-actions{margin-top:var(--space-50)}
#chat-form .chat-actions button{font:var(--type-caption);min-height:36px;white-space:nowrap}
#chat-send{margin-left:auto;flex:none}
.runtime-details{flex:none;font:var(--type-caption);color:var(--muted);padding-top:var(--space-100);max-height:160px;overflow:auto}
.runtime-details summary{cursor:pointer;min-height:24px}
.runtime-details p{margin-top:var(--space-100)}
.runtime-details .dialogue-connection{align-items:flex-start;margin-top:var(--space-100);overflow-wrap:anywhere}

.conversation-mode.immersive-mode .stage{grid-template-columns:minmax(0,1fr);position:relative}
.conversation-mode.immersive-mode .viewport{grid-column:1;grid-row:2}
.conversation-mode.immersive-mode .dialogue-panel{position:absolute;grid-area:auto;bottom:var(--space-300);left:50%;transform:translateX(-50%);width:min(680px,calc(100% - 48px));padding:0;border:0;z-index:5;background:transparent;overflow:visible}
.immersive-mode .dialogue-panel>:not(#chat-form):not(.conversation-status){display:none}
.immersive-mode .stage-caption:not([hidden]){display:block;bottom:200px;left:50%;transform:translateX(-50%);width:min(680px,calc(100% - 48px));right:auto}
.immersive-mode .stage-bottom{display:none}
.immersive-mode .stage-overlay{bottom:auto;top:35%}
.immersive-mode .viewport:has(.stage-caption:not([hidden])) .stage-overlay{display:none}
.immersive-mode .conversation-status{padding:var(--space-100);background:var(--surface);border-radius:var(--radius-md)}
@media(max-width:900px){
 .conversation-mode .topbar{margin:var(--space-100);width:calc(100% - 16px);padding:var(--space-75)}
 .conversation-mode main{padding:0 var(--space-100) var(--space-100)}
 .conversation-mode .stage{grid-template-columns:1fr;grid-template-rows:auto minmax(160px,28%) minmax(0,1fr)}
 .conversation-mode .viewport{grid-row:2;grid-column:1;min-height:0;height:100%;width:100%}
 .conversation-mode .dialogue-panel{grid-row:3;grid-column:1;border-left:0;border-top:1px solid var(--line);padding:var(--space-100) var(--space-200)}
 .conversation-mode .stage-header{padding:var(--space-75) var(--space-100);gap:var(--space-75);min-height:48px}
 .conversation-mode .stage-header>div{flex:1}
 .conversation-mode #stage-title{max-width:130px;font:var(--type-caption)}
 .conversation-mode #saved-avatars-open{font-size:0;min-width:44px}
 .conversation-mode #saved-avatars-open::after{content:'换形象';font:var(--type-caption)}
 .conversation-mode #appearance-open,.conversation-mode #immersive{font:var(--type-caption);min-height:44px}
 .conversation-mode .stage-bottom,.conversation-mode .stage-coordinates{display:none}
 .conversation-mode .speech-indicator{left:var(--space-100);top:var(--space-100);max-width:calc(100% - 16px)}
 .dialogue-panel .panel-heading,.identity-note{display:none}
 .voice-toolbar{margin-bottom:var(--space-100)}
 .voice-toolbar select{width:100%;min-width:100px;font:var(--type-caption);min-height:40px}
 .voice-toolbar button{min-height:40px}
 .chat-message{padding:var(--space-100)}
 .chat-message p{line-height:20px}
 .message-actions button,.message-more summary{min-height:40px}
 .runtime-details{padding-top:var(--space-50);max-height:100px}
 .runtime-details summary{min-height:24px}
 #chat-form .chat-actions button{min-height:40px;flex:none}
 #chat-form .chat-actions #chat-send{margin-left:auto}
 .conversation-mode.immersive-mode .stage{grid-template-rows:auto minmax(0,1fr)}
 .conversation-mode.immersive-mode .dialogue-panel{padding:0;bottom:var(--space-100);width:calc(100% - 16px);border:0}
 .immersive-mode .stage-caption:not([hidden]){width:calc(100% - 16px);bottom:192px;padding:var(--space-100)}
 .conversation-mode.keyboard-open .stage{grid-template-rows:auto minmax(64px,16%) minmax(0,1fr)}
 .conversation-mode.keyboard-open .voice-toolbar,.conversation-mode.keyboard-open .runtime-details{display:none}
 .conversation-mode.keyboard-open.immersive-mode .stage{grid-template-rows:auto minmax(0,1fr)}
 .conversation-mode .topbar .nav-item:first-child{display:block}
 .conversation-mode .topbar .brand-sub,.conversation-mode .topbar .brand>span{display:none}
 .conversation-mode .topbar nav{gap:0}
 .conversation-mode .stage-overlay h2{font:var(--type-title)}
 .conversation-mode .stage-overlay p,.conversation-mode .stage-overlay .demo-label{display:none}
 .conversation-mode .stage-overlay{bottom:var(--space-100)}
 .conversation-mode .welcome-actions{margin-top:var(--space-100)}
 .history-buttons{width:100%;justify-content:flex-end}
 .creation-ready{flex-direction:column;align-items:flex-start}
}
@media(prefers-reduced-motion:reduce){.sound-bars i{transform:none}.conversation-mode .viewport::after{display:none}}

/* Speech input keeps the existing composer layout and visible keyboard focus. */
.asr-button {flex:0 0 40px; width:40px; height:40px; display:inline-flex; align-items:center; justify-content:center;}
.asr-button svg {width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;}
.asr-button[aria-pressed="true"] {color:#ff9696;background:#313131;border-color:currentColor;}
.asr-button:focus-visible {outline:2px solid #8fe7e7;outline-offset:2px;}
.asr-feedback {display:flex;align-items:center;gap:8px;min-height:40px;}
.asr-feedback .hint {margin:0;flex:1;}
#asr-result {width:100%;min-height:96px;}
.chat-actions {flex-wrap:wrap;}
@media (max-width:600px) {
 #chat-form .chat-actions {display:grid;grid-template-columns:1fr 40px 40px auto;gap:8px;}
 #chat-stop {grid-row:1;grid-column:1 / 3;justify-self:start;}
 #speech-stop {grid-row:1;grid-column:3 / 5;justify-self:end;}
 #asr-mic {grid-row:2;grid-column:2;}
 #asr-upload {grid-row:2;grid-column:3;}
 #chat-send {grid-row:2;grid-column:4;}
}
