#chartOptions, #openQuickWatch, #editMobileTabs, #mainNav .mobile-only-tab { display: none; }
.phone-chart-bar, .phone-tab-strip { display: none; }
.lower-study-resize { display: none; }
.chart-area > .phone-chart-reset { display: none; }
#tools .rail-mobile-actions { display: none; }

.quick-watch-list { margin-inline: -10px; }
.quick-watch-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 0;
  border-bottom: 1px solid var(--hairline);
  text-align: left;
}
.quick-watch-row:last-child { border-bottom: 0; }
.quick-watch-row[aria-current], .quick-watch-row:enabled:hover { background: var(--hover); }
.quick-watch-row:focus-visible { outline-offset: -2px; }
.quick-watch-symbol { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 580; }
.quick-watch-price { text-align: right; white-space: nowrap; font: 12px var(--mono); }
.quick-watch-empty { padding: 0 12px; color: var(--muted); }

@media (max-width: 760px) {
  body > header {
    position: sticky;
    top: 0;
    z-index: 12;
    padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left));
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
  }
  body > header .brand img { display: block; width: 22px; height: 22px; }
  body > header .brand b { font-size: 15px; }
  body > header .header-actions { gap: 2px; }
  body > header .header-actions > button {
    min-width: 38px;
    min-height: 40px;
    padding: 0 6px;
    justify-content: center;
  }
  body > header .header-actions :is(.arrange-toggle,.ai-button) span { display: none; }
  body > header .header-actions .ai-button { background: transparent; border-color: transparent; }
  body > header .header-actions .ai-button::before { width: 17px; height: 17px; }
  #phonePanels { gap: 4px; }
  body > header #mainNav { scrollbar-width: none; }
  body > header #mainNav button { min-height: 38px; font-size: 12px; white-space: nowrap; }
  body > header #mainNav .mobile-only-tab { display: inline-flex; }
  body > header #mainNav .hidden-on-mobile { display: none; }
  body > header #mainNav #editMobileTabs {
    display: inline-flex;
    position: sticky;
    inset-inline-end: 0;
    flex: 0 0 38px;
    min-width: 38px;
    margin-inline-start: auto;
    color: var(--muted);
    background: var(--bg);
  }
  #editMobileTabs:before { display: none; }
  #editMobileTabs .icon svg, #openQuickWatch .icon svg { width: 16px; height: 16px; }
  #dialogBody .mobile-tab-picker .settingrow { min-height: 42px; }

  #chartWidget .controlbar:not(:has(.tab-order-editing)) {
    display: grid;
    grid-template-columns: 40px minmax(0,1fr) 54px auto 38px;
    gap: 4px;
    height: 46px;
    min-height: 46px;
    padding: 2px 6px;
  }
  #chartWidget .controlbar:not(:has(.tab-order-editing)) > :is(#openQuickWatch,#pickMarket,#intervals,[data-action='studies'],#chartOptions) {
    display: flex;
    align-items: center;
    min-width: 0;
    height: 40px;
    margin: 0;
    padding: 0 7px;
    gap: 6px;
    white-space: nowrap;
  }
  #chartWidget #openQuickWatch { display: inline-flex; justify-content: center; padding-inline: 0; color: var(--muted); }
  #chartWidget #pickMarket b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  #chartWidget .controlbar [data-action='studies'] span { display: inline; }
  #chartWidget .controlbar:not(:has(.tab-order-editing)) > :is([data-action='layout'],[data-action='colors'],[data-action='screenshot']) {
    display: none;
  }
  #chartWidget .controlbar:not(:has(.tab-order-editing)) > #chartOptions { justify-content: center; }
  #chartOptions[aria-expanded='true'] { background: var(--hover); color: var(--accent); }

  .chart-area > .phone-chart-reset {
    position: absolute;
    z-index: 3;
    isolation: isolate;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    transform: translate(calc(-100% - 2px), calc(-100% - 2px));
    border-radius: 8px;
    color: var(--chart-text);
  }
  .phone-chart-reset::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 5px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
  }
  .phone-chart-reset:active { color: var(--accent); }
  .phone-chart-reset:active::before { background: var(--hover); }
  .phone-chart-reset:focus-visible { outline-offset: -4px; }
  .phone-chart-reset .icon svg { width: 17px; height: 17px; }

  #tools {
    height: auto;
    min-height: 48px;
    padding: 2px 4px max(2px, env(safe-area-inset-bottom));
  }
  #tools button { width: 40px; min-width: 40px; height: 44px; min-height: 44px; }
  #tools button .icon,
  #tools button .icon svg,
  #tools button .icon::before { width: 22px; height: 22px; }
  #tools .rail-grip { width: 28px; min-width: 28px; }
  #tools .rail-actions { gap: 0; }
  #tools .rail-actions > button { width: 44px; min-width: 44px; }
  #tools .rail-actions > button:not(.rail-more, .rail-mobile-actions, .mc-mobile) { display: none; }
  #tools .rail-mobile-actions { display: inline-flex; }
  .chart-menu[aria-label='Drawing actions'] .chart-menu-item { min-height: 44px; }
  .lower-study-header { gap: 4px; max-width: calc(100% - 8px); font-size: 11px; }
  .lower-study-header button { width: 25px; height: 26px; }
  .lower-study-header .lower-study-values { gap: 4px; }
  #watchWidget,.sdock-tile { scroll-margin-top: 96px; }
  .chart-menu { max-height: calc(100dvh - 16px); overflow-y: auto; overscroll-behavior: contain; }
}

