/* Final responsive layer. Keep this after the page and theme styles. */
@media (max-width: 900px) {
  body { min-width: 0; }
  body .page-wrap { width: 100%; min-width: 0; margin-left: 0; padding-inline: 0; }
  body .page-wrap > main { min-width: 0; margin-inline: auto; }
  body :is(h1,h2,h3) { overflow-wrap: anywhere; }
  body h1 { font-size: clamp(28px, 6vw, 40px); }
  body h2 { font-size: clamp(22px, 4.5vw, 30px); }
  body h3 { font-size: clamp(18px, 4vw, 24px); }
  body :is(input, select, textarea) { min-width: 0; max-width: 100%; font-size: 16px; }

  /* Use the same navigation breakpoint as the page layout, including tablets. */
  body.home-page .home-compact-nav { display: none; }
  body .sidebar, body .sidebar:has(.sidebar-link[href='/Perfil_usuario']) {
    position: fixed; top: auto; right: auto; bottom: calc(10px + env(safe-area-inset-bottom)); left: 50%;
    display: flex; width: min(calc(100% - 24px), 390px); height: 56px;
    min-height: 0; margin: 0; padding: 5px; transform: translateX(-50%);
  }
  body .sidebar :is(.sidebar-logo,.galar-nav-caption,.galar-nav-note) { display: none; }
  body .sidebar-nav { display: flex; flex-direction: row; width: 100%; gap: 2px; }
  body .sidebar-link { flex: 1 1 0; width: auto; min-width: 0; min-height: 44px; padding: 0 5px; font-size: 11px; }
  body .sidebar-link .sidebar-icon { display: none; }
  body.home-page .galar-top-profile { width: 42px !important; min-width: 42px !important; grid-template-columns: 42px !important; }
  body.home-page .galar-top-profile span { display: none !important; }
  body .top-menu-panel { top: 66px; right: 12px; width: min(380px, calc(100% - 24px)); max-height: calc(100dvh - 148px); overflow-y: auto; }
  body .quick-profile-user { grid-template-columns: 48px minmax(0,1fr); gap: 10px; }
  body .quick-profile-page-link { grid-column: 2; justify-self: start; }

  body.home-page .page-wrap > main.home-page-main { width: 100%; padding-bottom: 24px; }
  body.home-page :is(.home-wishlist-hero,.home-collection-banner,.home-section-hero) { width: min(calc(100% - 32px), 560px); gap: 16px; }
  body.home-page :is(.home-wishlist-hero-copy h1,.home-section-hero-copy h1,.home-collection-hero-copy h1) { font-size: clamp(28px,7vw,38px); }
  body.home-page :is(.home-wishlist-hero-copy p,.home-section-hero-copy p,.home-collection-hero-copy p) { font-size: 16px; line-height: 1.5; }
  body.home-page :is(.home-wishlist-hero-button,.home-community-button) { max-width: 100%; min-height: 44px; }

  body #wishlist-page .wishlist-mode-tab { min-width: 0; gap: 5px; font-size: 11px; }
  body #wishlist-page .wishlist-search-field { min-width: 0; }
  body #wishlist-page .wishlist-grid-actions { flex-wrap: wrap; }
  body #wishlist-page .wishlist-grid-actions button { min-height: 40px; padding-inline: 7px; }
  body #wishlist-page .album-binder-title-row, body #wishlist-page .album-binder-title-row > div { min-width: 0; max-width: 100%; }
  body #wishlist-page .album-icon-button { flex-shrink: 0; }
  body #wishlist-page .album-binder-title-row h2 { font-size: 24px; }
  body #wishlist-page .album-page { gap: clamp(6px,2vw,14px); padding: clamp(8px,2.5vw,18px); }
  body #wishlist-page .album-slot-add { font-size: 10px; padding: 4px; }
  body #wishlist-page .album-slot-remove { opacity: 1; }

  /* Dialogs scroll within the visible screen, including landscape phones. */
  body :is(.busca-modal-overlay,.modal-overlay-detalhe,.album-modal-overlay) { padding: 12px; align-items: center; justify-content: center; }
  body #busca-page.busca-modal-caixa { width: min(680px,100%); margin: 0; max-height: calc(100dvh - 24px); padding: 14px; border-radius: 14px; overflow-y: auto; }
  body #busca-page .search-container { clear: both; width: 100%; }
  body #busca-page .search-input-wrap { min-width: 0; }
  body #busca-page .catalog-grid-item { width: 100%; min-width: 0; padding-bottom: 0; }
  body #busca-page .catalog-grid-actions { position: static; min-height: 40px; margin-top: 6px; opacity: 1; transform: none; pointer-events: auto; }
  body #busca-page .catalog-grid-actions .add-wishlist-btn { width: 100%; min-height: 40px; font-size: 11px; }
  body #busca-page :is(.catalog-section-header,.colecoes-toolbar) { flex-wrap: wrap; gap: 10px; }
  body :is(.detalhe-caixa,.album-modal-card) { max-width: 100%; max-height: calc(100dvh - 24px); overflow-y: auto; }
  body .detalhe-conteudo { display: grid; grid-template-columns: minmax(0,1fr); }
  body .detalhe-imagem-col { margin-inline: auto; max-width: 100%; }
  body :is(.detalhe-imagem-col img,.detalhe-imagem-wrap img) { max-width: 100%; max-height: 48dvh; object-fit: contain; }
  body :is(.self-edit-card,.highlight-picker-card,.profile-banner-crop-card) { max-height: calc(100dvh - 24px); }

  body .public-profile-identity h1 { font-size: clamp(26px,6vw,36px); overflow-wrap: anywhere; }
  body :is(.social-panel,.social-search-card) { min-width: 0; padding: 16px; }
  body .social-section-heading { flex-wrap: wrap; gap: 12px; }
  body .social-section-heading h2 { font-size: 22px; }
  body .public-profile-grid { grid-template-columns: minmax(0,1fr); }
  body .public-favorite-pokemon > div { min-width: 0; overflow-wrap: anywhere; }
  body .public-social-links a { max-width: 100%; overflow-wrap: anywhere; }
  body .chat-shell { min-height: 0; }
  body :is(.chat-sidebar,.chat-panel) { height: clamp(280px, calc(100dvh - 240px), 620px); min-height: 0; }
  body .chat-active { min-height: 0; }
  body .chat-composer { min-width: 0; }
  body .chat-composer textarea { min-width: 0; }
  body.auth-body .auth-card { width: 100%; padding: 24px 18px; }
  body.auth-body .auth-card h1 { font-size: 32px; }
}
@media (max-width: 620px) {
  body #busca-page .catalog-cards-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px 12px; }
  body #wishlist-page .album-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px 12px; }
  body #wishlist-page .album-card-add { padding: 10px; gap: 5px; }
  body #wishlist-page .album-add-circle { width: 36px; height: 36px; }
  body #wishlist-page .wishlist-convite-vazio { flex-direction: column; gap: 12px; }
  body #wishlist-page .wishlist-convite-pokemon { flex-basis: auto; }
  body .public-profile-banner { height: clamp(120px,38vw,180px); }
  body .public-highlights { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
  body .highlight-picker-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

/* Mobile home and community: compact navigation and a dedicated full-screen panel. */
.galar-mobile-community-title { display: none; }
@media (max-width: 900px) {
  body .galar-masthead, body.home-page .galar-masthead { height: 64px !important; background: #f7f9fb; }
  body .galar-brand, body.home-page .galar-brand { display: flex !important; top: 20px; left: 16px; gap: 6px; }
  body .galar-brand > span:last-child { font-size: 12px; }
  body .galar-brand .galar-ball { width: 22px; height: 22px; }
  body .galar-brand small { display: none; }
  body .galar-top-actions, body.home-page .galar-top-actions { top: 12px !important; right: 16px !important; gap: 6px !important; width: auto; margin: 0; padding: 0; transform: none; }
  body .galar-top-profile, body.home-page .galar-top-profile { width: 38px !important; min-width: 38px !important; height: 38px !important; min-height: 38px !important; grid-template-columns: 38px !important; }
  body .galar-top-profile img, body.home-page .galar-top-profile img { width: 38px !important; height: 38px !important; }
  body .galar-top-icon, body.home-page .galar-top-icon { width: 38px !important; height: 38px !important; min-height: 38px; }
  body .page-wrap { padding-top: 64px; }
  body .sidebar, body .sidebar:has(.sidebar-link[href='/Perfil_usuario']) { height: 62px; padding: 4px; border-radius: 18px; }
  body .sidebar-link { min-height: 52px; flex-direction: column; gap: 3px; border-radius: 13px; font-size: 10px; font-style: normal; }
  body .sidebar-link .sidebar-icon { display: grid; place-items: center; width: 19px; height: 19px; }
  body .sidebar-link .sidebar-icon svg { width: 18px; height: 18px; }

  body.home-page .home-feature-shell { width: min(100%,600px); margin: 0 auto; padding: 8px 16px 16px; }
  body.home-page :is(.home-wishlist-hero,.home-collection-banner,.home-section-hero) { width: 100%; gap: 16px; }
  body.home-page :is(.home-wishlist-hero-art,.home-collection-banner picture,.home-section-hero > img) { aspect-ratio: 16 / 9; height: auto; border-radius: 12px; box-shadow: none; }
  body.home-page :is(.home-wishlist-hero-art img,.home-collection-banner picture img) { object-fit: contain; }
  body.home-page :is(.home-wishlist-hero-copy,.home-section-hero-copy,.home-collection-hero-copy) { padding: 0; }
  body.home-page :is(.home-wishlist-hero-copy h1,.home-section-hero-copy h1,.home-collection-hero-copy h1) { margin-bottom: 8px; font-size: clamp(26px,6.5vw,34px); line-height: 1.08; }
  body.home-page :is(.home-wishlist-hero-copy p,.home-section-hero-copy p,.home-collection-hero-copy p) { margin-bottom: 16px; font-size: 15px; line-height: 1.5; }
  body.home-page :is(.home-wishlist-hero-button,.home-community-button) { width: 100%; min-width: 0; min-height: 46px; margin: 0; justify-content: space-between; padding-inline: 16px; border-radius: 7px; }
  body.home-page .home-carousel-previews { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; width: 100%; margin-top: 22px; padding: 0; overflow: visible; }
  body.home-page .home-carousel-preview { display: grid; grid-template-columns: 48px minmax(0,1fr); gap: 8px; align-items: center; width: 100%; height: 64px; min-height: 64px; padding: 7px; border-radius: 8px; text-align: left; font-size: 11px; font-style: normal; text-transform: none; }
  body.home-page .home-carousel-preview img { position: static; width: 48px; height: 48px; opacity: 1; border-radius: 4px; object-fit: cover; }
  body.home-page .home-carousel-preview::before, body.home-page .home-carousel-preview::after { display: none; }
  body.home-page .home-carousel-preview span { position: static; align-self: center; min-width: 0; color: var(--ow-ink); text-shadow: none; line-height: 1.25; }
  body.home-page .home-carousel-preview.is-active { background: #fff5ed; box-shadow: inset 0 0 0 1px var(--ow-orange); }

  body.galar-social-menu-open { overflow: hidden; }
  body.galar-social-menu-open .galar-masthead { z-index: 1500; }
  body .galar-social-menu-overlay { inset: 0; background: rgba(24,32,44,.3); }
  body .galar-social-menu:has(.galar-community-frame) { inset: 0; display: flex; flex-direction: column; width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; box-shadow: none; animation: none; transform: none; }
  body .galar-social-menu[hidden] { display: none; }
  body .galar-social-menu:has(.galar-community-frame) > header.galar-community-menu-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; min-height: 60px; padding: max(8px,env(safe-area-inset-top)) 16px 8px; background: #fff; border-bottom: 1px solid var(--ow-line); }
  body .galar-mobile-community-title { display: block; font-size: 18px; color: var(--ow-ink); }
  body .galar-community-menu-header .galar-community-channel { display: none; }
  body .galar-social-menu > header.galar-community-menu-header > button { display: grid; place-items: center; width: 42px; height: 42px; flex-basis: 42px; padding: 0; border: 1px solid var(--ow-line); border-radius: 10px; color: var(--ow-ink); background: #f4f7fa; font-size: 30px; line-height: 1; cursor: pointer; }
  body .galar-community-frame { flex: 1 1 0; min-height: 0; height: 0; background: var(--ow-page); }

  /* The iframe has its own viewport: remove the full-page header/nav spacing. */
  body.social-embed .page-wrap { padding: 0 !important; min-height: 100dvh; }
  body.social-embed .page-wrap > main.social-main { width: 100%; margin: 0; padding: 16px 16px max(16px,env(safe-area-inset-bottom)); }
  body.social-embed .social-page-header { margin: 0 0 16px; }
  body.social-embed .social-page-header :is(h1,.social-kicker) { display: none; }
  body.social-embed .social-page-header p { font-size: 13px; line-height: 1.5; }
  body.social-embed .social-tabs { width: 100%; margin-bottom: 16px; padding: 4px; gap: 4px; }
  body.social-embed .social-tab { flex: 1 1 0; min-width: 0; min-height: 44px; gap: 5px; padding: 6px; font-size: 11px; }
  body.social-embed .social-search-card { margin-bottom: 16px; padding: 0; border: 0; background: none; box-shadow: none; }
  body.social-embed .social-search-field { min-height: 46px; padding: 0 12px; background: #fff; }
  body.social-embed .social-search-field input { font-size: 16px; }
  body.social-embed .social-search-hint { margin: 6px 0 0; font-size: 11px; }
  body .social-people-grid, body.social-embed .social-people-grid { grid-template-columns: minmax(0,1fr); gap: 10px; }
  body .social-user-card, body.social-embed .social-user-card { padding: 12px; border-radius: 12px; }
  body .social-user-top { gap: 12px; margin-bottom: 12px; }
  body .social-user-avatar { width: 44px; height: 44px; }
  body .social-user-copy { flex: 1; }
  body .social-user-copy strong { white-space: normal; overflow-wrap: anywhere; font-size: 14px; }
  body .social-user-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  body .social-user-actions .social-button { min-height: 40px; padding: 7px; font-size: 12px; }
  body.social-embed .chat-shell { min-height: 0; }
  body.social-embed :is(.chat-sidebar,.chat-panel) { height: max(240px,calc(100dvh - 170px)); min-height: 0; }
}
