/* IUAI v3.8.1.12 Mobile Responsive Layer
   Loaded AFTER production styles. Desktop >=1024 stays unchanged. */
:root{
  --iuai-safe-top:env(safe-area-inset-top,0px);
  --iuai-safe-right:env(safe-area-inset-right,0px);
  --iuai-safe-bottom:env(safe-area-inset-bottom,0px);
  --iuai-safe-left:env(safe-area-inset-left,0px);
  --iuai-visual-height:100dvh;
}
html,body{max-width:100%;overflow-x:hidden}
img,video,canvas,svg{max-width:100%}
pre,code,.rich-text,.report-body,.source-item,.material-file-item{max-width:100%}

/* Tablet: navigation becomes a drawer, without shrinking the application canvas. */
@media (max-width:1023px){
  body.workspace-flow-active #workspace{min-height:var(--iuai-visual-height,100dvh)!important;overflow-x:hidden!important}
  body.workspace-flow-active #workspace .sidebar{transition:transform .22s ease;
    z-index:140;box-shadow:20px 0 60px rgba(0,0,0,.30);
  }
  body.workspace-flow-active #workspace .sidebar.open{}
  body.workspace-flow-active #workspace .workspace-shell{}
  body.workspace-flow-active #workspace .sidebar-toggle{display:grid;place-items:center;border-radius:10px;color:#a9c7d8}
  body.workspace-flow-active #workspace .app-main{}
  body.workspace-flow-active #workspace .research-layout{grid-template-columns:1fr!important}
  body.workspace-flow-active #workspace .research-side{position:static!important;top:auto!important}
  body.workspace-flow-active #workspace .settings-grid{grid-template-columns:1fr 1fr!important}
  body.workspace-flow-active #workspace .project-grid{grid-template-columns:1fr 1fr!important}
  body.workspace-flow-active #workspace .result-intelligence-layout{grid-template-columns:1fr!important}
  body.workspace-flow-active #workspace .result-main-col{min-width:0!important;max-width:100%!important}
  .iuai-mobile-sidebar-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.48);z-index:130;opacity:0;visibility:hidden;transition:.2s;backdrop-filter:blur(2px)}
  .iuai-mobile-sidebar-backdrop.open{opacity:1;visibility:visible}
  body.iuai-drawer-open{overflow:hidden!important}
}