@media (max-width: 600px) {
  .lower-study-header:not(.mobile-open) { padding: 0; background: transparent; backdrop-filter: none; }
  .lower-study-header:not(.mobile-open) > :not(.lower-study-toggle,.lower-study-grip) { display: none; }
  .lower-study-header .lower-study-toggle, .chart-coverage-toggle:not([hidden]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 28px;
    border: 0;
    color: var(--chart-text);
    background: transparent;
  }
  .lower-study-toggle .icon { opacity: .55; }
  .lower-study-toggle[aria-expanded="true"] .icon { transform: rotate(90deg); opacity: 1; }
  .chart-coverage-toggle { position: absolute; left: 3px; bottom: 23px; z-index: 4; }
  .chart-coverage-toggle .icon { width: 13px; height: 13px; opacity: .65; }
  .chart-area > .chartnote:not(.error):not(.mobile-open) { display: none; }
  .chart-area > .chartnote.mobile-open:not(.error):not(:empty) { inset: auto auto 26px 34px; z-index: 5; }
}

@media (min-width: 640px) and (max-width: 760px) and (orientation: landscape) {
  body > header { grid-template-columns: auto minmax(0,1fr) auto; gap: 0 6px; }
  body > header #mainNav { grid-column: 2; grid-row: 1; min-width: 0; }
  body > header .header-actions { grid-column: 3; }
  #watchWidget,.sdock-tile { scroll-margin-top: 54px; }
}

