/* The tape: one paper trade replayed session by session, a newspaper chart beside a column of dispatches.
   Every selector is scoped under .m-tape. Colours come only from the tokens in styles.css. */
.m-tape {
  --tp-disp-w: 336px;
  --tp-gap: 30px;
  --tp-thumb: 10px;
  --tp-hatch-risk: repeating-linear-gradient(135deg, color-mix(in srgb, var(--red) 52%, transparent) 0 1px, transparent 1px 5px);
  --tp-hatch-room: repeating-linear-gradient(135deg, color-mix(in srgb, var(--green) 40%, transparent) 0 1px, transparent 1px 7px);
  --tp-hatch-ink: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ink) 16%, transparent) 0 1px, transparent 1px 6px);
}
.m-tape [hidden] { display: none !important; }
.m-tape .tp-n { font: 400 .9em/1 var(--mono); letter-spacing: -.02em; font-style: normal; }
.m-tape .tp-lab { font: 600 10.5px/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.m-tape .tp-head { overflow-wrap: anywhere; text-wrap: balance; }
.m-tape .tp-dek { max-width: 760px; }

/* The picker: a ruled line, like a dateline */
.m-tape .tp-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 0; border-top: 1px solid var(--rule); }
.m-tape .tp-pick .tp-lab { color: var(--ink); }
.m-tape .tp-sel { position: relative; display: inline-block; max-width: 100%; min-width: 0; flex: 0 1 auto; }
.m-tape .tp-sel::after { content: ''; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -6px; border: solid var(--ink); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); pointer-events: none; }
.m-tape .tp-sel select {
  -webkit-appearance: none; appearance: none; width: 100%; min-height: 38px; padding: 8px 36px 8px 11px;
  font: 500 13.5px/1.2 var(--mono); letter-spacing: -.01em; background: var(--card); color: var(--ink); border: 1px solid var(--ink); border-radius: 0; cursor: pointer;
  text-overflow: ellipsis;
}
.m-tape .tp-sel select:hover { background: var(--paper2); }
.m-tape .tp-pick-n { margin-left: auto; }

/* Where the trades come from */
.m-tape .tp-src { font: italic 400 15px/1.5 var(--serif); color: var(--muted); max-width: 860px; margin: 0 0 22px; }
.m-tape .tp-src b { font: 600 10.5px/1 var(--sans); font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: var(--ink); margin-right: 4px; }
.m-tape .tp-note { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 16px; align-items: baseline; margin: 0 0 22px; padding: 11px 14px 12px; border: 1px solid var(--ink); background: var(--tp-hatch-ink), var(--card); max-width: 920px; }
.m-tape .tp-note-k { font: 600 10.5px/1.5 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink); white-space: nowrap; background: var(--card); padding: 1px 0; }
.m-tape .tp-note p { margin: 0; font: italic 400 15px/1.5 var(--serif); color: var(--ink); background: var(--card); }

/* Two columns: the player, and the dispatches */
.m-tape .tp-grid { display: grid; grid-template-columns: minmax(0, 1fr) var(--tp-disp-w); border-top: 2px solid var(--ink); }
.m-tape .tp-main { container: tp-main / inline-size; min-width: 0; padding: 16px var(--tp-gap) 4px 0; }
.m-tape .tp-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }
.m-tape .tp-main[aria-busy="true"] .tp-plot { opacity: .45; transition: opacity .2s; }

/* The result, set like a front-page figure */
.m-tape .tp-top { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: 10px 30px; padding-bottom: 16px; }
.m-tape .tp-res { min-width: 0; }
.m-tape .tp-big {
  font: 800 104px/.84 var(--serif); letter-spacing: -.045em; font-variant-numeric: lining-nums tabular-nums;
  margin: 12px 0 0 -4px; white-space: nowrap; min-width: 4.2ch;
}
.m-tape .tp-big.up { color: var(--green); }
.m-tape .tp-big.dn { color: var(--red); }
.m-tape .tp-big.flat { color: var(--ink); }
.m-tape .tp-big.is-word { color: var(--muted); font-style: italic; font-weight: 400; letter-spacing: -.02em; }
.m-tape .tp-big-u { font-size: .5em; letter-spacing: 0; margin-left: .05em; font-weight: 600; }
.m-tape .tp-id { min-width: 0; padding-bottom: 2px; border-left: 1px solid var(--rule); padding-left: 22px; }
.m-tape .tp-sym { font: 800 30px/1 var(--serif); letter-spacing: -.015em; }
.m-tape .tp-dir { font: 600 11px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; margin-left: 10px; vertical-align: 6px; }
.m-tape .tp-meta { font: 12.5px/1.45 var(--sans); color: var(--muted); margin-top: 7px; }
.m-tape .tp-state { font: italic 400 16.5px/1.4 var(--serif); margin-top: 6px; color: var(--ink); }

