/* Cella007FX PRO mobile.css — phones (< 768 px) and landscape phones (SPEC 2.3, 1.2 #14). Owner: WP-6.
   Header 2 lines (64 px), toolbar at the bottom (48 px + safe-area) with a horizontally scrolling TF strip (44 px
   targets), panel as a bottom sheet (#panel.sheet, snap 60 % / 90 %, drag handle #panel-grip), touch-action:none on
   the chart, 100dvh with a 100vh fallback, no horizontal page scroll. Landscape (max-height 500 px): header 1 line,
   status bar hidden. Loaded after app.css, so equal-specificity rules here win. */

@media (max-width: 767px) {
  :root { --hdr-h: 64px; --tb-h: 48px; }

  #app {
    grid-template-rows: var(--hdr-h) var(--legend-h) minmax(0, 1fr) auto var(--status-h) calc(var(--tb-h) + env(safe-area-inset-bottom, 0px));
    grid-template-areas: "hdr" "lg" "stage" "banner" "status" "tb";
    height: 100vh; height: 100dvh;
  }

  /* header: line 1 = brand (grows, so the quote wraps) + right cluster; line 2 = quote (priority) + stats (truncates) */
  #hdr { display: flex; flex-wrap: wrap; align-items: center; align-content: stretch; gap: 0 8px; padding: 0 10px; overflow: hidden; }
  #hdr::after { content: ""; order: 1; flex: 0 0 100%; height: 0; }          /* hard line break after the right cluster */
  /* flex-basis 0 (not auto): a long source-pill label squeezes the brand mark (which ellipsizes). That alone does NOT
     stop line 1 breaking: flex-wrap breaks as soon as the right cluster by itself is wider than the line, so the cluster
     must be able to shrink too (min-width 0 + max-width) — the pill clips, ≡ never moves, the bid row stays on line 2.
     A weekend FALLBACK label ("FALLBACK · Binance·proxy · weekend · 125s", ~246 px) broke it at 320 px. */
  #brand { order: 0; flex: 1 1 0; height: 32px; line-height: 32px; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
  #brand-sym { display: none; }
  #hdr-right { order: 0; flex: 0 1 auto; min-width: 0; max-width: calc(100% - 8px); height: 32px; margin-left: 0; gap: 8px; }
  #hdr-right #srcpill { min-width: 0; overflow: hidden; }
  #hdr-right #btn-panel { flex: 0 0 auto; }
  #hdr-quote, #hdr-stats { order: 2; display: block; height: 32px; line-height: 32px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #hdr-quote { flex: 1 1 0; }                                                /* bid / ask first; the tail truncates */
  #hdr-quote > * + * { margin-left: 8px; }
  #hdr-stats { flex: 0 1 auto; max-width: calc(100% - 100px); text-align: right; font-size: 11px; }   /* chips take their width, the bid keeps >= 100 px */
  #hdr-stats > * + * { margin-left: 8px; }
  #hdr-quote:empty, #hdr-stats:empty { display: none; }
  #hq-bid { font-size: 22px; }                                               /* the number a trader glances at is the largest text */
  #btn-panel { min-width: 44px; height: 32px; padding: 0; font-size: 20px; }  /* the button that opens everything gets a real target */
  /* the per-timeframe arrows carry the signal on a phone; the words and the score would crowd them out */
  .mtf-hdr-bias, .mtf-hdr-score { display: none; }
  #hdr-stats { overflow: visible; }
  .mtf-hdr-tfs { gap: 4px; justify-content: flex-end; }
  .mtf-hdr-tf { font-size: 11px; line-height: 26px; min-height: 28px; padding: 0 7px; }   /* tappable: each chip switches the timeframe */
}
/* narrow phones (iPhone SE/8/12 mini, 360-wide Androids): six chips (M1 added 10 Nov 2026) must fit beside the bid */
@media (max-width: 400px) {
  .mtf-hdr-tf { font-size: 10px; padding: 0 3px; }
  .mtf-hdr-tfs { gap: 2px; }
}
/* 11 Nov 2026: the pinned cluster now holds Zoom to area + Auto fit too; 40 px TF keys (still finger-size) keep five
   or more timeframes (M1..H1) in view beside it; 440 px (review UX-5) so 412 / 414 px phones get them as well as 400 */
