/* Mobile-Dedicated UI (/m) — Shared app.js engine with touch-first layout */

html[data-ui-mode="mobile"] {
  height: 100%;
  overflow: hidden;
}

html[data-ui-mode="mobile"] body {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
}

html[data-ui-mode="mobile"] aside.sidebar {
  display: none !important;
}

html[data-ui-mode="mobile"] .mobile-only {
  display: flex;
}

html[data-ui-mode="mobile"] .mobile-menu-btn,
html[data-ui-mode="mobile"] #modelSwitcher {
  display: none !important;
}

html[data-ui-mode="mobile"] main.workspace {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

html[data-ui-mode="mobile"] .topbar,
html[data-ui-mode="mobile"] .composer-dock,
html[data-ui-mode="mobile"] .mobile-bottom-nav {
  flex-shrink: 0;
}

html[data-ui-mode="mobile"] .topbar {
  padding: 8px 10px;
  gap: 8px;
  flex-wrap: nowrap;
}

html[data-ui-mode="mobile"] .persona-header {
  gap: 8px;
  flex: 1;
  min-width: 0;
}

html[data-ui-mode="mobile"] .header-title-row {
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
}

html[data-ui-mode="mobile"] .topbar > .row:last-child {
  flex-shrink: 0;
  gap: 5px;
}

html[data-ui-mode="mobile"] #mobileModelQuickBtn,
html[data-ui-mode="mobile"] #galleryToggleBtn {
  padding: 5px 8px;
  font-size: 11px;
  white-space: nowrap;
}

html[data-ui-mode="mobile"] #personaSettingsBtn {
  flex-shrink: 0;
}

html[data-ui-mode="mobile"] .avatar-lg,
html[data-ui-mode="mobile"] .avatar-lg-fallback {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}

html[data-ui-mode="mobile"] .header-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 128px;
}

html[data-ui-mode="mobile"] .scene-chips {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  margin-top: 3px;
}
html[data-ui-mode="mobile"] .scene-chips::-webkit-scrollbar {
  display: none;
}
html[data-ui-mode="mobile"] .scene-chip {
  white-space: nowrap;
  font-size: 10.5px;
  padding: 2px 7px;
}

html[data-ui-mode="mobile"] .messages {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 11px;
  gap: 12px;
}

html[data-ui-mode="mobile"] .msg-bubble {
  max-width: 88%;
  padding: 10px 13px;
  font-size: 13.5px;
}

html[data-ui-mode="mobile"] .msg-image-wrap {
  max-width: 100%;
}

html[data-ui-mode="mobile"] .composer-dock {
  padding: 8px 10px;
  min-width: 0;
  max-width: 100%;
}

html[data-ui-mode="mobile"] .composer-inner {
  max-width: 100%;
  min-width: 0;
  gap: 4px;
}

html[data-ui-mode="mobile"] .composer-box {
  padding: 6px 8px;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

html[data-ui-mode="mobile"] .composer-box textarea {
  width: 0;
  min-width: 0;
  flex: 1;
  font-size: 13px;
  line-height: 1.35;
  min-height: 44px;
  padding: 6px 4px;
}

html[data-ui-mode="mobile"] .chat-model-trigger {
  padding: 6px 8px;
  font-size: 11px;
}

html[data-ui-mode="mobile"] #sendBtn {
  padding: 8px 11px;
  font-size: 12.5px;
  flex-shrink: 0;
}

html[data-ui-mode="mobile"] .mobile-bottom-nav {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding: 5px 4px calc(6px + env(safe-area-inset-bottom));
  flex-shrink: 0;
  z-index: 25;
}

html[data-ui-mode="mobile"] .mobile-nav-tab {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

html[data-ui-mode="mobile"] .explore-view,
html[data-ui-mode="mobile"] .persona-home-view {
  flex: 1 1 0%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px 20px;
}

html[data-ui-mode="mobile"] .explore-header {
  min-width: 0;
  max-width: 100%;
}

html[data-ui-mode="mobile"] .persona-home-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  width: 100%;
}

html[data-ui-mode="mobile"] .persona-home-grid .persona-card {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  padding: 10px 11px;
}

