:root {
  --app-header-height: 60px;
  --app-mobile-header-height: 56px;
  --app-mobile-header-offset: calc(var(--app-mobile-header-height) + env(safe-area-inset-top, 0px) + 6px);
  --app-mobile-nav-height: 60px;
  --app-mobile-page-scale: 0.94;
  --app-mobile-content-max: 540px;
  --app-mobile-radius: 16px;
  --app-mobile-gap: 0.9rem;
  --app-mobile-bg: #f4f6fb;
  --app-mobile-surface: #ffffff;
  --app-mobile-border: rgba(15, 23, 42, 0.08);
  --app-mobile-text: #0f172a;
  --app-mobile-muted: #64748b;
  --app-mobile-primary: var(--mc-color-primary, #2563eb);
  --app-mobile-shadow-1: 0 6px 24px rgba(15, 23, 42, 0.08);
  --app-mobile-shadow-2: 0 16px 36px rgba(15, 23, 42, 0.16);
}

@media (max-width: 991.98px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-overflow-scrolling: touch;
  }

  body {
    min-height: 100dvh;
    font-size: 16px;
    line-height: 1.55;
    color: var(--app-mobile-text);
    background: var(--app-mobile-bg);
    padding-top: 0 !important;
    padding-bottom: calc(var(--app-mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 12px) !important;
  }

  .navbar.fixed-top,
  .navbar-mega,
  .app-navbar {
    top: 0 !important;
    min-height: var(--app-mobile-header-height) !important;
  }

  .app-navbar .container-fluid,
  .navbar-mega .container-fluid {
    min-height: var(--app-mobile-header-height) !important;
  }

  .app-top-offset {
    display: none !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .app-content {
    padding-top: var(--app-mobile-header-offset) !important;
    margin-top: 0 !important;
    position: relative;
    z-index: 1;
  }

  .app-layout-grid {
    display: block !important;
    padding: 0.8rem 0.75rem 0.25rem !important;
    min-height: auto !important;
    gap: 0 !important;
  }

  .layout-sidebar,
  .layout-right-sidebar {
    display: none !important;
  }

  .convo-feed {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  body.mobile-fit-mode .app-content {
    overflow-x: visible;
  }

  body.mobile-fit-mode .app-container {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
    transform: none !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  body.mobile-fit-mode .app-container > * {
    width: 100%;
    max-width: min(var(--app-mobile-content-max), 100%);
    margin-left: auto;
    margin-right: auto;
  }

  body.mobile-fit-mode .app-container * {
    min-width: 0;
    box-sizing: border-box;
  }

  .card,
  .page-shell .card,
  .container .card,
  .container-fluid .card {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .profile-nav-tabs,
  .profile-page-wrapper .profile-nav-tabs {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    left: 0 !important;
    right: 0 !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    box-sizing: border-box;
  }

  .hero-magazine,
  .hero-magazine-image {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    left: 0 !important;
    right: 0 !important;
  }

  h1,
  .h1 {
    font-size: clamp(1.45rem, 5.4vw, 1.9rem);
    line-height: 1.25;
  }

  h2,
  .h2 {
    font-size: clamp(1.3rem, 4.6vw, 1.6rem);
    line-height: 1.3;
  }

  h3,
  .h3 {
    font-size: clamp(1.15rem, 3.9vw, 1.4rem);
    line-height: 1.35;
  }

  h4,
  h5,
  h6,
  .h4,
  .h5,
  .h6,
  .lead {
    text-align: inherit;
    line-height: 1.4;
  }

  .app-content,
  .app-container,
  .page-shell,
  main,
  .container,
  .container-fluid {
    width: 100%;
    max-width: 100%;
    overflow-x: visible;
  }

  body.mobile-fit-mode .app-content,
  body.mobile-fit-mode .app-container,
  body.mobile-fit-mode .page-shell,
  body.mobile-fit-mode main {
    transform: none !important;
    left: auto !important;
    right: auto !important;
  }

  .app-container,
  .container,
  .container-fluid {
    padding-left: 0.9rem !important;
    padding-right: 0.9rem !important;
  }

  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .row > [class^="col-"],
  .row > [class*=" col-"] {
    padding-left: 0.45rem;
    padding-right: 0.45rem;
  }

  .navbar-mega {
    min-height: var(--app-mobile-header-height) !important;
    border-bottom: 1px solid var(--app-mobile-border) !important;
    box-shadow: 0 2px 18px rgba(15, 23, 42, 0.06);
    background: rgba(255, 255, 255, 0.94) !important;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .navbar-mega .container-fluid {
    min-height: var(--app-mobile-header-height);
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .navbar-mega .navbar-brand {
    min-height: var(--app-mobile-header-height);
    margin: 0 !important;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: calc(100vw - 88px);
    white-space: nowrap;
    overflow: hidden;
  }

  .navbar-mega .navbar-brand img {
    height: 26px !important;
    width: auto !important;
    object-fit: contain;
  }

  .navbar-mega .navbar-brand span {
    font-size: 0.92rem;
    line-height: 1;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .navbar-mega .navbar-toggler {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    padding: 0;
  }

  .hero-section,
  .page-hero,
  .challenges-hero,
  .hero-magazine,
  .hero-magazine-image {
    margin-top: 0 !important;
  }

  .hero-section {
    padding-top: 1rem !important;
  }

  .mobile-nav-modern {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1070;
    height: var(--app-mobile-nav-height);
    padding: 0.25rem 0.35rem calc(env(safe-area-inset-bottom, 0px) + 0.2rem);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.1rem;
    align-items: center;
    border-top: 1px solid var(--app-mobile-border);
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 -12px 28px rgba(15, 23, 42, 0.12);
  }

  .mobile-nav-modern .nav-item-modern {
    min-width: 44px;
    min-height: 44px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.1rem;
    color: var(--app-mobile-muted);
    font-size: 0.65rem;
    line-height: 1;
    letter-spacing: 0.01em;
    position: relative;
    text-align: center;
    padding: 0.2rem 0.15rem;
  }

  .mobile-nav-modern .nav-item-modern.active {
    color: var(--app-mobile-primary);
  }

  .mobile-nav-modern .nav-item-modern.active::after {
    display: none;
  }

  .mobile-nav-modern .mobile-nav-label {
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1;
  }

  .mobile-nav-modern .nav-item-fab {
    padding-top: 0;
  }

  .mobile-nav-modern .mobile-fab-core {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--app-mobile-primary), var(--mc-color-primary-dark, #1d4ed8));
    color: #fff;
    box-shadow: var(--app-mobile-shadow-2);
    margin-top: -20px;
    margin-bottom: 2px;
  }

  .mobile-nav-modern .mobile-fab-core i {
    font-size: 1.3rem;
  }

  .mobile-nav-modern .mobile-nav-badge {
    position: absolute;
    top: -4px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    font-size: 0.65rem;
    line-height: 18px;
    font-weight: 700;
    color: #fff;
    background: #dc2626;
    border: 2px solid #fff;
  }

  .mobile-bottom-sheet {
    z-index: 1082;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    transform: translateY(calc(100% + env(safe-area-inset-bottom, 0px))) !important;
    visibility: hidden;
    pointer-events: none;
  }

  .mobile-bottom-sheet.open {
    transform: translateY(0) !important;
    visibility: visible;
    pointer-events: auto;
  }

  .mobile-bottom-sheet .sheet-content {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
  }

  .mobile-bottom-sheet-backdrop {
    z-index: 1081;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  .mobile-bottom-sheet-backdrop.show {
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .app-mobile-menu {
    width: min(88vw, 340px) !important;
    max-width: min(88vw, 340px) !important;
  }

  .app-mobile-menu .offcanvas-header {
    min-height: var(--app-mobile-header-height);
  }

  .app-mobile-menu .offcanvas-body {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    -webkit-overflow-scrolling: touch;
  }

  .card,
  .page-shell .card,
  .list-group-item,
  .table.mobile-card-table tbody tr {
    border-radius: var(--app-mobile-radius) !important;
    border: 1px solid var(--app-mobile-border) !important;
    background: var(--app-mobile-surface);
    box-shadow: var(--app-mobile-shadow-1);
  }

  .card {
    margin-left: 0 !important;
    margin-right: 0 !important;
    margin-bottom: var(--app-mobile-gap);
  }

  .card-header,
  .card-body,
  .card-footer {
    padding: 0.95rem 1rem;
  }

  .btn,
  .nav-link,
  .dropdown-item,
  .menu-link,
  button,
  [role="button"] {
    min-height: 44px;
  }

  .btn {
    border-radius: 12px !important;
  }

  img,
  video,
  canvas,
  iframe,
  svg,
  table {
    max-width: 100%;
  }

  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
  }

  .table.mobile-card-table {
    border-collapse: separate;
    border-spacing: 0 0.7rem;
    margin-bottom: 0;
  }

  .table.mobile-card-table thead {
    display: none;
  }

  .table.mobile-card-table tbody,
  .table.mobile-card-table tr,
  .table.mobile-card-table td {
    display: block;
    width: 100%;
  }

  .table.mobile-card-table tbody tr {
    padding: 0.5rem 0.7rem;
    margin: 0;
  }

  .table.mobile-card-table td {
    border: 0 !important;
    padding: 0.46rem 0.2rem !important;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    text-align: left;
  }

  .table.mobile-card-table td::before {
    content: attr(data-label);
    flex: 0 0 42%;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--app-mobile-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  .table.mobile-card-table td > * {
    max-width: 58%;
  }

  .form-control,
  .form-select,
  input,
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
  }

  .mobile-overlay-open {
    overflow: hidden;
  }

  [style*="width: 100vw"],
  [style*="max-width:100vw"],
  [style*="max-width: 100vw"] {
    max-width: 100% !important;
  }

  [style*="width: calc(100% +"],
  [style*="width:calc(100% +"] {
    width: 100% !important;
    max-width: 100% !important;
  }

  [style*="margin-left:-"],
  [style*="margin-right:-"] {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

@media (hover: none) and (pointer: coarse) {
  .card:hover,
  .btn:hover,
  .nav-link:hover {
    transform: none !important;
    box-shadow: inherit;
  }
}

/* Final viewport guard against right-shift on mobile */
@media (max-width: 991.98px) {
  html,
  body {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  body,
  body.mobile-layout,
  body.mobile-fit-mode {
    margin: 0 !important;
    left: 0 !important;
    right: auto !important;
    transform: none !important;
  }

  .navbar.fixed-top,
  .navbar-mega {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin-left: 0 !important;
    transform: none !important;
  }

  .app-content,
  .app-container,
  .page-shell,
  main,
  .container,
  .container-fluid {
    left: 0 !important;
    right: auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    transform: none !important;
    translate: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .app-container,
  .container,
  .container-fluid {
    box-sizing: border-box !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .app-container > *,
  .page-shell > * {
    max-width: 100% !important;
  }

  body.desktop-layout .app-content,
  body.desktop-layout .navbar,
  body.desktop-layout footer {
    margin-left: 0 !important;
    left: 0 !important;
    width: 100% !important;
  }

  body.mobile-overflow-scaled .app-container {
    transform: none !important;
    transform-origin: top left;
    width: 100% !important;
  }

  body.mobile-overflow-scaled .app-container,
  body.mobile-overflow-scaled .page-shell,
  body.mobile-overflow-scaled .container,
  body.mobile-overflow-scaled .container-fluid {
    max-width: 100% !important;
    overflow-x: clip !important;
  }

  body.mobile-overflow-scaled [style*="min-width"],
  body.mobile-overflow-scaled [style*="width: 1"],
  body.mobile-overflow-scaled [style*="width:1"] {
    max-width: 100% !important;
  }
}

/* Routed pages: global mobile polish for all page=* views */
@media (max-width: 991.98px) {
  body.mobile-first-all .app-content {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  body.mobile-first-all .app-container {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  body.mobile-first-all .page-shell {
    width: 100% !important;
    max-width: 100% !important;
  }

  body.mobile-first-all .card,
  body.mobile-first-all .list-group-item,
  body.mobile-first-all .alert,
  body.mobile-first-all .table-responsive,
  body.mobile-first-all .modal-content {
    border-radius: 14px !important;
  }

  body.mobile-first-all .card {
    margin-bottom: 0.85rem !important;
  }

  body.mobile-first-all .page-header,
  body.mobile-first-all .page-hero,
  body.mobile-first-all .hero-section,
  body.mobile-first-all .challenges-hero {
    margin: 0 0 0.75rem !important;
    padding-top: 0.5rem !important;
  }

  body.mobile-first-all .input-group,
  body.mobile-first-all .btn-group,
  body.mobile-first-all .btn-toolbar {
    width: 100% !important;
    max-width: 100% !important;
  }

  body.mobile-first-all .table {
    font-size: 0.92rem;
  }

  body.mobile-first-all .sticky-top {
    top: calc(var(--app-mobile-header-height) + 6px) !important;
  }

  body.mobile-first-all .row > [class^="col"],
  body.mobile-first-all .row > [class*=" col"] {
    min-width: 0 !important;
  }

  body.mobile-first-all [style*="margin-left"],
  body.mobile-first-all [style*="margin-right"],
  body.mobile-first-all [style*="left:"],
  body.mobile-first-all [style*="right:"] {
    max-width: 100% !important;
  }

  /* Communication/chat screen */
  body.page-communication .msg-page {
    height: calc(100dvh - var(--app-mobile-header-offset) - var(--app-mobile-nav-height) - env(safe-area-inset-bottom, 0px) - 18px) !important;
    max-width: 100% !important;
    margin: 0 !important;
    border-radius: 14px !important;
    overflow: hidden !important;
  }

  body.page-communication .msg-sidebar {
    width: 100% !important;
    max-width: 100% !important;
  }

  body.page-communication .msg-chat-header,
  body.page-communication .msg-input-area,
  body.page-communication .msg-messages {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  body.page-communication .msg-bubble {
    max-width: 86% !important;
  }

  /* Kanban/workspace pages */
  body.page-job_manage .kanban-container,
  body.page-market_workspace .kanban-container,
  body.page-projects .kanban-container {
    min-width: 0 !important;
    width: 100% !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
    overflow: visible !important;
  }

  body.page-job_manage [style*="min-width: 1000px"],
  body.page-market_workspace [style*="min-width: 1000px"],
  body.page-projects [style*="min-width: 1000px"] {
    min-width: 100% !important;
  }

  /* Dense card grids/pages */
  body.page-search .row > [class*="col-"],
  body.page-browse .row > [class*="col-"],
  body.page-feed .row > [class*="col-"],
  body.page-forum .row > [class*="col-"],
  body.page-members_hub .row > [class*="col-"],
  body.page-studios_list .row > [class*="col-"] {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }
}

/* Neutralize legacy negative card offsets on very small screens */
@media (max-width: 575.98px) {
  .page-shell .card {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
  }
}

/* Universal guards for all routed pages and nested subpages */
@media (max-width: 991.98px) {
  body.mobile-first-all,
  body.mobile-first-all * {
    box-sizing: border-box;
  }

  body.mobile-first-all .container[style*="max-width"],
  body.mobile-first-all .container-fluid[style*="max-width"],
  body.mobile-first-all .card[style*="max-width"],
  body.mobile-first-all .row[style*="max-width"],
  body.mobile-first-all .d-grid[style*="max-width"] {
    max-width: 100% !important;
  }

  body.mobile-first-all form.d-flex {
    width: 100% !important;
    flex-wrap: wrap !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  body.mobile-first-all form.d-flex > .form-control,
  body.mobile-first-all form.d-flex > .form-select,
  body.mobile-first-all form.d-flex > .btn,
  body.mobile-first-all form.d-flex > .input-group,
  body.mobile-first-all form.d-flex > .btn-group {
    flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body.mobile-first-all .nav.nav-tabs,
  body.mobile-first-all .nav.nav-pills {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    gap: 0.35rem;
    padding-bottom: 0.25rem;
  }

  body.mobile-first-all .nav.nav-tabs .nav-item,
  body.mobile-first-all .nav.nav-pills .nav-item {
    flex: 0 0 auto !important;
  }

  body.mobile-first-all .nav.nav-tabs .nav-link,
  body.mobile-first-all .nav.nav-pills .nav-link {
    white-space: nowrap;
  }

  body.mobile-first-all [style*="min-width: 100"],
  body.mobile-first-all [style*="min-width:100"],
  body.mobile-first-all [style*="min-width: 120"],
  body.mobile-first-all [style*="min-width:120"],
  body.mobile-first-all [style*="min-width: 140"],
  body.mobile-first-all [style*="min-width:140"],
  body.mobile-first-all [style*="min-width: 160"],
  body.mobile-first-all [style*="min-width:160"],
  body.mobile-first-all [style*="min-width: 180"],
  body.mobile-first-all [style*="min-width:180"],
  body.mobile-first-all [style*="min-width: 200"],
  body.mobile-first-all [style*="min-width:200"],
  body.mobile-first-all [style*="min-width: 220"],
  body.mobile-first-all [style*="min-width:220"],
  body.mobile-first-all [style*="min-width: 240"],
  body.mobile-first-all [style*="min-width:240"],
  body.mobile-first-all [style*="min-width: 260"],
  body.mobile-first-all [style*="min-width:260"],
  body.mobile-first-all [style*="min-width: 280"],
  body.mobile-first-all [style*="min-width:280"],
  body.mobile-first-all [style*="min-width: 300"],
  body.mobile-first-all [style*="min-width:300"],
  body.mobile-first-all [style*="min-width: 320"],
  body.mobile-first-all [style*="min-width:320"],
  body.mobile-first-all [style*="min-width: 340"],
  body.mobile-first-all [style*="min-width:340"],
  body.mobile-first-all [style*="min-width: 360"],
  body.mobile-first-all [style*="min-width:360"],
  body.mobile-first-all [style*="min-width: 380"],
  body.mobile-first-all [style*="min-width:380"],
  body.mobile-first-all [style*="min-width: 400"],
  body.mobile-first-all [style*="min-width:400"],
  body.mobile-first-all [style*="min-width: 420"],
  body.mobile-first-all [style*="min-width:420"],
  body.mobile-first-all [style*="min-width: 440"],
  body.mobile-first-all [style*="min-width:440"],
  body.mobile-first-all [style*="min-width: 460"],
  body.mobile-first-all [style*="min-width:460"],
  body.mobile-first-all [style*="min-width: 480"],
  body.mobile-first-all [style*="min-width:480"],
  body.mobile-first-all [style*="min-width: 500"],
  body.mobile-first-all [style*="min-width:500"],
  body.mobile-first-all [style*="min-width: 600"],
  body.mobile-first-all [style*="min-width:600"],
  body.mobile-first-all [style*="min-width: 700"],
  body.mobile-first-all [style*="min-width:700"],
  body.mobile-first-all [style*="min-width: 800"],
  body.mobile-first-all [style*="min-width:800"],
  body.mobile-first-all [style*="min-width: 900"],
  body.mobile-first-all [style*="min-width:900"],
  body.mobile-first-all [style*="min-width: 1000"],
  body.mobile-first-all [style*="min-width:1000"] {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body.mobile-first-all [style*="margin-left:-"],
  body.mobile-first-all [style*="margin-right:-"],
  body.mobile-first-all [style*="left:-"],
  body.mobile-first-all [style*="right:-"] {
    margin-left: 0 !important;
    margin-right: 0 !important;
    left: 0 !important;
    right: auto !important;
  }

  body.mobile-first-all .table-responsive {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  body.mobile-first-all .table-responsive > .table {
    width: 100% !important;
    min-width: 100% !important;
  }

  body.mobile-first-all .list-group.position-absolute,
  body.mobile-first-all #participant-suggest,
  body.mobile-first-all #release_model_suggest,
  body.mobile-first-all #cp_suggest {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  body.mobile-first-all #tui-calendar {
    width: 100% !important;
    max-width: 100% !important;
    height: min(64vh, 560px) !important;
  }

  body.mobile-first-all #scoutMap,
  body.mobile-first-all #locationMap {
    width: 100% !important;
    max-width: 100% !important;
    height: min(54vh, 420px) !important;
  }

  body.page-communication .msg-page,
  body.page-messages .msg-page,
  body.page-messages_thread .msg-page,
  body.page-group_chat .chat-container,
  body.page-group_chats .chat-container {
    width: 100% !important;
    max-width: 100% !important;
    height: calc(100dvh - var(--app-mobile-header-offset) - var(--app-mobile-nav-height) - env(safe-area-inset-bottom, 0px) - 18px) !important;
    margin: 0 !important;
    overflow: hidden !important;
  }
}

/* Global hardening: project-wide mobile safety net */
@media (max-width: 991.98px) {
  body.mobile-first-all main,
  body.mobile-first-all .app-content,
  body.mobile-first-all .app-container {
    overflow-x: clip;
  }

  body.mobile-first-all img,
  body.mobile-first-all video,
  body.mobile-first-all canvas,
  body.mobile-first-all iframe,
  body.mobile-first-all svg {
    max-width: 100%;
    height: auto;
  }

  body.mobile-first-all table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.mobile-first-all pre,
  body.mobile-first-all code,
  body.mobile-first-all kbd,
  body.mobile-first-all samp {
    white-space: pre-wrap;
    word-break: break-word;
  }

  body.mobile-first-all .input-group,
  body.mobile-first-all .form-control,
  body.mobile-first-all .form-select,
  body.mobile-first-all .btn,
  body.mobile-first-all .badge {
    max-width: 100%;
  }

  body.mobile-first-all .btn-group {
    flex-wrap: wrap;
  }

  body.mobile-first-all .btn-group > .btn {
    flex: 1 1 auto;
  }

  body.mobile-first-all .modal-dialog {
    margin: 0.6rem;
    max-width: calc(100vw - 1.2rem);
  }

  body.mobile-first-all .offcanvas {
    max-width: min(90vw, 380px);
  }

  body.mobile-first-all [class*="chart"],
  body.mobile-first-all [id*="chart"],
  body.mobile-first-all .apexcharts-canvas {
    max-width: 100% !important;
    overflow: hidden;
  }

  /* Defensive: hidden backdrops must never block taps/clicks */
  body.mobile-first-all .offcanvas-backdrop:not(.show),
  body.mobile-first-all .modal-backdrop:not(.show),
  body.mobile-first-all .mobile-bottom-sheet-backdrop:not(.show) {
    pointer-events: none !important;
  }
}

@media (max-width: 575.98px) {
  body.mobile-first-all .container,
  body.mobile-first-all .container-fluid,
  body.mobile-first-all .app-container {
    padding-left: 0.7rem !important;
    padding-right: 0.7rem !important;
  }

  body.mobile-first-all .row > [class^="col-"],
  body.mobile-first-all .row > [class*=" col-"] {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }

  body.mobile-first-all .modal-dialog {
    margin: 0.45rem;
    max-width: calc(100vw - 0.9rem);
  }
}