@media (max-width: 440px) {
  #toolbar #tf-strip .btn { min-width: 40px; }        /* 2 ids: beats the later 767px "#tf-strip .btn" rule */
}
@media (max-width: 340px) {                          /* 320 px: keep H1 (the backtested TF) in view; still 44 px tall */
  #toolbar #tf-strip .btn { min-width: 34px; padding: 4px 1px; }
  #toolbar #tb-right .btn.tb-icon { min-width: 34px; padding: 4px 3px; }
}
@media (max-width: 360px) {
  #hq-bid { font-size: 19px; }
  .mtf-hdr-tf { font-size: 9.5px; padding: 0 2px; }
}
@media (max-width: 767px) {
  #clock { display: none; }
  #srcpill { height: 20px; padding: 0 7px; font-size: 10px; }

  /* toolbar at the bottom: one horizontally scrolling strip, 44 px targets, safe-area padding */
  #toolbar {
    flex-wrap: nowrap; gap: 6px; padding: 2px 6px calc(2px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); border-bottom: 0;
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; overscroll-behavior-x: contain;
  }
  #toolbar::-webkit-scrollbar { display: none; }
  #toolbar > div { flex: 0 0 auto; gap: 2px; }
  #toolbar > div + div { padding-left: 6px; }
  /* phone toolbar = timeframes + drawing tools + a pinned alert bell. Chart type and the four toggles live in Settings >
     Display, Ind / gear duplicate the sheet tabs, fullscreen is unsupported on iPhone and ? is a keyboard map. */
  #toolbar > #tb-type, #toolbar > #tb-toggles, #btn-fullscreen, #btn-help { display: none; }   /* > #id beats app.css "#toolbar > div { display:flex }" */
  #tb-right { position: sticky; right: 0; margin-left: auto; padding-left: 6px; border-left: 1px solid var(--line); background: var(--bg-1); box-shadow: -10px 0 10px -8px rgba(0,0,0,.6); }
  #toolbar .btn { min-height: 44px; min-width: 44px; padding: 4px 8px; font-size: 13px; border-radius: 8px; }
  /* 11 Nov 2026: Zoom to area + Auto fit are moved into the pinned cluster (ui/toolbar.js) — 40 px wide icons */
  #tb-right { gap: 2px; right: -6px; padding-right: 6px; }   /* review UX-4: cover the bar's 6 px right gutter ("Dr" sliver) */
  /* 15 Nov 2026 (review UX10-5): H4 / D1 / W1 and Draw scroll under this pinned group and nothing said so. While there
     is more to the right (ui/toolbar.js sets .tb-more) a small gold chevron stands on the group's left edge. */
  #toolbar.tb-more #tb-right::before {
    content: "\203A"; position: absolute; left: -14px; top: 0; bottom: 0; width: 14px; display: flex; align-items: center; justify-content: center;
    font: 700 20px/1 var(--font-ui); color: var(--gold); background: linear-gradient(to right, transparent, var(--bg-1) 55%); pointer-events: none;
  }
  #toolbar .btn.tb-icon { min-width: 38px; min-height: 44px; padding: 4px 5px; }
  .tb-icon svg { width: 20px; height: 20px; }
  #tf-strip { gap: 2px; }
  #tf-strip .btn { min-width: 44px; padding: 4px 4px; }
  #tb-type select { min-height: 40px; padding: 2px 4px; }

  /* legend: single line (legend.js sets no inline layout any more). 12 Nov 2026 (review G7UX-1): it held 900 px of text in
     375 px and cut the rest off ("EMA(200) · need…", an added VWAP / ATR never seen), so it now scrolls sideways with a
     finger; while there is more than fits (.lg-more, set by ui/legend.js) the right edge fades out to show it, and a
     24 px spacer lets the last item clear the fade. */
  #legend { display: block; line-height: var(--legend-h); padding: 0 8px; font-size: 11px; white-space: nowrap;
    overflow-x: auto; overflow-y: hidden; text-overflow: clip; scrollbar-width: none; overscroll-behavior-x: contain; }
  #legend::-webkit-scrollbar { display: none; }
  #legend.lg-more { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
  #legend.lg-more::after { content: ''; display: inline-block; width: 24px; }
  #legend > span + span { margin-left: 8px; }
  #legend .lg-ind { display: inline; }
  /* trade setup card on a phone: bigger grade ring and tiles, finger-size controls */
  .setup-gauge { flex-basis: 132px; }
  .setup-gauge-svg { width: 120px; height: 142px; }
  .setup-age-v { font-size: 14px; }
  .setup-tile-v { font-size: 17px; }
  .setup-headline { font-size: 15px; }
  .setup-foot label { min-height: 36px; display: inline-flex; align-items: center; gap: 6px; }
  /* no developer status bar on a phone: the pill says the same, the strip shows the timeframe */
  :root { --status-h: 0px; }
  #statusbar { display: none; }
  /* finger-size the controls inside the sheet (desktop density untouched) */
  .setup-foot select, .ind-add-row select { min-height: 36px; font-size: 16px; padding: 2px 8px; }
  /* Help on a phone = "About this page" only; the key map needs a keyboard */
  .help-keys-title, .help-grid, .help-card > .note { display: none; }
  .ind-row .btn.ghost, .draw-row .btn.ghost, .btn.sm { min-height: 36px; min-width: 36px; padding: 4px 8px; font-size: 12px; }
  .ind-row, .draw-row, .alert-row { padding: 6px 0; }
  /* 13 Nov 2026 (review UX8-8): finger-size the Alerts tab. The three buttons under the form were 28 px high and a
     row's on / off box 13 px. */
  #alert-form .settings-actions .btn { min-height: 40px; }
  .alert-row > input[type="checkbox"] { width: 20px; height: 20px; flex: 0 0 auto; margin: 8px 4px 8px 0; }
  .al-away-line { padding-left: 34px; }
  .modal-x { min-width: 40px; min-height: 40px; }
  .calc-adv > summary { padding: 8px 0; }
  .setup-foot, .setup-alertrow { gap: 10px 16px; }
  .mk-chip { line-height: 24px; padding: 0 9px; }
  .mk-news summary { padding: 4px 0; }

  /* stage: chart only; touch is owned by the chart (no page scroll / zoom) */
  #stage { grid-template-columns: minmax(0, 1fr); }
  #chart-wrap { touch-action: none; }
  #countdown { font-size: 10px; }

  /* panel: bottom sheet (snap 60 % / 90 %; ui/panel.js drives translateY during the drag and .open / .full after it) */
  #panel-grip {
    display: block; flex: 0 0 auto; height: 28px; position: relative; touch-action: none; cursor: grab;
  }
  #panel-grip::before {
    content: ""; position: absolute; left: 50%; top: 11px; width: 42px; height: 5px; margin-left: -21px; border-radius: 3px; background: var(--text-2);
  }
  #panel.sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: 60vh; height: 60dvh; max-height: 90dvh;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: var(--shadow);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transform: translateY(100%); transition: transform .24s ease, height .18s ease; visibility: hidden;
  }
  #panel.sheet.open { transform: none; visibility: visible; }
  #panel.sheet.full { height: 90vh; height: 90dvh; }
  #panel.sheet.dragging { transition: none; }
  #panel.sheet > section { padding: 8px 10px 14px; }
  #panel-tabs .tab { min-height: 40px; }
  #panel-resizer { display: none; }                 /* the sheet is full-width */

  /* overlays: keep toasts above the bottom toolbar; modals fill the width */
  #toast-root { right: 8px; left: 8px; width: auto; bottom: calc(var(--tb-h) + var(--status-h) + 10px + env(safe-area-inset-bottom, 0px)); }
  #modal-root { padding: 10px; align-items: flex-end; }
  .modal { width: 100%; max-height: min(88vh, 88dvh); margin-bottom: env(safe-area-inset-bottom, 0px); }
  #help { padding: 10px; align-items: flex-end; }
  .help-card { width: 100%; max-height: min(85vh, 85dvh); }
  .help-grid { grid-template-columns: 1fr; }

  /* forms: bigger targets */
  .field input, .field select { min-height: 40px; font-size: 16px; }   /* 16 px: iOS Safari zooms the page for anything smaller */
  /* ...and EVERY other text control on a phone (pivot type select, session time inputs, alert price fields): a focus
     zoom leaves the page wider than the screen until the user pinches back — the same symptom as the banner bug */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea { font-size: 16px; }
  /* Settings > Sessions: five columns (name + zone note, two time inputs, On, Shade) must fit a 300 px card; the
     inline 84 px time-input min-width and the unbreakable IANA zone held the table at ~370 px and the section's
     overflow-x:hidden cut off the Shade checkbox. Let the inputs and the note shrink; scroll as the last resort. */
  #settings-sessions { overflow-x: auto; }
  #settings-sessions .note { overflow-wrap: anywhere; }
  #settings-sessions input[type="time"] { min-width: 0 !important; width: 100%; padding: 2px 4px; }
  /* each session = two lines on a phone: the name + zone note across the card, then Start | End | On | Shade */
  #settings-sessions table, #settings-sessions thead, #settings-sessions tbody { display: block; width: 100%; }
  #settings-sessions tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px 44px; gap: 2px 6px; align-items: center; }
  #settings-sessions tr > :first-child { grid-column: 1 / -1; }
  #settings-sessions tbody tr { padding: 6px 0; border-top: 1px solid var(--line); }
  #settings-sessions th, #settings-sessions td { padding: 0; min-width: 0; }
  #settings-sessions td:nth-child(n+4), #settings-sessions th:nth-child(n+4) { text-align: center; }
  .field input[type="checkbox"] { width: 20px; height: 20px; }
  .field.check:not(.switch):has(> .hint) > .hint { padding-left: 28px; }   /* under the label: 20 px box + 8 px gap */
  .grid2 { grid-template-columns: 1fr 1fr; }

  /* banner / status: keep to one line */
  #banner { padding: 3px 10px; font-size: 11px; }
  /* 11 Nov 2026 (review G3-UX-4): the open sheet covers the banner's grid row, so a warning / error banner (DELAYED,
     OFFLINE...) is pinned on the sheet's top edge while the sheet is open (just under the header when the sheet is full
     height): its words and "Change source" stay reachable and the chart's top-left note is not covered. Opaque, so the
     candles never show through. The calm weekend info banner stays in its row. */
  #app:has(#panel.sheet.open) > #banner.lvl-warn:not([hidden]),
  #app:has(#panel.sheet.open) > #banner.lvl-err:not([hidden]) {
    position: fixed; left: 0; right: 0; bottom: 60vh; bottom: 60dvh; z-index: 45; box-shadow: var(--shadow);
    background-color: var(--bg-1);
  }
  #app:has(#panel.sheet.open) > #banner.lvl-warn:not([hidden]) { background-image: linear-gradient(var(--warn-dim), var(--warn-dim)); }
  #app:has(#panel.sheet.open) > #banner.lvl-err:not([hidden]) { background-image: linear-gradient(var(--err-dim), var(--err-dim)); }
  #app:has(#panel.sheet.open.full) > #banner.lvl-warn:not([hidden]),
  #app:has(#panel.sheet.open.full) > #banner.lvl-err:not([hidden]) { bottom: auto; top: calc(var(--hdr-h) + var(--legend-h)); }
  /* review G3-UX-11: dialog buttons are finger-size too (Welcome "Got it" was 28 px) */
  .modal-ft .btn { min-height: 44px; }
  #statusbar { padding: 0 8px; font-size: 10px; }
  #statusbar .sb-debug, #statusbar .sb-right { display: none; }   /* the disclaimer / Help link needs the desktop width */
}

