/* Native iPhone only: reserve the reported safe area once, inside the header.
   Do not add an artificial inset to a WKWebView that is already inset. */
html.koe-native-iphone { --koe-top: env(safe-area-inset-top, 0px); }
html.koe-native-iphone #toasts { top: calc(var(--koe-top) + 76px); }
@media (max-width: 810px) {
  html.koe-native-iphone, html.koe-native-iphone body {
    overflow-x: clip;
    overflow-y: visible;
    scroll-behavior: auto;
  }
  html.koe-native-iphone .mobile-header {
    top: 0;
    margin: 0 0 14px;
    height: calc(64px + var(--koe-top));
    padding-top: var(--koe-top);
    padding-left: max(15px, env(safe-area-inset-left, 0px));
    padding-right: max(15px, env(safe-area-inset-right, 0px));
    background: var(--bg);
  }
  html.koe-native-iphone .app-shell {
    padding-bottom: calc(68px + max(7px, env(safe-area-inset-bottom, 0px)));
  }
  html.koe-native-iphone .onboarding-shell {
    padding-top: calc(14px + var(--koe-top));
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  html.koe-native-iphone .flex.between:has(> button[data-action="new-voice"]) {
    flex-wrap: wrap;
  }
  html.koe-native-iphone button[data-action="new-voice"] {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  html.koe-native-iphone button[data-action="new-voice"] svg { flex-shrink: 0; }
}
.koe-boot-retry { padding: 10px 16px; border-radius: 10px; cursor: pointer; }
@media (max-width: 810px) {
  html.koe-native-android #toasts { top: auto; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  html.koe-native-android:has(.onboarding-shell) #toasts { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
}

/* Koeboard Android native layout 6 — added below the iPhone layout 5 rules.
   Keep iPhone WKWebView and ordinary Chrome/Safari behavior unchanged. */
@media (max-width: 810px) {
  html.koe-native-android .mobile-header {
    top: 0;
    margin: 0 0 14px;
    padding-left: max(15px, env(safe-area-inset-left, 0px));
    padding-right: max(15px, env(safe-area-inset-right, 0px));
  }
  html.koe-native-android .mobile-header .brand { min-width: 0; }
  html.koe-native-android .mobile-header .brand-name { white-space: nowrap; }
  html.koe-native-android .mobile-header .top-right { flex-shrink: 0; }
  html.koe-native-android .mobile-nav {
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }
  html.koe-native-android .app-shell {
    padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  }
  html.koe-native-android .section-head:has(> button[data-action="random-room"]) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  html.koe-native-android .section-head:has(> button[data-action="random-room"]) > h2 {
    grid-column: 1 / -1;
    margin: 0;
  }
  html.koe-native-android .section-head:has(> button[data-action="random-room"]) > button {
    width: 100%;
    min-width: 0;
    padding: 10px 6px;
    font-size: 12px;
    line-height: 1.35;
    white-space: nowrap;
  }
  html.koe-native-android .flex.between:has(> button[data-action="new-voice"]) {
    flex-wrap: wrap;
    gap: 10px;
  }
  html.koe-native-android button[data-action="new-voice"] {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  /* Fallback for already-installed older APKs whose WebView covers system bars.
     Newer builds already reserve insets in MainActivity; avoid a double gap there. */
  html.koe-native-android.koe-android-legacy-edge .mobile-header {
    top: 0;
    height: 92px;
    padding-top: 28px;
  }
  html.koe-native-android.koe-android-legacy-edge .mobile-nav {
    padding-bottom: calc(12px + 24px);
  }
  html.koe-native-android.koe-android-legacy-edge .app-shell {
    padding-bottom: calc(92px + 24px);
  }
  html.koe-native-android.koe-android-legacy-edge #toasts {
    bottom: calc(100px + 24px);
  }
}
@media (max-width: 810px) and (orientation: landscape) {
  html.koe-native-android.koe-android-legacy-edge .mobile-header {
    height: 64px;
    padding-top: 0;
  }
}
