/* Market stats app (js/market.js) */
#ms-app { display: grid; gap: 1.25rem; }
.ms-h { margin: 0; }
.ms-bar { position: sticky; top: var(--ms-top, 0px); z-index: 40; display: flex; align-items: center; gap: .6rem .9rem; background: #fff; border: 1px solid var(--line); border-bottom: 2px solid var(--gold); border-radius: var(--radius); padding: .5rem .75rem; box-shadow: 0 4px 12px rgba(20,32,58,.08); }
.ms-types { min-height: 2.75rem; flex: 0 0 auto; }
.ms-types button { min-width: 6.5rem; }
.ms-sm-t { display: none; }
.ms-pick { flex: 1 1 14rem; min-width: 0; }
.ms-pick select { font: inherit; font-size: var(--text-small); width: 100%; min-height: 2.75rem; padding: .5rem .7rem; border: 1px solid var(--border-control); border-radius: var(--radius); background: #fff; color: var(--navy); font-weight: 600; text-overflow: ellipsis; }
.ms-nav { margin: 0; }
.ms-nav[hidden] { display: none; }
.ms-nav__t { margin: 0 0 .45rem; font-size: var(--text-caption); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ms-chips2 { display: flex; gap: .5rem; overflow-x: auto; padding: 0 0 .5rem; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.ms-chip2 { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 2.75rem; padding: .35rem 1rem; border: 1px solid var(--border-control); border-radius: 999px; background: #fff; color: var(--navy); font-size: var(--text-small); font-weight: 600; text-decoration: none; white-space: nowrap; scroll-snap-align: start; }
.ms-chip2:hover { border-color: var(--navy); }
.ms-chip2.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.ms-chip2:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.ms-banner { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1.5rem 2rem; align-items: center; background: #fff; border: 1px solid var(--line); border-left: 6px solid var(--navy); border-radius: var(--radius); padding: clamp(1rem, 3vw, 1.75rem); }
.ms-banner.ms-buyer { border-left-color: #2f6f8f; }
.ms-banner.ms-balanced { border-left-color: var(--gold); }
.ms-banner.ms-seller { border-left-color: #a8442f; }
.ms-banner p { margin: 0 0 .5rem; max-width: 46rem; }
.ms-eyebrow { font-size: var(--text-caption); letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ms-verdict { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0 0 .4rem; color: var(--navy); }
.ms-gauge__bar { position: relative; display: flex; height: 14px; border-radius: 7px; overflow: visible; }
.ms-gauge__bar span { height: 100%; }
.ms-gauge__bar .g1 { width: 40%; background: #2f6f8f; border-radius: 7px 0 0 7px; }
.ms-gauge__bar .g2 { width: 26.67%; background: var(--gold); }
.ms-gauge__bar .g3 { width: 33.33%; background: #a8442f; border-radius: 0 7px 7px 0; }
.ms-gauge__bar i { position: absolute; top: -6px; width: 4px; height: 26px; background: var(--navy); border: 2px solid #fff; border-radius: 2px; transform: translateX(-50%); box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.ms-gauge__lab { display: flex; justify-content: space-between; font-size: var(--text-caption); color: var(--charcoal); margin-top: .6rem; }
.ms-gauge__num { margin-top: .15rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ms-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(210px, 100%), 1fr)); gap: .75rem; }
.ms-tiles li { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: .85rem 1rem; }
.ms-chg { display: block; font-size: var(--text-caption); color: var(--muted); margin-top: .2rem; }
.ms-chg .ms-up { color: #1d6b43; font-weight: 700; }
.ms-chg .ms-down { color: #a8442f; font-weight: 700; }
.ms-search { display: grid; grid-template-columns: minmax(0, 1.3fr) repeat(3, minmax(0, 1fr)) auto; gap: .75rem 1rem; align-items: end; background: var(--navy); color: #fff; border-radius: var(--radius); padding: clamp(1rem, 3vw, 1.5rem); }
.ms-search h3 { color: #fff; margin: 0 0 .15rem; font-size: 1.3rem; }
.ms-search .ms-note { color: var(--on-navy-muted); margin: 0; }
.ms-search label { display: flex; flex-direction: column; gap: .3rem; font-size: var(--text-small); font-weight: 600; }
.ms-search select { font: inherit; padding: .7rem .8rem; min-height: 3.25rem; border: 1px solid var(--border-control); border-radius: var(--radius); background: #fff; color: var(--charcoal); width: 100%; }
.ms-search .btn { min-height: 3.25rem; }
.ms-card { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: clamp(1rem, 3vw, 1.75rem); min-width: 0; }
.ms-card h3 { margin: 0 0 .25rem; font-size: clamp(1.25rem, 2.6vw, 1.55rem); }
.ms-note { color: var(--muted); font-size: var(--text-small); margin: 0 0 1rem; max-width: 52rem; }
.ms-row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.5rem; margin-bottom: .75rem; }
.ms-meas { flex-wrap: wrap; }
.ms-check { font-size: var(--text-small); font-weight: 600; color: var(--navy); display: inline-flex; align-items: center; gap: .4rem; }
.ms-check input { width: 1.15rem; height: 1.15rem; accent-color: var(--navy); }
.ms-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
.ms-chip { font: inherit; font-size: var(--text-small); font-weight: 600; padding: .5rem .95rem; min-height: 2.75rem; border: 1px solid var(--border-control); background: #fff; color: var(--navy); border-radius: 999px; cursor: pointer; }
.ms-chip[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.ms-readout { min-height: 1.6em; margin: 0 0 .4rem; font-variant-numeric: tabular-nums; color: var(--charcoal); }
.ms-tl { margin-top: .75rem; }
.ms-tl__svg { display: block; width: 100%; height: 54px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.ms-tl__win { fill: rgba(201,168,76,.28); }
.ms-tl__line { fill: none; stroke: var(--navy); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.ms-tl__years { position: relative; height: 2.9rem; margin: 0 0 .25rem; }
.ms-tl__years button { position: absolute; top: 0; transform: translateX(-50%); font: inherit; font-size: var(--text-caption); padding: .25rem .1rem; min-width: 1.5rem; min-height: 2.75rem; border: 0; background: none; color: var(--navy); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-variant-numeric: tabular-nums; }
.ms-tl__years button[aria-pressed="true"] { font-weight: 800; color: #000; }
.ms-y2 { font-size: .7rem; color: var(--muted); }
.ms-y4 { display: none; }
.is-major .ms-y4 { display: inline; }
.is-major .ms-y2 { display: none; }
@media (max-width: 640px) {
  .ms-tl__years { display: flex; gap: .4rem; height: auto; overflow-x: auto; padding: .6rem 0 .4rem; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .ms-tl__years button { position: static; transform: none; flex: 0 0 auto; min-width: 3.5rem; min-height: 2.75rem; padding: .4rem .7rem; font-size: var(--text-small); text-decoration: none; border: 1px solid var(--border-control); border-radius: 999px; background: #fff; scroll-snap-align: center; }
  .ms-tl__years button[aria-pressed="true"] { background: var(--navy); color: #fff; font-weight: 700; }
  .ms-y4, .is-major .ms-y4 { display: inline; }
  .ms-y2, .is-major .ms-y2 { display: none; }
  .ms-tl::after { content: "Swipe the years sideways to start the chart in any year back to 2005."; display: block; font-size: var(--text-caption); color: var(--muted); }
}
.ms-details { margin-top: 1rem; }
.ms-details summary { cursor: pointer; font-weight: 600; color: var(--navy); }
.ms-details .table-wrap { max-height: 22rem; overflow: auto; margin-top: .6rem; }
.ms-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
.ms-bars { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 1rem; }
.ms-bar__top, .ms-bar__foot { display: flex; justify-content: space-between; gap: 1rem; font-size: var(--text-small); }
.ms-bar__l { font-weight: 600; color: var(--navy); }
.ms-bar__v { font-weight: 700; font-variant-numeric: tabular-nums; }
.ms-few { font-weight: 500; font-size: var(--text-caption); color: var(--muted); }
.ms-bar__track { height: 14px; background: var(--white); border-radius: 7px; margin: .3rem 0; overflow: hidden; }
.ms-bar__fill { display: block; height: 100%; background: var(--navy); border-radius: 7px; transition: width .35s; }
.ms-bar__fill.is-few { background: #7d8aa6; }
.ms-bar__foot { color: var(--muted); font-size: var(--text-caption); }
.ms-bar__foot a { color: var(--navy); font-weight: 700; min-height: 2.75rem; display: inline-flex; align-items: center; }
.ms-donut { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 1rem 1.5rem; align-items: center; }
.ms-donut svg { width: 100%; height: auto; }
.ms-slice { transition: opacity .2s; cursor: pointer; }
.ms-donut a:hover .ms-slice, .ms-donut a:focus-visible .ms-slice { opacity: .8; }
.ms-donut a:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.ms-donut__big { font: 700 28px var(--serif); fill: var(--navy); }
.ms-donut__sub { font: 500 11px var(--sans); fill: var(--muted); }
.ms-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; }
.ms-legend a { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: .6rem; min-height: 2.75rem; color: var(--charcoal); text-decoration: none; font-size: var(--text-small); }
.ms-legend a:hover .ms-legend__l { text-decoration: underline; }
.ms-sw { width: 14px; height: 14px; border-radius: 3px; }
.ms-legend__l { font-weight: 600; color: var(--navy); }
.ms-legend__v { color: var(--muted); font-variant-numeric: tabular-nums; }
.ms-yoy__p { fill: #a9b3c9; background: #a9b3c9; }
.ms-yoy__c { fill: var(--navy); background: var(--navy); }
.ms-lg { display: flex; gap: 1.25rem; margin: .5rem 0 0; font-size: var(--text-small); }
.ms-lg i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: .4rem; vertical-align: -2px; }
.ms-source { font-size: var(--text-caption); color: var(--muted); margin: 0; max-width: 56rem; }
@media (max-width: 640px) {
  .ms-bar { gap: .4rem; padding: .4rem .5rem; flex-wrap: nowrap; }
  .ms-types button { min-width: 0; padding: .5rem .55rem; font-size: .8125rem; }
  .ms-lg-t { display: none; }
  .ms-sm-t { display: inline; }
  .ms-pick { flex: 1 1 0; }
  .ms-pick select { font-size: .8125rem; padding: .5rem .4rem; }
}
@media (max-width: 860px) {
  .ms-banner, .ms-grid { grid-template-columns: 1fr; }
  .ms-search { grid-template-columns: 1fr 1fr; }
  .ms-search .ms-search__t, .ms-search .btn { grid-column: 1 / -1; }
  .ms-donut { grid-template-columns: 1fr; justify-items: center; }
  .ms-donut .ms-legend { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { .ms-bar__fill, .ms-slice { transition: none; } }
.ms-search .btn { background: var(--gold); color: var(--navy); border-color: var(--gold); font-weight: 700; }
#ms-app, #ms-app > * { min-width: 0; max-width: 100%; }
.ms-nav, .ms-chips2 { min-width: 0; max-width: 100%; }
#ms-app { grid-template-columns: minmax(0, 1fr); }
.ms-chip2 { position: relative; }

/* ms-local */
.ms-local{background:#fff;border:1px solid rgba(27,43,75,.12);border-left:3px solid var(--gold,#C9A84C);border-radius:6px;padding:1.1rem 1.3rem;margin:1.4rem 0 0;max-width:46rem;color:var(--charcoal,#2C2C2C)}
.ms-local h2{font-size:1.25rem;margin:0 0 .5rem;color:var(--navy,#1B2B4B)}
.ms-local p{margin:.35rem 0 0}
.ms-datanote{font-size:.9rem;color:var(--muted,#5a5f6b)}

/* Chart upgrade (Dec 2026): hover price label, 1/3/5 year buttons and year menu */
.sc-chart-wrap { position: relative; }
.ms-tip { position: absolute; z-index: 3; pointer-events: none; background: var(--navy); color: #fff; border-radius: 8px; padding: .35rem .65rem; line-height: 1.25; white-space: nowrap; box-shadow: 0 4px 14px rgba(27,43,75,.25); transform: translate(-50%, -100%); opacity: 0; transition: opacity .12s; }
.ms-tip.show { opacity: 1; }
.ms-tip b { display: block; font-family: var(--serif); font-size: 1.2rem; font-weight: 700; }
.ms-tip span { color: var(--on-navy-muted); font-size: .78rem; }
.ms-chips { align-items: center; }
.ms-yearsel { font: inherit; font-size: var(--text-small); font-weight: 600; min-height: 2.75rem; padding: .5rem .7rem; border: 1px solid var(--border-control); border-radius: var(--radius); background: #fff; color: var(--navy); }
.ms-yearsel.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.ms-yearsel:focus-visible { outline: 3px solid var(--focus-ring, var(--gold)); outline-offset: 2px; }
@media (max-width: 520px) { .ms-yearsel { flex: 1 1 100%; } }
@media (prefers-reduced-motion: reduce) { .ms-tip { transition: none; } }

/* Fit the chart card on one screen: the value shows in the hover label, so the text readout is kept for screen readers only; chart height follows the window */
.ms-card .ms-readout { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; min-height: 0; }
.ms-card .sc-chart-wrap svg[tabindex] { max-height: clamp(220px, calc(100svh - 462px), 460px); }
@supports not (height: 100svh) { .ms-card .sc-chart-wrap svg[tabindex] { max-height: clamp(220px, calc(100vh - 462px), 460px); } }
.ms-card .ms-note { margin-bottom: .6rem; }