/* landscape phones: 1-line header, status bar hidden, tighter legend */
@media (max-width: 767px) and (max-height: 500px) {
  :root { --hdr-h: 40px; --status-h: 0px; --legend-h: 18px; }
  #hdr { flex-wrap: nowrap; gap: 0 10px; }
  #hdr::after { display: none; }
  #brand { flex: 0 0 auto; height: 40px; line-height: 40px; }
  #hdr-quote { flex: 1 1 auto; height: 40px; line-height: 40px; }
  #hdr-stats { display: none; }
  #hdr-right { flex: 0 0 auto; height: 40px; }
  #hq-bid { font-size: 16px; }
  #statusbar { display: none; }
  #toast-root { bottom: calc(var(--tb-h) + 10px + env(safe-area-inset-bottom, 0px)); }
  #panel.sheet { height: 90vh; height: 90dvh; }
  /* review G3-UX-4: the sheet is 90 % high here, so the pinned banner goes under the header */
  #app:has(#panel.sheet.open) > #banner.lvl-warn:not([hidden]),
  #app:has(#panel.sheet.open) > #banner.lvl-err:not([hidden]) { bottom: auto; top: var(--hdr-h); }
}

/* (the group 5 phone header line block is at the end of this file) */
/* very narrow (<= 360 px): hide the tool group labels' padding so nothing forces page overflow */
@media (max-width: 360px) {
  #hdr { padding: 0 8px; }
  #hdr-quote { gap: 6px; }
  #hq-bid { font-size: 16px; }
  #toolbar > div + div { padding-left: 4px; }
}

