/* Chart section of the one-page app (TG-UX-002, new look TG-UI-003). Every rule is scoped under #chartsec so it cannot touch the other sections (style.css).
   Colours and sizes are the tokens of style.css. Safe-area variables --sa-* come from safe.js on <html>. Wide layout (nav on the left, panel on the right) starts at 1100 px.
   Bottom of the chart: a tall time axis (--axis-h, chartview.js gives the same number to the library) and under it the navigator (#navi): the whole history with a window to drag. */
#chartsec { --axis-h: 42px; --navi-h: 52px; --ctl: 40px; }
#chartsec, #chartsec * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
#chartsec [hidden] { display: none !important; }
#chartsec { position: fixed; top: 0; right: 0; bottom: 0; left: var(--navw, 0px); z-index: 4; display: flex; background: var(--bg); color: var(--text); font: var(--fs-m)/1.4 var(--sans); overscroll-behavior: none; overflow: hidden;
  padding: max(env(safe-area-inset-top), var(--sa-t)) max(env(safe-area-inset-right), var(--sa-r)) max(env(safe-area-inset-bottom), var(--sa-b)) max(env(safe-area-inset-left), var(--sa-l)); }
#chartsec #cmain { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
#chartsec #bar { flex: none; display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--stroke); position: relative; z-index: 6; background: var(--surface); }
#chartsec .grow { flex: 1 1 auto; }
#chartsec .cseg { display: flex; background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--r-s); padding: 2px; }
#chartsec .cseg button { font: 600 var(--fs-s) var(--sans); color: var(--text-2); background: none; border: 0; border-radius: 8px; padding: 0 9px; height: calc(var(--ctl) - 6px); min-width: 34px; cursor: pointer; transition: background var(--dur), color var(--dur); }
#chartsec .cseg button:hover { color: var(--text); }
#chartsec .cseg button:disabled { opacity: .4; cursor: default; }
#chartsec .cseg button.on { background: var(--accent); color: var(--accent-ink); }
#chartsec .ib { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--ctl); min-width: var(--ctl); padding: 0 8px; border: 1px solid var(--stroke); background: var(--surface-2); color: var(--text); border-radius: var(--r-s); font: 600 var(--fs-s) var(--sans); cursor: pointer; transition: border-color var(--dur), background var(--dur); }
#chartsec .ib:hover { border-color: var(--stroke-2); }
#chartsec .ib svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#chartsec .ib .lbl { display: none; }
#chartsec .ib[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#chartsec #cnt { font: 700 10px var(--mono); background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 1px 4px; position: absolute; top: -4px; right: -4px; }
#chartsec #cnt:empty { display: none; }
#chartsec #fwrap { position: relative; }
#chartsec #filters { display: none; position: absolute; right: 0; top: 46px; background: var(--surface); border: 1px solid var(--stroke-2); border-radius: var(--r-m); padding: 8px; gap: 6px; flex-direction: column; box-shadow: var(--shadow-pop); min-width: 220px; }
#chartsec #filters.open { display: flex; }
#chartsec .cchip { display: inline-flex; align-items: center; gap: 6px; font: 600 var(--fs-s) var(--sans); color: var(--text); background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--r-full); padding: 0 12px; min-height: var(--ctl); cursor: pointer; white-space: nowrap; transition: opacity var(--dur); }
#chartsec .cchip[aria-pressed="false"] { color: var(--text-2); background: none; }
#chartsec .cchip[aria-pressed="false"] .d { opacity: .4; }
#chartsec .d { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
#chartsec .d.a { background: var(--up); }
#chartsec .d.b { background: var(--down); }
#chartsec .d.r { background: var(--real); }
#chartsec .d.s { background: var(--text-3); }
#chartsec #stage { position: relative; flex: 1 1 auto; min-height: 0; background: var(--surface); }
#chartsec #chart { position: absolute; inset: 0; touch-action: none; z-index: 1; }
/* a lit band under the time axis: shows that the bottom strip can be grabbed. The canvas above it is see-through */
#chartsec #axisband { position: absolute; left: 0; right: var(--price-w, 60px); bottom: 0; height: var(--axis-h); background: var(--surface-2); border-top: 1px solid var(--stroke); pointer-events: none; transition: background var(--dur); }
#chartsec #stage.on-axis #axisband { background: var(--surface-3); }
#chartsec #stage.on-axis #chart { cursor: ew-resize; }
#chartsec #ohlc { position: absolute; z-index: 2; top: 8px; left: 12px; right: 76px; display: flex; flex-wrap: wrap; gap: 0 10px; font: 500 var(--fs-xs)/1.5 var(--mono); letter-spacing: -.02em; color: var(--text-2); pointer-events: none; }
#chartsec #ohlc b { color: var(--text); font-weight: 600; }
#chartsec #ohlc .q { display: none; }
#chartsec #flag { position: absolute; z-index: 2; top: 30px; left: 12px; background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 1px 7px; font: 700 11px/1.5 var(--sans); pointer-events: none; white-space: nowrap; }
#chartsec #flag.quiet { background: var(--surface-3); color: var(--text-2); font-weight: 600; }
#chartsec #msg { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 16px; color: var(--text-2); pointer-events: none; }
#chartsec #msg:empty { display: none; }
#chartsec #attr { flex: none; padding: 8px 12px 6px; font-size: 11px; line-height: 1.4; color: var(--text-2); border-top: 1px solid var(--stroke); }
#chartsec #attr a { color: inherit; text-decoration: underline; }
#chartsec #sheet { position: absolute; z-index: 5; left: 6px; right: 6px; bottom: 6px; max-height: 62%; overflow-y: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-m); box-shadow: var(--shadow-pop); animation: chartsheet .24s var(--ease) both; }
@keyframes chartsheet { from { opacity: 0; transform: translateY(10px); } }
#chartsec .ctr { background: var(--surface); border: 1px solid var(--stroke-2); border-left: 4px solid var(--up); border-radius: var(--r-m); padding: 12px 14px; }
#chartsec .ctr.sell { border-left-color: var(--down); }
#chartsec .ctr.real { border-left-color: var(--real); }
#chartsec .ctr .top { display: flex; align-items: flex-start; gap: 8px; }
#chartsec .ctr h3 { margin: 0; font-size: var(--fs-m); font-weight: 650; flex: 1; }
#chartsec .ctr .src { font-size: 11px; font-weight: 700; color: var(--warn); background: var(--warn-soft); border-radius: 6px; padding: 1px 7px; display: inline-block; margin: 4px 0; }
#chartsec .ctr.real .src { color: var(--real); background: var(--accent-soft); }
#chartsec .ctr dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 6px 0 8px; font-size: var(--fs-s); }
#chartsec .ctr dt { color: var(--text-2); }
#chartsec .ctr dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
#chartsec .ctr p { margin: 0 0 10px; font-size: 14px; }
#chartsec .ctr .nav { display: flex; gap: 8px; }
#chartsec .ctr .nav button { flex: 1; height: 42px; border: 1px solid var(--stroke); background: var(--surface-2); color: var(--text); border-radius: var(--r-s); font: 600 var(--fs-s) var(--sans); cursor: pointer; }
#chartsec .ctr .nav button:hover:not(:disabled) { border-color: var(--stroke-2); }
#chartsec .ctr .nav button:disabled { opacity: .45; cursor: default; }
#chartsec .cx { border: 0; background: none; color: var(--text-2); font-size: 18px; min-width: 40px; height: 40px; margin: -6px -6px 0 0; cursor: pointer; }
#chartsec #side { position: fixed; z-index: 20; inset: 0; background: var(--surface); display: flex; flex-direction: column; padding: max(env(safe-area-inset-top), var(--sa-t)) max(env(safe-area-inset-right), var(--sa-r)) max(env(safe-area-inset-bottom), var(--sa-b)) max(env(safe-area-inset-left), var(--sa-l)); }
#chartsec .sidehead { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; border-bottom: 1px solid var(--stroke); }
#chartsec #sideCard { flex: none; padding: 8px; }
#chartsec #sideCard:empty { display: none; }
#chartsec #list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; -webkit-overflow-scrolling: touch; }
#chartsec #list li button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--stroke); background: none; color: var(--text); padding: 10px 12px; min-height: 46px; font: var(--fs-s) var(--sans); cursor: pointer; }
#chartsec #list li button:hover { background: var(--surface-2); }
#chartsec #list li button.sel { background: var(--accent-soft); }
#chartsec #list .when { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-2); flex: none; }
#chartsec #list .what { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#chartsec #list .px { font-family: var(--mono); font-size: var(--fs-xs); flex: none; }
#chartsec #list .empty { padding: 16px; color: var(--text-2); }
#chartsec .coinbtn { padding: 0 8px 0 10px; gap: 2px; }
#chartsec .coinbtn b { font-size: var(--fs-m); font-weight: 700; }
#chartsec .tabs2 { display: flex; gap: 4px; }
#chartsec .tabs2 button { height: 40px; padding: 0 14px; border: 0; border-radius: var(--r-s); background: none; color: var(--text-2); font: 650 14px var(--sans); cursor: pointer; }
#chartsec .tabs2 button[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }
#chartsec .pane { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#chartsec .pane[hidden] { display: none; }
#chartsec .search { flex: none; padding: 8px 12px; }
#chartsec .search input { width: 100%; height: 44px; border: 1px solid var(--stroke); border-radius: var(--r-m); background: var(--surface-2); color: var(--text); font: 16px var(--sans); padding: 0 12px; }
#chartsec .search input::placeholder { color: var(--text-3); }
#chartsec .search input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
#chartsec #coinlist { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; }
#chartsec #coinlist h4 { margin: 0; padding: 12px 14px 5px; font: 650 var(--fs-xs) var(--sans); color: var(--text-2); position: sticky; top: 0; background: var(--surface); z-index: 1; }
#chartsec #coinlist ul { list-style: none; margin: 0; padding: 0; }
#chartsec #coinlist li { display: flex; align-items: stretch; border-bottom: 1px solid var(--stroke); }
#chartsec #coinlist li:hover { background: var(--surface-2); }
#chartsec #coinlist li.hi { background: var(--accent-soft); }
#chartsec #coinlist li.cur .nm { color: var(--accent); }
#chartsec .crow { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: none; color: var(--text); padding: 8px 4px 8px 14px; min-height: 50px; font: 14px var(--sans); cursor: pointer; }
#chartsec .crow .cmain { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
#chartsec .crow .nm { font-weight: 700; font-size: var(--fs-m); }
#chartsec .crow .meta { font-size: var(--fs-xs); color: var(--text-2); font-variant-numeric: tabular-nums; }
#chartsec .crow .meta .up, #chartsec .sparkline.up { color: var(--up); }
#chartsec .crow .meta .down, #chartsec .sparkline.down { color: var(--down); }
#chartsec .crow .spark { flex: none; width: 72px; height: 24px; }
#chartsec .star { flex: none; width: 46px; border: 0; background: none; color: var(--text-2); font-size: 19px; cursor: pointer; }
#chartsec .star[aria-pressed="true"] { color: var(--s4); }
#chartsec .cempty { padding: 18px 14px; color: var(--text-2); }
#chartsec #btnRotate[hidden],
#chartsec #rotmsg:empty { display: none; }
#chartsec #rotmsg { font-size: var(--fs-xs); color: var(--text-2); max-width: 210px; }
#chartsec .auto { position: absolute; z-index: 3; right: 8px; bottom: calc(var(--axis-h) + 8px); margin-right: var(--price-w, 60px); height: 30px; padding: 0 11px; border: 1px solid var(--stroke-2); border-radius: var(--r-full); background: var(--glass); color: var(--text-2); font: 650 var(--fs-xs) var(--sans); cursor: pointer; transition: background var(--dur), color var(--dur); }
#chartsec .auto:hover { color: var(--text); }
#chartsec .auto[aria-pressed="false"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* navigator: the whole history; drag the window, its edges change the scale */
#chartsec #navi { flex: none; display: flex; align-items: stretch; gap: 8px; padding: 8px; background: var(--surface); border-top: 1px solid var(--stroke); }
#chartsec #ranges { display: none; flex: none; align-items: center; }
#chartsec #navibox { position: relative; flex: 1 1 auto; min-width: 0; height: var(--navi-h); background: var(--surface-2); border: 1px solid var(--stroke); border-radius: var(--r-s); overflow: hidden; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
#chartsec #navicv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#chartsec .nshade { position: absolute; top: 0; bottom: 0; background: var(--bg); opacity: .62; pointer-events: none; }
#chartsec #navishadeL { left: 0; } #chartsec #navishadeR { right: 0; }
#chartsec #naviwin { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; border: 1.5px solid var(--accent); border-radius: 8px; background: var(--accent-soft); cursor: grab; touch-action: none; }
#chartsec #naviwin:active { cursor: grabbing; }
#chartsec #naviwin:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
#chartsec .nh { position: absolute; top: 50%; width: 5px; height: 22px; margin-top: -11px; border-radius: 3px; background: var(--accent); cursor: ew-resize; display: block; }   /* only drawn here: what a press means is decided by its position (Navi) */
#chartsec .nh.l { left: 2px; } #chartsec .nh.r { right: 2px; }
#chartsec #btnFit { flex: none; align-self: center; }
@media (pointer: coarse) {
  #chartsec { --ctl: 42px; }
}
@media (min-width: 700px) and (min-height: 521px) {
#chartsec .ib .lbl { display: inline; }
#chartsec #filters { position: static; display: flex; flex-direction: row; border: 0; box-shadow: none; padding: 0; min-width: 0; background: none; }
#chartsec #btnFilt { display: none; }
#chartsec #ranges { display: flex; }
#chartsec #ohlc .q { display: inline; }
}
@media (min-width: 1100px) and (min-height: 521px) {
#chartsec { --axis-h: 46px; --navi-h: 58px; --ctl: 38px; }
#chartsec #side { position: static; flex: none; width: 360px; border-left: 1px solid var(--stroke); padding: 0; display: flex; }
#chartsec #side[hidden] { display: none; }
#chartsec #sheet { left: 12px; right: auto; bottom: calc(var(--axis-h) + 8px); width: 420px; }
#chartsec #bar { padding: 8px 12px; gap: 8px; }
#chartsec .coinbtn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); border-color: var(--stroke); }   /* the list is a permanent column here: nothing to light up */
#chartsec #navi { padding: 10px 12px; gap: 10px; }
}
@media (min-width: 2300px) and (min-height: 521px) {
#chartsec { --axis-h: 50px; --navi-h: 68px; }
#chartsec #side { width: 420px; }
}
@media (max-height: 520px) {
#chartsec #sheet { max-height: 80%; }
}
/* phone: the axis stays easy to hit; the card sits above it */
@media (max-width: 699px) { #chartsec #sheet { bottom: calc(var(--axis-h) + 4px); max-height: calc(100% - var(--axis-h) - 12px); } }
@media (max-height: 520px) and (orientation: landscape) {
#chartsec { --axis-h: 30px; --navi-h: 30px; --ctl: 34px; }
#chartsec #bar { padding: 3px 8px; gap: 4px; }
#chartsec .cseg button { padding: 0 8px; min-width: 32px; }
#chartsec #filters { top: 40px; }
#chartsec #ohlc { top: 4px; }
#chartsec #flag { top: 24px; font-size: 10px; }
#chartsec #navi { padding: 3px 8px; }
#chartsec #btnFit { height: 30px; min-width: 30px; padding: 0 4px; }
#chartsec #sheet { left: auto; top: 6px; bottom: 6px; right: 6px; width: min(340px, 46%); max-height: none; }
#chartsec #side { inset: 0 0 0 auto; width: min(380px, 55vw); border-left: 1px solid var(--stroke); box-shadow: var(--shadow-pop); }
#chartsec .ctr dl { margin: 2px 0 4px; font-size: var(--fs-xs); }
#chartsec .ctr p { font-size: var(--fs-s); }
#chartsec .ctr .nav button { height: 38px; }
#chartsec .auto { height: 26px; bottom: calc(var(--axis-h) + 4px); }
}
html.bar-hidden #chartsec #bar { display: none; }
html.tgrow #chartsec { padding-top: max(env(safe-area-inset-top), var(--sa-s)); }
html.tgrow #chartsec #bar { min-height: max(var(--sa-c), 40px); padding-left: 112px; padding-right: 108px; border-bottom: 0; }
html.tgrow.bar-hidden #chartsec { padding-top: max(env(safe-area-inset-top), var(--sa-t)); }
@media (max-width: 400px) {
#chartsec .cseg button { padding: 0 6px; min-width: 30px; }
#chartsec #bar { gap: 4px; padding: 6px 6px; }
#chartsec .ib { min-width: 36px; padding: 0 6px; }
}

/* whose marks are on the chart: a separate account says so above the candles; P1 keeps the old look */
#chartsec #acctbar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; padding: 4px 10px; border-bottom: 1px solid var(--stroke); background: var(--surface-2, var(--surface)); font-size: var(--fs-xs); line-height: 1.4; }
#chartsec #acctbar[hidden] { display: none; }
#chartsec #acctbar .who { min-width: 0; }
#chartsec #acctbar .cw { color: var(--down); font-weight: 700; white-space: nowrap; }
#chartsec #acctbar .cl { color: var(--warn); font-weight: 700; }
#chartsec #acctbar #btnAcctInfo { margin-left: auto; }
#chartsec #acctbar #btnAcctInfo[hidden] + #btnAcctOff { margin-left: auto; }
#chartsec #paneAcct { overflow-y: auto; flex: 1 1 auto; }
#chartsec #paneAcct[hidden] { display: none; }
#chartsec .tabs2 [hidden] { display: none; }
#chartsec .acctpick { display: inline-flex; align-items: center; gap: 6px; }
#chartsec .acctpick[hidden], #chartsec .cchip[hidden] { display: none; }
#chartsec .acctpick select { max-width: 170px; background: var(--surface); color: var(--text); border: 1px solid var(--stroke); border-radius: 6px; font: inherit; padding: 2px 4px; }
#chartsec .ctr .cwarn { color: var(--down); font-weight: 650; }
#chartsec .ctr .clabel { color: var(--warn); font-weight: 600; }
@media (max-height: 520px) and (orientation: landscape) { #chartsec #acctbar { flex-wrap: nowrap; padding: 2px 8px; white-space: nowrap; overflow: hidden; } #chartsec #acctbar .who { overflow: hidden; text-overflow: ellipsis; } }
@media (max-width: 699px) { #chartsec #btnAcctOff .lbl { display: none; } #chartsec #btnAcctOff { min-width: 40px; min-height: 32px; justify-content: center; } #chartsec #acctbar .who { flex: 1 1 100%; } }
html.bar-hidden #chartsec #acctbar { display: none; }

#chartsec #btnCoin { flex: none; }
@media (max-width: 1599px) { #chartsec .acctpick select { max-width: 120px; } }
