.gen-media-name{font-weight:500;color:var(--text);overflow-wrap:anywhere;min-width:0}
.gen-media-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:8px;flex-shrink:0}
.gen-images figcaption{flex-wrap:wrap;gap:8px 12px}
.gen-images .gen-media-actions > :is([data-gen-download],[data-gen-reference],[data-local-edit],.gen-video-clip-edit){
 display:inline-grid;place-items:center;flex:none;width:44px;min-width:44px;height:44px;min-height:44px;
 padding:0;border:0;border-radius:50%;background:var(--tg-soft);color:var(--text);
}
.gen-images .gen-media-actions > :is([data-gen-download],[data-gen-reference],[data-local-edit],.gen-video-clip-edit) svg{
 width:22px;height:22px;stroke-width:1.65;
}
@media(hover:hover){
 .gen-images .gen-media-actions > :is([data-gen-download],[data-gen-reference],[data-local-edit],.gen-video-clip-edit):hover{
  background:var(--tg-selected);
 }
}
.gen-images .gen-media-actions > :is([data-gen-download],[data-gen-reference],[data-local-edit],.gen-video-clip-edit):active{
 background:var(--tg-selected);
}
.gen-reference-action{display:inline-flex;align-items:center;justify-content:center;flex:none;width:44px;height:44px;padding:12px;border:0;border-radius:50%;color:var(--muted);background:transparent;cursor:pointer;transition:background-color .16s,opacity .16s}
.gen-reference-action .gen-glyph{width:20px;height:20px}
.gen-reference-action:disabled{opacity:.5;cursor:wait}
.gen-reference-action:focus-visible{outline:2px solid var(--conversation-muted);outline-offset:3px}
.gen-sent-reference{display:flex;align-items:center;gap:10px;max-width:320px;padding:8px;margin:0 0 8px auto;border:1px solid var(--conversation-line);border-radius:16px;background:var(--conversation-soft);box-sizing:border-box}
.gen-sent-reference img{width:52px;height:52px;object-fit:cover;border-radius:10px;flex:none}
.gen-sent-reference>span{display:flex;flex-direction:column;gap:3px;min-width:0}
.gen-sent-reference strong{font-size:13px;font-weight:500;overflow-wrap:anywhere;color:var(--conversation-ink)}
.gen-sent-reference small{font-size:12px;color:var(--conversation-muted)}
/* Sent attachments are a local horizontal strip. Keep each player's node
 * mounted across chat polling so playback and the strip's scroll survive. */
