/* Text controls must fit the available pane, including nested grid/flex labels. */
#app button, #app summary {
  box-sizing: border-box !important;
  min-inline-size: 0 !important;
  max-inline-size: 100% !important;
  overflow-wrap: anywhere;
}
#app :is(.sidebar,.sidebar-explorer,.module-nav,.crm-huske-list) :is(button,summary) {
  overflow: hidden !important;
  white-space: normal !important;
}
#app :is(.project-nav,.module-nav,.module-item-row,.project-nav-copy,.module-text,.crm-huske-project-nav,.crm-huske-nav-group) {
  min-width: 0 !important;
  max-width: 100%;
  box-sizing: border-box;
}
#app :is(.sidebar,.sidebar-explorer,.module-nav,.crm-huske-list) :is(button,summary) :is(strong,small,.module-text,.module-count,.project-nav-meta) {
  min-width: 0 !important;
  max-width: 100% !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  box-sizing: border-box;
}
#app .project-nav { container-type: inline-size; }
#app .module-item { grid-template-columns: 18px 24px minmax(0,1fr) minmax(0,auto); }
#app .module-icon { max-width:24px; }
#app .module-count { overflow:hidden; text-overflow:ellipsis; }
@container (max-width: 380px) {
  #app .module-nav .module-item {
    grid-template-columns:18px 24px minmax(0,1fr) !important;
    height:auto !important;
    max-height:none !important;
    row-gap:3px;
  }
  #app .module-item > .module-count {
    grid-column:3 !important;
    grid-row:2 !important;
    text-align:left;
    font-size:11px;
    line-height:1.3;
  }
  #app .module-item > .module-text { grid-column:3; grid-row:1; }
  #app .module-item > :is(.module-section-caret,.module-section-spacer,.module-icon) { grid-row:1/3; }
  #app .module-item-row.has-action {
    grid-template-columns:minmax(0,1fr) auto !important;
  }
  #app .module-item-row.has-action > .module-count { grid-column:1/-1; padding:0 8px; }
  #app .project-nav-copy.has-factory { grid-template-columns:minmax(0,1fr) !important; gap:3px; }
  #app .project-factory-badges { justify-content:flex-start; max-width:100%; overflow:hidden; }
  #app .project-factory-badge { max-width:100%; box-sizing:border-box; white-space:normal; overflow-wrap:anywhere; }
}
@container (max-width: 200px) {
  #app .module-nav { padding-left:4px !important; }
  #app .module-nav .module-item { grid-template-columns:minmax(0,1fr) !important; padding:8px !important; }
  #app .module-item > :is(.module-section-spacer,.module-icon) { display:none !important; }
  #app .module-item > .module-section-caret { grid-column:1; grid-row:1; justify-self:end; z-index:1; }
  #app .module-item > .module-text { grid-column:1; padding-right:18px; }
  #app .module-item > .module-count { grid-column:1 !important; }
  #app .module-text strong { font-size:12px !important; line-height:1.25; display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:2; overflow:hidden; }
}

/* Keep trailing module labels clear of the tile outline, including the native
   bridge's padding:8px 0 rule and compact project panes. */
#app .module-nav .module-item-row > .module-item {
  padding-inline-end: 16px !important;
}
#app .module-nav .module-item-row > .module-count {
  padding-inline-end: 8px !important;
}

/* One count per module: keep the subtitle, with room for the add action. */
#app .module-nav .module-item-row.has-action {grid-template-columns:minmax(0,1fr) auto!important;}
#app .module-nav .module-item {grid-template-columns:18px 24px minmax(0,1fr);}

/* Touch activation has no double-tap delay; pressed feedback does not wait for data. */
button,a[href],[role="button"],summary{touch-action:manipulation}
button:not(:disabled):active,[role="button"]:active,summary:active{filter:brightness(1.16)}

/* Desktop navigation must scroll independently, including pinned files below tiles. */
#app .shell.dalux-layout:not(.mobile-sections-only)>.sidebar>.sidebar-rail{height:100%;max-height:100vh;max-height:100dvh;min-height:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;-webkit-overflow-scrolling:touch;box-sizing:border-box}
#app .shell.dalux-layout:not(.mobile-sections-only)>.sidebar>.sidebar-rail>*{flex-shrink:0}