/* Phone workspace */
@media (max-width:767px){
  html{scroll-padding-top:calc(58px + var(--iuai-safe-top))}
  body.workspace-flow-active{min-height:var(--iuai-visual-height,100dvh)!important;overflow-x:hidden!important}
  body.workspace-flow-active #workspace .app-topbar{z-index:90;
  }
  body.workspace-flow-active #workspace .mobile-workspace-brand{
    display:flex;align-items:center;order:1;
    color:#e8f3f8;text-decoration:none;
  }
  body.workspace-flow-active #workspace .mobile-workspace-brand img{object-fit:contain}
  body.workspace-flow-active #workspace .mobile-workspace-brand b{font-size:16px;letter-spacing:.16em;font-weight:600}
  body.workspace-flow-active #workspace .app-search{display:none}
  body.workspace-flow-active #workspace .topbar-actions{display:contents}
  body.workspace-flow-active #workspace .system-chip,
  body.workspace-flow-active #workspace .app-lang,
  body.workspace-flow-active #workspace #theme-toggle,
  body.workspace-flow-active #workspace #top-avatar{display:none}
  body.workspace-flow-active #workspace #top-new-research{
    display:inline-flex;order:2;border-radius:10px;font-size:12px;white-space:nowrap;
  }
  body.workspace-flow-active #workspace .sidebar-toggle{order:3;background:#0c1721;border:1px solid rgba(108,153,184,.22)}
  body.workspace-flow-active #workspace .app-main{
  }
  body.workspace-flow-active #workspace .app-view{min-width:0!important;width:100%!important}
  body.workspace-flow-active #workspace .page-head:not(.home-head){}
  body.workspace-flow-active #workspace .page-head:not(.home-head) h1{font-size:25px;line-height:1.2}
  body.workspace-flow-active #workspace [data-app-view="home"] .home-head{display:block;overflow:visible;
  }
  body.workspace-flow-active #workspace [data-app-view="home"] .home-head>div:first-child{display:block}
  body.workspace-flow-active #workspace [data-app-view="home"] .home-head h1{font-size:26px;line-height:1.22;white-space:normal}
  body.workspace-flow-active #workspace [data-app-view="home"] .page-kicker{margin-bottom:7px!important}
  body.workspace-flow-active .flow-core-wrap{display:none!important}
  body.workspace-flow-active #workspace .quota-pill{display:inline-flex;font-size:10px}

  body.workspace-flow-active #workspace .home-composer{padding:12px!important;border-radius:12px!important}
  body.workspace-flow-active #workspace .composer-line{min-height:0!important;display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:10px!important;padding:10px!important}
  body.workspace-flow-active #workspace .composer-line>span:first-child{display:none!important}
  body.workspace-flow-active #workspace #home-question{font-size:16px!important;line-height:1.6!important;min-height:92px!important;padding:4px 2px!important}
  body.workspace-flow-active #workspace #home-start{width:100%!important;align-self:stretch!important;height:48px!important;min-height:48px!important;font-size:14px!important}
  body.workspace-flow-active #workspace .composer-tools{display:flex!important;gap:8px!important;overflow-x:auto!important;padding-bottom:2px!important;scrollbar-width:none!important}
  body.workspace-flow-active #workspace .composer-tools::-webkit-scrollbar{display:none!important}
  body.workspace-flow-active #workspace .composer-tools button{min-width:max-content!important;height:42px!important;min-height:42px!important;padding:0 12px!important}

  body.workspace-flow-active #workspace .mode-grid{grid-template-columns:1fr!important;gap:9px!important;margin:14px 0 22px!important}
  body.workspace-flow-active #workspace .mode-card{min-height:72px!important;padding:13px!important;grid-template-columns:38px minmax(0,1fr) auto!important;gap:11px!important}
  body.workspace-flow-active #workspace .mode-card .mode-icon{width:36px!important;height:36px!important;border-radius:9px!important}
  body.workspace-flow-active #workspace .mode-card span{display:block!important;font-size:9px!important}
  body.workspace-flow-active #workspace .dashboard-grid{}
  body.workspace-flow-active #workspace .dashboard-grid .card{}
  body.workspace-flow-active #workspace .action-card>button{min-height:58px!important}
  body.workspace-flow-active #workspace .research-row{}
  body.workspace-flow-active #workspace .research-row>div:nth-child(3),body.workspace-flow-active #workspace .research-row>div:nth-child(4){display:none}

  body.workspace-flow-active #workspace input,
  body.workspace-flow-active #workspace textarea,
  body.workspace-flow-active #workspace select{font-size:16px!important}
  body.workspace-flow-active #workspace .research-form,
  body.workspace-flow-active #workspace .research-side{padding:14px!important}
  body.workspace-flow-active #workspace .field-row{grid-template-columns:1fr!important;gap:10px!important}
  body.workspace-flow-active #workspace .switch-row{flex-direction:column!important;gap:8px!important}
  body.workspace-flow-active #workspace .research-mode{min-height:60px!important;padding:12px!important}
  body.workspace-flow-active #workspace .big-action{height:52px!important;min-height:52px!important}
  body.workspace-flow-active #workspace .material-dropzone{display:grid!important;grid-template-columns:38px minmax(0,1fr)!important;gap:10px!important;padding:14px!important}
  body.workspace-flow-active #workspace .material-dropzone .btn{grid-column:1/-1!important;width:100%!important;min-height:46px!important}
  .iuai-mobile-upload-actions{grid-column:1/-1!important;display:grid!important;grid-template-columns:1fr 1fr!important;gap:8px!important;width:100%!important}
  .iuai-mobile-upload-actions button{min-height:46px!important;border-radius:10px!important;border:1px solid rgba(92,139,173,.35)!important;background:#0e1a25!important;color:#c9deea!important;font-weight:600!important}
  .iuai-mobile-upload-actions button:last-child{background:linear-gradient(110deg,#b1e9f2,#c4d6ff)!important;color:#102738!important}
  body.workspace-flow-active #workspace .material-file-item{min-width:0!important;overflow:hidden!important}
  body.workspace-flow-active #workspace .material-file-item b,
  body.workspace-flow-active #workspace .material-file-item .file-preview{white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;max-width:calc(100vw - 95px)!important}

  body.workspace-flow-active #workspace .progress-head{flex-direction:column!important;gap:10px!important}
  body.workspace-flow-active #workspace .workflow-steps{gap:10px!important;padding:12px!important;overflow-x:auto!important;scrollbar-width:none!important}
  body.workspace-flow-active #workspace .workflow-steps::-webkit-scrollbar{display:none!important}
  body.workspace-flow-active #workspace .analysis-visual{height:330px!important}

  body.workspace-flow-active #workspace .result-page-head{margin-top:16px!important}
  body.workspace-flow-active #workspace .result-head-actions{display:flex!important;width:100%!important;flex-wrap:nowrap!important;gap:7px!important;overflow-x:auto!important;padding-bottom:4px!important;scrollbar-width:none!important}
  body.workspace-flow-active #workspace .result-head-actions::-webkit-scrollbar{display:none!important}
  body.workspace-flow-active #workspace .result-head-actions .btn{display:inline-flex!important;flex:0 0 auto!important;min-height:42px!important;padding:0 12px!important;font-size:11px!important}
  body.workspace-flow-active #workspace .result-head-actions .ppt-export-btn{display:inline-flex!important}
  body.workspace-flow-active #workspace .result-tabs{
    position:sticky!important;top:calc(58px + var(--iuai-safe-top))!important;z-index:24!important;
    display:flex!important;flex-wrap:nowrap!important;overflow-x:auto!important;gap:6px!important;padding:8px 0!important;margin:8px 0!important;scrollbar-width:none!important;
  }
  body.workspace-flow-active #workspace .result-tabs::-webkit-scrollbar{display:none!important}
  body.workspace-flow-active #workspace .result-tabs button{flex:0 0 auto!important;min-height:40px!important;white-space:nowrap!important;padding:8px 11px!important}
  body.workspace-flow-active #workspace .result-detail{padding:16px 12px!important}
  body.workspace-flow-active #workspace .rich-text,
  body.workspace-flow-active #workspace .report-body{font-size:14px!important;line-height:1.72!important;overflow-wrap:anywhere!important;word-break:break-word!important}
  body.workspace-flow-active #workspace .rich-text pre,
  body.workspace-flow-active #workspace .rich-text table,
  body.workspace-flow-active #workspace .report-table-wrap,
  body.workspace-flow-active #workspace .smart-comparison{max-width:100%!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch!important}
  body.workspace-flow-active #workspace .rich-text pre{white-space:pre!important}
  body.workspace-flow-active #workspace .rich-text a,
  body.workspace-flow-active #workspace .source-item a,
  body.workspace-flow-active #workspace .source-item small{overflow-wrap:anywhere!important;word-break:break-word!important}
  body.workspace-flow-active #workspace .result-side{width:min(94vw,390px)!important;padding:max(12px,var(--iuai-safe-top)) 12px max(12px,var(--iuai-safe-bottom))!important}

  /* Data view geometry lives in workspace-flow.css, including phone cards. */
  body.workspace-flow-active #workspace .table-toolbar{gap:8px!important;flex-wrap:wrap!important}
  body.workspace-flow-active #workspace .filter-search{min-width:0!important;width:100%!important;height:44px!important}
  body.workspace-flow-active #workspace .history-table,
  body.workspace-flow-active #workspace .library-table{overflow-x:auto;-webkit-overflow-scrolling:touch}
  body.workspace-flow-active #workspace .library-header,
  body.workspace-flow-active #workspace .library-item{}
  body.workspace-flow-active #workspace .project-grid{grid-template-columns:1fr!important}
  body.workspace-flow-active #workspace .settings-grid{grid-template-columns:1fr!important;gap:12px!important}
  body.workspace-flow-active #workspace .preferences-card{grid-row:auto!important}
  body.workspace-flow-active #workspace .language-grid{grid-template-columns:1fr 1fr!important}
  body.workspace-flow-active #workspace .language-grid button,
  body.workspace-flow-active #workspace .theme-grid button,
  body.workspace-flow-active #workspace .setting-check{min-height:46px!important}
  body.workspace-flow-active #workspace .lang-popover{position:fixed!important;right:max(10px,var(--iuai-safe-right))!important;top:calc(58px + var(--iuai-safe-top))!important;max-height:65dvh!important;width:min(230px,calc(100vw - 20px))!important}

  body.workspace-flow-active #workspace .sidebar{
  }
  body.workspace-flow-active #workspace .side-nav button{min-height:50px!important}
  body.workspace-flow-active #workspace .sidebar-bottom{padding-bottom:var(--iuai-safe-bottom)!important}

  body.iuai-keyboard-open.workspace-flow-active #workspace .flow-core-wrap,
  body.iuai-keyboard-open.workspace-flow-active #workspace .quota-pill{display:none}
}

