/* Keep the supplied desktop artwork; let phone layouts fit the real viewport. */
@media (max-width:1100px) {
  #app .main-layout { grid-template-columns:minmax(0,1fr);min-width:0; }
  #app .content { min-width:0;max-width:100%; }
  #mainContent :where(form,section,fieldset,.feature-field,.settings-acc,.chat-container) { min-width:0; }
  #mainContent :where(p,dd,.msg-bubble,.profile-name,.feature-note) { overflow-wrap:anywhere; }
}

@media (max-width:768px) {
  html { -webkit-text-size-adjust:100%;text-size-adjust:100%; }
  #app > header { padding-top:env(safe-area-inset-top,0px); }
  #app .header-logo-row { align-items:center;gap:8px;padding:6px 10px; }
  #app .header-logo-row .logo-center img { width:auto;max-width:100%;max-height:44px; }
  #app .header-logo-row .logo-side { min-width:36px; }
  #app .header-nav-row { padding:2px 4px; }
  #app .header-nav-row .nav-icons { overflow:visible; }
  #app .header-nav-row .nav-icon { min-width:0;min-height:52px;padding:4px 1px;gap:3px;font-size:.64rem;letter-spacing:0; }
  #app .header-nav-row .nav-icon .ico { width:28px;height:28px; }
  #app .header-nav-row .nav-icon .ico svg { width:26px;height:26px; }
  #app .header-balance-row { gap:6px;padding:4px 8px 6px; }
  #app .header-balance-row .balance,#app .header-balance-row .goal-badge { min-width:0;max-width:100%;padding:4px 8px;gap:4px;font-size:.75rem;line-height:1.4;letter-spacing:0; }
  #app .header-balance-row .balance { flex-wrap:wrap;justify-content:center; }
  #app .header-balance-row .bal-ico,#app .header-balance-row .goal-ico { width:14px;height:14px; }
  #app .header-balance-row .bal-ico svg,#app .header-balance-row .goal-ico svg { width:14px;height:14px; }
  #app .notif-btn,#app .user-chip { min-width:36px;min-height:36px; }
  #app .content { min-height:0;padding:12px;overflow-y:visible; }
  #app .section-title,#app .portal-feature-view .section-title { flex-wrap:wrap;gap:6px;font-size:1.15rem;line-height:1.35;margin-bottom:14px; }

  /* In-flow copy can grow with the user's text size and never cover the face. */
  #app .welcome-spis.welcome-full-img { --welcome-art-height:clamp(340px,100vw,850px);--welcome-visible-height:clamp(200px,56vw,440px);flex:1 0 auto;min-height:0;height:auto;justify-content:flex-start;margin:-12px -12px 0;width:calc(100% + 24px); }
  #app .welcome-spis.welcome-full-img .ws-full { position:relative;inset:auto;display:block;width:100%;height:var(--welcome-art-height);max-height:none;object-fit:cover;object-position:center top;transform:none;margin-bottom:calc(var(--welcome-visible-height) - var(--welcome-art-height));-webkit-mask-image:linear-gradient(#000 calc(var(--welcome-visible-height) - 20px),transparent var(--welcome-visible-height));mask-image:linear-gradient(#000 calc(var(--welcome-visible-height) - 20px),transparent var(--welcome-visible-height)); }
  #app .welcome-spis.welcome-full-img .ws-below { position:relative;inset:auto;top:auto;bottom:auto;width:100%;padding:0 18px 24px;margin:0;background:transparent; }
  #app .welcome-spis.welcome-full-img .ws-title { font-size:clamp(1.18rem,4.5vw,1.5rem);line-height:1.25;margin:0 0 12px; }
  #app .welcome-spis.welcome-full-img .ws-text { max-width:38ch;padding:0;font-size:.94rem;line-height:1.5;margin:0 auto 10px; }
  #app .welcome-spis.welcome-full-img .ws-finale { font-size:1.05rem;line-height:1.4;margin:12px 0 0; }

  #app :where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]),select,textarea),
  #authGate :where(input:not([type=checkbox]):not([type=radio]),select,textarea),
  #modalOverlay :where(input:not([type=checkbox]):not([type=radio]),select,textarea) { min-width:0;max-width:100%;font-size:16px!important; }
  #mainContent .feature-field :is(input,select,textarea),#modalOverlay .photo-comment-form textarea { font-size:16px; }
  #mainContent :where(.feature-tabs,.feature-actions,.modal-footer,.filter-chips,.discover-tabs) { max-width:100%;flex-wrap:wrap; }
  #mainContent .btn { max-width:100%;white-space:normal;overflow-wrap:anywhere; }
  #mainContent #profileNameDisplay { overflow-wrap:anywhere; }
  #mainContent div:has(> #profileNameDisplay) { min-width:0; }
  #mainContent .feature-profile-details { grid-template-columns:minmax(0,1fr);gap:4px; }
  #mainContent .feature-profile-details dd { margin-bottom:8px; }

  #app .chat-container { height:min(500px,calc(100dvh - 230px));min-height:260px;max-height:none; }
  #app .chat-messages { min-height:0;min-width:0;padding:10px; }
  #app .msg-bubble { max-width:90%;overflow-wrap:anywhere; }
  #app .chat-input-area { display:grid;grid-template-columns:minmax(0,1fr) auto auto;gap:8px;padding:10px; }
  #app .chat-input-area input { grid-column:1/-1;min-width:0;width:100%;font-size:16px; }
  #app .chat-input-area .btn { min-height:40px;padding:8px 12px;font-size:.9rem; }

  #modalOverlay { padding:8px; }
  #modalOverlay .modal { width:100%!important;max-width:100%!important;max-height:calc(100dvh - 16px);margin:0; }
  #modalOverlay .modal-header { gap:10px;padding:12px 14px; }
  #modalOverlay .modal-header h2 { min-width:0;overflow-wrap:anywhere;font-size:1.05rem; }
  #modalOverlay .modal-close { flex-shrink:0;min-width:36px;min-height:36px; }
  #modalOverlay .modal-body { padding:14px;min-width:0; }
  #modalOverlay .modal-body img { height:auto!important;max-width:100%; }
  #modalOverlay .modal-body .feature-comment-avatar { width:30px;height:30px!important; }
  #modalOverlay .modal-body .feature-avatar { width:64px;height:64px!important; }
  #modalOverlay .modal-body .profile-photo-tile img { height:100%!important; }
  #modalOverlay .modal-footer { flex-wrap:wrap;gap:8px;padding:12px 14px; }
  #modalOverlay .modal-footer .btn { min-height:40px;padding:10px 14px;max-width:100%;white-space:normal; }
  #modalOverlay .photo-detail-layout { min-height:0; }
  #modalOverlay .photo-detail-image { max-height:45dvh; }
  #modalOverlay .photo-detail-layout.is-locked .photo-detail-visual,#modalOverlay .photo-secret-panel { min-height:0; }
  #modalOverlay .photo-secret-panel { padding:24px 16px;gap:12px; }
  #modalOverlay .photo-secret-panel > .photo-secret-icon { width:56px;height:56px; }
  #modalOverlay .feature-profile-details { grid-template-columns:minmax(0,1fr);gap:4px; }
  #modalOverlay .feature-profile-details dd { margin-bottom:8px;overflow-wrap:anywhere; }
  #app .site-footer { padding:16px 12px max(16px,env(safe-area-inset-bottom,0px));font-size:.78rem; }
  #app .site-footer .footer-links { display:flex;justify-content:center;flex-wrap:wrap;gap:8px 16px; }
  #app .site-footer a { margin:0; }
}

@media (max-width:360px) {
  #app .header-balance-row { gap:4px;padding-inline:5px; }
  #app .header-balance-row .balance,#app .header-balance-row .goal-badge { font-size:.7rem;padding:4px 6px; }
  #app .header-nav-row .nav-icon { font-size:.59rem; }
  #mainContent .feature-photo-grid,#mainContent .feature-person-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}
