:root {
  --bg: #0f1216; --panel: #151a21; --panel2: #1b222b; --border: #262e3a;
  --text: #d5dbe5; --muted: #8592a3; --up: #2fbf71; --down: #f0524f; --accent: #4c8dff;
  /* the chart reads these too (see readTheme in app.js) */
  --line: var(--line); --hover: #26303d; --border2: #3a4656; --chip: rgba(21,26,33,.85); --overlay: rgba(15,18,22,.88);
  --grid: #1a2029; --axis: #8f9bab; --handle: #ffffff; --cost: #e6c34a; --tag: #b9c8ff;
  color-scheme: dark;
}
:root[data-theme=light] {
  --bg: #f5f6f8; --panel: #ffffff; --panel2: #edf0f4; --border: #d3d9e2;
  --text: #1a2230; --muted: #5f6b7c; --up: #0e8a55; --down: #d33a37; --accent: #2a66e0;
  --line: #e6eaf0; --hover: #e2e7ee; --border2: #aeb8c6; --chip: rgba(255,255,255,.92); --overlay: rgba(245,246,248,.9);
  --grid: #eceff3; --axis: #5f6b7c; --handle: #1a2230; --cost: #b98900; --tag: #2a66e0;
  color-scheme: light;
}
:root[data-theme=light] .badge.paper { color: var(--accent); }
:root[data-theme=light] .badge.live { color: var(--down); }
:root[data-theme=light] #results, :root[data-theme=light] #indMenu { box-shadow: 0 10px 30px rgba(20,30,50,.18); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: grid; grid-template-rows: 46px 1fr; overflow: hidden;
}
button, select, input { font: inherit; color: inherit; }
button, select {
  background: var(--panel2); border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; white-space: nowrap;
}
button:hover, select:hover { border-color: var(--border2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
input[type=number], input:not([type]) {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px;
}
input:focus, select:focus, button:focus-visible { outline: 1px solid var(--accent); outline-offset: 0; }
.up { color: var(--up); } .down { color: var(--down); } .muted { color: var(--muted); }

/* top bar */
#top { display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; letter-spacing: .2px; margin-right: 4px; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.brand img { display: block; border-radius: 5px; }
.brand span { color: var(--accent); }
.spacer { flex: 1; }
.seg { display: flex; }
.seg button { border-radius: 0; margin-left: -1px; padding: 5px 9px; }
.seg button:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: #fff; position: relative; }
.chk { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.search, .menu { position: relative; }
.search input { width: 230px; }
#results, #indMenu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; margin: 0; padding: 4px; list-style: none;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; min-width: 100%;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
#results { width: 380px; }
#results li, #indMenu li { padding: 6px 8px; border-radius: 5px; cursor: pointer; display: flex; gap: 8px; white-space: nowrap; }
#results li:hover, #results li.on, #indMenu li:hover { background: var(--hover); }
#results li b { min-width: 76px; }
#results li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; }
#results li .x { color: var(--muted); font-size: 11px; }
#indMenu { min-width: 230px; max-height: calc(100vh - 80px); overflow-y: auto; }
#indMenu li.head { cursor: default; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 8px 3px; }
#indMenu li.head:hover { background: none; }
#fly {
  position: absolute; left: 44px; z-index: 50; margin: 0; padding: 4px; list-style: none;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
:root[data-theme=light] #fly { box-shadow: 0 10px 30px rgba(20,30,50,.18); }
#fly li { padding: 6px 10px 6px 8px; border-radius: 5px; cursor: pointer; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#fly li:hover { background: var(--hover); }
#fly li.on { color: var(--accent); }

/* chart view */
main { min-height: 0; }
#chartView { display: grid; grid-template-columns: 44px 1fr 330px; }
#tools { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; }
#tools { position: relative; }
#tools button { position: relative; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; background: transparent; border-color: transparent; }
#tools button i { position: absolute; right: 2px; bottom: 2px; border: 3px solid transparent; border-right-color: currentColor; border-bottom-color: currentColor; opacity: .55; } /* marks a button that opens a list */
#tools button:hover { background: var(--panel2); }
#tools button.on { background: var(--accent); color: #fff; }
#tools svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#tools hr { width: 22px; border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
#stage { position: relative; min-width: 0; overflow: hidden; }
#chart, #draw { position: absolute; inset: 0; }
#draw { width: 100%; height: 100%; pointer-events: none; z-index: 3; }
#draw.active { pointer-events: auto; cursor: crosshair; }
#legend { position: absolute; top: 8px; left: 10px; right: 80px; z-index: 4; pointer-events: none; }
#legend .row1 { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
#lgSym { font-size: 15px; }
#lgName { color: var(--muted); }
#lgOhlc { font-variant-numeric: tabular-nums; }
#lgOhlc i { font-style: normal; color: var(--muted); margin-right: 2px; }
#lgOhlc span { margin-right: 8px; }
#chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 5px; padding: 1px 3px 1px 7px;
  background: var(--chip); border: 1px solid var(--border); border-radius: 5px; font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip input { width: 46px; padding: 0 3px; height: 20px; }
.chip button { border: 0; background: transparent; padding: 0 5px; color: var(--muted); }
.chip button:hover { color: var(--down); }
#hint { position: absolute; bottom: 36px; left: 50%; transform: translateX(-50%); z-index: 4; background: var(--panel2); border: 1px solid var(--border); padding: 5px 10px; border-radius: 6px; color: var(--muted); pointer-events: none; }
#msg { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: var(--overlay); color: var(--muted); font-size: 14px; padding: 20px; text-align: center; }

/* watchlist */
#watch { background: var(--panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.whead { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); font-weight: 600; }
.whead button { font-weight: 400; font-size: 12px; padding: 3px 8px; }
#wlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#wlist li { display: grid; grid-template-columns: 1fr auto auto 18px; gap: 8px; align-items: center; padding: 7px 4px 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-variant-numeric: tabular-nums; }
#wlist li:hover { background: var(--panel2); }
#wlist li.on { box-shadow: inset 2px 0 var(--accent); background: var(--panel2); }
#wlist .s { font-weight: 600; }
#wlist .nm { display: block; color: var(--muted); font-size: 11px; font-weight: 400; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#wlist .c { min-width: 54px; text-align: right; }
#wlist .rm { visibility: hidden; border: 0; background: transparent; padding: 0; color: var(--muted); }
#wlist li:hover .rm { visibility: visible; }
#wlist .rm:hover { color: var(--down); }

#wlist li.sec { grid-template-columns: 1fr 18px 18px 18px; gap: 4px; padding: 5px 4px 5px 10px; background: var(--bg); color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; }
#wlist li.sec:hover { color: var(--text); }
#wlist li.sec input { grid-column: 1 / -1; width: 100%; padding: 2px 6px; }
#wlist li.dropB { box-shadow: inset 0 2px var(--accent); }
#wlist li.dropA { box-shadow: inset 0 -2px var(--accent); }
.whead { flex-wrap: wrap; gap: 6px; }
.whead button { padding: 3px 6px; }
#watch { min-width: 0; overflow: hidden; }
#wlist li { grid-template-columns: minmax(0, 1fr) auto auto auto 18px; gap: 6px; }
#wlist .c { min-width: 48px; }
#wlist .nm { max-width: 100%; }
.search { flex: 0 1 230px; min-width: 110px; }
.search input { width: 100%; }

#wlist .p, #wlist .c { text-align: right; }
#wlist .x { display: block; font-size: 11px; color: var(--muted); }
#wlist .x.up { color: var(--up); } #wlist .x.down { color: var(--down); }
#lgSrc, #webNote { text-decoration: none; white-space: nowrap; }
#lgSrc, #webNote, #lgOhlc .tag {background: rgba(120,150,255,.18); color: var(--tag); border-radius: 4px; padding: 0 6px; font-size: 11px; }

/* keep a crowded top bar from pushing the page wider than the window */
body { grid-template-columns: minmax(0, 1fr); }
#top { gap: 8px; padding: 0 10px; min-width: 0; }
.brand { margin-right: 0; }
.seg button { padding: 5px 7px; }
.search { min-width: 70px; }
@media (max-width: 1150px) { .brand { display: none; } }

#msg div { max-width: 520px; } #msg a { color: var(--accent); }
#theme { padding: 5px 9px; }
#refresh { padding: 5px 9px; }
#refresh.busy { opacity: .5; cursor: wait; }
#updated { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
#updated.err { color: var(--down); }
#ver { margin-top: auto; font-size: 10px; color: var(--muted); text-decoration: none; }
#ver:hover { color: var(--tag); text-decoration: underline; }
#ver.new { color: var(--accent); font-weight: 600; white-space: nowrap; }

/* side panel tabs + IBKR positions */
#sideTabs { padding: 8px 10px 0; }
#sideTabs button { flex: 1; }
#ibDot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--up); margin-left: 6px; vertical-align: middle; }
#sideWatch { display: flex; flex-direction: column; flex: 1; min-height: 0; }
#sidePos, #sidePaper { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; font-variant-numeric: tabular-nums; }
#sidePos h4, #sidePaper h4 { margin: 14px 0 4px; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
#sidePos p, #sidePaper p, #sidePos ol, #sidePaper ol { margin: 0 0 8px; color: var(--muted); }
#sidePos ol, #sidePaper ol { padding-left: 18px; } #sidePos li, #sidePaper li { margin-bottom: 4px; }
#sidePos code, #sidePaper code { color: var(--text); font-size: 12px; }
#sidePos a, #sidePaper a { color: var(--accent); }
.ibhead { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.badge { font-size: 10px; font-weight: 700; letter-spacing: .5px; padding: 1px 6px; border-radius: 4px; }
.badge.paper { background: rgba(76,141,255,.2); color: #9cc0ff; }
.badge.live { background: rgba(240,82,79,.2); color: #ff9a98; }
.badge.ro { background: var(--panel2); color: var(--muted); font-weight: 500; }
.ibsum { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; margin-top: 10px; }
.ibsum span:nth-child(odd) { color: var(--muted); }
.ibrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 7px 6px; border-bottom: 1px solid var(--line); border-radius: 4px; }
.ibrow.link { cursor: pointer; } .ibrow.link:hover { background: var(--panel2); }
.ibrow.on { box-shadow: inset 2px 0 var(--accent); background: var(--panel2); }
.ibrow b { font-weight: 600; } .ibrow .r { text-align: right; }
.ibrow small { display: block; color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ibrow small.up { color: var(--up); } .ibrow small.down { color: var(--down); }

/* import dialog */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 18px; width: min(480px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin: 0 0 6px; }
dialog p { margin: 0 0 10px; }
dialog code { color: var(--text); }
dialog textarea { width: 100%; margin: 10px 0; background: var(--bg); color: inherit; border: 1px solid var(--border); border-radius: 6px; padding: 8px; font: 12px/1.4 ui-monospace, Consolas, monospace; resize: vertical; }
#impInfo { min-height: 18px; margin-top: 8px; }
.dlgBtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* screener */
#screenView { display: flex; flex-direction: column; }
#screenView[hidden], #chartView[hidden] { display: none; }
.sbar, .filters { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--panel); }
.sbar label, .filters label { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.filters input[type=number] { width: 68px; }
#uniCustom { flex: 1; min-width: 240px; }
#scanInfo { color: var(--muted); }
.tablewrap { flex: 1; overflow: auto; min-height: 0; }
#grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
#grid th, #grid td { padding: 7px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
#grid th { position: sticky; top: 0; background: var(--panel); color: var(--muted); font-weight: 500; cursor: pointer; user-select: none; z-index: 1; }
#grid th:hover { color: var(--text); }
#grid th.l, #grid td.l { text-align: left; }
#grid tbody tr { cursor: pointer; }
#grid tbody tr:hover { background: var(--panel); }
#grid td.nm { color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
#grid td button { padding: 1px 8px; font-size: 12px; }
#gridEmpty { padding: 40px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  #chartView { grid-template-columns: 44px 1fr; }
  #watch { display: none; }
  .search input { width: 150px; }
  #top { overflow-x: auto; }
}

/* practice account (paper trading) */
.ibhead .grow { flex: 1; }
.ibhead button, .ibrow .mini { padding: 2px 8px; font-size: 11px; font-weight: 500; }
.ibrow .mini { margin-top: 3px; }
.ticket { border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: grid; gap: 8px; }
.ticket .trow { display: flex; gap: 6px; align-items: center; }
.ticket .trow:first-child { justify-content: space-between; }
.ticket label { display: flex; align-items: center; gap: 8px; color: var(--muted); flex: 1; min-width: 0; white-space: nowrap; }
.ticket input { flex: 1; width: 100%; min-width: 0; }
.ticket input[hidden] { display: none; }
.ticket select { flex: 1; min-width: 0; }
.ticket .buy, .ticket .sell { flex: 1; color: #fff; font-weight: 600; border-color: transparent; }
.ticket .buy { background: var(--up); } .ticket .sell { background: var(--down); }
.ticket .buy:hover, .ticket .sell:hover { filter: brightness(1.1); }
#sidePaper .pnote { margin: 0; color: var(--text); font-size: 12px; }
#sidePaper .pfoot { margin-top: 14px; font-size: 11px; }

/* multi-chart layout: the main chart plus up to three more, each a copy of the app in a frame (html.embed) */
#multi { display: grid; min-width: 0; min-height: 0; gap: 2px; background: var(--border); }
#multi > * { min-width: 0; min-height: 0; position: relative; background: var(--bg); }
#multi[data-layout="2h"], #multi[data-layout="4"] { grid-template-columns: 1fr 1fr; }
#multi[data-layout="2v"], #multi[data-layout="4"] { grid-template-rows: 1fr 1fr; }
#multi iframe { border: 0; width: 100%; height: 100%; display: block; }
#multi:not([data-layout="1"]) > .active::after { content: ''; position: absolute; inset: 0; border: 2px solid var(--accent); pointer-events: none; z-index: 20; }
html.embed body { grid-template-rows: auto 1fr; }
html.embed #top { flex-wrap: wrap; gap: 5px; padding: 4px 6px; }
html.embed .brand, html.embed #refresh, html.embed #updated, html.embed .spacer, html.embed #webNote, html.embed #lang, html.embed #theme,
html.embed #views, html.embed #watch, html.embed #layout, html.embed #top label.chk, html.embed #ver { display: none !important; }
html.embed #chartView { grid-template-columns: 44px 1fr; }
html.embed .search { flex: 0 1 130px; }
html.embed .seg button { padding: 5px 6px; }

/* symbol search inside a side tab */
.psearch { position: relative; }
.psearch input { width: 100%; }
.hits { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50; margin: 0; padding: 4px; list-style: none; background: var(--panel2);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-height: 260px; overflow-y: auto; }
:root[data-theme=light] .hits, :root[data-theme=light] #ctx, :root[data-theme=light] .toast { box-shadow: 0 10px 30px rgba(20,30,50,.18); }
.hits li { padding: 6px 8px; border-radius: 5px; cursor: pointer; display: flex; gap: 8px; white-space: nowrap; margin: 0; }
.hits li:hover, .hits li.on { background: var(--hover); }
.hits li b { min-width: 64px; color: var(--text); }
.hits li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.ticket .trow.head { justify-content: space-between; }

/* price alerts */
#sideAlerts { flex: 1; min-height: 0; overflow-y: auto; padding: 10px; font-variant-numeric: tabular-nums; }
#sideAlerts h4 { margin: 14px 0 4px; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
#sideAlerts p { margin: 0 0 8px; color: var(--muted); }
#sideAlerts .pnote { margin: 0; color: var(--text); font-size: 12px; }
#sideAlerts .pfoot { margin-top: 14px; font-size: 11px; }
#sideAlerts h4 button { float: right; text-transform: none; letter-spacing: 0; }
.ibrow .mini { margin-left: 6px; }
#ctx { position: fixed; z-index: 100; margin: 0; padding: 4px; list-style: none; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
#ctx li { padding: 6px 12px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
#ctx li:hover { background: var(--hover); }
#ctx li.head { cursor: default; color: var(--muted); font-size: 11px; padding: 4px 12px; }
#ctx li.head:hover { background: none; }
#ctx li.danger:hover { color: var(--down); }
/* watchlist: the "+ Add" box, the section "+" button, and the highlight on a symbol just added or moved */
#wAdd { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--panel2); }
#wAdd .wrow { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
#wAdd .wrow select { flex: 1; min-width: 0; }
#wAdd > button { align-self: flex-start; font-size: 12px; padding: 3px 8px; }
#wAdd .wnote { margin: 0; font-size: 11px; color: var(--muted); }
#wlist .rm.add:hover { color: var(--accent); }
@keyframes wflash { from { background: rgba(76,141,255,.35); } to { background: transparent; } }
#wlist li.flash { animation: wflash 1.6s ease-out; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.toast { background: var(--panel2); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.5); cursor: pointer; }
.toast b { display: block; margin-bottom: 2px; }

/* Compare: search box under the button */
#cmpBox { position: absolute; top: calc(100% + 4px); left: 0; z-index: 50; width: 280px; padding: 6px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
:root[data-theme=light] #cmpBox { box-shadow: 0 10px 30px rgba(20,30,50,.18); }
#stage.grab, #stage.grab * { cursor: grabbing !important; }

/* touch: drawing on the chart must not scroll the page; a long press must not select text or open the iOS callout */
#draw.active { touch-action: none; }
#stage, #wlist, #phoneNav { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
@media (hover: none) { #wlist .rm { visibility: visible; opacity: .55; } }

/* ---------------------------------------------------------------- phones (html.phone is set in app.js)
   One thing at a time: chart, a side tab or the screener, picked in the tab bar at the bottom (#phoneNav).
   The top bar keeps search, refresh and timeframes; the other controls open with "⋯" (#top.more).
   env(safe-area-inset-*) keeps clear of the iPhone's notch / Dynamic Island and home indicator. */
html.phone, html.phone body { height: 100%; height: 100dvh; }
html.phone body { grid-template-rows: auto minmax(0, 1fr) auto; font-size: 14px; }
html.phone input, html.phone select, html.phone textarea { font-size: 16px; } /* below 16px iOS zooms the page when a box gets focus */
html.phone #top { position: relative; flex-wrap: wrap; gap: 6px; overflow: visible; min-height: 0;
  padding: calc(6px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) 6px calc(8px + env(safe-area-inset-left)); }
html.phone #top > * { display: none; order: 9; }
html.phone #top > .search { display: block; order: 1; flex: 1 1 auto; min-width: 0; }
html.phone #top > #refresh, html.phone #top > #more { display: block; order: 2; min-width: 40px; min-height: 38px; font-size: 17px; padding: 0 10px; }
html.phone #top > #more { order: 3; }
html.phone #top > #tfs { display: flex; order: 4; flex: 1 0 100%; }
html.phone #tfs button { flex: 1; min-height: 34px; padding: 4px 0; }
html.phone .search input { min-height: 38px; }
html.phone #top.more > #type, html.phone #top.more > .menu, html.phone #top.more > #scale, html.phone #top.more > #lang,
html.phone #top.more > #theme, html.phone #top.more > #webNote { display: block; }
html.phone #top.more > :is(#type, .menu, #scale, #lang, #theme, #webNote) { order: 5; }
html.phone #top.more > :is(#type, #scale, #lang) { flex: 1 1 40%; min-width: 0; min-height: 38px; }
html.phone #top.more .menu > button, html.phone #top.more > #theme { min-height: 38px; }
html.phone #top.more > #webNote { align-self: center; padding: 3px 8px; }
html.phone .menu { position: static; } /* so the indicator list and compare box span the screen */
html.phone #indMenu, html.phone #cmpBox, html.phone #results { left: 8px; right: 8px; width: auto; min-width: 0; max-height: 60vh; overflow-y: auto; }
html.phone .search { position: static; }
html.phone #results li { padding: 9px 8px; }
html.phone #indMenu li { padding: 9px 8px; }
#more { padding: 5px 9px; }

html.phone #chartView, html.phone #screenView { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
html.phone #chartView { grid-template-columns: 40px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
html.phone #tools { min-height: 0; overflow-y: auto; overflow-x: hidden; scrollbar-width: none; } /* a short (landscape) screen scrolls the toolbar */
html.phone #tools button { width: 34px; height: 34px; flex: 0 0 auto; }
html.phone #fly { left: 40px; }
html.phone #fly li { padding: 9px 12px 9px 10px; }
html.phone #legend { left: 8px; right: 64px; top: 6px; }
html.phone #lgName { display: none; }
html.phone #lgOhlc { font-size: 12px; }
html.phone .chip { font-size: 11px; }
html.phone .chip input { font-size: 16px; width: 44px; height: 22px; transform: scale(.75); transform-origin: left center; margin-right: -11px; }
/* a side tab fills the screen instead of the chart */
html.phone[data-pv="watch"] #chartView, html.phone[data-pv="pos"] #chartView,
html.phone[data-pv="paper"] #chartView, html.phone[data-pv="alerts"] #chartView { grid-template-columns: minmax(0, 1fr); }
html.phone[data-pv="watch"] :is(#tools, #multi), html.phone[data-pv="pos"] :is(#tools, #multi),
html.phone[data-pv="paper"] :is(#tools, #multi), html.phone[data-pv="alerts"] :is(#tools, #multi) { display: none; }
html.phone #watch { display: none; border-left: 0; }
html.phone:not([data-pv="chart"]) #watch { display: flex; }
html.phone #sideTabs { display: none !important; }
html.phone .whead { padding: 10px 12px; }
html.phone .whead button { min-height: 34px; padding: 4px 10px; font-size: 14px; }
html.phone #wlist li { grid-template-columns: minmax(0, 1fr) auto auto auto 30px; padding: 10px 4px 10px 12px; }
html.phone #wlist li.sec { grid-template-columns: 1fr 30px 30px 30px; padding: 8px 4px 8px 12px; font-size: 12px; }
html.phone #wlist .rm { font-size: 15px; min-height: 28px; }
html.phone #wAdd > button, html.phone .ticket button, html.phone .ibhead button { min-height: 36px; }
html.phone #sideAlerts, html.phone #sidePaper, html.phone #sidePos { padding: 12px; }
html.phone .ibrow { padding: 10px 6px; }
html.phone .ibrow .mini { min-height: 30px; min-width: 30px; }

/* bottom tab bar */
#phoneNav { display: flex; background: var(--panel); border-top: 1px solid var(--border);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#phoneNav button { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 5px;
  border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: 10.5px; }
#phoneNav button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
#phoneNav svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#phoneNav button.on { color: var(--accent); }

/* screener on a phone: tighter bars; the table scrolls sideways */
html.phone .sbar, html.phone .filters { padding: 8px 10px; gap: 6px 10px; }
html.phone .filters input[type=number] { width: 64px; }
html.phone #uniCustom { min-width: 0; flex-basis: 100%; }
html.phone .sbar button { min-height: 36px; }
#fToggle { display: none; }
html.phone #fToggle { display: block; }
html.phone #screenView:not(.showF) .filters { display: none; }
html.phone #grid th, html.phone #grid td { padding: 8px; }

/* menus and messages */
html.phone #ctx li { padding: 11px 14px; }
html.phone #toasts { left: 8px; right: 8px; max-width: none; bottom: calc(64px + env(safe-area-inset-bottom)); }
html.phone #hint { bottom: 12px; max-width: calc(100% - 20px); white-space: normal; text-align: center; }
html.phone dialog { width: calc(100vw - 24px); }
/* landscape phone: little height, so a one-row top bar and a slimmer tab bar */
@media (orientation: landscape) {
  html.phone #top > #tfs { flex: 0 1 auto; order: 2; }
  html.phone #tfs button { padding: 4px 8px; }
  html.phone #phoneNav button { flex-direction: row; justify-content: center; gap: 6px; padding: 5px 0; min-height: 40px; font-size: 12px; }
  html.phone #phoneNav svg { width: 18px; height: 18px; }
  html.phone #toasts { bottom: calc(44px + env(safe-area-inset-bottom)); }
}

/* practice account: equity curve and statistics */
.eqcurve { display: block; width: 100%; height: 84px; margin: 4px 0 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.bysym { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; margin-top: 6px; }
