/* STOCK FOXES phone layer (B14). Loaded after shell.css. Phone = read-only: Home, Alerts, Den read-back, Reports,
   Research. Layout only - no behaviour lives here. Per-page <style> blocks sit later in the document, so overrides of
   them carry one extra class / id of specificity. Never fix overflow with overflow-x: hidden on html / body (slate 57:
   the phone shell's html / body overflow: hidden below is the one-inner-scroller rule, not an overflow fix).
   slate 56: no :hover rule lives here; -webkit-overflow-scrolling is gone (a no-op since iOS 13). */

/* Horizontal scroll wrapper for tables (any width). */
.scroll { max-width: 100%; overflow-x: auto; }

/* The desktop-only note exists on the trading pages but shows only on a phone. */
.sf-desk-only[hidden] { display: none; }

@media (max-width: 900px) {
  /* ---- slate 29 S2 on a phone: every .ctl is a 44 px target (an override of the S1 token, not a second token);
     a .page-head wraps with its actions on their own row under the title; a .chips-cap row shows two rows of chips
     and its "+N" chip (a <label> for the row's checkbox) expands it - CSS only ---- */
  :root { --sf-control-h: 44px; }
  /* slate 56 T4: 44 px table rows + the 44 px tap token; the phone type scale (meta / labels 11-12 px weight 500 -
     light-on-dark reads thinner -, cells 13, headline 15, title 17 semibold, big numbers 22-28 mono; nothing under 11) */
  :root { --sf-row-h: 44px; --sf-tap: 44px; --sf-fs-meta: 11px; --sf-fs-label: 12px; --sf-fs-cell: 13px; --sf-fs-head: 15px;
    --sf-fs-title: 17px; --sf-fs-big: 22px; --sf-fs-big-2: 28px; --sf-fw-label: 500; --sf-fw-title: 600; }
  html[data-density="comfortable"] { --sf-row-h: 48px; }
  .page-head .title { font-size: var(--sf-fs-title); font-weight: var(--sf-fw-title); }
  .page-head .sub, .pane-head, .tile h3 { font-weight: var(--sf-fw-label); }
  .tile .big { font-size: var(--sf-fs-big); }
  /* slate 56 T4: no iOS zoom on ANY field - every input / select / textarea at 16 px or more (!important: a page's
     later <style> must not take a field back under 16 px) */
  input, select, textarea { font-size: max(16px, 1em) !important; }
  .page-head .actions { flex-basis: 100%; margin-left: 0; }
  .chips-cap .chips-cap-row { max-height: calc(2 * 18px + var(--sf-sp-1)); overflow: hidden; }
  .chips-cap .chips-cap-more { display: inline-block; margin-top: var(--sf-sp-1); }
  .chips-cap .chips-cap-x:checked ~ .chips-cap-row { max-height: none; }
  .chips-cap .chips-cap-x:checked ~ .chips-cap-more { display: none; }
  /* slate 32: a "+N" the page hides (hidden attribute, nothing beyond row two) or a row with no chips: no label */
  .chips-cap .chips-cap-more[hidden], .chips-cap .chips-cap-row:empty ~ .chips-cap-more { display: none; }

  /* ---- slate 31 (B69): Watch / Alerts / Account. Page heads wrap (above), every .ctl is 44 px (the token), a .ctl-sm
     row action is 36 px; the Alerts rule editor's WHAT / WHEN rows stack with their label above the controls ---- */
  .ctl.ctl-sm { height: 36px; padding: 0 var(--sf-sp-3); }
  .rule-form .rule-row { grid-template-columns: minmax(0, 1fr); gap: var(--sf-sp-1); }
  .rule-form .rule-lab { height: auto; }
  .alerts-page > .page-head .alert-filters label, .rule-form label { min-height: 44px; }
  .alerts-page .rule-tpls { gap: var(--sf-sp-2); }
  /* watch.html / account.html carry their own <style> after this file: these overrides carry the page id */
  #wl .wl-grid > .tile { padding: var(--sf-sp-2); }
  #wl #wl-new input[name=lname] { flex: 1 1 100%; }
  #wl #wl-new label { min-height: 44px; }
  #sf-account label.chk { min-height: 44px; }
  #sf-account #sf-push-devices button { height: 36px; padding: 0 var(--sf-sp-3); }
  #sf-alerts .alert-table .chip { white-space: nowrap; }

  /* ---- slate 32 (B70): Reports / Fox Wire / Studies. The recap tiles' "open" links (.ctl-sm look by CSS in
     reports.html) are 36 px like every .ctl-sm; page heads wrap and .ctl controls are 44 px (above) ---- */
  #rc .rc-card h3 a { height: 36px; padding: 0 var(--sf-sp-3); }
}

