/* ==========================================================================
   IQ Xchange — live rate board
   Self-hosted fonts, no external requests. Logical properties keep the whole
   layout working in both RTL (Arabic) and LTR (English).
   ========================================================================== */

@font-face {
  font-family: "Manrope";
  src: url("fonts/manrope-latin.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Noto Kufi Arabic";
  src: url("fonts/noto-kufi-arabic.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #131313;
  --panel: #201f1f;
  --panel-2: #2a2a2a;
  --panel-3: #353534;
  --line: #4f4632;
  --gold: #f6c500;
  --gold-soft: #ffe5a0;
  --text: #e5e2e1;
  --muted: #d4c5ab;
  --down: #ffb4ab;
  --up: #7ee0a0;
  /* direction indicators are brighter than the flash tint: they stay on screen */
  --up-neon: #3dff8f;
  --down-neon: #ff4d63;

  /* Latin first, then the Arabic script face (Arabic + Sorani Kurdish — Noto
     Kufi carries ڕ ڵ ێ ۆ ە گ چ پ ژ), then Cyrillic, then CJK: every locale is
     covered without shipping a single extra font byte. */
  --font-head: "Manrope", "Noto Kufi Arabic", "Noto Sans", "Segoe UI", Roboto,
               "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  --font-body: "Inter", "Noto Kufi Arabic", "Noto Sans", "Segoe UI", Roboto,
               "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               "Noto Sans SC", "Source Han Sans SC", system-ui, Tahoma, sans-serif;

  --radius: 14px;
  --pad: clamp(1.1rem, 2.2vw, 1.9rem);
  --gap: clamp(0.9rem, 1.6vw, 1.5rem);
  --ticker-h: 68px;
}

/* Volt accent — the same board, lit fluorescent green instead of gold. Only the
   accent and the warm neutral tones move; the charcoal panels stay put so the
   layout, contrast and hierarchy read exactly the same. */
html[data-accent="volt"] {
  --gold: #c6ff00;
  --gold-soft: #ecffb0;
  --line: #3b4a1d;
  --muted: #c9d3b3;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* notched phones in landscape and the home indicator at the bottom */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, p, ul, li { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; }

/* several blocks are toggled from JS — keep `hidden` authoritative */
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 clamp(1rem, 3vw, 3rem);
  min-height: 84px;
  background: #131313;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 35%, transparent);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  font-family: var(--font-head);
  text-transform: uppercase;
}

.brand-mark {
  background: var(--gold);
  color: #131313;
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  letter-spacing: -0.02em;
}

.brand-name {
  color: var(--text);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.04em;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: clamp(0.6rem, 1.6vw, 1.4rem);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 10px;
  background: var(--panel-3);
  border: 1px solid color-mix(in srgb, var(--line) 45%, transparent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-soft);
  white-space: nowrap;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 50%, transparent);
  animation: pulse 2.4s ease-out infinite;
}

.live-pill[data-state="offline"] { color: var(--down); }
.live-pill[data-state="offline"] .live-dot { background: var(--down); animation: none; }
.live-pill[data-state="degraded"] { color: var(--muted); }
.live-pill[data-state="degraded"] .live-dot { background: var(--muted); animation: none; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 45%, transparent); }
  70% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.clock {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.clock svg { color: var(--gold-soft); opacity: 0.8; }

.clock time {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(1.1rem, 1.8vw, 1.4rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.lang-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 10px;
  color: var(--muted);
  transition: color 140ms ease, border-color 140ms ease;
}

.lang-switch .ico-globe { flex: none; opacity: 0.7; }
.lang-switch .ico-chev { flex: none; opacity: 0.55; }

/* A native select keeps six locales in one compact control and hands phones
   their own list instead of a wrapping bar of buttons. */
.lang-switch select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  touch-action: manipulation;
  /* a constant width keeps the header still while the name changes */
  width: 4.05rem;
  text-overflow: ellipsis;
}

/* the popup list is drawn by the platform; give it a readable surface anyway */
.lang-switch select option { background: #1b1b1b; color: var(--text); }

.lang-switch select:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 3px;
  border-radius: 5px;
}

.lang-switch:hover {
  color: var(--gold-soft);
  border-color: color-mix(in srgb, var(--line) 90%, transparent);
}

/* icon buttons (fullscreen / TV mode) */
.icon-btn {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  touch-action: manipulation;
  transition: color 140ms ease, border-color 140ms ease;
}

.icon-btn:hover { color: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 50%, transparent); }
.icon-btn:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

/* the swatch button carries a half circle in the live accent, so the header
   always shows which palette is on */
.icon-btn .ico-accent { fill: var(--gold); stroke: none; }

.icon-btn .ico-exit { display: none; }

body.tv .icon-btn { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 55%, transparent); }
body.tv .icon-btn .ico-expand { display: none; }
body.tv .icon-btn .ico-exit { display: inline; }

/* -------------------------------------------------------------------- page */
.page {
  flex: 1;
  padding: clamp(1.2rem, 2.6vw, 2.4rem) clamp(1rem, 3vw, 3rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2vw, 1.8rem);
  background: var(--panel);
}

.page-head { display: flex; flex-direction: column; gap: 0.35rem; }

.kicker {
  color: var(--muted);
  font-size: clamp(0.72rem, 1.1vw, 0.9rem);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.75;
}

.page-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.9rem, 3.4vw, 2.9rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: #fff;
}

.page-note {
  color: var(--muted);
  font-size: clamp(0.78rem, 1.1vw, 0.9rem);
  opacity: 0.72;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
}

.page-note-sep { opacity: 0.45; }
.updated { font-variant-numeric: tabular-nums; }

.feed-note {
  margin-top: 0.6rem;
  padding-inline-start: 0.7rem;
  border-inline-start: 2px solid color-mix(in srgb, var(--gold) 45%, transparent);
  color: var(--gold-soft);
  font-size: clamp(0.74rem, 1vw, 0.84rem);
  opacity: 0.85;
}