[data-gen-conversations] .gen-user-message.has-sent-references{width:100%;max-width:680px;box-sizing:border-box}
.gen-sent-reference-list{display:flex;align-items:flex-start;gap:8px;width:fit-content;max-width:100%;margin:0 0 12px auto;padding:3px;box-sizing:border-box;overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:thin}
.gen-sent-reference-list:focus-visible{outline:2px solid var(--conversation-muted);outline-offset:2px;border-radius:18px}
.gen-sent-reference-list .gen-sent-reference{display:flex;flex-direction:column;align-items:stretch;gap:0;flex:0 0 112px;max-width:none;min-width:0;margin:0;padding:0;overflow:hidden;border-radius:16px}
.gen-sent-reference-list .gen-sent-reference-video{flex-basis:var(--gen-reference-width,208px);width:var(--gen-reference-width,208px);max-width:100%}
.gen-sent-reference-list .gen-sent-reference:only-child{flex-shrink:1;max-width:100%}
.gen-sent-reference-list .gen-sent-reference>img,.gen-sent-reference-list .gen-sent-reference>video{display:block;width:100%;height:112px;margin:0;border:0;border-radius:0;object-fit:cover;flex:none}
.gen-sent-reference-list .gen-sent-reference>video{height:auto;min-width:0;min-height:0;aspect-ratio:var(--gen-reference-ratio,16/9);object-fit:contain;background:#111}
.gen-sent-reference-list .gen-sent-reference-caption{display:grid;grid-template-columns:minmax(0,1fr) 44px;grid-template-rows:auto auto;column-gap:0;row-gap:2px;align-items:center;min-height:48px;padding:2px 2px 2px 8px;box-sizing:border-box}
.gen-sent-reference-list .gen-sent-reference strong,.gen-sent-reference-list .gen-sent-reference small{grid-column:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:1.4}
.gen-sent-reference-list .gen-sent-reference strong{align-self:end}
.gen-sent-reference-list .gen-sent-reference small{align-self:start}
.gen-sent-reference-list .gen-sent-reference small:empty{display:none}
.gen-sent-reference-list .gen-sent-reference strong:has(+small:empty){grid-row:1/3;align-self:center}
.gen-sent-reference-list .gen-reference-action{grid-column:2;grid-row:1/3;align-self:center}
.gen-sent-reference-list .gen-reference-action:focus-visible{outline-offset:-3px}
.gen-sent-reference-list .gen-reference-action:active{background:var(--conversation-line)}
.gen-sent-reference-caption>.gen-video-clip-edit{grid-column:1/-1;justify-self:start;min-height:44px}
.gen-reference-tray{display:block;min-width:0;max-width:100%;padding:6px 6px 0}
.gen-reference-strip{display:flex;flex-wrap:nowrap;align-items:flex-start;gap:10px;min-width:0;max-width:100%;padding:8px 8px 6px;box-sizing:border-box;overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;scrollbar-width:thin;-webkit-overflow-scrolling:touch}
.gen-reference-thumb{position:relative;flex:0 0 80px;width:80px;min-width:0;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.gen-reference-insert{display:block;position:relative;width:80px;height:80px;padding:0;border:0;border-radius:16px;overflow:hidden;color:#fff;background:var(--conversation-line);touch-action:pan-x;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
.gen-reference-insert img{display:block;width:100%;height:100%;object-fit:cover;pointer-events:none}
.gen-reference-insert>span{position:absolute;inset:auto 0 0;padding:12px 4px 4px;background:linear-gradient(transparent,#0009);font-size:12px;font-weight:600;text-align:center;pointer-events:none}
.gen-reference-thumb.is-holding .gen-reference-insert{outline:2px solid var(--conversation-muted);outline-offset:2px;cursor:grabbing}
.gen-reference-placeholder{opacity:.3}
.gen-reference-drag{pointer-events:none;opacity:.95;filter:drop-shadow(0 6px 10px #0003)}
.gen-reference-thumb>small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10px;line-height:1.5;color:var(--conversation-muted);margin-top:3px}
.gen-reference-remove{display:grid;place-items:center;position:absolute;top:-6px;right:-6px;width:44px;height:44px;padding:0;border:0;background:transparent;color:#fff;font-size:23px;line-height:1;isolation:isolate}
.gen-reference-remove::before{content:'';position:absolute;inset:10px;border-radius:50%;background:#333b;z-index:-1}
.gen-reference-insert-hint{display:block;margin:0 8px 4px;font-size:11px;color:var(--conversation-muted)}
[data-gen-conversations] .gen-composer-shell .gen-chat-editor{display:block;width:100%;min-width:0;min-height:54px;max-height:144px;overflow-y:auto;padding:14px 16px 6px;border:0;background:transparent;color:var(--conversation-ink);font:inherit;font-size:16px;line-height:28px;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;scrollbar-width:thin;cursor:text}
.gen-chat-editor[data-empty=true]::before{content:attr(data-placeholder);color:var(--conversation-muted);pointer-events:none}
.gen-chat-editor:focus{outline:none}
.gen-reference-chip{display:inline-flex;vertical-align:middle;align-items:center;gap:4px;max-width:100%;height:28px;margin:0 3px;padding:2px 6px 2px 3px;border-radius:7px;background:var(--conversation-line);color:var(--conversation-ink);font-size:14px;line-height:24px;white-space:nowrap;user-select:all;-webkit-user-select:all}
.gen-reference-chip :is(img,video){display:block;width:22px;height:22px;object-fit:cover;border-radius:4px;pointer-events:none}
[data-gen-conversations] .gen-composer-shell .gen-chat-compose-row{grid-template-columns:44px minmax(0,1fr) 44px;align-items:center;padding:6px 8px 8px;gap:8px}
/* Idle: a single 58px line. Editing: text above, all tools and
 * parameters in one anchored bottom row, never part of the text flow. */
[data-gen-conversations] .gen-composer-shell,
[data-gen-conversations] .gen-composer-shell:not(.is-active){
 display:grid;grid-template-columns:minmax(0,1fr) 44px;
 grid-template-areas:"references references" "prompt submit";
 align-items:center;column-gap:8px;row-gap:0;padding:6px 8px;
 min-width:0;min-height:58px
}
[data-gen-conversations] .gen-composer-shell.is-active{
 display:grid;grid-template-columns:minmax(0,1fr) 44px;
 grid-template-areas:"references references" "prompt prompt" "actions submit";
 row-gap:2px
}
[data-gen-conversations] .gen-composer-shell .gen-reference-tray{grid-area:references;padding:0}
[data-gen-conversations] .gen-composer-shell .gen-chat-editor,
[data-gen-conversations] .gen-composer-shell:not(.is-active) .gen-chat-editor{grid-area:prompt;min-height:44px;max-height:144px;padding:8px 2px;overflow-y:auto}
[data-gen-conversations] .gen-composer-shell .gen-chat-compose-row,
[data-gen-conversations] .gen-composer-shell:not(.is-active) .gen-chat-compose-row{display:contents}
[data-gen-conversations] .gen-composer-shell .gen-composer-actions{grid-area:actions;display:flex;align-items:center;gap:4px;min-width:0;max-width:100%}
[data-gen-conversations] .gen-composer-shell .gen-composer-actions[hidden]{display:none!important}
[data-gen-conversations] .gen-composer-shell #gen-chat-upload{flex:none}
[data-gen-conversations] .gen-composer-shell .gen-composer-actions .gen-composer-tools{flex:none;width:44px;min-width:44px;padding:0;margin:0}
[data-gen-conversations] .gen-composer-shell .gen-composer-actions #gen-chat-settings-open{flex:1;min-width:44px;max-width:100%;margin:0;overflow:hidden}
[data-gen-conversations] .gen-composer-shell .gen-composer-actions #gen-chat-settings-summary{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
[data-gen-conversations] .gen-composer-shell #gen-chat-submit{grid-area:submit;align-self:end}
#gen-manual-modes .gen-composer-tools{margin:0 0 20px;padding:0}
@media(hover:hover){.gen-reference-action:hover{background:var(--tg-soft);color:var(--text)}}
@media(max-height:500px){.gen-reference-tray{max-height:104px}[data-gen-conversations] .gen-composer-shell .gen-chat-editor{max-height:72px}}
/* Keyboard height can change without a CSS media-query change. Keep the
 * toolbar outside the editor/reference scrollers, including in landscape. */
[data-gen-conversations].gen-keyboard-open .gen-chat-form{display:flex;flex-direction:column;max-height:calc(100% - 24px);margin-bottom:12px}
[data-gen-conversations].gen-keyboard-open .gen-composer-shell{min-height:0}
[data-gen-conversations].gen-keyboard-open .gen-composer-shell.is-active{display:grid;overflow:hidden}
[data-gen-conversations].gen-keyboard-open .gen-composer-shell.is-active .gen-reference-tray{flex:0 1 auto;min-height:0}
[data-gen-conversations].gen-keyboard-open .gen-composer-shell.is-active .gen-chat-editor{flex:0 1 auto}
[data-gen-conversations].gen-keyboard-open .gen-chat-compose-row{flex:none}
@media(prefers-reduced-motion:reduce){.gen-reference-action{transition:none}}


.gen-material-excerpt{padding:10px 8px 24px;color:var(--conversation-ink);background:var(--conversation-soft);font-size:11px;line-height:1.5;text-align:left;overflow:hidden;height:100%;box-sizing:border-box;overflow-wrap:anywhere}
.gen-reference-insert[aria-pressed=true]{outline:1px solid var(--conversation-muted);outline-offset:2px}

/* Settings stay available whenever their owning mode displays them. */
#gen-mode-switch{width:44px;height:44px;min-width:44px;background:var(--conversation-canvas);border:0;box-shadow:none}
#gen-mode-switch svg{width:23px;height:23px;stroke-width:1.65}
#gen-mode-options{position:fixed;inset:auto;margin:0;padding:5px;min-width:168px;max-width:calc(100vw - 16px);border:1px solid var(--conversation-line);border-radius:18px;background:var(--conversation-canvas);color:var(--conversation-ink);box-shadow:0 10px 32px #0003}
#gen-mode-options:popover-open{display:block}
#gen-mode-options [role=tablist]{
 --gen-mode-row:44px;
 --gen-mode-gap:2px;
 position:relative;display:grid;grid-auto-rows:var(--gen-mode-row);gap:var(--gen-mode-gap);
}
#gen-mode-options [role=tablist]::before{
 content:"";position:absolute;inset:0 0 auto;height:var(--gen-mode-row);
 box-sizing:border-box;border:1px solid var(--conversation-line);border-radius:12px;
 background:var(--conversation-soft);pointer-events:none;transition:transform .18s ease;
}
#gen-mode-options [role=tablist]:has([data-kind=image][aria-selected=true])::before{
 transform:translateY(calc(var(--gen-mode-row) + var(--gen-mode-gap)));
}
#gen-mode-options [role=tablist]:has([data-kind=video][aria-selected=true])::before{
 transform:translateY(calc(2 * (var(--gen-mode-row) + var(--gen-mode-gap))));
}
[data-gen-conversations] #gen-mode-options .gen-mode-tab{
 appearance:none;position:relative;display:flex;align-items:center;justify-content:flex-start;
 width:100%;min-width:0;min-height:var(--gen-mode-row);gap:10px;padding:8px 12px;border:0;
 border-radius:12px;background:transparent;box-shadow:none;color:var(--conversation-ink);
 text-align:left;font-size:14px;
}
@media(prefers-reduced-motion:reduce){#gen-mode-options [role=tablist]::before{transition:none}}
@media(forced-colors:active){#gen-mode-options [role=tablist]::before{border-color:Highlight}}
#gen-mode-options .gen-mode-tab svg{flex:none;width:22px;height:22px}
#gen-mode-options .gen-mode-tab span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#gen-mode-options.gen-composer-popover-local,#gen-chat-attachments.gen-composer-popover-local{position:absolute;inset:auto;margin:0;z-index:3;box-sizing:border-box;max-width:calc(100% - 16px)}
#gen-mode-options[hidden],#gen-chat-attachments[hidden]{display:none!important}

@media(max-height:500px){[data-gen-conversations] .gen-composer-shell .gen-chat-editor,[data-gen-conversations] .gen-composer-shell:not(.is-active) .gen-chat-editor{max-height:72px}}
/* Keep a multiline editor's inertial scroll local to the composer. */
[data-gen-conversations] .gen-composer-shell .gen-chat-editor{overscroll-behavior-y:contain}

.gen-chat-idle-draft{display:none}
[data-gen-conversations] .gen-composer-shell:not(.is-active) .gen-chat-idle-draft{
 grid-area:prompt;display:flex;align-items:center;gap:8px;min-width:0;
 padding:0 2px;pointer-events:none;color:var(--conversation-ink);font-size:16px;line-height:28px
}
[data-gen-conversations] .gen-composer-shell:not(.is-active) .gen-chat-editor{
 opacity:0;height:44px;overflow:hidden
}
[data-gen-conversations] .gen-composer-shell:not(.is-active) .gen-reference-tray{display:none}
.gen-chat-idle-images{display:flex;flex:none;align-items:center}
.gen-chat-idle-images:empty{display:none}
.gen-chat-idle-images img{display:block;inline-size:1em;block-size:1em;box-sizing:border-box;border:1px solid var(--conversation-canvas);border-radius:4px;object-fit:cover}
.gen-chat-idle-images img+img{margin-inline-start:-.7em}
.gen-chat-idle-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.gen-chat-idle-text.is-placeholder{color:var(--conversation-muted)}

#gen-chat-thread :is(.gen-chat-preview-media,.gen-sent-reference img,.gen-reference-chip img,.gen-chat-media-card img),#gen-chat-form video.gen-chat-preview-media,
.gen-chat-image-viewer .pswp__img,.gen-chat-video-viewer video{cursor:zoom-in;-webkit-touch-callout:default;pointer-events:auto}
.gen-chat-preview-media:focus-visible{outline:2px solid var(--conversation-muted);outline-offset:-3px}
.gen-chat-image-viewer .pswp__top-bar{padding-top:env(safe-area-inset-top,0px)}
.gen-chat-video-viewer[open]{position:fixed;inset:0;box-sizing:border-box;width:100%;height:100dvh;max-width:none;max-height:none;margin:0;border:0;padding:0;display:grid;place-items:center;background:#000;color:#fff}
.gen-chat-video-viewer::backdrop{background:#000}
.gen-chat-video-viewer video,.gen-chat-video-viewer iframe{width:100%;max-height:100%;object-fit:contain;border:0}
.gen-chat-video-viewer iframe{height:100%}
.gen-chat-viewer-close{position:absolute;top:max(8px,env(safe-area-inset-top));right:max(8px,env(safe-area-inset-right));height:44px;width:44px;padding:0;border:0;border-radius:50%;background:#222b;color:#fff;font-size:30px}
.gen-attachment-option{display:flex;align-items:center;gap:10px}
.gen-attachment-option>svg{width:22px;height:22px;flex:none}
[data-gen-conversations] .gen-composer-shell .gen-chat-attachment-stack{grid-area:references;min-width:0;max-width:100%;max-height:min(280px,38svh);overflow-y:auto;overscroll-behavior:contain}
.gen-chat-media-preview{display:flex;gap:8px;overflow-x:auto;max-width:100%;padding:8px 0;overscroll-behavior-x:contain}
.gen-chat-media-preview[hidden]{display:none}
.gen-chat-media-item{display:grid;grid-template-columns:minmax(0,1fr) 44px;gap:4px;flex:0 0 min(230px,80%);min-width:0;padding:8px;border:1px solid color-mix(in srgb,currentColor 12%,transparent);border-radius:16px;background:color-mix(in srgb,var(--conversation-canvas,#fff) 75%,transparent)}
.gen-chat-media-item>video{grid-column:1/-1;width:100%;height:112px;object-fit:contain;border-radius:10px;background:#111}
.gen-chat-media-item>audio{grid-column:1/-1;width:100%;height:44px}
.gen-chat-media-item>span{align-self:center;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px}
.gen-chat-media-item>.gen-icon{width:44px;height:44px}
.gen-video-reference-role{grid-column:1/-1;display:flex;flex-wrap:wrap;gap:8px;align-items:center;min-width:0;font-size:12px}
.gen-video-reference-role>select{flex:1 1 120px;min-width:0;max-width:100%;min-height:44px;padding:8px;border:1px solid var(--line,rgba(128,128,128,.35));border-radius:10px;background:var(--conversation-canvas,#fff);color:inherit;font:inherit;font-size:16px}



.gen-chat-media-item>.gen-video-clip-edit{grid-column:1/-1;justify-self:start;min-height:44px}
.gen-images .gen-video-clip-edit{min-height:44px}
.gen-video-remake{border:1px solid var(--line,rgba(128,128,128,.35));border-radius:12px;padding:0 12px;min-width:0}
.gen-video-remake>summary{cursor:pointer;padding:12px 0}
.gen-video-remake fieldset{display:grid;gap:10px;border:0;margin:0;padding:0 0 12px;min-width:0}
.gen-video-remake fieldset>label{display:grid;gap:4px}
.gen-video-remake fieldset>label:has([type=checkbox]){display:flex;align-items:center;gap:8px}
.gen-video-remake :is(select,textarea,input[type=file]){width:100%;box-sizing:border-box;font-size:16px}
.gen-video-remake p{margin:0;font-size:13px}
.gen-video-remake [role=status]:not(:empty){padding-bottom:12px}
.gen-video-remake a{justify-self:start;font-size:12px}
