/* The chart on real candles: the timeframe keys and their list, the plate's states (loading, failed with Retry, no
   history), the one notice on the chart (paused, reconnecting, older candles...), the lines' pending / done / refused
   looks, the indicator menu's count and its "remove all", the toasts' place on a computer (the positions panel). Tokens only; hover only
   where a pointer hovers; never italic. Loaded last. */

/* ---- timeframes: the main ones as keys, the others in a list beside them ---- */
.tf-seg { gap: 1px; }
.tf-seg .seg-b { min-width: 34px; padding: 0 8px; font-family: var(--font-num); font-stretch: var(--num-stretch); font-size: 11.5px; }
.tf-more-w { position: relative; display: inline-flex; align-items: center; }
.tf-more-w .i { position: absolute; right: 6px; width: 12px; height: 12px; color: var(--dim); pointer-events: none; }
/* the key is the word, as wide as what it says in every language; the list lies over it unseen (a list is as wide as
   its longest choice: shown, it left a gap before the arrow). .tf-seg in the selectors: the keys' own padding and
   figures font (.tf-seg .seg-b) must not take the arrow's room */
.tf-seg .tf-more-t { padding: 0 22px 0 9px; font-family: var(--font-ui); font-stretch: normal; }
.tf-seg select.tf-more { position: absolute; inset: 0; width: 100%; height: 100%; min-width: 0; min-height: 0; padding: 0; opacity: 0; -webkit-appearance: none; appearance: none; cursor: pointer; }
select.tf-more option { background: var(--surface-2); color: var(--text); }
.tf-more-w[data-on="1"] .tf-more-t { background: var(--surface-4); color: var(--text); }
.tf-more-w:has(select:focus-visible) .tf-more-t { outline: 2px solid var(--focus); outline-offset: 1px; }
.tf-more-w[data-on="1"] .i { color: var(--mute); }

/* ---- the plate while there is no candle to draw ---- */
.chart-state { z-index: 4; }
.chart-state-i { display: none; width: 22px; height: 22px; color: var(--warn); }
.chart-state:not([data-state="loading"]) .pstate-skel { display: none; }
.chart-state[data-state="failed"] .chart-state-i { display: block; }
.chart-state[data-state="failed"] .pstate-text, .chart-state[data-state="empty"] .pstate-text { color: var(--text); font-size: 13px; text-align: center; }
.chart-sub { max-width: 320px; margin: -6px 0 0; color: var(--dim); font-size: 12px; line-height: 1.45; text-align: center; }
.chart-retry { pointer-events: auto; min-width: 112px; }
.chartwrap[data-cover] #chart, .chartwrap[data-cover] .lines { visibility: hidden; }

/* ---- the one notice on the chart, top centre (the drawing hint takes its place while drawing). It never moves and
   never leaves under the pointer: the library's legend starts under it and its highest / lowest price label gives way
   (chart.js) ---- */
/* the notice stays over the candles, never over the price axis and its figures (Q4): a narrow chart writes it on two lines */
.chart-flag { position: absolute; top: 8px; left: 12px; right: calc(var(--axis, 64px) + 12px); z-index: 3; width: fit-content; max-width: calc(100% - var(--axis, 64px) - 24px); margin: 0 auto;
  padding: 5px 10px; border-radius: var(--r-sm); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--hair-3); color: var(--mute); font-size: 11.5px;
  white-space: normal; overflow-wrap: anywhere; pointer-events: none; animation: toast-in var(--t) var(--ease); }
.chart-flag[data-tone="warn"] { color: var(--text); box-shadow: inset 0 0 0 1px var(--warn); background: var(--surface-2); }
.chartwrap[data-drawing="1"] .chart-flag { display: none; }
.chartwrap[data-pop="1"] .chart-flag { opacity: 0; }       /* an open chart panel: it steps aside */
.chart-flag { transition: opacity var(--t) var(--ease); }

/* ---- the lines: each part moves by itself (--y), so no line makes a layer of its own and every tag sits above every
   line: a line under a tag never takes the press meant for the tag ---- */
.ln { will-change: auto; }
.ln > .ln-rule, .ln > .ln-link { transform: translateY(var(--y, 0px)); z-index: 1; }
.ln > .ln-px { transform: translateY(calc(var(--y, 0px) - 50% + var(--py, 0px))); z-index: 2; }
.ln > .ln-tag { transform: translateY(calc(var(--y, 0px) - 50% + var(--dy, 0px))); z-index: 3; }

