/* Market pulse (public/v2/pulse.js). Every row has a fixed height and figures
   are tabular, so a refresh changes digits and never the layout. */
body.v2 .v2-pulse { position: relative; margin: 0 0 14px; }
body.v2 .v2-pulse[hidden], body.v2 .v2-pulse [hidden] { display: none !important; }
body.v2 .v2-pulse-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
body.v2 .v2-pulse-card { min-width: 0; padding: 11px 14px 9px; border: 1px solid var(--line); border-radius: var(--v2-radius); background: var(--panel); }
body.v2 .v2-pulse-card header { height: 30px; margin-bottom: 4px; }
body.v2 .v2-pulse-card h3 { margin: 0; color: var(--subtle); font-size: 12px; font-weight: 600; line-height: 15px; letter-spacing: .07em; text-transform: uppercase; }
body.v2 .v2-pulse-note { display: block; color: var(--subtle); font-size: 12px; line-height: 15px; }
body.v2 .v2-pulse-card h3, body.v2 .v2-pulse-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Gainers and losers ---------- */
body.v2 .v2-pulse-card ol { height: 78px; margin: 0; padding: 0; list-style: none; }
body.v2 .v2-pulse-card li { height: 26px; }
body.v2 .v2-pulse-line {
  display: flex; align-items: center; gap: 8px; width: calc(100% + 12px); height: 26px; margin: 0 -6px; padding: 0 6px;
  border: 0; border-radius: 7px; background: transparent; color: var(--text); font-size: 14px; line-height: 20px; text-align: left; cursor: pointer;
}
body.v2 .v2-pulse-line:hover { background: var(--panel-2); }
body.v2 .v2-pulse-slot { flex: none; width: 22px; height: 22px; }
body.v2 .v2-pulse-mark { position: relative; display: grid; place-items: center; width: 22px; height: 22px; overflow: hidden; border-radius: 6px; background: var(--panel-3); color: var(--muted); font-size: 12px; font-weight: 650; line-height: 1; }
body.v2 .v2-pulse-mark > * { grid-area: 1 / 1; }
body.v2 .v2-pulse-mark img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
body.v2 .v2-pulse-mark.has-logo { background: #fff; }
body.v2 .v2-pulse-ticker { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
body.v2 .v2-pulse-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12.5px; }
body.v2 .v2-pulse-change { flex: none; min-width: 8ch; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
body.v2 .v2-pulse-empty { height: 78px; margin: 0; color: var(--subtle); font-size: 13px; line-height: 26px; }
body.v2 .v2-pulse .is-up, body.v2 #v2-pulse-dialog .is-up { color: var(--green); }
body.v2 .v2-pulse .is-down, body.v2 #v2-pulse-dialog .is-down { color: var(--red); }
body.v2 .v2-pulse .is-flat, body.v2 #v2-pulse-dialog .is-flat { color: var(--muted); }

/* ---------- "See all" and the ranking window ---------- */
body.v2 .v2-pulse-movers header { position: relative; }
body.v2 .v2-pulse-movers h3 { padding-right: 60px; }
body.v2 .v2-pulse-more { position: absolute; top: -3px; right: -6px; height: 22px; padding: 0 6px; border: 0; border-radius: 6px; background: transparent; color: var(--accent); font: inherit; font-size: 12px; font-weight: 600; line-height: 22px; white-space: nowrap; cursor: pointer; }
body.v2 .v2-pulse-more::after { content: " ›"; }
body.v2 .v2-pulse-more:hover { background: var(--panel-2); color: var(--accent-strong); }
body.v2 #v2-pulse-dialog { display: none; flex-direction: column; width: min(560px, calc(100vw - 32px)); max-height: min(80vh, 720px); padding: 0; overflow: hidden; border: 1px solid #232b38; border-radius: 16px; background: var(--panel); color: var(--text); box-shadow: var(--v2-shadow); }
body.v2 #v2-pulse-dialog[open] { display: flex; }
body.v2 #v2-pulse-dialog > header { display: flex; flex: none; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 10px 20px; }
body.v2 #v2-pulse-dialog > header > div { min-width: 0; }
body.v2 #v2-pulse-dialog h2 { margin: 0; font-size: 17px; font-weight: 650; line-height: 24px; letter-spacing: -.02em; }
body.v2 .v2-pulse-dialog-note { margin: 2px 0 0; overflow: hidden; color: var(--subtle); font-size: 12.5px; line-height: 17px; text-overflow: ellipsis; white-space: nowrap; }
body.v2 .v2-pulse-dialog-close { flex: none; display: grid; place-items: center; width: 32px; height: 32px; margin: -4px -4px 0 0; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--subtle); cursor: pointer; }
body.v2 .v2-pulse-dialog-close:hover { background: var(--panel-2); color: var(--text); }
body.v2 .v2-pulse-dialog-close svg { width: 16px; height: 16px; }
body.v2 .v2-pulse-dialog-tabs { display: flex; flex: none; gap: 4px; padding: 0 20px 10px; border-bottom: 1px solid var(--line); }
body.v2 .v2-pulse-dialog-tab { display: inline-flex; align-items: baseline; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
body.v2 .v2-pulse-dialog-tab b { color: var(--subtle); font-weight: 500; font-variant-numeric: tabular-nums; }
body.v2 .v2-pulse-dialog-tab:hover { background: var(--panel-2); color: var(--text); }
body.v2 .v2-pulse-dialog-tab[aria-selected="true"] { border-color: var(--line); background: var(--panel-2); color: var(--text); }
/* flex-basis auto, not 0%: in a dialog whose height follows its content, Safari resolves 0% to nothing and the list vanishes. */
body.v2 .v2-pulse-dialog-list { flex: 1 1 auto; min-height: 0; margin: 0; padding: 6px 8px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; list-style: none; }
body.v2 .v2-pulse-row { display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
body.v2 .v2-pulse-row:hover { background: var(--panel-2); }
body.v2 .v2-pulse-rank { flex: none; width: 22px; color: var(--subtle); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
body.v2 .v2-pulse-ident { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 17px; }
body.v2 .v2-pulse-ident .v2-pulse-ticker { max-width: none; }
body.v2 .v2-pulse-ident .v2-pulse-name { flex: none; font-size: 12px; }
body.v2 .v2-pulse-cap { flex: none; min-width: 9ch; color: var(--muted); font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
body.v2 #v2-pulse-dialog .v2-pulse-empty { height: auto; margin: 0; padding: 18px 20px; line-height: 20px; }
body.v2 #v2-pulse-dialog > footer { flex: none; padding: 8px 12px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
body.v2 .v2-pulse-dialog-sort { width: 100%; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
body.v2 .v2-pulse-dialog-sort:hover { background: var(--panel-2); color: var(--text); }
@media (max-width: 700px) {
  body.v2 #v2-pulse-dialog { width: 100vw; max-width: none; max-height: 88dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  body.v2 .v2-pulse-cap { display: none; }
}

/* ---------- Breadth ---------- */
body.v2 .v2-pulse-bar { display: flex; gap: 2px; height: 8px; margin: 9px 0; overflow: hidden; border-radius: 4px; }
body.v2 .v2-pulse-bar i { flex: 0 0 0; min-width: 3px; transition: flex-grow .4s ease; }
body.v2 .v2-pulse-bar .is-up { background: var(--green); }
body.v2 .v2-pulse-bar .is-down { background: var(--red); }
body.v2 .v2-pulse-bar .is-flat { background: var(--subtle); opacity: .55; }
body.v2 .v2-pulse-counts, body.v2 .v2-pulse-average { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 26px; margin: 0; font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
/* "2,768 up 212 unchanged 2,048 down" has to fit a 260px card. */
body.v2 .v2-pulse-counts { gap: 6px; }
body.v2 .v2-pulse-counts > span, body.v2 .v2-pulse-summary > span { display: inline-flex; align-items: baseline; gap: 5px; }
body.v2 .v2-pulse-counts b, body.v2 .v2-pulse-average b { font-size: 14px; font-weight: 600; }
body.v2 .v2-pulse-average > span { color: var(--muted); }

/* ---------- Collapse control: a chevron on wide screens, a labelled row when
   the section is collapsed or its cards scroll sideways ---------- */
body.v2 .v2-visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
body.v2 .v2-pulse-head { position: absolute; top: 7px; right: 7px; z-index: 1; display: flex; align-items: center; gap: 14px; }
body.v2 .v2-pulse-label, body.v2 .v2-pulse-summary { display: none; margin: 0; }
body.v2 .v2-pulse-label { flex: none; color: var(--subtle); font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; }
body.v2 .v2-pulse-summary { min-width: 0; overflow: hidden; gap: 8px; color: var(--muted); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
body.v2 .v2-pulse-summary b { font-size: 14px; font-weight: 600; }
body.v2 .v2-pulse-summary > span + span::before { content: "·"; margin-right: 3px; color: var(--subtle); }
body.v2 .v2-pulse-summary .is-average, body.v2 .v2-pulse-summary .is-average > span { color: var(--muted); }
body.v2 .v2-pulse-toggle { flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin-left: auto; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--subtle); cursor: pointer; }
body.v2 .v2-pulse-toggle:hover { background: var(--panel-2); color: var(--text); }
body.v2 .v2-pulse-toggle svg { width: 16px; height: 16px; transition: transform .15s ease; }
body.v2 .v2-pulse.is-collapsed .v2-pulse-toggle svg { transform: rotate(180deg); }
body.v2 .v2-pulse-breadth header { padding-right: 26px; }
body.v2 .v2-pulse.is-collapsed .v2-pulse-head { position: static; min-height: 40px; padding: 0 6px 0 16px; border: 1px solid var(--line); border-radius: var(--v2-radius); background: var(--panel); }
body.v2 .v2-pulse.is-collapsed .v2-pulse-label { display: block; }
body.v2 .v2-pulse.is-collapsed .v2-pulse-summary { display: flex; }

/* ---------- Narrow: the cards keep a readable width and scroll sideways ---------- */
@media (max-width: 860px) {
  body.v2 .v2-pulse-head { position: static; min-height: 28px; margin-bottom: 6px; padding-left: 2px; }
  body.v2 .v2-pulse.is-collapsed .v2-pulse-head { margin-bottom: 0; }
  body.v2 .v2-pulse-label { display: block; }
  body.v2 .v2-pulse-breadth header { padding-right: 0; }
  body.v2 .v2-pulse-cards { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none; }
  body.v2 .v2-pulse-cards::-webkit-scrollbar { display: none; }
  body.v2 .v2-pulse-card { scroll-snap-align: start; }
}

/* A mouse cannot swipe. Between phone and desktop widths (half a laptop screen)
   it gets a thin scrollbar to reach the card that is cut at the edge. */
@media (min-width: 701px) and (max-width: 860px) and (hover: hover) and (pointer: fine) {
  body.v2 .v2-pulse-cards { padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: var(--subtle) transparent; }
}

/* ---------- Phone: one card at a time, the next one showing at the edge ---------- */
@media (max-width: 700px) {
  body.v2 .v2-pulse { margin-bottom: 10px; }
  body.v2 .v2-pulse-cards { grid-auto-columns: 85%; gap: 8px; scroll-snap-type: x mandatory; }
  body.v2 .v2-pulse.is-collapsed .v2-pulse-head { padding-left: 12px; }
  body.v2 .v2-pulse-summary .is-flat, body.v2 .v2-pulse-summary .is-average { display: none; }
  /* Choosing a list scrolls the table to the top of the screen; keep the pulse
     of that list (and the 50px sticky masthead) above it. */
  body.v2 .v2-pulse:not([hidden]) + .panel { scroll-margin-top: 182px; }
  body.v2 .v2-pulse.is-collapsed:not([hidden]) + .panel { scroll-margin-top: 58px; }
}

@media (prefers-reduced-motion: reduce) {
  body.v2 .v2-pulse-bar i, body.v2 .v2-pulse-toggle svg { transition: none; }
}
