/* Phone layout and motion share the existing light/dark theme roles. */
:root { --mobile-height: 100dvh; --mobile-top: 0px; --motion-quick: 120ms; --motion-panel: 220ms; --ease-mobile: cubic-bezier(.22,1,.36,1); }
.mobile-only { display: none !important; }
[hidden] { display: none !important; }
.sheet-suspended { visibility: hidden; }
.sheet-suspended::backdrop { background: transparent; }

html.mobile-layout[data-theme] .mobile-only { display: inline-flex !important; }
html.mobile-layout[data-theme] .mobile-only[hidden] { display: none !important; }
html.mobile-layout[data-theme] :is(button, select, summary, .radio-option, .app-footer a) { min-height: 44px; }
html.mobile-layout[data-theme] :is(button, a, select) { touch-action: manipulation; }
html.mobile-layout[data-theme] :is(button, a, select, summary) { transition: background-color var(--motion-quick), color var(--motion-quick), opacity var(--motion-quick), transform var(--motion-quick) var(--ease-mobile); }
html.mobile-layout[data-theme] button:not(:disabled):active { transform: scale(.98); }
html.mobile-layout[data-theme] :is(input, textarea, select) { font-size: 16px; }
html.mobile-layout[data-theme] :is(input, textarea, select, button):focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
html.mobile-layout[data-theme] .is-chat { position: fixed; inset: var(--mobile-top) 0 auto; height: var(--mobile-height); width: 100%; min-height: 0; overflow: hidden; }
html.mobile-layout[data-theme] .workspace { display: block; }
html.mobile-layout[data-theme] .is-chat :is(.workspace, .workspace-content) { height: 100%; min-height: 0; }
html.mobile-layout[data-theme] .workspace-content { padding: 0 16px max(8px, env(safe-area-inset-bottom)); }
html.mobile-layout[data-theme] .workspace-topbar { flex: 0 0 auto; min-height: 60px; padding: env(safe-area-inset-top) 0 0; margin: 0 -8px; gap: 0; }
html.mobile-layout[data-theme] .topbar-sidebar-toggle { display: inline-flex; width: 48px; min-height: 48px; flex: 0 0 48px; border-radius: 50%; }
html.mobile-layout[data-theme] .workspace-name { font-size: 16px; font-weight: 550; letter-spacing: -.02em; margin-right: auto; min-width: 0; text-decoration: none; }
html.mobile-layout[data-theme] .topbar-account { display: none; }
html.mobile-layout[data-theme] .mobile-header-action { width: 48px; min-height: 48px; align-items: center; justify-content: center; padding: 12px; border: 0; border-radius: 50%; flex: 0 0 48px; background: transparent; }
html.mobile-layout[data-theme] .mobile-header-action .action-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
html.mobile-layout[data-theme] .mobile-chat-actions { font-size: 0; }
html.mobile-layout[data-theme] .mobile-chat-actions::after { content: '•••'; font-size: 14px; letter-spacing: 2px; }
html.mobile-layout[data-theme] .mobile-chat-actions:has(svg)::after { content: none; }
html.mobile-layout[data-theme] :is(.sidebar-toggle, .light-sidebar-toggle, .sidebar-collapse) { display: none; }

