[hidden] { display: none !important; }
.home_mode_switch button { cursor: pointer !important; }
.home_mode_switch button:focus-visible { outline: 2px solid #28a745; outline-offset: 2px; }
.results_page .home_mode_switch { display: flex; gap: 4px; margin: 0 16px 0 auto; order: 3; }
.results_page .home_mode_switch button { border: 0; background: transparent; color: #007725; cursor: pointer; padding: 8px; white-space: nowrap; }
.results_page .search_bar { order: 2; }

/* Keep the Search logo, mode switch and tagline in their shared home layout. */
body.agent_mode { display: flex; flex-direction: column; height: auto; min-height: 100vh; }
.agent_mode .search_bar, .agent_mode .home_examples, .agent_mode .home_stats,
.agent_mode .main, .agent_mode #loadres { display: none !important; }
.agent_mode.agent-has-messages .search_home { justify-content: flex-start; padding-top: 32px; }
.agent_mode .home_footer { position: static; box-sizing: border-box; margin-top: auto; padding: 32px 16px 18px; }
.agent-shell { box-sizing: border-box; width: min(620px, calc(100vw - 48px)); color: #212529; font-size: 15px; line-height: 1.6; }
.agent-shell button, .agent-menu button, .agent-menu select { font: inherit; cursor: pointer; }
.agent-shell button:disabled, .agent-menu button:disabled { opacity: .5; cursor: default; }
.agent-shell button:focus-visible, .agent-menu summary:focus-visible, .agent-menu button:focus-visible,
.agent-menu select:focus-visible, .agent-menu a:focus-visible { outline: 2px solid #28a745; outline-offset: 3px; }
.agent-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Conversation and account controls stay behind a single disclosure. */
.agent-menu { position: fixed; top: 24px; right: 24px; z-index: 10; color: #495057; font-size: 14px; line-height: 1.5; }
.agent-menu > summary { display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 38px; height: 38px; border: 1px solid #e9ecef; border-radius: 50%; background: #fff; cursor: pointer; list-style: none; }
.agent-menu > summary::-webkit-details-marker { display: none; }
.agent-menu > summary:hover, .agent-menu[open] > summary { background: #f5f6f7; }
.agent-menu > summary svg { width: 22px; height: 22px; fill: currentColor; }
.agent-menu-panel { position: absolute; top: 48px; right: 0; box-sizing: border-box; width: min(320px, calc(100vw - 32px)); max-height: calc(100dvh - 88px); overflow-y: auto; padding: 20px; background: #fff; border: 1px solid #e9ecef; border-radius: 12px; box-shadow: 0 8px 32px #00000012; }
.agent-menu-heading { display: block; color: #6c757d; font-size: 12px; margin-bottom: 6px; }
.agent-menu h1 { margin: 0 0 14px; font-size: 15px; line-height: 1.4; font-weight: 500; overflow-wrap: anywhere; }
.agent-menu-action { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; border-radius: 8px; padding: 9px 10px; margin-bottom: 20px; background: #f2f8f3; color: #218838; text-align: left; }
.agent-menu-action:hover { background: #e7f3e9; }
.agent-menu-action svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.agent-menu select { box-sizing: border-box; width: 100%; min-width: 0; padding: 8px; border: 1px solid #ced4da; border-radius: 6px; background: #fff; color: #495057; }
.agent-menu-account { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; border-top: 1px solid #e9ecef; margin-top: 20px; padding-top: 16px; }
.agent-menu-account span { color: #6c757d; font-size: 12px; overflow-wrap: anywhere; max-width: 100%; }
.agent-menu-account a { text-decoration: none; }
.agent-menu-account a:hover { text-decoration: underline; }

.agent-message { margin: 0 0 24px; overflow-wrap: anywhere; }
.agent-message-user { background: #f5f6f7; border-radius: 12px; padding: 12px 16px; margin-left: 8%; white-space: pre-wrap; }
.agent-message-assistant { padding: 0 2px; }
.agent-message-label { font-size: 12px; color: #6c757d; margin-bottom: 8px; }
.agent-message p { margin: 8px 0; }
.agent-message hr { border: 0; border-top: 1px solid #e9ecef; margin: 24px 0; }
.agent-message pre { overflow-x: auto; background: #f5f6f7; padding: 12px; border-radius: 6px; white-space: pre; }
.agent-message code { font-family: monospace; font-size: .9em; }
.agent-message blockquote { border-left: 3px solid #ced4da; margin-left: 0; padding-left: 12px; color: #495057; }
.agent-sources { margin-top: 16px; border-top: 1px solid #e9ecef; padding-top: 12px; }
.agent-message > hr + .agent-sources { border-top: 0; margin-top: 0; padding-top: 0; }
.agent-sources summary { color: #007725; cursor: pointer; }
.agent-source { display: block; border: 1px solid #e9ecef; border-radius: 8px; padding: 12px; margin: 10px 0; }
.agent-source a { font-weight: 500; }
.agent-source small { display: block; color: #6c757d; overflow-wrap: anywhere; }
.agent-source p { font-size: 13px; }
.agent-error { margin-bottom: 12px; padding: 12px; color: #8d2323; background: #fff0ef; border-radius: 8px; }
#agent-retry { margin-bottom: 16px; padding: 8px 12px; border: 1px solid #ced4da; border-radius: 8px; color: #218838; background: white; }

/* The light iFigure composer: white textarea and circular Send/Stop button. */
.agent-form { position: relative; }
.agent-form textarea { display: block; box-sizing: border-box; width: 100%; height: 98px; min-height: 98px; resize: none; padding: 12px 48px 12px 16px; border: 1px solid #ced4da; border-radius: 8px; font: inherit; font-size: 16px; line-height: 24px; color: #111827; background: #fff; transition: border-color .2s, box-shadow .2s; }
.agent-form textarea::placeholder { color: #6b7280; opacity: 1; }
.agent-form textarea:focus { outline: none; border-color: #28a745; box-shadow: 0 0 0 1px #28a745; }
#agent-send, #agent-stop { position: absolute; right: 8px; bottom: 10px; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 8px; border: 0; border-radius: 50%; background: #28a745; color: #fff; }
#agent-send:hover:not(:disabled), #agent-stop:hover:not(:disabled) { background: #218838; }
#agent-send:disabled { background: #6b7280; }
.agent-form button svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.agent-input-hint { margin: 10px 0 0; color: #6c757d; font-size: 12px; text-align: center; }

/* The same green core, glow and orbiting rings as iFigure's thinking indicator. */
.agent-activity { display: flex; align-items: center; gap: 4px; min-height: 32px; margin: 0 0 12px; }
#agent-status { color: #6c757d; font-size: 13px; }
.agent-thinking { width: 56px; height: 56px; flex: 0 0 56px; overflow: hidden; border-radius: 50%; }
.agent-thinking svg { display: block; width: 64px; height: 64px; margin: -4px; }
.agent-thinking svg * { transform-origin: 60px 60px; }
.agent-thinking-glow { animation: agent-glow 2.2s ease-in-out infinite; }
.agent-thinking-core { animation: agent-core 1.5s ease-in-out infinite; }
.agent-thinking-orbit { animation: agent-orbit 2.5s linear infinite; }
.agent-thinking-orbit-reverse { animation: agent-orbit 1.8s linear infinite reverse; }
.agent-thinking-orbit-slow { animation-duration: 3s; }
.agent-thinking-ring { animation: agent-ring 2.8s ease-in-out infinite; }
.agent-thinking-ring-outer { animation-duration: 3.4s; }
@keyframes agent-glow { 0%, 100% { transform: scale(.79); opacity: .6; } 50% { transform: scale(1.21); opacity: .2; } }
@keyframes agent-core { 0%, 100% { transform: scale(.8); } 50% { transform: scale(1.1); } }
@keyframes agent-orbit { to { transform: rotate(360deg); } }
@keyframes agent-ring { 0%, 100% { transform: scale(.78); opacity: .6; } 50% { transform: scale(1.44); opacity: .1; } }
@media (prefers-reduced-motion: reduce) { .agent-thinking svg * { animation: none; } .agent-form textarea { transition: none; } }
@media (max-width: 760px) {
    .results_page:not(.agent_mode) .home_mode_switch { position: fixed; bottom: 12px; right: 12px; background: white; border: 1px solid #e9ecef; border-radius: 20px; box-shadow: 0 2px 8px #0002; margin: 0; }
    .agent-shell { width: 100%; }
    .agent-menu { top: 16px; right: 16px; }
    .agent_mode.agent-has-messages .search_home { padding-top: 24px; }
    .agent-message-user { margin-left: 3%; }
}
