/* Plates (from the mock-up v5): the grid of the desk, the plates, their tabs, the chart, its order lines, its bar. */
/* lot Q1: the panes edge to edge, one hairline between two (the grid's 1 px gaps over its hairline ground); the book's width
   and the bottom panel's height are the trader's (panes.js) or these, the panel never taller than what it lists
   (--bot-fit: it grows with its rows up to that height; --bot-need: a view of fixed height, the account's rules, is shown
   whole above that height unless the trader set one); the account's line is in the top bar, else a band */
.tgrid { grid-area: main; --tk-w: 272px; --book-w: var(--book-user, 232px); --bot: min(var(--bot-user, max(var(--bot-def, 184px), var(--bot-need, 0px))), var(--bot-fit, 9999px));
  display: grid; grid-template-columns: minmax(0, 1fr) var(--book-w) var(--tk-w); grid-template-rows: auto minmax(0, 1fr) var(--bot);
  grid-template-areas: "acct acct ticket" "chart book ticket" "bottom bottom ticket"; gap: 1px; padding: 0; min-height: 0; background: var(--hair); }
.term[data-dock="1"] .tgrid { grid-template-rows: minmax(0, 1fr) var(--bot); grid-template-areas: "chart book ticket" "bottom bottom ticket"; }
.tgrid[data-fold="1"] { --bot: var(--bot-fold); }
.chartp { grid-area: chart; }
.bookp { grid-area: book; }
.side { display: contents; }
.gaugep { grid-area: acct; }
.ticketp { grid-area: ticket; }
.botp { grid-area: bottom; }

.plate { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); overflow: hidden; }
.marketsp { border-radius: var(--r-lg); }                 /* the one plate that opens over the others */

/* ---- tabs inside a plate ---- */
.ptabs-in { display: flex; align-items: center; gap: 2px; min-height: var(--bot-fold); box-sizing: border-box; padding: 0 8px; border-bottom: 1px solid var(--hair); flex: none; overflow-x: auto; scrollbar-width: none; }
.ptabs-in::-webkit-scrollbar { display: none; }
.tab { position: relative; min-height: calc(var(--bot-fold) - 1px); padding: 0 10px; border: 0; background: none; color: var(--dim); font-weight: 600; font-size: 12px; white-space: nowrap; cursor: pointer; transition: color var(--t-fast) var(--ease); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 2px; background: var(--acc); }
.tab .n { margin-left: 6px; color: var(--mute); font-family: var(--font-num); font-stretch: var(--num-stretch); font-size: 11px; }
.tab-end { margin-left: auto; }
.tab-acts { margin-left: auto; display: flex; gap: 6px; padding-left: 12px; }
@media (hover: hover) { .tab:hover { color: var(--text); } }

