
/* Layout: a trading-desk sheet. The tape (every market, every window) sits on top, one market's
   workspace below it (price + volume, book, holders), then share of volume, then method notes. */
:root {
  --paper: #eef1f4;
  --panel: #ffffff;
  --sunk: #f6f8fa;
  --ink: #0e1621;
  --ink-2: #485364;
  --ink-3: #7d8797;
  --rule: #e1e6ec;
  --rule-2: #c8d0da;
  --accent: #2f45cf;
  --accent-wash: rgba(47, 69, 207, 0.08);
  --up: #0a7d45;
  --down: #c9353a;
  --up-mark: #12a35d;
  --down-mark: #e0484d;
  --warn: #9a6700; --warn-wash: #fff8c5; --warn-line: #e8c547; --bad: #cf222e; --bad-wash: #ffebe9; --bad-line: #ffaba8; /* data health only */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s0: #8a94a3;
  --shadow: 0 1px 2px rgba(14, 22, 33, 0.06), 0 8px 24px -12px rgba(14, 22, 33, 0.12);
  --f-cjk: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC";
  --f-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, var(--f-cjk), sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", var(--f-cjk), sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b0f15; --panel: #121821; --sunk: #0f141c; --ink: #e8edf4; --ink-2: #a9b3c1; --ink-3: #6e7989;
    --rule: #1f2834; --rule-2: #2e3a48; --accent: #8a9bff; --accent-wash: rgba(138, 155, 255, 0.12);
    --up: #2fca84; --down: #ff7a7e; --up-mark: #22b673; --down-mark: #f0575c;
    --warn: #d29922; --warn-wash: rgba(187, 128, 9, 0.15); --warn-line: rgba(187, 128, 9, 0.45); --bad: #f85149; --bad-wash: rgba(248, 81, 73, 0.12); --bad-line: rgba(248, 81, 73, 0.45);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s0: #6e7989;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  --paper: #0b0f15; --panel: #121821; --sunk: #0f141c; --ink: #e8edf4; --ink-2: #a9b3c1; --ink-3: #6e7989;
  --rule: #1f2834; --rule-2: #2e3a48; --accent: #8a9bff; --accent-wash: rgba(138, 155, 255, 0.12);
  --up: #2fca84; --down: #ff7a7e; --up-mark: #22b673; --down-mark: #f0575c;
    --warn: #d29922; --warn-wash: rgba(187, 128, 9, 0.15); --warn-line: rgba(187, 128, 9, 0.45); --bad: #f85149; --bad-wash: rgba(248, 81, 73, 0.12); --bad-line: rgba(248, 81, 73, 0.45);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s0: #6e7989;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 14px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 20px; padding-block: 20px 56px; display: grid; gap: 18px; }
@media (max-width: 560px) { .wrap { padding-inline: 16px; } }
h1, h2, h3 { margin: 0; text-wrap: balance; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--f-mono); }
.muted { color: var(--ink-3); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- header ---------- */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mark { display: grid; grid-template-rows: repeat(3, 5px); gap: 2px; width: 22px; flex: none; }
.mark i { display: block; border-radius: 2px; }
.mark i:nth-child(1) { background: #e0484d; width: 22px; }
.mark i:nth-child(2) { background: #12a35d; width: 16px; }
.mark i:nth-child(3) { background: #2a78d6; width: 19px; }
.logo { width: 44px; height: 44px; flex: none; display: block; } /* a copy's own logo (window.LNFI_TAPE.logo) */
.brand h1 { font: 700 26px/1.05 var(--f-display); letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--rule-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { white-space: nowrap; border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.seg button:hover { background: var(--sunk); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); background: var(--panel); border: 1px solid var(--rule-2); border-radius: 999px; padding: 5px 6px 5px 12px; max-width: 100%; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.status[data-state="live"] .dot { background: var(--up-mark); }
.status[data-state="busy"] .dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.status[data-state="warn"] .dot { background: var(--warn); }
.status[data-state="error"] .dot { background: var(--bad); }
.status span.txt { min-width: 0; overflow-wrap: anywhere; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .status[data-state="busy"] .dot { animation: none; } }
.btn { border: 1px solid var(--rule-2); background: var(--sunk); border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--ink); }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.theme { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; flex: none; border: 1px solid var(--rule-2); border-radius: 999px; background: var(--panel); color: var(--ink-2); cursor: pointer; }
.theme:hover { background: var(--sunk); color: var(--ink); }
.theme svg { display: block; width: 16px; height: 16px; }

/* transitions.dev: icon swap (https://transitions.dev) */
:root {
  --icon-swap-dur: 250ms;
  --icon-swap-blur: 2px;
  --icon-swap-start-scale: 0.25;
  --icon-swap-ease: ease-in-out;
}
.t-icon-swap {
  position: relative;
  display: inline-grid;
}
.t-icon-swap .t-icon {
  grid-area: 1 / 1;
  transition:
    opacity   var(--icon-swap-dur) var(--icon-swap-ease),
    filter    var(--icon-swap-dur) var(--icon-swap-ease),
    transform var(--icon-swap-dur) var(--icon-swap-ease);
  will-change: opacity, filter, transform;
}
.t-icon-swap[data-state="a"] .t-icon[data-icon="a"],
.t-icon-swap[data-state="b"] .t-icon[data-icon="b"] {
  opacity: 1;
  filter: blur(0);
  transform: scale(1);
}
.t-icon-swap[data-state="a"] .t-icon[data-icon="b"],
.t-icon-swap[data-state="b"] .t-icon[data-icon="a"] {
  opacity: 0;
  filter: blur(var(--icon-swap-blur));
  transform: scale(var(--icon-swap-start-scale));
}

@media (prefers-reduced-motion: reduce) {
  .t-icon-swap .t-icon { transition: none !important; }
}

/* data health: shown only when something is stale, missing or unreachable; worst level first */
.health { display: grid; gap: 4px; padding: 10px 14px; border: 1px solid var(--warn-line); background: var(--warn-wash); border-radius: var(--r); font-size: 13px; }
.health[data-level="error"] { border-color: var(--bad-line); background: var(--bad-wash); }
.health b { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.health b::before { content: '!'; display: inline-grid; place-items: center; flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--warn); color: var(--panel); font-size: 12px; font-weight: 700; }
.health[data-level="error"] b::before { background: var(--bad); }
.health ul { margin: 0; padding-left: 26px; color: var(--ink-2); }
.health li::marker { color: var(--warn); }
.health li[data-level="error"]::marker { color: var(--bad); }
.platform { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 12.5px; color: var(--ink-2); padding: 10px 14px; border: 1px dashed var(--rule-2); border-radius: var(--r); }
.platform b { color: var(--ink); font-weight: 600; }

/* ---------- panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; padding: 16px 18px 10px; }
.panel-head h2 { font: 600 16px/1.3 var(--f-body); }
.panel-head .sub { font-size: 12.5px; color: var(--ink-3); }

/* ---------- tape (overview table) ---------- */
.table-scroll { overflow-x: auto; }
table.tape { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 980px; }
.tape th, .tape td { padding: 9px 12px; text-align: right; white-space: nowrap; }
.tape th { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); border-bottom: 1px solid var(--rule); background: var(--panel); }
.tape th.grp { text-align: center; border-bottom: 0; padding-bottom: 0; color: var(--ink-2); }
.tape th button { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
.tape th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tape th button[data-dir]::after { content: attr(data-dir); color: var(--accent); }
.tape th:first-child, .tape td:first-child { text-align: left; position: sticky; left: 0; background: inherit; z-index: 1; }
.tape tbody tr { background: var(--panel); cursor: pointer; border-top: 1px solid var(--rule); }
.tape tbody tr:hover { background: var(--sunk); }
.tape tbody tr[aria-selected="true"] { background: var(--accent-wash); }
.tape tbody tr[aria-selected="true"] td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.tape td.sep, .tape th.sep { border-left: 1px solid var(--rule); }
.mkt { display: flex; align-items: center; gap: 9px; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.mkt b { font-weight: 600; }
.chip { font-size: 10.5px; font-weight: 600; letter-spacing: .03em; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--rule-2); color: var(--ink-2); }
.chip.rgb { border-color: transparent; background: var(--accent-wash); color: var(--accent); }
.cell2 { display: grid; justify-items: end; line-height: 1.25; }
.cell2 small { font-size: 11.5px; }
.delta { font-variant-numeric: tabular-nums; font-weight: 500; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--ink-3); }
.spark { display: block; }

/* ---------- market workspace ---------- */
.ws-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; padding: 18px 18px 6px; }
.ws-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.ws-title h2 { font: 700 30px/1 var(--f-display); letter-spacing: -0.01em; }
.ws-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12.5px; color: var(--ink-3); padding: 0 18px 12px; }
.ws-meta .cid { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
.ws-meta .cid code { font: 400 12px var(--f-mono); color: var(--ink-2); overflow-wrap: anywhere; }
.ws-meta .cid > span, .copy { flex: none; white-space: nowrap; } /* Chinese breaks anywhere: keep these whole */
.copy { border: 1px solid var(--rule-2); background: transparent; border-radius: 6px; padding: 1px 7px; font-size: 11.5px; cursor: pointer; color: var(--ink-2); }
.copy:hover { color: var(--accent); border-color: var(--accent); }
.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.picker button { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--rule-2); background: var(--panel); border-radius: 999px; padding: 4px 11px 4px 9px; font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--ink-2); }
.picker button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--sunk); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 4px 18px 14px; border-bottom: 1px solid var(--rule); }
.filters .note { font-size: 12px; color: var(--ink-3); }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-bottom: 1px solid var(--rule); }
.kpi { padding: 14px 16px; display: grid; gap: 3px; align-content: start; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--rule); }
.kpi .lbl { font-size: 12px; color: var(--ink-3); }
.kpi .val { font: 600 21px/1.15 var(--f-body); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.kpi .val small { font-size: 12px; font-weight: 500; color: var(--ink-3); letter-spacing: 0; }
.kpi .cmp { font-size: 12px; color: var(--ink-3); }
.meter { height: 6px; border-radius: 999px; background: var(--rule); overflow: hidden; margin-top: 4px; display: flex; gap: 2px; }
.meter i { display: block; height: 100%; }
@media (max-width: 1020px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpi:nth-child(4) { border-left: 0; } .kpi:nth-child(n+4) { border-top: 1px solid var(--rule); } }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi:nth-child(odd) { border-left: 0; } .kpi:nth-child(4) { border-left: 1px solid var(--rule); } .kpi:nth-child(n+3) { border-top: 1px solid var(--rule); } }