html[data-ui-mode="mobile"] .persona-home-grid .avatar-sm,
html[data-ui-mode="mobile"] .persona-home-grid .avatar-fallback {
  width: 42px;
  height: 42px;
}

html[data-ui-mode="mobile"] #homeOpenCommunityBtn,
html[data-ui-mode="mobile"] #closeCommunityHubBtn,
html[data-ui-mode="mobile"] #closeStudioBtn,
html[data-ui-mode="mobile"] #studioExpandBtn {
  display: none;
}

html[data-ui-mode="mobile"] .studio-workbench-grid {
  grid-template-columns: 1fr;
}

html[data-ui-mode="mobile"] .studio-controls-grid {
  grid-template-columns: 1fr 1fr;
}

html[data-ui-mode="mobile"] .template-grid,
html[data-ui-mode="mobile"] .comm-gallery-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

html[data-ui-mode="mobile"] .explore-toolbar {
  padding: 8px 10px;
  gap: 7px;
}

html[data-ui-mode="mobile"] .explore-toolbar input[type="text"] {
  min-width: 0;
  flex: 1 1 100%;
}

html[data-ui-mode="mobile"] .gallery-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 0;
  height: 100dvh;
  z-index: 45;
  pointer-events: none;
  visibility: hidden;
  transition: width 0.22s ease, visibility 0.22s ease;
}

html[data-ui-mode="mobile"] .gallery-sidebar.open,
html[data-ui-mode="mobile"] .gallery-sidebar.studio-gallery-sidebar.open {
  width: 86vw;
  max-width: 340px;
  pointer-events: auto;
  visibility: visible;
  box-shadow: var(--shadow);
}

html[data-ui-mode="mobile"] .modal-backdrop:not(#authModal):not(#passwordResetModal) {
  align-items: flex-end;
  padding: 0;
}

html[data-ui-mode="mobile"] .modal-backdrop:not(#authModal):not(#passwordResetModal) > .modal {
  width: 100% !important;
  max-width: 100% !important;
  max-height: 92dvh;
  border-radius: 18px 18px 0 0;
  padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
}

html[data-ui-mode="mobile"] #authModal > .modal,
html[data-ui-mode="mobile"] #passwordResetModal > .modal {
  width: calc(100vw - 24px) !important;
  max-width: 400px !important;
}

html[data-ui-mode="mobile"] .grid-2,
html[data-ui-mode="mobile"] .grid-3,
html[data-ui-mode="mobile"] .coupon-form-grid,
html[data-ui-mode="mobile"] .compare-grid,
html[data-ui-mode="mobile"] .consult-layout {
  grid-template-columns: 1fr;
}

html[data-ui-mode="mobile"] .wizard-preview-box,
html[data-ui-mode="mobile"] .profile-card-hero,
html[data-ui-mode="mobile"] .settings-profile-card {
  flex-direction: column;
  align-items: stretch;
}

html[data-ui-mode="mobile"] .settings-profile-card .row {
  flex-wrap: wrap;
}

html[data-ui-mode="mobile"] select,
html[data-ui-mode="mobile"] input[type="text"],
html[data-ui-mode="mobile"] input[type="password"],
html[data-ui-mode="mobile"] input[type="number"],
html[data-ui-mode="mobile"] textarea.field {
  min-width: 0;
  max-width: 100%;
}

html[data-ui-mode="mobile"] .crop-viewport {
  width: min(290px, calc(100vw - 56px));
  height: min(290px, calc(100vw - 56px));
}

html[data-ui-mode="mobile"] .lightbox-img {
  max-width: 94vw;
  max-height: 70dvh;
}

html[data-ui-mode="mobile"] .compare-modal {
  width: calc(100vw - 16px);
  max-height: 92dvh;
  padding: 14px;
}

html[data-ui-mode="mobile"] .consult-messages {
  min-height: 180px;
  max-height: 220px;
}

html[data-ui-mode="mobile"] .toast-wrap {
  bottom: calc(68px + env(safe-area-inset-bottom));
  right: 12px;
  left: 12px;
  align-items: center;
}
