.chat-stage, .chat-main, .message, .message-body, .bubble { min-width: 0; }
.message.assistant .message-body { width: 100%; max-width: 100%; }
.message.assistant .bubble { width: 100%; min-width: 0; overflow-wrap: anywhere; }
.markdown-body pre, .markdown-body table { max-width: 100%; overflow-x: auto; }
.markdown-body pre { white-space: pre; }
.markdown-body th, .markdown-body td { min-width: 120px; max-width: 320px; overflow-wrap: anywhere; }
.message-tool-row, .message-actions { min-width: 0; flex-wrap: wrap; }
.memory-controls { position: relative; flex: 0 0 auto; color: #526078; font-size: 13px; }
.memory-controls summary {
    width: 36px; height: 36px; padding: 0; display: grid; place-items: center;
    border-radius: 6px; cursor: pointer; list-style: none;
}
.memory-controls summary::-webkit-details-marker { display: none; }
.memory-controls summary svg { width: 18px; height: 18px; }
.memory-controls summary:hover, .memory-controls[open] summary { background: #edf3fa; color: var(--blue); }
.memory-controls > .memory-menu {
    position: absolute; bottom: calc(100% + 12px); left: 0; z-index: 80;
    width: 264px; min-width: 0; padding: 14px; overflow-y: auto;
    background: #fff; color: var(--ink); border: 1px solid #dde3ea; border-radius: 8px;
    box-shadow: 0 8px 24px rgba(25, 40, 60, .12);
}
.memory-menu-title { display: block; margin: 0 0 8px; font-size: 12px; color: #596579; font-weight: 600; }
.memory-controls .memory-option { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 40px; margin: 0; cursor: pointer; }
.memory-option input {
    appearance: none; flex: 0 0 32px; width: 32px; height: 18px; padding: 0; margin: 0;
    border: 1px solid #8190a2; border-radius: 9px; background: #e6ebf1; cursor: pointer;
    position: relative; transition: background .12s;
}
.memory-option input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .12s; }
.memory-option input:checked { background: var(--blue); border-color: var(--blue); }
.memory-option input:checked::after { transform: translateX(14px); }
.memory-option input:disabled { opacity: .55; cursor: wait; }
.memory-menu-actions { margin-top: 10px; padding-top: 8px; border-top: 1px solid #e7ebf0; }
.memory-controls .memory-menu-actions button {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; margin: 0;
    padding: 6px 8px; color: inherit; font: inherit; border: 0; border-radius: 5px; background: transparent; text-align: left;
}
.memory-menu-actions button svg { width: 16px; height: 16px; flex-shrink: 0; color: #647086; }
.memory-menu-actions button span { flex: 1; }
.memory-menu-actions button:hover { background: #f1f4f8; }
.memory-controls summary:focus-visible, .memory-option input:focus-visible, .memory-menu-actions button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.answer-download > div {
    position: absolute; bottom: 100%; right: 0; z-index: 30; padding: 12px; min-width: 180px;
    background: var(--panel, #fff); color: var(--ink); border: 1px solid var(--line, #d9e1e9); border-radius: 6px;
}
.answer-download { position: relative; }
.answer-download summary { display: flex; align-items: center; gap: 5px; padding: 4px; cursor: pointer; }
.answer-download button { display: block; width: 100%; min-height: 34px; text-align: left; }
.load-history, .load-newer { justify-self: center; padding: 8px 16px; border: 1px solid var(--line, #d9e1e9); border-radius: 6px; color: var(--ink); background: var(--panel, #fff); }
.jump-to-latest { position: absolute; right: 24px; bottom: 190px; display: flex; align-items: center; gap: 6px; padding: 9px 12px; border: 1px solid var(--line, #d9e1e9); border-radius: 6px; color: var(--ink); background: var(--panel, #fff); z-index: 15; }
.jump-to-latest[hidden] { display: none; }
.citation-original { display: inline-block; margin: 14px 0; color: #1262cf; text-underline-offset: 3px; }
:root[data-theme="dark"] .memory-controls > div, :root[data-theme="dark"] .answer-download > div, :root[data-theme="dark"] .load-history, :root[data-theme="dark"] .load-newer, :root[data-theme="dark"] .jump-to-latest { background: #171c22; color: #e8edf3; border-color: #3d4753; }
:root[data-theme="dark"] .memory-controls { color: #b4c0d0; }
:root[data-theme="dark"] .memory-menu-title { color: #b4c0d0; }
:root[data-theme="dark"] .memory-menu-actions { border-color: #3d4753; }
:root[data-theme="dark"] .memory-menu-actions button:hover, :root[data-theme="dark"] .memory-controls summary:hover, :root[data-theme="dark"] .memory-controls[open] summary { background: #253140; }
:root[data-theme="dark"] .memory-menu-actions button svg { color: #b4c0d0; }
@media (hover: none), (pointer: coarse) {
    .message-actions { opacity: 1; visibility: visible; }
    .message-actions button, .answer-download summary { min-height: 36px; }
}
@media (max-width: 680px) {
    .prompt-toolbar { flex-wrap: wrap; }
    .message-actions { gap: 4px; }
    .message-actions button { font-size: 11px; }
    .composer-actions { flex-wrap: wrap; }
    .send-actions { margin-left: auto; }
}
@media (max-width: 980px) {
    body { height: 100dvh; overflow: hidden; }
    .assistant-shell { height: 100dvh; min-height: 0; grid-template-rows: minmax(0, 1fr); }
    .product-rail { grid-row: 1; height: 100dvh; }
    .chat-stage { grid-row: 1; height: 100dvh; min-height: 0; }
    .chat-card { height: 100dvh; min-height: 0; }
}
@media (min-width: 761px) and (max-width: 980px) {
    .assistant-shell, .assistant-shell.sidebar-collapsed { grid-template-columns: 52px minmax(0, 1fr); }
    .conversation-sidebar { left: 52px; width: min(320px, calc(100vw - 52px)); }
    .chat-stage { grid-column: 2; }
}
.conversation-item.has-search-match .conversation-main small {
    display: -webkit-box;
    grid-column: 1 / -1;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--muted);
    line-height: 1.5;
    font-size: 12px;
}

.composer {
    width: min(960px, calc(100% - 64px)); max-width: none; padding: 12px;
    border-radius: 8px; box-shadow: 0 4px 18px rgba(30, 50, 75, .05);
}
.composer-box { padding: 0; gap: 14px; }
.composer textarea { min-height: 32px; font-size: 15px; line-height: 1.65; }
.composer textarea::placeholder { color: #67758a; }
.composer:focus-within { border-color: #8baddd; }
.composer-actions { display: flex; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px 16px; }
.prompt-toolbar { flex: 1 1 280px; display: flex; flex-wrap: nowrap; gap: 8px; width: auto; overflow: visible; padding: 0; }
.model-switch { flex: 1 1 200px; max-width: 320px; min-width: 0; min-height: 36px; border-radius: 6px; background: #f6f8fb; }
.model-picker-button { flex: 1; min-width: 0; max-width: none; height: 34px; font-weight: 600; }
.model-picker-button span { flex: 1; text-align: left; }
.model-provider-logo { flex-shrink: 0; width: 16px; height: 16px; }
.model-picker-menu { overflow-y: auto; border-radius: 8px; }
.reference-button { flex: 0 1 auto; min-width: 0; min-height: 36px; border-radius: 6px; font-weight: 500; }
.reference-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reference-button svg { flex-shrink: 0; width: 16px; height: 16px; }
.send-actions { flex: 0 0 auto; width: auto; gap: 4px; margin-left: auto; }
.send-actions .icon-action, .send-actions .expand-button { flex: 0 0 36px; width: 36px; height: 36px; border: 0; border-radius: 6px; background: transparent; color: #526078; margin: 0; display: grid; place-items: center; }
.send-actions .icon-action svg, .send-actions .expand-button svg { width: 18px; height: 18px; }
.send-actions .icon-action:hover, .send-actions .expand-button:hover { background: #edf3fa; color: var(--blue); }
#sendButton { height: 36px; min-height: 36px; margin-left: 8px; border-radius: 6px; background: var(--blue); box-shadow: none; font-weight: 600; }
.model-picker-button:focus-visible, .reference-button:focus-visible, .send-actions button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.protocol-notice { margin: 8px 0; padding: 10px 0; color: #9b4b13; font-size: 13px; }
.thinking-panel { width: 100%; color: #596579; margin-bottom: 14px; }
.thinking-panel .thinking-summary {
    display: flex; width: fit-content; min-height: 32px; padding: 2px 0; gap: 8px;
    border: 0; border-radius: 0; background: transparent; overflow: visible;
}
.thinking-title { font-size: 13px; font-weight: 500; color: #526078; }
.thinking-separator { display: none; }
.thinking-summary-text { flex: 0 1 auto; max-width: none; font-size: 12px; color: #647086; }
.thinking-leading, .thinking-chevron { color: #647086; }
.thinking-panel[open] .thinking-summary-text { display: none; }
.thinking-panel .thinking-body {
    margin: 6px 0 0; padding: 4px 0 4px 22px; border: 0; border-radius: 0;
    background: transparent; color: #596579; font-size: 13px; line-height: 1.8; max-height: 240px;
}
.thinking-panel.active .thinking-body { color: #596579; }
.thinking-panel.active .thinking-summary::after { display: none; animation: none; }
.thinking-panel summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
:root[data-theme="dark"] .thinking-title, :root[data-theme="dark"] .thinking-panel .thinking-body, :root[data-theme="dark"] .thinking-summary-text, :root[data-theme="dark"] .thinking-leading, :root[data-theme="dark"] .thinking-chevron { color: #b4c0d0; background: transparent; }
:root[data-theme="dark"] .composer textarea::placeholder { color: #a1adbd; }
:root[data-theme="dark"] .model-switch { background: #202a36; border-color: #3d4753; }
:root[data-theme="dark"] .send-actions .icon-action, :root[data-theme="dark"] .send-actions .expand-button { background: transparent; color: #b4c0d0; }
:root[data-theme="dark"] .protocol-notice { color: #edbf89; }
:root[data-theme="dark"] .thinking-panel .thinking-summary, :root[data-theme="dark"] .thinking-panel .thinking-body { background: transparent !important; border: 0 !important; }
:root[data-theme="dark"] .memory-option input:checked { background: var(--blue) !important; border-color: var(--blue) !important; }
.sidebar-resizer { display: none; }
@media (min-width: 981px) {
    .assistant-shell { grid-template-columns: 52px var(--wenya-sidebar-width, 258px) minmax(0, 1fr); }
    .assistant-shell.sidebar-collapsed { grid-template-columns: 52px 0 minmax(0, 1fr); }
    .sidebar-resizer { display: block; position: absolute; z-index: 5; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; touch-action: none; }
    .sidebar-resizer:hover, .sidebar-resizer:focus-visible { background: rgba(30, 103, 230, .1); outline: none; }
    .sidebar-resizer:focus-visible { box-shadow: inset -2px 0 var(--blue); }
    .sidebar-collapsed .sidebar-resizer { display: none; }
    .assistant-shell.is-resizing { transition: none; cursor: col-resize; user-select: none; }
    .assistant-shell.is-resizing .sidebar-resizer { background: rgba(30, 103, 230, .2); }
}
@media (max-width: 980px) {
    .composer { width: calc(100% - 32px); margin-inline: auto; }
}
@media (max-width: 600px) {
    .composer { width: calc(100% - 20px); padding: 10px; }
    .composer-box { gap: 10px; }
    .composer textarea { font-size: 16px; }
    .composer-actions { flex-direction: column; align-items: stretch; gap: 10px; }
    .prompt-toolbar { flex: none; width: 100%; gap: 6px; }
    .model-switch { max-width: none; flex: 1; }
    .model-picker-button { padding: 0; }
    .reference-button { max-width: 110px; padding: 0 8px; }
    .reference-button > svg:last-child { display: none; }
    .send-actions { justify-content: flex-end; width: 100%; }
    .send-actions .icon-action, .send-actions .expand-button, .memory-controls summary { width: 44px; height: 44px; flex-basis: 44px; }
    #sendButton { min-height: 44px; }
    .memory-controls .memory-option, .memory-menu-actions button { min-height: 44px; }
}
@media (max-width: 400px) {
    #sendButton { flex: 0 0 44px; width: 44px; padding: 0; justify-content: center; }
    #sendButton span { display: none; }
}

/* Quiet conversation workspace; temporary surfaces carry the visual weight. */
.assistant-shell { --wenya-assistant-width: 860px; --wenya-user-width: 540px; }
.conversation-sidebar { padding: 18px 12px 16px; gap: 14px; background: #f7f8fa; backdrop-filter: none; border-color: #e4e7eb; }
.sidebar-heading { display: none; }
.title-row h1 { font-size: 18px; font-weight: 650; }
.title-row span { display: none; }
.new-chat-button { min-height: 40px; border: 1px solid #dce0e5; border-radius: 6px; background: transparent !important; color: var(--ink) !important; box-shadow: none !important; font-size: 13px; font-weight: 500; }
.new-chat-button:hover { background: #edf0f4 !important; }
.conversation-search { height: 38px; gap: 6px; border-radius: 6px; box-shadow: none; border-color: #e0e4e9; background: transparent; }
.conversation-search input { font-size: 13px; }
.folder-heading { padding-left: 8px; }
.folder-heading h2 { color: #657080; font-size: 12px; font-weight: 500; }
.folder-list { gap: 6px; scrollbar-width: thin; scrollbar-color: #c6ccd5 transparent; }
.folder-main { min-height: 34px; font-weight: 500; color: #4c5665; border: 0; border-radius: 5px; padding-left: 4px; }
.folder-main:hover { background: #edf0f4; color: var(--ink); }
.folder-conversations { border: 0; margin-left: 10px; padding-left: 8px; gap: 0; }
.conversation-main { min-height: 36px; border: 0; border-radius: 5px; padding: 4px 8px; }
.conversation-main strong { font-size: 13px; font-weight: 400; }
.conversation-main time { font-size: 11px; font-variant-numeric: tabular-nums; }
.conversation-item.active .conversation-main { background: #e9edf2 !important; }
.conversation-item.active .conversation-main strong { font-weight: 550; }
.conversation-item:hover .conversation-main { background: #edf0f4; }
.conversation-menu { border-radius: 6px; }
.chat-topbar { border-color: #eceef1; }
.chat-title-button { font-weight: 500; }
.message-stream { padding: 28px 32px 24px; gap: 26px; }
.message-status { font-weight: 400; }
.composer { border-color: #dfe3e8; box-shadow: none; border-radius: 8px; margin-bottom: 18px; }
.composer:focus-within { border-color: #98a5b7; box-shadow: none; }
.model-switch, :root[data-theme="dark"] .model-switch { flex: 0 1 auto; width: auto; max-width: 300px; background: transparent !important; border: 0 !important; padding: 0 4px; }
.model-picker-button { height: 36px; padding: 0 4px; font-weight: 500; background: transparent !important; }
.model-provider-logo { display: none; }
.model-switch:hover, :root[data-theme="dark"] .model-switch:hover { background: #f0f2f5 !important; }
.reference-button, .reference-button.active { border: 0 !important; background: transparent !important; color: #526078; padding: 0 8px; width: auto; }
.reference-button.active > svg:first-child { color: var(--blue); }
.reference-button:hover { background: #f0f2f5 !important; }
.prompt-toolbar { flex: 1 1 200px; gap: 6px; }
.message-actions button { border: 0; background: transparent; font-weight: 400; }
.message-tool-row a { border-radius: 5px; }
.sidebar-backdrop { display: none; }
.mobile-new-chat { display: none; }
.reference-dialog, .action-dialog, .citation-dialog, .attachment-preview-dialog { border-radius: 8px; }
.reference-dialog::backdrop { backdrop-filter: none; background: rgba(20, 26, 34, .36); }
.reference-dialog header strong { font-size: 16px; font-weight: 600; }
.reference-dialog header small { font-size: 12px; color: #626e7e; }
.reference-dialog header button { border: 0; background: transparent; border-radius: 6px; }
.reference-dialog-body { padding: 16px 20px; }
.reference-modes { display: flex; gap: 4px; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid #e7eaee; }
.reference-modes button { min-height: 38px; flex: 1; border: 0; border-radius: 5px; background: transparent; color: #596579; font-size: 13px; font-weight: 400; }
.reference-modes button[aria-pressed="true"] { background: #edf2fa; color: #185db9; font-weight: 600; }
.reference-search { height: 40px; border-radius: 6px; border-color: #dfe3e8; background: transparent; }
.reference-list { gap: 0; margin-top: 12px; }
.reference-group { border: 0; border-radius: 0; background: transparent; margin-bottom: 14px; }
.reference-group-heading { min-height: 40px; border: 0; background: transparent; font-weight: 550; color: #596579; }
.reference-group-heading svg { width: 16px; height: 16px; }
.reference-document { min-height: 48px; border: 0; padding: 8px 10px 8px 26px; gap: 12px; border-radius: 5px; }
.reference-document:hover { background: #f4f6f8; }
.reference-document strong { font-size: 13px; font-weight: 400; white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.reference-document small { color: #687486; font-size: 11px; }
.reference-list input { accent-color: var(--blue); width: 16px; height: 16px; flex-shrink: 0; }
.reference-dialog footer { padding: 12px 20px; justify-content: space-between; }
#referenceSelectionCount { font-size: 12px; color: #596579; }
.reference-dialog footer button { border-radius: 6px; font-size: 13px; font-weight: 500; }
.reference-dialog footer button:disabled { opacity: .45; cursor: default; }
:root[data-theme="dark"] .conversation-sidebar { background: #171b20 !important; }
:root[data-theme="dark"] .conversation-item.active .conversation-main { background: #2a3039 !important; }
:root[data-theme="dark"] .new-chat-button { color: #e2e7ef !important; border-color: #3b424d; }
:root[data-theme="dark"] .new-chat-button:hover, :root[data-theme="dark"] .model-switch:hover, :root[data-theme="dark"] .reference-button:hover { background: #2a3039 !important; }
:root[data-theme="dark"] .reference-button { color: #bac5d3; }
:root[data-theme="dark"] .reference-modes button { color: #bac5d3 !important; background: transparent !important; }
:root[data-theme="dark"] .reference-modes button[aria-pressed="true"] { background: #2b3645 !important; color: #9dc2ff !important; }
:root[data-theme="dark"] .reference-group-heading, :root[data-theme="dark"] #referenceSelectionCount { color: #bac5d3; }
:root[data-theme="dark"] .reference-document:hover { background: #2a3039 !important; }

@media (max-width: 980px) {
    .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 44; border: 0; border-radius: 0; background: rgba(20, 26, 34, .3); }
    .sidebar-heading { display: flex; min-height: 44px; justify-content: flex-end; padding: 0; }
    .mobile-sidebar-close { border: 0; width: 44px; height: 44px; }
    .conversation-sidebar { padding: 16px 12px; }
}
@media (max-width: 760px), (max-width: 980px) and (max-height: 500px) {
    body { height: var(--wenya-viewport-height, 100dvh); min-width: 0; }
    .assistant-shell, .assistant-shell.sidebar-collapsed { position: fixed; inset: 0; top: var(--wenya-viewport-top, 0px); height: var(--wenya-viewport-height, 100dvh); grid-template-columns: minmax(0, 1fr); }
    .chat-stage, .chat-card { height: 100%; min-height: 0; }
    .chat-stage { grid-column: 1; }
    .chat-card { grid-template-rows: calc(52px + env(safe-area-inset-top, 0px)) minmax(0, 1fr) auto; }
    .chat-topbar { grid-template-columns: 52px minmax(0, 1fr) 52px; grid-template-rows: minmax(0, 1fr); padding-top: env(safe-area-inset-top, 0px); }
    .chat-topbar > .usage-strip, .topbar-ai-notice { display: none; }
    .chat-topbar > * { grid-row: 1; }
    .topbar-left { padding: 0; }
    .topbar-sidebar-toggle { width: 44px; height: 44px; }
    .chat-title-button { width: 100%; min-width: 0; max-width: 100%; padding: 0 8px; font-size: 14px; }
    .mobile-new-chat { display: grid; place-items: center; width: 44px; height: 44px; grid-column: 3; border: 0; border-radius: 6px; background: transparent; }
    .mobile-new-chat svg { width: 19px; height: 19px; }
    .product-rail { position: fixed; z-index: 48; left: 0; bottom: auto; top: calc(var(--wenya-viewport-top, 0px) + var(--wenya-viewport-height, 100dvh) - 64px - env(safe-area-inset-bottom, 0px)); height: calc(64px + env(safe-area-inset-bottom, 0px)); width: min(320px, calc(100vw - 36px)); padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border: 0; border-top: 1px solid #e4e7eb; flex-direction: row; justify-content: space-around; gap: 4px; background: #f7f8fa; }
    .product-rail .brand-mark { display: none; }
    .product-rail .account-anchor { margin: 0; }
    .rail-link span { display: none; }
    .sidebar-collapsed .product-rail { display: none; }
    .conversation-sidebar { left: 0; top: var(--wenya-viewport-top, 0px); width: min(320px, calc(100vw - 36px)); height: var(--wenya-viewport-height, 100dvh); padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(76px + env(safe-area-inset-bottom, 0px)); z-index: 46; border: 0; }
    .account-popover { position: fixed; left: 12px; top: calc(var(--wenya-viewport-top, 0px) + var(--wenya-viewport-height, 100dvh) - 76px - env(safe-area-inset-bottom, 0px)); bottom: auto; transform: translateY(-100%); width: min(296px, calc(100vw - 60px)); border-radius: 8px; }
    .folder-action, .conversation-menu-trigger { opacity: 1; }
    .conversation-main { min-height: 44px; padding-right: 32px; }
    .conversation-main time { display: none; }
    .conversation-menu-trigger { width: 44px; height: 44px; }
    .conversation-actions { top: 0; right: 0; }
    .folder-main { min-height: 44px; }
    .folder-action { min-height: 40px; min-width: 32px; top: 2px; }
    .new-chat-button, .conversation-search { min-height: 44px; }
    .conversation-search input, .reference-search input, dialog input, dialog textarea, dialog select { font-size: 16px; }
    .message-stream { padding: 18px 16px 24px; gap: 20px; }
    .message.assistant .bubble { font-size: 16px; line-height: 1.75; }
    .message.user .message-body { max-width: 90%; }
    .message.user .bubble { padding: 10px 14px; border-radius: 8px; }
    .composer { width: calc(100% - 24px); padding: 10px; border-radius: 18px; margin: 0 auto max(10px, env(safe-area-inset-bottom)); }
    .composer textarea { min-height: 44px; max-height: 130px; font-size: 16px; }
    .composer-box { gap: 8px; }
    .composer-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px; }
    .prompt-toolbar { flex: none; width: auto; gap: 0; }
    .model-switch { flex: 1; min-width: 0; max-width: 210px; }
    .model-picker-button { height: 44px; font-size: 12px; }
    .reference-button { width: 44px; height: 44px; flex: 0 0 44px; padding: 0; justify-content: center; }
    .reference-button span, .reference-button > svg:last-child { display: none; }
    .send-actions { width: auto; gap: 0; }
    .send-actions .icon-action, .send-actions .expand-button, .memory-controls summary { width: 44px; height: 44px; flex-basis: 44px; }
    #sendButton { width: 44px; height: 44px; min-height: 44px; padding: 0; margin-left: 2px; justify-content: center; border-radius: 50%; }
    #sendButton span { display: none; }
    .composer-actions .expand-button { display: none; }
    .composer textarea { resize: none; }
    .message-actions { gap: 4px; opacity: 1; visibility: visible; }
    .message-actions button, .answer-download summary { min-height: 44px; padding: 6px; font-size: 12px; }
    .message-actions button[data-action="note"], .message-actions button[data-action="save"] { font-size: 12px; }
    dialog { max-height: calc(var(--wenya-viewport-height, 100dvh) - 24px) !important; }
    .reference-dialog { width: calc(100vw - 24px); }
    .reference-dialog header { padding: 14px; gap: 8px; }
    .reference-dialog header button { width: 44px; height: 44px; flex-shrink: 0; }
    .reference-dialog-body { padding: 12px 14px; }
    .reference-modes button { min-height: 44px; }
    .reference-dialog footer { padding: 12px 14px; gap: 8px; }
    .reference-dialog footer button { min-height: 44px; white-space: nowrap; }
    .reference-document { min-height: 54px; padding-left: 14px; }
    .reference-search { height: 44px; }
    .jump-to-latest { right: 16px; bottom: calc(var(--wenya-composer-height, 132px) + 8px); }
    .conversation-navigator { display: none; }
    .conversation-navigator-rail { width: 24px; }
    .conversation-navigator-node, .conversation-navigator-node:hover, .conversation-navigator-node.is-active { width: 24px; height: 24px; justify-content: flex-end; }
    .conversation-navigator-stroke { max-width: 20px; }
    .conversation-navigator-preview { left: auto; right: 30px; width: min(282px, calc(100vw - 70px)); border-radius: 8px; }
    .markdown-body td, .markdown-body th { min-width: 80px; }
    .keyboard-open .composer { margin-bottom: 6px; }
    :root[data-theme="dark"] .product-rail { background: #171b20 !important; }
}
@media (max-width: 360px) {
    .composer-actions { grid-template-columns: minmax(0, 1fr) auto; }
    .reference-button span { display: none; }
    .model-picker-button { font-size: 11px; }
}

.message-actions .message-icon-action { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: 6px; }
.message-actions .message-icon-action:hover { background: #f0f2f5; }
.message-icon-action svg { width: 16px; height: 16px; }
.message-time { margin-left: 6px; font-size: 11px; color: #657080; }
.message-status[hidden] { display: none; }
.jump-to-latest { width: 40px; height: 40px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: var(--paper, #fff); bottom: calc(var(--wenya-composer-height, 150px) + 8px); }
.jump-to-latest[hidden] { display: none; }
.answer-sources { margin: 0 0 14px; font-size: 12px; color: #596579; }
.answer-sources > summary { display: flex; align-items: center; gap: 7px; cursor: pointer; min-height: 36px; list-style: none; width: fit-content; max-width: 100%; }
.answer-sources > summary::-webkit-details-marker { display: none; }
.answer-sources > summary svg { width: 14px; height: 14px; flex-shrink: 0; }
.answer-sources[open] > summary > svg:last-child { transform: rotate(180deg); }
.source-list { margin-top: 6px; max-height: 300px; overflow-y: auto; border-block: 1px solid #e4e7eb; }
.source-entry { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px; text-align: left; width: 100%; min-width: 0; border: 0; border-radius: 0; background: transparent; color: inherit; text-decoration: none; white-space: normal; overflow-wrap: anywhere; font: inherit; cursor: pointer; }
.source-entry:hover { background: #f0f2f5; }
.source-entry small { font-size: 11px; color: #657080; }
.source-entry strong { font-size: 13px; font-weight: 500; color: var(--ink); line-height: 1.5; }
.answer-content .inline-source { display: inline-flex; vertical-align: baseline; align-items: center; min-height: 24px; max-width: min(200px, 100%); margin: 0 3px; padding: 2px 7px; border: 0; border-radius: 4px; background: #eef0f3; color: #4f5b6c; font-family: inherit; font-size: 11px; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.source-preview { position: fixed; z-index: 100; padding: 4px; background: #fff; border-radius: 8px; box-shadow: 0 6px 24px rgba(20,26,34,.18); overflow-y: auto; color: #151719; }
.citation-dialog #citationContent { white-space: pre-wrap; overflow-wrap: anywhere; }
.citation-dialog #citationContent .source-entry { font-family: system-ui, sans-serif; }
:root[data-theme="dark"] .inline-source, :root[data-theme="dark"] .source-entry:hover, :root[data-theme="dark"] .message-icon-action:hover { background: #2a3039 !important; color: #c3ccd8; }
:root[data-theme="dark"] .source-preview { background: #20262e; color: #e2e7ef; }
:root[data-theme="dark"] .source-entry small, :root[data-theme="dark"] .answer-sources { color: #bac5d3; }
@media (max-width: 760px), (max-width: 980px) and (max-height: 500px) {
    .message-actions .message-icon-action { width: 44px; height: 44px; }
    .message.user .message-actions { margin-top: 4px; }
    .message.user .message-body { gap: 4px; }
    .composer textarea { min-height: 40px; }
    .composer-box { gap: 4px; }
    .answer-sources > summary { min-height: 44px; }
    .answer-content .inline-source { min-height: 28px; }
    .source-entry { min-height: 44px; }
}
@media (max-width: 980px) and (max-height: 500px) {
    .chat-card { grid-template-rows: calc(44px + env(safe-area-inset-top, 0px)) minmax(0, 1fr) auto; }
    .composer textarea { min-height: 36px; max-height: 72px; }
    .composer-box { gap: 0; }
    .message-stream { padding-block: 12px; }
    .conversation-navigator { top: 56px; bottom: 160px; }
}

/* Compact composing and numbered references use the same geometry while streaming. */
.composer { position: relative; }
.composer.is-file-dragover { outline: 2px dashed var(--blue); outline-offset: 3px; }
.composer.is-file-dragover::after { content: '松开添加附件'; position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; background: var(--theme-surface, #fff); color: var(--blue); font-size: 16px; pointer-events: none; z-index: 5; }
.attachment-vision-status { margin: 6px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.5; overflow-wrap: anywhere; }
.attachment-vision-status.is-warning { color: #a32929; }
:root[data-theme="dark"] .attachment-vision-status.is-warning { color: #ffb7b7; }
.composer .attachment-status.ready { width: 100%; min-width: 0; max-height: min(200px, calc(var(--wenya-viewport-height, 100dvh) * .26)); overflow-y: auto; overscroll-behavior: contain; }
.composer .message-attachment-card { min-width: 0; border-radius: 8px; }
@media (max-width: 980px), (max-height: 600px) {
    .attachment-vision-status { font-size: 14px; }
    .composer .message-attachment-card > button { width: 44px; height: 44px; }
}
.composer-input { position: relative; min-width: 0; }
.composer-input textarea { display: block; width: 100%; padding-right: 32px; }
.composer-input .expand-button { position: absolute; top: 0; right: 0; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: #657080; }
.composer-input .expand-button svg { width: 14px; height: 14px; }
.composer-input .expand-button:hover { background: #f0f2f5; }
.composer.expanded textarea { min-height: min(180px, 35dvh); max-height: min(360px, 45dvh); resize: none; }
.jump-to-latest { left: 50%; right: auto; transform: translateX(-50%); }
.message-actions { gap: 0; }
.message-actions .message-icon-action { width: 30px; height: 32px; min-height: 32px; flex: 0 0 30px; margin: 0; }
.message.user .message-actions { gap: 0; }
.answer-content .inline-source { display: inline-grid; min-width: 16px; min-height: 18px; max-width: none; margin: 0 1px; padding: 0 2px; border: 0; border-radius: 3px; background: transparent; color: #53627a; font-size: 11px; line-height: 18px; vertical-align: super; white-space: nowrap; user-select: none; }
.answer-content .inline-source:hover, .answer-content .inline-source:focus-visible { color: var(--blue); background: #edf2fa; }
.source-preview { user-select: none; }
.answer-process { margin-bottom: 12px; color: #596579; font-size: 13px; }
.answer-process > summary { display: flex; align-items: center; gap: 8px; width: fit-content; min-height: 32px; list-style: none; cursor: pointer; }
.answer-process > summary::-webkit-details-marker { display: none; }
.answer-process > summary svg { width: 15px; height: 15px; }
.answer-process[open] > summary svg:last-child { transform: rotate(180deg); }
.answer-process > .thinking-panel, .answer-process > .answer-sources { margin: 6px 0 0; padding-left: 16px; }
.answer-process .thinking-body { padding-left: 0; }
.reference-folder-row { display: flex; align-items: center; gap: 2px; }
.reference-expand { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 40px; border: 0; border-radius: 5px; color: inherit; background: transparent; }
.reference-expand svg { width: 16px; height: 16px; }
.reference-group-heading { display: grid; width: 100%; min-width: 0; grid-template-columns: 18px minmax(0, 1fr) auto 16px; text-align: left; border-radius: 5px; font: inherit; padding: 8px 10px; }
.reference-group-heading span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reference-group-heading small { font-size: 12px; font-weight: 400; }
.reference-document { width: calc(100% - 38px); margin-left: 38px; display: grid; grid-template-columns: 20px minmax(0, 1fr) 16px; text-align: left; padding: 8px 10px; background: transparent; color: inherit; font: inherit; }
.reference-document > span { min-width: 0; }
.reference-document > svg { width: 16px; height: 16px; }
.reference-group-heading:hover, .reference-expand:hover { background: #f4f6f8; }
.reference-list [aria-pressed="true"], .reference-list .partially-selected { background: #edf2fa; color: #185db9; }
.reference-list button:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.reference-list button:disabled { opacity: .55; cursor: default; }
.reference-group { margin-bottom: 4px; }
:root[data-theme="dark"] .reference-list [aria-pressed="true"], :root[data-theme="dark"] .reference-list .partially-selected { background: #2b3645 !important; color: #9dc2ff; }
:root[data-theme="dark"] .answer-content .inline-source { background: transparent !important; color: #b8c8e0; }
:root[data-theme="dark"] .answer-process { color: #bac5d3; }
@media (max-width: 760px), (max-width: 980px) and (max-height: 500px) {
    .composer-input textarea { min-height: 32px; padding-right: 40px; }
    .composer-input .expand-button { width: 36px; height: 36px; }
    .composer { padding: 8px 10px; }
    .composer.expanded textarea { min-height: min(140px, 30dvh); max-height: 38dvh; }
    .message-actions .message-icon-action { width: 44px; height: 44px; min-height: 44px; flex-basis: 44px; }
    .reference-expand { width: 44px; height: 44px; flex-basis: 44px; }
    .reference-group-heading { min-height: 44px; }
    .reference-document { margin-left: 46px; width: calc(100% - 46px); }
    .answer-content .inline-source { min-height: 24px; min-width: 24px; line-height: 24px; }
    .answer-process > summary { min-height: 44px; }
    .jump-to-latest { left: 50%; right: auto; }
}

/* The composer exposes common actions; touch-only panels retain the same controls. */
.composer-actions { flex-wrap: nowrap; gap: 12px; }
.prompt-toolbar { flex: 1 1 120px; min-width: 0; }
.send-actions { gap: 2px; }
.send-actions #referenceButton { flex: 0 0 36px; width: 36px; height: 36px; min-height: 36px; padding: 0; border: 0; background: transparent; color: var(--muted, #526078); }
.send-actions #referenceButton.active { color: var(--blue); }
#referenceButton.active::after { content: ''; width: 4px; height: 4px; border-radius: 50%; background: currentColor; position: absolute; right: 4px; top: 4px; }
#referenceButton { position: relative; }
#referenceButton .sr-only { display: block; }
.composer-secondary { display: flex; align-items: center; gap: 2px; }
.composer-more-button, .composer-more-heading, .secondary-label { display: none !important; }
.control-tooltip { position: fixed; z-index: 140; max-width: min(300px, calc(100vw - 16px)); padding: 6px 9px; border-radius: 4px; background: var(--ink, #182130); color: var(--theme-surface, #fff); font-size: 12px; pointer-events: none; overflow-wrap: anywhere; }
.chat-title-button { width: min(640px, 42vw); }
.citation-attached { white-space: nowrap; }
.markdown-block { display: contents; }
.markdown-body pre { position: relative; padding-top: 42px; }
.code-copy { position: absolute; top: 4px; right: 6px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 4px; background: var(--theme-surface-2, #f8fbff); color: var(--ink, #182130); cursor: pointer; }
.code-copy svg { width: 15px; height: 15px; }
.source-excerpt { margin: 4px 0; white-space: pre-wrap; font-size: 13px; line-height: 1.65; font-weight: 400; color: var(--ink); }
.source-preview { max-width: calc(100vw - 24px); overscroll-behavior: contain; }
.source-preview .source-excerpt { max-height: 180px; overflow-y: auto; }
.source-evidence { cursor: default; }
.source-preview .source-evidence strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.source-evidence:hover { background: transparent; }
.source-evidence + .source-evidence { border-top: 1px solid var(--line); }
.source-evidence .source-location { margin: 4px 0 0; font-size: 12px; }
.source-full-text { margin: 8px 0; font-size: 13px; }
.source-full-text summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; color: var(--blue); }
.source-full-text p { margin: 8px 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.source-original { display: inline-flex; align-items: center; min-height: 32px; color: var(--blue); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.citation-dialog #citationContent { max-height: 62vh; overflow-y: auto; padding: 18px; white-space: normal; user-select: text; overscroll-behavior: contain; }
.citation-dialog .source-evidence { width: 100%; height: auto; }
:root[data-theme="dark"] #closeCitationButton { background: var(--theme-surface-2, #20262e); color: var(--ink); }
@media (max-width: 760px), (max-width: 980px) and (max-height: 500px) {
    .source-original, .source-full-text summary { min-height: 44px; }
    .citation-dialog .source-evidence strong, .citation-dialog .source-excerpt, .source-full-text p { font-size: 16px; }
}
.message-more { display: block; }
.message-more-menu { display: flex; align-items: center; gap: 2px; }
.message-more > summary { display: none; }
.conversation-navigator-node:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.usage-dialog { width: min(460px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 8px; background: var(--theme-surface, #fff); color: var(--ink); }
.usage-dialog::backdrop { background: rgba(20, 26, 34, .36); }
.usage-dialog article { min-width: 0; }
.usage-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.usage-dialog header div { min-width: 0; display: grid; gap: 4px; }
.usage-dialog header strong { font-size: 16px; }
.usage-dialog header small { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.usage-dialog header button, .composer-more-heading button { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 4px; background: transparent; color: inherit; padding: 0; }
.usage-dialog header svg, .composer-more-heading svg { width: 18px; height: 18px; }
.usage-dialog-body { padding: 16px 20px; overflow-y: auto; }
.usage-dialog dl { margin: 0 0 16px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px 16px; font-size: 13px; }
.usage-dialog dt { color: var(--muted); }
.usage-dialog dd { text-align: right; overflow-wrap: anywhere; margin: 0; font-variant-numeric: tabular-nums; }
#refreshBalanceButton { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px; color: inherit; background: transparent; cursor: pointer; }
#refreshBalanceButton svg { width: 15px; height: 15px; }
#refreshBalanceButton:disabled { opacity: .55; cursor: default; }
:is(.usage-dialog, .composer-secondary, .source-preview) button:focus-visible, .code-copy:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

@media (max-width: 760px), (max-width: 980px) and (max-height: 500px) {
    .composer { border-radius: 8px; }
    .composer-actions { gap: 0; }
    .prompt-toolbar { min-width: 0; }
    .model-switch { padding: 0 4px; }
    .model-picker-button { font-size: 12px; }
    .model-picker-button svg { flex: 0 0 12px; width: 12px; }
    .send-actions #referenceButton { width: 44px; height: 44px; flex-basis: 44px; }
    .send-actions .composer-more-button { display: grid !important; }
    .composer-secondary { display: none; position: fixed; z-index: 85; left: 12px; right: 12px; top: calc(var(--wenya-viewport-top, 0px) + var(--wenya-viewport-height, 100dvh) - var(--wenya-composer-height, 120px) - 8px); transform: translateY(-100%); padding: 12px; max-height: calc(var(--wenya-viewport-height, 100dvh) - var(--wenya-composer-height, 120px) - 24px); overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--theme-surface, #fff); color: var(--ink); overscroll-behavior: contain; }
    .composer-secondary.is-open { display: block; }
    .composer-more-heading { display: flex !important; align-items: center; justify-content: space-between; padding-bottom: 6px; font-size: 14px; }
    .secondary-label { display: inline !important; }
    .composer-secondary .memory-controls > summary, .composer-secondary #usageButton { width: 100%; height: 44px; min-height: 44px; display: flex; justify-content: flex-start; gap: 10px; font-size: 14px; font-weight: 400; padding: 0 8px; }
    .composer-secondary .memory-menu { position: static; width: 100%; padding: 8px; margin-bottom: 4px; border: 0; box-shadow: none; background: transparent; }
    .composer-secondary .memory-menu-title { display: none; }
    .composer-more-heading button { width: 44px; height: 44px; }
    .model-picker-menu { position: fixed; z-index: 85; border-radius: 8px; }
    .model-picker-option { min-height: 44px; border-radius: 4px; font-size: 14px; }
    .chat-title-button { width: 100%; }
    :is(.reference-dialog, .citation-dialog, .usage-dialog, .action-dialog, .attachment-preview-dialog) { position: fixed; inset: auto; left: 8px; top: calc(var(--wenya-viewport-top, 0px) + var(--wenya-viewport-height, 100dvh) - 8px); transform: translateY(-100%); width: calc(100vw - 16px); margin: 0; max-height: calc(var(--wenya-viewport-height, 100dvh) - 24px) !important; border-radius: 8px; overflow: hidden; }
    :is(.reference-dialog, .citation-dialog, .usage-dialog, .attachment-preview-dialog) > article { max-height: calc(var(--wenya-viewport-height, 100dvh) - 24px); display: flex; flex-direction: column; min-height: 0; }
    :is(.reference-dialog, .citation-dialog, .usage-dialog, .attachment-preview-dialog) header { flex-shrink: 0; }
    :is(.reference-dialog-body, .usage-dialog-body, .attachment-preview-body), .citation-dialog #citationContent { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
    .reference-dialog footer { flex-shrink: 0; }
    .citation-dialog #citationContent { max-height: none; padding: 8px; margin: 0; }
    .usage-dialog header { padding: 12px 16px; }
    .usage-dialog header button, #refreshBalanceButton { min-width: 44px; min-height: 44px; }
    .message-more { position: relative; display: block; }
    .message-actions { transform: none !important; flex-wrap: nowrap; max-width: 100%; }
    .message-tool-row { width: 100%; gap: 4px; }
    .message-tool-row .message-actions { flex: 1 1 auto; }
    .message-time { flex: 0 0 auto; white-space: nowrap; }
    .message-actions > .message-icon-action > span, .message-actions .answer-download > summary > span { display: none; }
    .answer-process .source-list { max-height: min(280px, 40dvh); overflow-y: auto; overscroll-behavior: contain; }
    .answer-process .source-entry strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .message-more > summary { display: grid; place-items: center; width: 44px; height: 44px; list-style: none; cursor: pointer; border-radius: 4px; }
    .message-more > summary::-webkit-details-marker { display: none; }
    .message-more > summary svg { width: 16px; height: 16px; }
    .message-more-menu { position: fixed; z-index: 90; width: 212px; padding: 8px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 8px; background: var(--theme-surface, #fff); display: grid; }
    .message-more:not([open]) .message-more-menu { display: none; }
    .message-more-menu .message-icon-action { display: flex; justify-content: flex-start; gap: 10px; width: 100%; padding: 8px; }
    .message-more-menu button[aria-label="整理对话笔记"]::after { content: '整理对话笔记'; }
    .message-more-menu button[aria-label="保存这条回答"]::after { content: '保存这条回答'; }
    .message-more-menu .answer-download > summary::after { content: '下载回答'; }
    .message-more-menu .answer-download > div { position: static; border: 0; padding: 0 8px; background: transparent; min-width: 0; }
    .message-more-menu .answer-download button { min-height: 44px; }
    .code-copy { width: 44px; height: 44px; }
    .markdown-body pre { padding-top: 52px; }
}
.attachment-preview-dialog { width: min(1040px, calc(100vw - 32px)); }
.attachment-preview-dialog header > div { min-width: 0; }
#attachmentPreviewTitle { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-preview-toolbar { display: flex; align-items: center; gap: 4px; padding: 4px 0 12px; user-select: none; }
.attachment-preview-toolbar button { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--theme-surface, #fff); }
.attachment-preview-toolbar button:hover:not(:disabled) { color: var(--blue); background: var(--soft); }
.attachment-preview-toolbar button:disabled { opacity: .4; cursor: default; }
.attachment-preview-toolbar svg { width: 18px; height: 18px; }
.attachment-preview-toolbar output { margin-left: 8px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.attachment-image-viewport { width: 100%; height: min(560px, calc(var(--wenya-viewport-height, 100dvh) - 200px)); min-height: 80px; overflow: auto; overscroll-behavior: contain; background: var(--theme-bg, #f4f5f7); }
.attachment-image-canvas { min-width: 100%; min-height: 100%; width: max-content; display: grid; place-items: center; }
.attachment-image-canvas .attachment-preview-image { display: block; max-width: none; max-height: none; margin: 0; object-fit: contain; }
@media (max-width: 760px), (max-width: 980px) and (max-height: 500px) {
    .attachment-preview-toolbar button { width: 44px; height: 44px; }
}