/* The stat strip */
.m-tape .tp-stats { display: grid; grid-template-columns: 1fr 1.25fr .9fr .9fr 1.45fr .8fr; margin: 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.m-tape .tp-stat { min-width: 0; padding: 9px 10px 10px 12px; border-left: 1px solid var(--rule); }
.m-tape .tp-stat:first-child { border-left: 0; padding-left: 0; }
.m-tape .tp-stat dt { font: 600 10px/1.3 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-tape .tp-stat dd { margin: 5px 0 0; font: 500 16px/1.2 var(--mono); letter-spacing: -.02em; white-space: nowrap; }
.m-tape .tp-sl { color: var(--muted); margin: 0 .12em; font-weight: 400; }
.m-tape .tp-dash { color: var(--muted); }

/* The chart */
.m-tape .tp-figure { margin: 16px 0 0; }
.m-tape .tp-cap { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 16px; margin-bottom: 6px; }
.m-tape .tp-cap .tp-lab { color: var(--ink); }
.m-tape .tp-cap-k { font: italic 400 13.5px/1.4 var(--serif); color: var(--muted); }
.m-tape .tp-plot { position: relative; height: 380px; }
.m-tape .tp-chart { position: absolute; inset: 0; z-index: 1; }
.m-tape .tp-over { position: absolute; left: 0; top: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.m-tape .tp-band { position: absolute; display: none; }
.m-tape .tp-risk { background: var(--tp-hatch-risk); }
.m-tape .tp-room { background: var(--tp-hatch-room); }
.m-tape .tp-now { position: absolute; top: 0; bottom: 0; width: 0; display: none; border-left: 1px solid var(--accent); }
.m-tape .tp-plot.is-empty { height: auto; min-height: 220px; display: grid; place-items: center; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); background: var(--tp-hatch-ink); }
.m-tape .tp-nodata { max-width: 440px; margin: 28px 20px; padding: 14px 18px; background: var(--paper); text-align: center; }
.m-tape .tp-nodata p { margin: 0; font: italic 400 15px/1.5 var(--serif); color: var(--muted); }
.m-tape .tp-nodata p + p { margin-top: 6px; }
.m-tape .tp-nodata b { font: 600 19px/1.3 var(--serif); font-style: normal; color: var(--ink); }
.m-tape .tp-key { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 8px; font: 12px/1.4 var(--sans); color: var(--muted); }
.m-tape .tp-key.is-void > span:not(:last-child) { display: none; }
.m-tape .tp-sw { display: inline-block; width: 18px; height: 10px; margin-right: 7px; vertical-align: -1px; }
.m-tape .tp-sw-risk { background: var(--tp-hatch-risk); outline: 1px solid color-mix(in srgb, var(--red) 55%, transparent); outline-offset: -1px; }
.m-tape .tp-sw-room { background: var(--tp-hatch-room); outline: 1px solid color-mix(in srgb, var(--green) 45%, transparent); outline-offset: -1px; }
.m-tape .tp-sw-now { width: 0; height: 12px; border-left: 1px solid var(--accent); margin: 0 9px 0 4px; vertical-align: -2px; }

/* Transport: a ruled bar of typographic buttons */
.m-tape .tp-transport { display: flex; margin-top: 14px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); }
.m-tape .tp-b {
  -webkit-appearance: none; appearance: none; margin: 0; border: 0; border-radius: 0; background: none; color: var(--ink); cursor: pointer;
  font: 600 11.5px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; min-height: 42px; padding: 0 15px; white-space: nowrap;
}
.m-tape .tp-b:hover { background: var(--paper2); }
.m-tape .tp-b:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.m-tape .tp-transport .tp-b + .tp-b { border-left: 1px solid var(--rule); }
.m-tape .tp-transport .tp-b[aria-disabled="true"] { color: var(--muted); opacity: .55; cursor: default; }
.m-tape .tp-transport .tp-b[aria-disabled="true"]:hover { background: none; }
.m-tape .tp-play { min-width: 104px; background: var(--ink); color: var(--paper); }
.m-tape .tp-play:hover { background: var(--ink); color: var(--paper); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.m-tape .tp-transport .tp-play + .tp-b { border-left-color: var(--ink); }
.m-tape .tp-transport [data-a="decision"] { margin-left: auto; border-left: 1px solid var(--rule); }

/* The scrubber: one line, a tick per session (tall ticks are decisions), the accent bar is "now" */
.m-tape .tp-scrub { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 6px 22px; padding: 8px 0 4px; }
.m-tape .tp-rail { position: relative; height: 40px; min-width: 0; }
.m-tape .tp-track, .m-tape .tp-prog { position: absolute; top: 50%; left: 0; height: 0; pointer-events: none; }
.m-tape .tp-track { right: 0; border-top: 1px solid var(--ink); }
.m-tape .tp-prog { left: calc(var(--tp-thumb) / 2); width: calc((100% - var(--tp-thumb)) * var(--p, 0)); border-top: 3px solid var(--ink); margin-top: -1px; }
.m-tape .tp-ticks { position: absolute; left: calc(var(--tp-thumb) / 2); right: calc(var(--tp-thumb) / 2); top: 50%; height: 0; pointer-events: none; }
.m-tape .tp-tick { position: absolute; left: calc(var(--x) * 100%); top: -4px; width: 0; height: 8px; border-left: 1px solid var(--muted); }
.m-tape .tp-tick.is-key { top: -9px; height: 18px; border-left: 1.5px solid var(--ink); }
.m-tape .tp-rail input[type=range] { -webkit-appearance: none; appearance: none; position: relative; z-index: 1; display: block; width: 100%; height: 40px; margin: 0; padding: 0; background: transparent; cursor: pointer; }
.m-tape .tp-rail input[type=range]:disabled { cursor: default; }
.m-tape .tp-rail input[type=range]:focus { outline: none; }
.m-tape .tp-rail input[type=range]::-webkit-slider-runnable-track { height: 40px; background: transparent; border: 0; }
.m-tape .tp-rail input[type=range]::-moz-range-track { height: 40px; background: transparent; border: 0; }
.m-tape .tp-rail input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: var(--tp-thumb); height: 26px; margin-top: 7px; border: 0; border-radius: 0; background: var(--accent); }
.m-tape .tp-rail input[type=range]::-moz-range-thumb { width: var(--tp-thumb); height: 26px; border: 0; border-radius: 0; background: var(--accent); }
.m-tape .tp-rail input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }
.m-tape .tp-rail input[type=range]:focus-visible::-moz-range-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }
.m-tape .tp-pos { display: grid; justify-items: end; gap: 3px; font: 400 12px/1.2 var(--mono); color: var(--muted); white-space: nowrap; min-width: 9.5rem; }
.m-tape .tp-pos b { color: var(--ink); font-weight: 500; }
.m-tape .tp-pos-n { font: 600 10.5px/1.2 var(--sans); letter-spacing: .12em; text-transform: uppercase; }
.m-tape .tp-pos-n b { font: 500 13px/1 var(--mono); letter-spacing: 0; }
.m-tape .tp-speed { display: flex; align-items: center; border-left: 1px solid var(--rule); padding-left: 14px; }
.m-tape .tp-speed .tp-lab { margin-right: 4px; }
.m-tape .tp-sp { min-width: 38px; min-height: 36px; padding: 0 6px; font: 400 13px/1 var(--mono); letter-spacing: 0; text-transform: none; color: var(--muted); }
.m-tape .tp-sp[aria-pressed="true"] { color: var(--ink); font-weight: 500; text-decoration: underline; text-decoration-color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 6px; }

