/* ════════════════════════════════════════════════════════════════════════
   mobile.css — THE mobile UI layer (phones only).

   Everything mobile lives HERE, separate from the desktop UI in style.css:
   change one without touching the other. Every rule is scoped `html.mob`
   (plus the base display:none for the mobile-only elements), so on
   desktops this whole file is inert even though it always loads. The
   `mob` class is set by the device-detection script at the top of
   index.html <head>; the matching behavior lives in app.js inside the
   "MOBILE UI" module (search for that banner).
   ════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE — DEVICE-based, not width-based. A head script adds `mob` to
   <html> on phones (UA detection; tablets count as desktop-class), so:
     · a phone gets this chrome at ANY width/orientation (incl. landscape),
     · a desktop never gets it, even in a narrow window (which keeps the
       ordinary width-based responsive rules above).
   The chrome: fixed bottom tab bar (Home · Consensus · Search · Agents ·
   Me) + floating compose button; the ☰ drawer stays for secondary content.
   Safe-area aware (viewport-fit=cover exposes env(safe-area-inset-*)).
   ═══════════════════════════════════════════════════════════════════════ */
:root { --mtab-h: 56px; }
#mtab, #mtab-compose { display: none; }

html.mob #mtab {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; align-items: stretch;
  height: calc(var(--mtab-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 env(safe-area-inset-right, 0px)
           env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: var(--bg-sidebar, #fff);
  border-top: 1px solid var(--border, #e6e9f0);
  box-shadow: 0 -4px 18px rgba(15, 23, 42, .07);
}
html.mob .mtab-btn {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px;
  border: none; background: none; cursor: pointer;
  color: var(--muted, #6b7280);
  font-size: 10px; font-weight: 700; letter-spacing: .01em;
  padding: 6px 0 4px;
  -webkit-tap-highlight-color: transparent;
}
html.mob .mtab-btn .mtab-ico { font-size: 20px; line-height: 1; }
html.mob .mtab-btn .mtab-lbl {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
html.mob .mtab-btn.is-active { color: var(--accent, #2563eb); }

/* Floating compose (Home tab only — app.js toggles data-off). */
html.mob #mtab-compose {
  position: fixed; right: 16px; z-index: 59;
  bottom: calc(var(--mtab-h) + env(safe-area-inset-bottom, 0px) + 16px);
  width: 52px; height: 52px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--neo-grad, linear-gradient(120deg, #2563eb, #0d9488));
  color: #fff; font-size: 21px; border: none; cursor: pointer;
  box-shadow: 0 6px 20px rgba(37, 99, 235, .38);
  -webkit-tap-highlight-color: transparent;
}
html.mob #mtab-compose[data-off] { display: none; }

/* App chrome on the DEVICE regardless of width: mobile-bar on top, no
   desktop topbar, single column, off-canvas sidebar — these mirror the
   width-based ≤720/≤1180 rules so a phone held LANDSCAPE (wider than the
   breakpoints) still gets the phone layout. */
html.mob #neo-topbar { display: none; }
html.mob .mobile-bar { display: flex; }
html.mob #mobile-sidebar-toggle { display: block; }
html.mob .sidebar-header { display: block; }
html.mob .app {
  grid-template-columns: 1fr;
  height: calc(100vh - 48px - var(--mtab-h) - env(safe-area-inset-bottom, 0px));
  height: calc(100dvh - 48px - var(--mtab-h) - env(safe-area-inset-bottom, 0px));
}
html.mob .sidebar {
  position: fixed; top: 48px; left: 0;
  width: 86%; max-width: 320px; z-index: 50;
  transform: translateX(-100%);
  transition: transform .2s ease; max-height: none;
  bottom: calc(var(--mtab-h) + env(safe-area-inset-bottom, 0px));
}
html.mob .sidebar.drawer-open { transform: translateX(0); }
html.mob .market-panel {
  position: fixed; top: 48px; right: 0;
  width: 360px; max-width: 86%; z-index: 50;
  display: flex; transform: translateX(100%);
  transition: transform .2s ease; max-height: none;
  bottom: calc(var(--mtab-h) + env(safe-area-inset-bottom, 0px));
}
html.mob .market-panel.drawer-open { transform: translateX(0); }
html.mob .mobile-backdrop:not([hidden]) { display: block; }
html.mob #cm-rail-right, html.mob #cm-right-rail { display: none; }

/* ---- Core-surface fit + touch targets ---------------------------------- */
html.mob .detail-overlay { padding: 16px 12px; }
html.mob .detail-head h1 { font-size: 21px; }
html.mob .cm-actions { max-width: none; }
html.mob .cm-act { padding: 9px 10px; font-size: 13px; }
html.mob .cm-act .cm-act-ic { font-size: 16px; }
html.mob .ticker-range-btn { padding: 8px 12px; font-size: 13px; }
html.mob .kg-tl-chip { padding: 7px 12px; }
html.mob { --cm-colw: 100%; }
html.mob .chat-input-form { padding: 8px 12px 12px 12px; }
html.mob .chat-messages { padding: 0 12px; }

/* ---- Mobile full-screen search page (Search tab) ----------------------- */
#msearch { display: none; }
html.mob #msearch:not([hidden]) {
  display: flex; flex-direction: column;
  position: fixed; left: 0; right: 0; top: 48px;
  bottom: calc(var(--mtab-h) + env(safe-area-inset-bottom, 0px));
  z-index: 55;                 /* over content, under the tab bar (60) */
  background: var(--bg, #fff);
}
html.mob .msearch-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border, #e6e9f0);
  background: var(--bg-sidebar, #f7f8fa);
}
html.mob #msearch-input {
  width: 100%; box-sizing: border-box;
  font-size: 16px;             /* ≥16px stops iOS zoom-on-focus */
  padding: 11px 16px; border-radius: 999px;
  border: 1px solid var(--border, #d5d9e0);
  background: var(--bg, #fff); color: inherit;
}
html.mob #msearch-input:focus { outline: none; border-color: var(--accent, #2563eb); }
html.mob #msearch-results {
  flex: 1; overflow-y: auto; margin: 0; list-style: none;
  padding: 4px 14px 24px;
}
/* Result rows: full-width, finger-sized, separated — not sidebar chips. */
html.mob #msearch-results .sidebar-list-item {
  padding: 13px 2px; font-size: 14.5px; line-height: 1.4;
  border-bottom: 1px solid var(--border, #eceff3); border-radius: 0;
}
html.mob #msearch-results .sidebar-list-item.placeholder,
html.mob #msearch-results .sidebar-list-header { border-bottom: none; }
/* The $TICKER hit leads as a tappable accent card. */
html.mob #msearch-results .search-hit-ticker {
  margin: 10px 0 4px; padding: 14px;
  border: 1px solid var(--accent, #2563eb); border-radius: 12px;
  font-size: 15.5px; font-weight: 700; color: var(--accent, #2563eb);
  background: rgba(37, 99, 235, .05);
}

/* ---- Mobile drawer declutter ------------------------------------------- */
/* The drawer is SECONDARY on phones (profile, composer, context) — the
   bottom tab bar owns navigation. Hide the desktop chrome that crowded a
   390px panel: the icon nav-rail (Chats/Movers/Watch/… — admins saw all of
   it), the duplicate brand header (the top mobile-bar already shows it),
   the duplicate search box (the Search tab is a dedicated page), and the
   status/version telemetry lines. Sign out stays; a ⚙️ Settings entry is
   injected next to it (app.js) since the rail's settings button is gone. */
html.mob .nav-rail { display: none; }
html.mob .sidebar .sidebar-header { display: none; }
html.mob #community-search-row,
html.mob #community-search-results { display: none; }
html.mob .sidebar .status-indicator,
html.mob .sidebar .data-status { display: none; }
html.mob .sidebar-footer .disclaimer { font-size: 10px; opacity: .75; }

/* ---- Mobile compose sheet (✍️ FAB) ------------------------------------- */
#mcompose { display: none; }
html.mob #mcompose:not([hidden]) {
  display: flex; flex-direction: column;
  position: fixed; left: 0; right: 0; top: 48px;
  bottom: calc(var(--mtab-h) + env(safe-area-inset-bottom, 0px));
  z-index: 56; background: var(--bg, #fff);
}
html.mob .mcompose-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--border, #e6e9f0);
}
html.mob #mcompose-cancel {
  background: none; border: none; cursor: pointer; font-size: 14.5px;
  color: var(--muted, #6b7280); padding: 6px 4px;
}
html.mob #mcompose-send {
  background: var(--neo-grad, linear-gradient(120deg, #2563eb, #0d9488));
  color: #fff; border: none; cursor: pointer; font-size: 14px;
  font-weight: 800; padding: 8px 22px; border-radius: 999px;
}
html.mob #mcompose-send[disabled] { opacity: .6; }
html.mob #mcompose-body {
  flex: 1; resize: none; border: none; outline: none;
  font-size: 16px;                     /* ≥16px stops iOS zoom-on-focus */
  line-height: 1.5; padding: 14px; background: transparent; color: inherit;
  font-family: inherit;
}
html.mob .mcompose-status {
  min-height: 18px; padding: 0 14px 10px;
  font-size: 12px; color: var(--neg, #d64545);
}