/* ==== group 5 phone header line (11 Nov 2026; widgets/header.js #hdr-line3) =========================================
   Owner: "tools for trading on the phone". A third header line on a portrait phone: left = the setup card's one-line
   summary ('H1 setup  ▲ BUY · +0.42R  late · skip' / 'H1 setup  WAITING'; a tap opens the Setup card, L33), right = the
   compact trend tag ('◆ MIXED 4/7', the word drops only when the line does not fit; a tap opens the Trend card, KL-MIXEDPHONE). Its own
   line, so the 320 px price + chip line is untouched. Header 64 -> 88 px. Hidden on desktop and in landscape. */
#hdr-line3 { display: none; }
@media (max-width: 767px) and (min-height: 501px) {
  :root { --hdr-h: 88px; }
  #hdr-line3 { order: 3; flex: 0 0 100%; display: flex; align-items: center; gap: 8px; height: 24px; min-width: 0; border-top: 1px solid var(--line); }
  #hdr-line3 > button { position: relative; height: 24px; margin: 0; padding: 0; border: 0; background: none; color: var(--text-1); font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  /* review UX5-7: a 28 px hit area without a taller header (the header clips below; 4 px up is the chip line's empty edge) */
  #hdr-line3 > button::after { content: ''; position: absolute; left: 0; right: 0; top: -4px; bottom: 0; }
  #hdr-line3 > button:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; border-radius: 4px; }
  #hdr-line3 > button:active { opacity: .7; }
  #hdr-setup { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px; text-align: left; font-size: 12px; line-height: 24px; }
  #hdr-setup .hl3-in { flex: 0 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #hdr-setup .hl3-chev { flex: 0 0 auto; font-size: 15px; line-height: 24px; color: var(--text-2); }
  #hdr-setup .hl3-tf { margin-right: 4px; font-size: 11px; color: var(--text-2); }
  #hdr-setup .hl3-tfw { margin-right: 6px; font-size: 11px; color: var(--text-2); }
  #hdr-line3.no-setupw .hl3-tfw { display: none; }
  #hdr-line3.no-setupw .hl3-tf { margin-right: 6px; }
  #hdr-setup .hl3-txt { font-weight: 700; color: var(--text-1); }
  #hdr-setup .hl3-txt.hl3-up { color: var(--up); }
  #hdr-setup .hl3-txt.hl3-down { color: var(--down); }
  #hdr-setup .hl3-txt.hl3-off { font-weight: 600; color: var(--text-1); }
  #hdr-setup .hl3-r { margin-left: 6px; font-weight: 700; }          /* review UX5-3: coloured by its own sign */
  #hdr-setup .hl3-r.hl3-up { color: var(--up); } #hdr-setup .hl3-r.hl3-down { color: var(--down); } #hdr-setup .hl3-r.hl3-off { color: var(--text-1); }
  #hdr-setup .hl3-late { margin-right: 6px; padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 700; color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
  #hdr-mtf-tag { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px; height: 20px !important; padding: 0 7px !important;
    border: 1px solid var(--line) !important; border-radius: 10px; background: var(--bg-3) !important; font-size: 11px; line-height: 18px; white-space: nowrap; }
  #hdr-mtf-tag[hidden] { display: none; }
  #hdr-mtf-tag::after { top: -6px; bottom: -2px; }
  #hdr-mtf-tag .hl3-word { font-weight: 700; letter-spacing: .03em; }
  #hdr-mtf-tag.no-word .hl3-word { display: none; }                   /* review UX5-8: only when the line does not fit (header.js fitLine3) */
  #hdr-mtf-tag.up { color: var(--up); } #hdr-mtf-tag.down { color: var(--down); } #hdr-mtf-tag.flat { color: var(--text-1); }
}
/* ==== end group 5 phone header line ================================================================================= */