/* -------------------------------------------------------------------- grid */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  align-items: stretch;
}

.card {
  grid-column: span 4;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: var(--pad);
  background: var(--panel-2);
  border: 1px solid color-mix(in srgb, var(--line) 22%, transparent);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 190px;
}

.card-hero {
  grid-row: span 2;
  grid-column: span 4;
  background:
    linear-gradient(150deg, color-mix(in srgb, var(--gold-soft) 10%, transparent) 0%, transparent 55%),
    var(--panel-3);
  border-bottom: 4px solid var(--gold);
  justify-content: space-between;
}

.card-official {
  background: var(--panel);
  border-color: color-mix(in srgb, var(--line) 35%, transparent);
}

.card-list { justify-content: flex-start; gap: 0.7rem; }

.card-ghost {
  position: absolute;
  inset-block-end: -3rem;
  inset-inline-end: -3rem;
  width: 15rem;
  height: 15rem;
  color: var(--gold);
  opacity: 0.06;
  pointer-events: none;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.card-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  line-height: 1.15;
  color: #fff;
  letter-spacing: -0.02em;
}

.card-title-lg { font-size: clamp(1.7rem, 2.6vw, 2.3rem); font-weight: 800; }

.card-tag {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 12%, transparent);
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.card-official .card-tag {
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  color: var(--muted);
}

.tier-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
  white-space: nowrap;
  opacity: 0.85;
}

.tier-badge[data-tier="LOCAL"] {
  color: #131313;
  background: var(--gold);
  border-color: var(--gold);
}

/* Last known: still a real market price, just not from this moment. Outline
   instead of a filled tag, so a wall screen reads "market" and "current" as
   two different claims. */
.tier-badge[data-tier="LAST"] {
  color: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 60%, transparent);
  background: transparent;
  opacity: 1;
}

.card-body { display: flex; flex-direction: column; gap: 0.15rem; }

/* Two sided quote. The channel this board is fed from publishes one dealt
   price, so the pair is written the way a sarrafa writes it: buy on top, sell
   underneath, each side owning half the card height — label first, figure
   under it — and the figure taking the whole width of that half. Sizing off
   the card (cqw, not vw) is what makes the digits fill the cell at any width:
   the board is a grid of cards, so the card is the unit a number has to fit. */
.card-quote { container-type: inline-size; }

.card-body.quote { flex: 1; min-height: 0; gap: 0; }

.quote-row {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 0.1rem;
  padding-block: 0.35rem;
  /* a label can never push a figure out of its half of the card */
  overflow: hidden;
}

.quote-row + .quote-row {
  border-block-start: 1px solid color-mix(in srgb, var(--line) 28%, transparent);
}

.quote-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-height: 1.1em;
  white-space: nowrap;
}

.quote-side {
  font-family: var(--font-body);
  font-size: clamp(0.64rem, 2.6cqw, 1rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.85;
}

/* The figure is sized by the card, not the viewport: digits run about 3.6em,
   so 20cqw is the most a seven digit number can take and still clear the
   card's padding (the content box is 0.87 of the card). The hero takes it. */
.quote-value {
  font-size: clamp(1.7rem, 15cqw, 4.2rem);
  line-height: 0.92;
  white-space: nowrap;
}

.card-hero .quote-value { font-size: clamp(2rem, 20cqw, 6.4rem); }

/* The small change readout beside each side label: arrow + move. The arrow is
   drawn in em here, so it keeps its weight against a figure five times its
   height. */
.quote-head .delta { font-size: clamp(0.7rem, 2.9cqw, 1.1rem); }
.quote-head .delta::before {
  border-inline-start-width: 0.5em;
  border-inline-end-width: 0.5em;
  border-bottom-width: 0.9em;
}
.quote-head .delta.is-down::before { border-top-width: 0.9em; }

.value {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(2.4rem, 4.4vw, 3.5rem);
  line-height: 1;
  letter-spacing: -0.035em;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.value-xl {
  /* scales with the card, not the viewport: the number must never clip */
  font-size: clamp(3.2rem, 6vw, 5.2rem);
  /* tighter tracking makes the big figure read as one solid block */
  letter-spacing: -0.045em;
  margin-block: 0.35rem;
}

.value-unit {
  color: var(--muted);
  font-weight: 700;
  font-size: clamp(0.8rem, 1.15vw, 0.95rem);
  opacity: 0.82;
}

.card-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: auto;
  font-size: 0.78rem;
  color: var(--muted);
}

.card-foot-muted { opacity: 0.6; }
.note { font-size: 0.72rem; }

.delta {
  display: inline-flex;
  align-items: baseline;
  gap: 0.32rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  opacity: 0.7;
  white-space: nowrap;
}

/* direction is a solid arrow, not a +/- sign */
.delta::before {
  content: "";
  display: none;
  width: 0;
  height: 0;
  border-inline-start: 4.5px solid transparent;
  border-inline-end: 4.5px solid transparent;
  border-bottom: 7.5px solid currentColor;
  transform: translateY(-1px);
}

.delta.is-up,
.delta.is-down { opacity: 1; }

.delta.is-up {
  color: var(--up-neon);
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--up-neon) 65%, transparent));
}

.delta.is-down {
  color: var(--down-neon);
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--down-neon) 65%, transparent));
}

.delta.is-up::before,
.delta.is-down::before { display: inline-block; }

.delta.is-down::before {
  border-bottom: 0;
  border-top: 7.5px solid currentColor;
  transform: translateY(1px);
}

.delta.is-pop { animation: delta-pop 420ms ease-out; }

/* Inside a list the arrow is the signal, so an unchanged row stays wordless —
   that is what keeps "без изменений" from crowding out the city names. */
