/* =============================================================================
   China's Rise in Key Technologies — what only this tool uses
   -----------------------------------------------------------------------------
   On top of tools/tool.css (tokens and the shared components) and the shell
   (projects/_tool_base.html); design direction docs/unga-design.md. Plain CSS,
   linked with {% static_v %}.

   Colour: the accent is China (the Chinese companies, together or one by
   one), nothing else. Every other band is one of two neutrals, alternating
   inside a home so that neighbours part; what a source does not break down
   is the palest. Flat fills, no legend: bands carry their names, the side
   panel and the tooltip carry the numbers.
   ============================================================================= */

/* 1. Data colours (the sources dialog sits outside the app, so it takes them too) */
.ts, .ts-sources {
    --cn: var(--accent-fill);
    /* a lighter step of the accent in both themes, so its labels keep the dark on-accent ink */
    --cn-2: color-mix(in srgb, var(--accent-fill) 58%, rgb(var(--pe-on-chrome)));
    --nb-a: color-mix(in srgb, var(--text) 30%, var(--surface));
    --nb-b: color-mix(in srgb, var(--text) 18%, var(--surface));
    --nb-rest: color-mix(in srgb, var(--text) 7%, var(--surface));
}

/* 2. Layout ------------------------------------------------------------------ */
.ts-bar .ts-tabs { flex: none; }
.ts-bar-btn span { display: none; }
@media (min-width: 1280px) { .ts-bar-btn span { display: inline; } }

