/* App-like viewport. Loaded after theme CSS.
   Pinch-zoom and sideways pans are turned off. iPhone focus-zoom needs
   16px text fields. The Android shell draws edge-to-edge (API 35+), so a
   fixed black strip sits in the status-bar inset and the page scrolls
   under it. */

html {
  max-width: 100%;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

body {
  max-width: 100%;
  overscroll-behavior-x: none;
  touch-action: pan-y;
}

html.lr-ios input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]):not([type="file"]),
html.lr-ios select,
html.lr-ios textarea {
  font-size: 16px !important;
}

html.lr-android {
  background: #000;
  --lr-status-top: max(env(safe-area-inset-top, 0px), var(--safe-area-inset-top, 0px));
}

html.lr-android::before {
  content: "";
  position: fixed;
  z-index: 5000;
  top: 0;
  right: 0;
  left: 0;
  height: var(--lr-status-top);
  background: #000;
  pointer-events: none;
}

html.lr-android body {
  padding-top: var(--lr-status-top);
}

/* Stick the whole nation bar under the status strip.
   .hud is position:relative inside that bar. A length on its own `top`
   makes Android WebView apply the sticky shift twice, so the page title
   climbs over the nation art. Telegram never sets that length. */
html.lr-android .chrome-top {
  top: var(--lr-status-top);
}

html.lr-android .hud {
  top: auto;
}

/* MOST grows with the document. Drop the status inset so a short page
   does not gain an empty scroll equal to the bar. */
html.lr-android .app {
  min-height: calc(100dvh - var(--lr-status-top));
}

/* Modern locks the shell to the viewport. Same subtraction, or the
   tab bar sits one status-bar below the screen. */
html.lr-android .screen {
  height: calc(100dvh - var(--lr-status-top));
  max-height: calc(100dvh - var(--lr-status-top));
}

/* WebView paints a blue rectangle on tap. Press feedback is a scale-down. */
* {
  -webkit-tap-highlight-color: transparent;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
label:focus:not(:focus-visible),
summary:focus:not(:focus-visible),
[role="button"]:focus:not(:focus-visible) {
  outline: none;
}

@media (hover: none) {
  button:focus,
  button:focus-visible,
  a:focus,
  a:focus-visible,
  input:focus,
  input:focus-visible,
  select:focus,
  select:focus-visible,
  textarea:focus,
  textarea:focus-visible,
  label:focus,
  label:focus-visible,
  summary:focus,
  summary:focus-visible,
  [role="button"]:focus,
  [role="button"]:focus-visible {
    outline: none;
  }
}

/* Innermost control only, so a button inside a card does not scale twice.
   Badges positioned with translate() are excluded: replacing that transform
   would shove them off their anchor. */
@supports selector(:has(*)) {
  :where(
    button,
    a,
    label,
    summary,
    [role="button"],
    .res-item,
    input[type="button"],
    input[type="submit"],
    input[type="reset"]
  ):active:not(:disabled):not(:has(:active)):not(.ad-off-tab):not(.turn-fab__slot-chip) {
    transform: scale(0.96);
  }
}

@supports not selector(:has(*)) {
  :where(
    button,
    a,
    label,
    summary,
    [role="button"],
    .res-item,
    input[type="button"],
    input[type="submit"],
    input[type="reset"]
  ):active:not(:disabled):not(.ad-off-tab):not(.turn-fab__slot-chip) {
    transform: scale(0.96);
  }
}

@media (prefers-reduced-motion: reduce) {
  @supports selector(:has(*)) {
    :where(
      button,
      a,
      label,
      summary,
      [role="button"],
      .res-item,
      input[type="button"],
      input[type="submit"],
      input[type="reset"]
    ):active:not(:disabled):not(:has(:active)):not(.ad-off-tab):not(.turn-fab__slot-chip) {
      transform: none;
    }
  }

  @supports not selector(:has(*)) {
    :where(
      button,
      a,
      label,
      summary,
      [role="button"],
      .res-item,
      input[type="button"],
      input[type="submit"],
      input[type="reset"]
    ):active:not(:disabled):not(.ad-off-tab):not(.turn-fab__slot-chip) {
      transform: none;
    }
  }
}
