/* r326: phones. Taller bottom row in full screen (clear of the gesture bar), legend at the very top in full screen,
   one clean bottom-sheet style for Tools, time frame, chart type and other menus. Theme variables only. */
@media (max-width: 767px), (max-width: 1024px) and (max-height: 500px) and (pointer: coarse) {
  /* ---------- full screen: bottom tool row taller and lifted off the gesture bar ---------- */
  html.sc-full body:not(.embed), html.sc-full body:not(.embed)[data-desk-density] { --mobile-controls-h: calc(58px + max(env(safe-area-inset-bottom), 16px)) !important; }
  html.sc-full body.mobile-toolbar-mounted:not(.embed) .top { height: calc(58px + max(env(safe-area-inset-bottom), 16px)) !important; padding: 4px max(8px, env(safe-area-inset-right)) max(env(safe-area-inset-bottom), 16px) max(8px, env(safe-area-inset-left)) !important; border-top: 1px solid var(--hair); background: var(--card); }
  html.sc-full body.mobile-toolbar-mounted:not(.embed) #mobileToolbarRow { height: 50px !important; gap: 4px !important; }
  html.sc-full body.mobile-toolbar-mounted:not(.embed) #mobileToolbarRow > #symBtn { height: 46px !important; }
  html.sc-full body.mobile-toolbar-mounted:not(.embed) #mobileToolbarRow > :is(#typeBtn, #indBtn, #quickBtn) { flex: 0 0 42px !important; width: 42px !important; min-width: 42px !important; max-width: 42px !important; height: 42px !important; min-height: 42px !important; }
  html.sc-full body.mobile-toolbar-mounted:not(.embed) #mobileToolbarRow > #tfBtn { height: 38px !important; min-height: 38px !important; }
  html.sc-full .sc-full-exit { right: calc(env(safe-area-inset-right) + 72px) !important; }

  /* ---------- full screen: symbol name and O H L C sit at the top edge (below the notch) ---------- */
  html.sc-full body:not(.embed) .card .legend, html.sc-full body:not(.embed) .legend { top: max(env(safe-area-inset-top), 4px) !important; left: max(env(safe-area-inset-left), 8px) !important; }
  html.sc-full body:not(.embed) .stage, html.sc-full body:not(.embed) .card { top: 0 !important; margin-top: 0 !important; padding-top: 0 !important; }
  html.sc-full body:not(.embed) .panel-tabs { display: none !important; }

  /* ---------- one bottom-sheet style for every menu ---------- */
  .pop.mobile-sheet { z-index: 1100 !important; left: max(8px, env(safe-area-inset-left)) !important; right: max(8px, env(safe-area-inset-right)) !important; width: auto !important; max-width: none !important;
    bottom: calc(var(--nav-h, 66px) + env(safe-area-inset-bottom) + 8px) !important; top: auto !important; max-height: min(74dvh, calc(var(--mobile-visible-height, 100dvh) - var(--nav-h, 66px) - env(safe-area-inset-bottom) - 24px)) !important;
    overflow-y: auto !important; overscroll-behavior: contain; padding: 0 12px 12px !important; border-radius: 18px !important; border: 1px solid var(--hair) !important; background: var(--card) !important; box-shadow: 0 -10px 34px rgba(0,0,0,.22) !important; }
  html.sc-full .pop.mobile-sheet { bottom: calc(var(--mobile-controls-h) + 8px) !important; max-height: calc(100dvh - var(--mobile-controls-h) - env(safe-area-inset-top) - 20px) !important; }
  .pop.mobile-sheet .sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; margin: 0 -12px 6px; padding: 14px 12px 10px; background: var(--card); border-bottom: 1px solid var(--hair); }
  .pop.mobile-sheet .sheet-head::before { content: ""; position: absolute; top: 5px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 999px; background: var(--hair); }
  .pop.mobile-sheet .sheet-head b { font-size: 15px; font-weight: 700; }
  .pop.mobile-sheet .sheet-head .sheet-close { width: 34px; height: 34px; border-radius: 10px; background: var(--fill); }
  .pop.mobile-sheet .ph { margin: 10px 2px 6px !important; padding: 0 !important; font-size: 11px !important; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--t3); }
  .pop.mobile-sheet .pi { min-height: 46px; padding: 0 12px; border-radius: 11px; font-size: 14px; gap: 12px; }
  .pop.mobile-sheet .pi svg { width: 20px; height: 20px; flex: none; }
  .pop.mobile-sheet .pi.on { background: var(--fill-2); font-weight: 650; }
  .pop.mobile-sheet .psep { margin: 8px 0; }

  /* Tools menu: tidy 4-column tiles in sections */
  .pop.mm-pop .menu-section { margin: 0; padding: 0; border: 0; }
  .pop.mm-pop .mm-grid { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 6px !important; padding: 0 !important; }
  .pop.mm-pop .mm { display: flex !important; flex-direction: column !important; align-items: center !important; justify-content: center !important; gap: 6px !important; min-height: 74px !important; padding: 8px 4px !important; border: 1px solid var(--hair) !important; border-radius: 12px !important; background: var(--card) !important; color: var(--t1); font-size: 10.5px !important; line-height: 1.25 !important; text-align: center; }
  .pop.mm-pop .mm svg { width: 22px !important; height: 22px !important; color: var(--t1); }
  .pop.mm-pop .mm span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 10.5px !important; }
  .pop.mm-pop .mm:active { background: var(--fill-2) !important; }
  .pop.mm-pop .mobile-view-actions .mm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .pop.mm-pop .mobile-view-actions .mm { min-height: 44px !important; font-size: 12px !important; }
  .pop.mm-pop .mobile-view-actions .mm[aria-pressed=true] { background: var(--t1) !important; color: var(--card) !important; border-color: var(--t1) !important; }
  @media (max-width: 360px) { .pop.mm-pop .mm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; } }

  /* modal sheets (drawing tools, indicators, settings) above the navigation bar */
  .modal { z-index: 1150 !important; }
}

/* r328: price freshness label next to the live dot (all screens) */
@media all { .lg-fresh { margin-left: 5px; padding: 0 5px; border-radius: 4px; font-size: 10px; font-weight: 600; line-height: 16px; white-space: nowrap; color: var(--t3); background: var(--fill); font-variant-numeric: tabular-nums; }
  .lg-fresh:empty { display: none; }
  .lg-fresh[data-st=ok] { color: var(--up, #089981); }
  .lg-fresh[data-st=slow] { color: #d98a00; }
  .lg-fresh[data-st=old] { color: var(--down, #f23645); } }
