/* ═══════════════════════════════════════════════════════════════════════════════════════════
   ADE ALGO TERMINAL — PHONE LAYER for the MODE CELLS (ade-mobile.css)
   Built from work/mobile-audit-2026-10-10 (aries / planner-risk / omni / neo / heatmaps).

   RULES OF THIS FILE
   • EVERY rule lives inside the phone breakpoint — nothing here may touch desktop
     (>820px wide AND >500px tall). The two query forms are:
        PHONE      @media (max-width:820px), ((max-height:500px) and (pointer:coarse))
        LANDSCAPE  @media (max-height:500px) and (pointer:coarse)      (compaction only)
   • terminal.html's own <style> blocks and the runtime-injected FLOWFIELD #ff-css sheet
     load AFTER this file, so every selector is prefixed with `html body` (or a longer
     chain) to win on specificity, and `!important` is used only where the original is
     an inline style (planner/risk account row, manual positions, consistency rule,
     settings-panel range inputs) or itself `!important`.
   • House style: gold-on-black HUD, vars --gold / --border / --muted. No new tokens.
   • This sheet is also loaded inside the 2D/3D cell iframes (same terminal.html), which
     is where the HEATMAP CELL section applies (html.cell-iframe-3d).
   ═══════════════════════════════════════════════════════════════════════════════════════════ */


/* ───────────────────────────────────────────────────────────────────────────────────────────
   0. SHARED CELL CHROME  (.anal-cell-head — every mode cell)
   36px tap targets on the type/sym/tf selects + ⤢ expand; the head row scrolls sideways
   instead of squeezing when it overflows.
   ─────────────────────────────────────────────────────────────────────────────────────────── */
@media (max-width:820px), ((max-height:500px) and (pointer:coarse)){
  html body .anal-cell-head{
    overflow-x:auto; overflow-y:hidden; flex-wrap:nowrap;
    -webkit-overflow-scrolling:touch; scrollbar-width:none;
  }
  html body .anal-cell-head::-webkit-scrollbar{ display:none; }
  html body .anal-cell-head > *{ flex-shrink:0; }
  html body .anal-cell-head select.anal-cell-sym{ flex:1 1 auto; }
  html body .anal-cell-head select.anal-cell-type,
  html body .anal-cell-head select.anal-cell-sym,
  html body .anal-cell-head select.anal-cell-tf,
  html body .anal-cell-head .anal-cell-expand,
  html body .anal-cell-head .anal-cell-editmode{
    min-height:36px; font-size:12px;
  }
  html body .anal-cell-head .anal-cell-expand,
  html body .anal-cell-head .anal-cell-editmode{ min-width:36px; height:auto; width:auto; }
}


/* ───────────────────────────────────────────────────────────────────────────────────────────
   1. ARIES CELL  (.av2-root — World Monitor panel over the WebGL sphere)
   AR-1 stack grid, AR-2 tap targets, AR-3 type ≥10px, AR-4 full-width control row,
   AR-5/AR-7 one scroller fills the cell.
   ─────────────────────────────────────────────────────────────────────────────────────────── */
@media (max-width:820px), ((max-height:500px) and (pointer:coarse)){
  /* AR-1 — vertical stack: full-width panel, the empty sphere column goes (sphere is
     position:absolute;inset:0 on .av2-sphere so it still fills the background) */
  html body .av2-grid{ padding:0 10px 10px; }
  html body .av2-grid.av2-grid-wm{ flex-direction:column; gap:0; }
  html body .av2-grid-wm .av2-col-c{ display:none; }
  html body .av2-root .av2-grid-wm .av2-col-r,
  html body .av2-root.av2-pairmode .av2-grid-wm .av2-col-r{
    flex:1 1 auto; width:100%; min-height:0; order:0 !important;
    display:flex; flex-direction:column; overflow:hidden;
  }
  /* AR-5 / AR-7 — drop the desktop max-height cap; the panel is the ONE scroller */
  html body .av2-col-r .av2-panel.av2-wm,
  html body .av2-wm{ max-height:none; flex:1 1 auto; min-height:0; overflow-y:auto; }

  /* AR-4 — brand on its own line, the two selects share a full-width row beneath */
  html body .av2-top{ flex-wrap:wrap; padding:10px 12px; gap:8px; }
  html body .av2-controls{ flex:1 0 100%; flex-wrap:nowrap; gap:8px; }
  html body .av2-controls .av2-sel{ flex:1 1 0; min-width:0; }

  /* AR-2 — tap targets */
  html body .av2-sel{ padding:10px 12px; font-size:12px; min-height:40px; }
  html body .av2-wmp-back{ padding:10px 12px; font-size:10px; min-height:36px; }

  /* AR-3 — lift 8/9px type to ≥10px; hide the brand subtitle (it wrapped to 2×9px lines) */
  html body .av2-lbl, html body .av2-wm-badge, html body .av2-wm-pulls, html body .av2-wm-cnt,
  html body .av2-wmp-rgn, html body .av2-wmp-ra, html body .av2-wmp-lh span{ font-size:10.5px; }
  html body .av2-wmp-lh em{ font-size:10px; }
  html body .av2-brand span{ display:none; }
}
@media (max-height:500px) and (pointer:coarse){
  /* AR-7 — landscape compaction */
  html body .av2-top{ padding:6px 12px; gap:6px; }
  html body .av2-grid{ padding:0 8px 8px; }
}


