/* Mobile community UI; desktop visual language stays in forum.css. */
.mobile-menu { display: none; }
.community-account > svg { display: none; }
.layout > *, .topic-layout > *, .form-layout > *, .rightbar > *,
.author-line > div, .notice-item > div, .sidebar { min-width: 0; }
.button, .tags a, .tags > span, .pill, .breadcrumbs a,
.author-line a, .notice-item strong, .notice-item a, .my-item h2,
.public-profile h1, .page-heading h1 { overflow-wrap: anywhere; }
.post-actions > *, .editor input, .editor select, .editor textarea,
.reply-editor textarea, .report textarea { max-width: 100%; min-width: 0; }

@media (max-width: 850px) {
  html { scroll-padding-top: 88px; }
  body { -webkit-text-size-adjust: 100%; }
  .topbar { z-index: 10; }
  .topinner {
    position: relative;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    min-height: 68px;
    gap: 10px;
    padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  }
  .brand-divider, .community-brand, .sidebar, .topnav .query-link { display: none; }
  .logo { justify-self: start; min-width: 0; white-space: nowrap; gap: 3px; font-size: 1rem; }
  .logo-mark { flex-shrink: 0; width: 30px; height: 30px; margin-right: 3px; }
  .topnav { min-width: 0; margin-left: 0; gap: 8px; }
  .topnav .bell { width: 44px; height: 44px; align-items: center; justify-content: center; padding: 10px; }
  .topnav .bell b { top: 1px; right: 0; }
  .topnav .community-account { width: 44px; min-height: 44px; padding: 10px; }
  .community-account > svg { display: block; }
  .community-account > span { display: none; }
  .topnav .community-login { min-height: 44px; padding: 10px 12px; font-size: .875rem; }
  .mobile-menu { display: block; }
  .mobile-menu > summary {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 10px;
    color: #244c89; background: #eff4fd;
    border: 1px solid #dce6f6; border-radius: 11px;
    cursor: pointer; list-style: none;
  }
  .mobile-menu > summary::-webkit-details-marker { display: none; }
  .mobile-menu > summary:focus-visible { outline: 3px solid #e4a637; outline-offset: 3px; }
  .mobile-menu .menu-close-icon, .mobile-menu[open] .menu-open-icon { display: none; }
  .mobile-menu[open] .menu-close-icon { display: block; }
  .mobile-menu[open] > summary { color: #fff; background: #2857cc; border-color: #2857cc; }
  .mobile-menu-panel {
    position: absolute; top: calc(100% + 6px);
    left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right));
    display: grid; gap: 3px; padding: 16px;
    max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px);
    overflow-y: auto; overscroll-behavior: contain;
    border: 1px solid #d8e3f4; border-radius: 16px;
    background: #fff; box-shadow: 0 16px 42px #12386e30;
  }
  .mobile-menu-heading { display: flex; gap: 12px; justify-content: space-between; align-items: center; padding: 4px 10px 12px; font-size: 1.05rem; font-weight: 800; color: #173d77; }
  .mobile-menu-heading span { font-size: .75rem; letter-spacing: .08em; color: #7990b0; }
  .mobile-menu-panel > a { min-height: 46px; padding: 11px 12px; display: flex; gap: 10px; align-items: center; color: #344f77; font-size: .9375rem; font-weight: 600; border-radius: 9px; overflow-wrap: anywhere; }
  .mobile-menu-panel > a.selected { color: #2857cc; background: #eaf1ff; }
  .mobile-menu-panel > a:hover { text-decoration: none; background: #f0f5fd; }
  .mobile-menu-panel > .mobile-new-topic { color: #fff; background: #2857cc; justify-content: center; margin-top: 8px; }
  .mobile-menu-panel > .mobile-new-topic:hover { background: #2048b0; }
  .mobile-menu-panel .eyebrow { margin: 14px 12px 6px; }
  .mobile-menu-panel .side-divider { display: block; margin: 10px 12px; }
  .layout { display: block; padding: 20px max(20px, env(safe-area-inset-right)) 20px max(20px, env(safe-area-inset-left)); }
  .topic-layout, .form-layout { grid-template-columns: minmax(0, 1fr); }
  .welcome { padding: 22px; gap: 20px; margin-bottom: 18px; }
  .welcome h1 { font-size: 1.8rem; line-height: 1.2; margin-bottom: 10px; }
  .welcome h1 br { display: none; }
  .welcome p { line-height: 1.5; font-size: 1rem; }
  .search { margin-bottom: 20px; gap: 10px; }
  .search input { font-size: 16px; min-height: 44px; }
  .search button { min-height: 44px; font-size: .875rem; }
  .filters a { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; font-size: .875rem; }
  .rightbar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 4px; }
  .rightbar .community-stats { display: none; }
  .rightbar .card { padding: 18px; }
  .card { max-width: 100%; }
  .topic-card .excerpt, .topic-card h3, .post-body, .quiet-empty, .notice-item p { font-size: 1rem; }
  .post-body { line-height: 1.75; }
  .post-actions { gap: 8px; }
  .post-actions .button, .post-actions .text-action, .report summary,
  .notice-item .text-action, .tags a, .footer a { min-height: 44px; }
  .text-action { display: inline-flex; justify-content: center; align-items: center; font-size: .875rem; }
  .report summary { padding: 10px 0; font-size: .875rem; }
  .tags a { display: inline-flex; align-items: center; font-size: .875rem; }
  .editor input:not([type=checkbox]), .editor select, .editor textarea,
  .reply-editor textarea, .report textarea { font-size: 16px; min-height: 48px; scroll-margin-top: 95px; scroll-margin-bottom: 24px; }
  .editor textarea, .reply-editor textarea { min-height: 160px; }
  .editor label, .reply-editor label, .report label { font-size: .9375rem; }
  .editor #id_tags { gap: 8px; }
  .editor #id_tags label { display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 10px; font-size: .875rem; }
  .editor #id_tags input[type=checkbox] { flex-shrink: 0; margin: 0; }
  .editor input[type=checkbox] { width: 20px; height: 20px; }
  .author-line { align-items: flex-start; gap: 10px; }
  .author-line > div { flex: 1; }
  .author-line a { font-size: .9375rem; }
  .author-line .permalink { flex-shrink: 0; display: grid; place-items: center; min-width: 36px; min-height: 44px; margin-top: -7px; }
  .breadcrumbs { flex-wrap: wrap; row-gap: 3px; font-size: .875rem; }
  .breadcrumbs a { padding: 5px 0; }
  .reply, .reply-editor { scroll-margin-top: 94px; }
  .footer { padding: 20px max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); column-gap: 20px; row-gap: 4px; }
  .footer a { display: inline-flex; align-items: center; font-size: .875rem; }
  .footer > span { flex-basis: 100%; }
}

@media (max-width: 580px) {
  .topinner { gap: 8px; padding-right: max(12px, env(safe-area-inset-right)); padding-left: max(12px, env(safe-area-inset-left)); }
  .logo { font-size: .875rem; }
  .logo-mark { display: none; }
  .topnav { gap: 6px; }
  .topnav .community-login { padding: 10px; }
  .layout { padding: 14px max(12px, env(safe-area-inset-right)) 18px max(12px, env(safe-area-inset-left)); }
  .welcome { display: block; padding: 18px; border-radius: 14px; }
  .welcome .eyebrow { font-size: .75rem; margin-bottom: 9px; }
  .welcome h1 { font-size: 1.5rem; line-height: 1.2; }
  .welcome p { font-size: .9375rem; }
  .welcome .button { width: 100%; min-height: 46px; margin-top: 16px; font-size: .9375rem; }
  .search { padding: 5px 6px 5px 12px; margin-bottom: 18px; gap: 8px; }
  .search > svg { width: 18px; height: 18px; }
  .search button { padding: 10px 12px; }
  .feed-top { flex-wrap: wrap; gap: 6px 10px; margin-bottom: 10px; }
  .feed-top h2 { font-size: 1.125rem; }
  .feed .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding-bottom: 12px; margin-bottom: 12px; }
  .filters a { padding: 8px 10px; font-size: .875rem; }
  .topic-card { display: block; padding: 16px; border-radius: 12px; }
  .topic-card > .topic-avatar { display: none; }
  .topic-card .meta { margin-bottom: 10px; font-size: .8125rem; }
  .topic-card .topic-bottom { font-size: .8125rem; gap: 6px 12px; }
  .topic-card .reply-count { flex-basis: auto; margin-left: auto; }
  .topic-bottom > a { max-width: 100%; overflow-wrap: anywhere; }
  .card { padding: 18px; border-radius: 14px; }
  .rightbar { grid-template-columns: minmax(0, 1fr); }
  .rightbar .safe-card { padding: 16px 18px; }
  .rightbar .safe-card .mini-icon { display: none; }
  .empty-state { padding: 28px 18px; }
  .empty-state p { font-size: 1rem; }
  .empty-state .empty-icon { width: 46px; height: 46px; border-radius: 14px; font-size: 1.5rem; margin-bottom: 14px; }
  .empty-state .button { width: 100%; font-size: .9375rem; }
  .page-heading { padding: 4px 0 20px; }
  .page-heading h1 { font-size: 1.7rem; line-height: 1.2; }
  .page-heading p { font-size: 1rem; }
  .original-post { padding: 20px 18px; }
  .original-post h1 { font-size: 1.65rem; margin: 12px 0 20px; }
  .post-body { margin-bottom: 20px; }
  .post-actions > form { flex: 1 1 100%; }
  .post-actions > form .button { width: 100%; }
  .post-actions > .button { flex: 1 1 100%; }
  .post-actions .button { font-size: .875rem; padding: 11px 12px; }
  .post-actions .text-action { flex: 1 1 auto; padding: 8px 10px; }
  .report form { padding: 12px; }
  .report button { width: 100%; }
  .accepted-label { margin: -18px -18px 18px; padding: 12px 18px; border-radius: 13px 13px 0 0; }
  .editor p { margin-bottom: 18px; }
  .editor .form-footer { padding-top: 16px; }
  .form-footer > span { max-width: none; font-size: .875rem; }
  .editor .form-footer .button, .reply-editor .button { width: 100%; min-height: 48px; font-size: .9375rem; }
  .notice { font-size: .9375rem; padding: 13px 15px; }
  .notice-item { gap: 10px; padding: 16px; }
  .notice-item > form { flex-shrink: 0; }
  .notice-item .text-action { padding: 8px 4px; }
  .pagination { gap: 8px; justify-content: space-between; }
  .pagination > span { order: -1; flex-basis: 100%; text-align: center; margin-bottom: 4px; }
  .pagination .button { min-height: 44px; font-size: .875rem; }
  .public-profile h1 { font-size: 1.6rem; }
  .disclaimer, .hint, .helptext { font-size: .875rem; }
}

@media (max-width: 360px) {
  .topinner { column-gap: 6px; padding-left: 10px; padding-right: 10px; }
  .logo { font-size: .8125rem; }
  .topnav { gap: 2px; }
  .topnav .community-login { max-width: 94px; font-size: .875rem; padding: 8px; }
  .mobile-menu-heading { flex-wrap: wrap; gap: 3px; }
  .mobile-menu-panel { padding: 12px; }
  .search { display: grid; grid-template-columns: 18px minmax(0, 1fr); }
  .search button { grid-column: 1 / -1; width: 100%; }
}

/* Short landscape viewports leave space for the keyboard instead of fixing the header. */
@media (max-height: 500px) and (max-width: 950px) {
  .topbar { position: relative; }
  .mobile-menu-panel { max-height: calc(100dvh - 86px); }
}