html.mobile-layout[data-theme] .is-chat .workspace .intro { flex: 1; min-height: 0; padding: 0; margin: 0 auto; justify-content: flex-end; }
html.mobile-layout[data-theme] .is-chat .intro > h1 { flex: 1 1 auto; min-height: 44px; display: grid; place-content: center; text-align: center; padding: 0 20px; margin: 0; font-size: 28px; font-weight: 550; letter-spacing: -.025em; line-height: 1.25; }
html.mobile-layout[data-theme] .is-chat .intro .example-question { order: 1; margin: 0 auto 20px; padding: 8px 14px; min-height: 44px; border-color: var(--line); font-size: 13px; }
html.mobile-layout[data-theme] .is-chat .intro > .composer { order: 2; }
html.mobile-layout[data-theme] .is-chat .intro > :is(.status-message, button:not(.example-question)) { order: 3; }
html.mobile-layout[data-theme] .is-chat .chat-view { position: relative; display: flex; flex: 1; min-height: 0; margin: 0; }
html.mobile-layout[data-theme] .chat-toolbar { flex: 0 0 auto; margin: 0; padding: 0; min-height: 0; }
html.mobile-layout[data-theme] .chat-toolbar .mobile-chat-actions { display: none; }
html.mobile-layout[data-theme] .chat-toolbar:has(select) { min-height: 44px; }
html.mobile-layout[data-theme] .chat-toolbar select { min-height: 44px; font-size: 14px; }
html.mobile-layout[data-theme] .is-chat .message-thread { flex: 1; padding: 8px 0 20px; min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; overscroll-behavior: contain; }
html.mobile-layout[data-theme] .message-thread::-webkit-scrollbar { display: none; }
html.mobile-layout[data-theme] .user-message { margin: 16px 0 24px; }
html.mobile-layout[data-theme] .user-message h2 { font-size: 16px; line-height: 1.55; padding: 12px 16px; max-width: 90%; border-radius: 20px; }
html.mobile-layout[data-theme] .answer-summary { font-size: 16px; line-height: 1.75; }
html.mobile-layout[data-theme] .answer { margin-bottom: 24px; }
html.mobile-layout[data-theme] .icon-action { width: 44px; min-height: 44px; border-radius: 50%; padding: 12px; }
html.mobile-layout[data-theme] .message-actions { gap: 2px; margin-left: -8px; }
html.mobile-layout[data-theme] .source-list .source-title { min-height: 44px; padding: 10px 12px; font-size: 13px; text-align: left; line-height: 1.4; }
html.mobile-layout[data-theme] .answer-notes > summary { min-height: 44px; font-size: 13px; padding-block: 12px; }
html.mobile-layout[data-theme] .reading > .note { font-size: 13px; }
html.mobile-layout[data-theme] .mobile-latest { position: absolute; right: 0; bottom: 162px; z-index: var(--layer-header, 10); display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 10px; border: 1px solid var(--line); border-radius: 50%; background: var(--canvas); animation: mobile-reveal 160ms var(--ease-mobile); }

