
/* =========================================================
   v1.31 — Mobile native composition
   - no desktop toolbar squeezed into the phone
   - no stale global scrim
   - edge-to-edge tab bar
   - mobile density/typography hierarchy
   ========================================================= */
@media (max-width:780px){
  :root{
    --v131-safe-top:0px;
    --v131-safe-bottom:env(safe-area-inset-bottom,0px);
    --v131-appbar:54px;
    --v131-tabbar:58px;
    --top:calc(var(--v131-appbar) + var(--v131-safe-top));
    --mobile-nav:var(--v131-tabbar);
    --mobile-edge:16px;
  }
  /* In normal Safari/QuickLook the browser already reserves the status area.
     Only standalone/fullscreen apps consume the iOS top safe-area themselves. */
  @media (display-mode:standalone){:root{--v131-safe-top:env(safe-area-inset-top,0px)}}

  html,body{background:var(--surface-canvas)!important;color:var(--text-primary)!important}
  body{overflow:hidden!important}
  .app{grid-template-rows:var(--top) minmax(0,1fr)!important;height:100dvh!important}

  /* Kill v1.30 pseudo-scrim: mobile scrim is explicit and visibility-driven in JS. */
  body.drawer-open-v117 .app:after,.app:after{content:none!important;display:none!important;background:transparent!important}
  body.drawer-open-v117 .mobile-nav{transform:none!important;opacity:1!important;pointer-events:auto!important}
  body.mobile-sheet-open-v131 .mobile-nav{transform:translateY(calc(100% + var(--v131-safe-bottom) + 2px))!important;opacity:0!important;pointer-events:none!important}

  .mobile-sheet-scrim-v131{
    display:none;position:fixed;inset:0;z-index:134;background:rgba(0,0,0,.54);
    opacity:0;transition:opacity var(--motion-small,150ms) ease;
  }
  body.mobile-sheet-open-v131 .mobile-sheet-scrim-v131{display:block;opacity:1}

  /* Real mobile app bar: title/context + search + account. */
  .topbar{
    height:var(--top)!important;min-height:var(--top)!important;
    padding:var(--v131-safe-top) 12px 0!important;
    display:grid!important;grid-template-columns:minmax(0,1fr) 40px 40px!important;
    grid-template-rows:var(--v131-appbar)!important;gap:4px!important;align-items:center!important;
    background:var(--surface-nav)!important;border-bottom:1px solid var(--stroke-subtle)!important;
    backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
  }
  .topbar>.brand,.topbar>.scope-cluster,.topbar .create-btn,.topbar .hide-mobile,.topbar .theme-utility{display:none!important}
  .mobile-app-title-v131{
    grid-column:1;min-width:0;height:44px;border:0;background:transparent;color:var(--text-primary);
    display:flex;align-items:center;text-align:left;padding:0 8px;border-radius:12px;gap:9px;
  }
  .mobile-app-title-v131:active{background:var(--surface-hover)}
  .mobile-app-title-v131 .mobile-title-copy-v131{min-width:0;display:grid;gap:1px}
  .mobile-app-title-v131 strong{font-size:16px;line-height:1.15;font-weight:720;letter-spacing:-.015em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .mobile-app-title-v131 small{font-size:10.5px;line-height:1.2;color:var(--text-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .mobile-app-title-v131 .mobile-title-chevron-v131{font-size:11px;color:var(--text-faint);flex:0 0 auto}
  .search-trigger{grid-column:2!important;width:38px!important;height:38px!important;min-width:38px!important;border:0!important;background:transparent!important;border-radius:12px!important;font-size:20px!important}
  .search-trigger:active{background:var(--surface-hover)!important}
  .top-actions{display:contents!important}
  #avatarBtn{grid-column:3!important;width:38px!important;height:38px!important;min-width:38px!important;justify-self:end!important;font-size:10.5px!important}

  /* Edge-to-edge native tab bar instead of floating desktop-like pill. */
  .mobile-nav{
    left:0!important;right:0!important;bottom:0!important;
    height:calc(var(--v131-tabbar) + var(--v131-safe-bottom))!important;
    padding:3px 6px var(--v131-safe-bottom)!important;border-radius:0!important;
    border:0!important;border-top:1px solid var(--stroke-subtle)!important;
    background:var(--surface-nav)!important;box-shadow:0 -8px 28px rgba(0,0,0,.12)!important;
    backdrop-filter:none!important;-webkit-backdrop-filter:none!important;
    transition:transform var(--motion-small,150ms) var(--ease-standard,ease),opacity var(--motion-small,150ms) ease!important;
  }
  .mobile-nav button{position:relative;min-width:0!important;border-radius:10px!important;gap:3px!important;color:var(--text-muted)!important;background:transparent!important}
  .mobile-nav button::before{content:"";position:absolute;top:0;left:50%;width:20px;height:2px;border-radius:9px;background:transparent;transform:translateX(-50%)}
  .mobile-nav button.active{background:transparent!important;color:var(--accent)!important}
  .mobile-nav button.active::before{background:var(--accent)}
  .mobile-nav button b{display:grid;place-items:center;height:25px!important;font-size:0!important;color:currentColor!important}
  .mobile-nav button b svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
  .mobile-nav button span{font-size:10px!important;font-weight:600!important;color:currentColor!important;letter-spacing:.005em}

  /* AI is not a floating widget on mobile. It stays reachable from Mais. */
  #aiCapacityDockV117{display:none!important}

  .shell,.main{min-width:0!important;width:100%!important}
  .main{padding-bottom:0!important;background:var(--surface-canvas)!important}
  .page{
    padding:14px var(--mobile-edge) calc(var(--v131-tabbar) + var(--v131-safe-bottom) + 18px)!important;
    width:100%!important;max-width:none!important;
  }
  .page-head{margin-bottom:12px!important;gap:8px!important}
  .page-title h1{font-size:24px!important;line-height:1.08!important;font-weight:760!important;letter-spacing:-.025em!important}
  .page-title p{font-size:13px!important;line-height:1.35!important;color:var(--text-muted)!important;margin-top:3px!important}
  .section-bar{min-height:44px!important;margin-bottom:10px!important}
  .section-bar h1{font-size:21px!important;letter-spacing:-.02em!important}
  .section-symbol{width:31px!important;height:31px!important;border-radius:10px!important}

  /* Mobile cards and list rows: less tiny text, larger tap targets. */
  .panel{border-radius:16px!important;border-color:var(--stroke-subtle)!important;overflow:hidden!important}
  .panel-h{min-height:48px!important;padding:0 13px!important}
  .panel-h h3{font-size:15px!important;letter-spacing:-.01em!important}
  .panel-h .meta{font-size:11px!important;color:var(--text-muted)!important}
  .panel-b{padding:9px 12px!important}
  .att-row{min-height:64px!important;grid-template-columns:10px minmax(0,1fr) 34px!important;gap:9px!important;padding:10px 2px!important;align-items:center!important}
  .att-main b{font-size:13.5px!important;line-height:1.25!important}
  .att-main span{font-size:11.5px!important;line-height:1.35!important;margin-top:3px!important}
  .att-row>.btn{width:32px!important;height:32px!important;min-width:32px!important;padding:0!important;font-size:0!important;border:0!important;background:transparent!important;border-radius:50%!important;position:relative!important}
  .att-row>.btn:after{content:"›";font-size:24px;line-height:1;color:var(--text-faint)}
  .account-card{min-height:62px!important;border-radius:13px!important;padding:10px 11px!important;gap:8px!important;align-items:center!important}
  .account-card b{font-size:13.5px!important;line-height:1.25!important}
  .account-card p{font-size:11.5px!important;line-height:1.35!important;margin-top:3px!important}
  .account-card>.btn{width:32px!important;height:32px!important;min-width:32px!important;padding:0!important;font-size:0!important;border:0!important;background:transparent!important;position:relative!important}
  .account-card>.btn:after{content:"›";font-size:24px;color:var(--text-faint)}

  /* Workspace status becomes a native horizontal chip strip. */
  #home>.status-line{display:flex!important;overflow-x:auto!important;flex-wrap:nowrap!important;gap:7px!important;margin:2px -4px 8px!important;padding:0 4px 4px!important;scrollbar-width:none!important}
  #home>.status-line::-webkit-scrollbar{display:none!important}
  #home>.status-line span{flex:0 0 auto!important;min-height:29px!important;padding:0 9px!important;border:1px solid var(--stroke-subtle)!important;border-radius:999px!important;background:var(--surface-primary)!important;font-size:10.5px!important;display:flex!important;align-items:center!important;gap:5px!important}

  /* Metrics are swipeable cards, not four desktop columns stacked vertically. */
  #home>.g4{display:flex!important;overflow-x:auto!important;gap:8px!important;margin-left:calc(var(--mobile-edge) * -1)!important;margin-right:calc(var(--mobile-edge) * -1)!important;padding:0 var(--mobile-edge) 5px!important;scroll-snap-type:x proximity!important;scrollbar-width:none!important}
  #home>.g4::-webkit-scrollbar{display:none!important}
  #home>.g4 .metric{flex:0 0 min(74vw,270px)!important;min-height:92px!important;border-radius:16px!important;scroll-snap-align:start!important;padding:13px!important}
  #home>.g4 .metric .k{font-size:11px!important}
  #home>.g4 .metric .v{font-size:24px!important;margin-top:6px!important}
  #home>.g4 .metric .d{font-size:10.5px!important;margin-top:5px!important}

  .job{min-height:58px!important;grid-template-columns:minmax(0,1fr) auto!important;gap:8px!important;padding:9px 0!important}
  .job>div:first-child b{font-size:13px!important;line-height:1.25!important}
  .job>div:first-child span{font-size:11px!important;line-height:1.3!important}
  .job>.progress{display:none!important}
  .job>.pill{font-size:10px!important;align-self:center!important}

  /* Sheets keep native composition, but scrim is managed by v1.31 JS. */
  .drawer,.drawer.left{z-index:145!important;max-height:calc(100dvh - 8px)!important;border-radius:22px 22px 0 0!important}
  .drawer-h{min-height:54px!important;padding:10px 15px!important}
  .drawer-body{padding-bottom:calc(var(--v131-safe-bottom) + 12px)!important}
  .palette{padding-top:0!important}
  .overlay{z-index:170!important;background:var(--surface-canvas)!important;backdrop-filter:none!important}

  /* Touch target floor for app shell and common list actions. */
  .mobile-app-title-v131,.search-trigger,#avatarBtn,.mobile-nav button{touch-action:manipulation}
}

@media (max-width:360px){
  :root{--mobile-edge:13px;--v131-appbar:52px}
  .page-title h1{font-size:22px!important}
  .mobile-app-title-v131 strong{font-size:15px}
  .panel-b{padding-left:10px!important;padding-right:10px!important}
}

@media (max-height:700px) and (max-width:780px){
  :root{--v131-appbar:50px;--v131-tabbar:54px}
  .page{padding-top:10px!important}
  .panel-h{min-height:44px!important}
}

@media (prefers-reduced-motion:reduce) and (max-width:780px){
  .mobile-sheet-scrim-v131,.mobile-nav{transition:none!important}
}