@media (max-width: 700px) {
  .bell-all, .alert-read { min-height: 36px; padding: 0 var(--sf-sp-3); }
  .bell-row { padding: var(--sf-sp-2) var(--sf-sp-3); }

  /* ---- tiles + sections: one column, nothing wider than the screen ---- */
  .grid { grid-template-columns: minmax(0, 1fr); }
  .tile { min-width: 0; }
  .tile .kv dd { min-width: 0; overflow-wrap: anywhere; }
  .muted, .tile .body { overflow-wrap: anywhere; }

  /* ---- desktop-only note (big / foxtrot; /little is a phone-friendly read-back since B23) ---- */
  .sf-desk-only[hidden] { display: block; margin: var(--sf-sp-2); padding: var(--sf-sp-3); background: color-mix(in srgb, var(--sf-warn) 12%, transparent); color: var(--sf-warn);
    border: 1px solid var(--sf-warn); border-radius: var(--sf-r); font-size: var(--sf-fs-2); }

  /* ---- forms: login / forgot / reset / offline fit 375 px; 16 px inputs (no iOS zoom). Slate 33: the card is full
     width with 16 px gutters; its .ctl fields + button are 44 px (the phone token); the text links 36 px tall ---- */
  .login { max-width: none; margin: 6vh var(--sf-sp-4); width: auto; }
  .login input { font-size: 16px; min-height: var(--sf-control-h); }
  .login input[type=checkbox] { min-height: 0; width: 20px; height: 20px; vertical-align: middle; }
  .login button { min-height: var(--sf-control-h); }
  .login a:not(.ctl) { display: inline-block; min-height: 36px; line-height: 36px; }

  /* ---- alerts ---- */
  .alerts-page { padding: var(--sf-sp-2); }
  .alert-filters select, .alert-filters button, .alert-filters label { min-height: 36px; }
  .alert-filters label { display: inline-flex; align-items: center; gap: var(--sf-sp-1); }
  .alert-table td { overflow-wrap: anywhere; }
  /* slate 34 (B72): the alerts table (not the rules table) at 375: each row a small grid - time | level | fox | read on
     line one (time + fox nowrap, the level chip as it is), the message on its own full-width line under them (wraps
     at word gaps, breaks a long word only when it must); the column heads hide (the row reads without them) */
  #sf-alerts .alert-table:not(.rule-table) thead { display: none; }
  #sf-alerts .alert-table:not(.rule-table), #sf-alerts .alert-table:not(.rule-table) > tbody { display: block; }
  #sf-alerts .alert-table:not(.rule-table) tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; align-items: center;
    column-gap: var(--sf-sp-2); padding: var(--sf-sp-1) 6px; border-bottom: 1px solid var(--sf-line); }
  #sf-alerts .alert-table:not(.rule-table) td { border-bottom: 0; padding: 2px 0; min-width: 0; }
  #sf-alerts .alert-table:not(.rule-table) td:is(:nth-child(1), :nth-child(3)) { white-space: nowrap; overflow-wrap: normal; overflow: hidden; text-overflow: ellipsis; }
  #sf-alerts .alert-table:not(.rule-table) td:nth-child(1) { font-size: var(--sf-fs-0); }
  #sf-alerts .alert-table:not(.rule-table) td:nth-child(4) { grid-column: 1 / -1; grid-row: 2; overflow-wrap: anywhere; word-break: normal; }
  #sf-alerts .alert-table:not(.rule-table) td:nth-child(5) { grid-column: 4; grid-row: 1; justify-self: end; }
  #sf-alerts .alert-table:not(.rule-table) tr.unread { background: var(--sf-pane); box-shadow: inset 2px 0 0 var(--sf-text-2); }
  #sf-alerts .alert-table:not(.rule-table) tr.unread td:first-child { box-shadow: none; }
  /* slate 35 (B73): the rules table at 375 the same way - one line per rule of its short cells (user | channels |
     quiet | on | edit + delete; never broken mid-word, a too-long line wraps between cells), the rule text (kind, fox,
     params) full-width under them; only its params line may break a long token. Cells are counted from the end: the
     owner's rows lead with a user cell, the crew's do not; the column heads hide (the row reads without them) */
  #sf-alerts .rule-table thead { display: none; }
  #sf-alerts .rule-table, #sf-alerts .rule-table > tbody { display: block; }
  #sf-alerts .rule-table tr { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--sf-sp-3); row-gap: 2px;
    padding: var(--sf-sp-1) 6px; border-bottom: 1px solid var(--sf-line); }
  #sf-alerts .rule-table td { border-bottom: 0; padding: 2px 0; white-space: nowrap; overflow-wrap: normal; }
  #sf-alerts .rule-table td:nth-last-child(5) { order: 1; flex: 1 1 100%; min-width: 0; white-space: normal; }
  #sf-alerts .rule-table td:nth-last-child(5) > :not(div) { overflow-wrap: normal; }
  #sf-alerts .rule-table td:nth-last-child(5) > div { overflow-wrap: anywhere; }
  #sf-alerts .rule-table td:last-child { margin-left: auto; }
  #sf-alerts .rule-table td:nth-last-child(3)::before { content: "quiet "; color: var(--sf-text-3); }   /* slate 36 (B74): the quiet cell labels itself (no heads) */
  .rule-form { flex-direction: column; align-items: stretch; }
  .rule-form .rule-ctls, .rule-form .rule-grp { flex-direction: column; align-items: stretch; }   /* slate 31: one control per line */
  .rule-form label > .ctl { flex: 1 1 auto; min-width: 0; }
  .rule-form label, .rule-form button, .rule-form input, .rule-form select { min-height: 36px; }
  .rule-acts button { margin: 2px 0; }
  /* B39 scanner_row: bounds rows wrap, panel picks stack, the Desk strip's last-scanner-alert chip never widens the page */
  .scan-bounds, .scan-panels { display: flex; }
  .scan-bounds:empty, .scan-panels:empty { display: none; }
  .scan-bound { flex-wrap: wrap; white-space: normal; }
  .scan-bound input { min-width: 0; flex: 1 1 5em; }
  .scan-panels label { min-height: 36px; }
  .desk-strip #desk-scanalert { max-width: 100%; min-width: 0; flex: 0 1 auto; }
  /* B40: template buttons + the Desk quick-rule controls stay tappable and never widen the page */
  .rule-tpls .rule-tpl { min-height: 36px; white-space: normal; text-align: left; }
  .scan-d-alert, .watch-alerts { min-height: 32px; max-width: 100%; }
  .scan-d-qmsg { flex: 1 1 100%; min-width: 0; overflow-wrap: anywhere; }

  /* ---- reports: list + viewer stack (reports.html); bigger targets ---- */
  .rp .rp-row { padding: var(--sf-sp-2); }
  .rp .rp-row .m { flex-wrap: wrap; overflow-wrap: anywhere; }
  .rp .rp-chips button { min-height: 32px; padding: 0 var(--sf-sp-2); }
  /* slate 32: the chip cap at 32 px chips - two rows + the "+N" label (reports.html fills N) */
  .rp .chips-cap .chips-cap-row { max-height: calc(2 * 32px + var(--sf-sp-1)); }
  .rp .chips-cap .chips-cap-more { line-height: 32px; padding: 0 var(--sf-sp-2); }
  .rp .rp-back { display: inline-flex; align-items: center; min-height: 36px; }
  .rp .rp-head { overflow-wrap: anywhere; }

  /* ---- playbook: section nav = one horizontal chip row that scrolls ---- */
  .pb > .pb-nav { flex-wrap: nowrap; overflow-x: auto; gap: var(--sf-sp-1);
    padding: var(--sf-sp-2); scrollbar-width: thin; }
  .pb > .pb-nav button { flex: none; width: auto; white-space: nowrap; min-height: 36px; padding: 0 var(--sf-sp-3);
    border: 1px solid var(--sf-line); border-radius: 18px; background: var(--sf-pane-2); }
  .pb > .pb-nav button.on { background: var(--sf-fox-dim); border-color: var(--sf-fox-dim); color: var(--sf-fox-2); box-shadow: none; font-weight: 600; }   /* slate 33: active = fox-dim */
  .pb .pb-main { padding: var(--sf-sp-2); }
  .pb .md table { display: block; max-width: 100%; overflow-x: auto; }
  .pb .btn, .pb .chips button { min-height: 36px; }
  #pb input[type=search], #pb input[type=text], #pb select, #pb textarea { font-size: 16px; min-height: 36px; max-width: 100%; }
  #pb .grow { min-width: 0; flex-basis: 100%; }

  /* ---- research: ticker box full width, sections stack, brief panel full width ---- */
  :where(input, select, textarea).ctl { font-size: 16px; }   /* slate 29: no iOS zoom on any .ctl field */
  form#rs-form { padding: var(--sf-sp-2); }
  #rs-form #rs-t { width: 100%; flex: 1 1 100%; }
  #rs-form .actions button.ctl { flex: 1 1 0; }
  .rs-title { overflow-wrap: anywhere; }
  #rs-grid .tile.wide, section#brief.tile { grid-column: 1 / -1; }
  section#brief .sfb-card { max-width: none; }
  section#brief .sfb-btn { min-height: 36px; }
  section#brief .sfb-open { min-height: 32px; }

  /* ---- den read-back (B18): journal table scrolls sideways, filters stack, day-log groups stack ---- */
  #den.den { padding: var(--sf-sp-2); }
  #den #dn-table-wrap { overflow-x: auto; max-width: 100%; }
  /* slate 85 P9: the filter in two rows - a two-by-two grid (since | until, symbol | filter) with "clear" as a text link
     beside the button; each label's word above its field; every field 16 px text (no zoom on focus) and 44 px tall */
  #den .dn-filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end;
    gap: var(--sf-sp-2); }
  #den .dn-filters label { display: flex; flex-direction: column; align-items: stretch; gap: 2px; min-width: 0; text-align: left; }
  #den .dn-filters label:nth-of-type(2) { grid-column: 2 / -1; }
  #den .dn-filters input, #den .dn-filters button, #den select { font-size: 16px; min-height: 36px; }
  #den .dn-filters input, #den .dn-filters button { min-height: 44px; }
  #den .dn-filters input { width: 100%; min-width: 0; }
  #den .dn-filters #dn-clear { background: none; border: 0; padding: 0 var(--sf-sp-1); color: var(--sf-text-2);
    text-decoration: underline; }
  #den .dn-open { margin-left: 0; min-height: 36px; }
  #den .dn-low, #den .dn-groups { grid-template-columns: minmax(0, 1fr); }
  #den .dn-pager button { min-height: 36px; }
  /* B51 Reviews / Debrief tabs: tabs share the row, cards stack, the report's tables / pre scroll inside their card,
     the date input is 16 px (no iOS zoom) */
  #den .dn-tabs .dn-tab { flex: 1 1 0; min-height: 36px; font-size: 16px; padding: 4px 6px; }
  /* slate 33: the segmented control spans the row; the controls inside the section heads are 36 px */
  #den .dn-tabs { display: flex; }
  #den h2 .ctl { height: 36px; }
  #den .dn-r-top { grid-template-columns: minmax(0, 1fr); }
  #den #dn-report table, #den #dn-report pre { display: block; max-width: 100%; overflow-x: auto; }
  #den #dn-d-day { font-size: 16px; min-height: 36px; }
  /* B51 MY DAY strip on the Desk: wraps onto more lines, never widens the page; the links stay tappable */
  #myday.myday { flex-wrap: wrap; }
  #myday .myday-line { flex: 1 1 100%; min-width: 0; }
  #myday .myday-links { margin-left: 0; }
  #myday .myday-links a { display: inline-flex; align-items: center; min-height: 32px; }

  /* ---- Fox Wire tab (B41): rows stack, filters wrap, 36 px targets, 16 px inputs, long titles / urls wrap ---- */
  #fw.fw { padding: var(--sf-sp-2); }
  #fw .btn { min-height: 36px; min-width: 36px; }
  #fw .bar input[type=text], #fw .bar input[type=number] { font-size: 16px; min-height: 36px; }
  #fw .bar .q { flex-basis: 100%; }
  #fw .bar .tk, #fw .bar .ms { flex: 1 1 5em; width: auto; }
  #fw .bar label { min-height: 36px; }
  /* slate 32: category / trend chips 32 px; the category row capped at two rows + the fixed "more" label */
  #fw .btn.pill { min-height: 32px; }
  #fw .chips-cap .chips-cap-row { max-height: calc(2 * 32px + var(--sf-sp-1)); }
  #fw .chips-cap .chips-cap-x:checked ~ .chips-cap-row { max-height: none; }   /* the #fw cap above must not beat the expand */
  #fw .chips-cap .chips-cap-more { line-height: 32px; padding: 0 var(--sf-sp-2); }
  #fw .meta { row-gap: 2px; }
  #fw .tks a { display: inline-flex; align-items: center; min-height: 36px; }
  #fw .ttl, #fw .tz, #fw ul.bd li { overflow-wrap: anywhere; min-width: 0; }
  #fw .tz { min-height: 24px; }
  /* ---- Fox Wire settings pane (B44, owner + SF_FOXWIRE_CONFIG=1): rows stack, 36 px targets, 16 px inputs ---- */
  #fw section.cfg { padding: var(--sf-sp-2); }
  #fw .cfg-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  #fw .cfg-acts { flex-direction: column; align-items: stretch; }
  #fw .cfg-v input { font-size: 16px; min-height: 36px; }
  #fw .cfg-chip button { min-width: 36px; min-height: 36px; }
  #fw .cfg-a .btn, #fw .cfg-acts .btn, #fw .cfg-top .btn, #fw .cfg-open { min-height: 36px; }
  /* ---- Fox Wire Shadow tab (B54, owner): the two mover tables stack, 44 px rows to tap, the SVGs shrink ---- */
  #fw section.shp { padding: var(--sf-sp-2); }
  #fw .sh-grid { grid-template-columns: minmax(0, 1fr); gap: var(--sf-sp-2); }
  #fw .sh-tbl tr.sh-row td { height: 44px; }
  #fw .sh-tbl col.c-sc { width: 5.6em; }
  #fw .sh-svg { max-width: 100%; }
  #fw .sh-open { min-height: 36px; }
}