.rate-list .delta.is-none { display: none; }

/* the small pair line under a currency name */
.row-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;   /* both lines hug the inline start (right in RTL) */
  gap: 0.12rem;
  min-width: 0;
}

.row-cross {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.74;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.row-cross:empty { display: none; }

.asof { font-variant-numeric: tabular-nums; opacity: 0.65; }

/* number change feedback — only the changed digits animate */
@keyframes flash-up {
  0% { color: var(--up); transform: translateY(-1px); }
  100% { color: var(--gold); transform: none; }
}

@keyframes flash-down {
  0% { color: var(--down); transform: translateY(1px); }
  100% { color: var(--gold); transform: none; }
}

@keyframes delta-pop {
  0% { transform: scale(1.22); }
  100% { transform: none; }
}

.value.is-flash-up { animation: flash-up 900ms ease-out; }
.value.is-flash-down { animation: flash-down 900ms ease-out; }

/* ------------------------------------------------------------------- lists */
.card-list-title {
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-list-sub {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  opacity: 0.72;
  font-family: var(--font-body);
  font-weight: 700;
}

.rate-list { display: flex; flex-direction: column; }

.rate-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding-block: 0.62rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 20%, transparent);
}

.rate-list li:last-child { border-bottom: 0; }

/* The name is the only part of a row allowed to give: it shrinks and elides,
   which is what lets the value grow to the full weight of its cell without
   ever pushing the row sideways. */
.row-name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.05rem, 1.45vw, 1.26rem);
  line-height: 1.12;
  color: #fff;
  letter-spacing: -0.015em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rate-list-cur .row-name {
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.row-right {
  display: inline-flex;
  align-items: baseline;
  gap: 0.8rem;
  flex: none;
  white-space: nowrap;
}

/* Big enough to carry the row on its own, tight enough that six digits never
   reach the badge. nowrap plus the eliding name keeps every locale on one line. */
.row-value {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.3rem, 2.1vw, 1.8rem);
  line-height: 1.02;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  white-space: nowrap;
}

/* A governorate row carries both sides, so the pair stacks and the numbers
   share one right (inline-start) edge instead of stepping in and out. */
.row-quote-group {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
}

.row-quote {
  display: inline-flex;
  align-items: baseline;
  gap: 0.42rem;
}

.row-side {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.72;
  min-width: 3rem;
}

.rate-list .row-value { font-size: clamp(1.1rem, 1.75vw, 1.45rem); }

.rate-list-cur .row-value { font-size: clamp(1.05rem, 1.6vw, 1.32rem); }

.row-badge {
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: var(--muted);
  opacity: 0.6;
  min-width: 2.6rem;
  text-align: end;
}

.row-badge[data-tier="LOCAL"] { color: var(--gold); opacity: 0.9; }
.row-badge[data-tier="LAST"] { color: var(--gold); opacity: 0.55; }

.disclaimer {
  color: var(--muted);
  font-size: 0.74rem;
  opacity: 0.5;
  text-align: center;
  padding-block-end: 0.2rem;
}

/* The credit is a sentence now, not a two-word tag, so it takes its own row
   under the disclaimer instead of floating over the end of the sentence —
   the longest locales would otherwise run straight underneath it. */
.page-foot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  margin-block-start: auto;
}

/* `dir="ltr"` on the credit keeps the Latin lockup reading left to right on
   the Arabic and Kurdish boards. */
.powered {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.3rem 0.5rem;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.62;
  transition: opacity 160ms ease;
}

.page-foot:hover .powered { opacity: 0.9; }

.powered-by,
.powered-tech { white-space: nowrap; }

/* the wordmark already spells “Volls”, so it carries the link to vollstech.com */
.powered-link { display: inline-flex; align-items: center; color: inherit; text-decoration: none; }
.powered-link:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; border-radius: 4px; }

/* height wins over the intrinsic 523x221 so the mark scales with the type */
.powered-mark { display: block; height: clamp(17px, 1.4vw, 21px); width: auto; }

/* An <img> cannot read the page's custom properties, so the mark is shipped in
   both accents and only the one matching the active accent is shown. */
.powered-mark.is-volt { display: none; }
html[data-accent="volt"] .powered-mark.is-gold { display: none; }
html[data-accent="volt"] .powered-mark.is-volt { display: block; }

/* ------------------------------------------------------------------ ticker */
.ticker {
  display: flex;
  align-items: stretch;
  min-height: var(--ticker-h);
  background: rgba(19, 19, 19, 0.94);
  border-top: 1px solid color-mix(in srgb, var(--gold) 18%, transparent);
  box-shadow: 0 -10px 40px color-mix(in srgb, var(--gold) 5%, transparent);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.ticker-label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding-inline: clamp(1rem, 2.4vw, 2.4rem) 1.2rem;
  color: var(--gold);
  font-family: var(--font-head);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--bg);
  z-index: 1;
}

.ticker-label svg { flex: none; }

.ticker-view { flex: 1; overflow: hidden; display: flex; align-items: center; }

.ticker-track {
  display: inline-flex;
  align-items: center;
  gap: 3rem;
  white-space: nowrap;
  will-change: transform;
  animation: marquee var(--marquee-duration, 60s) linear infinite;
}

.ticker:hover .ticker-track,
.ticker-track:focus-within { animation-play-state: paused; }

@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

[dir="rtl"] .ticker-track { animation-name: marquee-rtl; }

