/* ============================================================
   Mysterious Matters — mobile.css
   Load AFTER app.css and nav.css.
   Nothing below applies above 780px: the desktop theme is untouched.
   ============================================================ */

/* ---- Global guards (all widths, harmless on desktop) ---- */
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }
img, video, iframe, table, pre { max-width: 100%; }
pre, code { overflow-wrap: anywhere; }
:where(input, textarea, select) { font-size: 16px; }
:where(a, button, [role="button"]):focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 780px) {

:root {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --bar-h: 52px;
  --tab-h: 56px;
  --gut: 14px;
}

body {
  padding-bottom: calc(var(--tab-h) + var(--safe-b));
  overscroll-behavior-y: none;
  font-size: 15px;
}
.shell { width: calc(100% - (var(--gut) * 2)); }
.page  { padding: 12px 0 24px; }

/* ============================================================
   1. APP BAR
   ============================================================ */
.site-head { padding-top: var(--safe-t); }
.top {
  height: var(--bar-h);
  min-height: var(--bar-h);
  padding: 0;
  gap: 9px;
  flex-wrap: nowrap;
}
.nav-toggle {
  display: grid; place-items: center;
  order: -1;
  width: 36px; height: 36px;
  flex: 0 0 36px;
  font-size: 15px;
  border-radius: 9px;
}
.brand { font-size: 15px; gap: 8px; min-width: 0; flex: 1 1 auto; }
.brand > span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { display: none; }
.brandmark { width: 22px; height: 22px; flex: 0 0 22px; border-width: 2px; }
.brandmark:after { width: 11px; height: 4px; left: 6px; top: 7px; }
.nav, .subnav-wrap, .site-head .menu { display: none; }

.actions { margin-left: auto; gap: 6px; flex: 0 0 auto; }
.actions > *:not(.alert-button):not(.btn.primary) { display: none; }
.actions .btn { min-height: 34px; padding: 0 12px; font-size: 9px; }
.actions .alert-button {
  position: relative;
  width: 36px; height: 36px; min-height: 36px;
  padding: 0;
  font-size: 0;
  border-radius: 9px;
}
.actions .alert-button::before {
  content: "\25D4"; font: 400 15px/1 var(--serif); color: var(--muted);
}
.actions .alert-button .alert-count {
  position: absolute; top: -5px; right: -5px;
  margin: 0;
}

/* ============================================================
   2. DRAWER
   ============================================================ */
.mobile-nav {
  display: flex !important;
  flex-direction: column;
  gap: 1px;
  position: fixed;
  left: 0; right: auto; top: 0; bottom: 0;
  z-index: 90;
  width: min(310px, 84vw);
  padding: calc(var(--safe-t) + 12px) 10px calc(var(--safe-b) + 12px);
  border: 0;
  border-right: 1px solid var(--line2);
  border-radius: 0;
  background: linear-gradient(180deg, #101627, var(--bg));
  box-shadow: 30px 0 80px rgba(0,0,0,.6);
  transform: translateX(-102%);
  opacity: 1;
  pointer-events: none;
  transition: transform .24s cubic-bezier(.32,.72,0,1);
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.nav-open .mobile-nav { transform: translateX(0); pointer-events: auto; }
.mobile-nav a, .mobile-nav button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; min-height: 44px;
  padding: 0 13px;
  border: 0; border-radius: 9px;
  background: transparent; color: var(--text);
  text-align: left;
  font: 500 15px var(--body); letter-spacing: 0; text-transform: none;
}
.mobile-nav a:active { background: rgba(95,208,207,.1); }
.mobile-nav a.on { color: var(--amber2); background: rgba(232,180,90,.08); }
.mobile-nav .drawer-label {
  padding: 14px 13px 5px;
  color: var(--dim);
  font: 700 8px var(--mono); letter-spacing: .16em; text-transform: uppercase;
}
.mobile-nav hr { border: 0; border-top: 1px solid var(--line); margin: 7px 4px; }
.mobile-nav .drawer-spacer { flex: 1 1 auto; min-height: 10px; }
.mobile-nav form { margin: 0; width: 100%; }
.mobile-nav .drawer-me { gap: 10px; min-height: 54px; font: 600 16px var(--serif); color: var(--amber2); }
.mobile-nav .drawer-me > :first-child {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center; overflow: hidden;
  border: 1px solid rgba(95,208,207,.45); border-radius: 50%;
  background: radial-gradient(circle at 30% 20%, var(--panel2), var(--deep));
  font: 700 11px var(--mono);
}
.mobile-nav .drawer-me img { width: 100%; height: 100%; object-fit: cover; }
.mobile-nav .alert-count {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; margin-left: 8px; padding: 0 5px;
  border-radius: 999px; background: var(--red); color: #1b0f0d;
  font: 700 9px/1 var(--mono);
}

body.nav-open::after, body.rail-open::after {
  content: ""; position: fixed; inset: 0; z-index: 80;
  background: rgba(4,6,12,.62);
}

/* ============================================================
   3. TAB BAR
   ============================================================ */
.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 75;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  border-top: 1px solid var(--line);
  background: rgba(9,12,21,.94);
  backdrop-filter: blur(18px);
}
.tabbar a {
  display: grid; place-items: center; align-content: center; gap: 3px;
  color: var(--dim);
  font: 700 8px var(--mono); letter-spacing: .06em; text-transform: uppercase;
}
.tabbar svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.tabbar a.on { color: var(--teal2); }
.tabbar a.compose svg {
  width: 30px; height: 30px; padding: 6px;
  border-radius: 9px;
  background: linear-gradient(var(--amber2), var(--amber));
  stroke: #1b1309; stroke-width: 2.2;
}

/* ============================================================
   4. HOME PAGE — the glass layout
   ============================================================ */

/* Forum list first, utility rail underneath. Reading the board is the
   reason someone opened the page; Members online is not. */
.glass-forum-shell {
  display: flex !important;
  flex-direction: column;
  gap: 12px;
}
.glass-forum-main { order: 1; min-width: 0; }
.glass-utility-rail { order: 2; position: static; display: grid; grid-template-columns: 1fr; gap: 10px; }

/* --- Welcome panel --- */
.glass-welcome {
  display: block !important;
  padding: 16px;
  margin-bottom: 12px;
}
.welcome-icon { display: none; }
.welcome-copy h1 { margin: 4px 0 6px; font: 700 23px/1.15 var(--serif); }
.welcome-copy p { font-size: 14px; line-height: 1.5; }
.welcome-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-start; }
.welcome-actions .btn { flex: 1 1 0; min-height: 42px; padding: 0 10px; font-size: 9px; }
.eyebrow { font-size: 7px; letter-spacing: .14em; }