/* ───────────────────────────────────────────────────────────────────────────────────────────
   2. PASS PLANNER (calc) + RISK MANAGER (risk)  — shared .moni-root / .calc-* shell
   PR-1 single scroller, PR-2 card grid, PR-3 tap targets, PR-4 16px inputs,
   PR-5 label alignment, PR-6 compact head (see §4 MO-1), PR-7 type, PR-8 landscape.
   ─────────────────────────────────────────────────────────────────────────────────────────── */
@media (max-width:820px), ((max-height:500px) and (pointer:coarse)){
  /* PR-1 — .moni-body becomes the only scroller so #rm-consist (CONSISTENCY / PAYOUT /
     ACCOUNT PROGRESS) is reachable without scrolling through every signal card */
  html body .moni-body .calc-wrap{ height:auto; overflow:visible; }
  /* PR-8 — stacking also in landscape (the 820 rule alone misses 844x390) */
  html body .moni-body .calc-wrap{ flex-direction:column; }
  html body .moni-body .calc-col-in{ width:100%; }

  /* PR-2 — 2 columns of cards on a 375px phone (2×140+9 = 289 fits a 311px column) */
  html body .rm-cards{ grid-template-columns:repeat(auto-fill, minmax(140px, 1fr)); }

  /* PR-3 — tap targets (inline-styled controls need !important) */
  html body .calc-sbtn, html body .rm-chip, html body .calc-btn,
  html body #rm-fetch, html body #calc-adv-btn, html body #calc-copy,
  html body #rm-acct-new, html body #rm-acct-ren, html body #rm-acct-del,
  html body #calc-acct-new, html body #calc-acct-ren, html body #calc-acct-del,
  html body #rm-mpos-add, html body #rmc-reset{
    min-height:40px !important;
  }
  html body #rm-acct-new, html body #rm-acct-ren, html body #rm-acct-del,
  html body #calc-acct-new, html body #calc-acct-ren, html body #calc-acct-del{ min-width:40px !important; }
  html body .rm-card .rc-ck{ width:22px; height:22px; top:8px; right:8px; }
  html body .rm-mpos-del{ min-width:36px !important; min-height:36px !important; }
  html body #rm-mpos-pair, html body #rm-mpos-risk, html body #rmc-mode, html body #rmc-limit{ min-height:40px !important; }
  html body #rmc-limit{ width:72px !important; }
  html body #rmc-reset{ font-size:10px !important; }

  /* PR-4 — 16px inputs/selects: stops iOS Safari focus-zoom */
  html body .calc-in, html body .calc-sel,
  html body #rm-mpos-pair, html body #rm-mpos-risk, html body #rmc-mode, html body #rmc-limit{
    font-size:16px !important;
  }

  /* PR-5 — two-column rows: inputs share one baseline even when one label wraps */
  html body .calc-row .calc-field{ display:flex; flex-direction:column; }
  html body .calc-row .calc-field .calc-lbl{ flex:1 0 auto; }

  /* PR-7 — sub-10px tokens → 10–11px */
  html body .calc-lbl, html body .calc-lbl .calc-tip, html body .rm-chip,
  html body .rc-dir, html body .rm-card .rc-dir{ font-size:11px; }
  html body .calc-kpi .kk{ font-size:10.5px; }
  html body .rc-when, html body .rm-card .rc-when{ font-size:10px; }
}