@keyframes marquee-rtl {
  from { transform: translateX(0); }
  to { transform: translateX(50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
}

.ticker-item::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  opacity: 0.35;
  margin-inline-start: 1rem;
}

.ticker-src {
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ticker-text { white-space: nowrap; }

a.ticker-item:hover .ticker-text { color: var(--gold-soft); }

/* ------------------------------------------------------- TV / kiosk mode --- */
/* Entered from the fullscreen button (or the F key) so the board can be put on
   a television: chrome trimmed, numbers scaled up, the whole viewport used and
   the cursor fading out after a few idle seconds. */
body.tv { height: 100dvh; overflow: hidden; }
body.tv.idle { cursor: none; }

body.tv .page {
  min-height: 0;   /* let the grid shrink into the viewport, not push the ticker off */
  overflow: hidden;
  gap: clamp(0.9rem, 1.6vw, 1.6rem);
  padding: clamp(1rem, 1.6vw, 1.8rem) clamp(1rem, 2vw, 2.2rem);
}

body.tv .page-head,
body.tv .disclaimer { display: none; }
/* an empty row would still take a gap out of the broadcast grid */
body.tv .page-foot { display: none; }

body.tv .grid {
  flex: 1;
  min-height: 0;
  /* equal rows that shrink instead of pushing the ticker off a TV screen */
  grid-auto-rows: minmax(0, 1fr);
}
body.tv .card { min-height: 0; gap: clamp(0.6rem, 1.2vh, 1rem); }

/* the hero fills a double-height card: title stays at the top, the number sits
   in the middle, the footer at the bottom — no dead band in the middle of a
   television screen */
body.tv .card-hero {
  justify-content: space-between;
  gap: clamp(0.8rem, 1.6vh, 1.5rem);
}
body.tv .card-hero .card-body { margin-block-start: auto; }
body.tv .card-hero .card-foot { margin-top: 0; }

body.tv .card-title { font-size: clamp(1.5rem, 2vw, 2.2rem); }
body.tv .card-title-lg { font-size: clamp(2rem, 2.7vw, 3rem); }
body.tv .card-tag { font-size: 0.74rem; }
body.tv .tier-badge { font-size: 0.68rem; }

body.tv .value { font-size: clamp(2.6rem, 3.9vw, 4.4rem); }
/* the hero number is what a viewer reads from across the room */
body.tv .value-xl { font-size: clamp(3.6rem, 6.6vw, 8rem); }
body.tv .value-unit { font-size: clamp(0.9rem, 1.2vw, 1.1rem); }

/* two sided quote on a TV: each side gets half the card, and the figure is
   the only thing a viewer three metres away can actually read — so it takes
   the whole row. Two ceilings, because a figure is limited twice: the card's
   width (cqw) and the board's height (vh — a quote card is one grid row, and
   the grid rows split the viewport). Width binds on a wide single-column
   board, height on a 3-column 1080p set; `min()` keeps whichever is smaller,
   so the digits fill the row instead of stalling at a fixed rem cap. */
body.tv .quote-value {
  font-size: clamp(1.9rem, min(25cqw, 7vh), 20rem);
  /* Manrope stops at 800; the stroke is the extra weight at TV distance */
  font-weight: 800;
  letter-spacing: -0.035em;
  -webkit-text-stroke: 0.024em currentColor;
}
/* the hero's two halves run deeper into the card, so height is all width */
body.tv .card-hero .quote-value { font-size: clamp(1.9rem, min(25cqw, 26vh), 20rem); }
body.tv .quote-side { font-size: clamp(0.8rem, 3cqw, 1.35rem); }
body.tv .quote-head .delta { font-size: clamp(0.85rem, 3.3cqw, 1.5rem); }
body.tv .row-side { font-size: 0.66rem; }
body.tv .rate-list .row-value { font-size: clamp(1.15rem, 1.65vw, 1.7rem); }

body.tv .card-list-title { font-size: clamp(1rem, 1.2vw, 1.25rem); }
body.tv .row-name { font-size: clamp(1.15rem, 1.5vw, 1.6rem); }
body.tv .rate-list-cur .row-name { font-size: clamp(0.95rem, 1.1vw, 1.2rem); }
body.tv .row-value { font-size: clamp(1.3rem, 1.9vw, 1.9rem); }
body.tv .rate-list-cur .row-value { font-size: clamp(1.15rem, 1.6vw, 1.6rem); }
body.tv .rate-list li { padding-block: clamp(0.65rem, 1.4vh, 1.15rem); }
/* the currency card carries five rows: tighten it so it still fits a 16:9 TV */
body.tv .rate-list-cur li { padding-block: clamp(0.4rem, 0.9vh, 0.7rem); }
body.tv .rate-list-cur .row-value { font-size: clamp(1.05rem, 1.35vw, 1.45rem); }
body.tv .card-foot { font-size: 0.82rem; }

body.tv .ticker { min-height: clamp(60px, 8vh, 92px); }
body.tv .ticker-item { font-size: clamp(1rem, 1.2vw, 1.3rem); }
body.tv .ticker-src { font-size: 0.72rem; }
body.tv .row-cross { font-size: clamp(0.8rem, 1vw, 1rem); }

/* ---------------------------------------------------------------- scripts -- */

/* Chinese has no case and no use for tracking; a little more leading keeps the
   labels legible on a phone as well as across a room. */
html:lang(zh) .page-title,
html:lang(zh) .card-title,
html:lang(zh) .card-list-title,
html:lang(zh) .value { letter-spacing: 0; }
html:lang(zh) .page-title { line-height: 1.24; }
html:lang(zh) .card-title,
html:lang(zh) .card-list-title { line-height: 1.3; }

/* the status pill is read, not shouted: upper case stretches Cyrillic and
   Turkish long after the dot has already said "live" */
html:lang(tr) .live-pill,
html:lang(ru) .live-pill { text-transform: none; letter-spacing: 0.03em; }

/* Cyrillic upper case is wide — the badges must not push the card title */
html:lang(ru) .tier-badge,
html:lang(ru) .card-tag { letter-spacing: 0.05em; }

/* Arabic script is joined: tracking — negative or positive — either collides
   the joins or tears them apart (the Kufi ascenders in Sorani show it first),
   so the two Arabic-script editions read with neutral spacing. */
html:lang(ar) *,
html:lang(ckb) * { letter-spacing: normal; }

/* The Arabic face stops at 700. Asking for more makes the browser embolden it
   synthetically, which smears the joins of a large heading. */
html:lang(ar) .page-title,
html:lang(ckb) .page-title,
html:lang(ar) .card-title-lg,
html:lang(ckb) .card-title-lg { font-weight: 700; }

/* -------------------------------------------------------------- responsive */

/* tablet — two columns, the hero stops spanning two rows ------------------- */
@media (max-width: 1080px) {
  .card,
  .card-hero { grid-column: span 6; }
  .card-hero { grid-row: auto; }
}

/* phone — one column, header breaks into brand row + tools row ------------- */
@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    min-height: auto;
    padding-block: 0.6rem;
    gap: 0.45rem;
  }
  .brand { width: 100%; }
  .topbar-tools { width: 100%; justify-content: space-between; gap: 0.4rem; }
  .brand-name { font-size: 1.1rem; }
  .brand-mark { font-size: 1.05rem; padding: 0.3rem 0.45rem; }
  .clock time { font-size: 1rem; }
  .live-pill { font-size: 0.6rem; padding: 0.32rem 0.55rem; letter-spacing: 0.05em; }
  .lang-switch { padding: 0.34rem 0.45rem; }
  .lang-switch select { font-size: 0.72rem; width: 3.5rem; }
  .icon-btn { width: 40px; height: 40px; }

  .page { gap: 0.9rem; padding-block: 1rem; }
  .card, .card-hero { grid-column: span 12; }
  .card-hero { grid-row: auto; }
  .card { min-height: 0; padding: 1.05rem; }

  .card-title { font-size: 1.2rem; }
  .card-title-lg { font-size: 1.45rem; }
  .value { font-size: clamp(2.1rem, 9vw, 2.6rem); }
  .value-xl { font-size: clamp(2.6rem, 13vw, 3.6rem); }
  /* a quote figure is sized by its card, not by the phone: the .value rules
     above are for the single-number rows and must not shrink the pair */
  .quote-value { font-size: clamp(1.7rem, 15cqw, 4.2rem); }
  .card-hero .quote-value { font-size: clamp(2rem, 20cqw, 6.4rem); }

  .row-name { font-size: 1.02rem; }
  .row-value { font-size: 1.18rem; }
  .rate-list-cur .row-name { font-size: 0.82rem; }
  .rate-list-cur .row-value { font-size: 1.06rem; }
  .rate-list li { padding-block: 0.55rem; }

  .powered-mark { height: 15px; }

  .ticker { min-height: 56px; }
  .ticker-label { font-size: 0.64rem; padding-inline: 0.8rem 0.6rem; gap: 0.4rem; }
  .ticker-item { font-size: 0.85rem; }
}

