/* Quote currency belongs to the amount, so every figure remains self-contained. */
.quote-amount {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px 7px;
  max-width: 100%;
  vertical-align: baseline;
}
.quote-number {
  min-width: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  overflow-wrap: normal;
}
.quote-unit {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font: 500 .6875rem/1.25 var(--sans);
  letter-spacing: .025em;
  white-space: nowrap;
  vertical-align: middle;
}
.quote-unit img {
  display: block;
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  object-fit: contain;
}

/* Three overview cards above the adjacent historical/live trade counts. */
.metrics-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.metrics-grid > .metric {
  grid-column: span 2;
  container-type: inline-size;
}
.metrics-grid > .metric-trades-total,
.metrics-grid > .metric-live {
  grid-column: span 3;
}
.metric-heading {
  align-items: flex-start;
}
.metric h2 {
  line-height: 1.4;
}
.metric-icon {
  margin-top: 1px;
}
.metric-value {
  min-height: 45px;
  font-size: 1.75rem;
  font-size: clamp(1.375rem, 14cqi, 2rem);
  white-space: normal;
}
.metric-value .quote-amount {
  justify-content: flex-start;
  gap: 5px 7px;
  line-height: 1.3;
}
.metric-value .quote-number {
  font-size: 1.375rem;
  font-size: clamp(1rem, 10cqi, 1.75rem);
  letter-spacing: -.045em;
}
.metric-value .quote-unit {
  color: var(--muted);
  font-size: .6875rem;
  font-weight: 500;
}
.metric p {
  line-height: 1.45;
}

/* The source timestamp and refresh state describe different things. */
.summary-heading {
  flex-wrap: wrap;
  row-gap: 9px;
}
.snapshot-meta {
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px 12px;
}
#stats-asof {
  font-variant-numeric: tabular-nums;
}
.snapshot-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 25px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font: 500 .6875rem/1.4 var(--sans);
  white-space: nowrap;
}
.snapshot-refresh::before {
  content: "";
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--faint);
}
.snapshot-refresh[data-state="live"]::before,
.snapshot-refresh[data-state="loading"]::before {
  background: var(--green);
}
.snapshot-refresh[data-state="loading"] {
  color: var(--green);
  background: var(--green-light);
}
.snapshot-refresh[data-state="error"] {
  color: var(--red);
  background: var(--red-light);
}
.snapshot-refresh[data-state="error"]::before {
  background: currentColor;
}
.snapshot-refresh[data-state="paused"] {
  background: var(--surface-soft);
}

/* A second, quieter line preserves the tape's compact numeric columns. */
.trade-table .quote-amount {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 3px;
  line-height: 1.25;
}
.trade-table .quote-unit {
  font-size: .6875rem;
  letter-spacing: .01em;
}
.trade-table .quote-unit img {
  width: 12px;
  height: 12px;
}

/* Keep the price, its denomination, and its independently ticking age together. */
.market-list > .market-item {
  min-height: 77px;
}
.market-last-price {
  display: block;
}
.market-last-price .quote-amount {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 3px;
}
.market-last-price .quote-number {
  line-height: 1.25;
}
.market-last-price .quote-unit {
  font-size: .6875rem;
  letter-spacing: .025em;
}
.market-last-price .quote-unit img {
  width: 12px;
  height: 12px;
}
.market-item .market-price .market-last-time {
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}
#trade-detail dd .quote-amount {
  justify-content: flex-start;
  row-gap: 5px;
}

/* The filter carries the same currency cue as the values it filters. */
.quote-input {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}
.quote-input > input {
  width: 100%;
  padding-right: 78px;
}
.quote-input > .quote-unit {
  position: absolute;
  top: 50%;
  right: 11px;
  transform: translateY(-50%);
  pointer-events: none;
}
.quote-input > input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}
.quote-input > input::-webkit-inner-spin-button,
.quote-input > input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

@media (min-width: 1200px) {
  .metrics-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
  .metrics-grid > .metric,
  .metrics-grid > .metric-trades-total,
  .metrics-grid > .metric-live {
    grid-column: auto;
  }
}

@media (max-width: 650px) {
  .summary-heading {
    align-items: flex-start;
    flex-wrap: nowrap;
  }
  .summary-heading .small-heading {
    padding-top: 5px;
  }
  .snapshot-meta {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: end;
    gap: 6px 9px;
  }
  #stats-asof {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: 225px;
    font-size: .6875rem;
    line-height: 1.4;
    text-align: right;
  }
  .snapshot-refresh {
    grid-column: 1;
    grid-row: 1;
    justify-self: end;
  }
  .snapshot-meta .text-button {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metrics-grid > .metric,
  .metrics-grid > .metric-trades-total,
  .metrics-grid > .metric-live {
    grid-column: auto;
  }
  .metric-value {
    min-height: 43px;
    margin-top: 11px;
  }
  .metric-value .quote-amount {
    gap: 5px 6px;
  }
  .metric-value .quote-number {
    font-size: 1rem;
    font-size: clamp(1rem, 10cqi, 1.5rem);
  }
  .metrics-grid > .metric-traders {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 14px;
    padding-top: 13px;
    padding-bottom: 13px;
    align-items: center;
  }
  .metric-traders .metric-heading {
    grid-column: 1;
    grid-row: 1;
  }
  .metric-traders .metric-value {
    grid-column: 2;
    grid-row: 1 / 3;
    margin: 0;
    min-height: 0;
    font-size: 1.625rem;
    text-align: right;
  }
  .metric-traders p {
    grid-column: 1;
    grid-row: 2;
    margin-top: 3px;
  }
  .metric-trades-total .metric-heading,
  .metric-live .metric-heading {
    min-height: 2.45em;
  }
}
