/* Final mobile sizing layer. Theme, media pixels and speaking effects stay owned by their existing styles. */
/* These two preparation details apply on desktop as well as on phones. */
body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-title-field #liveTitle {
  border:1px solid #ffffff55!important;
  border-radius:16px!important;
}
body.rgb-theme.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-title-field #liveTitle {
  border-color:hsl(calc(var(--rgb-base-hue) + var(--rgb-surface-turn) + 12deg) 61% 62% / .47)!important;
}
body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-cover .live-cover-thumbnail {
  width:min(200px,100%);
  max-width:200px;
  height:auto;
  aspect-ratio:1 / 1;
  border-radius:18px;
}

@media (max-width:760px) {
  :root {
    --fit-left:max(10px,env(safe-area-inset-left,0px));
    --fit-right:max(10px,env(safe-area-inset-right,0px));
    --fit-top:max(10px,env(safe-area-inset-top,0px));
    --fit-bottom:max(10px,env(safe-area-inset-bottom,0px));
    --fit-width:calc(100vw - var(--fit-left) - var(--fit-right));
    --fit-height:calc(100dvh - var(--fit-top) - var(--fit-bottom));
    --fit-center:calc((100vw + var(--fit-left) - var(--fit-right)) / 2);
  }

  html,body { min-width:0; }
  body :is(.shell,.main,.content,.page,.panel,.card,.public-live-card,.room-layout,.studio-workspace,.studio-setup-card,.overlive-social) { min-width:0; }
  body :is(.panel,.card,.public-live-card,.field,.account-form,.account-profile-editor,.account-reset-panel,.background-settings,.social-content) { max-width:100%; }
  body .content { padding-inline:var(--fit-left) var(--fit-right); }
  body .topbar { height:auto; min-height:calc(56px + env(safe-area-inset-top,0px)); flex-wrap:wrap; gap:7px; padding:calc(6px + env(safe-area-inset-top,0px)) var(--fit-right) 6px var(--fit-left); }
  body .topbar :is(.mobile-brand,.search,.top-actions) { min-width:0; }
  body .topbar .mobile-brand { flex:0 1 auto; font-size:clamp(18px,5.8vw,23px); gap:6px; }
  body .topbar .mobile-brand .logo-img { flex:0 0 auto; width:32px; height:32px; }
  body .top-actions { flex-wrap:wrap; justify-content:flex-end; gap:5px; }
  body .app-back { flex:0 0 auto; min-height:44px; padding-inline:8px; }
  body .current-live-button { min-width:0; max-width:112px; padding-inline:8px; white-space:normal; }
  body .nav { left:var(--fit-center); right:auto; width:min(480px,var(--fit-width)); max-width:var(--fit-width); }
  body .nav button { min-width:0; padding-inline:5px; overflow-wrap:anywhere; }

  body :is(.title-row,.section-head,.account-heading) { min-width:0; gap:8px; flex-wrap:wrap; }
  body :is(.title-row,.section-head,.account-heading) > :first-child { min-width:0; }
  body :is(.page-title,.title-row,.section-head,.account-identity,.public-live-card) :is(h1,h2,h3,p,strong) { overflow-wrap:anywhere; }
  body :is(.grid2,.cards,.hero,.stats,.room-setup,.studio-settings-grid) > * { min-width:0; max-width:100%; }
  body :is(.btn,.filter,.account-tabs button,.social-tabs button,.social-contact-button,.background-buttons button) { min-width:0; max-width:100%; white-space:normal; overflow-wrap:anywhere; }
  body :is(input:not([type='checkbox']):not([type='radio']):not([type='color']),select,textarea) { min-width:0; max-width:100%; }
  body input[type='file'] { display:block; width:100%; min-width:0; max-width:100%; }
  body .filters { min-width:0; flex-wrap:wrap; gap:6px; }
  body .filter { flex:0 1 auto; padding-inline:12px; }
  body .emoji-card :is(picture,svg) { max-width:100%; height:auto; aspect-ratio:1 / 1; }
  body .room-directory-controls { min-width:0; flex-wrap:wrap; }
  body .room-directory-controls input { min-width:0; flex:1 1 140px; }
  body .room-directory-controls .btn { flex:0 1 auto; }
  body .public-live-card { padding:14px; gap:8px; border-radius:18px; }
  body .public-live-card h3 { font-size:clamp(16px,4.5vw,19px); }
  body .public-live-cover { max-width:100%; }
  body .overlive-download-home :is(a,button) { max-width:100%; padding-inline:15px; font-size:13px; white-space:normal; text-align:center; }
  body .chill-home .chill-actions { min-width:0; max-width:100%; }
  body .chill-home .chill-action { min-width:0; grid-template-columns:34px minmax(0,1fr) 18px; gap:5px 9px; padding-inline:12px; }
  body .chill-home .chill-action > span:not(.action-icon):not(.action-arrow) { min-width:0; overflow-wrap:anywhere; }

  /* Center each sheet inside the safe rectangle; long contents scroll inside it. */
  body dialog:not(.camera-focus) {
    min-width:0;
    max-width:var(--fit-width);
    max-height:var(--fit-height);
    inset-inline-start:var(--fit-left);
    inset-inline-end:var(--fit-right);
    margin-inline:auto;
    overflow-y:auto;
    overscroll-behavior:contain;
  }
  body :is(.live-user-profile,.social-action-dialog,.social-confirm-dialog,.invite-qr-dialog,.beauty-dialog,.background-dialog,.netflix-session-panel,.room-youtube-search-dialog) {
    padding-inline:clamp(14px,4vw,20px);
    border-radius:20px;
  }
  body dialog:not(.camera-focus) :is(h1,h2,h3,p,.hint,.field) { min-width:0; overflow-wrap:anywhere; }
  body dialog:not(.camera-focus) :is(.btn,.social-contact-button,.social-confirm-dialog button) { min-width:0; max-width:100%; white-space:normal; }
  body .social-confirm-dialog > div { flex-wrap:wrap; }
  body .invite-qr-dialog .invite-qr-image { width:min(230px,100%); margin-block:14px; }
  body .invite-qr-dialog .invite-qr-actions { gap:7px; }
  body .live-user-avatar { width:clamp(76px,24vw,100px); height:clamp(76px,24vw,100px); margin-bottom:12px; border-radius:20px; }
  body .live-user-profile { padding-top:38px; }
  body .room-youtube-results .room-youtube-result { grid-template-columns:min(28vw,96px) minmax(0,1fr); gap:8px; }
  body .room-youtube-result img { width:100%; max-width:96px; }
  body .video-source-choices { grid-template-columns:repeat(2,minmax(0,1fr)); }
  body .video-source-choices button { min-width:0; max-width:100%; white-space:normal; overflow-wrap:anywhere; }
  body .beauty-options { grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; }
  body .beauty-options label { min-width:0; gap:6px; padding:9px 8px; font-size:12px; }
  body .beauty-options input { flex:0 0 20px; }
  body .background-settings { padding:12px!important; }
  body .background-dialog .background-settings { padding:0!important; }
  body .background-editor { min-width:0; gap:9px; }
  body .background-preview { width:clamp(64px,22vw,88px); }
  body .background-buttons { min-width:0; }
  body .background-buttons button { padding-inline:9px; font-size:12px; }
  body .account-photo-editor { min-width:0; gap:9px; }
  body .account-photo-preview { width:64px; height:64px; }
  body .account-photo-editor .field { flex:1 1 0; min-width:0; }

  /* Both social destinations and every request action fit without horizontal clipping. */
  body .overlive-social { min-width:0; padding:14px 10px 10px; gap:9px; }
  body .social-heading > div { min-width:0; }
  body .social-refresh { flex:0 0 40px; }
  body .social-tabs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px; }
  body .social-tabs button { min-width:0; padding:10px 6px; font-size:12px; }
  body .social-row,.social-row-main,.social-row-text,.social-thread-heading { min-width:0; max-width:100%; }
  body .social-row-main { flex:1 1 0; gap:8px; }
  body .social-row:has(> .social-refuse) { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; }
  body .social-row:has(> .social-refuse) .social-row-main { grid-column:1 / -1; }
  body .social-row > :is(.social-pill,.social-refuse) { min-width:0; max-width:100%; white-space:normal; }
  body .social-row > .social-refuse { min-height:44px; padding:8px; }
  body :is(.social-find,.social-private-form) { min-width:0; gap:6px; }
  body :is(.social-find input,.social-private-form textarea) { flex:1 1 0; width:0; min-width:0; }
  body .social-private-form .social-pill { flex:0 0 auto; padding-inline:10px; }
  body .social-private-message { min-width:0; max-width:94%; }
  body .social-contact-heading :is(h2,p) { overflow-wrap:anywhere; }

  /* Live anchors retain their existing vertical placement and media behavior. */
  body.immersive-live { --live-avatar-size:clamp(44px,15vw,64px); }
  body.immersive-live .room-header { left:var(--fit-left); max-width:calc(var(--fit-width) - 72px); }
  body.immersive-live #sharedChatDock,
  body.immersive-live #roomsPanel .room-primary-actions,
  body.immersive-live.chat-keyboard-open #roomsPanel .room-primary-actions { left:var(--fit-left); right:var(--fit-right); width:auto; max-width:var(--fit-width); }
  body.immersive-live #roomsPanel .room-primary-actions { flex-wrap:wrap; gap:7px; }
  body.immersive-live #sharedSeats,
  body.immersive-live:not(.immersive-audio) .seats-open #sharedSeats { left:var(--fit-center); width:min(540px,calc(var(--fit-width) - 12px)); }
  body.immersive-live #sharedSeats .seat-name { display:block; min-width:0; max-width:100%; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
  body #roomsPanel .room-more-menu { width:min(280px,var(--fit-width)); max-width:var(--fit-width); }
  body #roomsPanel .room-more-menu > .field { min-width:0; flex-wrap:wrap; gap:8px; }
  body #roomsPanel .room-more-menu > .btn { min-width:0; overflow-wrap:anywhere; white-space:normal; }
  body #roomsPanel .room-more-menu input[type='color'] { flex:0 0 46px; }
  body #sharedChatDock .overlive-chat-form { min-width:0; gap:5px; }
  body #sharedChatDock .overlive-chat-form textarea { flex:1 1 0; width:0; min-width:0; }
  body #sharedChatDock .overlive-gif-grid { grid-template-columns:repeat(auto-fit,minmax(min(64px,100%),1fr)); }
  body .overlive-chat-drawer { width:var(--fit-width); bottom:max(8px,env(safe-area-inset-bottom,0px)); padding:14px; }
  body .room-music-bubbles[data-live='true'] { left:var(--fit-left); right:auto; }
  body .room-music-bubbles .music-control-panel { left:0; right:auto; width:min(310px,var(--fit-width)); max-width:var(--fit-width); }
  body .camera-focus-title { left:var(--fit-left); max-width:calc(var(--fit-width) - 112px); }
  body .camera-focus-close { right:var(--fit-right); }
  body .camera-focus-fullscreen { right:calc(var(--fit-right) + 52px); }
  body .camera-focus-controls { left:var(--fit-center); max-width:var(--fit-width); flex-wrap:wrap; justify-content:center; }
  body .toast { left:var(--fit-center); max-width:var(--fit-width); overflow-wrap:anywhere; }

  /* Compact square import and a real rounded title field on the preparation screen. */
  body.prelive-screen .topbar {
    height:calc(52px + env(safe-area-inset-top,0px))!important;
    min-height:calc(52px + env(safe-area-inset-top,0px))!important;
    padding:calc(4px + env(safe-area-inset-top,0px)) var(--fit-right) 4px var(--fit-left)!important;
  }
  body.prelive-screen .content {
    height:calc(100dvh - 52px - env(safe-area-inset-top,0px))!important;
    padding:10px var(--fit-right) max(12px,env(safe-area-inset-bottom,0px)) var(--fit-left)!important;
  }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] { gap:10px; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-card { width:100%; min-width:0; gap:12px; padding:4px 2px 0; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-title-field { min-width:0; max-width:100%; padding:2px; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-title-field #liveTitle {
    width:100%; min-width:0; min-height:50px; padding:10px 12px;
    font-size:clamp(20px,6vw,28px); line-height:1.25; text-align:center;
  }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-cover { min-width:0; gap:8px; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-cover .live-cover-thumbnail {
    width:clamp(136px,42vw,180px); max-width:100%; height:auto; aspect-ratio:1 / 1; border-radius:18px;
  }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-cover-add { width:44px; min-width:44px; height:44px; min-height:44px; right:8px; bottom:8px; font-size:30px; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] #liveCoverRemove { right:7px; top:7px; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-settings { min-width:0; gap:8px; padding-top:4px; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-settings select { min-width:0; min-height:44px; padding:9px 10px; font-size:14px; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] > .studio-launcher { width:100%; min-width:0; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .studio-launcher #startSession { min-width:0; width:100%; min-height:50px; padding:11px 14px; border-radius:26px; font-size:15px; }
}

@media (max-width:360px) {
  body .topbar .mobile-brand { font-size:18px; }
  body .topbar .mobile-brand .logo-img { width:28px; height:28px; }
  body #overliveAccountPanel { padding:14px 12px; }
  body .account-heading { gap:8px; }
  body .account-heading h2 { font-size:20px; }
  body .account-photo-editor { align-items:flex-start; }
  body .beauty-options { grid-template-columns:minmax(0,1fr); }
  body .invite-qr-dialog .invite-qr-actions { grid-template-columns:minmax(0,1fr); }
}

@media (max-width:760px) and (max-height:690px) {
  body[data-page='home'] #home.chill-home { justify-content:flex-start; overflow-y:auto; padding-top:8px; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-card { gap:8px; }
  body.prelive-screen #studio.prelive-simple[data-prelive='true'] .prelive-cover .live-cover-thumbnail { width:min(136px,28dvh); }
}