/* ---- chart ---- */
.ctool { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 0 8px; border-bottom: 1px solid var(--hair); flex: none; }
.ctool-note { margin-left: auto; min-width: 0; color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chartwrap { position: relative; flex: 1; min-height: 0; background: var(--chart-bg); }   /* the candles and both axes on black */
#chart { position: absolute; inset: 0; }
.lines { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; }
.ln { position: absolute; left: 0; right: 0; top: 0; height: 0; color: var(--mute); will-change: transform; }
.ln-rule { position: absolute; left: 0; right: var(--axis, 64px); top: 0; border-top: 1px dashed currentColor; opacity: 0.75; }
.ln[data-kind="entry"] .ln-rule { border-top-style: solid; opacity: 0.5; }
.ln[data-kind="sl"], .ln[data-kind="dsl"] { color: var(--down); }
.ln[data-kind="tp"], .ln[data-kind="dtp"] { color: var(--up); }
.ln[data-kind="order"], .ln[data-kind="dentry"], .ln[data-kind="dlimit"] { color: var(--acc); }
.ln[data-draft="1"] .ln-rule { opacity: 0.45; }
.ln[data-kind="dlimit"] .ln-rule { border-top-style: dotted; }
.ln-tag { position: absolute; left: 10px; top: 0; transform: translateY(calc(-50% + var(--dy, 0px))); display: flex; align-items: stretch; height: 24px; border-radius: var(--r-sm); background: var(--surface-3); box-shadow: inset 0 0 0 1px currentColor, 0 6px 14px -8px rgba(0, 0, 0, 0.6); pointer-events: auto; font-size: 11px; font-weight: 600; overflow: hidden; touch-action: none; }
.ln[data-drag="1"] .ln-tag { cursor: ns-resize; }
.ln[data-draft="1"] .ln-tag { background: var(--surface); box-shadow: inset 0 0 0 1px var(--hair-3); }
.ln-tag > * { display: inline-flex; align-items: center; padding: 0 8px; border: 0; background: none; color: var(--text); white-space: nowrap; font: inherit; }
.ln-tag > * + * { box-shadow: inset 1px 0 0 var(--hair-2); }
.ln-tag > .ln-k { color: currentColor; }
.ln-tag > span.ln-k { color: inherit; }
.ln-tag button { cursor: pointer; color: var(--mute); }
.ln-tag button:focus-visible { outline-offset: -2px; }
.ln-px { position: absolute; right: 0; top: 0; transform: translateY(calc(-50% + var(--py, 0px))); width: var(--axis, 64px); height: 20px; line-height: 20px; background: currentColor; text-align: center; font-size: 10.5px; }
.ln-px b { color: var(--bg); font-weight: 600; }
.ln-tag button[aria-pressed="true"] { background: var(--down-soft); color: var(--down); }
@media (hover: hover) { .ln-tag button:hover { color: var(--text); background: var(--surface-4); } }
/* With a mouse, a line is also grabbed by the line itself. On a phone only the tag drags, so the chart still pans. */
@media (hover: hover) and (pointer: fine) {
  .ln[data-drag="1"] .ln-rule::before { content: ''; position: absolute; left: 0; right: 0; top: -4px; height: 7px; pointer-events: auto; cursor: ns-resize; }
  .ln[data-drag="1"] .ln-rule:hover { opacity: 1; }
}
/* A tag moved off its line keeps a thin link to it. */
.ln-link { display: none; position: absolute; left: 22px; top: min(0px, var(--dy, 0px)); height: max(var(--dy, 0px), calc(-1 * var(--dy, 0px))); border-left: 1px solid currentColor; opacity: 0.75; }
.ln[data-moved="1"] .ln-link { display: block; }
.ln[data-draft="1"] .ln-link { left: auto; right: calc(var(--axis, 64px) + 22px); }
/* While the trader draws, the order tags let the clicks through to the chart. */
.chartwrap[data-drawing="1"] .ln-tag, .chartwrap[data-drawing="1"] .ln-rule::before { pointer-events: none; }
.draw-hint { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 3; max-width: calc(100% - var(--axis, 64px) - 24px); padding: 5px 10px; border-radius: var(--r-sm); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--hair-3); color: var(--text); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

/* ---- chart bar: indicators and drawing ---- */
.ct-open { flex: none; }
.ctool-n { min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--surface-4); color: var(--text); font-size: 10.5px; line-height: 16px; text-align: center; }
.ct-bar { display: flex; align-items: center; gap: 2px; flex: none; }
.ct-b { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: var(--mute); cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.ct-b:focus-visible, .ct-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.ct-b[aria-pressed="true"], .ct-item[aria-pressed="true"], #drawBtn[aria-pressed="true"] { background: var(--surface-4); color: var(--text); }
.ct-b[data-armed="1"], .ct-item[data-armed="1"] { color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn); }
.ct-sep { flex: none; width: 1px; height: 18px; margin: 0 5px; background: var(--hair-2); }
#drawBtn { display: none; }
.ctool[data-narrow="1"] .ct-bar { display: none; }
.ctool[data-narrow="1"] #drawBtn { display: inline-flex; }
.cpop { position: absolute; z-index: 42; display: grid; gap: 8px; width: min(560px, calc(100% - 16px)); padding: 12px; border-radius: var(--r); background: var(--surface-2); box-shadow: var(--shadow-pop); overflow-y: auto; overscroll-behavior: contain; }
.cpop[data-kind="draw"] { width: min(280px, calc(100% - 16px)); padding: 6px; gap: 2px; }
.cpop-h { display: flex; align-items: baseline; justify-content: space-between; margin: 2px 0 0; color: var(--dim); font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.cpop-sep { height: 1px; margin: 4px 0; background: var(--hair); }
.ci-none, .ci-note { margin: 0; color: var(--dim); font-size: 12px; }
.ci-note { color: var(--warn); }
.ct-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--mute); font: inherit; font-size: 12.5px; font-weight: 600; text-align: left; cursor: pointer; }
@media (hover: hover) { .ct-b:hover, .ct-item:hover { color: var(--text); background: var(--surface-3); } }
