/* Portrait layouts use the visible viewport, including browser bars and keyboard. */
@media (max-width:820px) {
  html {scroll-padding-top:calc(84px + var(--fg-safe-top, 0px));scroll-padding-bottom:calc(96px + var(--fg-safe-bottom, 0px));}
  body {min-width:0;}
  :is(#main-grid,#main-grid > *,#content-wrapper,#post-container,.prose,.fg-platform .main-content) {min-width:0;}
  :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),textarea,[contenteditable=true],.fg-select-trigger,#year-trigger) {font-size:16px!important;}
  :is(input,textarea,[contenteditable=true]) {scroll-margin-block:24px;}
  :is(#post-container,#content-wrapper > article) {overflow-wrap:anywhere;}
  :is(#post-container,#content-wrapper > article) :is(pre,table) {display:block;max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;}
  :is(#post-container,#content-wrapper > article) :is(img,video,iframe,audio) {max-width:100%;}
  #navbar {padding:calc(12px + var(--fg-safe-top, 0px)) 12px 0;}
  #navbar-card > #nav-menu-panel {position:absolute;top:calc(100% + 12px)!important;right:0;max-width:calc(100vw - 24px);max-height:calc(var(--fg-vv-height,100dvh) - 108px - var(--fg-safe-top,0px) - var(--fg-safe-bottom,0px));overflow-y:auto;overscroll-behavior:contain;}
  #nav-menu-panel a,.fg-account-panel a,.fg-account-panel button {min-height:48px;}
  .fg-account-panel {right:0;max-width:calc(100vw - 24px);max-height:calc(var(--fg-vv-height,100dvh) - 108px - var(--fg-safe-top,0px) - var(--fg-safe-bottom,0px));overflow:auto;overscroll-behavior:contain;}
  .fg-dialog {top:calc(var(--fg-vv-top,0px) + 12px + var(--fg-safe-top,0px));bottom:auto;margin:0 auto;width:calc(100% - 24px);max-width:430px;max-height:calc(var(--fg-vv-height,100dvh) - 24px - var(--fg-safe-top,0px) - var(--fg-safe-bottom,0px));padding:24px 20px;overscroll-behavior:contain;}
  .fg-profile-list {max-height:none;}
  .fg-search-dialog {top:calc(var(--fg-vv-top,0px) + 12px + var(--fg-safe-top,0px));margin:0 auto;width:calc(100% - 24px);max-height:calc(var(--fg-vv-height,100dvh) - 24px - var(--fg-safe-top,0px) - var(--fg-safe-bottom,0px));padding:18px 16px;border-radius:24px;overflow:hidden;}
  .fg-search-dialog[open] {display:flex;flex-direction:column;}
  .fg-search-dialog :is(header,form,.fg-search-status,footer) {flex:none;}
  .fg-search-dialog header {margin-bottom:14px;}
  .fg-search-dialog h2 {font-size:21px;}
  .fg-search-results {flex:1 1 auto;min-height:0;max-height:none;overflow-y:auto;}
  .fg-search-status {padding:14px 4px 10px;}
  .fg-search-dialog footer {display:none;}
  .fg-search-empty {padding:22px 12px;}
  html.fg-keyboard-open .fg-search-eyebrow {display:none;}
  html.fg-keyboard-open .fg-search-dialog header {margin-bottom:10px;}
  html.fg-keyboard-open .fg-search-dialog h2 {margin:0;}
  .fg-confirm-overlay {top:var(--fg-vv-top,0px);bottom:auto;height:var(--fg-vv-height,100dvh);padding:calc(12px + var(--fg-safe-top,0px)) 12px calc(12px + var(--fg-safe-bottom,0px));overflow:auto;}
  .fg-confirm-panel {max-height:100%;overflow:auto;padding:24px 20px;}
  .fg-confirm-actions {flex-wrap:wrap;}
  .fg-advanced-overlay {top:var(--fg-vv-top,0px)!important;bottom:auto!important;height:var(--fg-vv-height,100dvh);padding:calc(12px + var(--fg-safe-top,0px)) 12px calc(12px + var(--fg-safe-bottom,0px));}
  .fg-advanced-panel {max-height:100%;padding:20px 16px;}
  .fg-advanced-close,.fg-calendar-nav button {min-width:44px;min-height:44px;}
  .fg-select-option {min-height:44px;}
  .fg-select-trigger {min-height:48px;}
  .fg-platform-notice {bottom:calc(var(--fg-vv-bottom,0px) + 12px + var(--fg-safe-bottom,0px));max-width:calc(100vw - 24px);}
  body.gateway-page {min-height:var(--fg-vv-height,100dvh);padding:calc(20px + var(--fg-safe-top,0px)) 12px calc(20px + var(--fg-safe-bottom,0px));align-items:flex-start;}
  body.gateway-page .gateway-wrapper {margin:auto;padding:28px 22px;}
  body.gateway-page .halo-form :is(a,button) {min-height:44px;}
  html.fg-keyboard-open body.gateway-page .gateway-wrapper {margin:0 auto;}
  body.fg-platform :is(.layout,.main-content) {max-width:100%;min-height:0;}
  body.fg-platform .modal-wrapper .modal-content {max-height:calc(var(--fg-vv-height,100dvh) - 24px - var(--fg-safe-top,0px) - var(--fg-safe-bottom,0px));}
  body.fg-platform .modal-wrapper {top:var(--fg-vv-top,0px);bottom:auto;height:var(--fg-vv-height,100dvh);padding:12px;}
  body.fg-platform .drawer__content {max-height:var(--fg-vv-height,100dvh);}
  body.fg-platform :is(.btn,.dropdown-item-wrapper,.select-option-item) {min-height:44px;}
  body[data-entry-step] {min-height:var(--fg-vv-height,100dvh);padding:0;}
  body[data-entry-step] .entry {min-height:var(--fg-vv-height,100dvh);display:block;max-width:480px;padding:calc(28px + var(--fg-safe-top,0px)) 18px calc(20px + var(--fg-safe-bottom,0px));}
  body[data-entry-step] .wordmark {margin-bottom:20px;font-size:12px;}
  body[data-entry-step] .intro h1 {font-size:34px;margin-bottom:10px;}
  body[data-entry-step] .intro p {font-size:13px;margin:0 0 24px;}
  body[data-entry-step] .entry-card {padding:24px 20px;border-radius:25px;}
  body[data-entry-step] .steps {margin-bottom:22px;}
  body[data-entry-step] .sub {margin-bottom:22px;}
  body[data-entry-step] .entry-link {display:flex;align-items:center;justify-content:center;min-height:44px;margin-top:12px;}
  body[data-entry-step] footer {margin-top:24px;text-align:center;}
  #year-options {max-height:var(--fg-year-height,240px);top:calc(100% + 8px);bottom:auto;scroll-padding-block:6px;}
  #year-options.fg-year-up {top:auto;bottom:calc(100% + 8px);}
  #year-options .year-option {min-height:44px;height:44px;line-height:44px;font-size:16px;}
  .fg-media .fg-media-range {height:44px;min-height:44px;}
  .fg-media video {max-height:calc(var(--fg-vv-height,100dvh) - 110px);}
}
@media (max-width:767px) {
  /* Only the body reserves the shortcut bar; main-grid must not reserve it again. */
  body {padding-bottom:0;}
  body.fg-mobile-has-nav {padding-bottom:calc(92px + var(--fg-safe-bottom,0px));}
  body.fg-mobile-has-nav:has(.fg-player:not([hidden])) {padding-bottom:calc(164px + var(--fg-safe-bottom,0px));}
  #main-grid {padding-bottom:12px!important;}
  .fg-mobile-nav {left:12px;right:12px;bottom:calc(var(--fg-vv-bottom,0px) + 12px + var(--fg-safe-bottom,0px));}
  .floating-controls,#back-to-top-btn {bottom:calc(var(--fg-vv-bottom,0px) + 96px + var(--fg-safe-bottom,0px))!important;}
  .fg-player {left:12px;right:12px;bottom:calc(var(--fg-vv-bottom,0px) + 92px + var(--fg-safe-bottom,0px));}
  .fg-player .fg-music-close {min-width:44px;min-height:44px;}
  .fg-player .fg-volume input {height:44px;}
  body:has(.fg-player:not([hidden])) :is(.floating-controls,#back-to-top-btn) {bottom:calc(var(--fg-vv-bottom,0px) + 168px + var(--fg-safe-bottom,0px))!important;}
  html.fg-keyboard-open :is(.fg-mobile-nav,.floating-controls,#back-to-top-btn,.fg-player) {display:none!important;}
  html.fg-search-open :is(.fg-mobile-nav,.floating-controls,#back-to-top-btn,.fg-player) {visibility:hidden;}
  .post-card-content {padding:23px 20px!important;}
  #post-container,#content-wrapper > article {padding:24px 18px!important;}
  .fg-post-stats {flex-wrap:wrap;gap:8px;}
}
@media (max-width:820px) and (max-height:650px) {
  body[data-entry-step] .entry {padding-top:calc(20px + var(--fg-safe-top,0px));}
  body[data-entry-step] .wordmark {margin-bottom:12px;}
  body[data-entry-step] .intro h1 {font-size:28px;}
  body[data-entry-step] .intro p {margin-bottom:18px;}
  body[data-entry-step] .entry-card {padding:20px;}
  body[data-entry-step] .steps {margin-bottom:16px;}
}