/* --- Utility modules (Members online / Latest posts / Statistics) --- */
.glass-module { overflow: hidden; }
.module-head {
  display: flex !important;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.022);
}
.module-head span { display: inline-flex; flex: 0 0 auto; color: var(--teal2); font-size: 13px; line-height: 1; }
.module-head h2 { margin: 0 !important; font: 700 13px var(--serif) !important; }

.online-members, .latest-post-stack { padding: 4px 11px; }
.online-members > a, .latest-post-stack > a {
  display: flex !important;
  align-items: center;
  gap: 9px;
  padding: 9px 2px;
  border-bottom: 1px solid rgba(160,180,215,.09);
}
.online-members > a:last-child, .latest-post-stack > a:last-child { border-bottom: 0; }
.online-members .mini-avatar, .latest-post-stack .mini-avatar {
  width: 32px; height: 32px; flex: 0 0 32px; overflow: hidden;
}
.online-members .mini-avatar img, .latest-post-stack .mini-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.online-members > a > div, .latest-post-stack > a > div { min-width: 0; }
.online-members b, .latest-post-stack b {
  display: block !important;
  font: 600 13px/1.25 var(--serif);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.online-members small, .latest-post-stack small {
  display: block !important;
  margin-top: 2px;
  color: var(--dim);
  font: 700 7px var(--mono);
}
.member-presence.online:after, .member-presence.recently_left:after { left: 23px; top: 26px; }
.module-empty { padding: 12px 13px 14px; font-size: 12px; }
.module-foot {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
}

/* Statistics: label left, number right, on one line */
.rail-stats { padding: 4px 13px; }
.rail-stats p {
  display: flex !important;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0;
  padding: 9px 0;
  border-bottom: 1px solid rgba(160,180,215,.1);
}
.rail-stats p:last-child { border-bottom: 0; }
.rail-stats span { color: var(--muted); font-size: 13px; }
.rail-stats b { color: var(--amber2); font: 700 16px var(--serif); }

/* Below the fold on a phone, three modules is a lot of scrolling.
   Cap the lists; the full view is one tap away. */
.online-members > a:nth-child(n+6),
.latest-post-stack > a:nth-child(n+5) { display: none !important; }

/* --- Forum list --- */
.forum-list-heading {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 2px 2px 10px;
}
.forum-list-heading h2 { margin: 2px 0 0 !important; font: 700 21px var(--serif) !important; }
.forum-list-actions { display: flex; gap: 14px; }
.forum-list-actions a { font: 700 9px var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--dim); }

