/* RoomMate iOS layout fixes. Loaded after the main stylesheet. */
:root {
  --roommate-app-bg: #f5f7f8;
  --roommate-safe-top: env(safe-area-inset-top, 0px);
  --roommate-safe-bottom: env(safe-area-inset-bottom, 0px);
  --roommate-nav-height: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body { min-height: 100vh; min-height: 100dvh; }

.app-shell,
#dashboard,
#dashboard .app-content {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 100%;
}

/* The splash already owns the full-screen gradient; avoid a 100vw scrollbar on iOS. */
.app-splash {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

/* The mobile sidebar is the fixed bottom navigation. Its background fills the home-indicator area. */
@media (max-width: 700px) {
  #dashboard .sidebar {
    bottom: 0 !important;
    min-height: calc(var(--roommate-nav-height) + var(--roommate-safe-bottom)) !important;
    padding-bottom: calc(7px + var(--roommate-safe-bottom)) !important;
    background: var(--sidebar);
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }

  #dashboard .app-content {
    padding-bottom: calc(var(--roommate-nav-height) + var(--roommate-safe-bottom) + 16px) !important;
    margin-bottom: 0 !important;
  }

  /* Dedicated pages hide the topbar, so this is their only top spacing. */
  #dashboard:has(#activityPage:not(.hidden)) .dashboard-main,
  #dashboard:has(#personalAccountPage:not(.hidden)) .dashboard-main,
  #dashboard:has(#personalExpensesPage:not(.hidden)) .dashboard-main,
  #dashboard:has(#householdPage:not(.hidden)) .dashboard-main {
    padding-top: max(16px, var(--roommate-safe-top)) !important;
  }

  #dashboard .dashboard-main,
  #dashboard .activity-page,
  #dashboard .personal-account-page,
  #dashboard .personal-expenses-page,
  #dashboard .page-intro {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  #dashboard .activity-heading,
  #dashboard .personal-expenses-toolbar,
  #dashboard #accountPageHeading,
  #dashboard #activityHeading,
  #dashboard #personalExpensesPageHeading {
    filter: none;
    opacity: 1;
  }

  /* Dedicated page headers are opaque and never sit beneath a blur layer. */
  #dashboard:has(#activityPage:not(.hidden)) .activity-heading,
  #dashboard:has(#personalAccountPage:not(.hidden)) .account-page-heading,
  #dashboard:has(#personalExpensesPage:not(.hidden)) .personal-expenses-toolbar {
    position: relative;
    z-index: 2;
    background: var(--roommate-app-bg);
  }
}

@supports (-webkit-touch-callout: none) {
  input, textarea, select { font-size: max(16px, 1em); }
  button, input, select, textarea {
    -webkit-tap-highlight-color: transparent;
  }
}

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