.ts-overview, .ts-market { display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.ts-overview[hidden], .ts-market[hidden] { display: none; }

.ts-cards { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 16px; }
/* the market's name across the top; on the left the drawing, then the size and
   China's share; on the right, most of the card, the year columns */
.ts-card {
    display: grid; grid-template-columns: minmax(0, 38%) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "kick kick" "art chart" "fig chart"; gap: 6px 14px; min-height: 0; min-width: 0;
    padding: 14px 16px 12px; text-align: left; font: inherit; color: inherit; cursor: pointer;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    transition: border-color .15s;
}
.ts-card:hover { border-color: var(--text-3); }
.ts-card-fig { grid-area: fig; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; min-width: 0; padding-bottom: 14px; }
.ts-card-kicker { grid-area: kick; display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ts-card-rank { font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ts-card-kicker .u-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* How big the market is: the revenue of the companies counted in its latest
   year, as a figure over a bar on one scale for all nine cards (full width:
   the largest). Neutral: the accent is China's alone. */
.ts-card-size { display: grid; gap: 3px; }
.ts-size-track { position: relative; height: 6px; border-radius: 999px; background: var(--nb-rest); overflow: hidden; }
.ts-size-fill { position: absolute; inset: 0 auto 0 0; width: max(3px, calc(var(--w) * 100%)); border-radius: 999px;
                background: var(--nb-a); transform-origin: 0 50%; transition: background-color .15s; }
.ts-card:hover .ts-size-fill { background: var(--text-2); }
.ts-size-v { font-size: var(--fs-xs); line-height: 16px; font-weight: 700; color: var(--text); white-space: nowrap;
             font-variant-numeric: tabular-nums; }
/* The industry's technical drawing (scripts/build_ts_art.py): an isometric
   object drawn as if transparent, fine ink lines with the working parts in
   orange, and the dimension lines, arcs and notes of a technical drawing. Pure
   decoration (aria-hidden); the one place the orange is not China. */
.ts-card-art { grid-area: art; position: relative; min-height: 0; min-width: 0; }
/* the drawing bleeds a little into the card's padding, so it can be as large as the column allows */
.ts-art { position: absolute; inset: -2px -4px 0 -10px; width: calc(100% + 14px); height: calc(100% + 2px); overflow: visible; pointer-events: none; }
.ts-art path, .ts-art circle { fill: none; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.ts-art .i { stroke: var(--text); stroke-width: .7px; }
.ts-art .h { stroke: var(--text); stroke-width: .45px; opacity: .5; }
.ts-art .a { stroke: var(--accent-fill); stroke-width: .8px; }
.ts-art .af { stroke: var(--accent-fill); stroke-width: .8px; fill: var(--accent-fill); fill-opacity: .12; }
.ts-art .d { stroke: var(--text); stroke-width: .4px; opacity: .55; }
.ts-art .c { stroke: var(--accent-fill); stroke-width: .45px; stroke-dasharray: 6 2 1 2; opacity: .75; }
.ts-art .dot { fill: var(--accent-fill); stroke: none; }
.ts-art text { font-family: var(--font); fill: var(--text); opacity: .65; }
.ts-art text.ta { fill: var(--accent-fill); opacity: 1; }
.ts-card:hover .ts-art .i { stroke-width: .85px; }
.ts-card-now { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; font-variant-numeric: tabular-nums; }
.ts-card-now .v { font-size: var(--fs-2xl); line-height: 1.1; font-weight: 700; color: var(--accent); white-space: nowrap; }
.ts-card-now .yr { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; }
.ts-card-now.is-scrub .yr { color: var(--text); font-weight: 700; }
.ts-card-chart { grid-area: chart; position: relative; min-height: 0; }
.ts-card-chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.ts-options { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.ts-options .u-seg:empty { display: none; }
.ts-pick { display: inline-flex; align-items: center; gap: 8px; }
.ts-pick .u-select { min-width: 200px; }
.ts-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 25vw, 390px); gap: 16px; }
.ts-chart-panel { min-height: 0; overflow: hidden; }
.ts-chart { position: relative; flex: 1; min-height: 0; outline-offset: -2px; }
.ts-chart svg { display: block; position: absolute; inset: 0; }
/* Touch: a sideways drag over a chart moves through the years, so the chart
   keeps horizontal drags and leaves vertical ones to the page. */
.ts-chart, .ts-card-chart { touch-action: pan-y; }
.ts-touch-hint { margin: 0; }
.ts-touch-hint[hidden] { display: none; }

/* The readout under the chart, below 1024 px (where the side panel sits under
   the chart): the year with its steps, China's figure, the band a tap selected
   and the year's company changes. Hidden on desktop, where hover and the side
   panel beside the chart do this. */
.ts-readout { display: none; flex: none; padding: 8px 12px 12px; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.ts-ro-top { display: flex; align-items: center; gap: 6px; }
.ts-readout .u-icon-btn { width: 40px; height: 40px; font-size: var(--fs-lg); }
.ts-ro-yr { min-width: 3.4em; text-align: center; font-size: var(--fs-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.ts-ro-cn { margin-left: auto; display: inline-flex; align-items: baseline; flex-wrap: wrap; justify-content: flex-end; gap: 0 6px; text-align: right; }
.ts-ro-cn .v { font-size: var(--fs-lg); font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ts-ro-cn .k { font-size: var(--fs-xs); color: var(--text-2); }
.ts-ro-band { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 2px 2px 2px 10px; border-radius: 10px; background: var(--surface-2); }
.ts-ro-band .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.ts-ro-band .v { white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ts-ro-band .v b { color: var(--text); }
.ts-ro-band.is-cn .v b { color: var(--accent); }
.ts-ro-band .ts-ro-x { flex: none; }
.ts-ro-src { display: inline-block; margin: 6px 0 0 10px; padding: 6px 0; border: 0; background: none; font: inherit; font-size: var(--fs-xs);
             color: rgb(var(--pe-accent-text)); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.ts-ro-hint { margin: 8px 0 0; font-size: var(--fs-xs); line-height: 16px; color: var(--text-3); }
.ts-ro-chg { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px solid var(--border); display: grid; gap: 6px;
             font-size: var(--fs-xs); line-height: 16px; color: var(--text-2); }
.ts-ro-chg li { display: flex; align-items: flex-start; gap: 8px; }
.ts-ro-chg .ts-glyph { margin-top: 2px; color: var(--text); }
.ts-basis { flex: none; margin: 0; padding: 2px 16px 12px; }
.ts-side { padding: 16px; gap: 12px; }

/* 3. Chart marks ------------------------------------------------------------- */
/* Hover: the band under the pointer stays whole and gets an outline drawn on
   top of the stack (.ts-band-hl), so no neighbour hides any of its edges; the
   other bands and their labels step back. A change in the lane does the same
   for the bands it touches (.is-linked). */
.ts-band { stroke: var(--surface); stroke-width: 1; stroke-linejoin: round; cursor: pointer; transition: opacity .15s; }
.ts-band.cn { fill: var(--cn); }
.ts-band.cn-2 { fill: var(--cn-2); }
.ts-band.nb-a { fill: var(--nb-a); }
.ts-band.nb-b { fill: var(--nb-b); }
.ts-band.nb-rest { fill: var(--nb-rest); }
.ts-svg.has-focus .ts-band:not(.is-on), .ts-svg.has-links .ts-band:not(.is-linked) { opacity: .32; }
.ts-svg.has-focus .ts-label:not(.is-on), .ts-svg.has-links .ts-label:not(.is-linked) { opacity: .3; }
.ts-band-hl { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; pointer-events: none; }
.ts-label { font-family: var(--font); font-size: 11px; fill: var(--text); pointer-events: none; font-variant-numeric: tabular-nums; transition: opacity .15s; }
.ts-label.on-cn { fill: var(--on-accent); font-weight: 700; }
.ts-label tspan.v { opacity: .75; }
.ts-nodata { font-family: var(--font); font-size: 11px; fill: var(--text-3); }
.ts-nodata-wash { fill: var(--text); opacity: .035; }
.ts-cross { stroke: var(--text); stroke-width: 1; opacity: .55; pointer-events: none; }
.ts-yeardot { fill: var(--text-3); }
.ts-yeardot.is-on { fill: var(--text); }
.ts-hit { fill: transparent; cursor: crosshair; }
/* China at the crosshair: a dot on the top of the Chinese stack, its value in a pill */
.ts-cn-mark { pointer-events: none; }
.ts-cn-mark circle { fill: var(--cn); stroke: var(--surface); stroke-width: 2; }
.ts-cn-pill rect { fill: var(--cn); }
.ts-cn-pill text { font-family: var(--font); font-size: 11px; font-weight: 700; fill: var(--on-accent); font-variant-numeric: tabular-nums; }
/* Overview cards: one column per year, a 0-100% track filled to China's share */
.ts-col-track { fill: var(--nb-rest); }
.ts-col { fill: var(--cn-2); }
.ts-col.is-last { fill: var(--cn); }
.ts-card:hover .ts-col { fill: var(--cn); }
.ts-col-ghost { fill: none; stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 2 2; opacity: .55; }
.ts-col-hit { fill: transparent; }
.ts-yr.is-on .ts-col-hit { fill: var(--text); opacity: .07; }
.ts-yr.is-on .ts-col-track { fill: var(--nb-b); }
.ts-mini-half { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 2 3; opacity: .7; pointer-events: none; }
.ts-mini-axis { font-family: var(--font); font-size: 11px; fill: var(--text-3); font-variant-numeric: tabular-nums; }
/* first visit: the size bars grow and the columns rise, card by card, year by year */
@keyframes ts-rise { from { transform: scaleY(0); } }
@keyframes ts-grow { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: no-preference) {
    .ts-cards.is-intro .ts-col {
        transform-box: fill-box; transform-origin: 50% 100%;
        animation: ts-rise .6s cubic-bezier(.2, .7, .2, 1) both;
        animation-delay: calc(var(--k, 0) * 70ms + var(--i, 0) * 22ms);
    }
    .ts-cards.is-intro .ts-size-fill {
        animation: ts-grow .7s cubic-bezier(.2, .7, .2, 1) both;
        animation-delay: calc(var(--k, 0) * 70ms);
    }
    .ts-cards.is-intro .ts-art { animation: ts-fade .9s ease-out both; animation-delay: calc(var(--k, 0) * 70ms); }
}

/* Company changes: a lane above the plot, one node per year (the change's
   glyph, or the number of changes), ringed in the accent when a Chinese band
   is involved; connectors from the band revenue leaves to the band it joins. */
.ts-lane-rule { stroke: var(--border); stroke-width: 1; }
.ts-lane-label { font-family: var(--font); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; fill: var(--text-3); }
.ts-node { cursor: pointer; outline: none; }
.ts-node .hit { fill: transparent; }
.ts-node .disc { fill: var(--surface); stroke: var(--text-3); stroke-width: 1.25; transition: fill .15s, stroke .15s; }
.ts-node path { fill: none; stroke: var(--text-2); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.ts-node text { font-family: var(--font); font-size: 11px; font-weight: 700; fill: var(--text-2); pointer-events: none; }
.ts-node text.aa { font-size: 9px; }
.ts-node.is-cn .disc { stroke: var(--cn); stroke-width: 2; }
.ts-node.is-dot .disc { fill: var(--text-3); stroke: none; }
.ts-node.is-dot.is-cn .disc { fill: var(--cn); }
.ts-node:hover .disc, .ts-node.is-on .disc, .ts-node.is-pinned .disc, .ts-node:focus-visible .disc { fill: var(--text); stroke: var(--text); }
.ts-node.is-cn:hover .disc, .ts-node.is-cn.is-on .disc, .ts-node.is-cn.is-pinned .disc { stroke: var(--cn); }
.ts-node:hover path, .ts-node.is-on path, .ts-node.is-pinned path, .ts-node:focus-visible path { stroke: var(--surface); }
.ts-node:hover text, .ts-node.is-on text, .ts-node.is-pinned text, .ts-node:focus-visible text { fill: var(--surface); }
.ts-links { pointer-events: none; animation: ts-fade .18s ease-out; }
@keyframes ts-fade { from { opacity: 0; } }
.ts-link-halo { fill: none; stroke: var(--surface); stroke-width: 6; stroke-linecap: round; opacity: .85; }
.ts-link { fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.ts-arrow { fill: var(--text); }
.ts-link-start { fill: var(--surface); stroke: var(--text); stroke-width: 2; }
.ts-link-mark { fill: none; stroke: var(--text); stroke-width: 2; }
.ts-link-label { font-family: var(--font); font-size: 11px; font-weight: 700; fill: var(--text); paint-order: stroke;
                 stroke: var(--surface); stroke-width: 3.5px; stroke-linejoin: round; }
/* the glyphs, inline in the side panel and the tooltip */
.ts-glyph { flex: none; overflow: visible; }
.ts-glyph path { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.ts-glyph .aa { font-family: var(--font); font-size: 6.5px; font-weight: 700; fill: currentColor; }
.ts-tip-ev { display: inline-flex; align-items: baseline; gap: 6px; }
.ts-tip-ev .ts-glyph { align-self: center; }

/* 4. Side panel -------------------------------------------------------------- */
.ts-side-head .u-2xl { margin-top: 2px; font-variant-numeric: tabular-nums; }
.ts-side-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ts-side-nav .years { display: inline-flex; gap: 4px; }
.ts-cn-fig { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; align-items: baseline;
             padding: 12px; border-radius: 10px; background: var(--accent-soft); }
.ts-cn-fig .v { font-size: var(--fs-2xl); line-height: 36px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.ts-cn-fig .k { font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.ts-cn-fig .m { grid-column: 1 / -1; font-size: var(--fs-xs); line-height: 16px; color: var(--text-2); }
.ts-rank { margin: 0; padding: 0; list-style: none; }
.ts-rank li { display: grid; grid-template-columns: 18px minmax(0, 1fr) 56px 62px; align-items: center; gap: 8px; padding: 5px 0;
              border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.ts-rank li:first-child { border-top: 0; }
.ts-rank .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-rank .v { text-align: right; font-variant-numeric: tabular-nums; }
.ts-rank li.is-cn .nm, .ts-rank li.is-cn .v { font-weight: 700; }
.ts-rank li.is-rest { color: var(--text-3); }
.ts-rank li.is-on { background: var(--surface-2); }
.ts-rank .u-bar-fill { background: var(--bar); }
.ts-rank li.is-cn .u-bar-fill { background: var(--cn); }
.ts-rank li.is-rest .u-bar-fill { background: var(--nb-a); }
.ts-flag, .ts-dot { width: 14px; height: 14px; border-radius: 999px; flex: none; }
.ts-dot { display: inline-block; background: var(--nb-a); }
.ts-dot.cn { background: var(--cn); }
.ts-side-src { font-size: var(--fs-xs); line-height: 16px; color: var(--text-3); }
.ts-side-src a { color: var(--text-2); }
.ts-side-note { font-size: var(--fs-xs); line-height: 16px; color: var(--text-3); margin-top: auto; }

/* 5. Drawer ------------------------------------------------------------------ */
.ts-src-markets > .u-label { margin-bottom: 6px; }
.ts-src-list { margin: 8px 0 0; padding-left: 18px; font-size: var(--fs-xs); line-height: 16px; color: var(--text-2); }
.ts-src-list li + li { margin-top: 6px; }
.ts-table summary { cursor: pointer; }
.ts-table__wrap { margin-top: 14px; overflow-x: auto; }
.ts-table table { border-collapse: collapse; font-size: var(--fs-xs); line-height: 16px; font-variant-numeric: tabular-nums; }
.ts-table caption { text-align: left; font-weight: 700; color: var(--text); padding-bottom: 4px; white-space: nowrap; }
.ts-table th, .ts-table td { padding: 2px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; text-align: right; color: var(--text-2); }
.ts-table tbody th { text-align: left; font-weight: 400; color: var(--text); position: sticky; left: 0; background: var(--surface); }
.ts-table tr.is-cn th, .ts-table tr.is-cn td { color: var(--accent); font-weight: 700; }

/* 6. Below 1024 px: the views stack and the page scrolls --------------------- */
@media (max-width: 1023px) {
    .ts-bar .ts-tabs { order: 3; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
    .ts-bar .ts-tabs::-webkit-scrollbar { display: none; }
    .ts .u-view { position: static; }
    .ts .u-stage { min-height: 0; }
    .ts-overview, .ts-market { padding: 16px; }
    .ts-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: auto; }
    .ts-card-chart { min-height: 170px; }
    .ts-card-art { min-height: 96px; }
    .ts-main { grid-template-columns: minmax(0, 1fr); }
    .ts-chart { height: 440px; flex: none; }
    .ts-readout { display: block; }
    /* the side panel repeats the year and its steps the readout already shows */
    .ts-side .ts-side-nav .years { display: none; }
}
@media (max-width: 639px) {
    .ts-overview, .ts-market { padding: 12px; gap: 12px; }
    .ts-cards { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .ts-card { grid-template-columns: minmax(0, 40%) minmax(0, 1fr); gap: 4px 10px; }
    .ts-card-chart { min-height: 150px; }
    /* the market on its own row, the two switches side by side under it */
    .ts-options { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
    .ts-pick { grid-column: 1 / -1; width: 100%; min-width: 0; }
    .ts-pick .u-select { flex: 1; width: auto; min-width: 0; }
    .ts-options .u-seg { display: flex; width: 100%; min-width: 0; }
    .ts-options .u-seg button { flex: 1; min-width: 0; height: 36px; padding: 0 6px; }
    /* the chart takes most of the screen, the readout fits under it */
    .ts-chart { height: clamp(320px, 56svh, 500px); }
}
@media (min-width: 1024px) and (max-height: 820px) {
    .ts-overview, .ts-market { padding: 16px 24px; gap: 12px; }
    .ts-cards { gap: 12px; }
    .ts-card { padding: 10px 14px 10px; gap: 2px 10px; }
    .ts-card-fig { padding-bottom: 12px; }
    .ts-card-now .v { font-size: var(--fs-xl); }
}

/* Drawer: what each market and each count of it measures */
.ts-src-market + .ts-src-market { margin-top: 14px; }
.ts-src-lenses { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 6px 0 0; }
.ts-src-lenses dt { color: var(--text); font-weight: 700; }
.ts-src-lenses dd { margin: 0; }

/* Estimates (grade B or C) in the side panel, and its rows that open the evidence */
.ts-est { display: inline-block; margin-left: 4px; padding: 0 4px; border: 1px solid var(--border); border-radius: 4px;
          font-size: 10px; line-height: 14px; font-weight: 400; color: var(--text-3); vertical-align: 1px; }
.ts-rank li[data-ev-open] { cursor: pointer; }
.ts-rank li[data-ev-open]:hover .nm { text-decoration: underline; text-underline-offset: 2px; }
.ts-tip-flag { opacity: .75; }

/* The evidence behind one figure, and the audit page */
.ts-ev { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: var(--fs-xs); line-height: 16px; }
.ts-ev-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.ts-ev-body { color: var(--text-2); }
.ts-ev dl { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 10px; }
.ts-ev dt { color: var(--text-3); }
.ts-ev dd { margin: 0; overflow-wrap: anywhere; color: var(--text); }
.ts-ev a, .ts-audit a { color: rgb(var(--pe-accent-text)); text-decoration: underline; }
.ts-ev q { quotes: none; font-style: italic; }
.ts-ev-status { font-weight: 700; padding: 0 6px; border: 1px solid var(--border); border-radius: 3px; }
.ts-ev-status.is-uncertain, .ts-ev-status.is-missing { color: rgb(var(--pe-down)); border-color: rgb(var(--pe-down)); }
.ts-ev-status.is-foundry { color: var(--text-3); }
.ts-audit-stage { padding: 16px; display: flex; flex-direction: column; gap: 28px; overflow: auto; }
.ts-audit-markets { flex-wrap: wrap; }
.ts-audit-markets a { padding: 4px 10px; text-decoration: none; color: var(--text-2); border-radius: 999px; }
.ts-audit-markets a[aria-current] { background: var(--surface); color: var(--text); font-weight: 700; }
.ts-audit-filters { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 12px 0; font-size: 12px; }
.ts-audit-filters select { font: inherit; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); padding: 3px 6px; }
.ts-audit-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.ts-audit-table th, .ts-audit-table td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.ts-audit-table th[data-sort] { cursor: pointer; }
.ts-audit-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ts-audit-table .note { max-width: 56ch; color: var(--text-2); }
.ts-audit-table tr.is-out td { opacity: .6; background: var(--surface-2); }
.ts-audit-table tr.is-big td { background: color-mix(in srgb, rgb(var(--pe-accent)) 14%, transparent); }
.ts-audit-table tr[hidden] { display: none; }

/* Side panel: the year's company changes as cards, and every change of the market */
.ts-chgs h3 { margin: 0 0 6px; }
.ts-chgs ul, .ts-chg-all ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ts-chg { display: grid; grid-template-columns: 16px minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px 10px;
          border: 1px solid var(--border); border-radius: 10px; color: var(--text-2); font-size: var(--fs-xs); line-height: 16px; }
.ts-chg:hover { border-color: var(--text-3); }
.ts-chg .ts-glyph { margin-top: 1px; color: var(--text); }
.ts-chg .t { display: block; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; }
.ts-chg .s { display: block; color: var(--text); font-weight: 700; }
.ts-chg .d { display: block; margin-top: 4px; }
.ts-chg-all { font-size: var(--fs-xs); line-height: 16px; border-top: 1px solid var(--border); padding-top: 10px; }
.ts-chg-all summary { cursor: pointer; color: var(--text-2); margin-bottom: 8px; }
.ts-chg-all summary:hover { color: var(--text); }
.ts-chg-all button { display: grid; grid-template-columns: 14px 36px minmax(0, 1fr); gap: 8px; align-items: start; width: 100%; padding: 4px 6px;
                     border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font: inherit; text-align: left; cursor: pointer; }
.ts-chg-all button:hover { background: var(--surface-2); color: var(--text); }
.ts-chg-all button .ts-glyph { margin-top: 1px; }
.ts-chg-all .y { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.ts-ev-tree { margin-top: 8px; padding: 0; border: 0; background: none; font: inherit; font-size: var(--fs-xs); }

/* 7. Sources: a tree of markets, companies and years ------------------------- */
.ts-sources { width: min(760px, 100vw); }
.ts-sources[open] { display: flex; flex-direction: column; }
.ts-sources-head { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 56px; padding: 0 24px;
                   border-bottom: 1px solid var(--border); }
.ts-sources-tools { flex: none; display: grid; gap: 8px; padding: 16px 24px 8px; }
.ts-find { position: relative; display: block; }
.ts-find .u-input { width: 100%; padding-left: 32px; }
.ts-tree { flex: 1; min-height: 0; padding: 4px 16px 32px; }
.ts-tree-empty { padding: 0 24px 24px; }
.ts-tree details > summary { list-style: none; display: grid; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px;
                             cursor: pointer; min-width: 0; }
.ts-tree details > summary::-webkit-details-marker { display: none; }
.ts-tree details > summary:hover { background: var(--surface-2); }
.ts-tree details[hidden] { display: none; }
.ts-chev { flex: none; transition: transform .2s ease-out; }
.ts-chev path { fill: none; stroke: var(--text-3); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ts-tree details[open] > summary > .ts-chev { transform: rotate(90deg); }
.ts-tree .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-tree .meta { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* the guide line of each level, like a file tree */
.ts-t-kids { margin-left: 13px; padding: 2px 0 6px 12px; border-left: 1px solid var(--border); }
.ts-t-market > summary { grid-template-columns: 12px 20px minmax(0, 1fr) auto; font-size: var(--fs-md); font-weight: 700; }
.ts-t-market .rk { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.ts-t-co > summary { grid-template-columns: 12px 14px minmax(0, 1fr) 56px auto; font-size: var(--fs-sm); }
.ts-t-co[open] > summary .nm { font-weight: 700; }
.ts-spark path { fill: none; stroke: var(--text-3); stroke-width: 1.25; stroke-linejoin: round; }
.ts-spark.cn path { stroke: var(--cn); }
.ts-t-wait { padding: 6px 8px; font-size: var(--fs-xs); color: var(--text-3); }
.ts-t-years { list-style: none; margin: 0; padding: 0; }
.ts-t-years li { display: grid; grid-template-columns: 40px 92px minmax(0, 1fr); gap: 10px; padding: 6px 8px; border-radius: 6px;
                 font-size: var(--fs-xs); line-height: 16px; }
.ts-t-years li + li { border-top: 1px solid var(--border); }
.ts-t-years .yr { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.ts-t-years .usd { color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ts-t-years .doc { min-width: 0; overflow-wrap: anywhere; }
.ts-t-years .doc a { color: rgb(var(--pe-accent-text)); text-decoration: underline; text-underline-offset: 2px; }
.ts-t-years .doc a.more { margin-left: 8px; color: var(--text-2); }
.ts-t-years .loc { display: block; color: var(--text-3); }
.ts-t-years li.is-flash { animation: ts-flash 1.6s ease-out; }
@keyframes ts-flash { from { background: var(--accent-soft); } }
@media (max-width: 639px) {
    .ts-t-co > summary { grid-template-columns: 12px 14px minmax(0, 1fr) auto; }
    .ts-t-co .ts-spark { display: none; }
    .ts-t-years li { grid-template-columns: 40px minmax(0, 1fr); }
    .ts-t-years .doc { grid-column: 1 / -1; }
}
