/* Screen size and input capabilities adapt on iOS, Android, and narrow windows. */
:root{--app-height:100dvh;--app-top:0px;--header-height:68px}
.sidebar-dismiss{display:none}
@media(max-width:900px){
 body{height:var(--app-height);position:relative;top:var(--app-top)}
 header{height:var(--header-height);min-height:var(--header-height);padding-top:env(safe-area-inset-top);padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right))}
 main,body.sidebar-collapsed main{display:grid;grid-template-columns:minmax(0,1fr);height:calc(var(--app-height) - var(--header-height));min-height:0;overflow:hidden;padding:0}
 .chat{height:100%;min-height:0;overflow:hidden}
 #conversationScroll{overflow-x:hidden;-webkit-overflow-scrolling:touch}
 .chat-sidebar{top:calc(var(--app-top) + var(--header-height));bottom:auto;height:calc(var(--app-height) - var(--header-height));width:min(310px,88vw);padding-bottom:max(16px,env(safe-area-inset-bottom));z-index:42}
 body.sidebar-open .chat-sidebar{display:flex}
 body.sidebar-open .sidebar-dismiss{display:block;position:fixed;inset:var(--header-height) 0 0;background:#10272066;z-index:41}
 #showSidebar,#sidebarToggle{min-width:44px;min-height:44px;flex:none}
 #showSidebar{display:block}
 .chat-heading{padding:4px 12px;min-height:52px;flex-shrink:0}
 .chat-heading h1{font-size:15px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
 .chat-sidebar input,.filters input,.filters select,#chatAtlas{font-size:16px}
 .history-row button,.site-menu .nav,.account-menu summary{min-height:44px}
 .image-viewport:not(.is-expanded){touch-action:pan-y pinch-zoom}
 .image-viewport.is-expanded{top:var(--app-top);height:calc(var(--app-height) - var(--viewer-note-height,0px));width:100%;touch-action:none}
 .workspace .image-viewport.is-expanded #mainImage,.workspace .image-viewport.is-expanded #imageStage{max-height:calc(var(--app-height) - var(--viewer-note-height,0px) - 24px)}
 .zoomtools button{min-width:44px;height:44px}.zoomtools #zoomReset{min-width:54px}
 .image-viewport.is-expanded .zoomtools{top:max(8px,env(safe-area-inset-top));right:max(8px,env(safe-area-inset-right));bottom:auto}
 .composer-area{padding-bottom:max(8px,env(safe-area-inset-bottom));flex:none}
 #query{font-size:16px;scroll-margin-bottom:12px}
 #send,.mic{min-height:44px;min-width:44px}
 #send{width:44px;height:44px;flex:none}
 dialog{max-height:calc(var(--app-height) - 24px);overflow:auto}
 dialog .close,#sourceContextDialog .close,#anatomyPanel .close{min-width:44px;min-height:44px}
}
@media(max-width:680px){
 :root{--header-height:calc(60px + env(safe-area-inset-top))}
 header{gap:8px;flex-wrap:nowrap}.brand-logo{width:42px;height:42px;object-fit:contain}
 .site-menu summary{min-width:44px;min-height:44px;text-align:center;padding:5px}
 .home-control{min-height:44px;padding:8px;gap:5px}.public{display:none}
 #messages{padding:16px 12px 0}#conversationScroll>.workspace{padding:16px 12px}
 .message{font-size:16px;overflow-wrap:anywhere;margin-bottom:20px}.message.user{max-width:94%;padding:10px 12px}
 .workspace-top{align-items:flex-start;gap:8px}.workspace-top h2{font-size:19px;line-height:1.4}
 #share{min-height:44px;min-width:44px}.workspace-top>div{min-width:0}
 .figure-meta{gap:6px}.figure-meta #sourceTag{width:100%;font-size:11px;letter-spacing:.6px}
 .figure-meta #viewTag{font-size:12px;overflow-wrap:anywhere}
 .figure-actions{width:100%;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:5px;margin:4px 0 0}
 .figure-meta .figure-actions .source-context-control{white-space:normal;font-size:12px;line-height:1.3;min-height:44px;padding:6px 4px;margin:0}
 .workspace .image-viewport:not(.is-expanded){height:clamp(280px,55svh,500px);min-height:0;border-radius:8px}
 .image-and-labels,.image-and-labels.labels-open{display:block;position:relative}
 .anatomy-panel{position:absolute;z-index:6;top:8px;right:8px;width:min(220px,calc(100% - 16px));max-height:240px;padding:10px;box-shadow:0 5px 24px #0003}
 #anatomyPanel #structureList{max-height:120px}#anatomyPanel .tiny{display:none}
 #anatomyPanel .structure,.floating-anatomy .structure{min-height:44px;font-size:13px;padding:9px 5px}
 #anatomyPanel .close{min-height:36px;min-width:36px}
 .under-image{align-items:flex-start;font-size:12px;line-height:1.5}.under-image label{min-height:44px;align-items:flex-start;padding-top:4px}
 .under-image input{width:18px;height:18px;margin:0 4px}
 .workspace .alternative-images,.workspace.is-empty.has-related>.alternatives .alternative-images{display:grid;grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:78%;gap:10px;overflow-x:auto;scroll-snap-type:x proximity;padding:4px 3px 12px;overscroll-behavior-x:contain}
 .alternative-images .card{scroll-snap-align:start}.workspace .alternative-images .card h4{font-size:14px}
 .workspace .results{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
 .filters{display:grid;grid-template-columns:1fr 1fr;gap:8px}.filters select{min-width:0;max-width:100%;width:100%;min-height:44px}
 #librarySearch{grid-column:1/-1;min-width:0;width:100%;font-size:16px}.card-text{padding:9px}.card small{font-size:10px}
 .explore-options{grid-template-columns:1fr;gap:8px}.explore-options button{min-height:56px;font-size:15px;padding:12px 14px}.explore-group{margin-top:20px}
 .home-explore{padding-bottom:16px}.home-browse{margin-top:18px}
 .composer-area{padding:6px 10px max(6px,env(safe-area-inset-bottom));z-index:12}
 #chatForm{padding:7px 9px;border-radius:18px}#query{height:40px;min-height:40px;max-height:90px;padding:4px 2px}
 .composer-actions{gap:4px;margin-top:0}#chatAtlas{min-width:0;width:auto;max-width:45%;min-height:40px;margin:0 0 0 auto;padding:5px;font-size:16px}
 .mic{font-size:13px;gap:3px}#voiceStatus{font-size:12px}
 .floating-anatomy{top:65px;right:8px;width:min(260px,calc(100% - 16px));max-height:min(48dvh,350px)}
 .floating-help{display:none}.floating-content{max-height:240px}.floating-anatomy #structureList{max-height:150px}.floating-collapse{width:44px;height:44px}
 #sourceContextDialog,#costEstimatesDialog,dialog{width:calc(100% - 20px);padding:18px;max-height:calc(var(--app-height) - 24px)}
 .query-progress{font-size:13px;padding:12px}.query-progress ol{overflow-wrap:anywhere}
 footer{padding:18px 0;font-size:11px}
}
@media(max-width:900px) and (max-height:500px){
 .chat-heading{min-height:44px}.chat-heading h1{font-size:13px;-webkit-line-clamp:1}
 .composer-area{padding-top:4px;padding-bottom:4px}#query{height:36px;min-height:36px}#chatForm{padding-top:4px;padding-bottom:4px}
 .floating-anatomy{max-height:calc(var(--app-height) - 80px)}.floating-content{max-height:calc(var(--app-height) - 150px)}
}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}.card,#toast{transition:none}.query-progress:not(.finished) summary:before{animation:none}}

/* Keep the phone home screen focused on immediately usable atlas shortcuts. */
@media(max-width:680px){
 body.home-mode #messages{display:none}
 body.home-mode #conversationScroll>.workspace{padding:12px}
 body.home-mode .home-explore{padding:0}
 body.home-mode .explore-group{margin-top:12px}
 body.home-mode .explore-group h3{margin-bottom:6px;font-size:13px}
 body.home-mode .explore-options{grid-template-columns:repeat(2,minmax(0,1fr));gap:7px}
 body.home-mode .explore-options button{min-height:52px;padding:8px 10px;font-size:13px;line-height:1.3;gap:4px}
 body.home-mode .home-browse{min-height:44px;margin-top:12px;padding:10px 12px;font-size:14px}
 body.home-mode .home-browse small{display:none}
}
@media(max-width:680px) and (max-height:700px){
 body.home-mode .home-explore>.eyebrow,body.home-mode .explore-group h3{display:none}
 body.home-mode .explore-group{margin-top:0;margin-bottom:7px}
 body.home-mode .home-browse{margin-top:8px}
}
@media(max-width:900px) and (max-height:500px){
 body.home-mode #messages{display:none}
 body.home-mode #conversationScroll>.workspace{padding:8px 12px}
 body.home-mode .home-explore{padding:0}
 body.home-mode .home-explore>.eyebrow,body.home-mode .explore-group h3{display:none}
 body.home-mode .explore-group{margin:0 0 6px}
 body.home-mode .explore-options{grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
 body.home-mode .explore-options button{min-height:44px;padding:5px 8px;font-size:12px;line-height:1.25}
 body.home-mode .home-browse{min-height:44px;margin:0;padding:8px 12px}
 body.home-mode .home-browse small{display:none}
}
