/* Keep the map at its working size, from the first loading frame onwards. */
#market-map-dialog {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  inset: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
}
#market-map-dialog[open] { display: flex; flex-direction: column; }
.map-dialog-header { flex: none; }
.map-dialog-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
.map-dialog-body .matrix-controls select,
.map-dialog-body .matrix-controls input {
  height: 44px;
  min-height: 44px;
  padding: 8px 10px;
  line-height: normal;
}
.map-dialog-body .matrix-controls > button { min-height: 44px; height: 44px; }
.map-dialog-body .matrix-grid thead th:first-child { width: clamp(160px, 22vw, 320px); }
.map-dialog-body .matrix-grid tbody th {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  padding: 5px 14px 5px 0;
  font-size: 11px;
  line-height: 1.45;
}
.matrix-label-main, .matrix-label-sub { display: block; }
.matrix-label-main { font-weight: 600; }
.matrix-label-sub { color: var(--muted); font-size: 10px; }
.matrix-sampling-note { margin: -3px 0 16px; padding: 10px 12px; border-left: 2px solid var(--teal); background: var(--panel2); color: var(--muted); font-size: 12px; line-height: 1.6; }
.matrix-availability { padding: 13px 16px; margin-bottom: 15px; background: var(--panel2); border: 1px solid var(--line); font-size: 12px; line-height: 1.6; }
.matrix-availability p { margin: 0; }
.matrix-availability details { margin-top: 6px; color: var(--muted); }
.matrix-availability ul { margin: 7px 0; padding-left: 20px; }
.matrix-availability button { margin-top: 10px; }

/* A visible, accessible status accompanies neutral chart placeholders. */
.sm-load-status {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  margin: 0 0 20px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  background: var(--panel2);
  color: var(--text);
  border-radius: 7px;
}
.sm-load-status strong { display: block; font-size: 14px; font-weight: 600; line-height: 1.5; }
.sm-load-status p { margin: 4px 0 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.sm-load-status > button { margin-left: auto; flex-shrink: 0; }
.sm-load-status[data-state="error"] { border-left-color: var(--gold); }
.sm-loading-spinner {
  display: block;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: sm-loading-turn .85s linear infinite;
}
@keyframes sm-loading-turn { to { transform: rotate(360deg); } }
#map-dialog-title { display: flex; align-items: center; gap: 14px; }
.map-header-loading { display: none; width: 18px; height: 18px; flex-basis: 18px; border-width: 2px; }
#market-map-dialog:has(#matrix-view[aria-busy="true"]) .map-header-loading { display: block; }
.sm-skeleton {
  display: block;
  background: var(--line);
  position: relative;
  overflow: hidden;
}
.sm-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--panel), transparent);
  transform: translateX(-100%);
  animation: sm-loading-sweep 2s ease-in-out infinite;
}
@keyframes sm-loading-sweep { to { transform: translateX(100%); } }
.sm-skeleton-title { height: 22px; width: 56%; margin-bottom: 14px; }
.sm-skeleton-caption { height: 9px; width: 72%; margin-bottom: 10px; }
.sm-skeleton-number { height: 28px; width: 42px; margin-bottom: 0; flex-shrink: 0; }
.sm-placeholder-counts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 24px;
}
.sm-placeholder-counts > div { display: flex; align-items: center; gap: 18px; padding: 16px; border-right: 1px solid var(--line); }
.sm-placeholder-counts > div:last-child { border-right: 0; }
.sm-placeholder-counts .sm-skeleton-caption { margin-bottom: 0; width: 55%; }
.sm-placeholder-feature { --panel:#102938; --panel2:#153444; --line:#2c4757; display:grid; grid-template-columns:minmax(0,.82fr) minmax(0,2fr); gap:26px 42px; padding:26px 30px; border:1px solid var(--line); border-radius:12px; background:var(--panel); margin-bottom:28px; }
.sm-placeholder-tools { grid-column:1/-1; display:flex; align-items:center; justify-content:space-between; padding-bottom:18px; border-bottom:1px solid var(--line); }
.sm-placeholder-tools .sm-skeleton-caption { width:40%; margin:0; }
.sm-placeholder-story { padding-top:26px; }
.sm-placeholder-story .sm-skeleton-title { margin:22px 0; width:90%; height:35px; }
.sm-placeholder-readings { display:flex; gap:45px; margin:50px 0; }
.sm-placeholder-filmstrip { display:flex; gap:24px; grid-column:1/-1; border-top:1px solid var(--line); padding-top:20px; }
.sm-placeholder-filmstrip .sm-skeleton-title { width:22%; height:35px; margin:0; }
.sm-placeholder-chart { padding-top: 8px; }
.sm-placeholder-plot {
  height: 255px;
  margin: 23px 0 15px;
  border-bottom: 1px solid var(--line);
  background: repeating-linear-gradient(to bottom, var(--panel2) 0, var(--panel2) calc(25% - 1px), var(--line) calc(25% - 1px), var(--line) 25%);
}
.sm-placeholder-plot.sm-placeholder-gap { height:100px; margin-top:20px; }
.sm-placeholder-mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 29px; }
.sm-placeholder-mini > div { border-top: 1px solid var(--line); padding-top: 20px; }
.sm-placeholder-mini .sm-placeholder-plot { height: 120px; }
.sm-placeholder-heading { display: flex; justify-content: space-between; gap: 24px; margin: 25px 0 18px; }
.sm-placeholder-heading .sm-skeleton-title { width: 30%; }
.sm-placeholder-heading .sm-skeleton-caption { width: 20%; }
.sm-placeholder-matrix {
  height: clamp(220px, 42dvh, 520px);
  margin-bottom: 18px;
  background-color: var(--panel2);
  background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(5% - 3px), var(--panel) calc(5% - 3px), var(--panel) 5%), repeating-linear-gradient(to bottom, transparent 0, transparent 23px, var(--panel) 23px, var(--panel) 26px);
}
@media (max-width: 760px) {
  .sm-load-status { padding: 16px 13px; gap: 12px; flex-wrap: wrap; }
  .sm-load-status > div { flex: 1; min-width: 180px; }
  .sm-load-status strong { font-size: 13px; }
  .sm-load-status p { font-size: 11px; }
  .sm-placeholder-counts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm-placeholder-counts > div { padding: 12px; }
  .sm-placeholder-counts > div:nth-child(2) { border-right: 0; }
  .sm-placeholder-counts > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .sm-placeholder-feature, .sm-placeholder-mini { grid-template-columns: 1fr; gap: 22px; }
  .sm-placeholder-feature { padding:20px; }
  .sm-placeholder-story { padding-top:0; }
  .sm-placeholder-readings { margin:25px 0; }
  .sm-placeholder-plot { height: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  .sm-loading-spinner, .sm-skeleton::after { animation: none; }
}
