/* Shared phone layout, loaded after themes so every entry uses the same bounds. */
:root {
  --app-safe-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  --app-safe-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
  --app-safe-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
  --app-safe-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
}
html[data-layout="mobile"] { height: 100%; overflow: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html[data-layout="mobile"] body { min-width: 0; min-height: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
html[data-layout="mobile"] .app-shell {
  position: fixed; top: var(--app-viewport-top, 0px); inset-inline: 0; margin-inline: auto;
  width: 100%; max-width: 100%; height: var(--app-viewport-height, 100dvh); min-height: 0;
  border: 0; box-shadow: none;
  --phone-tab-height: 58px;
  --phone-bottom: var(--app-safe-bottom);
}
html[data-layout="mobile"][data-keyboard="open"] { --app-safe-bottom: 0px; }
html[data-layout="mobile"] .workspace { display: block; position: relative; width: 100%; height: 100%; min-height: 0; }
html[data-layout="mobile"] .details { display: none; }
html[data-layout="mobile"] .conversations {
  position: absolute; inset: 0; width: 100%; min-width: 0;
  padding: var(--app-safe-top) var(--app-safe-right) calc(var(--phone-tab-height) + var(--phone-bottom)) var(--app-safe-left);
}
html[data-layout="mobile"] .main-panel { position: absolute; inset: 0; display: none; min-width: 0; min-height: 0; }
html[data-layout="mobile"] .workspace.mobile-chat-open .conversations { display: none; }
html[data-layout="mobile"] .workspace.mobile-chat-open .main-panel,
html[data-layout="mobile"] .workspace.other-view .main-panel { display: flex; }
html[data-layout="mobile"] .mobile-back { display: inline-grid; }
html[data-layout="mobile"] .mobile-tabs {
  position: absolute; inset-inline: 0; bottom: 0; display: flex; width: 100%;
  height: calc(var(--phone-tab-height) + var(--phone-bottom));
  padding: 0 var(--app-safe-right) var(--phone-bottom) var(--app-safe-left);
}
html[data-layout="mobile"] .workspace.mobile-chat-open .mobile-tabs,
html[data-layout="mobile"][data-keyboard="open"] .mobile-tabs { display: none; }
html[data-layout="mobile"] .mobile-tab { max-width: none; padding: 6px 3px; gap: 3px; font-size: 11px; }
html[data-layout="mobile"] .mobile-tab span { max-width: 100%; overflow-wrap: anywhere; }
html[data-layout="mobile"] .mobile-tab .icon { width: 22px; height: 22px; }
html[data-layout="mobile"] .conv-head { flex: 0 0 auto; padding: 17px 16px 13px; }
html[data-layout="mobile"] .conv-title { min-width: 0; font-size: 24px; }
html[data-layout="mobile"] .conv-subtitle { margin-top: 6px; }
html[data-layout="mobile"] .conv-head .search-box { margin-top: 13px; }
html[data-layout="mobile"] .conv-title-line > .icon-btn { flex: 0 0 44px; width: 44px; height: 44px; }
html[data-layout="mobile"] .conversation-list { min-height: 0; padding: 6px 8px; overscroll-behavior: contain; }
html[data-layout="mobile"] .conversation { min-height: 76px; padding: 12px 8px; gap: 10px; }
html[data-layout="mobile"] .sidebar-footer { flex: 0 0 auto; padding: 10px; text-align: center; flex-wrap: wrap; }
html[data-layout="mobile"] .chat-header {
  height: auto; min-height: calc(58px + var(--app-safe-top)); flex: 0 0 auto;
  padding: var(--app-safe-top) calc(6px + var(--app-safe-right)) 0 calc(6px + var(--app-safe-left)); gap: 4px;
}
html[data-layout="mobile"] .chat-header > .avatar { display: none; }
html[data-layout="mobile"] .chat-header .icon-btn { width: 36px; min-width: 36px; height: 44px; flex: 0 0 36px; }
html[data-layout="mobile"] .chat-header .header-actions { gap: 0; flex: 0 0 auto; }
html[data-layout="mobile"] .chat-title { font-size: 16px; }
html[data-layout="mobile"] .chat-subtitle { font-size: 10px; margin-top: 3px; }
html[data-layout="mobile"] .message-scroller { padding: 14px calc(10px + var(--app-safe-right)) 12px calc(10px + var(--app-safe-left)); min-width: 0; overflow-x: hidden; overscroll-behavior: contain; }
html[data-layout="mobile"] .message-row { max-width: 96%; gap: 6px; }
html[data-layout="mobile"] .message-row > .avatar { width: 30px; height: 30px; }
html[data-layout="mobile"] .message-bubble-wrap { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
html[data-layout="mobile"] .bubble { min-width: 0; padding: 10px 12px; }
html[data-layout="mobile"] .media-content,
html[data-layout="mobile"] .bubble-video { min-width: 0; max-width: 100%; }
html[data-layout="mobile"] .media-content audio { display: block; width: 260px; max-width: 100%; }
html[data-layout="mobile"] .media-content video,
html[data-layout="mobile"] .media-content img { max-width: 100%; }
html[data-layout="mobile"] .message-actions { flex: 0 0 28px; }
html[data-layout="mobile"] .message-actions .icon-btn { width: 28px; min-width: 28px; height: 44px; }
html[data-layout="mobile"] .composer-wrap { padding: 6px calc(10px + var(--app-safe-right)) calc(8px + var(--phone-bottom)) calc(10px + var(--app-safe-left)); }
html[data-layout="mobile"] .composer-tools { gap: 2px; margin-bottom: 3px; }
html[data-layout="mobile"] .composer-tools .icon-btn { width: 38px; height: 38px; flex: 0 0 38px; }
html[data-layout="mobile"] .composer-note { display: none; }
html[data-layout="mobile"] .composer { gap: 7px; min-width: 0; }
html[data-layout="mobile"] .composer textarea { font-size: 16px; min-height: 44px; max-height: min(110px, 25vh); padding: 10px 11px; }
html[data-layout="mobile"] .send-btn { width: 44px; height: 44px; }
html[data-layout="mobile"] .voice-hold { min-height: 44px; }
html[data-layout="mobile"] .emoji-popover { inset-inline-start: 8px; max-width: calc(100% - 16px); grid-template-columns: repeat(8, minmax(0, 1fr)); }
html[data-layout="mobile"] .translation-toolbar { flex: 0 0 auto; padding: 5px calc(10px + var(--app-safe-right)) 5px calc(10px + var(--app-safe-left)); gap: 4px 8px; font-size: 11px; }
html[data-layout="mobile"] .translation-toolbar .translation-status { flex-basis: 100%; margin-inline-start: 0; }
html[data-layout="mobile"] .calls-view,
html[data-layout="mobile"] .moments-view,
html[data-layout="mobile"] .contacts-view,
html[data-layout="mobile"] .discover-view,
html[data-layout="mobile"] .notices-view {
  min-width: 0; min-height: 0; overflow-x: hidden; overscroll-behavior: contain;
  padding: calc(20px + var(--app-safe-top)) calc(16px + var(--app-safe-right)) calc(76px + var(--phone-bottom)) calc(16px + var(--app-safe-left));
}
html[data-layout="mobile"] .view-heading { flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
html[data-layout="mobile"] .view-heading h2 { font-size: 24px; }
html[data-layout="mobile"] .view-heading > .primary-btn { max-width: 100%; }
html[data-layout="mobile"] .contact-grid { grid-template-columns: minmax(0, 1fr); }
html[data-layout="mobile"] .settings-row { gap: 10px; }
html[data-layout="mobile"] .settings-copy,
html[data-layout="mobile"] .module-copy,
html[data-layout="mobile"] .profile-identity { min-width: 0; overflow-wrap: anywhere; }
html[data-layout="mobile"] .settings-row > .icon { flex-shrink: 0; }
html[data-layout="mobile"] .profile-summary { gap: 12px; padding: 14px 0 24px; }
html[data-layout="mobile"] .profile-summary .avatar { width: 58px; height: 58px; }
html[data-layout="mobile"] .profile-summary .detail-name { font-size: 22px; overflow-wrap: anywhere; }
html[data-layout="mobile"] .detail-handle { overflow-wrap: anywhere; }
html[data-layout="mobile"] .module-row { padding: 16px 12px; gap: 12px; }
html[data-layout="mobile"] .login-screen {
  height: 100%; min-height: 0; max-height: none; overflow-y: auto; overscroll-behavior: contain; align-items: start;
  padding: calc(16px + var(--app-safe-top)) calc(14px + var(--app-safe-right)) calc(20px + var(--app-safe-bottom)) calc(14px + var(--app-safe-left));
}
html[data-layout="mobile"] .login-layout { min-width: 0; width: 100%; max-width: 490px; grid-template-columns: minmax(0, 1fr); }
html[data-layout="mobile"] .login-intro { padding: 20px; }
html[data-layout="mobile"] .login-tagline { margin: 16px 0 8px; font-size: 22px; }
html[data-layout="mobile"] .login-copy { font-size: 12px; }
html[data-layout="mobile"] .login-form { min-width: 0; padding: 20px; }
html[data-layout="mobile"] .login-form .hint { margin-bottom: 18px; }
html[data-layout="mobile"] :is(input, textarea, select) { font-size: 16px; max-width: 100%; }
html[data-layout="mobile"] .field, html[data-layout="mobile"] .inline-input { min-width: 0; }
html[data-layout="mobile"] .modal-backdrop,
html[data-layout="mobile"] .capture-backdrop {
  top: var(--app-viewport-top, 0px); bottom: auto; height: var(--app-viewport-height, 100dvh);
  padding: calc(12px + var(--app-safe-top)) calc(12px + var(--app-safe-right)) calc(12px + var(--app-safe-bottom)) calc(12px + var(--app-safe-left));
}
html[data-layout="mobile"] .modal { min-width: 0; max-width: 490px; max-height: 100%; overscroll-behavior: contain; }
html[data-layout="mobile"] .modal-head { gap: 10px; padding: 12px 16px; }
html[data-layout="mobile"] .modal-head h2 { min-width: 0; overflow-wrap: anywhere; }
html[data-layout="mobile"] .modal-head .icon-btn { flex: 0 0 44px; width: 44px; height: 44px; }
html[data-layout="mobile"] .modal-body { min-width: 0; padding: 16px; overflow-wrap: anywhere; }
html[data-layout="mobile"] .modal-actions { flex-wrap: wrap; }
html[data-layout="mobile"] .modal-actions button { height: auto; min-height: 44px; padding: 10px 16px; }
html[data-layout="mobile"] .shop-filters,
html[data-layout="mobile"] .shop-contact-line,
html[data-layout="mobile"] .capture-actions,
html[data-layout="mobile"] .call-controls { flex-wrap: wrap; }
html[data-layout="mobile"] .shop-contact-actions { display: grid; }
html[data-layout="mobile"] .shop-number, html[data-layout="mobile"] .shop-order { flex-wrap: wrap; }
html[data-layout="mobile"] .shop-tabs { overflow-x: auto; }
html[data-layout="mobile"] .shop-tab { flex-shrink: 0; white-space: nowrap; }
html[data-layout="mobile"] .capture-panel video,
html[data-layout="mobile"] .capture-photo { max-height: calc(var(--app-viewport-height, 100dvh) * .55); }
html[data-layout="mobile"] .toast-region { inset-inline: 16px; bottom: auto; top: calc(var(--app-viewport-top, 0px) + var(--app-safe-top) + 16px); max-width: 428px; margin-inline: auto; }
html[data-layout="mobile"] .toast { max-width: 100%; overflow-wrap: anywhere; }
html[data-layout="mobile"] .preview-banner { flex-wrap: wrap; flex: 0 0 auto; padding: 6px 12px; }
/* A desktop H5 preview may be framed; phones, tablets and native apps fill their window. */
@media (min-width: 701px) {
  html[data-surface="h5"][data-mobile-device="false"] .app-shell { width: 460px; border-inline: 1px solid var(--line); }
}
@media (max-width: 359px) {
  html[data-layout="mobile"] .login-intro, html[data-layout="mobile"] .login-form { padding: 16px; }
  html[data-layout="mobile"] .chat-header .icon-btn { width: 32px; min-width: 32px; flex-basis: 32px; }
  html[data-layout="mobile"] .me-commerce-shortcuts { grid-template-columns: minmax(0, 1fr); }
  html[data-layout="mobile"] .inline-input { grid-template-columns: minmax(0, 1fr); }
}
@media (max-height: 500px) and (orientation: landscape) {
  html[data-layout="mobile"] .app-shell { --phone-tab-height: 50px; }
  html[data-layout="mobile"] .conv-subtitle,
  html[data-layout="mobile"] .sidebar-footer,
  html[data-layout="mobile"] .login-copy,
  html[data-layout="mobile"] .login-feature-row { display: none; }
  html[data-layout="mobile"] .conv-head { padding-block: 6px; }
  html[data-layout="mobile"] .conv-head .search-box { margin-top: 6px; }
  html[data-layout="mobile"] .chat-header { min-height: calc(48px + var(--app-safe-top)); }
  html[data-layout="mobile"] .login-tagline { margin: 8px 0 0; font-size: 18px; }
  html[data-layout="mobile"] .composer-wrap { padding-top: 3px; }
  html[data-layout="mobile"] .composer-tools { margin-bottom: 0; }
}