/* ==== slate 56 (B94) T4, the phone's CSS-only rules (ruled 14:0x; docs/design/phone-2026-11-03.md section 3). Still no
   markup / JS / route. The phone query = the <= 900 px blocks; these come last so they out-rank the earlier phone
   rules and, with one more id / class, the pages' own later <style> blocks. ==== */
@media (max-width: 900px) {
  /* one-line chip / tab rows: the Desk's scanner panel tabs, watch-list tabs and chart chips, the Fox Wire class
     pills and day tabs, the Den tabs scroll sideways (snap, no scrollbar, a right-edge fade) instead of wrapping */
  .desk .scan-tabs, .desk .watch-tabs, .desk .chart-chips, #fw .cls, #fw .days, #den .dn-tabs {
    flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
    scrollbar-width: none; max-width: 100%; max-height: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  .desk .scan-tabs::-webkit-scrollbar, .desk .watch-tabs::-webkit-scrollbar, .desk .chart-chips::-webkit-scrollbar,
  #fw .cls::-webkit-scrollbar, #fw .days::-webkit-scrollbar, #den .dn-tabs::-webkit-scrollbar { display: none; }
  .desk .scan-tabs > *, .desk .watch-tabs > *, .desk .chart-chips > *, #fw .cls > *, #fw .days > *, #den .dn-tabs > * {
    flex: none; white-space: nowrap; scroll-snap-align: start; }
  #den .dn-tabs .dn-tab { flex: 1 0 auto; }   /* the tabs still share the row when they fit */
  /* the Fox Wire class row is one line now: its two-row cap and "+N" label have nothing to do */
  #fw .cls-cap .chips-cap-more { display: none; }
}
@media (max-width: 700px) {
  /* the alerts / rules tables are stacked grids here (above): a cell is not a 44 px row */
  #sf-alerts .alert-table td { height: auto; }
}

