/* Mobile-first polish — load after page styles */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

img, video, iframe, svg {
  max-width: 100%;
  height: auto;
}

.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Chat stays bottom-left; back-to-top goes bottom-right (never overlap) */
.ai-assistant-widget {
  left: 20px !important;
  right: auto !important;
}
.back-to-top,
.rtl-body .back-to-top,
html[dir="rtl"] .back-to-top,
body.ltr-body .back-to-top {
  left: auto !important;
  right: 20px !important;
}

@media (max-width: 768px) {
  body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    overflow-x: clip;
  }

  .container {
    padding-inline: 1rem;
  }

  .section,
  .org-section {
    padding-block: 2.25rem;
  }

  /* Compact floating cookie sheet above bottom nav */
  .cookie-banner {
    left: 10px !important;
    right: 10px !important;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    width: auto !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 12px !important;
    border-radius: 16px !important;
    background: #fff !important;
    color: #1e293b !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .22) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    z-index: 1205 !important;
    transform: translateY(calc(100% + 96px)) !important;
    pointer-events: none;
  }
  .cookie-banner.show {
    transform: translateY(0) !important;
    pointer-events: auto;
  }
  .cookie-content {
    align-items: flex-start !important;
    gap: 8px !important;
  }
  .cookie-content i {
    font-size: 1.1rem !important;
    margin-top: .1rem;
    color: #c9a227 !important;
  }
  .cookie-content p {
    margin: 0 !important;
    font-size: .78rem !important;
    line-height: 1.55 !important;
    color: #334155 !important;
    font-weight: 600 !important;
  }
  .cookie-content a {
    color: #1e3a5f !important;
    text-decoration: underline;
  }
  .cookie-actions {
    display: grid !important;
    grid-template-columns: 1.4fr 1fr;
    gap: 8px !important;
    width: 100%;
  }
  .cookie-banner .cookie-accept,
  .cookie-banner .cookie-decline {
    width: 100% !important;
    min-width: 0 !important;
    padding: 10px 8px !important;
    font-size: .82rem !important;
    border-radius: 11px !important;
  }
  .cookie-banner .cookie-accept {
    background: #1e3a5f !important;
    color: #fff !important;
  }
  .cookie-banner .cookie-decline {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    color: #475569 !important;
  }

  /* FABs clear bottom nav; opposite corners — never overlap */
  .ai-assistant-widget {
    left: 6px !important;
    right: auto !important;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 997 !important;
  }
  .back-to-top,
  .rtl-body .back-to-top,
  html[dir="rtl"] .back-to-top,
  body.ltr-body .back-to-top {
    left: auto !important;
    right: 12px !important;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    width: 44px !important;
    height: 44px !important;
    z-index: 996 !important;
  }

  /* While cookie is open: hide back-to-top, lift chat above the sheet */
  body:has(.cookie-banner.show) .back-to-top {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(8px) !important;
  }
  body:has(.cookie-banner.show) .ai-assistant-widget {
    bottom: calc(220px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .mobile-bottom-nav .nav-item {
    font-size: 11px;
    gap: 4px;
    min-height: 48px;
  }
  .mobile-bottom-nav .nav-item i {
    font-size: 17px;
  }

  /* Common card/page grids */
  .steps-grid,
  .vmg-grid,
  .achievement-grid,
  .reg-grid,
  .people-grid,
  .adm-req-grid,
  .faculty-members-grid,
  .depts-grid,
  .org-deans-grid,
  .org-executives-grid {
    grid-template-columns: 1fr !important;
  }

  .deadline-card {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px !important;
    padding: 18px !important;
  }

  .faculty-nav {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    margin-bottom: 1.5rem !important;
  }
  .faculty-tab-btn {
    width: 100% !important;
    justify-content: flex-start !important;
    border-radius: 14px !important;
    padding: 14px 16px !important;
    white-space: normal !important;
    min-height: 48px;
  }
  .faculty-detail-hero {
    padding: 1.35rem 1.15rem !important;
    border-radius: 18px !important;
    gap: 1rem !important;
  }
  .faculty-stats-row {
    width: 100%;
    justify-content: space-between !important;
    gap: .75rem !important;
  }
  .fstat {
    flex: 1 1 auto;
    min-width: 0;
  }

  .roadmap-stepper {
    flex-direction: column;
  }
  .step-btn {
    width: 100%;
    min-width: 0 !important;
  }
  .roadmap-nodes-grid {
    grid-template-columns: 1fr !important;
  }

  .prog-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }
  .prog-tab {
    flex: 0 0 auto;
  }

  .form-card,
  .dept-card,
  .step-card,
  .vmg-card,
  .person-card,
  .reg-card,
  .adm-req-card,
  .faculty-member-card,
  .elig-card {
    border-radius: 16px;
  }

  .header .logo-text {
    max-width: 9.5rem;
  }
  .header .logo-main {
    font-size: .95rem !important;
  }
  .header .logo-sub {
    font-size: .65rem !important;
  }
}

@media (max-width: 480px) {
  .stats-panel {
    grid-template-columns: 1fr !important;
  }
  .stat-card {
    border-inline-start: 0 !important;
    border-top: 1px solid rgba(30, 58, 95, .08);
  }
  .stat-card:first-child {
    border-top: 0 !important;
  }

  .ar-services,
  .ar-strip__grid,
  .ar-endow {
    grid-template-columns: 1fr !important;
  }

  .home-dates__panel {
    padding: 1rem !important;
  }
  .home-dates__link,
  .accred-strip__link {
    width: 100%;
    justify-content: center;
  }

  .cookie-content {
    flex-direction: row;
    gap: 8px !important;
  }
  body:has(.cookie-banner.show) .ai-assistant-widget {
    bottom: calc(250px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
