/* =========================================================================
   Cabinhub News — market data layer (js/markets.js)

   Design: part of THE LETTERHEAD, not a dashboard. The strip is a tape, not a
   row of cards: one hairline band, monospaced tabular figures, a drawn rule
   between instruments, no boxes, no shadows, no gradients. Colour appears on
   exactly one thing — the change figure — and never as the only carrier of
   direction: every change also carries an arrow glyph and a signed number.

   Constraints honoured:
     * colours come from the product tokens (--bg --surface --fg --fg-2
       --fg-3 --line --accent --focus) with documented fallbacks, so the strip
       works inside this dark letterhead and inside a light reading page;
     * motion is a 140 ms opacity change and is removed under
       prefers-reduced-motion;
     * every interactive target is at least 44x44 CSS px;
     * the chart canvas is decorative-with-a-fallback: the same numbers are
       also printed as a text summary and a table, so nothing is chart-only.
   ========================================================================= */

/* The component's own scope. The product's tokens (css/tokens.css) are
   --paper / --canvas / --ink / --rule / --accent / --focus; each alias reads
   those and falls back to the mandated palette, so this file also works on a
   bare page with no tokens at all. Both themes come free: tokens.css re-points
   --paper/--ink/--rule under html[data-theme="dark"] and under a dark OS
   preference, and the fallback pair below follows the same switch. */