/* small phones — drop what does not fit instead of shrinking it to death ---- */
@media (max-width: 420px) {
  .clock { display: none; }
  .brand-name { font-size: 1rem; }
  .page { padding-inline: 0.85rem; }
  .card { padding: 0.95rem; }
  /* the brand already says who we are; the rates should start higher up */
  .kicker { display: none; }
  .page-title { font-size: 1.7rem; }
  .page-note { font-size: 0.72rem; }
  .feed-note { margin-top: 0.3rem; font-size: 0.72rem; }
  /* a long status word in Cyrillic must not shove the tools off the row */
  .live-pill { flex: 0 1 auto; min-width: 0; gap: 0.35rem; padding: 0.32rem 0.45rem; }
  #live-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  /* the globe is decoration: at 320 px the language name itself must fit */
  .lang-switch .ico-globe { display: none; }
  .lang-switch { gap: 0.25rem; padding: 0.34rem 0.4rem; }
  .lang-switch select { width: 3.45rem; }
  .value-xl { font-size: clamp(2.4rem, 12.5vw, 3.2rem); }
  .value { font-size: clamp(2rem, 8.5vw, 2.4rem); }
  /* the pair still fills its card at 320 px — same rule, one more reset */
  .quote-value { font-size: clamp(1.7rem, 15cqw, 4.2rem); }
  /* a governorate row keeps name + number + badge; the delta is the first to go */
  /* a changed rate keeps its neon arrow; the amount would not fit at 320px */
  .rate-list .delta .delta-num { display: none; }
  .ticker-label { font-size: 0.6rem; }
}

/* very narrow phones — the tools row has to survive 280 px in every locale -- */
@media (max-width: 380px) {
  .topbar-tools { gap: 0.32rem; }
  .icon-btn { width: 36px; height: 36px; }
  /* wide enough for the longest native name (Русский) — measured, not guessed */
  .lang-switch select { width: 3.1rem; }
}

/* short viewports — landscape phones and small laptops get less chrome ------ */
@media (max-height: 560px) {
  .kicker { display: none; }
  .page-title { font-size: clamp(1.4rem, 3vw, 1.9rem); }
  .page-note { font-size: 0.76rem; }
  .feed-note { margin-top: 0.3rem; }
  .page { gap: 0.7rem; padding-block: 0.7rem; }
}

/* short or narrow screens cannot hold the broadcast grid: let it scroll ----- */
@media (max-width: 720px), (max-height: 560px) {
  body.tv { height: auto; overflow: auto; }
  body.tv .page { overflow: visible; }
  body.tv .grid { grid-auto-rows: auto; }
  body.tv .value-xl { font-size: clamp(2.8rem, 12vw, 4rem); }
  body.tv .value { font-size: clamp(2.2rem, 9vw, 3rem); }
}

@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none !important; }
  .live-dot { animation: none; }
  .value.is-flash-up,
  .value.is-flash-down { animation: none; }
  .delta.is-pop { animation: none; }
}