/* ==== slate 60b (B103): Research's section rail = ONE sideways chip line under the page head, sticky at the top of
   #sf-main (snap, no scrollbar, the right-edge fade: the slate 56 chip-row rule); a chip tap scrolls its section into
   view (research_rail.js). The Alerts template cards go 1-up. (docs/design/d3-pages.md sections 3 + 4) ==== */
@media (max-width: 700px) {
  #rs-cols > .rs-rail { position: sticky; top: 0; z-index: 2; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
    scroll-snap-type: x proximity; scrollbar-width: none; max-width: 100%; padding: var(--sf-sp-2); background: var(--sf-bg);
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  #rs-cols > .rs-rail::-webkit-scrollbar { display: none; }
  #rs-cols > .rs-rail > .rs-link { flex: none; min-height: 36px; scroll-snap-align: start; }
  #rs-grid > .tile { scroll-margin-top: 60px; }
  .alerts-page #sf-rule-tpls { grid-template-columns: minmax(0, 1fr); }
  /* R103 S2: the two small Alerts targets reach the 36 px floor (the "..." disclosure, the how-it-fires chip) */
  #sf-alerts details.alert-machine > summary { min-width: 36px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
  .alerts-page .rules-how { min-height: 36px; display: inline-flex; align-items: center; }
}