.ws-body { display: grid; grid-template-columns: minmax(0, 1fr) 330px; }
.ws-main { padding: 14px 8px 10px 18px; min-width: 0; }
.ws-side { border-left: 1px solid var(--rule); display: grid; align-content: start; min-width: 0; }
.side-block { padding: 14px 18px; display: grid; gap: 10px; }
.side-block + .side-block { border-top: 1px solid var(--rule); }
.side-block h3 { font: 600 13.5px/1.3 var(--f-body); }
@media (max-width: 1020px) { .ws-body { grid-template-columns: minmax(0, 1fr); } .ws-side { border-left: 0; border-top: 1px solid var(--rule); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } .side-block + .side-block { border-top: 0; } }
@media (max-width: 560px) { .ws-main { padding-inline: 12px 4px; } .side-block + .side-block { border-top: 1px solid var(--rule); } }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; font-size: 12px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .ln { width: 14px; height: 2px; border-radius: 2px; }
.legend .bx { width: 10px; height: 10px; border-radius: 3px; }
.legend .tri { width: 10px; height: 8px; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.seg.mini { margin-left: auto; padding: 2px; }
.seg.mini button { padding: 2px 10px; font-size: 12px; }

.chart { position: relative; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; }
.chart:focus-visible { outline-offset: 4px; }
.axis text { font: 400 10.5px var(--f-mono); fill: var(--ink-3); }
.grid line { stroke: var(--rule); stroke-width: 1; shape-rendering: crispEdges; }
.base { stroke: var(--rule-2); stroke-width: 1; shape-rendering: crispEdges; }
.xhair { stroke: var(--ink-3); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.pane-label { font: 600 10.5px var(--f-body); fill: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--panel); border: 1px solid var(--rule-2); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; font-size: 12px; min-width: 150px; display: grid; gap: 3px; }
.tip .when { font: 500 11px var(--f-mono); color: var(--ink-3); }
.tip .row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; }
.tip .row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip .row span { color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; }
.tip .key { width: 12px; height: 2px; border-radius: 2px; display: inline-block; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; margin: 0; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; gap: 4px; font-size: 12.5px; }
.bar-row .top { display: flex; justify-content: space-between; color: var(--ink-2); }
.bar-row .track { height: 8px; border-radius: 999px; background: var(--rule); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 999px; }
.big { font: 600 26px/1.1 var(--f-body); letter-spacing: -0.01em; }

details.data { margin: 6px 10px 4px 0; font-size: 12.5px; }
details.data summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }
details.data .table-scroll { max-height: 280px; overflow: auto; margin-top: 8px; border: 1px solid var(--rule); border-radius: 8px; }
details.data table { border-collapse: collapse; width: 100%; font-size: 12px; }
details.data th, details.data td { padding: 5px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--rule); }
details.data th { position: sticky; top: 0; background: var(--sunk); color: var(--ink-3); font-weight: 600; }
details.data td:first-child, details.data th:first-child { text-align: left; }

/* ---------- share + notes ---------- */
.share-body { padding: 4px 8px 14px 18px; display: grid; gap: 10px; }
.share-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12.5px; padding-right: 10px; }
.share-legend span { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); }
.share-legend b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

.notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px 28px; padding: 6px 18px 18px; font-size: 13px; color: var(--ink-2); }
.notes h3 { font: 600 13.5px/1.3 var(--f-body); color: var(--ink); margin-bottom: 6px; }
.notes p, .notes ul { margin: 0 0 8px; max-width: 65ch; }
.notes ul { padding-left: 18px; }
.notes code { font: 400 12px var(--f-mono); background: var(--sunk); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.foot { font-size: 12px; color: var(--ink-3); }
