/* Workspace interactions own these states; Voice 1 has no matching selectors. */
html, body { max-width: 100%; overscroll-behavior-y: none; }
body { overflow-x: hidden; }
body:has(#appRoot.app:not(.hidden)) { overflow-y: hidden; }
html body #appRoot.app { min-height: 0; height: 100dvh; overflow: hidden; }
html body #appRoot.app .chat-area, html body #mathStudioPanel, .drawer-chat-section, .math-drawer-notes-section { overscroll-behavior: contain; }
html body #appRoot.app .chat-area, html body #mathStudioPanel { touch-action: manipulation; }
button, summary, #userInput, .message-editor textarea { touch-action: manipulation; }
.workspace-drawer-backdrop { display: none; }
.math-studio-fullscreen-btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px; border: 0; border-radius: 8px; background: transparent; color: #187dad; font: 600 11px Inter, system-ui, sans-serif; cursor: pointer; }
.math-studio-fullscreen-btn svg { width: 17px; height: 17px; }
html body #appRoot.app:has(> #mathStudioPanel:not(.hidden)) > #mathStudioPanel .math-studio-head { grid-template-columns: minmax(0, 1fr) auto auto auto !important; }
.studio-composer-dock, .studio-chat-sheet { display: none; }
html body #profanityLock { display: none !important; }
html body #appRoot.app.studio-integrated > #sideDrawer,
html body #appRoot.app.studio-integrated > .topbar,
html body #appRoot.app.studio-integrated > .workspace-drawer-backdrop { visibility: hidden !important; pointer-events: none !important; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen {
  position: fixed !important; inset: 0 !important; z-index: 110 !important; width: 100% !important; max-width: none !important; height: 100dvh !important; margin: 0 !important;
  border-radius: 0 !important; padding-bottom: 0 !important; overscroll-behavior: contain;
}
/* Older studio geometry uses :has() IDs; match its specificity deliberately. */
html body #appRoot.app:has(> #mathStudioPanel.studio-fullscreen) > #mathStudioPanel.studio-fullscreen { position: fixed !important; inset: 0 !important; width: 100% !important; max-width: none !important; height: 100dvh !important; max-height: 100dvh !important; margin: 0 !important; padding: 0 !important; border-radius: 0 !important; overflow: hidden !important; z-index: 110 !important; transform: none !important; }
html body #appRoot.app:has(> #mathStudioPanel.studio-fullscreen) > #mathStudioPanel.studio-fullscreen .math-studio-head { position: sticky !important; top: 0 !important; z-index: 4 !important; background: var(--studio-head-surface, #f2faffed) !important; backdrop-filter: blur(15px); }
html body #appRoot.app #mathStudioPanel.studio-fullscreen #mathStudioResizeHandle { display: none !important; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen .math-studio-head { position: sticky; top: 0; z-index: 4; background: var(--studio-head-surface, #f2faffed); backdrop-filter: blur(15px); }
body.ui-dark-mode { --studio-head-surface: #122235ed; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen .studio-composer-dock { display: block; position: fixed; z-index: 12; bottom: 0; left: 50%; transform: translateX(-50%); width: min(890px, calc(100% - 28px)); height: calc(142px + env(safe-area-inset-bottom)); pointer-events: none; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen .studio-composer-dock::before { content: none !important; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen .studio-chat-reveal { position: absolute; bottom: calc(116px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: block; pointer-events: auto; padding: 7px 18px; color: #2377a2; border: 1px solid #c8e4f099; border-radius: 13px 13px 0 0; background: #faffffe6; box-shadow: 0 -4px 18px #36586d12; backdrop-filter: blur(16px); font: 600 12px Inter, system-ui, sans-serif; cursor: pointer; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen .studio-chat-reveal::after { content: " ›"; display: inline-block; margin-left: 7px; transition: transform .25s ease; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen .studio-chat-reveal[aria-expanded="true"]::after { transform: rotate(90deg); }
html body #appRoot.app #mathStudioPanel.studio-fullscreen .studio-chat-sheet:not([hidden]) { display: flex; position: fixed; z-index: 11; left: 50%; bottom: calc(140px + env(safe-area-inset-bottom)); width: min(890px, calc(100% - 28px)); height: min(55dvh, calc(100dvh - 225px)); transform: translateX(-50%); overflow: hidden; border: 1px solid #bddce8a8; border-bottom: 0; border-radius: 18px 18px 0 0; background: #f7fcfff0; box-shadow: 0 -12px 38px #253a4b17; backdrop-filter: blur(20px); animation: workspaceSheet .25s ease-out; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen #chatArea { display: block !important; width: 100% !important; min-height: 0 !important; height: 100% !important; margin: 0 !important; padding: 20px 18px 32px !important; overflow-y: auto !important; background: transparent !important; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen form#chatForm.reference-composer { display: block !important; position: absolute !important; isolation: isolate; pointer-events: auto; left: 0 !important; right: 0 !important; bottom: calc(24px + env(safe-area-inset-bottom)) !important; width: 100% !important; margin: 0 !important; transform: none !important; background: rgba(255,255,255,.92) !important; border: 1px solid #dcebf0c2 !important; box-shadow: 0 8px 24px rgba(40,70,90,.12) !important; backdrop-filter: blur(7px) saturate(1.04) !important; -webkit-backdrop-filter: blur(7px) saturate(1.04) !important; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen form#chatForm.reference-composer::before { content: ""; position: absolute; z-index: -1; inset: -5px -6px 0; border-radius: 20px; background: rgba(231,245,255,.12); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); pointer-events: none; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen form#chatForm.reference-composer > .composer-safety-info { display: none !important; }
html body.ui-dark-mode #appRoot.app #mathStudioPanel.studio-fullscreen .studio-chat-sheet,
html body.ui-dark-mode #appRoot.app #mathStudioPanel.studio-fullscreen .studio-chat-reveal,
html body.ui-dark-mode #appRoot.app #mathStudioPanel.studio-fullscreen form#chatForm.reference-composer { background: rgba(19,38,56,.94) !important; color: #d7efff; border-color: #3b647a88 !important; backdrop-filter: blur(7px) saturate(1.04) !important; -webkit-backdrop-filter: blur(7px) saturate(1.04) !important; }
html body #appRoot.app form#chatForm.reference-composer { bottom: calc(var(--workspace-footer-height, 22px) + 8px + env(safe-area-inset-bottom)) !important; }
html body #appRoot.app form#chatForm.reference-composer > .composer-safety-info { display: flex !important; position: absolute !important; top: calc(100% + 5px) !important; bottom: auto !important; left: 0 !important; right: 0 !important; width: 100% !important; height: auto !important; min-height: 0 !important; padding: 0 !important; margin: 0 !important; transform: none !important; justify-content: center; background: transparent !important; background-image: none !important; border: 0 !important; box-shadow: none !important; backdrop-filter: none !important; z-index: 10; }
html body #appRoot.app form#chatForm.reference-composer .composer-safety-disclosure { width: 100%; background: transparent !important; }
html body #appRoot.app form#chatForm.reference-composer .composer-safety-summary { justify-content: center; background: transparent !important; box-shadow: none !important; font-size: 10px !important; line-height: 17px !important; padding: 0 !important; transition: opacity .18s ease, filter .18s ease; }
html body #appRoot.app form#chatForm.reference-composer .footer-text-collision .composer-safety-summary { opacity: 0; filter: blur(2px); pointer-events: none; }
html body #appRoot.app form#chatForm.reference-composer .composer-safety-disclosure[open] .account-safety-details { max-height: 42dvh; overflow-y: auto; padding: 14px; margin-top: 8px; border-radius: 12px; background: #fffffff5; box-shadow: 0 7px 24px #14233a15; }
html body.ui-dark-mode #appRoot.app form#chatForm.reference-composer .composer-safety-disclosure[open] .account-safety-details { background: #182435f5; color: #d7e3f4; }
.message-actions { display: flex; align-items: center; gap: 5px; margin-top: 5px; opacity: .75; color: #73818f; }
.message-actions button { display: grid; place-items: center; width: 27px; height: 27px; padding: 5px; border: 0; border-radius: 7px; color: inherit; background: transparent; cursor: pointer; transition: color .16s ease, background .16s ease, transform .16s ease; }
.message-actions button svg { display: block; width: 16px; height: 16px; }
.message-actions button:hover, .message-actions button[aria-pressed="true"] { color: #8851c1; background: #aa7ac818; }
.math-chat-message .message-actions button:hover, .math-chat-message .message-actions button[aria-pressed="true"] { color: #087dbe; background: #0ea5e919; }
html body #appRoot.app.math-mode #mathStudioPanel.studio-fullscreen :is(button:has(svg):hover, button:has(svg):focus-visible) { color: #087dbe !important; background-color: rgba(14,165,233,.12) !important; }
html body #appRoot.app.math-mode #mathStudioPanel.studio-fullscreen .message-actions button:hover,
html body #appRoot.app.math-mode #mathStudioPanel.studio-fullscreen .message-actions button[aria-pressed="true"] { color: #087dbe !important; background: rgba(14,165,233,.12) !important; }
html body #appRoot.app.math-mode #mathStudioPanel.studio-fullscreen #chatSubmitBtn.stop-generating { border: 1px solid rgba(125,211,252,.68) !important; background: linear-gradient(145deg, #7dd3fc, #0ea5e9 58%, #0369a1) !important; box-shadow: 0 0 0 3px rgba(14,165,233,.12), 0 8px 22px rgba(2,132,199,.28), inset 0 1px 0 rgba(255,255,255,.38) !important; }
html body #appRoot.app.math-mode #mathStudioPanel.studio-fullscreen #chatSubmitBtn.stop-generating:hover { background: linear-gradient(145deg, #bae6fd, #38bdf8 58%, #0284c7) !important; box-shadow: 0 0 0 4px rgba(14,165,233,.17), 0 10px 24px rgba(2,132,199,.34), inset 0 1px 0 rgba(255,255,255,.48) !important; }
.message-actions button:focus-visible { outline: 2px solid #8b63bb; outline-offset: 2px; }
.message-actions button:disabled { opacity: .45; cursor: wait; }
.message-actions .is-working svg { animation: workspaceWorking 1s ease-in-out infinite; }
.msg.user .message-actions { justify-content: flex-start; color: #73818f; opacity: 0; transition: opacity .18s ease; }
.msg.user:hover .message-actions, .msg.user:focus-within .message-actions { opacity: .7; }
html body #appRoot.app .msg.user { display: flex; flex-direction: column; align-items: flex-end; overflow: visible; padding: 0 !important; border: 0 !important; background: transparent !important; background-image: none !important; box-shadow: none !important; filter: none !important; }
html body #appRoot.app .msg.user > .message-content { display: block; width: fit-content; max-width: 100%; box-sizing: border-box; padding: 10px 14px; border-radius: 12px; background: var(--user); color: #fff; }
html body #appRoot.app .msg.user > .message-expand-btn { align-self: flex-end; margin-right: 14px !important; }
html body #appRoot.app .msg.user > .message-actions { align-self: flex-start; justify-content: flex-start; margin-top: 2px; margin-left: 3px; padding: 0; }
.message-editor { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.message-editor textarea { grid-column: 1 / -1; width: 100%; min-height: 90px; box-sizing: border-box; resize: vertical; padding: 10px; border: 1px solid #c0cddd; border-radius: 9px; font: inherit; color: #182235; background: #ffffffed; }
.message-editor button { padding: 7px 11px; border: 1px solid #c4d5e5; border-radius: 8px; color: #253c55; background: #f1f6fb; cursor: pointer; }
.msg.is-editing > .message-content, .msg.is-editing > .message-expand-btn { display: none; }
.workspace-toast { position: fixed; z-index: 1500; left: 50%; bottom: 150px; transform: translate(-50%, 8px); max-width: min(440px, calc(100% - 36px)); padding: 10px 14px; border: 1px solid #d1deeb; border-radius: 12px; color: #263548; background: #fffffff2; box-shadow: 0 7px 24px #172e4319; backdrop-filter: blur(15px); font: 12px/1.5 Inter, system-ui, sans-serif; pointer-events: none; opacity: 0; transition: opacity .2s ease, transform .2s ease; }
.workspace-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.workspace-copy-helper { position: fixed; left: -9999px; top: 0; }
html body #appRoot.app #mathStudioPanel.studio-fullscreen .studio-composer-dock { height: calc(120px + var(--workspace-footer-height, 22px) + env(safe-area-inset-bottom)); }
html body #appRoot.app #mathStudioPanel.studio-fullscreen .studio-chat-reveal { bottom: calc(94px + var(--workspace-footer-height, 22px) + env(safe-area-inset-bottom)); }
html body #appRoot.app #mathStudioPanel.studio-fullscreen .studio-chat-sheet:not([hidden]) { bottom: calc(118px + var(--workspace-footer-height, 22px) + env(safe-area-inset-bottom)); height: min(55dvh, calc(100dvh - 203px - var(--workspace-footer-height, 22px))); }
html body #appRoot.app #mathStudioPanel.studio-fullscreen form#chatForm.reference-composer { bottom: calc(2px + var(--workspace-footer-height, 22px) + env(safe-area-inset-bottom)) !important; }
@keyframes workspaceSheet { from { opacity: 0; clip-path: inset(90% 0 0); } to { opacity: 1; clip-path: inset(0); } }
@keyframes workspaceWorking { 50% { transform: scale(.88); opacity: .5; } }
@media (max-width: 700px) {
  html body #appRoot.app #userInput, html body #appRoot.app input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), html body #appRoot.app textarea, html body #appRoot.app [contenteditable="true"] { font-size: max(16px, 1rem) !important; }
  html body #appRoot.app .msg.user .message-actions { opacity: .7; }
  html body #appRoot.app .message-actions button { width: 28px; height: 28px; padding: 5px; }
  html body #appRoot.app .message-actions button svg { width: 16px; height: 16px; }
  html body #appRoot.app .math-studio-fullscreen-btn { display: none !important; }
  html body #appRoot.app:has(> #mathStudioPanel:not(.hidden)) > #mathStudioPanel .math-studio-head { grid-template-columns: minmax(0, 1fr) auto auto !important; }
  html body #appRoot.app > aside#sideDrawer.drawer-gesture { display: flex !important; visibility: visible !important; opacity: 1 !important; left: 0 !important; width: min(334px, 88vw) !important; max-width: 88vw !important; transform: translateX(calc((var(--drawer-gesture-progress, 0) - 1) * 100%)) !important; transition: none !important; z-index: 310 !important; }
  html body #appRoot.app > aside#sideDrawer.drawer-gesture.drawer-gesture-settle { transition: transform .21s cubic-bezier(.22,.8,.3,1) !important; }
  html body #appRoot.app > .workspace-drawer-backdrop { position: fixed; inset: 0; z-index: 299; padding: 0; border: 0; background: #13213638; backdrop-filter: blur(1px); touch-action: pan-y; }
  html body #appRoot.app.drawer-gesture-active > .workspace-drawer-backdrop { display: block; opacity: var(--drawer-gesture-progress); }
  html body #appRoot.app:has(> #sideDrawer:not(.hidden):not(.is-collapsed)) > .workspace-drawer-backdrop { display: block; }
  html body #appRoot.app > aside#sideDrawer:not(.hidden):not(.is-collapsed) { z-index: 310 !important; }
}
@media (prefers-reduced-motion: reduce) {
  .message-actions button, .workspace-toast, .composer-safety-summary { transition: none !important; }
  .studio-chat-sheet, .message-actions .is-working svg { animation: none !important; }
}