@media (max-width:380px){
  body.workspace-flow-active #workspace #top-new-research span:last-child{display:none}
  body.workspace-flow-active #workspace #top-new-research{justify-content:center}
  body.workspace-flow-active #workspace .mobile-workspace-brand b{font-size:14px}
  body.workspace-flow-active #workspace .mode-card{grid-template-columns:34px minmax(0,1fr)!important}
  body.workspace-flow-active #workspace .mode-card>span{display:none!important}
}

/* IUAI animated homepage: preserve the artwork, but make it truly phone-safe. */
@media (max-width:767px){
  body.iuai-homepage-route{min-height:var(--iuai-visual-height,100dvh);overflow-x:hidden}
  body.iuai-homepage-route header{
    padding:max(16px,var(--iuai-safe-top)) max(16px,var(--iuai-safe-right)) 12px max(16px,var(--iuai-safe-left))!important;
    min-height:calc(62px + var(--iuai-safe-top))!important;gap:8px!important;
  }
  body.iuai-homepage-route header .brand img{width:98px!important;height:auto!important}
  body.iuai-homepage-route section{min-height:100dvh!important;padding-left:max(18px,var(--iuai-safe-left))!important;padding-right:max(18px,var(--iuai-safe-right))!important}
  body.iuai-homepage-route #menu{padding:max(110px,calc(80px + var(--iuai-safe-top))) max(22px,var(--iuai-safe-right)) calc(30px + var(--iuai-safe-bottom)) max(22px,var(--iuai-safe-left))!important;overflow-y:auto!important}
  body.iuai-homepage-route #menu a{font-size:clamp(30px,10vw,42px)!important;line-height:1.15!important}
  body.iuai-homepage-route .rail{display:none!important}
  body.iuai-homepage-route footer{bottom:max(14px,var(--iuai-safe-bottom))!important;left:max(18px,var(--iuai-safe-left))!important;right:max(18px,var(--iuai-safe-right))!important}
  #iuai-home-actions-v3819{gap:5px!important;min-width:0!important}
  #iuai-home-actions-v3819 .iuai-home-action{min-height:44px!important;height:44px!important;max-height:44px!important}
  #iuai-home-lang-v3819{height:44px!important}
  #iuai-home-lang-v3819 .iuai-home-lang-toggle{width:44px!important;min-width:44px!important;max-width:44px!important;height:44px!important;padding:0 9px!important}
  #iuai-home-login-v3819{height:44px!important;min-height:44px!important;min-width:58px!important;padding:0 10px!important}
  #iuai-home-actions-v3819 #menuButton{height:44px!important;width:44px!important;min-width:44px!important;max-width:44px!important}
  #iuai-home-lang-v3819 .iuai-home-lang-menu{position:fixed!important;top:calc(62px + var(--iuai-safe-top))!important;right:max(10px,var(--iuai-safe-right))!important;width:min(220px,calc(100vw - 20px))!important;max-height:70dvh!important}
}
@media (max-width:430px){
  #iuai-home-actions-v3819 .iuai-home-theme{display:none!important}
}