/* ---- the lines: a stop dropped and on its way, done, refused; the line being dragged ---- */
.ln-tag button:focus-visible { outline: 2px solid var(--focus); }
.ln-tag .ln-v[hidden] { display: none; }
.ln-tag > .ln-v { min-width: 0; }
/* Q2: while a stop loss is dragged, the share of what is left to lose that it would take, on its own tag */
.ln-tag .ln-room[hidden] { display: none; }
.ln-tag > .ln-room { color: var(--down); background: var(--down-soft); }
.ln[data-dragging="1"] .ln-rule, .ln[data-act] .ln-rule { opacity: 1; border-top-style: solid; }
.ln[data-act="pending"] .ln-tag { animation: pstate-breathe 0.8s var(--ease) infinite alternate; cursor: progress; }
.ln[data-act="done"] .ln-tag { box-shadow: inset 0 0 0 1px var(--acc), 0 6px 14px -8px rgba(0, 0, 0, 0.6); }
.ln[data-act="refused"] .ln-tag { box-shadow: inset 0 0 0 2px var(--down), 0 6px 14px -8px rgba(0, 0, 0, 0.6); }
.ln[data-dragging="1"] .ln-tag { background: var(--surface-4); }
.ln:not([data-drag]) .ln-tag { cursor: default; }

/* ---- a line whose price is off the scale: its tag waits at that edge, with its price and an arrow towards it; no rule,
   no label on the axis, and it is not dragged from there ---- */
.ln-tag > .ln-at { display: none; }
.ln[data-edge] > .ln-rule, .ln[data-edge] > .ln-link, .ln[data-edge] > .ln-px { display: none; }
.ln[data-edge] .ln-tag > .ln-at { display: inline-flex; }
.ln[data-edge] .ln-tag { cursor: default; }
.ln[data-edge] .ln-tag > .ln-k::after { content: ''; margin-inline-start: 6px; border: 4px solid transparent; border-top: 0; border-bottom: 5px solid currentColor; }
.ln[data-edge="bottom"] .ln-tag > .ln-k::after { transform: rotate(180deg); }

/* ---- indicators: the count and "remove all" ---- */
.ci-count { display: inline-flex; align-items: center; gap: 8px; letter-spacing: 0; text-transform: none; }
.ci-clear { min-height: 22px; padding: 0 8px; font-size: 11px; }
.ci-clear[data-armed="1"] { box-shadow: inset 0 0 0 1px var(--warn), 0 1px 0 var(--key-edge); color: var(--warn); }

/* ---- toasts on a computer: one line in the free space of the positions panel's tab row, between its tabs and its
   keys, over nothing (no row, no key, no candle); the last one only, on two lines when one is not enough (the row keeps
   its height); whole in its title; the activity tab keeps all ---- */
.tab-toasts { flex: 1 1 0; min-width: 0; display: flex; justify-content: flex-end; padding-left: 12px; }
.tab-toasts > .toasts { position: static; display: flex; min-width: 0; max-width: 100%; pointer-events: auto; }
/* two lines at most inside the tab row's own height (34 px, Q1): 2 x 14 + 4 = 32 px, the row never grows when a note comes */
.tab-toasts .toast { align-items: center; min-width: 0; max-width: 100%; min-height: 0; max-height: calc(var(--bot-fold) - 2px); padding: 2px 10px; font-size: 12px; line-height: 14px; box-shadow: inset 0 0 0 1px var(--hair-2); animation-name: toast-fade; }
.tab-toasts .toast .i { margin-top: 0; }
.tab-toasts .toast span { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.tab-toasts .toast:not(:last-child) { display: none; }
/* a note in the tab row takes the room of the folded panel's own words (Q1) while it shows: it reads whole in 2 lines */
.ptabs-in:has(.tab-toasts .toast) > .bot-note { display: none !important; }
.tab-toasts .toast[data-out="1"] { transform: none; }
.tab-toasts .toast[data-kind="bad"] { box-shadow: inset 0 0 0 1px var(--down); }
.tab-toasts .toast[data-kind="bad"] .i { color: var(--down); }
@keyframes toast-fade { from { opacity: 0; } }

/* ---- the phone: the chart bar's keys keep their touch size ---- */
.term[data-form="phone"] .tf-seg .seg-b { min-width: 44px; padding: 0 6px; }
.term[data-form="phone"] .tf-seg .tf-more-t { min-width: 64px; padding: 0 20px 0 6px; }   /* the arrow: 6 to 18 px from the right */
.term[data-form="phone"] .chart-flag { font-size: 12px; }
.term[data-form="phone"] .chart-flag { top: 6px; }
/* the chart fills the phone's width: no plate corners at the window's edges */
.term[data-form="phone"] .chartp::before { display: none; }

@media (hover: hover) {
  .tf-more-w:hover .i, .tf-more-w:hover .tf-more-t { color: var(--text); }
  .ln[data-drag] .ln-tag:hover { background: var(--surface-4); }
}
@media (prefers-reduced-motion: reduce) {
  .ln[data-act="pending"] .ln-tag, .chart-flag { animation: none; }
}
