/*
 * Mobile layout — Place+ on phones (per the Claude Design spec):
 * edge-to-edge map with the sidebar recast as a three-detent bottom
 * sheet whose top carries the selector stack (dashboard switcher,
 * metric, area). Scoped to <=768px and activated by mobile.js, which
 * restructures the DOM and drives the sheet.
 *
 * Measurements follow the "Place+ Mobile Prototype" spec: 44px control
 * bars, 16px sheet gutters, 18px section rhythm with 1px dividers,
 * 40x2px grabber, mono 11px section labels, 34px KPI values, 17/21
 * fact prose.
 */
@media (max-width: 768px) {
  /* ---- selector stack ---------------------------------------------------
     Dashboard switcher bar + metric bar, at the top of the glass sheet
     just above the area bar. The map runs edge-to-edge behind the sheet
     with nothing fixed over it. */
  #m-top {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 8px;
  }

  #m-top .m-title-bar {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  /* The dashboard-info container becomes the dark title bar — a
     dashboard-switcher dropdown trigger. mobile.js lifts its (i) button
     out to sit beside it so the open panel never covers it. */
  #m-top #dashboard-info-container {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    /* Same bar height and arrow treatment as the desktop dropdowns. */
    height: 1.6875rem;
    box-sizing: border-box;
    background-color: var(--prior-sys-dropdown-background);
    color: var(--prior-sys-dropdown-colour);
    padding: 0 2rem 0 var(--prior-sys-padding);
    margin: 0;
    cursor: pointer;
    /* Same arrow size/position as the autocomplete inputs below it. */
    background-image: var(--prior-sys-dropdown-arrow);
    background-repeat: no-repeat;
    background-size: 14px;
    background-position: calc(100% - 12px) 50%;
    -webkit-tap-highlight-color: transparent;
  }

  #m-top #dashboard-info-container .profile-info-text {
    font-family: "GT America Mono";
    font-size: 0.6875rem;
    font-weight: 300;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--prior-sys-dropdown-colour);
  }

  #m-top .row,
  #m-top label {
    width: 100%;
    margin: 0;
  }

  /* No (i) beside the title bar on phones — the bars run full width. */
  #m-top #profile-info-btn {
    display: none !important;
  }

  /* ---- Place+ wordmark, fixed top-left over the map ------------------ */
  #m-logo {
    position: fixed;
    top: 12px;
    left: 8px;
    z-index: 20;
    display: block;
    width: 88px;
    color: #121212;
    -webkit-tap-highlight-color: transparent;
  }

  body[data-theme="dark"] #m-logo {
    color: #d0d0d0;
  }

  #m-logo svg {
    display: block;
    width: 100%;
    height: auto;
  }

  /* ---- dashboard switcher overlay (opened from the title bar) --------
     Full-screen glass panel per the spec: mono header + close, 44px dark
     search field, then theme-grouped rows (10px dot, uppercase name,
     tick on the current dashboard, 1px rules). */
  #m-dash-switcher,
  #m-picker {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: flex;
    flex-direction: column;
    background: var(--prior-sys-sidebar-background);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  #m-dash-switcher[hidden],
  #m-picker[hidden] {
    display: none;
  }

  .m-switcher-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--prior-sys-panel-line-colour);
  }

  .m-switcher-head > span {
    flex: 1;
    font-family: "GT America Mono";
    font-size: 11px;
    line-height: 15px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--prior-sys-colour-primary);
  }

  #m-switcher-close,
  #m-picker-close {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    margin-right: -10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    color: var(--prior-sys-colour-primary);
  }

  #m-switcher-close .icon-x,
  #m-picker-close .icon-x {
    width: 20px;
    height: 20px;
  }

  /* Back button in the picker header (shown when drilled into a group). */
  #m-picker-back {
    flex: 0 0 36px;
    width: 36px;
    height: 44px;
    margin-left: -8px;
    display: flex;
    align-items: center;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    color: var(--prior-sys-colour-primary);
  }

  #m-picker-back[hidden] {
    display: none;
  }

  #m-picker-back .m-icon-back {
    width: 20px;
    height: 20px;
  }

  .m-switcher-search {
    flex: 0 0 auto;
    padding: 12px 16px;
    border-bottom: 1px solid var(--prior-sys-panel-line-colour);
  }

  .m-switcher-search input {
    width: 100%;
    height: 44px;
    box-sizing: border-box;
    padding: 0 12px;
    border: none;
    border-radius: var(--prior-sys-button-radius, 0);
    background: var(--prior-sys-dropdown-background);
    color: var(--prior-sys-dropdown-colour);
    font-family: "GT America Mono";
    font-size: 11px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
  }

  .m-switcher-search input::-webkit-search-cancel-button,
  .m-switcher-search input::-webkit-search-decoration {
    -webkit-appearance: none;
    display: none;
  }

  .m-switcher-search input::placeholder {
    color: var(--prior-sys-dropdown-colour);
    opacity: 0.6;
    text-transform: uppercase;
  }

  .m-switcher-list {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 16px 34px;
  }

  .m-switcher-group {
    padding: 18px 5px 6px;
    font-family: "GT America Mono";
    font-size: 11px;
    line-height: 12px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--prior-sys-type-colour);
  }

  .m-switcher-row {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    box-sizing: border-box;
    padding: 8px 5px;
    border-bottom: 1px solid var(--prior-sys-panel-line-colour);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .m-switcher-dot {
    flex: 0 0 10px;
    width: 10px;
    height: 10px;
  }

  .m-switcher-name {
    flex: 1;
    font-family: "GT America Mono";
    font-size: 11px;
    line-height: 15px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--prior-sys-chart-font-colour);
  }

  .m-switcher-row[data-current] .m-switcher-name {
    color: var(--prior-sys-colour-primary);
  }

  /* Current dashboard marked with the Place+ plus (the loader glyph). */
  .m-switcher-tick {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
    background-color: var(--prior-sys-colour-primary);
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 110 113'><path d='M69.6384 41.9331V0H40.2473V41.9331H0V70.1768H40.2473V112.11H69.6384V70.2033H109.886V41.9596L69.6384 41.9331Z' fill='black'/></svg>");
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 110 113'><path d='M69.6384 41.9331V0H40.2473V41.9331H0V70.1768H40.2473V112.11H69.6384V70.2033H109.886V41.9596L69.6384 41.9331Z' fill='black'/></svg>");
    mask-size: contain;
    -webkit-mask-size: contain;
    mask-repeat: no-repeat;
    -webkit-mask-repeat: no-repeat;
    mask-position: center;
    -webkit-mask-position: center;
  }

  .m-switcher-empty {
    padding: 24px 5px;
    font-family: "GT America Mono";
    font-size: 11px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--prior-sys-type-colour);
  }

  /* ---- metric / area picker rows -------------------------------------- */
  .m-picker-row {
    width: 100%;
    min-height: 52px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 5px;
    border: none;
    border-bottom: 1px solid var(--prior-sys-panel-line-colour);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .m-picker-row .m-switcher-name {
    color: var(--prior-sys-chart-font-colour);
  }

  .m-picker-row[data-current] .m-switcher-name {
    color: var(--prior-sys-colour-primary);
  }

  /* Question-led group headings in the metric picker (sans, sentence
     case — per the mock-up's Metric picker). */
  .m-picker-question {
    margin: 0;
    padding: 20px 5px 8px;
    font-family: "GT America";
    font-size: 15px;
    line-height: 19px;
    font-weight: 300;
    letter-spacing: -0.0175rem;
    color: var(--prior-sys-type-colour);
  }

  /* Drill-down group rows in the area picker. */
  .m-picker-col {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
  }

  .m-picker-group .m-switcher-name {
    color: var(--prior-sys-colour-primary);
  }

  .m-picker-count {
    font-family: "GT America Mono";
    font-size: 11px;
    line-height: 12px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--prior-sys-type-colour);
  }

  .m-icon-next {
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    background-color: var(--prior-sys-type-colour);
    mask-image: var(--prior-sys-icon-arrow-right);
    -webkit-mask-image: var(--prior-sys-icon-arrow-right);
  }

  /* Third-tier sub-group headings inside a drilled area family. */
  .m-picker-sub {
    padding: 14px 5px 4px;
    font-family: "GT America Mono";
    font-size: 11px;
    line-height: 12px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--prior-sys-type-colour);
  }

  /* The pickers replace the inline autocomplete UI entirely on phones. */
  body.m-mobile .autocomplete-suggestions {
    display: none !important;
  }

  body.m-mobile .autocomplete-clear {
    display: none !important;
  }

  /* ---- info overlay: every (i) opens on a full-screen glass panel
     with a back button, per the mock-up's "Dashboard info" screen ------ */
  #m-info-overlay {
    position: fixed;
    inset: 0;
    z-index: 46;
    display: flex;
    flex-direction: column;
    background: var(--prior-sys-sidebar-background);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  #m-info-overlay[hidden] {
    display: none;
  }

  .m-info-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 12px;
  }

  #m-info-back {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    margin-left: -10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    color: var(--prior-sys-colour-primary);
  }

  .m-icon-back {
    width: 20px;
    height: 20px;
    background-color: var(--prior-sys-colour-primary);
    mask-image: var(--prior-sys-icon-arrow-left);
    -webkit-mask-image: var(--prior-sys-icon-arrow-left);
  }

  #m-info-title {
    flex: 1;
    font-family: "GT America Mono";
    font-size: 11px;
    line-height: 15px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--prior-sys-colour-primary);
  }

  .m-info-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 16px 34px;
  }

  /* The info card itself: accent surface with dark text, as in the
     mock-up (and the desktop info popup). */
  .m-info-card {
    background: var(--prior-sys-colour-accent);
    padding: 16px 14px 20px;
    color: #121212;
  }

  .m-info-card h5 {
    margin: 0 0 1.25rem;
    font-family: "GT America";
    font-size: 20px;
    line-height: 24px;
    font-weight: 300;
    color: #121212;
  }

  .m-info-card h6 {
    margin: 1rem 0 0.375rem;
    font-family: "GT America";
    font-size: 14px;
    line-height: 18px;
    font-weight: 500;
    color: #121212;
  }

  .m-info-card p,
  .m-info-card li {
    margin: 0 0 0.8125rem;
    font-family: "GT America";
    font-size: 13px;
    line-height: 17px;
    font-weight: 300;
    color: #121212;
  }

  .m-info-card ul {
    margin: 0 0 0.8125rem;
    padding-left: 1.1rem;
  }

  .m-info-card a {
    font: inherit;
    letter-spacing: inherit;
    color: inherit;
    text-decoration: underline;
  }

  /* Chart tooltip is disabled on phones (belt-and-braces with the
     tooltip config override in lib/mobile.js). */
  body.m-mobile #chart-tooltip {
    display: none !important;
  }

  /* ---- map feature popup ---------------------------------------------
     Sits above the map and chrome but below the full-screen overlays. */
  body.m-mobile .popup:not(#chart-tooltip) {
    z-index: 35 !important;
  }

  /* Close (✕) pinned to the popup's top-left; the popup gains top
     padding so the first text line clears it. */
  body.m-mobile .popup.m-has-close {
    padding-top: 32px;
  }

  body.m-mobile .m-popup-close {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  body.m-mobile .m-popup-close .icon-x {
    width: 14px;
    height: 14px;
  }

  /* Show Profile action at the foot of the popup — exactly the pill
     style of the dashboard's other text buttons (benchmark, KEY, sort).
     !important throughout: the popup's nested `* { margin/padding/font }`
     reset carries ID-level specificity (its selector list includes
     #chart-tooltip) and flattens anything weaker. */
  body.m-mobile .m-popup-profile,
  body.m-mobile .m-popup-profile span {
    font-family: "GT America Mono" !important;
    font-size: 0.6875rem !important;
    font-weight: 300 !important;
    line-height: 0.75rem !important;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #121212 !important;
  }

  body.m-mobile .m-popup-profile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: fit-content;
    margin: 14px 0 0 !important;
    /* 5px inset — same as KEY / MAP SETTINGS (.map-text-btn). */
    padding: 0.3125rem !important;
    border: none;
    border-radius: 0.1875rem;
    /* Same hardcoded fill as #chart-sort / .benchmark-option pills. */
    background-color: #d0d0d0 !important;
    box-shadow: none;
    cursor: pointer;
  }

  /* ---- map ----------------------------------------------------------- */
  #map {
    position: fixed !important;
    inset: 0;
    width: 100vw;
    height: 100vh;
  }

  #map-coordinates {
    display: none;
  }

  /* KEY + MAP SETTINGS bottom-left, zoom/reset stack bottom-right —
     both ride above the sheet; mobile.js keeps --m-controls-bottom in
     step with the sheet position. */
  #misc-controls {
    position: fixed;
    left: 8px;
    right: auto;
    bottom: var(--m-controls-bottom, 256px);
    margin: 0;
    z-index: 20;
  }

  #misc-controls > button {
    min-width: 0;
  }

  /* Zoom / reset / help stack: redundant on phones (pinch to zoom,
     drag to pan) — hidden entirely. */
  #button-controls {
    display: none !important;
  }

  /* Sidebar visibility toggle has no role in the sheet model. */
  #toggle-sidebar {
    display: none;
  }

  /* ---- bottom sheet --------------------------------------------------- */
  /* The sheet is now a transparent scroll container — each content
     panel carries its own glass card material instead. */
  body.m-mobile #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    z-index: 25;
    transform: translateY(var(--m-sheet-y, calc(100vh - 240px)));
    /* 8px gutters: panels align with the KEY+ button (left: 8px) and
       the zoom stack (right: 8px). */
    padding: 0 8px 16px;
    /* No glass on the sheet itself — the panels float on the bare map.
       !important beats the sidebar's own .blur class. */
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    border: none;
    box-shadow: none;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* ---- glass panels ----------------------------------------------------
     One card per content group; 16px padding, 5px radius. The head strip
     (theme name + collapse icon) is all that remains when minimised. */
  .m-panel {
    background: var(--prior-sys-sidebar-background);
    backdrop-filter: blur(var(--prior-sys-blur-radius));
    -webkit-backdrop-filter: blur(var(--prior-sys-blur-radius));
    border-radius: 5px;
    padding: 16px;
    /* Panels sit almost flush — just a sliver of map between cards. */
    margin: 0 0 3px;
  }

  .m-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .m-panel-name {
    font-family: "GT America Mono";
    font-size: 11px;
    line-height: 15px;
    font-weight: 400;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--prior-sys-facts-colour);
  }

  .m-panel-toggle {
    flex: 0 0 35px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: transparent;
    box-shadow: none;
    /* Arrow colour: light mode 121212 / dark mode d0d0d0. */
    color: #121212;
  }

  body[data-theme="dark"] .m-panel-toggle {
    color: #d0d0d0;
  }

  /* Explicit stroke as well — the path uses currentColor, but pin it so
     the theme swap never depends on inherited-colour recalculation. */
  .m-panel-toggle svg path {
    stroke: #121212;
  }

  body[data-theme="dark"] .m-panel-toggle svg path {
    stroke: #d0d0d0;
  }

  /* Icon backplate: a9a9a9 at 25% in light mode (the SVG's own 10% was
     near-invisible on the light glass); d0d0d0 at the original 10% in
     dark. */
  .m-panel-toggle svg rect {
    fill: #a9a9a9;
    fill-opacity: 0.25;
  }

  body[data-theme="dark"] .m-panel-toggle svg rect {
    fill: #d0d0d0;
    fill-opacity: 0.1;
  }

  .m-panel[data-open="true"] .m-panel-head {
    margin-bottom: 14px;
  }

  .m-panel[data-open="false"] .m-panel-body {
    display: none;
  }

  /* The KEY legend anchors above its button and sits under the sheet. */
  body.m-mobile #legend {
    position: fixed;
    left: 8px;
    right: auto;
    bottom: calc(var(--m-controls-bottom, 256px) + 40px);
    margin: 0;
    z-index: 22;
  }

  /* Grabber: its own row ABOVE the area picker — 40x2 line per the spec. */
  #m-sheet-handle {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0 8px;
    margin: 0 -16px;
    cursor: grab;
    touch-action: none;
    z-index: 2;
  }

  #m-sheet-handle::before {
    content: "";
    width: 40px;
    height: 2px;
    background: var(--prior-sys-type-colour);
  }

  /* ---- sheet section rhythm: 18px gaps, 1px dividers ------------------ */

  /* Area picker — full-width 44px bar like the two above it (the desktop
     rule clips #filter-controls to calc(100% - 12px)). */
  body.m-mobile #filter-controls {
    padding: 0;
    margin: 0;
    width: 100%;
  }

  /* Selector controls keep the desktop dropdown height and styling
     (1.6875rem via the shared select/input rules) — no mobile override. */

  /* Light sweep across a bar while its prompt text wipes over to the
     real value (added/removed by mobile.js waveSwap, ~0.9s). */
  .m-wave-run {
    position: relative;
    overflow: hidden;
  }

  .m-wave-run::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
      105deg,
      transparent 30%,
      rgba(255, 255, 255, 0.35) 50%,
      transparent 70%
    );
    transform: translateX(-100%);
    animation: m-wave-sweep 0.9s linear forwards;
    pointer-events: none;
  }

  @keyframes m-wave-sweep {
    to {
      transform: translateX(100%);
    }
  }

  /* ---- facts: KPI stat first, then LIVE INSIGHTS header + prose ------- */
  body.m-mobile .facts {
    display: block;
  }

  body.m-mobile .facts-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* KPI stats FOLLOW the insight prose (natural DOM order): the fact
     sentence supplies the context the bare numbers lack, then the stat
     pair summarises it. A touch more air above them than the 12px gap. */
  body.m-mobile .facts-main .facts-stats {
    margin-top: 6px; /* + the 12px flex gap = 18px */
  }

  body.m-mobile .facts-stat .stat-value {
    font-size: 34px !important;
    font-weight: 300;
    line-height: 1.1 !important;
    letter-spacing: -0.02em;
  }

  body.m-mobile .facts-stat .stat-value .stat-unit {
    font-size: 12px;
    font-weight: 500;
    line-height: 16px;
    margin-left: 0.25rem;
  }

  body.m-mobile .facts-stat .stat-label {
    font-size: 12px !important;
    line-height: 16px !important;
  }

  body.m-mobile .stat-sep {
    width: 20px !important;
    height: 52px !important;
    margin: 2px 12px 0;
  }

  /* LIVE INSIGHTS header row: (i) then the mono label on the left,
     pager pushed to the right (mobile.js moves .facts-controls in here). */
  body.m-mobile .facts-title {
    justify-content: flex-start;
    gap: 10px;
  }

  body.m-mobile .facts-title h5 {
    font-family: "GT America Mono" !important;
    font-size: 11px !important;
    line-height: 12px;
    font-weight: 400;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  /* The (i) sits to the LEFT of the Live Insights heading. */
  body.m-mobile #facts-info-button {
    order: -1;
    margin-left: -4px;
  }

  body.m-mobile .facts-controls {
    gap: 6px;
    margin-left: auto; /* pager hugs the right edge of the header row */
    margin-right: -10px; /* optically align the arrow with the gutter */
  }

  body.m-mobile .facts-count {
    display: inline;
    font-family: "GT America Mono";
    font-size: 11px;
    line-height: 12px;
    letter-spacing: 0.03em;
    color: var(--prior-sys-type-colour);
    white-space: nowrap;
  }

  body.m-mobile .facts-controls button {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  body.m-mobile .facts-controls .icon-player-skip-back,
  body.m-mobile .facts-controls .icon-player-skip-forward {
    width: 18px;
    height: 18px;
  }

  body.m-mobile .facts-text,
  body.m-mobile .facts-text * {
    font-size: 17px !important;
    line-height: 21px !important;
    min-height: 0;
  }

  body.m-mobile .facts-text {
    min-height: 58px;
  }

  /* ---- COMPARE AGAINST: label line, then the pill row (the panel card
     provides the section separation now) ------------------------------- */
  body.m-mobile #benchmark-controls {
    flex-wrap: wrap;
    gap: 6px;
    margin: 18px 0 0;
    padding: 0;
    border-top: none;
  }

  /* Header row: (i) then COMPARE AGAINST — mirrors the Live Insights
     header (same typography as .facts-title h5 below). */
  body.m-mobile .m-bench-head {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 4px;
  }

  /* The desktop `#benchmark-controls #help-info-button` rule (two IDs)
     pushes the (i) to the row's far right via order: 99 — inside the
     header it sits first, flush left. Both IDs repeated to out-rank it. */
  body.m-mobile #benchmark-controls .m-bench-head button,
  body.m-mobile #benchmark-controls .m-bench-head #help-info-button {
    order: -1;
    margin-left: -4px;
    margin-right: 0;
  }

  body.m-mobile .m-bench-title {
    font-family: "GT America Mono";
    font-size: 11px;
    line-height: 12px;
    font-weight: 400;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--prior-sys-facts-colour);
  }

  /* Same height as KEY / MAP SETTINGS / SORT — the shared 5px pill
     inset (the desktop .map-text-btn metric). */
  body.m-mobile #benchmark-controls button.benchmark-option {
    padding: 0.3125rem;
    min-height: 0;
  }

  /* ---- chart block: native hr rules retired. Zero side padding — the
     desktop gutter would indent the sort pill and axis labels off the
     panel's shared left edge. ------------------------------------------ */
  body.m-mobile #sidebar-content {
    /* 18px separates the chart from the benchmark block above it now
       that both live inside the one Analytics panel; extra air below
       the chart before the panel's bottom edge. */
    margin: 18px 0 0;
    padding: 0 0 10px;
    border: none;
  }

  body.m-mobile #sidebar-content hr {
    display: none;
  }

  /* The area bar mirrors the displayed area now, so the chart's
     "Displaying Data for: X" line is redundant on phones. Hidden, not
     removed — mobile.js reads its text to drive that mirroring.
     !important: app.js re-asserts style.display = "block" inline on
     every title update. */
  body.m-mobile #chart-title {
    display: none !important;
  }

  /* The sidebar spinner keeps a ~500px flex box in layout even when
     idle, inflating the sheet's content height — phones use the map
     loader instead. */
  body.m-mobile #sidebar-loader {
    display: none !important;
  }

  /* ---- About panel: the dashboard-info copy + source + licence ------- */
  .m-panel[data-panel="about"] h5 {
    margin: 0 0 12px;
    font-family: "GT America";
    font-size: 20px;
    line-height: 24px;
    font-weight: 300;
    color: var(--prior-sys-facts-colour);
  }

  /* All body text in the About card shares one style — some templates
     use lists, sub-headings and emphasis, not just paragraphs. */
  .m-panel[data-panel="about"] p,
  .m-panel[data-panel="about"] li,
  .m-panel[data-panel="about"] em,
  .m-panel[data-panel="about"] strong,
  .m-panel[data-panel="about"] h6 {
    margin: 0 0 12px;
    font-family: "GT America";
    font-size: 13px;
    line-height: 17px;
    font-weight: 300;
    letter-spacing: -0.0175rem;
    color: var(--prior-sys-facts-colour);
    text-wrap: pretty;
  }

  .m-panel[data-panel="about"] li {
    margin-bottom: 6px;
  }

  .m-panel[data-panel="about"] ul {
    margin: 0 0 12px;
    padding-left: 1.1rem;
  }

  .m-panel[data-panel="about"] h6,
  .m-panel[data-panel="about"] strong {
    font-weight: 500;
  }

  .m-panel[data-panel="about"] p:last-child {
    margin-bottom: 0;
  }

  .m-panel[data-panel="about"] a {
    font: inherit;
    letter-spacing: inherit;
    color: inherit;
    text-decoration: underline;
  }

  /* ---- desktop ward "deep dive" dropdown: hidden on phones -------------
     Dashboards with sub-LAD data show a second dropdown beside the area
     picker on desktop. Phones stay LAD-level for now (a picker drill
     level is the planned replacement), and the area label reclaims the
     full row width. */
  body.m-mobile .ward-label,
  body.m-mobile #ward {
    display: none !important;
  }

  body.m-mobile #filter-controls .row .lad-label,
  body.m-mobile #filter-controls .row[data-ward-visible] label {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
  }
}