/* Landscape phones: reduce vertical waste. */
@media (max-width:900px) and (max-height:520px) and (orientation:landscape){
  body.workspace-flow-active #workspace [data-app-view="home"] .home-head{}
  body.workspace-flow-active #workspace .analysis-visual{height:260px!important}
  body.iuai-homepage-route section{padding-top:90px!important;padding-bottom:70px!important;min-height:100dvh!important}
}


/* IUAI v3.8.1.12.1 AUTH MOBILE HOTFIX */
@media (max-width:767px){
  body.iuai-auth-route{min-height:100dvh!important;overflow-x:hidden!important;overflow-y:auto!important;background:#071018!important}
  body.iuai-auth-route #public-site{min-height:100dvh!important;overflow-x:hidden!important}
  body.iuai-auth-route .modal-backdrop:not([hidden]){
    display:flex!important;align-items:flex-start!important;justify-content:center!important;
    position:fixed!important;inset:0!important;z-index:1000!important;pointer-events:auto!important;
    overflow-y:auto!important;-webkit-overflow-scrolling:touch!important;
    padding:max(12px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))!important;
  }
  body.iuai-auth-route .auth-modal{
    box-sizing:border-box!important;width:min(100%,420px)!important;max-width:420px!important;
    max-height:calc(100dvh - max(24px,env(safe-area-inset-top)) - max(24px,env(safe-area-inset-bottom)))!important;
    overflow-y:auto!important;-webkit-overflow-scrolling:touch!important;pointer-events:auto!important;
    margin:auto!important;padding:22px 16px 18px!important;border-radius:18px!important;
  }
  body.iuai-auth-route .auth-modal h2{font-size:26px!important;line-height:1.2!important;margin-right:38px!important}
  body.iuai-auth-route .auth-modal>p{margin-bottom:16px!important}
  body.iuai-auth-route .modal-close{width:40px!important;height:40px!important;right:10px!important;top:10px!important;z-index:2!important}
  body.iuai-auth-route .auth-tabs button,
  body.iuai-auth-route .auth-submit{min-height:46px!important}
  body.iuai-auth-route .field input{box-sizing:border-box!important;width:100%!important;min-height:46px!important;font-size:16px!important}
  body.iuai-auth-route .google-login-container{box-sizing:border-box!important;width:100%!important;max-width:100%!important;min-width:0!important;overflow:hidden!important;justify-content:center!important}
  body.iuai-auth-route .google-login-container>div,
  body.iuai-auth-route .google-login-container iframe{max-width:100%!important}
  body.iuai-auth-route .auth-or{margin:10px 0!important}
  body.iuai-auth-route .auth-switch{padding-bottom:2px!important}
}

/* IUAI_EXPORT_REPORT_V3920 */
@media(max-width:800px){
  body.workspace-flow-active #workspace #result-comparison.smart-comparison{max-width:100%!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch!important}
  body.workspace-flow-active #workspace #result-comparison.smart-comparison table{min-width:560px!important;table-layout:fixed!important}
}