.cbn-markets {
  --mk-bg: var(--paper, #F7F5F2);
  --mk-surface: var(--canvas, #FFFFFF);
  --mk-fg: var(--ink, #1C1714);
  --mk-fg-2: var(--ink-soft, #514942);
  --mk-fg-3: var(--ink-faint, #6D6259);
  --mk-line: var(--rule, #D6CBC2);
  --mk-accent: var(--accent, #BC3E0D);
  --mk-focus: var(--focus, #D64221);
  /* Direction is carried by the arrow and the sign as well as the colour, so
     these two are the only place colour appears at all. */
  --mk-up: var(--success, #176B3A);
  --mk-down: var(--danger, #B42318);

  font-family: var(--font-ui, -apple-system, "Segoe UI", system-ui, sans-serif);
  color: var(--mk-fg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

html[data-theme="dark"] .cbn-markets,
html[data-mk-theme="dark"] .cbn-markets {
  --mk-bg: var(--paper, #15110E);
  --mk-surface: var(--canvas, #1E1915);
  --mk-fg: var(--ink, #F3EEE9);
  --mk-fg-2: var(--ink-soft, #C9BFB6);
  --mk-fg-3: var(--ink-faint, #9F948A);
  --mk-line: var(--rule, #3A3129);
  --mk-accent: var(--accent, #FA8054);
  --mk-focus: var(--focus, #FF9C6B);
  --mk-up: var(--success, #4ADE80);
  --mk-down: var(--danger, #FF7B72);
}

/* ---------------------------------------------------------------- the strip */

.mk-tape {
  border-bottom: 1px solid var(--mk-line);
  background: var(--mk-bg);
  /* Same measure as the masthead/toolbar bands it sits between. */
  width: 100%;
}

/* The band's reserved box, shipped in index.html as `<div class="mk-slot"
   data-mk-slot>` right after the masthead. js/markets.js creates the strip AFTER
   first paint; if the strip is INSERTED between the masthead and the navigation,
   the whole page below it moves once by the band's whole height — measured
   2026-11-10 on the lane's own rig (390x844 dpr3, Fast-3G, 4x CPU): the band
   arrived as `main 362+482 -> 468+376`, one entry worth 0.1524 of a 0.1838 CLS.
   With the box present, filling it is a paint inside a box that already exists.
   The numbers are the MEASURED filled heights, not a guess: 135 px at 390 (the
   caption wraps to two rows and the scroller is 86 px) and 87 px at 1440, kept
   one hair under so a day with no quote movement cannot grow the page. */
.mk-slot { min-height: 8.4rem; }
@media (min-width: 761px) { .mk-slot { min-height: 5.4rem; } }
/* NOTE: the phone rule that hides this slot ON THE FEED sits after the route
   block above, so this file's first `.mk-slot … display:none` rule is still the
   detail-route one that ui_polish_20261116.test.mjs pins. */
/* On the instrument route and on the ops/digest surfaces the feed is not the
   page, and an empty reserved band above a full-screen view is a blank strip.
   THE STORY ROUTE IS THE SAME CASE, and was the widest one: measured live
   2026-11-16 at 390x844, `#/item/...` rendered the band at 313px (nine quotes in
   a 3x3 phone table) above the article, so the story's own <h1> began at y=720
   of an 844 first screen — 85% of the viewport was another page's furniture.
   Below 1120px js/markets.js moves the one tape node into the feed host after the
   lead; a story has no feed host, so the tape stayed in the slot at full height.
   The band is the FEED's context, so it is not drawn on a story. */
html.mk-route .mk-slot,
html[data-route="ops"] .mk-slot,
html[data-route="digest"] .mk-slot,
html[data-route="detail"] .mk-slot { min-height: 0; display: none; }

/* Below 1120px js/markets.js moves the single tape node into the feed host after
   the lead ON THE FEED (FEED_ORDER + a host), sets [data-mk-moved] and empties
   this slot. There the 135px reservation was a lie: measured live 2026-11-17 at
   390, `main` y 341 -> 206, a -135px slide worth 0.1306 of the feed's 0.1433
   CLS. Zeroing it everywhere was the wrong fix — #/search keeps the tape in the
   slot and re-grew it from 0 (CLS 0.148 -> 0.375) — so the rule is scoped to the
   feed route via `data-mk-feed`, which index.html sets BEFORE first paint and
   app.js keeps true on every route change. `display: none` rather than just
   min-height: 0 because markets.js appends the tape into the slot FIRST, then
   relocates it, so the slot took the tape's 135px and gave it back (`main` y 206
   -> 342 -> 206). The slot is never the tape's home on the feed at phone width. */
@media (width < 1120px) {
  html[data-mk-feed] .mk-slot { min-height: 0; display: none; }
}

/* The band's hairline runs the full width; its contents sit on the page's own
   measure and gutters, so the first instrument lines up with the wordmark and
   the last with the search field.

   Two rows, at EVERY width: the caption above, the quotes below. Side by side,
   the caption is 300-312px of a 1040px measure (measured 1440, en and zh), and
   that is what pushed the last instruments off the band: the quote row had
   717px for nine ticks that need 837, so "S&P 500 proxy" was cut mid-label and
   Bitcoin was not shown at all. Under the caption the same nine ticks fit
   1440, 1280 and 1024 with room left over, so the band has nothing to scroll
   and nothing to fade — and a band that never scrolls cannot clip a value. */
.mk-tape__inner {
  max-width: var(--page, 1120px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0 var(--pad-r, 1rem) 0 var(--pad-l, 1rem);
}

.mk-tape__head {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.1rem 0.55rem;
  flex: none;
  padding: 0.44rem 0 0.3rem;
  min-width: 0;
}

.mk-tape__title {
  margin: 0;
  font-size: var(--fs-micro, 0.75rem);
  color: var(--mk-fg);
}

.mk-tape__asof {
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
  margin: 0;
  font-size: var(--fs-micro, 0.75rem);
  /* Hallmark gate 67, and this is the line that proves it. It is the band's
     provenance sentence — "as of 9 Nov 2026 – 12 Nov 2026 · delayed · 1 older" —
     set at 12px. It carried 0.06em, measured at 0.72px on the live site. The
     zh-Hans edition renders it as "数据时间 2026年11月9日 – 2026年11月12日 · 延时 ·
     1 项旧数据": a tracked Latin label is a style, a tracked Han label opens a
     gap inside a word, and CJK has no inter-word space to absorb it. The
     tracking goes in both editions; the mono face stays, because these are
     dates and figures, which gate 64 exempts. */
  letter-spacing: 0;
  color: var(--mk-fg-3);
  /* Wraps, never ellipsized: the provenance sentence is the one thing on this
     band a reader must be able to finish ("2 older" cut in half is a lie about
     how many rows are old). */
  white-space: normal;
  overflow-wrap: break-word;
}

/* The band's freshness indicator — one state dot + one word, at the FRONT of the caption
   paragraph. It is an inline box inside that <p>, not a new flex item in the head, so it
   adds no head height and cannot push the band's reserved space; its nowrap keeps the
   word whole while the surrounding sentence still wraps. The dot is colour ONLY and
   aria-hidden; the WORD carries the state, so it reads without colour vision and in
   either edition. */
.mk-fresh {
  display: inline-flex;
  align-items: baseline;
  gap: 0.3em;
  margin-right: 0.4em;
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
  font-size: var(--fs-micro, 0.75rem);
  color: var(--mk-fg-2);
  white-space: nowrap;
}
.mk-fresh__dot {
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--mk-fg-3);
  display: inline-block;
  flex: none;
  align-self: center;
}
.mk-fresh__word { white-space: nowrap; }
.mk-fresh[data-mk-fresh="delayed"] .mk-fresh__dot { background: var(--mk-fg-3); }
.mk-fresh[data-mk-fresh="stale"] .mk-fresh__dot { background: var(--mk-accent); }
.mk-fresh[data-mk-fresh="offline"] .mk-fresh__dot { background: var(--mk-down); }
.mk-fresh[data-mk-fresh="unavailable"] .mk-fresh__dot { background: var(--mk-fg-3); }
/* The two non-routine states also tint the WORD — never the dot alone — so a change is
   noticeable at a glance; the words themselves still say the state for a reader who
   cannot see colour. */
.mk-fresh[data-mk-fresh="stale"] { color: var(--mk-accent); }
.mk-fresh[data-mk-fresh="offline"] { color: var(--mk-down); }

.mk-tape__scroller {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  /* No overflow at desktop widths (see the note on .mk-tape__inner); below
     1000px the grid takes over and there is nothing to scroll either. The
     fade and the snap are gone with the scrolling, and nothing can be cut at
     the edge of a box that does not cut. */
  overflow: visible;
  border-top: 1px solid var(--mk-line);
  flex: 1 1 auto;
  min-width: 0;
  min-height: 5.4rem;
  /* The quotes are fetched AFTER this band is mounted (js/markets.js mounts the strip,
     then asks /v1/site/markets). An empty scroller is 1px tall; a filled one is the
     height of a tick. On the measured page (tx-nj3 2026-11-09, 390x844, Fast-3G, 4x CPU
     throttle) the band grew 1px -> 86px at 5.5 s and pushed the whole feed down; that
     single entry was the page's entire CLS (0.1524). Reserve one row here. In rem, so a
     reader's text size scales the reserve together with the tick it has to hold. */
  min-height: 5.4rem;
}


.mk-tick {
  display: flex;
  flex-direction: column;
  /* TOP-aligned, not centred. The cells of one row stretch to the tallest cell, and
     exactly one row of the catalogue is taller than its neighbours (Brent carries an
     "old" chip under the period chip). Centring moved that tick's own label, price and
     change UP by 11px against the other eight — measured 2026-11-11 at 1440 on the
     closed band: `brent label 181..199` against `eurusd 192..210`, one row of a
     nine-column table printed 11px out of line. Starting every tick at the top puts
     the first three lines of every cell on the same baselines and lets the extra chip
     hang below them, which is what a table does. */
  justify-content: flex-start;
  gap: 0.1rem;
  /* Share the band evenly, never shrink below the words inside: a shrunken
     tick is a clipped price. Wrap rather than spill if a future instrument or a
     larger root font makes the row longer than the measure. */
  flex: 1 1 auto;
  min-width: max-content;
  min-height: 44px;
  /* Hallmark gate 44b, measured on the live site 2026-11-12 at 1280x800. The
     lead's headline, its sentence and its action must all be inside the first
     screen. Without the picture, the lead story is the "material above the
     fold" — and it was not: the deck ended at y=879 and the action at y=937 on
     an 800px screen, so a reader's first screen showed chrome and nine quotes
     and not one finishable sentence of reporting.
     The band is nine cells and 153px tall, and each cell spent 12.8px of it on
     cell padding alone (measured: ".mk-tick__label 181..199, price 200..219,
     chg 221..242" inside a cell at 174..294). Padding goes back to the 4px
     scale the rest of the product uses (gate 24b read it as 0.4rem, off the
     scale); the 8px saved is 8px the lead gets. Nothing moves sideways: the
     horizontal padding is unchanged, so every cell keeps its measure, and the
     44px minimum target stays. */
  padding: 0.25rem 0.42rem;
  border-right: 1px solid var(--mk-line);
  color: inherit;
  text-decoration: none;
  transition: background-color 140ms ease;
}
.mk-tick:last-child { border-right: 0; }

@media (hover: hover) and (pointer: fine) {
  .mk-tick:hover { background: color-mix(in srgb, var(--mk-fg) 7%, transparent); }
}
.mk-tick:focus-visible {
  outline: 2px solid var(--mk-focus);
  outline-offset: -2px;
}

.mk-tick__label {
  font-size: var(--fs-micro, 0.75rem);
  color: var(--mk-fg-2);
  white-space: nowrap;
}

.mk-tick__row {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  white-space: nowrap;
}

.mk-tick__price {
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.775rem;
  letter-spacing: 0.005em;
  color: var(--mk-fg);
}

.mk-tick__spark {
  display: block;
  width: 28px;
  height: 12px;
  align-self: center;
  color: var(--mk-fg-3); /* neutral: the sparkline never carries direction colour */
  overflow: visible;
}
.mk-tick__spark polyline {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.25;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.mk-tick__chg {
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
  font-size: var(--fs-meta, 0.875rem);
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.mk-tick__chg--up { color: var(--mk-up); }
.mk-tick__chg--down { color: var(--mk-down); }
.mk-tick__chg--flat { color: var(--mk-fg-3); }

/* A row whose newest published observation is older than its source's own cadence.
   It is a real observation, so it is shown; the word is the label, and the title
   carries the exact age. Never colour alone: the tick also says "old" in the
   reader's language. */
.mk-tick__stale {
  font-size: var(--fs-micro, 0.75rem);
  color: var(--mk-fg-3);
  border: 1px solid var(--mk-line);
  border-radius: 2px;
  padding: 0 0.2em;
  align-self: flex-start;
  margin-top: 0.1rem;
}

/* A row whose source publishes slower than daily prints its frequency and the period it
   describes ("Monthly · Oct 2026") in the tick itself, not only in a tooltip. Measured
   live 2026-11-11: the OECD share-price index sat in the band with a 70-day-old value and
   the same shape as that morning's FX, and the only visible hint was a chip reading "old".
   Same type as the stale chip so the two read as one statement about the row. */
.mk-tick__when {
  font-size: var(--fs-micro, 0.75rem);
  color: var(--mk-fg-2);
  border: 1px solid var(--mk-line);
  border-radius: 2px;
  padding: 0 0.2em;
  align-self: flex-start;
  margin-top: 0.1rem;
  /* The chip is TWO spans — the state or cadence word, then the date — and this is the
     whole reason: measured 2026-11-11, a phone cell is 119px wide and a desktop (9-column)
     cell 109px, while "Closed · 10 Nov 2026" is 125px and "每日 · 2026年11月3日" 123px. With
     `nowrap` those chips painted past their own cell's rule, over the neighbour: a
     page-level overflow probe stays green, because the page does not scroll and nothing is
     clipped. `flex-wrap` on the two spans gives exactly ONE break opportunity, between the
     word and the date, so the word stays whole on the first line and the date whole on the
     second; `max-width: 100%` keeps the chip inside the cell that a wrapped line needs. */
  display: flex;
  flex-wrap: wrap;
  max-width: 100%;
  white-space: normal;
}

/* The same slot, one stronger weight, for a row the API reports as CLOSED. It is not a
   louder colour — the word "Closed" / "休市" is the carrier, and colour is never the only
   signal on this band — but it is set in the primary ink on a filled ground so the eye
   reads "this is Friday's close" before it reads the number, on a row that would
   otherwise look exactly like a live quote. Measured 2026-11-11: a Friday fix read on a
   Saturday is one day old, so no freshness marker fired at all. */
.mk-tick__when--closed {
  color: var(--mk-fg);
  background: color-mix(in srgb, var(--mk-fg) 6%, transparent);
  border-color: color-mix(in srgb, var(--mk-fg) 28%, var(--mk-line));
  font-weight: 600;
}

/* On the phone the box chrome is what decides the BAND's height, not the words.
   Measured on the live page 2026-11-14 at 390x844: a chip's text is 99-105px and
   the cell offers around 102px of inner width, so the 1px border plus 2.4px of
   side padding was the 4px that pushed EVERY state row onto a second line —
   nine rows, nine wraps, a 364.6px band, and the lead headline at 943.8px,
   below an 844px fold. The weight and the filled ground are the signal the
   comment above argues for, and both survive; only the border and the padding
   go, which is what the slow-cadence row already looks like. Measured after:
   one line per row, band 304.6px, lead headline 883.8px — still 39.8px BELOW
   the 844px fold, not above it. This rule buys back 40px; it does not move the
   lead into the first screen. */
@media (max-width: 999px) {
  .mk-tick__when { padding: 0; border: 0; }
}
.mk-tick__when-state,
.mk-tick__when-date { white-space: nowrap; }

/* The arrow is decorative: the signed number beside it is the real signal. */
.mk-tick__arrow {
  font-size: 0.72em;
  margin-right: 0.18em;
  vertical-align: 0.05em;
}

.mk-tape__empty {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0.45rem 0;
  font-size: var(--fs-label, 0.8125rem);
  /* Hallmark gate 67: 0 in markets.css, as design_gate.test.mjs requires. The
     module lane's 0.02em is under the 0.03em ceiling but the sheet is held at 0. */
  letter-spacing: 0;
  color: var(--mk-fg-3);
  /* A state line is a sentence, not a quote: it reads at a measure and wraps like prose.
     The grid span that keeps it out of ONE cell of the narrow quote table lives inside
     the <=999px block, where that grid exists (see .mk-tape__empty there). */
  max-width: var(--measure, 34rem);
  line-height: 1.5;
}

/* ------------------------------------------------------------------ overview */

/* The route view replaces the feed shell (html.mk-route hides [data-root]), so
   it must carry the page's own gutters itself — without them the headline and
   the chart run into the screen edge on a phone, measured at 390. */
.mk {
  max-width: calc(var(--page, 1120px) - 2 * 0px);
  margin: 0 auto;
  padding: clamp(1.1rem, 3vw, 2.4rem) var(--pad-r, 1rem) clamp(2rem, 5vw, 3.5rem) var(--pad-l, 1rem);
  color: var(--mk-fg);
  overflow-x: clip;
}

.mk__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  /* zh "← 首页" measures 42px wide at every width: the token is square and a
     short label must not fall under it (n3_tap tN38, coarse pointer). */
  min-width: var(--tap, 44px);
  font-size: var(--fs-label, 0.8125rem);
  color: var(--mk-fg-3);
  text-decoration: none;
}
.mk__back:hover { color: var(--mk-fg); }
.mk__back:focus-visible { outline: 2px solid var(--mk-focus); outline-offset: 3px; }

.mk__head { padding-bottom: 1rem; border-bottom: 1px solid var(--mk-line); }

.mk__eyebrow {
  margin: 0 0 0.4rem;
  font-size: var(--fs-label, 0.8125rem);
  color: var(--mk-fg-3);
}

.mk__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display, "Iowan Old Style", Palatino, Georgia, serif);
  font-weight: 400;
  font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.mk__quote {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.55rem 0.9rem;
  margin: 0 0 0.35rem;
}

.mk__price {
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
  font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2.05rem);
  letter-spacing: -0.01em;
}

.mk__chg {
  font-size: 0.95rem;
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
}
.mk__chg--up { color: var(--mk-up); }
.mk__chg--down { color: var(--mk-down); }
.mk__chg--flat { color: var(--mk-fg-3); }
.mk__chg .mk-tick__arrow { font-size: 0.8em; }

.mk__meta {
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
  margin: 0;
  font-size: var(--fs-label, 0.8125rem);
  /* Hallmark gate 67: see .mk-tape__empty. Mono stays (these lines are data,
     which gate 64 exempts), the tracking does not. */
  letter-spacing: 0;
  color: var(--mk-fg-3);
}

/* -------------------------------------------------------------------- chart */

.mk__chartwrap { margin-top: 1.4rem; }

.mk__ranges {
  display: flex;
  gap: 0;
  border: 1px solid var(--mk-line);
  width: max-content;
  margin-bottom: 0.7rem;
}

.mk__range {
  appearance: none;
  background: none;
  border: 0;
  border-right: 1px solid var(--mk-line);
  color: var(--mk-fg-3);
  font: inherit;
  font-size: var(--fs-label, 0.8125rem);
  /* Hallmark gate 67: a 0.12em run is the widest tracking on the product. The
     control keeps its 44px target and its 52px min-width, so nothing about it
     shrinks with the tracking. */
  letter-spacing: 0;
  min-width: 52px;
  min-height: 44px;
  padding: 0 0.7rem;
  cursor: pointer;
  transition: color 140ms ease, background-color 140ms ease;
}
.mk__range:last-child { border-right: 0; }
.mk__range[aria-pressed="true"] {
  color: var(--mk-fg);
  box-shadow: inset 0 -2px 0 var(--mk-accent);
}
@media (hover: hover) and (pointer: fine) {
  .mk__range:hover { color: var(--mk-fg); }
}
.mk__range:focus-visible { outline: 2px solid var(--mk-focus); outline-offset: -2px; }

.mk__canvas {
  position: relative;
  max-width: 100%;
  height: clamp(220px, 34vw, 340px);
  border-top: 1px solid var(--mk-line);
  border-bottom: 1px solid var(--mk-line);
  background: var(--mk-surface);
}
.mk__canvas > div { position: absolute; inset: 0; }

.mk__canvas[hidden] + .mk__chart-credit,
.mk__canvas:empty + .mk__chart-credit { display: none; }
.mk__chart-credit a { color: inherit; text-underline-offset: 2px; }

.mk__chart-credit,
.mk__note {
  margin: 0.6rem 0 0;
  font-size: var(--fs-label, 0.8125rem);
  /* Hallmark gate 67: see .mk-tape__empty. */
  letter-spacing: 0;
  color: var(--mk-fg-3);
}

.mk__fallback {
  margin: 0.8rem 0 0;
  font-size: var(--fs-label, 0.8125rem);
  color: var(--mk-fg-2);
}
.mk__fallback svg { display: block; width: 100%; height: 90px; color: var(--mk-fg-3); }
.mk__fallback svg polyline { fill: none; stroke: currentColor; stroke-width: 1.2; }

/* A chart is never the only way to read the series. */
.mk__table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.8rem;
  font-size: var(--fs-label, 0.8125rem);
  color: var(--mk-fg-2);
}
.mk__table caption {
  text-align: left;
  color: var(--mk-fg-3);
  font-size: var(--fs-label, 0.8125rem);
  padding-bottom: 0.4rem;
}
.mk__table th,
.mk__table td {
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
  text-align: right;
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid var(--mk-line);
  font-weight: 400;
}
.mk__table th:first-child,
.mk__table td:first-child { text-align: left; }

.mk__table-wrap[hidden] { display: none; }
/* `hidden` is a UA rule, not an author choice: a class that sets `display` defeats it.
   Measured in the 2026-11-14 unavailable-state shot: a failed series still offered
   "Show the data table" because `.mk__toggle` below sets `display: inline-flex`, and
   no table existed to open. Same rule for any control this module hides. */
.mk__toggle[hidden] { display: none; }

.mk__toggle {
  appearance: none;
  background: none;
  border: 0;
  color: var(--mk-fg-2);
  font: inherit;
  font-size: var(--fs-label, 0.8125rem);
  /* No rule under the label. A border-bottom on an inline-flex box printed a
     stub that ended mid-sentence ("Show the data table" over a 140px hairline)
     and read as a broken decoration rather than a control. The chevron in the
     copy is the affordance; the 44px box is the target. */
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0;
  cursor: pointer;
}
.mk__toggle::after {
  content: "";
  width: 0.42em;
  height: 0.42em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-0.12em) rotate(45deg);
  transition: transform 160ms ease;
}
.mk__toggle[aria-expanded="true"]::after { transform: translateY(0.08em) rotate(-135deg); }
@media (prefers-reduced-motion: reduce) { .mk__toggle::after { transition: none; } }
.mk__toggle:hover { color: var(--mk-fg); }
.mk__toggle:focus-visible { outline: 2px solid var(--mk-focus); outline-offset: 3px; }

/* ------------------------------------------------------------------- stories */

.mk__stories {
  margin-top: clamp(1.6rem, 3.4vw, 2.6rem);
  padding-top: 1rem;
  border-top: 3px solid var(--mk-accent);
}

.mk__section {
  margin: 0 0 0.8rem;
  font-size: var(--fs-label, 0.8125rem);
  color: var(--mk-fg-3);
}

.mk__list { list-style: none; margin: 0; padding: 0; }

.mk__story {
  display: block;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--mk-line);
  text-decoration: none;
  color: inherit;
  min-height: 44px;
}
.mk__story:focus-visible { outline: 2px solid var(--mk-focus); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .mk__story:hover .mk__story-title { color: var(--mk-accent); }
}

.mk__story-title {
  display: block;
  font-family: var(--font-display, "Iowan Old Style", Palatino, Georgia, serif);
  font-size: 1.04rem;
  line-height: 1.3;
  color: var(--mk-fg);
  transition: color 140ms ease;
}

.mk__story-meta {
  display: block;
  margin-top: 0.25rem;
  font-size: var(--fs-label, 0.8125rem);
  color: var(--mk-fg-3);
}

.mk__more {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 0.4rem;
  font-size: var(--fs-label, 0.8125rem);
  color: var(--mk-fg-3);
  text-decoration: none;
}
.mk__more:hover { color: var(--mk-fg); }

/* The stories section's three non-data states (loading, empty, unavailable), plus the
   one action an empty answer owes the reader. They are rows of the same list, so the
   section keeps its rule and its rhythm instead of collapsing when it has no story:
   measured live 2026-11-12, an instrument with no match printed one bare note and the
   section's 3px accent rule over a 20px gap read as a rendering fault, not an answer. */
.mk__story-state { list-style: none; }
.mk__story-state .mk__note {
  margin: 0.85rem 0 0;
  max-width: var(--measure, 34rem);
  letter-spacing: 0;
  line-height: 1.5;
  color: var(--mk-fg-2);
}
/* A loading line pulses only where the reader has not asked for less motion; the
   text itself carries the meaning, so nothing is lost when it is still. */
.mk__story-state[data-mk-story-state="loading"] .mk__note { animation: mk-story-pulse 1.6s ease-in-out infinite; }
@keyframes mk-story-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.mk__story-state[data-mk-story-state="error"] .mk__note { color: var(--mk-fg-3); }

/* The escape hatch under an empty answer: a 44px target, an underline the reader can
   see, and the accent only on hover so it does not compete with the page's headings. */
.mk__note-action {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: 0.15rem;
  font-size: var(--fs-label, 0.8125rem);
  color: var(--mk-fg);
  text-decoration: underline;
  text-decoration-color: var(--mk-line);
  text-underline-offset: 0.22em;
  transition: color 140ms ease, text-decoration-color 140ms ease;
}
.mk__note-action:focus-visible { outline: 2px solid var(--mk-focus); outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .mk__note-action:hover { color: var(--mk-accent); text-decoration-color: var(--mk-accent); }
}

.mk__source {
  margin-top: 2rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--mk-line);
  font-size: var(--fs-label, 0.8125rem);
  line-height: 1.6;
  color: var(--mk-fg-3);
}
.mk__source a {
  color: var(--mk-fg-2);
  text-decoration: underline;
  text-underline-offset: 2px;
  /* The source link sits inside the closing sentence, like a citation; vertical
     padding on the inline box takes the hit area past the 24px target minimum
     (measured 37x12 by the route gate) without moving the line. */
  padding-block: 0.4rem;
}
.mk__source a:focus-visible { outline: 2px solid var(--mk-focus); outline-offset: 2px; }

/* -------------------------------------------------------- instrument index */

.mk__index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0;
  margin-top: 1.2rem;
  border-top: 1px solid var(--mk-line);
}

.mk__index-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem 0.7rem 0;
  border-bottom: 1px solid var(--mk-line);
  text-decoration: none;
  color: inherit;
  min-height: 44px;
  /* The row is a label, a price and a signed change on ONE line, and the price
     and change must never leave the row. Measured live 2026-11-12 on the
     production build at 390x844 (coarse pointer): every one of the nine rows
     painted its price and change PAST the page edge — `EUR/USD` row right 374,
     price right 417, change right 486 on a 390 viewport — and the container
     clipped them (`.cbn-markets` has overflow-x: clip), so the reader saw
     "1.1" and a red sliver instead of "1.1127 ▼-0.78%". At 768 three rows did
     the same, and at 1024 the OECD row's change ran to 1069.

     Cause: `.mk-tick__label` is `white-space: nowrap` and, inside the tape,
     `flex: 1 0 100%`; the index row is the same three spans but WITHOUT any
     flex basis on the label, so the label's nowrap intrinsic width won the
     space and pushed the price/change out. The page-level probe stayed green
     because `overflow-x: clip` means nothing ever scrolls — the text is simply
     cut off.

     Fix: let the LABEL be the part that shrinks and wraps, and pin the two
     numbers. The row grows in height (44px floor stays) rather than losing a
     digit. */
  flex-wrap: wrap;
}

.mk__index-row .mk-tick__label {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.mk__index-row .mk-tick__price,
.mk__index-row .mk-tick__chg { flex: 0 0 auto; }
.mk__index-row:focus-visible { outline: 2px solid var(--mk-focus); outline-offset: 2px; }

/* ------------------------------------------------------- article chart card */

.mk-card {
  margin: 0 0 1rem;
  border-top: 3px solid var(--mk-accent);
  padding-top: 0.6rem;
}

.mk-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.15rem;
}

.mk-card__label {
  font-size: var(--fs-label, 0.8125rem);
  color: var(--mk-fg-3);
}

.mk-card__sym {
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 0.78rem;
  /* Hallmark gate 67: a ticker symbol is a value, so the mono stays; the
     tracking was decoration on top of it. */
  letter-spacing: 0;
  color: var(--mk-fg);
}

.mk-card__row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.mk-card__price {
  font-size: 1.02rem;
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
}
.mk-card__chg {
  font-size: 0.76rem;
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
}
.mk-card__chg--up { color: var(--mk-up); }
.mk-card__chg--down { color: var(--mk-down); }
.mk-card__chg--flat { color: var(--mk-fg-3); }

.mk-card__chart {
  display: block;
  width: 100%;
  height: 54px;
  color: var(--mk-fg-3);
}
.mk-card__chart polyline {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.mk-card__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--fs-label, 0.8125rem);
  color: var(--mk-fg-3);
  text-decoration: none;
}
.mk-card__link:hover { color: var(--mk-fg); }
.mk-card__link:focus-visible { outline: 2px solid var(--mk-focus); outline-offset: 3px; }

.mk-card__asof {
  font-family: var(--font-mono, ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace);
  margin: 0;
  font-size: var(--fs-micro, 0.75rem);
  /* Hallmark gate 67: see .mk-tape__empty. */
  letter-spacing: 0;
  color: var(--mk-fg-3);
}

/* --------------------------------------------------------------- utilities */

.mk-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* While the instrument view is open, the feed shell behind it is not rendered.
   This is how the view takes over a route without editing app.js: app.js still
   paints its own shell, and the shell is simply not shown. */
html.mk-route [data-root] { display: none; }
html.mk-route .filters { display: none; }

@media (prefers-reduced-motion: reduce) {
  .mk-tick,
  .mk__range,
  .mk__story-title,
  .mk__note-action,
  .mk-card__link { transition: none; }
  .mk__story-state[data-mk-story-state="loading"] .mk__note { animation: none; }
}

/* Below 1000px nine quotes no longer fit one row inside the measure (measured
   1024: 837px of ticks in a 958px row after the caption moved above; at 900 the
   row is 842px, and a CJK label or a 4-digit price eats that slack). Rather
   than hide four instruments behind a horizontal scroll — which is the clipping
   this strip was reported for — the tape becomes a 3-column quote table: nine
   instruments, three rows of three, every value whole and nothing to swipe.
   Nine is exactly 3x3, so the last row is never ragged for the shipped
   catalogue. */
@media (max-width: 999px) {
  /* The 3-column quote table needs BOTH rules in one place: the grid (below
     1000px) and the caption row's reserved height (which the narrow layout
     needs so its title/caption pair cannot reflow when the quotes land). The
     reserved height used to live in a `max-width: 760px` block; at 999 the band
     is already a grid, the caption is already above the quotes, so the same
     reserve applies over the whole 1000px-and-under range. markets_layout.test.mjs
     reads the reserve from this block's own media context. */
  /* The empty/failed sentence is a single <p> inside this grid, so with no span it became
     ONE cell — about 110px at 390 — and broke into a seven-line column clipped by the
     band's bottom edge. Measured in the 390 shot 2026-11-12: "Market data is / unavailable
     / right now. No / number is / shown rather / th…". It answers for the whole row, so it
     spans the row. Every numeric probe before that shot read overflow=0, because the PAGE
     did not scroll. */
  .mk-tape__empty { grid-column: 1 / -1; }
  .mk-tape__scroller {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--mk-line);
    align-items: stretch;
  }
  .mk-tape__head {
    flex-direction: row;
    align-items: baseline;
    /* The desktop rule centres the head vertically in a column; read as a ROW
       that same `center` centres each wrapped line horizontally, so a phone
       printed "Markets" centred over a caption that starts at the left edge.
       Measured in the 360 shot, t5. */
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 0 0.4rem;
    margin-right: 0;
    border-right: 0;
    min-width: 0;
    flex-wrap: wrap;
    /* The caption is the wider half of this row, so at 390 the pair wraps onto two
       rows (title / caption) whether or not the quotes have arrived: measured 48px
       in both states. Reserve it, or the band's own height changes when the quotes
       land and every story below it moves — the page's whole CLS before this rule. */
    min-height: 3rem;
  }
  /* The visible "Markets" label is redundant on a phone: the band sits under the
     masthead and above a filters row that already carries a Markets chip, every
     row names its own instrument, and the section keeps its aria-label. Dropping
     it frees the first line of the caption, so the honest sentence — the date
     span, "delayed", and the count of older rows — prints in two lines instead
     of three and is never truncated. Measured at 390: head 74px -> 44px, and the
     whole tape 173px -> ~90px once the tick is two rows (below). */
  .mk-tape__title { display: none; }
  .mk-tape__asof {
    white-space: normal;
    line-height: 1.35;
  }
  .mk-tick {
    border-right: 1px solid var(--mk-line);
    /* Row rules between rows only: the band's own bottom hairline closes the
       table, and a second line under the last row would read as a 2px rule. */
    border-bottom: 1px solid var(--mk-line);
  }
  .mk-tick:nth-child(3n) { border-right: 0; }
  .mk-tick:nth-last-child(-n+3) { border-bottom: 0; }
  /* Density: the sparkline is the first thing to go. It is 28px of decoration
     per instrument and the same information is one tap away on the instrument
     page. */
  .mk-tick { padding: 0.5rem 0.55rem; }
  .mk-tick__spark { display: none; }
  .mk-tick__price { font-size: 0.8rem; }
  /* Two lines where they fit, three where they cannot: label above, then the
     price and its signed change side by side. Measured 2026-11-10 on the merged
     tree: price + change need 107px of a 91px cell at 360 (101px at 390), so a
     fixed two-column grid — whose `auto` track cannot shrink below the nowrap
     price — painted 8 of 9 pair-shapes across their cell border while every
     page-level overflow probe stayed green (the page has no scroll and the text
     is not clipped; it is one cell painting into the next). Flex-wrap instead:
     the pair sits on one line at 430 and up, and the change drops to its own
     line at 360/390 rather than cross the rule. A CJK label wraps inside the
     cell the same way (measured 390 zh: 美国股价指数（2015=100）). */
  .mk-tick {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    /* START, not the default `stretch` for a wrapping flex container. A cell is as
       tall as the tallest tick in its row, and one tick per row needs a fourth line
       (a wrapped CJK label, or "Monthly · Oct 2026" breaking in two). Under `stretch`
       the extra height is shared out as leading BETWEEN the lines of every cell in
       that row, so the same table printed its prices at 149, 231, 344 and 353 px
       down the page — measured 2026-11-11 at 390: `us10y label 321..335` then
       `price 353..369`, an 18px hole under the label where the tick above had 1px.
       Packing to the start keeps price-on-the-line-below-label true in every cell
       and lets the fourth line sit where it belongs, at the bottom. */
    align-content: flex-start;
    justify-content: flex-start;
    column-gap: 0.4rem;
    row-gap: 0.05rem;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .mk-tick__label {
    flex: 1 0 100%;
    white-space: normal;
    /* CJK has no spaces to break on; without this the whole run is one word. */
    word-break: break-word;
    line-height: 1.25;
  }
  .mk-tick__row { flex: 0 1 auto; min-width: 0; flex-wrap: wrap; }
  .mk-tick__chg { flex: 0 1 auto; }
  /* The chip hugs its word. It used to carry grid-column 1/-1 (own row); as a
     flex item a 100% basis would stretch its hairline border across the whole
     cell and read as an empty input — measured 360 shot, t6. */
  .mk-tick__stale { flex: 0 0 auto; }
  .mk-tick__when { flex: 0 0 auto; }
  .mk__table { font-size: var(--fs-label, 0.8125rem); }
}

/* The third line is honest but it is 20px an instrument; below 430 the band
   would take 281px of a 360 first screen. Buy the space back from leading and
   padding rather than from the words: measured 11-10, 281 -> see shot. */
@media (max-width: 430px) {
  /* The side padding is on the spacing scale. It was a bare 0.5rem, which read as
     off-scale padding (gate 24b's exact complaint) AND cost the cell 4px it needed
     to hold a one-line closed chip: measured live 2026-11-14, 0.5rem left 102px of
     inner width for a 104.9px chip, 0.25rem leaves 110px. */
  .mk-tick { padding: 0.34rem var(--sp-1); }
  .mk-tick__label,
  .mk-tick__price,
  .mk-tick__chg,
  .mk-tick__row { line-height: 1.2; }
}

/* The narrowest phones: a monthly figure lets the change wrap instead of leaving the cell.
   The OECD proxy prints "▼−0.47% MoM" — the basis word is part of the honest reading, because
   the same "−0.47%" beside a daily quote means a DAY's move. Measured on the live tree at
   320x700: that chip is 92.7px inside a 76px cell, so it painted 11.3px past the cell's right
   edge and 4px past its left, over the neighbouring instrument's rule. Nothing clipped it and
   the page did not scroll, which is why every page-level overflow probe stayed green.
   Below 341px the chip is allowed to wrap (it is a flex item, so the break falls between the
   percentage and the basis word), keeping 14px type: the alternative, 11px, is under
   `--fs-micro` which tokens.css calls "the smallest thing a reader must read". Measured after:
   every cell clean, page overflow 0, tick 140.6 -> 157.4px — and the whole 3-column row grows
   together, so the grid stays even. No value is dropped and the MoM basis still shows. */
@media (max-width: 340px) {
  .mk-tick__chg { white-space: normal; overflow-wrap: anywhere; }
}

.mk__calendar-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 600; text-underline-offset: .25em; }