.glass-category { margin-bottom: 12px; }
.glass-category-head {
  display: flex !important;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
}
.glass-category-head > div { display: flex !important; gap: 9px; align-items: flex-start; min-width: 0; }
.category-folder { flex: 0 0 auto; margin-top: 2px; font-size: 12px; }
.glass-category-head h2 { margin: 0 !important; font: 700 15px/1.25 var(--serif) !important; }
.glass-category-head p { margin: 3px 0 0 !important; font-size: 11px !important; line-height: 1.4; }
.category-collapse { flex: 0 0 auto; min-width: 34px; min-height: 34px; }

.glass-forum-card-grid { grid-template-columns: 1fr !important; gap: 1px; }
.forum-card-primary {
  display: grid !important;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
  padding: 13px 14px;
}
.forum-card-icon { width: 26px; height: 26px; flex: 0 0 26px; font-size: 12px; }
.forum-title-line { display: flex !important; align-items: center; gap: 6px; flex-wrap: wrap; }
.forum-title-line h3 { margin: 0 !important; font: 700 15px/1.25 var(--serif) !important; }
.forum-card-copy p { margin: 5px 0 !important; font-size: 12.5px !important; line-height: 1.4; }
.forum-card-copy small { font-size: 7px; }

/* The per-card footer ran its two halves together. Separate them. */
.forum-card-foot, .card-empty {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-top: 1px solid rgba(160,180,215,.09);
  font-size: 11px;
}

/* ============================================================
   5. Every other multi-column grid in the app
   ============================================================ */
.forum-layout, .thread-with-rail, .board-layout, .advanced-forum-layout,
.advanced-forum-layout.sidebar-left, .layout-split, .admin-shell,
.split-admin, .security-grid, .recovery-grid, .master-detail,
.admin-dashboard-grid, .seo-layout, .structure-manager, .profilegrid,
.admin-preview-grid, .tool-grid, .form-grid, .form-two, .quick-action-grid,
.category-navigator, .permission-tools, .preview-shell {
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 12px;
}
.metric-grid, .trend-grid, .community-stats, .board-stats, .mock-stats {
  grid-template-columns: 1fr 1fr !important;
}

/* ---- Board and thread rows ---- */
.forum-row { grid-template-columns: 30px minmax(0,1fr); padding: 13px 14px; gap: 11px; }
.forum-row:hover { transform: none; }
.forum-row h3 { font-size: 16px; }
.forum-row p { font-size: 13px; }
.latest { display: none; }

.thread-row {
  grid-template-columns: 34px minmax(0,1fr);
  padding: 12px 14px; gap: 10px; align-items: start;
}
.thread-row h3 { font-size: 15.5px; line-height: 1.3; margin: 0 0 4px; overflow-wrap: anywhere; }
.thread-row .count, .thread-row .views, .thread-row .last { display: none; }
.thread-row .row-stats {
  display: block; margin-top: 4px;
  color: var(--dim); font: 700 9px var(--mono); text-transform: uppercase;
}

