/* iPhone home-screen installation only. Browser and Telegram Mini App stay unchanged. */
@media (max-width: 800px) and (display-mode: standalone) {
  :root { color-scheme: dark; }
  html, body { overscroll-behavior-y: none; }
  body {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    background: #090d15;
  }
  button, select, textarea, input { font-size: 16px; }
  button { touch-action: manipulation; }
  .app-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 90 !important;
    padding: calc(env(safe-area-inset-top, 0px) + 6px) 10px 8px !important;
    background: linear-gradient(180deg, rgba(13, 20, 32, .96), rgba(13, 20, 32, .78)) !important;
    -webkit-backdrop-filter: blur(22px) saturate(165%);
    backdrop-filter: blur(22px) saturate(165%);
    border-bottom: 1px solid rgba(255, 255, 255, .09);
  }
  .header-shell { min-height: 48px !important; }
  .app-header .sidebar-toggle-btn,
  .app-header .header-action-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    border-radius: 15px !important;
  }
  .app-header .header-center { min-width: 0; }
  .app-header .header-chat-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .shell { padding-left: 0 !important; padding-right: 0 !important; }
  #panel-chat.active { min-height: 0 !important; }
  body.tab-chat-active:not(.hide-bottom-bar):not(.keyboard-open) #panel-chat.active {
    height: calc(var(--app-height, 100dvh) - 66px - env(safe-area-inset-top, 0px) - 92px - env(safe-area-inset-bottom, 0px)) !important;
    max-height: calc(var(--app-height, 100dvh) - 66px - env(safe-area-inset-top, 0px) - 92px - env(safe-area-inset-bottom, 0px)) !important;
  }
  #panel-chat .chat-window-card {
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
  }
  #panel-chat .chat-top-bar {
    margin: 0 12px;
    border-radius: 16px;
  }
  #panel-chat .chat-messages-container {
    padding-left: 14px !important;
    padding-right: 14px !important;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }
  #panel-chat .chat-composer-form {
    margin: 5px 10px 0 !important;
    padding: 7px !important;
    border: 1px solid rgba(255, 255, 255, .17) !important;
    border-radius: 24px !important;
    background: rgba(40, 48, 64, .86) !important;
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    backdrop-filter: blur(22px) saturate(140%);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .24), inset 0 1px rgba(255,255,255,.11) !important;
  }
  #panel-chat .chat-composer-form textarea {
    min-height: 42px !important;
    max-height: 144px !important;
    line-height: 1.35;
    resize: none;
  }
  #panel-chat .chat-composer-form .attach-btn,
  #panel-chat .chat-composer-form .mic-btn,
  #panel-chat .chat-composer-form .send-btn {
    min-width: 42px !important;
    min-height: 42px !important;
    flex: 0 0 42px;
    border-radius: 15px !important;
  }
  #panel-chat .chat-chips-carousel { -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  #panel-chat .chat-chips-carousel::-webkit-scrollbar { display: none; }
  .mobile-nav.flux-dock { bottom: max(8px, env(safe-area-inset-bottom, 8px)) !important; }
  .mobile-nav.flux-dock .m-tab:active { transform: scale(.94) !important; }
  .tab-panel:not(#panel-chat) { animation: flux-ios-enter .22s ease-out both; }
  .modal-backdrop:not(.hidden) .modal-card {
    border-radius: 24px 24px 0 0 !important;
    padding-bottom: max(18px, env(safe-area-inset-bottom, 18px)) !important;
  }
  @keyframes flux-ios-enter {
    from { opacity: .75; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 800px) and (display-mode: standalone) and (prefers-reduced-motion: reduce) {
  .tab-panel:not(#panel-chat) { animation: none; }
}