/* ==== slate 60c (B104): the reading-column rule (phone doc 161-165; docs/design/d3-pages.md section 6). Research /
   Playbook / Studies / Account / Users / Watch: the column at the full width with 16 px gutters (the page head, the
   panes and the cards on the same two edges), the long-read text at 15 px (~55-60 characters a line at 440 px).
   Reports: the readers' boxes stop scrolling on their own (#sf-main is the phone's one scroller), so the report's
   head (back + title) sticks at the top while the report scrolls, and the report text keeps its columns in its own
   sideways scroller - the cut-off right edge is the "more" signal (an inset hairline edge, no drop shadow). The ids
   (#sf-main ...) out-rank each page's own later <style>. ==== */
@media (max-width: 700px) {
  #sf-main .sf-column { padding-left: var(--sf-sp-4); padding-right: var(--sf-sp-4); }
  #sf-main .sf-column > :is(.page-head, .grid, .msg) { padding-left: 0; padding-right: 0; }
  #sf-main .sf-column > .sf-gate { margin-left: 0; margin-right: 0; }
  #sf-main form#rs-form, #sf-main #rs-grid { padding-left: var(--sf-sp-4); padding-right: var(--sf-sp-4); }
  #sf-main #rs-cols > .rs-rail { padding-left: var(--sf-sp-4); padding-right: var(--sf-sp-4); }
  #sf-main #pb .pb-main { padding-left: var(--sf-sp-4); padding-right: var(--sf-sp-4); }
  #sf-main #pb :is(.md, .rule .b), #sf-main .st :is(.readout ul, .readout .rule) { font-size: var(--sf-fs-3); line-height: 1.5; }
  /* Reports */
  #sf-main :is(.sf-reader > *, .sf-reader-main) { overflow: visible; }
  #sf-main .rp .rp-head { position: sticky; top: 0; z-index: 2; background: var(--sf-bg); }
  #sf-main .rp .rp-text { white-space: pre; word-break: normal; overflow-x: auto; overscroll-behavior-x: contain;
    box-shadow: inset -1px 0 0 var(--sf-line); }
}

/* ==== slate 57 (B95) T3: the phone shell (docs/design/phone-2026-11-03.md section 2). The phone query of the doc:
   <= 900 px, or a touch screen up to 1023 px (an iPad in portrait). The rail hides; the top bar (back / title / bell)
   and the tab bar (Home / Wire / Alerts / Den / More) frame #sf-main, the ONLY scroller (html / body do not scroll: a
   fixed bottom bar never drifts with the keyboard in WebKit standalone); sticky headers live inside it. Safe areas:
   viewport-fit=cover in base.html, the insets here. ==== */
