#marketHistorySection .history-layout {
  display: grid;
  grid-template-columns: minmax(240px, 285px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

#marketHistorySection [hidden] { display: none; }

#marketHistorySection .focus-block {
  min-width: 0;
  border-color: var(--border);
  background: var(--surface-1);
  box-shadow: none;
}

#marketHistorySection .focus-block:hover { transform: none; }

#marketHistorySection .history-chart { margin-bottom: 16px; }

#marketHistorySection .history-chart-heading {
  align-items: start;
  flex-wrap: wrap;
  gap: 8px 16px;
}

#marketHistorySection .history-chart-heading h3 { margin-bottom: 3px; }

#marketHistorySection .history-chart-plot {
  width: 100%;
  height: clamp(320px, 42vh, 460px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

#marketHistorySection .history-chart-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: calc(12px * var(--ui-font-scale, 1.14));
}

#marketHistorySection .history-chart-news {
  display: grid;
  gap: 5px;
  margin-top: 12px;
  padding: 10px 12px;
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

#marketHistorySection .history-chart-news p { margin: 0; }

#marketHistorySection :is(.history-chart-news-header, .history-chart-news-links) {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 16px;
}

#marketHistorySection .history-chart-news-header { justify-content: space-between; }

#marketHistorySection #caseSearch { scroll-margin-top: 76px; }

#marketHistorySection .history-chart-events {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

#marketHistorySection .history-chart-events button { white-space: normal; text-align: start; }

#marketHistorySection .history-index {
  display: grid;
  gap: 10px;
}

#marketHistorySection .history-index .focus-head { margin: 0; }

#marketHistorySection .history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#marketHistorySection .history-filters button {
  min-height: 34px;
  padding: 4px 9px;
  font-size: calc(12px * var(--ui-font-scale, 1.14));
}

#marketHistorySection :is(.history-filters, .history-chart-events) [aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--border-strong);
  color: var(--accent-strong);
}

#marketHistorySection ul,
#marketHistorySection ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

#marketHistorySection .history-list {
  display: grid;
  gap: 6px;
  max-height: min(60vh, 620px);
  overflow-y: auto;
  scrollbar-width: thin;
}

#marketHistorySection .case-option {
  display: grid;
  width: 100%;
  gap: 3px;
  min-height: 56px;
  padding: 8px 10px;
  text-align: left;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--ink);
  font: inherit;
}

#marketHistorySection .case-option:is(:hover, [aria-pressed="true"]) {
  border-color: var(--border-strong);
  background: var(--accent-soft);
}

#marketHistorySection .case-option[aria-pressed="true"] { box-shadow: inset 3px 0 var(--accent); }

#marketHistorySection .case-option-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 8px;
  font-variant-numeric: tabular-nums;
}

#marketHistorySection :is(.case-option-meta, .news-time, .case-date, .history-milestones time) {
  color: var(--muted);
  font-size: calc(12px * var(--ui-font-scale, 1.14));
}

#marketHistorySection .case-option-title {
  font-size: calc(13px * var(--ui-font-scale, 1.14));
  font-weight: 700;
}

#marketHistorySection :is(.phase-label, .case-note-label) { color: var(--accent-strong); }

#marketHistorySection .history-detail { min-width: 0; }

#marketHistorySection .case-header {
  border-bottom: 1px solid var(--border);
  padding: 0 0 12px;
}

#marketHistorySection .case-date { margin: 0; }

#marketHistorySection #caseTitle {
  font-size: calc(20px * var(--ui-font-scale, 1.14));
  margin: 3px 0 7px;
  scroll-margin-top: 76px;
}

#marketHistorySection .case-summary {
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

#marketHistorySection .history-block-title {
  margin: 0 0 9px;
  font-size: calc(15px * var(--ui-font-scale, 1.14));
}

#marketHistorySection :is(#caseFacts, #caseDetail) {
  display: grid;
  gap: 14px;
}

#marketHistorySection #caseDetail[hidden] { display: none; }

#marketHistorySection .history-metrics {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr));
}

#marketHistorySection .history-columns {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

#marketHistorySection :is(.history-news, .history-movers, .history-milestones) li {
  padding-block: 7px;
}

#marketHistorySection :is(.history-news, .history-movers, .history-milestones) li + li {
  border-top: 1px solid var(--border-subtle);
}

#marketHistorySection :is(.history-news, .history-movers, .history-milestones) li:last-child { padding-bottom: 0; }
#marketHistorySection .history-news li p { margin: 3px 0 5px; }

#marketHistorySection .history-stock-market {
  margin: 12px 0 0;
  font: inherit;
  font-weight: 700;
  color: var(--muted);
}

#marketHistorySection .history-movers li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 8px;
  align-items: baseline;
}

#marketHistorySection .history-movers small {
  display: inline-block;
  margin-inline-start: 7px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#marketHistorySection .history-movers li > span {
  text-align: right;
  font-weight: 700;
}

#marketHistorySection .history-milestones li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
}

#marketHistorySection .history-milestones li > span { color: var(--muted); }

#marketHistorySection .history-later { padding-block: 10px; }
#marketHistorySection .history-later summary { font-weight: 700; }
#marketHistorySection .history-later p { margin: 7px 0; }

#marketHistorySection .history-journal {
  border-inline-start: 3px solid var(--accent);
}

#marketHistorySection .journal-question {
  color: var(--accent-strong);
  margin: 0 0 12px;
}

#marketHistorySection .history-journal textarea { min-height: 64px; }

#marketHistorySection :is(.history-references ul, .history-related div) {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 16px;
}

#marketHistorySection a {
  color: var(--accent-strong);
  text-underline-offset: .2em;
}

#marketHistorySection .history-empty { margin: 0; }

@media (max-width: 1080px) {
  #marketHistorySection .history-layout { grid-template-columns: minmax(0, 1fr); }
  #marketHistorySection .history-list {
    max-height: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(175px, 42%);
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    padding: 4px;
    margin: 0 -4px;
    scrollbar-width: thin;
  }
  #marketHistorySection .case-option { height: 100%; }
}

@media (max-width: 500px) {
  #marketHistorySection .history-chart-plot { height: 286px; }
  #marketHistorySection .history-list { grid-auto-columns: minmax(156px, 71%); }
  #marketHistorySection .history-filters button { min-height: 40px; }
  #marketHistorySection .history-metrics { grid-template-columns: minmax(0, 1fr); }
  #marketHistorySection .market-index-card {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: baseline;
    gap: 9px;
    padding: 9px 10px;
  }
  #marketHistorySection .market-index-close { font-size: calc(16px * var(--ui-font-scale, 1.14)); }
  #marketHistorySection .history-milestones li { grid-template-columns: auto minmax(0, 1fr); gap: 2px 9px; }
  #marketHistorySection .history-milestones li > span { grid-column: 2; }
}