/* Dispatches: the right-hand column */
.m-tape .tp-disp { display: grid; grid-template-rows: auto minmax(0, 1fr); min-width: 0; padding: 16px 0 0 24px; border-left: 1px solid var(--rule); }
.m-tape .tp-disp-head { padding-bottom: 10px; border-bottom: 1px solid var(--ink); }
.m-tape .tp-disp-head h3 { margin: 0; font: 800 23px/1.05 var(--serif); letter-spacing: -.015em; text-transform: none; color: var(--ink); }
.m-tape .tp-disp-sub { display: block; margin-top: 4px; font: italic 400 13.5px/1.4 var(--serif); color: var(--muted); }
.m-tape .tp-logwrap { position: relative; min-height: 260px; }
.m-tape .tp-log { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.m-tape .tp-d { border-bottom: 1px solid var(--rule); }
.m-tape .tp-d-b {
  display: block; width: 100%; margin: 0; padding: 10px 6px 11px 13px; border: 0; border-left: 3px solid transparent; border-radius: 0;
  background: none; color: var(--muted); font: inherit; text-align: left; cursor: pointer;
}
.m-tape .tp-d-b:hover { background: var(--paper2); color: var(--ink); }
.m-tape .tp-d-b:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.m-tape .is-cur .tp-d-b { border-left-color: var(--accent); color: var(--ink); background: var(--card); }
.m-tape .tp-d-meta { display: flex; align-items: baseline; gap: 10px; }
.m-tape .tp-d-meta time { font: 400 11.5px/1.3 var(--mono); color: var(--muted); }
.m-tape .tp-d-act { font: 600 10.5px/1.3 var(--sans); letter-spacing: .15em; color: var(--ink); }
.m-tape .tp-act-HOLD, .m-tape .tp-act-VOID { color: var(--muted); }
.m-tape .tp-d-act.up { color: var(--green); }
.m-tape .tp-d-act.dn { color: var(--red); }
.m-tape .tp-d-r { margin-left: auto; font: 500 12px/1.3 var(--mono); }
.m-tape .tp-d-r.up { color: var(--green); }
.m-tape .tp-d-r.dn { color: var(--red); }
.m-tape .tp-d-r.flat { color: var(--ink); }
.m-tape .tp-d-body { display: block; margin-top: 4px; font: 400 15px/1.45 var(--serif); }
.m-tape .tp-d-body .tp-n { color: var(--ink); }
.m-tape .tp-d:not(.is-cur) .tp-d-body .tp-n { color: inherit; }
.m-tape .is-new .tp-d-b { animation: tp-set .42s cubic-bezier(.2, .7, .2, 1); }
@keyframes tp-set { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.m-tape .tp-foot { margin: 18px 0 0; padding-top: 8px; border-top: 1px solid var(--rule); font: italic 400 13.5px/1.5 var(--serif); color: var(--muted); }

/* Empty state */
.m-tape .tp-empty { display: grid; place-items: center; min-height: 200px; padding: 28px 16px; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); background: var(--tp-hatch-ink); }
.m-tape .tp-empty p { margin: 0; max-width: 440px; padding: 14px 18px; background: var(--paper); text-align: center; font: italic 400 17px/1.5 var(--serif); color: var(--muted); }

/* Narrow player column (tablets, and the phone) */
@container tp-main (max-width: 640px) {
  .m-tape .tp-big { font-size: 84px; }
  .m-tape .tp-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .m-tape .tp-stat:nth-child(4) { border-left: 0; padding-left: 0; }
  .m-tape .tp-stat:nth-child(n + 4) { border-top: 1px solid var(--rule); }
  .m-tape .tp-transport { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .m-tape .tp-transport .tp-b { padding: 0 6px; }
  .m-tape .tp-transport .tp-wide { grid-column: span 2; border-top: 1px solid var(--rule); margin-left: 0; }
  .m-tape .tp-transport [data-a="decision"] { border-left: 0; }
  .m-tape .tp-transport .tp-play + .tp-b { border-left-color: var(--rule); }
  .m-tape .tp-scrub { grid-template-columns: minmax(0, 1fr) auto; }
  .m-tape .tp-rail { grid-column: 1 / -1; }
  .m-tape .tp-pos { justify-items: start; min-width: 0; }
}
@container tp-main (max-width: 440px) {
  .m-tape .tp-top { grid-template-columns: minmax(0, 1fr); }
  .m-tape .tp-big { font-size: 76px; }
  .m-tape .tp-id { border-left: 0; padding-left: 0; padding-top: 12px; border-top: 1px solid var(--rule); }
  .m-tape .tp-stat { padding: 8px 6px 9px 9px; }
  .m-tape .tp-stat dd { font-size: 14px; }
  .m-tape .tp-speed { padding-left: 8px; }
  .m-tape .tp-speed .tp-lab { display: none; }
}

/* One column: the dispatches move under the player */
@media (max-width: 920px) {
  .m-tape .tp-grid { grid-template-columns: minmax(0, 1fr); }
  .m-tape .tp-main { padding-right: 0; }
  .m-tape .tp-disp { display: block; padding: 26px 0 0; border-left: 0; }
  .m-tape .tp-disp-head { border-top: 2px solid var(--ink); padding-top: 10px; }
  .m-tape .tp-logwrap { min-height: 0; }
  .m-tape .tp-log { position: static; max-height: 380px; }
}
@media (max-width: 760px) {
  .m-tape .tp-pick { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 12px; }
  .m-tape .tp-pick .tp-sel { grid-column: 1 / -1; grid-row: 2; }
  .m-tape .tp-pick-n { margin-left: auto; }
  .m-tape .tp-sel { width: 100%; }
  .m-tape .tp-plot { height: 300px; }
  .m-tape .tp-note { grid-template-columns: minmax(0, 1fr); }
  .m-tape .tp-d-body { font-size: 15.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .m-tape .is-new .tp-d-b { animation: none; }
  .m-tape .tp-main[aria-busy="true"] .tp-plot { transition: none; }
}