/* ───────────────────────────────────────────────────────────────────────────────────────────
   3. OMNI CELL  (📡 .omni-* panes)
   OM-2 chart pane stack, OM-3 feed stack, OM-4 live-TV stack + channel rail,
   OM-8 tap targets, OM-10 calendar / markets / COT.
   ─────────────────────────────────────────────────────────────────────────────────────────── */
@media (max-width:820px), ((max-height:500px) and (pointer:coarse)){
  /* OM-2 — CHART tab: chart full width, side panel below */
  html body .omni-chart-pane{ flex-direction:column; overflow-y:auto; -webkit-overflow-scrolling:touch; }
  html body .omni-chart-main{ border-right:none; flex:none; overflow-y:visible; }
  html body .omni-chart-side{
    min-width:0; max-width:none; flex:none; max-height:45vh;
    border-top:1px solid var(--border);
  }
  html body .omni-chart-host{ height:min(440px, 55vh); min-height:220px; }

  /* OM-3 — NEWS FEED tab: list over detail */
  html body .omni-feed-pane{ flex-direction:column; }
  html body .omni-feed-col{ border-right:none; flex:1 1 55%; min-height:0; }
  html body .omni-detail-col{ flex:1 1 45%; min-height:0; border-top:1px solid var(--border); }

  /* OM-4 — LIVE TV tab: player over a horizontal channel rail */
  html body .omni-tv-pane{ flex-direction:column; }
  html body .omni-tv-player{ min-height:56vw; flex:1 1 auto; }
  html body .omni-tv-rail{
    width:auto; flex:none; border-left:none; border-top:1px solid var(--border);
    display:flex; align-items:flex-start; gap:7px; overflow-x:auto; overflow-y:hidden;
    -webkit-overflow-scrolling:touch; padding:8px 10px;
  }
  html body .omni-tv-ch{ flex:none; min-width:150px; max-width:220px; height:auto; margin:0; }

  /* OM-8 — tap targets in the relocated OMNI header + chart controls */
  html body .omni-imp, html body .omni-pair, html body .omni-tog, html body .omni-ptab,
  html body .omni-ctf, html body .omni-sw, html body .omni-tab{ min-height:36px; }
  html body .omni-tog{ font-size:11px; }
  html body .omni-imp, html body .omni-tog, html body .omni-ctf{ display:inline-flex; align-items:center; }
  html body .omni-ptab{ align-items:center; }

  /* OM-10 — CALENDAR: wide table scrolls sideways instead of crushing to 10px */
  html body .omni-cal-pane{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
  html body .omni-cal{ min-width:640px; }
  /* OM-10 — MARKETS: one card per row; COT head wraps; selects/chips readable + tappable */
  html body .omni-card-grid{ grid-template-columns:1fr; }
  html body .omni-cot-head{ flex-wrap:wrap; gap:6px; }
  html body .omni-cot-views{ margin-left:0; margin-right:0; flex-wrap:wrap; }
  html body .omni-ct-dates{ display:flex; flex-wrap:wrap; width:100%; margin-left:0; }
  html body .omni-cot-csel, html body .omni-cot-view{ font-size:11px; min-height:32px; }
}


/* ───────────────────────────────────────────────────────────────────────────────────────────
   4. OMNI SIGNALS CELL  (🎯 .moni-* — head shared with PASS PLANNER / RISK MANAGER → PR-6)
   MO-1 wrapping head, MO-2 scoreboard wrap + weeks table scroll, MO-5/MO-6 close glyphs.
   ─────────────────────────────────────────────────────────────────────────────────────────── */
@media (max-width:820px), ((max-height:500px) and (pointer:coarse)){
  /* MO-1 / PR-6 — head wraps; subtitle hidden; filters take a full row and wrap */
  html body .moni-head{ flex-wrap:wrap; row-gap:8px; gap:8px; padding:8px 10px; }
  html body .moni-head .moni-sub{ display:none; }
  html body .moni-head .moni-filters{ margin-left:0; flex:1 1 100%; flex-wrap:wrap; row-gap:6px; }
  html body .moni-head .moni-fsep{ display:none; }
  html body .moni-head .moni-chip, html body .moni-head .moni-psel, html body .moni-head .moni-refresh,
  html body .moni-head .moni-ps, html body .moni-head select, html body .moni-head button{ min-height:36px; }
  html body .moni-head .moni-chip{ white-space:nowrap; }

  /* MO-2 — scoreboard cells wrap; weekly table scrolls sideways inside its box */
  html body .moni-score .ms-cell{ white-space:normal; }
  html body .moni-score.ms-reality .ms-cell:last-child{ flex-basis:100%; }
  html body .moni-weeks{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
  html body .moni-weeks table{ min-width:516px; }

  /* MO-5 / MO-6 — 40px close glyphs; 18px checkboxes; 34px buttons in the alert modal */
  html body .moni-alert-x{ padding:8px 10px; min-width:40px; min-height:40px; }
  html body .moni-mclose{ padding:8px 10px; min-width:40px; min-height:40px; top:2px; right:2px; }
  html body .moni-alert-body button{ min-height:34px; font-size:11px; }
  html body .moni-alert-body input[type=checkbox]{ width:18px; height:18px; }
}


/* ───────────────────────────────────────────────────────────────────────────────────────────
   5. NEO CELL  (.mx-root — FORMULA / MATRIX / DETAILS views)
   N7 toolbar wrap, N8 tap targets, N10 row-detail stacked, N11 formula table as cards.
   ─────────────────────────────────────────────────────────────────────────────────────────── */
@media (max-width:820px), ((max-height:500px) and (pointer:coarse)){
  /* N7 — toolbar wraps so ⚡ MOVERS / ⟳ SCAN stay reachable */
  html body .mx-root .mx-tools{ flex-wrap:wrap; row-gap:6px; }
  html body .mx-root .mx-head{ overflow:visible; }

  /* N8 — tap targets (chips were 19–21px) */
  html body .mx-root button, html body .mx-root select, html body .mx-root summary,
  html body .mx-root .mx-chip, html body .mx-root .mx-tfchip, html body .mx-root .nf-expand{
    min-height:36px;
  }
  html body .mx-root .mx-chip, html body .mx-root .mx-tfchip{ display:inline-flex; align-items:center; }
  html body .mx-root summary{ display:flex; align-items:center; }
  html body .mx-root .mx-grip, html body .mx-root .mx-eye{ padding:8px 4px; }

  /* N10 — row detail sections stack and pin to the visible left edge of the wide table */
  html body .mx-detailrow .mx-detail{
    position:sticky; left:0; width:calc(100vw - 16px); max-width:calc(100vw - 16px);
    flex-direction:column; flex-wrap:nowrap; box-sizing:border-box;
  }
  html body .mx-detailrow .mx-dsec{ min-width:0; flex:none; width:100%; }

  /* N11 — FORMULA table: the 810px market table becomes stacked cards (readable, no
     sideways scroll). Overrides ade-neo-formula.css (.nf-table{min-width:810px;table-layout:fixed}). */
  html body .nf .nf-scroll{ overflow-x:hidden; }
  html body .nf .nf-table{ min-width:0; table-layout:auto; display:block; }
  html body .nf .nf-table thead{ display:none; }
  html body .nf .nf-table tbody{ display:block; }
  html body .nf .nf-table tr.nf-market{
    display:grid; grid-template-columns:1fr 1fr; gap:8px 12px; padding:12px 12px;
    border-top:1px solid #212730;
  }
  html body .nf .nf-table tr.nf-market td{ display:block; padding:0; border-top:0; min-width:0; }
  html body .nf .nf-table tr.nf-market td:first-child{ grid-column:1 / -1; }
  html body .nf .nf-table tr.nf-market td:nth-child(n+2)::before{
    display:block; font-size:9.5px; letter-spacing:1.1px; color:#8996a6; font-weight:600; margin-bottom:4px;
  }
  html body .nf .nf-table tr.nf-market td:nth-child(2)::before{ content:'BASE FORMULA'; }
  html body .nf .nf-table tr.nf-market td:nth-child(3)::before{ content:'DXY EXPECTS'; }
  html body .nf .nf-table tr.nf-market td:nth-child(4)::before{ content:'LEVELS TAKEN'; }
  html body .nf .nf-table tr.nf-market td:nth-child(5)::before{ content:'= RESULT'; }
  html body .nf .nf-table tr.nf-market td:nth-child(5){ grid-column:1 / -1; }
  html body .nf .nf-table .nf-level{ white-space:normal; }
  html body .nf .nf-table .nf-ingredients{ flex-wrap:wrap; }
  html body .nf .nf-table tr:has(> td.nf-detail){ display:block; }
  html body .nf .nf-table td.nf-detail{ display:block; width:auto; max-width:100%; padding:12px; }
  html body .nf .nf-table td.nf-empty{ display:block; }
  html body .nf .nf-detailgrid{ grid-template-columns:1fr; width:auto; }
}


/* ───────────────────────────────────────────────────────────────────────────────────────────
   6. HEATMAP CELL  (2D / 3D — applies INSIDE html.cell-iframe-3d and the classic shell)
   H4 chip bar, H6 drawing rail, H7 settings panel, H8 heatmap popover, H13 hidden-flow badge.
   ─────────────────────────────────────────────────────────────────────────────────────────── */
@media (max-width:820px), ((max-height:500px) and (pointer:coarse)){
  /* H4 — #of-toggles: left-anchored, scrolls sideways, no centring transform */
  html body #of-toggles{
    left:0; right:0; transform:none; max-width:100%; width:auto;
    overflow-x:auto; overflow-y:hidden; -webkit-overflow-scrolling:touch;
    flex-wrap:nowrap; justify-content:flex-start; scrollbar-width:none; border-radius:0;
  }
  html body #of-toggles::-webkit-scrollbar{ display:none; }
  html body #of-toggles .of-tog{
    min-height:36px; padding:9px 10px; flex:0 0 auto; display:inline-flex; align-items:center; white-space:nowrap;
  }

  /* H6 — #draw-toolbar: wrapping horizontal row along the bottom, 36px tools */
  html body #draw-toolbar{
    flex-direction:row; flex-wrap:wrap; gap:4px;
    top:auto; bottom:8px; left:8px; right:8px; max-height:84px; overflow:auto;
    -webkit-overflow-scrolling:touch;
  }
  html body #draw-toolbar .dtool{ width:36px; height:36px; }
  html body #draw-toolbar .dt-sep{ display:none; }

  /* H7 — #settings-panel: full width, rows wrap, range inputs full width, 40px ✕, 44×24 toggle */
  html body #settings-panel{ width:100vw; max-width:100vw; left:0; right:0; }
  html body #settings-panel .sp-row{ flex-wrap:wrap; gap:4px; }
  html body #settings-panel .sp-row input[type=range]{ width:100% !important; flex:1 1 100%; min-height:28px; }
  html body #settings-panel .sp-row select, html body #settings-panel .sp-row button{ min-height:36px; }
  html body #settings-panel .sp-close{ width:40px; height:40px; min-width:40px; min-height:40px; font-size:20px; line-height:1; }
  html body #settings-panel .sp-toggle{ width:44px; height:24px; }
  html body #settings-panel .sp-toggle .sp-slider:before{ width:20px; height:20px; }
  html body #settings-panel .sp-toggle input:checked+.sp-slider:before{ transform:translateX(20px); }

  /* H8 — #hmset heatmap popover: full width under the bar, readable rows, 36px selects */
  html body #hmset{ left:4px; right:4px; width:auto; top:44px; max-height:70vh; }
  html body #hmset .row{ font-size:12px; }
  html body #hmset select{ font-size:13px; min-height:36px; }
  html body #hmset .seg b{ padding:9px 12px; font-size:11px; }

  /* H13 — hidden-flow badge: bottom-left, never over the chip bar / 3D pills */
  html body #hidden-flow-badge, html body #hf-badge{
    top:auto; right:auto; bottom:8px; left:8px; max-width:calc(100% - 16px); box-sizing:border-box;
  }
}

/* LEFT DRAWING RAIL on phones (2026-11-09, owner: hard to open with a finger) — bigger targets, no iOS long-press callout /
   text selection, no double-tap zoom delay. A tap now opens each tool's menu (terminal.html lwBuildToolbar). */
@media (max-width:820px), ((max-height:500px) and (pointer:coarse)){
  html body .lw-toolbar{ width:42px; flex:0 0 42px; gap:3px; }
  html body .lw-tbtn{ width:38px; height:38px; touch-action:manipulation; -webkit-touch-callout:none; -webkit-user-select:none; user-select:none; }
  html body .lw-tbtn svg{ width:20px; height:20px; }
  html body .lw-tbtn .lw-caret{ border-left-width:8px; border-bottom-width:8px; }
  html body .lw-toolbar .lw-sep{ width:26px; }
  html body .lw-fitem{ min-height:44px; }
}
