/* A full-width study desk and a real navigation drawer on phones/tablets.
   Keep mobile structure here so legacy icon-rail rules cannot compress it. */
body .workspace-brand { display:flex; align-items:center; gap:10px; min-width:0; }
body .mobile-sidebar-toggle,body .brand-mobile,body .sidebar-backdrop { display:none; }
body .brand-desktop { color:inherit; font:inherit; }
body.sidebar-collapsed #sidebarToggle { transform:none; }

@media(max-width:800px) {
  html.mobile-scroll-locked { overflow:hidden; }
  body.mobile-sidebar-open,body.chat-expanded { overflow:hidden; }
  body .wide-shell,body.sidebar-collapsed .wide-shell { margin-left:0!important; min-width:0; }
  body .topbar,body[data-theme="dark"] .topbar { position:sticky; top:0; z-index:45; min-height:64px; padding:8px 14px; padding-top:max(8px,env(safe-area-inset-top)); gap:10px; background:#0b101aed; }
  body .workspace-brand { flex:1; gap:9px; }
  body .brand { max-width:none; font:700 16px/1.3 Manrope,Arial,sans-serif; color:#f1edf4; white-space:nowrap; }
  body .brand-desktop { display:none; }
  body .brand-mobile { display:inline; color:inherit; font:inherit; }
  body .mobile-sidebar-toggle { display:grid; place-items:center; flex:none; width:44px; height:44px; padding:0; border:1px solid #ffffff24; border-radius:12px; background:#ffffff08; color:#e8ddeb; }
  body .chat-actions { gap:6px; }
  body .chat-actions #themeToggle { width:44px!important; height:44px!important; }
  body .chat-actions #saveChat { display:block; min-height:44px; padding:9px 11px; font-size:11px; }
  body .chat-actions #exportChat { display:none; }
  body .sidebar-backdrop:not([hidden]) { display:block; position:fixed; inset:0 0 0 min(340px,calc(100vw - 40px)); z-index:80; border:0; border-radius:0; padding:0; background:#050912b3; backdrop-filter:blur(4px); cursor:default; }
  body .icon-rail,body[data-theme="dark"] .icon-rail,body.sidebar-collapsed .icon-rail { z-index:85; inset:0 auto auto 0; width:min(340px,calc(100vw - 40px))!important; height:100dvh; padding:22px 18px max(18px,env(safe-area-inset-bottom))!important; padding-top:max(22px,env(safe-area-inset-top))!important; align-items:stretch; overflow-y:auto; overscroll-behavior:contain; transform:translateX(-100%); visibility:hidden; background:#0d1421; border-right:1px solid #ffffff1c; box-shadow:none; transition:transform .22s ease,visibility .22s; }
  body.mobile-sidebar-open .icon-rail { transform:translateX(0); visibility:visible; box-shadow:20px 0 70px #0005; }
  body .icon-rail .rail-heading { display:flex; flex-direction:row; justify-content:space-between; align-items:center; gap:12px; padding:0 0 24px; flex-shrink:0; }
  body .icon-rail .rail-logo,body.sidebar-collapsed .icon-rail .rail-logo { display:flex; font-size:18px; }
  body .icon-rail .rail-wordmark { display:block; }
  body .icon-rail .rail-wordmark small { font-size:10px; }
  body .icon-rail #sidebarToggle { display:grid; place-items:center; width:44px; height:44px; min-height:44px; font-size:23px!important; padding:0; }
  body .icon-rail .rail-nav { display:grid; flex-shrink:0; gap:8px; }
  body .icon-rail .rail-nav button,body.sidebar-collapsed .icon-rail .rail-nav button { display:flex; justify-content:flex-start; min-height:48px; padding:12px; gap:12px; color:#eee5f1; }
  body .icon-rail .rail-nav button>span:first-child { width:22px; font-size:21px!important; }
  body .icon-rail .rail-nav button .nav-label { display:inline!important; width:auto; font:500 14px/1.5 Manrope,Arial,sans-serif!important; }
  body .icon-rail .rail-recents { display:block; flex:1; min-height:80px; margin:30px 0 22px; }
  body .icon-rail .rail-recents>p { font-size:10px; letter-spacing:.12em; }
  body .icon-rail #sidebarRecentChats>span { display:block; padding:10px 8px; font-size:12px; line-height:1.7; }
  body .icon-rail .sidebar-recent { min-height:44px; font-size:13px; }
  body .icon-rail .sidebar-recent-actions { opacity:1; }
  body .icon-rail .sidebar-recent-actions button { min-height:40px; padding:8px; font-size:11px; }
  body .icon-rail #accountCard:not([hidden]) { display:grid!important; flex-shrink:0; grid-template-columns:36px minmax(0,1fr); align-items:center; gap:10px; width:100%; padding:16px 0 0; margin-top:auto; border-color:#ffffff1c; }
  body .icon-rail #accountCard[hidden] { display:none!important; }
  body .icon-rail #accountCard:not(.is-signed-in) { grid-template-columns:minmax(0,1fr); }
  body .icon-rail #accountInitials:not([hidden]) { display:grid!important; width:36px; height:36px; background:#65405c; font-size:11px; box-shadow:none; }
  body .icon-rail #accountButton { display:flex; width:100%; min-height:68px; padding:12px; gap:9px; justify-content:space-between; }
  body .icon-rail #accountButton::before { content:none; }
  body .icon-rail #accountButton .account-copy { display:grid; gap:4px; }
  body .icon-rail .account-name-row { display:flex; flex-direction:column; align-items:flex-start; gap:5px; }
  body .icon-rail #accountName { display:block; max-width:100%; font:600 14px/1.5 Manrope,Arial,sans-serif!important; }
  body .icon-rail #accountStatus { font:400 11px/1.5 Manrope,Arial,sans-serif; }
  body .icon-rail #accountAction { display:block; font-size:10px; min-width:18px; }
  body .icon-rail .trial-remaining { padding:4px 7px; font:500 10px/1.4 Manrope,Arial,sans-serif!important; }
  body .icon-rail #accountMenu { position:static; grid-column:1/-1; width:100%; margin:0; padding:6px; border-radius:12px; box-shadow:none; }
  body .icon-rail #accountMenu button { min-height:44px; font-size:13px; }
  body .app-stage { --desk-height:clamp(460px,66svh,620px); grid-template-columns:minmax(0,1fr); padding:20px 14px; gap:20px; min-height:0; }
  body #welcomePanel { padding:8px 6px 4px; }
  body .heart-welcome-copy { display:block; max-width:100%; }
  body .study-hero .eyebrow { margin:0 0 14px; font-size:8px; letter-spacing:.15em; }
  body .study-hero h1 { font-size:clamp(32px,8vw,45px); line-height:1.12; margin:0 0 12px; }
  body .study-hero h1 em { display:block; }
  body .heart-welcome-copy>p:last-of-type { max-width:360px; font-size:13px; line-height:1.65; }
  body .study-hero-action { margin:16px 0 4px; min-height:44px; padding:7px 9px 7px 16px; font-size:12px; gap:20px; }
  body .study-hero-action>span { width:28px; height:28px; font-size:17px; }
  body .chat-canvas { padding:16px; border-radius:20px; }
  body .study-desk-heading { gap:10px; padding-bottom:14px; margin-bottom:14px; }
  body .study-desk-heading>div { flex:1; }
  body .study-desk-heading .desk-mark,body .desk-tag { display:none; }
  body .study-desk-heading h2 { font-size:15px; line-height:1.4; }
  body .study-desk-heading p { font-size:11px; line-height:1.4; }
  body .desk-toggle { min-width:44px; width:auto; min-height:44px; padding:9px 10px; gap:6px; border-radius:11px; font-size:11px; }
  body .expand-label { display:inline; white-space:nowrap; }
  body .expand-icon { font-size:18px; }
  body .messages { margin-bottom:14px; gap:18px; }
  body .message { gap:8px; }
  body .bubble { padding:12px 14px; }
  body .reply-content { font-size:15px; line-height:1.7; overflow-wrap:anywhere; }
  body .composer { gap:6px; padding:7px; flex-wrap:wrap; }
  body .composer textarea { font-size:16px; line-height:1.5; min-height:44px; max-height:140px; max-height:min(140px,28dvh); padding:10px 3px; }
  body #attachButton { width:44px; height:44px; }
  body .send-button { width:44px; height:44px; flex-basis:44px; }
  body .composer .chart-image-mode { order:-1; flex:0 0 100%; max-width:none; padding:7px 9px; font-size:10px; }
  body .composer .chart-image-mode button { margin-left:auto; min-width:30px; min-height:24px; font-size:20px; }
  body #composerMenu { width:min(280px,calc(100vw - 58px)); min-width:0; max-height:60dvh; overflow-y:auto; bottom:58px; }
  body #composerMenu button { min-height:48px; font-size:13px; }
  body .composer-note { margin-top:10px; font-size:10px; line-height:1.5; }
  body .quick-panel { padding:20px; border-radius:20px; }
  body .quick-panel h2 { font-size:27px; }
  body .focus-toggle { width:44px; height:44px; }
  body .quick-copy { font-size:13px; }
  body .prompt-list { grid-template-columns:1fr; margin-top:14px; }
  body .prompt-list button { min-height:68px; }
  body .prompt-copy strong { font-size:13px; }
  body .prompt-copy small { font-size:11px; }
  body .site-footer { align-items:flex-start; flex-direction:column; padding:18px 20px max(20px,env(safe-area-inset-bottom)); gap:8px; font-size:10px; }
  body .site-footer nav { gap:0 18px; }
  body .site-footer a,body .site-footer button { min-height:44px; display:inline-flex; align-items:center; font-size:12px; }
  body .auth-modal,body .support-modal { padding:16px; }
  body .chart-viewer { padding:12px; }
  body .chart-viewer-dialog { max-height:calc(100dvh - 24px); padding:12px; border-radius:18px; }
  body .chart-viewer-canvas img { width:100%; min-width:0; }
  body .auth-dialog,body .support-dialog { padding:28px 22px; max-height:calc(100dvh - 32px); border-radius:20px; }
  body .auth-close,body .support-close,body .close-panel { width:44px; height:44px; }
  body .auth-copy,body .support-dialog>p { font-size:14px; line-height:1.65; }
  body .auth-form input { font-size:16px; }
  body #googleAuth,body .auth-form button[type="submit"] { min-height:48px; font-size:14px; }
  body .right-panel { width:100%; max-width:420px; padding:22px; }
  /* True full-screen chat: no side rail, page offset, or hidden restore target. */
  body.chat-expanded .topbar,body.chat-expanded .site-footer { display:none; }
  body.chat-expanded .app-stage { height:auto; min-height:0; padding:0; }
  body.chat-expanded .chat-canvas { position:fixed; z-index:70; left:0; right:0; top:var(--chat-viewport-top,0px); width:100%; height:var(--chat-viewport-height,100dvh); min-height:0; max-height:none; margin:0; padding:14px; padding-top:max(14px,env(safe-area-inset-top)); padding-bottom:max(12px,env(safe-area-inset-bottom)); border:0; border-radius:0; background:var(--studio-panel); box-shadow:none; -webkit-backdrop-filter:none; backdrop-filter:none; }
  body.chat-expanded .chat-canvas .messages { flex:1; min-height:0; overscroll-behavior:contain; }
  body.chat-expanded .study-desk-heading { flex-shrink:0; }
  body.chat-expanded .composer-note { margin-top:8px; }
}
@media(max-width:360px) {
  body .topbar,body[data-theme="dark"] .topbar { padding-inline:10px; gap:5px; }
  body .workspace-brand { gap:6px; }
  body .brand { font-size:15px; }
  body .chat-actions #saveChat { padding-inline:8px; font-size:10px; }
  body .app-stage { padding-inline:10px; }
  body .chat-canvas { padding:13px; }
  body .study-desk-heading { gap:6px; }
  body .study-desk-heading p { display:none; }
  body .desk-toggle { font-size:10px; padding-inline:8px; }
}
@media(prefers-reduced-motion:reduce) { body .icon-rail { transition:none; } }