/* ==========================================================================
   /iqd — the rate archive
   Same tokens, a different job: a document you read, not a board you glance at.
   Nothing here flashes; the only motion is the chart crosshair.
   ========================================================================== */

:root { --arc-bar-top: 84px; }

body.is-archive { background: var(--bg); }

.is-archive .page {
  background: var(--bg);
  gap: clamp(0.9rem, 1.7vw, 1.5rem);
  width: 100%;
  max-width: 1360px;
  margin-inline: auto;
}

/* The record tables are `white-space: nowrap` and scroll inside their own box.
   As flex items they would otherwise hand their min-content width up to the
   page and push the whole document wider than the phone. */
.is-archive .page > *,
.is-archive .card,
.arc-table-scroll { min-width: 0; }

/* ------------------------------------------------------------------ topnav */
.topnav { display: flex; align-items: center; gap: 0.3rem; }

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 140ms ease, border-color 140ms ease;
}

.nav-link:hover { color: var(--text); border-color: color-mix(in srgb, var(--line) 70%, transparent); }
.nav-link:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

.nav-link.is-active {
  background: var(--gold);
  border-color: var(--gold);
  color: #131313;
}

/* -------------------------------------------------------------------- hero */
.arc-hero { display: flex; flex-direction: column; gap: 0.4rem; }

.arc-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
  margin-block-start: 0.7rem;
}

.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  padding: 0.8rem 0.95rem 0.85rem;
  background: var(--panel-2);
  border: 1px solid color-mix(in srgb, var(--line) 40%, transparent);
  border-radius: var(--radius);
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 3px;
  background: color-mix(in srgb, var(--gold) 55%, transparent);
}

.stat-label {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.78;
}

.stat-value {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.45rem, 2.5vw, 2rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.stat-value-sm { font-size: clamp(1rem, 1.55vw, 1.2rem); color: var(--text); }

.stat-sub {
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.66;
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- filters */
.arc-bar {
  position: sticky;
  top: var(--arc-bar-top);
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  background: color-mix(in srgb, var(--panel-2) 94%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--line) 45%, transparent);
  border-radius: var(--radius);
}

.arc-field { display: flex; flex-direction: column; gap: 0.26rem; flex: 1 1 7.8rem; min-width: 0; }
.arc-field-wide { flex: 1 1 11rem; }

.arc-field label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.85;
  padding-inline-start: 0.3rem;
}

.arc-select { position: relative; display: flex; align-items: center; }

.arc-select svg {
  position: absolute;
  inset-inline-end: 0.7rem;
  pointer-events: none;
  opacity: 0.6;
}

.arc-select select {
  appearance: none;
  width: 100%;
  padding: 0.55rem 1.9rem 0.55rem 0.7rem;
  padding-inline-start: 0.7rem;
  padding-inline-end: 1.9rem;
  background: var(--panel-3);
  border: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.arc-select select:hover { border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.arc-select select:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 1px; }
.arc-select select option { background: #1b1b1b; color: var(--text); }

.arc-latest {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-inline-start: auto;
  padding: 0.58rem 0.85rem;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  border-radius: 10px;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}

.arc-latest:hover { color: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 55%, transparent); }
.arc-latest:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

/* ------------------------------------------------------------------- error */
.arc-error {
  padding: 0.7rem 0.9rem;
  border: 1px solid color-mix(in srgb, var(--down) 45%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--down) 10%, transparent);
  color: var(--down);
  font-size: 0.84rem;
}

/* ------------------------------------------------------------------- chart */
.arc-chart-card { gap: 0.7rem; }

.arc-chart-head { align-items: flex-start; gap: 1rem; flex-wrap: wrap; }

