/* The JS media query also includes phones held in landscape. No desktop overrides. */
.mobile-only { display: none; }
.mobile-settings-content, #mobile-chart-workspace { display: contents; }
body.mobile-charts main { padding: 14px 10px 24px; }
body.mobile-charts .intro { gap: 12px; margin-bottom: 10px; }
body.mobile-charts .intro > div:first-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
body.mobile-charts .search-row input { font-size: 16px; }
body.mobile-charts .search-row button { min-height: 44px; }
body.mobile-charts .location-bar { padding: 10px 0; }
body.mobile-charts .location-actions select { font-size: 16px; }
body.mobile-charts .models { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 9px; margin-bottom: 4px; scroll-snap-type: x proximity; }
body.mobile-charts .model { flex: 0 0 158px; padding: 10px; scroll-snap-align: start; }
body.mobile-charts .model > span:nth-child(2) { display: block; }
body.mobile-charts .model small:not(.model-run):not(.super-caption) { display: none; }
body.mobile-charts .model strong { font-size: 13px; }
body.mobile-charts .model small.model-run, body.mobile-charts .model small.super-caption { font-size: 10px; line-height: 1.5; white-space: normal; }
body.mobile-charts .super-icon { font-size: 18px; }
body.mobile-charts .mobile-only { display: flex; }
body.mobile-charts .mobile-model-hint, body.mobile-charts .mobile-chart-tip { margin: 4px 0 8px; font-size: 11px; line-height: 1.5; color: var(--muted); }
body.mobile-charts .mobile-settings-toggle { width: 100%; align-items: center; justify-content: space-between; margin: 0 0 10px; min-height: 44px; font-size: 13px; }
body.mobile-charts .mobile-settings-content { display: none; }
body.mobile-charts .mobile-settings-content.is-open { display: block; padding: 10px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 8px; }
body.mobile-charts .analysis-controls { gap: 12px 10px; }
body.mobile-charts .segmented button { min-width: 0; padding: 8px; white-space: normal; }
body.mobile-charts .intro { grid-template-columns: minmax(0, 1fr); }
body.mobile-charts .search { min-width: 0; }
body.mobile-charts .analysis-controls select, body.mobile-charts .colour-choice select, body.mobile-charts .scale-inputs input { font-size: 16px; }
body.mobile-charts .analysis-controls button, body.mobile-charts .super-presets button, body.mobile-charts .legend label { min-height: 44px; }
body.mobile-charts .legend-row { flex-wrap: wrap; }
body.mobile-charts .legend { gap: 4px 14px; }
body.mobile-charts .timebar { display: none; }
body.mobile-charts #mobile-chart-workspace { display: block; min-width: 0; }
body.mobile-charts .mobile-chart-toolbar { position: sticky; top: 0; z-index: 30; flex-direction: column; gap: 8px; padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--line); }
body.mobile-charts #mobile-chart-context { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
body.mobile-charts .mobile-chart-picker { display: flex; align-items: center; gap: 7px; }
body.mobile-charts .mobile-chart-picker label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
body.mobile-charts .mobile-chart-picker select { flex: 1; width: 0; font-size: 16px; font-weight: 600; min-height: 46px; border-color: var(--teal); }
body.mobile-charts #mobile-chart-expand { min-height: 46px; font-size: 13px; padding: 8px 12px; }
body.mobile-charts .mobile-chart-window { display: flex; gap: 8px; align-items: center; }
body.mobile-charts .mobile-horizons { display: flex; flex: 1; min-width: 0; gap: 4px; }
body.mobile-charts .mobile-horizons button { flex: 1; min-width: 0; min-height: 44px; font-size: 12px; padding: 6px 4px; background: var(--surface); color: var(--muted); border-color: var(--line); }
body.mobile-charts .mobile-horizons button[aria-pressed=true] { background: var(--raised); border-color: var(--teal); color: var(--teal); }
body.mobile-charts #mobile-reset-zoom { flex: 0 0 58px; min-height: 44px; padding: 6px 4px; font-size: 12px; white-space: normal; }
body.mobile-charts .mobile-chart-hidden { display: none; }
body.mobile-charts .chart-card { padding: 12px 6px 10px; margin: 10px 0 16px; }
body.mobile-charts .chart-heading { align-items: center; gap: 6px; }
body.mobile-charts .chart-title { min-width: 0; }
body.mobile-charts .chart-title .level, body.mobile-charts .expand-chart { display: none; }
body.mobile-charts .chart-card h2 { font-size: 15px; line-height: 1.4; }
body.mobile-charts .chart-tools { flex: none; }
body.mobile-charts .chart-tools .units { display: none; }
body.mobile-charts .chart-tools button { min-width: 44px; min-height: 44px; }
body.mobile-charts .chart-subtitle { font-size: 11px; line-height: 1.5; }
body.mobile-charts .chart-run { font-size: 11px; line-height: 1.5; }
body.mobile-charts .chart-window { display: block; font-size: 11px; padding: 7px; margin-bottom: 6px; background: var(--raised); border-radius: 5px; line-height: 1.5; }
body.mobile-charts .plot { height: 410px !important; height: clamp(300px, 48svh, 460px) !important; }
body.mobile-charts .chart-inspection { display: block; padding: 8px 0 0; border-top: 1px solid var(--line); }
body.mobile-charts .chart-inspection > div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
body.mobile-charts .chart-inspection .control-label { margin: 0; font-size: 10px; color: var(--muted); }
body.mobile-charts .chart-inspection strong { font-size: 12px; line-height: 1.5; color: var(--teal); }
body.mobile-charts .chart-time-slider { width: 100%; height: 44px; padding: 0; margin: 0; accent-color: var(--teal); }
body.mobile-charts .chart-values { gap: 9px 14px; padding: 10px 0 2px; }
body.mobile-charts .chart-values b { font-size: 13px; }
body.mobile-charts .chart-values .counts { margin-left: 0; }

/* Native dialog provides focus trapping and works in iPhone Safari without Fullscreen API. */
#mobile-chart-dialog { width: 100%; max-width: none; height: 100%; height: 100dvh; max-height: none; margin: 0; padding: 0 10px 12px; padding: env(safe-area-inset-top, 0px) max(10px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px)); border: 0; border-radius: 0; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; }
.mobile-chart-expanded, .mobile-chart-expanded body { overflow: hidden; }
.mobile-chart-expanded body { position: fixed; top: var(--mobile-scroll-top); width: 100%; }
body.mobile-charts #mobile-chart-dialog .plot { height: 52svh !important; min-height: 280px; }
@media (orientation: landscape) {
  body.mobile-charts #mobile-chart-dialog .mobile-chart-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, .8fr); align-items: center; padding: 6px 0; gap: 4px 14px; }
  body.mobile-charts #mobile-chart-dialog #mobile-chart-context { grid-column: 1 / -1; }
  body.mobile-charts #mobile-chart-dialog .mobile-chart-tip { display: none; }
  body.mobile-charts #mobile-chart-dialog .chart-heading,
  body.mobile-charts #mobile-chart-dialog .chart-subtitle { display: none; }
  body.mobile-charts #mobile-chart-dialog .chart-card { margin-top: 6px; padding-top: 6px; }
  body.mobile-charts #mobile-chart-dialog .chart-run { margin-bottom: 4px; }
  body.mobile-charts #mobile-chart-dialog .chart-window { margin-bottom: 4px; padding: 3px 7px; }
  body.mobile-charts #mobile-chart-dialog .plot { height: calc(100svh - 176px) !important; min-height: 190px; }
}