/* Project file list ends above the controls, never underneath their hit areas.
   Shared CSS applies to Safari and the native WKWebView. Keep the same scroller
   so file return and tree expansion retain their existing scroll snapshots. */
#app .shell.dalux-layout.crm-native-project.mobile-list-only.mobile-content-focus {
  --crm-project-dock-height:calc(88px + var(--crm-safe-bottom,env(safe-area-inset-bottom,0px)));
}
#app .shell.dalux-layout.crm-native-project.mobile-list-only.mobile-content-focus > .content {
  height:calc(100dvh - var(--crm-project-dock-height))!important;
  min-height:calc(100dvh - var(--crm-project-dock-height))!important;
  max-height:calc(100dvh - var(--crm-project-dock-height))!important;
  overflow-y:auto!important;
  scroll-padding-bottom:16px!important;
}
#app .shell.dalux-layout.crm-native-project.mobile-list-only.mobile-content-focus::after {
  content:"";position:fixed;inset:auto 0 0;height:var(--crm-project-dock-height);
  background:var(--back,#111922);border-top:1px solid var(--line,#638ba4);
  z-index:10000;pointer-events:none;
}
body:has(#app .shell.crm-native-project.mobile-list-only.mobile-content-focus) #crmPetAssistant {
  bottom:var(--crm-dock-bottom,calc(14px + env(safe-area-inset-bottom,0px)))!important;
  right:calc(84px + var(--crm-safe-right,env(safe-area-inset-right,0px)))!important;
  z-index:10015;
}

/* Pinned files size to their label, never to percentage-height star controls. */
#app .shell.dalux-layout :is(.crm-home-favorites,.crm-home-account-favorites,.crm-team-home){height:auto!important;min-height:0!important;flex:0 0 auto!important;}
#app .shell.dalux-layout :is(.crm-home-favorite-list,.crm-team-list){height:auto!important;min-height:0!important;align-content:start!important;}
#app .shell.dalux-layout .crm-home-favorite-entry{height:auto!important;min-height:64px!important;max-height:none!important;aspect-ratio:auto!important;grid-template-columns:minmax(0,1fr) 44px!important;grid-auto-rows:max-content!important;align-items:center!important;flex:0 0 auto!important;}
#app .shell.dalux-layout .crm-home-favorite-entry>button:not(.crm-home-favorite-star){height:auto!important;min-height:64px!important;max-height:none!important;aspect-ratio:auto!important;padding:12px!important;color:var(--ink,#1c2f45)!important;align-self:center!important;}
#app .shell.dalux-layout .crm-home-favorite-entry>button.crm-home-favorite-star{height:44px!important;min-height:44px!important;max-height:44px!important;width:44px!important;padding:0!important;align-self:center!important;font-size:24px!important;}
#app .shell.dalux-layout .crm-home-favorite-entry>button.crm-home-favorite-star.crm-team-priority{font-size:0!important;}
#app .shell.dalux-layout .crm-home-favorite-entry strong{font-size:14px!important;line-height:1.35!important;color:inherit!important;}
#app .shell.dalux-layout .crm-home-favorite-entry small{font-size:12px!important;line-height:1.3!important;}
#app .shell.dalux-layout .crm-home-favorite-entry.status-approved>button:not(.crm-home-favorite-star){color:#214c33!important;}
html[data-theme="dark"] #app .shell.dalux-layout .crm-home-favorite-entry.status-approved>button:not(.crm-home-favorite-star){color:#c8edda!important;}
#app .shell.dalux-layout .crm-home-favorite-entry>button:not(.crm-home-favorite-star)>span{display:block!important;min-width:0!important;width:100%!important;}
#app .shell.dalux-layout .crm-home-favorite-entry strong{display:-webkit-box!important;-webkit-box-orient:vertical!important;-webkit-line-clamp:3!important;overflow:hidden!important;}

/* Pinned filenames reveal more as the desktop rail is widened. */
#app .shell.dalux-layout .crm-home-favorite-entry strong{display:block!important;white-space:nowrap!important;overflow:hidden!important;text-overflow:ellipsis!important;-webkit-line-clamp:unset!important;max-width:100%!important;}

/* Completed projects stay after all standard and account-specific menu tiles. */
#app .sidebar-section-switch > [data-sidebar-section="finished"]{order:100!important;}