/* ---- Posts ---- */
.post { grid-template-columns: minmax(0,1fr) !important; margin-bottom: 10px; border-radius: 12px; }
.userbox {
  display: flex !important; align-items: center; gap: 10px;
  text-align: left; padding: 10px 14px;
  border-right: 0; border-bottom: 1px solid var(--line);
}
.userbox .avatar, .userbox .avatar-image {
  width: 36px; height: 36px; flex: 0 0 36px; margin: 0; font-size: 13px;
}
.userbox h3 { margin: 0; font-size: 14px; }
.userbox .trust, .userbox .userstats { display: none; }
.postmeta { padding: 8px 14px; font-size: 8px; gap: 8px; }
.prose { padding: 14px; font-size: 16px; line-height: 1.6; overflow-wrap: anywhere; }
.prose table { display: block; overflow-x: auto; }
.postfoot { gap: 2px; padding: 5px 8px; overflow-x: auto; scrollbar-width: none; }
.postfoot::-webkit-scrollbar { display: none; }
.postfoot button, .postfoot a { flex: 0 0 auto; min-height: 36px; padding: 0 10px; font-size: 9px; white-space: nowrap; }

.thread-head { flex-direction: column; align-items: stretch; gap: 9px; padding: 2px 0 12px; }
.thread-head h1 { font-size: 24px; line-height: 1.18; overflow-wrap: anywhere; }
.casebar { flex-wrap: wrap; gap: 9px 16px; padding: 11px 14px; }
.casebar .status { flex: 1 0 100%; margin: 0; }

/* ---- Profile ---- */
.profilehero { display: block; min-height: 0; padding: 16px; text-align: left; }
.profilehero .avatar, .profilehero .avatar-image { width: 68px; height: 68px; font-size: 22px; margin: 0 0 10px; }
.profilehero h1 { font-size: 25px; margin: 0 0 5px; overflow-wrap: anywhere; }
.box { padding: 15px; }

/* ---- Side rail as a bottom sheet ---- */
.side-rail {
  display: block; position: fixed;
  left: 0; right: 0; bottom: 0; top: auto; z-index: 85;
  width: auto; max-height: 78vh;
  padding: 8px 14px calc(var(--safe-b) + 18px);
  border-radius: 18px 18px 0 0;
  border-top: 1px solid var(--line2);
  background: rgba(11,15,26,.985);
  box-shadow: 0 -25px 70px rgba(0,0,0,.55);
  transform: translateY(102%);
  transition: transform .26s cubic-bezier(.32,.72,0,1);
  overflow-y: auto; overscroll-behavior: contain;
}
body.rail-open .side-rail { transform: translateY(0); }
.side-rail::before {
  content: ""; display: block;
  width: 36px; height: 4px; margin: 4px auto 12px;
  border-radius: 999px; background: var(--line2);
}
.sticky-side { position: static; }
.rail-close { width: 100%; min-height: 44px; margin-top: 10px; }
.rail-fab { right: 14px; bottom: calc(var(--tab-h) + var(--safe-b) + 12px); }

/* ---- Admin ---- */
.admin-nav {
  position: static; display: flex; gap: 4px; padding: 7px;
  overflow-x: auto; scrollbar-width: none;
}
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav .admin-brand { display: none; }
.admin-nav a { flex: 0 0 auto; padding: 10px 12px; white-space: nowrap; }
.admin-topbar { position: static; }
.section-head { flex-direction: column; align-items: stretch; gap: 8px; }
.section-head h1 { font-size: 22px; }
.master-list { max-height: none; }
.permission-matrix, .matrix-scroll { overflow-x: auto; }
.matrix-head, .matrix-row { grid-template-columns: minmax(150px,1fr) repeat(4,62px); min-width: 400px; }
.admin-row { flex-direction: column; align-items: stretch; gap: 8px; }

/* ---- Forms and editor ---- */
.toolbar { flex-direction: column; }
.searchbox { max-width: none; }
.form { padding: 15px; }
.btn { min-height: 42px; padding: 0 14px; }
.note-toolbar { display: flex !important; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.note-toolbar::-webkit-scrollbar { display: none; }
.note-editable { font-size: 16px !important; }
.note-editor .note-statusbar { display: none; }
.alert { font-size: 14px; }

}
