/* Mobile shell: fixed visual viewport, independently scrolling transcript/sheets. */
:root { color-scheme: light; --canvas: #fff; --surface: #f5f5f5; --ink: #202123; --ink-muted: #737373; --line: #e8e8e8; --accent-deep: #454545; }
html, body { position: fixed; inset: 0; width: 100%; height: 100%; min-height: 0; overflow: hidden; overscroll-behavior: none; scroll-behavior: auto; background: #fff; }
body { min-width: 0; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; }
/* Keyboard geometry must never inherit the global reduced-motion transition. */
html, body, .chat-page, .chat-dialog { transition: none !important; }
.chat-page { position: fixed; top: var(--chat-top, 0px); left: 0; right: 0; height: var(--chat-height, 100dvh); max-width: 820px; width: 100%; min-height: 0; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; overflow: hidden; }
.chat-page .chat-header { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; margin: 0; padding: max(8px, env(safe-area-inset-top)) 0 8px; gap: 12px; }
.chat-page h1 { font-size: 19px; font-weight: 600; margin: 0; letter-spacing: -.025em; flex: 1; }
.chat-page h1 span { color: #888; font-size: 12px; font-weight: 400; margin-left: 5px; }
.chat-page button, .chat-dialog button { min-height: 44px; margin: 0; border: 0; border-radius: 12px; padding: 10px 14px; background: transparent; }
.chat-page .icon-button { width: 44px; height: 44px; padding: 10px; flex-shrink: 0; border-radius: 50%; }
.icon-button svg { display: block; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chat-page .chat-stage { flex: 1; display: flex; flex-direction: column; border: 0; padding: 0; min-height: 0; min-width: 0; }
#chat-status { flex-shrink: 0; margin: 0 0 8px; font-size: 12px; max-height: 64px; overflow: auto; color: #656565; }
#chat-messages { flex: 1 1 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; -webkit-overflow-scrolling: touch; padding: 12px 4px; overflow-wrap: anywhere; }
.chat-empty { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 0; text-align: center; }
.chat-page .chat-empty h2 { font-size: 27px; font-weight: 600; letter-spacing: -.04em; margin: 0 0 8px; }
.chat-empty p { color: #888; font-size: 14px; margin: 0 0 24px; }
.chat-empty button { min-height: 40px; font-size: 14px; color: #696969; }
.chat-message { padding: 14px 0; overflow-wrap: anywhere; }
.chat-message h3 { font-size: 12px; color: #888; font-weight: 500; margin: 0 0 8px; }
.chat-message p { white-space: pre-wrap; font-size: 16px; line-height: 1.8; margin: 0; }
.chat-message[data-role="user"] { width: fit-content; max-width: 88%; margin: 8px 0 16px auto; padding: 12px 16px; background: #f2f2f2; border-radius: 22px; }
.chat-message[data-role="user"] h3 { display: none; }
.chat-message summary { color: #999; font-size: 12px; padding: 12px 0; min-height: 44px; }
.chat-page .chat-candidate { background: #f5f5f5; font-size: 12px; }
#chat-form { flex: 0 0 auto; position: relative; margin: 0; padding: 8px 0 max(8px, env(safe-area-inset-bottom)); background: #fff; }
#chat-fields { margin: 0; padding: 12px 10px 6px; background: #f4f4f4; border: 1px solid #ededed; border-radius: 26px; }
.chat-page #chat-input { display: block; width: 100%; min-height: 32px; height: 32px; max-height: 120px; padding: 2px 6px; border: 0; border-radius: 0; font-size: 16px; line-height: 1.7; background: transparent; resize: none; outline: none; overflow-y: auto; }
.chat-compose-actions { display: flex; justify-content: space-between; align-items: center; padding-top: 4px; }
.chat-page #chat-send, .chat-page #chat-stop { color: #fff; background: #202123; border-radius: 50%; width: 44px; height: 44px; }
.chat-page #chat-stop { position: absolute; right: 10px; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 25px); font-size: 0; padding: 14px; }
#chat-stop::after { content: ""; display: block; width: 14px; height: 14px; background: #fff; border-radius: 3px; }
.chat-page #chat-send-help { text-align: center; font-size: 10px; color: #999; margin: 6px 0 0; line-height: 1.4; }
#chat-attachments-selected { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 8px; }
.attachment-chip { display: inline-flex; align-items: center; white-space: nowrap; border: 1px solid #ddd; border-radius: 14px; max-width: 240px; flex-shrink: 0; }
.attachment-chip button:first-child { text-overflow: ellipsis; overflow: hidden; font-size: 13px; padding-right: 4px; }
.attachment-chip button:last-child { min-width: 44px; font-size: 20px; }
.chat-page #chat-pending { flex: 0 0 auto; max-height: 24%; overflow: auto; padding: 4px; margin: 0; border: 0; }
#chat-pending h3 { font-size: 13px; margin: 0; font-weight: 500; }
#chat-pending p { margin: 4px 0; font-size: 12px; color: #888; }
#chat-request-details summary { min-height: 32px; padding: 4px 0; font-size: 12px; color: #888; }
#chat-stop-controls { display: none; }
#chat-source-blocked { font-size: 13px; flex-shrink: 0; max-height: 72px; overflow: auto; color: #a43b29; }
.chat-dialog { position: fixed; color: #202123; background: #fff; border: 0; padding: 20px; width: min(100%, 540px); max-width: 100%; max-height: min(88dvh, var(--chat-height, 88dvh)); overflow-y: auto; overscroll-behavior: contain; box-shadow: none; }
.chat-dialog::backdrop { background: #0005; }
.chat-dialog:not([open]) { display: none; }
.chat-dialog.chat-sheet { top: auto; left: 0; right: 0; bottom: calc(100% - var(--chat-top, 0px) - var(--chat-height, 100dvh)); margin: 0 auto; border-radius: 26px 26px 0 0; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
.chat-dialog.chat-drawer { inset: var(--chat-top, 0px) auto auto 0; width: min(86vw, 350px); height: var(--chat-height, 100dvh); max-height: var(--chat-height, 100dvh); margin: 0; border-radius: 0 22px 22px 0; padding-top: max(20px, env(safe-area-inset-top)); }
.sheet-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.chat-dialog .sheet-heading h2 { margin: 0; font-size: 20px; }
.chat-dialog .sheet-heading button { color: #777; padding-inline: 8px; }
.chat-dialog .chat-hint, .chat-dialog p { color: #737373; font-size: 13px; }
#chat-drawer-new, #chat-history-list button { width: 100%; text-align: left; justify-content: flex-start; }
#chat-history-list button { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; font-size: 15px; margin: 4px 0; }
#chat-history-list button[aria-current="true"] { background: #f0f0f0; }
#chat-history-search { border: 0; border-radius: 14px; background: #f5f5f5; margin-top: 14px; font-size: 16px; }
.drawer-links { border-top: 1px solid #eee; margin-top: 28px; padding-top: 12px; display: grid; }
.drawer-links a, .drawer-links button { display: block; min-height: 48px; color: #5d5d5d; padding: 12px 14px; text-decoration: none; font-size: 14px; text-align: left; }
#chat-advanced { border: 0; }
#chat-advanced > summary { display: none; }
#chat-context-details > summary, #chat-sources-details > summary { font-size: 16px; font-weight: 500; padding: 16px 0; min-height: 52px; }
.chat-dialog .acknowledgement { font-size: 14px; }
#chat-sources-list article { border-top: 1px solid #eee; padding: 12px 0; }
#chat-sources-list p { white-space: pre-wrap; overflow-wrap: anywhere; }
#chat-sources-list .source-context-meta { font-size: 11px; }
#chat-attachment-done, .chat-dialog #chat-save, #chat-pair-submit { width: 100%; background: #202123; color: #fff; margin-top: 16px; }
#chat-review { inset: 0; margin: auto; border-radius: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.chat-page :focus-visible, .chat-dialog :focus-visible { outline: 2px solid #555; outline-offset: 2px; }
@media (max-height: 500px) { .chat-page .chat-header { padding-block: 4px; } #chat-input { max-height: 72px; } #chat-send-help { display: none; } .chat-empty { padding: 8px 0; } .chat-empty p { display: none; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