@media (max-width: 900px), (pointer: coarse) and (max-width: 1023px) {
  html.sf-frame, html.sf-frame body { height: 100%; overflow: hidden; }
  html.sf-frame body { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "pop" "top" "main" "tab"; height: 100dvh; padding-left: 0; }
  .popbar { grid-area: pop; }
  .rail { display: none; }
  #sf-main { grid-area: main; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .topbar { grid-area: top; position: relative; height: auto; min-height: calc(var(--sf-top-h) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) max(var(--sf-sp-2), env(safe-area-inset-right, 0px)) 0 max(var(--sf-sp-2), env(safe-area-inset-left, 0px));
    gap: var(--sf-sp-2); }
  .top-back:not([hidden]) { display: inline-flex; min-width: 44px; height: 44px; border: 0; font-size: 28px; padding: 0 var(--sf-sp-1); }
  .crumb { flex: 1 1 auto; min-width: 0; overflow: hidden; }
  .crumb-group, .crumb-sep { display: none; }
  .crumb-page { font-size: var(--sf-fs-title, 17px); font-weight: var(--sf-fw-title, 600); overflow: hidden; text-overflow: ellipsis; }
  .topbar.has-block .crumb { display: none; }
  .top-clock, .top-user { display: none; }   /* slate 121 B: the rail toggle (.rail-btn) went - the fox mark is it, in the rail */
  .top-right { gap: var(--sf-sp-1); }
  .bell-btn { min-width: 44px; min-height: 44px; }
  .bell { position: static; }
  .bell-btn { position: relative; }   /* slate 58b (R95 S2): the badge sits inside the 44 px button, inside the top bar at inset 0 */
  .bell .badge { top: 2px; right: 2px; }
  .bell-menu { position: fixed; top: calc(var(--sf-top-h) + env(safe-area-inset-top, 0px) + 4px); left: var(--sf-sp-2); right: var(--sf-sp-2);
    width: auto; max-width: none; }
  /* the tab bar: 49 px + the home indicator's inset; five tabs 44 px tall, a 10 px one-word label; the active tab = the
     one active-state rule (fox-dim + fox-2); the Alerts badge mirrors the bell's unread count (shell.js) */
  .tabbar { grid-area: tab; display: flex; align-items: flex-start; height: calc(49px + env(safe-area-inset-bottom, 0px));
    padding: 4px max(var(--sf-sp-1), env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(var(--sf-sp-1), env(safe-area-inset-left, 0px));
    background: var(--sf-pane); border-top: 1px solid var(--sf-line); }
  .tabbar .tab { position: relative; flex: 1 1 0; min-width: 0; height: 44px; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; margin: 0 2px; padding: 0; background: none; border: 0; border-radius: var(--sf-r);
    color: var(--sf-text-3); font: inherit; cursor: pointer; text-decoration: none; }
  .tabbar .tab .ic { width: 22px; height: 22px; }
  .tabbar .tab-lab { font-size: 10px; line-height: 12px; font-weight: 500; }
  .tabbar .tab.on { background: var(--sf-fox-dim); color: var(--sf-fox-2); }
  .tabbar .tab:focus-visible { outline: 2px solid var(--sf-fox); outline-offset: -2px; }
  .tabbar .tab-badge { position: absolute; top: 1px; left: calc(50% + 4px); min-width: 16px; padding: 0 4px; border-radius: 8px;
    background: var(--sf-fox); color: #000; font: 700 var(--sf-fs-0)/16px var(--sf-mono); text-align: center; }
  .tabbar .tab-badge[hidden] { display: none; }
  /* the More sheet: the rail's grouped list (admin for the owner) + Account / out, over the page, above the tab bar */
  .more-sheet:not([hidden]) { position: fixed; z-index: 70; left: 0; right: 0; top: 0; bottom: calc(49px + env(safe-area-inset-bottom, 0px));
    display: flex; flex-direction: column; justify-content: flex-end; background: color-mix(in srgb, var(--sf-bg) 60%, transparent); }
  .more-panel { max-height: calc(100% - env(safe-area-inset-top, 0px) - 24px); overflow-y: auto; overscroll-behavior: contain;
    background: var(--sf-pane); border-top: 1px solid var(--sf-line); border-radius: 12px 12px 0 0; box-shadow: var(--sf-shadow);
    padding: var(--sf-sp-1) 0; }
  .more-group + .more-group { border-top: 1px solid var(--sf-line); }
  .more-cap { padding: var(--sf-sp-3) var(--sf-sp-4) var(--sf-sp-1); color: var(--sf-text-3); font-size: var(--sf-fs-0); font-weight: 500;
    text-transform: uppercase; letter-spacing: .06em; }
  .more-group a, .more-out { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 var(--sf-sp-4); color: var(--sf-text-2);
    background: none; border: 0; font: inherit; text-align: left; cursor: pointer; text-decoration: none; }
  .more-group a.on { background: var(--sf-fox-dim); color: var(--sf-fox-2); box-shadow: inset 2px 0 0 var(--sf-fox); }
  /* slate 58a (B96): the shared ticker chip sits after the title (the bar's centre), 44 px tall, no box; the palette box
     is the magnifier in the trailing slot (before the bell) and opens the full-height sheet: the field 44 px (16 px type,
     the field floor above), result rows 44 px, recents as 44 px chips */
  .tick { margin-left: 0; height: 44px; background: none; border: 0; }
  .topbar.has-block .tick { display: none; }   /* the Desk: its tabs + finder fill the bar and #desk-symbol shows the same symbol */
  .tick-btn { min-width: 44px; padding: 0 var(--sf-sp-1); }
  .tick-x { width: 32px; border-left: 0; font-size: 20px; }
  .pal-box { width: 44px; height: 44px; padding: 0; justify-content: center; background: none; border: 0; color: var(--sf-text-2); cursor: pointer; }
  .pal-box .ic { width: 20px; height: 20px; }
  .pal-ph, .pal-kbd { display: none; }
  .pal-q { height: 44px; margin: 0 var(--sf-sp-3) var(--sf-sp-2); }
  .pal-it { min-height: 44px; }
  .pal-chip { height: 44px; min-width: 64px; }
  /* slate 64 B110 (A2, R101 N10): the phone Desk (desk.css's slate 59b query = this one) paints no pane pop-out, no
     collapse and no "layout" - pop-outs are desktop-only (59b); the markup stays. A pane collapsed on the desktop shows
     its body here (its collapse button is gone); the chart panes keep 59b's line in place of their body. */
  .desk .pane-btn[data-act="pop"], .desk .pane-btn[data-act="collapse"], .desk #desk-layout-btn { display: none; }
  .desk .pane.collapsed:not(.pane-chart) > .pane-body { display: flex; }
  /* slate 65 B111 (P2, R110 N4): the phone shows every pane - hide is a desktop layout thing (the prefs keep it) */
  .desk .pane.user-hidden { display: flex; }
  /* slate 67 B113: the phone Fox Tails (/tails + the Dictionary), scoped to #tl. One candle at full width; the answers =
     big buttons in two columns, 44 px (taller only when a name wraps; Name it = four, Read it = five, the fifth spans the
     row); every control 16 px text; the answer card's look-alike drops under the candle. */
  #tl { padding: var(--sf-sp-2); }
  #tl .tl-fig .tl-svg { max-width: 100%; height: 220px; }
  #tl .tl-choices, #tl .tl-choices[data-n="5"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #tl .tl-choices[data-n="5"] .tl-choice:last-child { grid-column: 1 / -1; }
  #tl .tl-choice { height: auto; min-height: 44px; font-size: 16px; }
  #tl .ctl { min-height: 44px; font-size: 16px; }
  #tl .tl-keys { display: none; }
  #tl .tl-pair, #tl .tl-pattern { grid-template-columns: minmax(0, 1fr); }
  #tl .tl-sum { min-width: 0; width: 100%; }
  /* slate 68 B114 (the same block grows): the Find it chart and the Build it scale at full width (the builder's handle
     squares measure 44 px and more at the phone's scale), the lesson / Progress grids one column, and the answer card's
     Next row sticks to the foot of the screen (R113 N14). */
  #tl .tl-fig-find .tl-svg { height: 200px; }
  #tl .tl-fig-build .tl-svg { max-width: 100%; height: 320px; }
  #tl .tl-lesson, #tl .tl-grid, #tl .tl-pairs, #tl .tl-stats { grid-template-columns: minmax(0, 1fr); }
  #tl .tl-ex-lesson .tl-svg { width: 120px; height: 110px; }
  #tl #tl-answer > .ctl-row:last-of-type { position: sticky; bottom: 0; z-index: 1; background: var(--sf-pane); padding: var(--sf-sp-2) 0; }
  /* slate 69 B115 (the same block grows): level 8's 1-minute runs at full width, Live Read's pickers stacked (16 px, 44 px)
     and its two answer rows as the drill's big buttons (Read it = five, the level-8 row = four). */
  #tl .tl-fig-run .tl-svg { max-width: 100%; height: 200px; }
  #tl .tl-live-pick { flex-direction: column; align-items: stretch; }
  #tl .tl-live-pick select { width: 100%; min-height: 44px; font-size: 16px; }
  #tl .tl-live-verdict { position: sticky; bottom: 0; z-index: 1; background: var(--sf-pane); padding: var(--sf-sp-2) 0; }
  /* slate 72 B119: the Little Fox / Big Fox flip = two 44 px halves across the pane */
  #tl .tl-live-track { display: flex; }
  #tl .tl-live-track > .tl-track { flex: 1 1 0; min-height: 44px; font-size: 16px; }
  /* slate 74 B121 Y2: /manual - each table scrolls sideways in its own box at 390 px (the page never does) */
  #tl .tl-manual-body table { display: block; max-width: 100%; overflow-x: auto; }
  /* slate 75 B122: the Pace control = two 44 px halves across the pane; the lesson's Test out button 44 px */
  #tl .tl-pace { display: flex; }
  #tl .tl-pace > .tl-track { flex: 1 1 0; min-height: 44px; font-size: 16px; }
  #tl .tl-testout { min-height: 44px; font-size: 16px; }
  /* slate 70a B116: the phone Fox Run (/foxrun, scoped to #fr): the action row = 44 px buttons pinned above the tab bar
     (sticky at the foot of #sf-main, the only scroller), the drills' / plan's buttons 44 px, the chart's price handles a
     44 px hit band (foxrun_draw.js HANDLE_PX draws the same), 16 px controls (no iOS zoom). */
  #fr .fr-actions { position: sticky; bottom: 0; z-index: 2; background: var(--sf-pane); padding: var(--sf-sp-1) 0; margin: 0; }
  #fr .fr-actions > button, #fr .fr-kit > button, #fr .fr-plan button, #fr #fr-db-next, #fr #fr-end { min-height: 44px; min-width: 44px; }
  #fr .fr-mode > button { height: 44px; }
  #fr .fr-hit { height: 44px; }
  #fr input.ctl, #fr select.ctl { font-size: 16px; min-height: 44px; }
  /* slate 70b B117: the scanner strip scrolls sideways (one symbol card per swipe stop), its buttons 44 px; the decision
     timer readable at a glance; the board's tables at 16 px, each scrolling sideways in its own wrap. */
  #fr .fr-strip { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: var(--sf-sp-2); padding-bottom: var(--sf-sp-1); }
  #fr .fr-cand { flex: 0 0 78%; scroll-snap-align: start; }
  #fr .fr-cand-ctl > button, #fr #fr-morning-new, #fr #fr-db-back, #fr #fr-c-filings { min-height: 44px; min-width: 44px; }
  #fr .fr-timer { font-size: 22px; }
  #frb .fr-bd-table { font-size: 16px; }
  #frb .fr-bd-table th, #frb .fr-bd-table td { padding: var(--sf-sp-2); }
  /* slate 84 (B131) the frame on the phone, inside this one phone-shell block. F2: the top bar's buttons are ONE look -
     44 px, no outline (the "?" was the lone outlined box); the back chevron and the bell are the sprite's Lucide symbols.
     F3: each More row carries the icon its rail row has, 18 px before the name (order, links and the 44 px rows
     unchanged); the Big Fox app row has no rail row, so its name sits on the same left edge with no icon. F4: a page
     head's title is visually hidden when the top bar's title already says the same words - each such page named by its
     own container (tests/test_frame84.py renders every page and checks this list is exactly the pages whose two titles
     match); the head's sub-line and actions stay, and the title stays readable to a screen reader. A head that says
     something else (Fox Den, Fox Ops, Fox Replay, the Fox Run board, the Fox Tails sub-pages, the Open brief once it
     names its day) keeps both; the Desk's top bar shows its block, not a title, and the Desk has no page head. */
  .top-right .top-btn { min-width: 44px; height: 44px; padding: 0; border: 0; font-size: 20px; }
  .top-right .top-btn .ic { width: 20px; height: 20px; }
  /* slate 122 A: the feedback button = the sprite's message-circle on the phone (its accessible name stays "Feedback");
     the panel is the bell menu's phone sheet (fixed under the bar, full width); the box 44 px with 16 px text */
  .fb { position: static; }
  .fb-btn .ic { display: block; }
  .fb-lab { display: none; }
  .top-right .top-btn.fb-btn { padding: 0; }
  .fb-pop { width: auto; }
  .fb-q, .fb-send { height: 44px; font-size: 16px; }
  .fb-x { min-height: 36px; padding: 0 var(--sf-sp-3); }
  .top-back .ic { width: 24px; height: 24px; }
  .more-group a, .more-out { gap: var(--sf-sp-3); }
  .more-group a .ic, .more-out .ic { flex: none; width: 18px; height: 18px; }
  .more-app a { padding-left: calc(var(--sf-sp-4) + 18px + var(--sf-sp-3)); }
  #sf-main :is(#sf-account, #sf-alerts, #bf.bf, #fr, .ft, #fw, .rp-page, .st-main, #train, .uadm, #wl) > .page-head > .title,
  #sf-main #tl:has(> #tl-start) > .page-head > .title, #sf-main form#rs-form.page-head > .title {
    position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; overflow: hidden; white-space: nowrap; clip-path: inset(50%); }
}