.arc-chart-sub {
  margin-block-start: 0.15rem;
  font-size: 0.76rem;
  color: var(--muted);
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.arc-legend { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

.arc-key {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted);
}

.arc-key i {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: var(--gold);
}

.arc-key.is-ref i {
  height: 0;
  border-block-start: 2px dashed color-mix(in srgb, var(--muted) 85%, transparent);
  background: none;
}

.arc-chart-wrap { position: relative; }

.arc-chart-wrap.is-empty .arc-chart { height: 0; }

.arc-chart { display: block; width: 100%; height: 320px; overflow: visible; }

.arc-chart text {
  fill: color-mix(in srgb, var(--muted) 82%, transparent);
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.arc-chart .grid-line { stroke: color-mix(in srgb, var(--line) 30%, transparent); stroke-width: 1; }
.arc-chart .axis-line { stroke: color-mix(in srgb, var(--line) 55%, transparent); stroke-width: 1; }
.arc-chart .series-desk { fill: none; stroke: var(--gold); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.arc-chart .series-ref { fill: none; stroke: color-mix(in srgb, var(--muted) 70%, transparent); stroke-width: 1.6; stroke-dasharray: 5 4; }
.arc-chart .area { fill: color-mix(in srgb, var(--gold) 16%, transparent); }
.arc-chart .dot { fill: var(--gold); stroke: var(--panel-2); stroke-width: 1.4; }
.arc-chart .marker { fill: none; stroke: var(--gold-soft); stroke-width: 1.6; }
.arc-chart .marker-line { stroke: color-mix(in srgb, var(--gold-soft) 45%, transparent); stroke-width: 1; stroke-dasharray: 3 3; }
.arc-chart .crosshair { stroke: color-mix(in srgb, var(--text) 55%, transparent); stroke-width: 1; opacity: 0; }
.arc-chart .cross-dot { fill: var(--gold-soft); opacity: 0; }
.arc-chart-wrap.is-hover .crosshair,
.arc-chart-wrap.is-hover .cross-dot { opacity: 1; }

.arc-tip {
  position: absolute;
  z-index: 5;
  min-width: 8.5rem;
  padding: 0.5rem 0.65rem;
  background: var(--panel-3);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  font-size: 0.74rem;
  line-height: 1.5;
  transform: translate(-50%, calc(-100% - 14px));
  pointer-events: none;
  white-space: nowrap;
}

.arc-tip-date { color: var(--muted); font-size: 0.7rem; opacity: 0.85; }

.arc-tip-value {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1rem;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.arc-empty {
  padding: 1.6rem 1rem;
  text-align: center;
  color: var(--muted);
  opacity: 0.7;
  font-size: 0.86rem;
}

/* --------------------------------------------------------------- day split */
.arc-split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: stretch;
}

.arc-day, .arc-intraday { gap: 0.7rem; }
.arc-day .card-head, .arc-intraday .card-head { flex-wrap: wrap; gap: 0.45rem; }

.arc-day-date {
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

.arc-ref {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.32rem 0.6rem;
  background: color-mix(in srgb, var(--panel-3) 70%, transparent);
  border: 1px dashed color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 10px;
}

.arc-ref-label {
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.8;
}

.arc-ref-value {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.arc-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.arc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
}

.arc-table th {
  padding: 0.4rem 0.55rem;
  border-block-end: 1px solid color-mix(in srgb, var(--line) 45%, transparent);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.8;
  text-align: start;
  white-space: nowrap;
}

.arc-table td {
  padding: 0.46rem 0.55rem;
  border-block-end: 1px solid color-mix(in srgb, var(--line) 18%, transparent);
  color: var(--text);
  white-space: nowrap;
}

.arc-table tbody tr:last-child td { border-block-end: 0; }
.arc-table tbody tr:hover td { background: color-mix(in srgb, var(--gold) 6%, transparent); }
.arc-table tr.is-target td { background: color-mix(in srgb, var(--gold) 11%, transparent); }
.arc-table .num { text-align: end; }
.arc-table th.num { text-align: end; }
.arc-table .cell-name { font-weight: 700; }
.arc-table .cell-sub { display: block; font-size: 0.66rem; color: var(--muted); opacity: 0.7; }

.arc-table .row-day {
  padding: 0;
  background: none;
  border: 0;
  color: var(--gold-soft);
  font: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
}

.arc-table .row-day:hover { text-decoration-color: currentColor; }
.arc-table .row-day:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

.arc-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  color: var(--gold-soft);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.arc-spark { display: flex; flex-direction: column; gap: 0.5rem; }
.arc-spark svg { display: block; width: 100%; height: 132px; }
.arc-spark .spark-line { fill: none; stroke: var(--gold); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.arc-spark .spark-area { fill: color-mix(in srgb, var(--gold) 12%, transparent); }
.arc-spark .spark-dot { fill: var(--gold); }
.arc-spark .spark-grid { stroke: color-mix(in srgb, var(--line) 28%, transparent); stroke-width: 1; }
.arc-spark text { fill: color-mix(in srgb, var(--muted) 80%, transparent); font-size: 9.5px; font-weight: 600; }

.arc-spark-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ record */
.arc-record { gap: 0.7rem; }
.arc-actions { display: flex; align-items: center; gap: 0.45rem; }

.arc-ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.38rem 0.62rem;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  border-radius: 9px;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}

.arc-ghost:hover { color: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.arc-ghost:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

.arc-record-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-block-start: auto;
}

.arc-count { font-size: 0.72rem; color: var(--muted); opacity: 0.72; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- method */
.arc-method {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding-block-start: 0.4rem;
  border-block-start: 1px solid color-mix(in srgb, var(--line) 35%, transparent);
}

.arc-method-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.arc-method-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.arc-method-item { display: flex; flex-direction: column; gap: 0.3rem; }

.arc-method-tag {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text);
}

.arc-method-item p {
  font-size: 0.78rem;
  line-height: 1.65;
  color: var(--muted);
  opacity: 0.8;
}

.arc-foot { padding-block-start: 1rem; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .arc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .arc-split { grid-template-columns: minmax(0, 1fr); }
  .arc-method-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (max-width: 720px) {
  :root { --arc-bar-top: 116px; }
  .topnav { order: 3; width: 100%; padding-block-start: 0.1rem; }
  .nav-link { padding: 0.34rem 0.65rem; font-size: 0.76rem; }
  .arc-stats { gap: 0.7rem; }
  .stat { padding: 0.65rem 0.7rem; }
  .stat-value { font-size: 1.35rem; }
  .arc-bar { gap: 0.5rem; padding: 0.6rem; }
  .arc-field { flex: 1 1 6.4rem; }
  .arc-field-wide { flex: 1 1 100%; }
  .arc-latest { margin-inline-start: 0; width: 100%; justify-content: center; }
  .arc-chart { height: 240px; }
  .arc-method-grid { grid-template-columns: minmax(0, 1fr); }
  .arc-chart-head { gap: 0.4rem; }
}

@media (max-width: 560px) {
  /* A phone cannot hold seven numeric columns side by side: keep the four that
     answer "what did a dollar cost that day", and let the range and the sample
     count stay in the day card above rather than behind a sideways scroll. */
  .arc-table .col-high,
  .arc-table .col-low,
  .arc-table .col-samples { display: none; }
  .arc-table .delta-pct { display: none; }
  .arc-table { font-size: 0.8rem; }
  .arc-table th, .arc-table td { padding-inline: 0.4rem; }
  /* the record head carries a title, a range and two exports: let the title own
     a full line before the buttons claim theirs */
  .arc-record .card-head { flex-wrap: wrap; row-gap: 0.5rem; }
  .arc-record .card-head > div:first-child { flex: 1 1 100%; min-width: 0; }
  .arc-record .arc-actions { margin-inline-start: auto; }
}

@media (max-width: 420px) {
  .arc-stats { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .stat-label { font-size: 0.58rem; letter-spacing: 0.1em; }
  .arc-chart { height: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  .arc-chart * { transition: none !important; }
}

/* ==========================================================================
   /source — the source monitor
   The archive's tokens and tables with one job: hold a number against the
   words that produced it. Nothing decorative; the proof is the content.
   ========================================================================== */

.src-bar { align-items: flex-end; }

/* The source picker only appears when the pair has more than one reader.
   `.arc-field` is display:flex, which would otherwise outrank [hidden]. */
#f-source-wrap { flex: 1 1 10rem; }
#f-source-wrap[hidden] { display: none; }

.src-bar #f-source { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.76rem; }

.src-auto {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.58rem 0.72rem;
  border: 1px solid color-mix(in srgb, var(--line) 45%, transparent);
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.src-auto input { width: 15px; height: 15px; margin: 0; accent-color: var(--gold); }
.src-auto:focus-within { outline: 2px solid var(--gold-soft); outline-offset: 2px; }

.src-list { gap: 0.7rem; }

/* The source key is an identifier, not prose: monospace and set apart. */
.src-source {
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.3rem 0.65rem;
  border: 1px dashed color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
}

/* The headline must read as a price first and a date second. */
.stat-value-last {
  font-size: clamp(1.25rem, 2.1vw, 1.7rem);
  white-space: nowrap;
}

/* --------------------------------------------------------------- the table */
.src-row { cursor: pointer; }
.src-row td { transition: background-color 120ms ease; }
.src-row:focus-within td { background: color-mix(in srgb, var(--gold) 9%, transparent); }

.src-when bdi { font-weight: 700; }
.src-price { font-family: var(--font-head); font-weight: 800; letter-spacing: -0.01em; }

.src-chip {
  display: inline-block;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.src-chip[data-status="active"] {
  color: var(--gold-soft);
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
}

/* Superseded is a normal step in a market feed, not a fault: quiet, not red. */
.src-chip[data-status="superseded"] {
  color: var(--muted);
  border-color: color-mix(in srgb, var(--line) 70%, transparent);
  opacity: 0.75;
}

.src-chip[data-status="quarantined"] {
  color: var(--down);
  background: color-mix(in srgb, var(--down) 12%, transparent);
  border-color: color-mix(in srgb, var(--down) 45%, transparent);
}

.src-chip[data-status="archived"] {
  color: var(--muted);
  border-color: color-mix(in srgb, var(--line) 55%, transparent);
  border-style: dashed;
}

.src-open { width: 2.4rem; text-align: end; }

.src-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease;
}

.src-toggle:hover { color: var(--gold-soft); border-color: color-mix(in srgb, var(--line) 60%, transparent); }
.src-toggle:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 1px; }
.src-toggle svg { transition: transform 160ms ease; }
.src-toggle[aria-expanded="true"] { color: var(--gold); }
.src-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* ------------------------------------------------------------- the detail */
.src-detail > td {
  padding: 0.8rem 0.8rem 1rem;
  background: color-mix(in srgb, var(--panel-3) 45%, transparent);
  border-block-end: 1px solid color-mix(in srgb, var(--line) 30%, transparent);
  white-space: normal;
}

.src-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.src-detail-main { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }

.src-detail-label {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.8;
}

/* The line is evidence: monospace, wrapped only where the word ends. */
.src-line {
  margin: 0;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--line) 45%, transparent);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.75;
  color: var(--text);
  overflow-wrap: anywhere;
}

.src-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.95rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.src-fact b { margin-inline-end: 0.3rem; font-weight: 700; opacity: 0.72; }
.src-fact i { font-style: normal; color: var(--text); }

.src-reason { margin: 0; font-size: 0.74rem; color: var(--down); }

.src-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem 0.95rem;
  margin: 0;
  font-size: 0.74rem;
}

.src-meta div { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }

.src-meta dt {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.75;
}

.src-meta dd {
  margin: 0;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.src-uuid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.66rem;
  color: var(--muted);
}

@media (max-width: 720px) {
  .src-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .src-auto { width: 100%; justify-content: center; }
  .src-bar .arc-latest { width: auto; margin-inline-start: 0; }
}

@media (max-width: 560px) {
  /* A phone keeps province, price, time and state; the change against the last
     reading of the same province stays in the detail row. The table stops being
     a table here: at this width columns crush each other and the detail panel
     gets clipped, so every row becomes a small stack instead. */
  .src-table,
  .src-table tbody,
  .src-table tr,
  .src-table td { display: block; }

  .src-table thead { display: none; }

  .src-table tr.src-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "place place price"
      "when  status open";
    align-items: center;
    gap: 0.12rem 0.5rem;
    padding: 0.6rem 0.2rem;
    border-block-end: 1px solid color-mix(in srgb, var(--line) 18%, transparent);
  }

  .src-table tr.src-row td {
    padding: 0;
    border: 0;
    background: none;
  }

  /* The highlight belongs to the row now that the cells are grid areas. */
  .src-table tbody tr.src-row:hover,
  .src-table tbody tr.src-row:focus-within {
    background: color-mix(in srgb, var(--gold) 6%, transparent);
  }

  .src-table .src-when { grid-area: when; }
  .src-table .cell-name { grid-area: place; }
  .src-table .src-price { grid-area: price; }
  .src-table .src-status { grid-area: status; justify-self: end; }
  .src-table .src-open { grid-area: open; justify-self: end; width: auto; }

  .src-table .src-col-change,
  .src-table .src-change { display: none; }

  .src-table tr.src-detail {
    border-block-end: 1px solid color-mix(in srgb, var(--line) 30%, transparent);
  }

  .src-detail > td {
    padding: 0.7rem 0.2rem 0.9rem;
    border: 0;
  }

  .src-meta { grid-template-columns: minmax(0, 1fr); }

  /* The source key may wrap under the title rather than be cut to "wa-iq…". */
  .src-list .card-head { flex-wrap: wrap; row-gap: 0.4rem; }
  .src-source { max-width: 100%; }
}