/* The application frame stays still; long lists and settings scroll internally. */
html, body { height: 100%; min-height: 0 !important; overflow: hidden !important; overscroll-behavior: none; }
body { height: 100dvh; max-height: 100dvh; width: 100%; }
.shell { height: 100%; min-height: 0 !important; overflow: hidden; }
.main { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }
.topbar { flex: 0 0 auto; height: calc(64px + env(safe-area-inset-top, 0px)); min-height: 0; width: 100%; padding: calc(8px + env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-right, 0px)) 8px max(18px, env(safe-area-inset-left, 0px)); }
.mobile-brand { font-size: 24px; }
.mobile-brand .logo-img { width: 38px; height: 38px; }
.content { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; height: auto; width: 100%; overflow: hidden; padding: 10px 22px calc(85px + env(safe-area-inset-bottom, 0px)); }
body[data-page='home'] .content { padding-bottom: max(10px, env(safe-area-inset-bottom, 0px)); }
.session-note { display: none; }
.page:not(.hidden) { display: flex; flex-direction: column; flex: 1 1 auto; height: 100%; max-height: 100%; min-height: 0; overflow: hidden; }
.page > .page-title, .page > .title-row, .page > .filters, .page > .notice { flex: 0 0 auto; }
.page-title { margin-bottom: 14px; }
.page-title h1, .title-row h1 { font-size: clamp(24px, 3.8vw, 34px); margin-block: 5px; }
.page-title .lead, .title-row .lead { font-size: 12px; }
.title-row { margin-bottom: 12px; }
.filters { margin: 12px 0; flex-wrap: nowrap; overflow-x: auto; overscroll-behavior: contain; scrollbar-width: none; }
.filter { flex: 0 0 auto; white-space: nowrap; }
.nav { bottom: 0; z-index: 20; padding-bottom: calc(9px + env(safe-area-inset-bottom, 0px)); }
.page :is(.grid2, .emoji-grid, .cards, .room-layout) { min-height: 0; }

/* The three-button start screen fits without moving the page. */
#home.chill-home { justify-content: center; align-items: center; padding-top: 0; padding-bottom: 0; }
.chill-home .chill-kicker { flex: 0 0 auto; margin: 0 0 10px; font-size: 9px; }
.chill-home .chill-mascot { flex: 0 0 auto; width: clamp(74px, 14dvh, 126px); height: clamp(74px, 14dvh, 126px); margin: 0 0 20px; border-radius: 28px; }
.chill-home .chill-title { flex: 0 0 auto; margin: 0 0 9px; font-size: clamp(28px, 4.8dvh, 47px); line-height: 1.06; }
.chill-home .chill-description { flex: 0 0 auto; margin: 0 0 16px; font-size: clamp(10px, 1.7dvh, 13px); line-height: 1.6; }
.chill-home .chill-actions { flex: 0 0 auto; width: min(100%, 480px); display: grid; gap: 10px; }
.chill-home .chill-action { min-height: 58px; padding: 11px 15px; border-radius: 15px; }
.chill-home .chill-action .action-icon { width: 34px; height: 34px; font-size: 21px; }
.chill-home .chill-action > span:not(.action-icon):not(.action-arrow) { font-size: 13px; }
.chill-home .chill-action small { font-size: 10px; line-height: 1.4; margin-top: 3px; }
.chill-home .chill-footnote { flex: 0 0 auto; margin: 13px 0 0; font-size: 9px; }

/* Each detail screen owns its overflow, never the application frame. */
#space { overflow-y: auto; overscroll-behavior: contain; padding-right: 3px; scrollbar-width: thin; }
#space > * { flex-shrink: 0; }
#studio > .grid2 { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 2px 4px 12px 0; scrollbar-width: thin; }
#studio .preview { max-height: 38dvh; min-height: 155px; }
#studio .controls { gap: 7px; margin-block: 12px; }
#studio .controls .btn { min-height: 44px; }
#studio .panel { min-height: min-content; }
#emojis > .panel { flex: 0 0 auto; padding: 12px 15px; margin-bottom: 10px !important; }
#emojis > .panel p { display: none; }
#emojis .emoji-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; align-content: start; padding: 4px 4px 16px 0; scrollbar-width: thin; }
#emojis > .hint { flex: 0 0 auto; font-size: 9px; margin: 8px 0 0; }
#emojis .emoji-card { min-height: 125px; }
#discover .hero { flex: 0 0 auto; max-height: 250px; }
#discover .feature { min-height: 220px; max-height: 250px; padding: 20px; }
#discover .spotlight { max-height: 250px; padding: 20px; }
#discover .feature h2 { font-size: 26px; }
#discover .feature-copy p { display: none; }
#discover .section-head { flex: 0 0 auto; margin: 15px 0 0; }
#discover .cards { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; align-content: start; padding-right: 4px; padding-bottom: 14px; scrollbar-width: thin; }
#discover .bottom-banner { display: none; }
#party > .grid2, #earnings > .grid2 { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 2px 4px 12px 0; scrollbar-width: thin; }
#earnings .stats { flex: 0 0 auto; margin-block: 13px; }
#earnings .stat { padding: 16px; }
#earnings .stat b { font-size: 25px; margin-block: 8px; }
.page :is(input, textarea, select) { font-size: 16px; }
dialog { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }

/* A live room keeps its stage, five places and controls in the fixed frame. */
#liveRoom.live-room-fixed { gap: 8px; min-height: 0; }
.live-room-fixed .room-header { flex: 0 0 auto; margin-bottom: 6px; gap: 8px; }
.live-room-fixed .room-header h2 { font-size: 21px; margin-bottom: 3px; }
.live-room-fixed .room-header p { font-size: 10px; }
.live-room-fixed .room-layout { display: flex; flex-direction: column; align-items: stretch; flex: 1 1 auto; min-height: 0; overflow: hidden; gap: 9px; }
.live-room-fixed .room-stage { flex: 1 1 auto; width: 100%; min-height: 100px; aspect-ratio: auto; max-height: none; }
.live-room-fixed .room-stage video { height: 100%; width: 100%; max-height: 100%; object-fit: contain; }
.live-room-fixed .room-seats { flex: 0 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; min-height: 0; margin: 7px 0; }
.live-room-fixed .room-seat { min-width: 0; padding: 8px 4px 4px; border-radius: 13px; }
.live-room-fixed .seat-number { top: 4px; left: 5px; font-size: 8px; }
.live-room-fixed .seat-avatar { width: 30px; height: 30px; font-size: 14px; margin: 3px auto 5px; }
.live-room-fixed .seat-name { min-height: 14px; font-size: 10px; margin-bottom: 5px; }
.live-room-fixed .seat-mic { display: none; }
.live-room-fixed .room-seat .btn { min-height: 44px; padding: 5px 3px !important; font-size: 9px !important; border-radius: 8px; }
.live-room-fixed .room-toolbar { flex: 0 0 auto; flex-wrap: wrap; overflow: visible; min-height: 49px; gap: 7px; margin: 5px 0; padding-bottom: 3px; }
.live-room-fixed .room-toolbar .btn { min-height: 44px; white-space: normal; }
#roomsPanel { margin-bottom: 0; }
#sharedStageEmpty { min-width: 0; max-width: 100%; }
#sharedRoomSession > .room-toolbar:not(.room-bottom-tools) { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: stretch; }
#roomsPanel #sharedRoomSession > .room-toolbar:not(.room-bottom-tools) > .btn { min-width: 0; min-height: 44px; padding: 7px 5px; font-size: 11px; line-height: 1.3; white-space: normal; overflow-wrap: anywhere; }
#roomsPanel .room-bottom-tools { display: flex; flex-wrap: wrap; overflow: visible; gap: 7px 12px; min-height: 44px; }
#roomsPanel .room-bottom-tools select { min-height: 44px; }
.live-room-fixed .room-audio-notice, .live-room-fixed .room-error { flex: 0 0 auto; max-height: 85px; overflow-y: auto; padding: 7px 10px; margin: 3px 0; font-size: 10px; }
.live-room-fixed .room-invite { flex: 0 0 auto; max-height: 115px; overflow-y: auto; margin: 4px 0; }

@media(max-width: 760px) {
  .content { padding: 8px 14px calc(80px + env(safe-area-inset-bottom, 0px)); }
  .topbar { padding-left: max(15px, env(safe-area-inset-left)); padding-right: max(15px, env(safe-area-inset-right)); }
  .mobile-brand { font-size: 23px; }
  .page-title h1, .title-row h1 { font-size: 26px; }
  .title-row .demo-tag { font-size: 8px; padding: 5px 6px; }
  #discover .hero { max-height: 195px; }
  #discover .feature { min-height: 180px; max-height: 195px; padding: 17px; }
  #discover .feature h2 { font-size: 23px; margin: 6px 0; }
  #discover .spotlight { display: none; }
  #discover .musician { height: 210px; transform: scale(.8) rotate(-10deg); transform-origin: bottom right; }
  #emojis > .panel { padding: 10px; gap: 10px !important; }
  #emojis > .panel b { font-size: 11px; }
  #emojis .emoji-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
  .live-room-fixed .room-seats { gap: 4px; }
  .live-room-fixed .room-seat { padding-inline: 3px; }
  .live-room-fixed .seat-name { font-size: 9px; }
  #sharedRoomSession > .room-toolbar:not(.room-bottom-tools) { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  #roomsPanel #sharedRoomSession > .room-toolbar:not(.room-bottom-tools) > .btn { font-size: 10.5px; }
}
@media(max-height: 680px) {
  .chill-home .chill-mascot { width: 68px; height: 68px; margin-bottom: 14px; border-radius: 20px; }
  .chill-home .chill-title { font-size: 29px; }
  .chill-home .chill-description { margin-bottom: 11px; font-size: 10px; }
  .chill-home .chill-action { min-height: 52px; padding-block: 8px; }
  .chill-home .chill-actions { gap: 8px; }
  .chill-home .chill-kicker { margin-bottom: 7px; font-size: 8px; }
  .chill-home .chill-footnote { margin-top: 8px; font-size: 8px; }
  #discover .hero { display: none; }
  .page-title .lead { display: none; }
  .page-title { margin-bottom: 8px; }
}
@media(max-height: 500px) and (min-width: 550px) {
  .chill-home .chill-mascot, .chill-home .chill-kicker, .chill-home .chill-footnote { display: none; }
  .chill-home .chill-title { font-size: 26px; }
  .chill-home .chill-title br { display: none; }
  .chill-home .chill-description { margin: 8px 0 14px; }
  .chill-home .chill-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; max-width: 850px; }
  .chill-home .chill-action { grid-template-columns: 25px minmax(0, 1fr); padding: 10px; min-height: 63px; }
  .chill-home .chill-action .action-icon { width: 25px; height: 30px; }
  .chill-home .action-arrow { display: none; }
  .chill-home .chill-action small { font-size: 9px; }
}