/* ==== slate 60a B102 (A5): the phone Den (docs/design/d3-pages.md section 1). The month heat-map is the Den tab's first
   screen (7 x 52 px cells, phone doc line 84) above the journal; the journal table stays the sideways scroller (the B18
   rule above) with its first column (the symbol) sticky on the pane colour. Scoped to #den. ==== */
@media (max-width: 700px) {
  #den .dn-cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); max-width: none; }
  #den button.dn-cal-cell, #den .dn-cal-gap { height: 52px; }
  #den button.dn-cal-cell { padding: 2px 3px; }
  #den .dn-cal-cell .v { font-size: var(--sf-fs-0); letter-spacing: -0.02em; }
  #den .dn-cal h2 { flex-wrap: wrap; }
  #den .dn-cal .dn-cal-day { flex-basis: 100%; }
  #den #dn-trades th:first-child, #den #dn-trades td:first-child { position: sticky; left: 0; z-index: 1; background: var(--sf-pane); box-shadow: inset -1px 0 0 var(--sf-line); }
}

/* ==== slate 61 B105 (C7): the phone Replay (docs/design/replay-chart.md section 6; phone doc line 163). The chart at full
   width, 320 px tall (replay.html), a line + VWAP by default (replay.js), the library's own touch: a horizontal drag pans
   the chart, a vertical one scrolls the page, pinch zooms, a long press = the crosshair with the readout strip under the
   chart. The play row wraps to two rows of 44 px controls; the tools row (timeframe chips, chart type, the toggles, fit)
   = one horizontal scroller, never a page-wide sideways pan. Scoped to #rp2. ==== */