@media (max-width: 760px) {
  body.phone-focus > .extraWidget { display: none; }
  body.phone-focus > header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    height: auto;
    padding: 0;
    border-bottom: 0;
  }
  body.phone-focus > header > :is(.brand, #mainNav, .header-actions),
  body.phone-focus:not(.news-open) #chartWidget .controlbar { display: none; }
  body.phone-focus:not(.news-open) #paneGrid.layout1 > .pane > .panehead {
    min-height: 32px; padding: 3px 5px 3px 9px; border: 0;
  }
  body.phone-focus #paneGrid.layout1 .panehead .instrument { display: none; }
  body.phone-focus #paneGrid.layout1 .panehead .quote {
    align-self: start;
    max-width: 40%;
    margin-inline-start: auto;
    font-size: 15px;
    line-height: 1.12;
    letter-spacing: -.25px;
  }
  body.phone-focus #paneGrid.layout1 .panehead .quote > span {
    display: block; white-space: nowrap;
  }
  body.phone-focus #paneGrid.layout1 .panehead .quote small {
    margin: 0;
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.phone-focus .phone-chart-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) repeat(5, clamp(36px, 10.75vw, 44px));
    align-items: center;
    gap: 3px;
    flex: none;
    min-height: 46px;
    padding: max(3px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) 3px max(6px, env(safe-area-inset-left));
    background: var(--panel);
    border-bottom: 1px solid var(--line);
  }
  .phone-chart-bar button {
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 44px;
    padding: 0;
    border-radius: 7px;
    color: var(--ink);
  }
  .phone-chart-bar button:is(:active, :focus-visible) { background: var(--hover); }
  body.news-open #phoneChartImage { visibility: hidden; }
  .phone-chart-bar .icon { width: 17px; height: 17px; }
  .phone-chart-bar #phoneMarket {
    justify-items: start;
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    padding-inline: 3px;
    text-align: start;
  }
  .phone-brand-mark {
    width: 17px;
    height: 17px;
    flex: none;
    object-fit: contain;
    margin-inline-end: 2px;
  }
  .phone-market-line {
    display: flex;
    align-items: center;
    gap: 3px;
    width: 100%;
    font-size: clamp(13px, 3.72vw, 14.5px);
    line-height: 1.15;
    letter-spacing: -0.015em;
  }
  .phone-market-line b, #phoneMarketVenue {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .phone-market-line > span { color: var(--muted); font-size: 12px; }
  #phoneMarketVenue {
    color: var(--muted);
    font-size: 10.5px;
    line-height: 1.15;
    padding-inline-start: 22px;
  }
  .phone-chart-bar #phoneInterval {
    color: var(--accent);
    background: var(--surface-raised);
    border: 1px solid var(--hairline);
    font-size: 12.5px;
    font-weight: 640;
  }
  #phoneChartMenu { grid-column: -2 / -1; }
  body.phone-focus .phone-tab-strip {
    display: flex;
    align-items: stretch;
    min-height: 39px;
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
  }
  #phoneWatchlist {
    flex: 0 0 40px;
    min-height: 38px;
    padding: 0;
    border-radius: 0;
    border-inline-end: 1px solid var(--line);
    color: var(--ink);
  }
  #phoneWatchlist svg { width: 17px; height: 17px; }
  #phoneWatchlist:is(:active,:focus-visible) { background: var(--hover); }
  #phoneWatchlist:focus-visible { outline-offset: -2px; }
  body.phone-focus #phoneChartTabs {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    gap: 0;
    height: auto;
    padding: 0;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    background: var(--panel);
    border: 0;
    border-radius: 0;
  }
  #phoneChartTabs button {
    flex: 1 0 auto;
    min-width: 42px;
    min-height: 38px;
    padding: 0 8px;
    border-radius: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 580;
    white-space: nowrap;
  }
  #phoneChartTabs button[aria-current='page'] {
    color: var(--ink);
    box-shadow: inset 0 -2px var(--accent);
  }
  #phoneChartTabs button:is(:active, :focus-visible) { background: var(--hover); }
  #phoneChartTabs button:focus-visible { outline-offset: -2px; }
  .phone-chart-actions { display: grid; gap: 8px; }
  .phone-chart-actions .workspace-setting-group {
    border: 1px solid var(--line);
    border-radius: 7px;
  }
  .phone-setting-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding-inline: 11px;
    cursor: pointer;
    list-style: none;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
  }
  .phone-setting-section::-webkit-details-marker { display: none; }
  .phone-setting-section:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .phone-setting-section .icon svg { width: 14px; height: 14px; }
  .phone-setting-section .icon { color: var(--muted); }
  .phone-chart-actions details[open] > .phone-setting-section {
    background: var(--hover);
    border-bottom: 1px solid var(--line);
  }
  .phone-chart-actions details[open] > .phone-setting-section .icon { transform: rotate(90deg); }
  .phone-chart-actions .workspace-setting { min-height: 44px; }
  .phone-chart-actions .workspace-setting:active { background: var(--hover); }
  .chart-menu[aria-label='Chart image'] .chart-menu-item { min-height: 44px; }
  .lower-study-header .lower-study-grip { min-width: 28px; height: 28px; color: var(--muted); }
  .lower-study-grip-edge {
    position: absolute;
    inset: 0 1px auto auto;
    display: grid;
    place-items: center;
    z-index: 5;
    width: 28px;
    height: 26px;
    padding: 0;
    color: var(--muted);
    touch-action: none;
    cursor: grab;
  }
  .lower-study-grip-edge .icon { width: 16px; height: 16px; }
  .lower-study-grip-edge:is(.dragging,:focus-visible) { color: var(--accent); background: var(--panel); }
  .lower-study-resize {
    position: absolute;
    inset: 0 auto auto 50%;
    z-index: 5;
    transform: translateX(-50%);
    display: grid;
    place-items: start center;
    width: 52px;
    height: 24px;
    padding: 4px 0 0;
    border-radius: 0 0 6px 6px;
    cursor: ns-resize;
    touch-action: none;
  }
  .lower-study-resize .icon { display: none; }
  .lower-study-resize::before {
    content: '';
    width: 20px;
    height: 3px;
    border-radius: 3px;
    background: var(--muted);
  }
  .lower-study-resize:is(:focus-visible,.resizing)::before { background: var(--accent); }
}

.touch-drawing svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Scrolling phone tab bar: fade the edge that has more tabs beyond it. */
#mainNav.fade-end, #phoneChartTabs.fade-end { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
#mainNav.fade-start, #phoneChartTabs.fade-start { -webkit-mask-image: linear-gradient(90deg, transparent, #000 28px); mask-image: linear-gradient(90deg, transparent, #000 28px); }
#mainNav.fade-start.fade-end, #phoneChartTabs.fade-start.fade-end { -webkit-mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent); }