html.mobile-layout[data-theme] .is-chat :is(.intro, .chat-view) > .composer { position: relative; flex: 0 0 auto; padding: 8px 0 0; margin: 0; max-width: none; width: 100%; background: var(--canvas); }
html.mobile-layout[data-theme] .question-box { padding: 8px 8px 4px; border-radius: 24px; }
html.mobile-layout[data-theme] .question-box textarea { font-size: 16px; line-height: 1.5; min-height: 36px; max-height: min(160px, calc(var(--mobile-height) * .3)); padding: 6px 8px; }
html.mobile-layout[data-theme] .question-box textarea:focus-visible { outline: none; }
html.mobile-layout[data-theme] .compose-bottom { margin: 2px 0 0; gap: 0; flex-wrap: nowrap; align-items: center; }
html.mobile-layout[data-theme] .mobile-options { flex: 0 0 44px; width: 44px; padding: 12px; align-items: center; justify-content: center; border-radius: 50%; }
html.mobile-layout[data-theme] .scope-picker { flex: 1; min-width: 0; }
html.mobile-layout[data-theme] .scope-picker select { font-size: 13px; min-height: 44px; max-width: 100%; padding: 8px 4px; border-radius: 10px; }
html.mobile-layout[data-theme] .send-actions { flex-shrink: 0; gap: 0; margin: 0 0 0 auto; }
html.mobile-layout[data-theme] .send-actions .cost { display: none; }
html.mobile-layout[data-theme] .send-actions .send-button { width: 44px; height: 44px; min-height: 44px; }
html.mobile-layout[data-theme] .send-actions:has(.mobile-stop) .send-button { display: none; }
html.mobile-layout[data-theme] .send-actions .mobile-stop { width: 44px; height: 44px; min-height: 44px; display: grid; place-content: center; border-radius: 50%; background: var(--action); color: var(--on-action); font-size: 0; padding: 12px; }
html.mobile-layout[data-theme] .stop-symbol { width: 14px; height: 14px; border-radius: 3px; background: currentColor; }
html.mobile-layout[data-theme] .composer .session-line { display: none; }
html.mobile-layout[data-theme] .composer .coverage-note { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
html.mobile-layout[data-theme] .mobile-summary { width: 100%; align-items: center; justify-content: center; gap: 8px; min-height: 44px; color: var(--muted); font-size: 13px; line-height: 1.3; }
html.mobile-layout[data-theme] .mobile-summary button { min-height: 44px; border: 0; padding: 8px 4px; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
html.mobile-layout[data-theme] .mobile-cost { overflow-wrap: anywhere; }
html.mobile-layout[data-theme] .is-chat .status-message { font-size: 13px; max-height: 100px; overflow: auto; margin: 4px 0; }

html.mobile-layout[data-theme] .conversation-sidebar { display: none; position: fixed; inset: 0 auto 0 0; width: min(340px, calc(100vw - 40px)); height: var(--mobile-height); top: var(--mobile-top); padding: env(safe-area-inset-top) 12px max(12px, env(safe-area-inset-bottom)); min-height: 0; z-index: var(--layer-drawer); border-radius: 0 20px 20px 0; }
html.mobile-layout[data-theme] .drawer-open .conversation-sidebar { display: flex; transform: translateX(var(--drawer-drag, 0px)); transition: transform 180ms var(--ease-mobile); animation: mobile-drawer-in var(--motion-panel) var(--ease-mobile); }
html.mobile-layout[data-theme] .drawer-open .conversation-sidebar[data-dragging=true] { animation: none; transition: none; }
html.mobile-layout[data-theme] .drawer-open .conversation-sidebar[data-entered=true] { animation: none; }
html.mobile-layout[data-theme] .drawer-open .drawer-shade { display: block; position: fixed; inset: 0; width: 100%; height: 100%; z-index: var(--layer-shade); background: var(--overlay); border: 0; border-radius: 0; animation: mobile-fade 160ms ease-out; }
html.mobile-layout[data-theme] .drawer-open[data-closing=true] .conversation-sidebar { animation: mobile-drawer-out 180ms ease-in forwards; }
html.mobile-layout[data-theme] .drawer-open[data-closing=true] .drawer-shade { opacity: 0; transition: opacity 180ms; }
html.mobile-layout[data-theme] .sidebar-heading { min-height: 64px; flex-shrink: 0; touch-action: pan-y; }
html.mobile-layout[data-theme] .sidebar-heading h2 { display: block; font-size: 17px; color: var(--ink); margin-right: auto; }
html.mobile-layout[data-theme] .sidebar-brand { display: none; }
html.mobile-layout[data-theme] .drawer-close { display: block; min-height: 44px; padding: 8px; font-size: 13px; }
html.mobile-layout[data-theme] .conversation-sidebar input[type=search] { min-height: 48px; background: var(--surface); border-radius: 12px; font-size: 16px; }
html.mobile-layout[data-theme] .conversation-list { min-height: 80px; flex: 1 0 auto; }
html.mobile-layout[data-theme] .conversation-row { grid-template-columns: minmax(0,1fr) 44px; }
html.mobile-layout[data-theme] .conversation-open { font-size: 15px; min-height: 48px; }
html.mobile-layout[data-theme] .conversation-meta { font-size: 12px; }
html.mobile-layout[data-theme] .sidebar-nav a { min-height: 48px; font-size: 15px; }
html.mobile-layout[data-theme] .sidebar-utilities { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px; }
html.mobile-layout[data-theme] .sidebar-utilities a { min-height: 44px; font-size: 14px; }
html.mobile-layout[data-theme] .sidebar-account { font-weight: 550; color: var(--ink); }
html.mobile-layout[data-theme] .sidebar-help { display: flex; flex-wrap: wrap; gap: 12px; }

html.mobile-layout[data-theme] dialog.mobile-sheet { position: fixed; inset: auto 0 max(0px, calc(100dvh - var(--mobile-height) - var(--mobile-top))); margin: 0 auto; width: 100%; max-width: 600px; max-height: calc(var(--mobile-height) - 24px); overflow: auto; overscroll-behavior: contain; border: 0; border-radius: 24px 24px 0 0; padding: 0 24px max(20px, env(safe-area-inset-bottom)); background: var(--dialog-surface); transform: translateY(var(--sheet-drag, 0px)); animation: mobile-sheet-in var(--motion-panel) var(--ease-mobile); }
html.mobile-layout[data-theme] dialog.mobile-sheet::backdrop { animation: mobile-fade 160ms ease-out; }
html.mobile-layout[data-theme] dialog.mobile-sheet[data-entered=true] { animation: none; }
html.mobile-layout[data-theme] .mobile-sheet[data-closing=true] { animation: mobile-sheet-out 180ms ease-in forwards; }
html.mobile-layout[data-theme] .mobile-sheet[data-closing=true]::backdrop { background: transparent; transition: background 180ms; }
html.mobile-layout[data-theme] .mobile-sheet[data-dragging=true] { animation: none; transition: none; }
html.mobile-layout[data-theme] .mobile-sheet .sheet-handle { display: flex; align-items: center; justify-content: center; width: 100%; height: 36px; min-height: 36px; padding: 0; border: 0; background: transparent; touch-action: none; cursor: grab; }
html.mobile-layout[data-theme] .sheet-handle span { width: 32px; height: 4px; border-radius: 4px; background: var(--edge); }
html.mobile-layout[data-theme] .mobile-sheet > h2 { margin: 4px 0 20px; font-size: 21px; letter-spacing: -.02em; line-height: 1.3; }
html.mobile-layout[data-theme] .mobile-sheet > button:not(.sheet-handle) { display: block; width: 100%; min-height: 48px; text-align: left; padding: 12px 0; }
html.mobile-layout[data-theme] .mobile-sheet > button.sheet-close { text-align: center; border-top: 1px solid var(--line); margin-top: 16px; padding: 16px; color: var(--muted); text-decoration: none; }
html.mobile-layout[data-theme] .mobile-option-rows { display: flex; flex-direction: column; margin-bottom: 20px; }
html.mobile-layout[data-theme] .mobile-option-row { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 16px; text-align: left; min-height: 60px; border-bottom: 1px solid var(--line); border-radius: 0; padding: 14px 0; font-size: 15px; }
html.mobile-layout[data-theme] .option-value { color: var(--muted); font-size: 13px; text-align: right; max-width: 52%; overflow-wrap: anywhere; }
html.mobile-layout[data-theme] .mobile-sheet :is(input:not([type=radio]):not([type=checkbox]), select, textarea) { width: 100%; max-width: 100%; min-height: 48px; padding: 12px; border: 1px solid var(--edge); border-radius: 12px; background: var(--surface); margin-block: 8px; }
html.mobile-layout[data-theme] .mobile-sheet .evidence { background: transparent; padding: 0; margin: 0; }
html.mobile-layout[data-theme] .mobile-sheet .evidence h2 { margin-top: 16px; }
html.mobile-layout[data-theme] .mobile-sheet .source-header { align-items: center; gap: 8px; }
html.mobile-layout[data-theme] .mobile-sheet .domain { overflow-wrap: anywhere; font-size: 13px; }

html.mobile-layout[data-theme] :is(.plain-view, .plain-page) { width: 100%; margin: 24px auto 40px; }
html.mobile-layout[data-theme] :is(.plain-view, .plain-page) h1 { font-size: 28px; line-height: 1.25; letter-spacing: -.025em; }
html.mobile-layout[data-theme] :is(.plain-view, .plain-page) h2 { font-size: 20px; margin-block: 28px 12px; }
html.mobile-layout[data-theme] :is(.plain-view, .plain-page) .actions { gap: 8px; }
html.mobile-layout[data-theme] :is(.plain-view, .plain-page) :is(input:not([type=checkbox]):not([type=radio]), select, textarea) { width: 100%; max-width: 100%; font-size: 16px; }
html.mobile-layout[data-theme] :is(.plain-view, .plain-page) fieldset { min-width: 0; }
html.mobile-layout[data-theme] .login-view { min-height: calc(var(--mobile-height) - 140px); display: flex; flex-direction: column; justify-content: center; padding: 24px 0 max(24px, env(safe-area-inset-bottom)); }
html.mobile-layout[data-theme] .login-view h1 { font-size: 28px; }
html.mobile-layout[data-theme] .login-view .guest-action { min-height: 48px; }
html.mobile-layout[data-theme] .radio-option { padding-block: 12px; }
html.mobile-layout[data-theme] .pwa-settings { padding-block: 16px; border-bottom: 1px solid var(--line); }
.pwa-status { position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 15; padding: 12px 16px; border-radius: 12px; background: var(--dialog-surface, #212121); color: var(--ink, #fff); border: 1px solid var(--line, #555); font-size: 14px; }
.pwa-status:empty { display: none; }

@keyframes mobile-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mobile-reveal { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes mobile-drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes mobile-drawer-out { from { transform: translateX(var(--drawer-drag, 0px)); } to { transform: translateX(-100%); } }
@keyframes mobile-sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes mobile-sheet-out { from { transform: translateY(0); } to { transform: translateY(100%); } }
@media (max-height: 500px) {
  html.mobile-layout[data-theme] .is-chat .intro > h1 { font-size: 22px; padding-block: 12px; }
  html.mobile-layout[data-theme] .is-chat .intro .example-question { display: none; }
  html.mobile-layout[data-theme] .workspace-topbar { min-height: 48px; }
  html.mobile-layout[data-theme] .question-box textarea { max-height: 80px; }
}
html.keyboard-open.mobile-layout[data-theme] .is-chat .intro .example-question { display: none; }
@media (prefers-reduced-motion: reduce) {
  html.mobile-layout[data-theme] *, html.mobile-layout[data-theme] *::before, html.mobile-layout[data-theme] *::after, html.mobile-layout[data-theme] dialog::backdrop { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  html.mobile-layout[data-theme] button:not(:disabled):active { transform: none; }
}
@media (forced-colors: active) {
  html.mobile-layout[data-theme] :is(.question-box, .mobile-sheet, .mobile-latest) { border: 1px solid CanvasText; }
  html.mobile-layout[data-theme] .sheet-handle span { background: CanvasText; }
}