@media (max-width: 700px) {
  #rp2 .rp-tools { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none;
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); padding-bottom: 2px; }
  #rp2 .rp-tools::-webkit-scrollbar { display: none; }
  #rp2 .rp-tools > *, #rp2 .rp-shows > * { flex: none; scroll-snap-align: start; }
  #rp2 .rp-shows { flex-wrap: nowrap; }
  #rp2 .rp-tools .seg > button, #rp2 .rp-tog, #rp2 #rp-fit { height: 44px; min-width: 44px; }
  #rp2 .rp-fox > button { height: 44px; }
  #rp2 .page-head .rp-fox { flex: 1 1 100%; }
  #rp2 .page-head .rp-fox > button { flex: 1 1 50%; }
  #rp2 .rp-ctl { row-gap: var(--sf-sp-2); }
  #rp2 #rp-chart { touch-action: pan-y; }
  #rp2 .rp-readout { font-size: var(--sf-fs-meta); }
}

/* ==== slate 78 (B125) D3, R121 N5: the phone Fox Run head = ONE row. The track switch and the four chips (Rank, Board,
   How it works, Desk) sit on one line that scrolls sideways (snap, no scrollbar, the right-edge fade: the slate 56 chip-row
   rule the Desk's tabs use); every chip 36 px tall (the Rank chip's line height; the links are 36 px already). CSS only, scoped to #fr; fix round 1 (R125 S1): the whole block at <= 700 px, the width where shell.css makes the link
   chips 36 px, so 701 px and up is master's head exactly (no fade, no Rank chip taller than the links). ==== */
@media (max-width: 700px) {
  #fr .page-head .actions { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
    scrollbar-width: none; max-width: 100%;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  #fr .page-head .actions::-webkit-scrollbar { display: none; }
  #fr .page-head .actions > * { flex: none; white-space: nowrap; scroll-snap-align: start; }
  #fr .page-head .actions > .fr-rank { line-height: 36px; }   /* the link chips are 36 px already (shell.css a.chip.desk-back) */
}
