/* CHIEL Dashboard 4.0 — central mobile/iPhone hardening */
:root {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark;
}

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

button, input, select, textarea, summary {
  touch-action: manipulation;
  color-scheme: dark;
}

select, option, optgroup {
  color-scheme: dark;
}

button, [role="button"] {
  min-height: 44px;
}

/* Keep all global overlays inside iPhone safe areas. The overlay modules have
   their own styling; these rules intentionally win on narrow screens so a
   later component tweak cannot put controls below the home indicator/notch. */
@media (max-width: 680px) {
  #chiel-homey-overlay-v4,
  #chiel-agenda-overlay-v4,
  #chiel-media-overlay-v4,
  #chiel-doorbell-overlay-v4 {
    padding-top: max(8px, env(safe-area-inset-top)) !important;
    padding-right: max(8px, env(safe-area-inset-right)) !important;
    padding-bottom: max(8px, env(safe-area-inset-bottom)) !important;
    padding-left: max(8px, env(safe-area-inset-left)) !important;
  }

  #chiel-homey-overlay-v4 .homey-panel,
  #chiel-agenda-overlay-v4 .agenda-card,
  #chiel-media-overlay-v4 .media-panel,
  #chiel-doorbell-overlay-v4 .chiel-doorbell-card {
    max-width: 100%;
    max-height: calc(100dvh - 16px);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  #chiel-homey-overlay-v4 .homey-panel,
  #chiel-agenda-overlay-v4 .agenda-card,
  #chiel-media-overlay-v4 .media-panel {
    overflow-y: auto;
  }

  #chiel-homey-overlay-v4 .homey-head,
  #chiel-agenda-overlay-v4 header,
  #chiel-media-overlay-v4 header {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  #chiel-homey-button-v4 {
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: max(10px, env(safe-area-inset-bottom)) !important;
  }

  #chiel-agenda-button-v4 {
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: max(72px, calc(env(safe-area-inset-bottom) + 62px)) !important;
  }

  #chiel-doorbell-overlay-v4 .chiel-doorbell-card {
    margin-top: 0 !important;
    overflow-y: auto;
  }
}

/* Standalone status screen uses the same mobile contract. */
@media (max-width: 560px) {
  body.chiel-status-page {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    padding-left: max(14px, env(safe-area-inset-left));
  }

  .chiel-status-page .top {
    flex-wrap: wrap;
  }

  .chiel-status-page .brand {
    min-width: 0;
  }

  .chiel-status-page .refresh {
    min-width: 96px;
    min-height: 44px;
  }

  .chiel-status-page .statusrow {
    flex-wrap: wrap;
  }

  .chiel-status-page .pill {
    max-width: 100%;
  }
}
