/* ==========================================================================
   Hunting Guide - application shell
   Dark, high-contrast UI that stays out of the way of the map.
   ========================================================================== */

:root {
    --hg-bg: #12160f;
    --hg-bg-panel: #1c2118;
    --hg-bg-panel-alt: #262c20;
    --hg-border: #3a4232;
    /* The border of a CONTROL (button, input, chip): at least 3:1 against the panel colours (WCAG 1.4.11, non-text). --hg-border stays
       the soft line of decoration (dividers, cards), which does not need it. */
    --hg-border-control: #727d66;
    --hg-text: #e8eddf;
    --hg-text-dim: #a8b39a;
    /* The glyph of a disabled icon button: dimmer than the dim text, still 3:1 on the panel. */
    --hg-text-disabled: #7d8872;
    --hg-accent: #ffd166;
    --hg-accent-dim: #c9a34e;
    --hg-danger: #ff6b52;
    --hg-panel-width: 300px;
    --hg-panel-width-search: 260px;
    /* Where the panels float over the map (every layout but desktop): wide enough for seven 44 px tabs in one row. */
    --hg-panel-width-overlay: min(336px, 94vw);
    --hg-toolbar-height: 48px;
    --hg-statusbar-height: 34px;

    /* The smallest sizes of text. On a desktop they are what they always were; on a phone or a tablet nothing is under 12 px
       (html[data-layout], below). */
    --hg-fs-10: 10px;
    --hg-fs-10-5: 10.5px;
    --hg-fs-11: 11px;

    /* The smallest thing a finger must hit (WCAG 2.5.5 / Android guidance); applied on touch layouts. */
    --hg-target: 44px;

    /* How far the app's own bars and toasts stay above the bottom edge of the map, clear of the Mapbox logo and attribution. Desktop: 0. */
    --hg-attrib-clear: 0px;

    --hg-focus-ring: 2px solid var(--hg-accent);
}

/* The layout flag (js/layout.js sets html[data-layout] once, before the first paint): phone, phone-land (a phone sideways), tablet, desktop. */
html[data-layout="phone"],
html[data-layout="phone-land"],
html[data-layout="tablet"] {
    --hg-fs-10: 12px;
    --hg-fs-10-5: 12px;
    --hg-fs-11: 12px;
    --hg-attrib-clear: 40px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: var(--hg-bg);
    color: var(--hg-text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
}

#app, .hg-app {
    height: 100%;
}

.hg-boot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--hg-text-dim);
    gap: 12px;
}

.hg-boot i {
    font-size: 40px;
    color: var(--hg-accent);
}

/* ---------------------------------------------------------------- shell -- */

.hg-shell {
    display: grid;
    /* minmax(0, 1fr), not the default auto: with auto the column grows to fit the widest
       thing in it, so on a phone the toolbar made the whole page wider than the screen and
       pushed the panel buttons off the right edge. */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--hg-toolbar-height) 1fr var(--hg-statusbar-height);
    height: 100%;
    width: 100%;
}

.hg-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 10px;
    background: var(--hg-bg-panel);
    border-bottom: 1px solid var(--hg-border);
    padding-top: env(safe-area-inset-top);
}

.hg-toolbar__group {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.hg-toolbar__group--center {
    justify-content: center;
    /* "safe": when the chips do not fit they start at the left edge and scroll, instead of spilling out on both sides where the first
       (the active one) could not be reached (F-09, a 768 px tablet). */
    justify-content: safe center;
    /* If the basemap chips still do not fit, they scroll; the buttons beside them do not. */
    overflow-x: auto;
    scrollbar-width: none;
    flex: 0 1 auto;
}

.hg-toolbar__group--center::-webkit-scrollbar {
    display: none;
}

.hg-toolbar__group:last-child {
    flex: 0 0 auto;
}

.hg-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--hg-accent);
    white-space: nowrap;
}

.hg-body {
    display: grid;
    min-height: 0;
    position: relative;
}

.hg-body--both {
    grid-template-columns: var(--hg-panel-width) 1fr var(--hg-panel-width-search);
}

.hg-body--grid {
    grid-template-columns: var(--hg-panel-width) 1fr 0;
}

.hg-body--search {
    grid-template-columns: 0 1fr var(--hg-panel-width-search);
}

.hg-body--none {
    grid-template-columns: 1fr;
}

/*
 * Each region is placed in its own column. Left to auto-placement, the map took the first
 * column whenever the grid panel was closed, which with the search panel open is the
 * zero-width one: the map vanished and the search panel filled the screen.
 */
.hg-body > .hg-panel--grid { grid-column: 1; grid-row: 1; }
.hg-body > .hg-map { grid-row: 1; }
.hg-body > .hg-panel--search { grid-row: 1; }

.hg-body--both > .hg-map { grid-column: 2; }
.hg-body--both > .hg-panel--search { grid-column: 3; }
.hg-body--grid > .hg-map { grid-column: 2; }
.hg-body--search > .hg-map { grid-column: 2; }
.hg-body--search > .hg-panel--search { grid-column: 3; }
.hg-body--none > .hg-map { grid-column: 1; }

.hg-map {
    position: relative;
    min-width: 0;
    background: #0d100b;
}

.hg-map .mapboxgl-canvas {
    outline: none;
}

/*
 * One stacking context for everything that lives ON the map: the pins, stands, probes (with their wind badge and name), path and
 * measurement handles. Their inline z-index runs to 3,000,001 (so the selected one wins over its neighbours), and with the map in the
 * page's own stacking context that beat the side panel (4), the dialogs and the sheets, and painted over their text and buttons
 * (docs/12-mobile-audit.md, F-01). Inside this box they still order themselves; outside it they are one layer, under everything else.
 * It is the canvas container (where Mapbox puts the markers), not the whole map, on purpose: the map's own overlays (toasts 6, the pointer
 * readout, the mode bars, the grid note) keep their z-index against the panel, so a toast still shows over an open panel.
 *
 * The z-order, lowest first: the map and its markers (0) < the Mapbox controls (2) < the map's notes, bars and readout (3) < the side panel (4)
 * < the loading notice (5) < the toasts of the map (6) < the inbox (30) < the share toasts (35) < the share dialog (40) < the forecast (41).
 */
.hg-map .mapboxgl-canvas-container {
    isolation: isolate;
}

/* --------------------------------------------------------------- panels -- */

.hg-panel {
    background: var(--hg-bg-panel);
    border-right: 1px solid var(--hg-border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.hg-panel--search {
    border-right: none;
    border-left: 1px solid var(--hg-border);
}

.hg-panel__header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--hg-border);
    flex: 0 0 auto;
}

.hg-panel__header h2 {
    margin: 0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--hg-text-dim);
    font-weight: 600;
}

.hg-panel__header i {
    margin-right: 6px;
    color: var(--hg-accent);
}

.hg-panel__body {
    padding: 12px;
    overflow-y: auto;
    flex: 1 1 auto;
    -webkit-overflow-scrolling: touch;
}

.hg-field {
    margin-bottom: 14px;
}

.hg-label {
    display: block;
    font-size: var(--hg-fs-11);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--hg-text-dim);
    margin-bottom: 6px;
}

.hg-input {
    width: 100%;
    background: var(--hg-bg);
    border: 1px solid var(--hg-border-control);
    border-radius: 6px;
    color: var(--hg-text);
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
}

.hg-input:focus {
    outline: none;
    border-color: var(--hg-accent-dim);
    box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.15);
}

.hg-chiprow {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.hg-chip {
    background: var(--hg-bg-panel-alt);
    border: 1px solid var(--hg-border-control);
    color: var(--hg-text-dim);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.hg-chip:hover {
    border-color: var(--hg-accent-dim);
    color: var(--hg-text);
}

.hg-chip--active {
    background: var(--hg-accent);
    border-color: var(--hg-accent);
    color: #1a1a10;
    font-weight: 600;
}

.hg-chip--small {
    padding: 5px 10px;
    font-size: var(--hg-fs-11);
}

.hg-icon-button {
    background: transparent;
    border: 1px solid var(--hg-border-control);
    color: var(--hg-text-dim);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

.hg-icon-button:hover {
    color: var(--hg-accent);
    border-color: var(--hg-accent-dim);
}

.hg-icon-button--active {
    background: var(--hg-accent);
    border-color: var(--hg-accent);
    color: #1a1a10;
}

.hg-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 9px 12px;
    border-radius: 6px;
    border: 1px solid var(--hg-border-control);
    background: var(--hg-bg-panel-alt);
    color: var(--hg-text);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

.hg-button:disabled {
    opacity: 0.5;
    cursor: default;
}

.hg-button--primary {
    background: var(--hg-accent);
    border-color: var(--hg-accent);
    color: #1a1a10;
    font-weight: 600;
}

.hg-button--danger {
    color: var(--hg-danger);
    /* a control's border: 3:1 on the panel (it was 35% red, 1.8:1) */
    border-color: rgba(255, 107, 82, 0.8);
}

.hg-button--icon {
    width: auto;
    padding: 8px 12px;
}

.hg-chiprow + .hg-input {
    margin-top: 8px;
}

.hg-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

.hg-hint,
.hg-note {
    font-size: 12px;
    color: var(--hg-text-dim);
    margin: 6px 0 0;
    line-height: 1.45;
}

.hg-error {
    font-size: 12px;
    color: var(--hg-danger);
    margin: 6px 0 0;
}

.hg-divider {
    height: 1px;
    background: var(--hg-border);
    margin: 14px 0;
}

.hg-searchbar {
    display: flex;
    gap: 6px;
}

.hg-results {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hg-result {
    display: block;
    width: 100%;
    text-align: left;
    background: var(--hg-bg-panel-alt);
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--hg-text);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
}

.hg-result:hover {
    border-color: var(--hg-accent-dim);
}

.hg-result i {
    color: var(--hg-accent);
    margin-right: 6px;
}

.hg-result__name {
    font-weight: 600;
}

.hg-result__context {
    display: block;
    font-size: var(--hg-fs-11);
    color: var(--hg-text-dim);
    margin-top: 2px;
}

.hg-summary {
    margin: 0;
    padding-top: 10px;
    border-top: 1px solid var(--hg-border);
    font-size: 12px;
}

.hg-summary > div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 3px 0;
}

.hg-summary dt {
    color: var(--hg-text-dim);
    margin: 0;
}

.hg-summary dd {
    margin: 0;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.hg-callout {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    background: rgba(255, 209, 102, 0.08);
    border: 1px solid rgba(255, 209, 102, 0.25);
}

.hg-callout__title {
    font-weight: 600;
    color: var(--hg-accent);
    font-variant-numeric: tabular-nums;
}

.hg-callout__body {
    font-size: 12px;
    color: var(--hg-text-dim);
    margin-top: 4px;
}

.hg-notice {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: left;
    background: rgba(18, 22, 15, 0.94);
    z-index: 5;
}

.hg-notice i {
    font-size: 26px;
    color: var(--hg-accent);
}

.hg-notice p {
    margin: 6px 0 0;
    color: var(--hg-text-dim);
    font-size: 13px;
}

.hg-notice .hg-button {
    margin-top: 12px;
}

.hg-notice code {
    background: var(--hg-bg-panel-alt);
    padding: 1px 5px;
    border-radius: 4px;
}

/* ------------------------------------------------------------ statusbar -- */

.hg-statusbar {
    display: flex;
    align-items: center;
    background: var(--hg-bg-panel);
    border-top: 1px solid var(--hg-border);
    padding: 0 10px;
    padding-bottom: env(safe-area-inset-bottom);
    overflow-x: auto;
}

.hg-status {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
    white-space: nowrap;
}

.hg-status__item {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 12px;
}

.hg-status__label {
    color: var(--hg-text-dim);
    text-transform: uppercase;
    font-size: var(--hg-fs-10);
    letter-spacing: 0.06em;
}

.hg-status__value {
    font-variant-numeric: tabular-nums;
    color: var(--hg-text);
}

.hg-status__item--wide .hg-status__value {
    color: var(--hg-accent);
    font-weight: 600;
}

/* ----------------------------------------------------------- responsive -- */

/*
 * Where the panels float over the map, one at a time: every layout but desktop (phone, phone-land, tablet; the flag is set once in
 * js/layout.js, which replaced the 900 px test that was repeated here and in script, and put a phone turned sideways on the desktop side).
 */
:where(html:not([data-layout="desktop"])) .hg-body,
:where(html:not([data-layout="desktop"])) .hg-body--both,
:where(html:not([data-layout="desktop"])) .hg-body--grid,
:where(html:not([data-layout="desktop"])) .hg-body--search,
:where(html:not([data-layout="desktop"])) .hg-body--none {
    grid-template-columns: 1fr;
}

/* The panels float over the map, so the map always takes the one column. */
:where(html:not([data-layout="desktop"])) .hg-body.hg-body > .hg-map,
:where(html:not([data-layout="desktop"])) .hg-body.hg-body > .hg-panel--grid,
:where(html:not([data-layout="desktop"])) .hg-body.hg-body > .hg-panel--search {
    grid-column: 1;
}

:where(html:not([data-layout="desktop"])) .hg-panel {
    position: absolute;
    top: 0;
    bottom: 0;
    width: var(--hg-panel-width-overlay);
    z-index: 4;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.55);
}

:where(html:not([data-layout="desktop"])) .hg-panel--grid {
    left: 0;
    border-right: 1px solid var(--hg-border);
}

:where(html:not([data-layout="desktop"])) .hg-panel--search {
    right: 0;
    border-left: 1px solid var(--hg-border);
}

/* The seven tabs of the header share one row of the panel, 44 px each: the header keeps its room (it was 12 px on each side). */
:where(html:not([data-layout="desktop"])) .hg-panel__header.hg-panel__header--split {
    padding-left: 6px;
    padding-right: 6px;
}

:where(html:not([data-layout="desktop"])) .hg-brand__text {
    display: none;
}

/*
 * The Mapbox logo (bottom left) and the attribution (bottom right) are a licence requirement of the map and are never covered by the
 * app's own interface. A panel that floats over the map would cover the one on its side, and there is no room beside it on a phone (a
 * 336 px panel leaves 76 px of a 412 px screen, the logo alone is 88), so the bottom corners are ABOVE the panel and the panel keeps a
 * strip along its foot (--hg-attrib-clear, 40 px) for them: nothing of the panel is under the logo, and the logo is not under the panel.
 */
:where(html:not([data-layout="desktop"])) .hg-map .mapboxgl-ctrl-bottom-left,
:where(html:not([data-layout="desktop"])) .hg-map .mapboxgl-ctrl-bottom-right {
    z-index: 5;
}

:where(html:not([data-layout="desktop"])) .hg-panel {
    padding-bottom: var(--hg-attrib-clear);
}

/* The scale bar sits beside the logo (not above it, as Mapbox stacks them) so the two together are one 40 px row, the strip the panel keeps. */
:where(html:not([data-layout="desktop"])) .hg-map .mapboxgl-ctrl-bottom-left {
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-end;
}

/* A phone, upright or sideways: the basemap chips shrink to their icons so the toolbar fits on one line. */
:where(html:is([data-layout="phone"], [data-layout="phone-land"])) .hg-toolbar {
    gap: 6px;
    padding: 0 6px;
}

:where(html:is([data-layout="phone"], [data-layout="phone-land"])) .hg-chip__label {
    display: none;
}

:where(html:is([data-layout="phone"], [data-layout="phone-land"])) .hg-toolbar .hg-chip {
    padding: 7px 11px;
}

/* The Sign out button is one more button in a toolbar that was already full: the gaps are tighter and the thin separators dropped, so every
   button stays on the screen (tests/e2e/mobile.js checks this). The selectors are in :where(), so they weigh what the media query rules did and
   sharing.css (later, same weight) still decides the buttons of the two-row phone header. */
:where(html:is([data-layout="phone"], [data-layout="phone-land"])) .hg-toolbar .hg-toolbar__group:last-child {
    gap: 4px;
}

:where(html:is([data-layout="phone"], [data-layout="phone-land"])) .hg-toolbar .hg-toolbar__sep {
    display: none;
}

/* Phones in landscape: the vertical space is scarce, so trim the chrome. */
@media (max-height: 480px) and (orientation: landscape) {
    :root {
        --hg-toolbar-height: 40px;
        --hg-statusbar-height: 28px;
    }

    .hg-status__item--wide {
        order: -1;
    }

    .hg-panel__header {
        padding: 6px 12px;
    }

    .hg-panel__body {
        padding: 8px 12px;
    }
}

/* Phones in portrait: keep the status bar to the essentials. */
@media (max-width: 560px) and (orientation: portrait) {
    .hg-status {
        gap: 12px;
    }

    .hg-status__item:nth-child(3),
    .hg-status__item:nth-child(5) {
        display: none;
    }
}

/* Coarse pointers get bigger hit targets. */
@media (pointer: coarse) {
    .hg-chip {
        padding: 9px 14px;
    }

    .hg-chip--small {
        padding: 8px 12px;
    }

    .hg-button {
        padding: 12px;
    }

    .hg-icon-button {
        width: 38px;
        height: 38px;
    }
}

/* ------------------------------------------------------- icon picker -- */

.hg-iconpicker {
    position: relative;
    display: inline-block;
}

.hg-iconpicker__trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--hg-bg);
    border: 1px solid var(--hg-border-control);
    border-radius: 6px;
    color: var(--hg-text);
    padding: 8px 10px;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    min-width: 150px;
}

.hg-iconpicker__trigger:hover {
    border-color: var(--hg-accent-dim);
}

.hg-iconpicker__current {
    flex: 1 1 auto;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hg-iconpicker__placeholder {
    flex: 1 1 auto;
    text-align: left;
    color: var(--hg-text-dim);
}

.hg-iconpicker__panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 20;
    /* No wider than the side panel it opens in (300 px less the room either side): a wider list was cut off at the panel's edge and made it scroll sideways. */
    width: min(276px, 88vw);
    max-height: 340px;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--hg-bg-panel);
    border: 1px solid var(--hg-border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    padding: 10px;
}

.hg-iconpicker__group {
    margin-top: 10px;
}

.hg-iconpicker__grouplabel {
    font-size: var(--hg-fs-10);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--hg-text-dim);
    margin-bottom: 6px;
}

.hg-iconpicker__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 4px;
}

.hg-iconpicker__item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--hg-bg-panel-alt);
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--hg-text);
    cursor: pointer;
    font-size: 15px;
}

.hg-iconpicker__item:hover {
    border-color: var(--hg-accent-dim);
    color: var(--hg-accent);
}

.hg-iconpicker__item--selected {
    background: var(--hg-accent);
    border-color: var(--hg-accent);
    color: #1a1a10;
}

/* ------------------------------------------------------- icon library -- */

.hg-iconspage {
    display: grid;
    grid-template-rows: var(--hg-toolbar-height) 1fr;
    height: 100%;
}

.hg-iconspage__body {
    overflow-y: auto;
    padding: 20px;
}

.hg-iconspage__intro {
    max-width: 640px;
    margin-bottom: 28px;
}

.hg-iconspage__intro h1 {
    margin: 0 0 8px;
    font-size: 20px;
}

.hg-iconspage__intro p {
    color: var(--hg-text-dim);
    font-size: 13px;
    line-height: 1.5;
    margin: 0 0 16px;
}

.hg-iconspage__picker {
    padding: 14px;
    border: 1px solid var(--hg-border);
    border-radius: 8px;
    background: var(--hg-bg-panel);
}

.hg-iconspage__section {
    margin-bottom: 26px;
}

.hg-iconspage__section h2 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--hg-text-dim);
    margin: 0 0 10px;
}

.hg-iconspage__count {
    color: var(--hg-accent);
    margin-left: 6px;
}

.hg-iconspage__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
}

.hg-iconspage__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 12px 6px;
    border: 1px solid var(--hg-border);
    border-radius: 8px;
    background: var(--hg-bg-panel);
    text-align: center;
}

.hg-iconspage__item i {
    font-size: 19px;
    color: var(--hg-accent);
}

.hg-iconspage__label {
    font-size: var(--hg-fs-11);
    color: var(--hg-text);
}

.hg-iconspage__name {
    font-size: var(--hg-fs-10);
    color: var(--hg-text-dim);
    font-family: ui-monospace, Consolas, monospace;
}

/* A non-blocking note. Never covers the map. */
.hg-toast {
    position: absolute;
    left: 12px;
    bottom: calc(12px + var(--hg-attrib-clear)); /* stays above the Mapbox logo and attribution on a phone or tablet (--hg-attrib-clear is 0 on a desktop) */
    z-index: 6;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: min(420px, calc(100% - 24px));
    padding: 9px 10px 9px 12px;
    border-radius: 8px;
    background: rgba(28, 33, 24, 0.94);
    border: 1px solid rgba(255, 209, 102, 0.35);
    color: var(--hg-text);
    font-size: 12px;
    line-height: 1.45;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.hg-toast i {
    color: var(--hg-accent);
    margin-top: 1px;
}

.hg-toast__text {
    flex: 1 1 auto;
    min-width: 0;
    /* a long address in a message (a tile that failed to load) breaks instead of pushing the Dismiss button off the screen */
    overflow-wrap: anywhere;
}

.hg-toast__dismiss {
    background: transparent;
    border: none;
    color: var(--hg-text-dim);
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.hg-toast__dismiss:hover {
    color: var(--hg-accent);
}

/* The settings are read-only until the server's copy is known. */
.hg-prefs__fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 0;
}

.hg-prefs__fieldset:disabled {
    opacity: 0.55;
}

/* ------------------------------------------------------- sync status -- */

/* "Is my work saved?" Tiny and quiet: an icon and a few words. On a phone only the icon stays, and only 16 px wide, so
   it never pushes a toolbar button off the screen (tests/e2e/mobile.js checks that). */
.hg-sync {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    min-width: 0;
    padding: 2px 4px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--hg-text-dim);
    font-size: 12px;
    line-height: 1;
    cursor: default;
    white-space: nowrap;
}

.hg-sync i {
    font-size: 13px;
}

.hg-sync--saved i { color: #7fc77f; }
.hg-sync--saving i, .hg-sync--loading i { color: var(--hg-text-dim); }
.hg-sync--waking i, .hg-sync--offline i { color: var(--hg-accent); }
.hg-sync--error { color: #ff9b8a; }
.hg-sync--error i { color: #ff9b8a; }

.hg-sync--offline, .hg-sync--error, .hg-sync--waking {
    cursor: pointer;
}

@media (max-width: 1100px) {
    .hg-sync__text {
        display: none;
    }
}

@media (max-width: 640px) {
    .hg-sync {
        padding: 2px;
    }
}

/* A second note above the first one at the bottom of the map. */
.hg-toast--stacked {
    bottom: calc(64px + var(--hg-attrib-clear));
}

/* Mapbox control tweaks so the chrome matches the app. */
.mapboxgl-ctrl-group {
    background: var(--hg-bg-panel) !important;
    border: 1px solid var(--hg-border) !important;
}

.mapboxgl-ctrl-group button + button {
    border-top: 1px solid var(--hg-border) !important;
}

.mapboxgl-ctrl-icon {
    filter: invert(1) hue-rotate(180deg);
}

.mapboxgl-ctrl-scale {
    background: rgba(28, 33, 24, 0.75);
    border-color: var(--hg-border);
    color: var(--hg-text);
    font-size: var(--hg-fs-10);
}

.mapboxgl-ctrl-attrib {
    background: rgba(18, 22, 15, 0.75) !important;
}

.mapboxgl-ctrl-attrib a {
    color: var(--hg-text-dim);
}

.mapboxgl-popup-content {
    background: var(--hg-bg-panel);
    color: var(--hg-text);
    border: 1px solid var(--hg-border);
    border-radius: 6px;
    padding: 8px 12px;
}

/* Blazor's error bar. */
#blazor-error-ui {
    background: #ffe9a8;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* --------------------------------------------------------- panel tabs -- */

.hg-panel__header--split {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.hg-panel__header--split h2 {
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hg-tabrow {
    display: flex;
    flex: 0 0 auto;
    gap: 3px;
}

.hg-tab {
    background: transparent;
    border: 1px solid transparent;
    color: var(--hg-text-dim);
    border-radius: 6px;
    width: 25px;
    height: 26px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hg-tab:hover {
    color: var(--hg-accent);
    border-color: var(--hg-border-control);
}

.hg-tab--active {
    background: var(--hg-accent);
    border-color: var(--hg-accent);
    color: #1a1a10;
}

/*
 * The panel header colours every icon inside it yellow, which beat the tab's own colour and
 * left the active tab's icon yellow on a yellow button: invisible.
 */
.hg-panel__header .hg-tab i {
    margin-right: 0;
    color: inherit;
}

/* ------------------------------------------------------------- toolbar -- */

.hg-toolbar__sep {
    width: 1px;
    height: 22px;
    background: var(--hg-border);
    margin: 0 2px;
}

/* Disabled: dimmer and with the soft border, but the glyph keeps 3:1 (it was faded with opacity to 2.3:1). */
.hg-icon-button:disabled {
    color: var(--hg-text-disabled);
    border-color: var(--hg-border);
    cursor: default;
}

.hg-icon-button:disabled:hover {
    color: var(--hg-text-disabled);
    border-color: var(--hg-border);
}

/* The Personalization and Debug buttons are links: centred like the buttons beside them (F-10). */
a.hg-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

/* ---------------------------------------------------- focus and motion -- */

/* One visible ring for everything that can be focused with a keyboard (a Bluetooth keyboard, switch access, TalkBack). The rules above that
   switch the browser's outline off (inputs, pins, probes, the grid forecast sheet) have their own ring or are covered here. */
:focus-visible {
    outline: var(--hg-focus-ring);
    outline-offset: 2px;
}

.hg-input:focus-visible {
    outline: var(--hg-focus-ring);
    outline-offset: 1px;
}

.mapboxgl-canvas:focus-visible {
    outline: none;
}

/* Nothing moves for a person who asked for less motion: no transitions, no spinner, no pulse. (The pin and probe pop and the Save
   fade are only decoration; the page works the same without them.) */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }

    /* This one fades IN by animation; without it the escape link would stay invisible. */
    .hg-boot__escape {
        opacity: 1;
    }
}

/* --------------------------------------------------------------- lists -- */

.hg-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hg-item {
    background: var(--hg-bg-panel-alt);
    border: 1px solid transparent;
    border-radius: 6px;
    overflow: hidden;
}

.hg-item--open {
    border-color: var(--hg-accent-dim);
}

.hg-item__main {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--hg-text);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    padding: 9px 10px;
    cursor: pointer;
}

.hg-item__main:hover {
    color: var(--hg-accent);
}

.hg-item__main i {
    color: var(--hg-accent);
    flex: 0 0 auto;
}

.hg-item__name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hg-item__meta {
    flex: 0 0 auto;
    font-size: var(--hg-fs-11);
    color: var(--hg-text-dim);
    font-variant-numeric: tabular-nums;
}

.hg-item__action {
    background: transparent;
    border: none;
    color: var(--hg-text-dim);
    cursor: pointer;
    padding: 9px 10px;
}

.hg-item__action:hover {
    color: var(--hg-danger);
}

.hg-item__body {
    padding: 4px 10px 12px;
    border-top: 1px solid var(--hg-border);
}

.hg-input--area {
    resize: vertical;
    font-family: inherit;
}

/* ------------------------------------------------------- pointer readout -- */

/*
 * The grid reference that follows the pointer. It sits above the map and never
 * takes clicks, so it cannot get in the way of using the map.
 */
.hg-cursor-readout {
    position: absolute;
    z-index: 3;
    pointer-events: none;
    background: rgba(18, 22, 15, 0.92);
    border: 1px solid var(--hg-accent-dim);
    border-radius: 5px;
    color: var(--hg-accent);
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.03em;
    padding: 3px 7px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

/* ----------------------------------------------------------- draw bar -- */

.hg-drawbar {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: calc(16px + var(--hg-attrib-clear));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(18, 22, 15, 0.94);
    border: 1px solid var(--hg-border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.hg-drawbar__count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--hg-text-dim);
    white-space: nowrap;
}

.hg-drawbar__count i {
    color: #7ec8ff;
}

.hg-input--draw {
    width: 170px;
}

.hg-button--small {
    width: auto;
    padding: 6px 10px;
    font-size: 12px;
}

/* ------------------------------------------------- placing modes + notes -- */

/*
 * The banner shown while the map is waiting for a click (placing the grid, dropping pins). It sits
 * at the top of the map, clear of the zoom controls on the right.
 */
.hg-modebar {
    position: absolute;
    z-index: 3;
    top: 12px;
    left: 12px;
    right: 56px;
    margin: 0 auto;
    width: fit-content;
    max-width: calc(100% - 68px);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 8px 10px;
    background: rgba(18, 22, 15, 0.95);
    border: 1px solid var(--hg-accent-dim);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    font-size: 13px;
    color: var(--hg-text);
}

.hg-modebar > i {
    color: var(--hg-accent);
}

.hg-modebar__text {
    flex: 1 1 auto;
    line-height: 1.4;
}

.hg-modebar__text i {
    color: var(--hg-accent);
    margin-right: 4px;
}

.hg-modebar--pin .hg-iconpicker__trigger {
    min-width: 0;
    padding: 6px 8px;
}

/* The small note that says what the numbers on the grid are. */
.hg-gridnote {
    position: absolute;
    z-index: 3;
    left: 12px;
    top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    background: rgba(18, 22, 15, 0.82);
    border: 1px solid var(--hg-border);
    color: var(--hg-text);
    font-size: var(--hg-fs-11);
    letter-spacing: 0.02em;
    pointer-events: none;
}

.hg-gridnote i {
    color: var(--hg-accent);
}

.hg-button--active {
    box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.35);
}

.hg-hint--active {
    color: var(--hg-accent);
}

.hg-input--small {
    padding: 5px 8px;
    font-size: 12px;
}

/* ----------------------------------------------------------------- pins -- */

/*
 * A pin on the map: a coloured circle holding a Font Awesome icon, with a small point at the bottom.
 * Mapbox positions the marker element with an inline transform, so nothing here may use transform on
 * the element itself; the scaling of a selected pin is on the head.
 */
.hg-pin {
    width: 32px;
    height: 41px;
    cursor: pointer;
    outline: none;
}

.hg-pin__head {
    position: absolute;
    top: 0;
    left: 0;
    width: 32px;
    height: 32px;
    box-sizing: border-box;
    border-radius: 50%;
    border: 2px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    transform-origin: 50% 100%;
    transition: transform 0.12s ease-out, box-shadow 0.12s ease-out;
}

.hg-pin::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 30px;
    margin-left: -6px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 10px solid #ffffff;
    filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.45));
}

.hg-pin:hover .hg-pin__head {
    transform: scale(1.1);
}

.hg-pin--selected .hg-pin__head {
    transform: scale(1.2);
    box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.95), 0 3px 8px rgba(0, 0, 0, 0.65);
}

.hg-pin:focus-visible .hg-pin__head {
    outline: 2px solid var(--hg-accent);
    outline-offset: 3px;
}

.hg-pin__label {
    display: none;
    position: absolute;
    top: 44px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 3px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    color: #ffffff;
    text-shadow: 0 0 3px #000, 0 0 3px #000, 0 1px 2px #000;
    pointer-events: none;
}

/* The names appear from zoom 15; the selected pin always shows its own. */
.hg-zoom-labels .hg-pin--named .hg-pin__label,
.hg-pin--selected.hg-pin--named .hg-pin__label {
    display: block;
}

/* A small coloured badge with the pin's icon, used in the list and the editor. */
.hg-pinchip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.85);
    font-size: 12px;
}

.hg-pinchip--small {
    width: 22px;
    height: 22px;
    font-size: 10px;
}

.hg-pinchip i,
.hg-tree__name .hg-pinchip i {
    color: inherit;
    margin: 0;
}

/* -------------------------------------------------------- colour swatches -- */

.hg-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.hg-swatch {
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    cursor: pointer;
}

.hg-swatch:hover {
    border-color: rgba(255, 255, 255, 0.8);
}

.hg-swatch--selected {
    border-color: #ffffff;
    box-shadow: 0 0 0 2px var(--hg-accent);
}

.hg-swatch:focus-visible {
    outline: 2px solid var(--hg-accent);
    outline-offset: 2px;
}

@media (pointer: coarse) {
    .hg-swatch {
        width: 32px;
        height: 32px;
    }
}

/* ------------------------------------------------------------ pin editor -- */

.hg-preset__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
}

.hg-preset .hg-iconpicker__trigger {
    min-width: 0;
}

.hg-editor {
    margin: 0 0 14px;
    padding: 10px;
    border: 1px solid var(--hg-accent-dim);
    border-radius: 8px;
    background: var(--hg-bg-panel-alt);
}

.hg-editor__title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--hg-text-dim);
}

.hg-editor__close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--hg-text-dim);
    cursor: pointer;
    padding: 4px 6px;
}

.hg-editor__close:hover {
    color: var(--hg-accent);
}

.hg-editor .hg-iconpicker {
    display: block;
}

.hg-editor .hg-iconpicker__trigger {
    width: 100%;
}

/* -------------------------------------------------------------- pin tree -- */

.hg-treebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 4px 0 6px;
}

.hg-treebar__title {
    margin: 0;
}

.hg-treebar__new {
    flex: 0 0 auto;
}

.hg-tree,
.hg-tree__group {
    list-style: none;
    margin: 0;
    padding: 0;
}

.hg-tree__row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    padding-right: 4px;
    border: 1px solid transparent;
    border-radius: 6px;
}

.hg-tree__row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.hg-tree__row--selected {
    background: var(--hg-bg-panel-alt);
    border-color: var(--hg-accent-dim);
}

.hg-tree__row--hidden .hg-tree__label,
.hg-tree__row--hidden .hg-tree__count {
    opacity: 0.5;
}

.hg-tree__row--pin[draggable="true"] {
    cursor: grab;
}

.hg-tree__chev,
.hg-tree__eye {
    flex: 0 0 auto;
    width: 26px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--hg-text-dim);
    font-size: 11px;
    cursor: pointer;
}

.hg-tree__chev:hover,
.hg-tree__eye:hover {
    color: var(--hg-accent);
}

.hg-tree__eye[aria-pressed="true"] {
    color: var(--hg-danger);
}

.hg-tree__chevspace {
    flex: 0 0 auto;
    width: 26px;
}

.hg-tree__name {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 4px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--hg-text);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.hg-tree__name:hover {
    color: var(--hg-accent);
}

.hg-tree__name:focus-visible,
.hg-tree__chev:focus-visible,
.hg-tree__eye:focus-visible {
    outline: 2px solid var(--hg-accent);
    outline-offset: -1px;
}

.hg-tree__name--static {
    cursor: default;
    color: var(--hg-text-dim);
}

.hg-tree__name--static:hover {
    color: var(--hg-text-dim);
}

.hg-tree__name > i {
    flex: 0 0 auto;
    color: var(--hg-accent);
}

.hg-tree__label {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hg-tree__count {
    flex: 0 0 auto;
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--hg-bg);
    color: var(--hg-text-dim);
    font-size: var(--hg-fs-11);
    line-height: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.hg-tree__rename {
    flex: 1 1 auto;
    min-width: 0;
    padding: 4px 8px;
    font-size: 13px;
}

.hg-tree__tools {
    margin: 2px 0 6px 6px;
    padding: 6px;
    border-left: 2px solid var(--hg-accent-dim);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hg-tree__toolrow,
.hg-tree__confirmrow {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.hg-tree__toolrow .hg-button,
.hg-tree__confirmrow .hg-button {
    width: auto;
    flex: 1 1 auto;
}

.hg-tree__moveto {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--hg-fs-11);
    color: var(--hg-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.hg-tree__moveto select {
    flex: 1 1 auto;
    min-width: 0;
    text-transform: none;
    letter-spacing: normal;
}

.hg-tree__confirm p {
    margin: 0 0 8px;
    font-size: 12px;
    line-height: 1.45;
}

@media (pointer: coarse) {
    .hg-tree__row {
        min-height: 40px;
    }

    .hg-tree__name {
        align-self: stretch;
        min-height: 38px;
    }

    .hg-tree__chev,
    .hg-tree__eye {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

@media (max-width: 560px) {
    .hg-modebar {
        font-size: 12px;
    }

    .hg-modebar--pin .hg-modebar__text {
        flex-basis: 100%;
    }
}

/* While the map waits for a click the pins let it through. */
.hg-placing .hg-pin {
    pointer-events: none;
}

/* The active tab keeps its dark glyph under the pointer (the plain hover colour is yellow, which is the tab's own colour). */
.hg-tab--active:hover {
    color: #1a1a10;
    border-color: var(--hg-accent);
}

/* ==========================================================================
   Round 3: layers, details, line editing, measuring
   ========================================================================== */

/* Visible to a screen reader only. */
.hg-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hg-actions--row {
    flex-direction: row;
    flex-wrap: wrap;
}

.hg-actions--row .hg-button {
    flex: 1 1 0;
    width: auto;
    min-width: 76px;
}

.hg-actions--spaced {
    margin-top: 10px;
}

.hg-label__value {
    float: right;
    color: var(--hg-accent);
    text-transform: none;
    letter-spacing: normal;
    font-variant-numeric: tabular-nums;
}

.hg-label--spaced {
    margin-top: 12px;
}

.hg-range {
    width: 100%;
    accent-color: var(--hg-accent);
    margin: 2px 0 4px;
}

.hg-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--hg-text);
    cursor: pointer;
}

.hg-check input {
    accent-color: var(--hg-accent);
    width: 16px;
    height: 16px;
}

.hg-note--strong {
    color: var(--hg-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- details -- */

.hg-detail__name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--hg-text);
    font-size: 14px;
    text-transform: none;
    letter-spacing: normal;
}

.hg-detail__note {
    margin: 0 0 10px;
    padding: 8px 10px;
    border-left: 2px solid var(--hg-accent-dim);
    background: rgba(0, 0, 0, 0.18);
    border-radius: 0 6px 6px 0;
    font-size: 13px;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.hg-summary--detail {
    margin-bottom: 12px;
    padding-top: 8px;
}

.hg-summary--detail dd {
    min-width: 0;
    overflow-wrap: anywhere;
}

.hg-colordot {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 5px;
    vertical-align: -1px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.8);
}

.hg-total {
    color: var(--hg-accent);
    font-weight: 700;
}

.hg-confirmbox {
    margin: 0 0 14px;
    padding: 8px 10px;
    border: 1px solid rgba(255, 107, 82, 0.35);
    border-radius: 6px;
}

/* ---------------------------------------------------------------- tables -- */

.hg-table {
    width: 100%;
    margin: 0 0 12px;
    border-collapse: collapse;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.hg-table th,
.hg-table td {
    padding: 4px 6px;
    text-align: right;
    border-bottom: 1px solid var(--hg-border);
    vertical-align: top;
}

.hg-table thead th {
    color: var(--hg-text-dim);
    font-size: var(--hg-fs-10);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hg-table tbody th {
    text-align: left;
    color: var(--hg-accent);
    font-weight: 700;
    width: 1%;
}

.hg-table__main {
    display: block;
    color: var(--hg-text);
}

.hg-table__sub {
    display: block;
    color: var(--hg-text-dim);
    font-size: var(--hg-fs-10-5);
}

/* ------------------------------------------------- custom colour, segmented -- */

.hg-swatch--custom {
    position: relative;
    display: inline-block;
    overflow: hidden;
    background: conic-gradient(#e5484d, #f08a24, #e0b341, #46a758, #2bb3a3, #3b82f6, #9b6bd6, #e5484d);
}

.hg-swatch__picker {
    position: absolute;
    inset: -6px;
    width: 40px;
    height: 40px;
    opacity: 0;
    cursor: pointer;
}

.hg-hexrow {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.hg-hexrow__label {
    font-size: var(--hg-fs-11);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--hg-text-dim);
}

.hg-input.hg-hex {
    width: 96px;
    font-family: 'Consolas', 'Courier New', monospace;
}

.hg-segmented {
    display: flex;
    border: 1px solid var(--hg-border-control);
    border-radius: 8px;
    overflow: hidden;
}

.hg-segmented__item {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 8px;
    background: var(--hg-bg-panel-alt);
    border: none;
    color: var(--hg-text-dim);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.hg-segmented__item + .hg-segmented__item {
    border-left: 1px solid var(--hg-border);
}

.hg-segmented__item:hover {
    color: var(--hg-text);
}

.hg-segmented__item--active {
    background: var(--hg-accent);
    color: #1a1a10;
    font-weight: 600;
}

/* ---------------------------------------------------------------- grid head -- */

.hg-gridhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 14px;
    padding: 8px 10px;
    border: 1px solid var(--hg-border);
    border-radius: 8px;
    background: var(--hg-bg-panel-alt);
}

.hg-gridhead__state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
}

.hg-gridhead__state i {
    color: var(--hg-accent);
}

.hg-gridhead--hidden .hg-gridhead__state {
    color: var(--hg-text-dim);
}

.hg-gridhead--hidden .hg-gridhead__state i {
    color: var(--hg-danger);
}

.hg-gridhead .hg-button {
    width: auto;
}

/* The grid legend on the map is also the eye of the grid. */
.hg-gridnote {
    padding-left: 3px;
    pointer-events: auto;
}

.hg-gridnote__eye {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--hg-accent);
    cursor: pointer;
}

.hg-gridnote__eye:hover {
    background: rgba(255, 209, 102, 0.18);
}

.hg-gridnote--hidden {
    color: var(--hg-text-dim);
}

.hg-gridnote--hidden .hg-gridnote__eye {
    color: var(--hg-danger);
}

/* ------------------------------------------------------------ layers tree -- */

.hg-tree__row--grid .hg-tree__name > i {
    color: var(--hg-accent);
}

.hg-tree__row--grid[draggable="true"],
.hg-tree__row--item[draggable="true"] {
    cursor: grab;
}

.hg-tree__row--hidden .hg-pinchip {
    opacity: 0.45;
}

.hg-tree__row--hidden .hg-item__meta {
    opacity: 0.5;
}

.hg-tree__name .hg-item__meta {
    margin-left: auto;
    padding-left: 6px;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Paths and measurements are squarer than pins, so the kind can be told at a glance. */
.hg-pinchip--path,
.hg-pinchip--measurement {
    border-radius: 6px;
}

.hg-pinchip--measurement {
    border-style: dashed;
}

.hg-pinchip svg,
.hg-pin__head svg,
.hg-iconpicker__item svg {
    display: block;
    flex: 0 0 auto;
}

/* ------------------------------------------------------------ views list -- */

.hg-item--view {
    display: block;
}

.hg-item__line {
    display: flex;
    align-items: center;
}

.hg-item__line .hg-item__main {
    flex: 1 1 auto;
    min-width: 0;
}

.hg-item__summary {
    padding: 0 10px 8px 34px;
    margin-top: -4px;
    font-size: var(--hg-fs-11);
    color: var(--hg-text-dim);
}

/* ---------------------------------------------------------- vertex handles -- */

/*
 * The handles for editing the points of a path or measurement. Mapbox positions the element with an
 * inline transform, so nothing here may use transform on the element itself.
 */
.hg-vertex {
    --hg-handle: #ffd166;
    width: 18px;
    height: 18px;
    box-sizing: border-box;
    border-radius: 50%;
    background: var(--hg-handle);
    border: 2.5px solid #ffffff;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
    cursor: grab;
    outline: none;
}

.hg-vertex:active {
    cursor: grabbing;
}

.hg-vertex--mid {
    width: 12px;
    height: 12px;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.85);
    background: rgba(18, 22, 15, 0.7);
    cursor: copy;
}

.hg-vertex--mid:hover {
    background: var(--hg-handle);
}

.hg-vertex--selected {
    border-color: #ff6b52;
    box-shadow: 0 0 0 3px rgba(255, 107, 82, 0.55), 0 1px 5px rgba(0, 0, 0, 0.65);
}

.hg-vertex:focus-visible {
    outline: 2px solid var(--hg-accent);
    outline-offset: 3px;
}

@media (pointer: coarse) {
    .hg-vertex {
        width: 26px;
        height: 26px;
    }

    .hg-vertex--mid {
        width: 18px;
        height: 18px;
    }
}

.hg-placing .hg-vertex {
    pointer-events: none;
}

/* --------------------------------------------------------- measure bar -- */

.hg-measurebar {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: calc(16px + var(--hg-attrib-clear));
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100% - 24px);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(18, 22, 15, 0.95);
    border: 1px solid var(--hg-accent-dim);
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.hg-measurebar__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.hg-measurebar__row .hg-button {
    flex: 0 0 auto;
}

.hg-measurebar__kind {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--hg-fs-11);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--hg-text-dim);
}

.hg-measurebar__kind i {
    color: var(--hg-accent);
}

.hg-measurebar__count {
    font-size: 12px;
    color: var(--hg-text-dim);
}

.hg-measurebar__total {
    margin-left: auto;
    font-size: 17px;
    font-weight: 700;
    color: var(--hg-accent);
    font-variant-numeric: tabular-nums;
}

.hg-measurebar__live {
    font-size: 12px;
    color: #7ec8ff;
    font-variant-numeric: tabular-nums;
}

.hg-measurebar__hint {
    margin: 0;
    font-size: var(--hg-fs-11);
    color: var(--hg-text-dim);
}

.hg-measurebar__row--name .hg-input {
    flex: 1 1 140px;
    min-width: 0;
    width: auto;
}

@media (max-width: 560px) {
    .hg-measurebar {
        bottom: calc(8px + var(--hg-attrib-clear));
        width: calc(100% - 16px);
    }

    .hg-measurebar__hint {
        display: none;
    }

    /* The logo goes, so the basemap chips keep some room beside the extra tool button. */
    .hg-brand {
        display: none;
    }
}

/* The Done / Cancel / Delete row of the editor stays in view while the form scrolls under it. */
.hg-actions--sticky {
    position: sticky;
    bottom: -10px;
    z-index: 2;
    margin: 8px -10px -10px;
    padding: 10px;
    background: var(--hg-bg-panel-alt);
    border-top: 1px solid var(--hg-border);
    border-radius: 0 0 8px 8px;
}

@media (pointer: coarse) {
    .hg-measurebar .hg-button,
    .hg-drawbar .hg-button,
    .hg-modebar .hg-button {
        min-height: 40px;
    }
}

/* ------------------------------------------------- sub pages and debug -- */
/* Standalone pages outside the map shell (debug, personalization). */

.hg-subpage {
    display: grid;
    grid-template-rows: var(--hg-toolbar-height) 1fr;
    height: 100%;
    width: 100%;
}

.hg-subpage__body {
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.hg-subpage__column {
    max-width: 720px;
    margin: 0 auto;
}

.hg-subpage h1 {
    margin: 4px 0 8px;
    font-size: 22px;
}

.hg-debug__section {
    background: var(--hg-bg-panel);
    border: 1px solid var(--hg-border);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 14px 0;
}

.hg-debug__section h2 {
    margin: 0 0 8px;
    font-size: 16px;
    color: var(--hg-accent);
}

.hg-debug__json {
    margin: 0;
    padding: 8px;
    background: var(--hg-bg);
    border-radius: 6px;
    overflow-x: auto;
    font-size: 12px;
}

.hg-tuning__row { margin: 10px 0; }

.hg-tuning__inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hg-tuning__range { flex: 1 1 auto; min-width: 0; accent-color: var(--hg-accent); }
.hg-tuning__number { width: 76px; flex: 0 0 auto; }

.hg-tuning__buttons { margin: 12px 0; }
.hg-tuning__savebar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 8px 0; background: var(--hg-bg-panel); }
.hg-tuning__state { flex: 1; font-size: 0.9rem; opacity: 0.8; }
.hg-tuning__state--dirty { opacity: 1; font-weight: 600; color: #e0b84a; }

.hg-tuning__heading {
    margin: 16px 0 6px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--hg-text-dim);
}

.hg-tuning__live {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 2px 14px;
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.hg-tuning__live dt { color: var(--hg-text-dim); }
.hg-tuning__live dd { margin: 0; }

.hg-tuning__table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

.hg-tuning__table th,
.hg-tuning__table td {
    text-align: left;
    padding: 3px 8px;
    border-bottom: 1px solid var(--hg-border);
}

.hg-tuning__table th { color: var(--hg-text-dim); font-weight: 600; }

.hg-tuning__row--now td {
    background: rgba(255, 209, 102, 0.16);
    color: var(--hg-accent);
}

/* The live grid readout on the map, and the floating tuning panel. */

.hg-gridhud {
    position: absolute;
    left: 10px;
    bottom: calc(10px + var(--hg-attrib-clear));
    z-index: 3;
    max-width: min(440px, calc(100% - 20px));
    padding: 6px 10px;
    background: rgba(18, 22, 15, 0.88);
    border: 1px solid var(--hg-border);
    border-radius: 8px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.hg-gridhud__line { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.hg-gridhud__line--dim { color: var(--hg-text-dim); }
.hg-gridhud .hg-button { margin-top: 6px; }

.hg-tuningfloat {
    position: absolute;
    right: 10px;
    top: 10px;
    bottom: 10px;
    z-index: 6;
    width: min(360px, calc(100% - 20px));
    overflow-y: auto;
    padding: 8px 12px 12px;
    background: rgba(28, 33, 24, 0.96);
    border: 1px solid var(--hg-border);
    border-radius: 8px;
}

.hg-tuningfloat__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}


/* ==========================================================================
   Personalization page (/personalization). Classes are prefixed hg-prefs.
   A standalone page: toolbar on top, one centred column that scrolls.
   ========================================================================== */

.hg-prefs {
    display: grid;
    grid-template-rows: var(--hg-toolbar-height) 1fr;
    height: 100%;
}

.hg-prefs__body {
    overflow-y: auto;
    padding: 20px 16px 40px;
    -webkit-overflow-scrolling: touch;
}

.hg-prefs__column {
    max-width: 640px;
    margin: 0 auto;
}

.hg-prefs__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.hg-prefs__head h1 {
    margin: 0 0 6px;
    font-size: 22px;
}

.hg-prefs__saved {
    min-width: 56px;
    text-align: right;
    font-size: 12px;
    font-weight: 600;
    color: var(--hg-accent);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.hg-prefs__saved--shown {
    opacity: 1;
}

.hg-prefs__lede {
    margin: 0 0 18px;
    color: var(--hg-text-dim);
    font-size: 13px;
    line-height: 1.5;
}

.hg-prefs__section {
    margin-bottom: 18px;
    padding: 14px 16px 4px;
    border: 1px solid var(--hg-border);
    border-radius: 8px;
    background: var(--hg-bg-panel);
}

.hg-prefs__section h2 {
    margin: 0 0 12px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--hg-accent);
}

.hg-prefs__sectionnote {
    margin: -6px 0 14px;
}

.hg-prefs__stack {
    flex-direction: column;
}

.hg-prefs__stack .hg-segmented__item + .hg-segmented__item {
    border-left: none;
    border-top: 1px solid var(--hg-border);
}

.hg-prefs__stack .hg-segmented__item {
    justify-content: flex-start;
    text-align: left;
}

.hg-prefs__auto {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--hg-text-dim);
}

.hg-prefs__back {
    width: auto;
    text-decoration: none;
}

.hg-prefs__footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}

.hg-prefs select.hg-input {
    appearance: auto;
}

/* ------------------------------------------------------------- sign-in -- */

/* Centred message pages: signed out, no access, server unreachable, access denied, sign-in failed. */
.hg-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 100%;
    padding: 24px;
    text-align: center;
}

.hg-gate > i {
    font-size: 40px;
    color: var(--hg-accent);
}

.hg-gate h1 {
    margin: 0;
    font-size: 22px;
}

.hg-gate p {
    margin: 0;
    max-width: 420px;
    color: var(--hg-text-dim);
}

.hg-gate .hg-gate__button {
    width: 220px;
    max-width: 100%;
    text-decoration: none;
}

/* The signed-in name beside the Sign out button. Hidden on narrower screens, where only the button stays. */
.hg-user {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    padding: 0 4px;
    color: var(--hg-text-dim);
    font-size: 12px;
}

.hg-user__name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .hg-user {
        display: none;
    }
}

/* ---------------------------------------------------------- front door -- */

.hg-landing {
    background: radial-gradient(ellipse at top, rgba(255, 209, 102, 0.08), transparent 60%), var(--hg-bg);
}

.hg-landing h1 { font-size: 30px; }

.hg-landing__tagline {
    font-size: 16px;
    color: var(--hg-text);
}

.hg-landing__note {
    padding: 4px 12px;
    border: 1px solid var(--hg-border);
    border-radius: 999px;
    background: var(--hg-bg-panel);
    font-size: 12px;
}

.hg-landing__features {
    margin: 8px 0 14px;
    padding: 0;
    list-style: none;
    color: var(--hg-text-dim);
    line-height: 1.7;
}

.hg-landing__small {
    margin-top: 6px;
    font-size: 12px;
}

/* A plain way out of the "taking you to sign-in" screen if the automatic move was swallowed. Appears after 3 s. */
.hg-boot__escape {
    margin-top: 6px;
    font-size: 12px;
    color: var(--hg-accent);
    opacity: 0;
    animation: hg-escape-in 0.4s ease 3s forwards;
}

@keyframes hg-escape-in {
    to { opacity: 1; }
}

/* ------------------------------------------------------------- grid list -- */

/* A hint that has nothing to say (the grid message) takes no room. */
.hg-hint[hidden] {
    display: none;
}

.hg-gridlist {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hg-gridlist__item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 2px;
    border: 1px solid var(--hg-border);
    border-radius: 8px;
    background: var(--hg-bg-panel-alt);
}

.hg-gridlist__item--selected {
    border-color: var(--hg-accent);
}

.hg-gridlist__item--hidden .hg-gridlist__name {
    color: var(--hg-text-dim);
}

.hg-gridlist__name {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.hg-gridlist__name > i {
    color: var(--hg-accent);
}

.hg-gridlist__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* A grid in the layers tree is square-cornered like paths, in its own line colour. */
.hg-pinchip--grid {
    border-radius: 4px;
}

/* <small> is 0.8333em by default (11.7 px). The larger of that and the floor: unchanged on a desktop, 12 px on a phone. */
small {
    font-size: max(var(--hg-fs-11), 0.8333em);
}

/* The active tool button keeps its dark glyph under a finger that stays "hovering" after a tap (the plain hover colour is the accent, which
   is the active button's own colour: an invisible icon on a touch screen). */
.hg-icon-button--active:hover {
    color: #1a1a10;
    border-color: var(--hg-accent);
}

/* ==========================================================================
   Touch targets (docs/12-mobile-design.md, step B3): on a touch screen (a coarse pointer) everything a finger must hit is at least
   --hg-target (44 px) in both directions. The VISIBLE size of small things (the sync dot, the eye, a swatch) stays modest where it can;
   the box that takes the tap does not. A mouse keeps the sizes it always had.
   ========================================================================== */
@media (pointer: coarse) {
    .hg-sync {
        min-width: var(--hg-target);
        min-height: var(--hg-target);
        justify-content: center;
        padding: 0;
    }

    .hg-toast__dismiss {
        min-width: var(--hg-target);
        min-height: var(--hg-target);
    }

    /* A tick box: the whole row is the target (the label), and the box itself is easier to see. */
    .hg-check {
        min-height: var(--hg-target);
    }

    .hg-check input {
        width: 22px;
        height: 22px;
        flex: 0 0 auto;
    }

    .hg-tree__row {
        min-height: var(--hg-target);
    }

    .hg-tree__name {
        min-height: var(--hg-target);
    }

    .hg-tree__chev,
    .hg-tree__eye {
        width: var(--hg-target);
        height: var(--hg-target);
    }

    .hg-tree__chevspace {
        width: var(--hg-target);
    }

    .hg-button,
    .hg-item__main,
    .hg-item__action,
    .hg-button--small,
    .hg-chip,
    .hg-chip--small,
    .hg-input,
    .hg-input--small,
    .hg-iconpicker__trigger,
    .hg-gridlist__name,
    .hg-segmented__item,
    .hg-treebar__new {
        min-height: var(--hg-target);
    }

    .hg-chiprow {
        gap: 8px;
    }

    .hg-chip--small {
        min-width: var(--hg-target);
    }

    .hg-item__action {
        min-width: var(--hg-target);
    }

    .hg-editor__close {
        min-width: var(--hg-target);
        min-height: var(--hg-target);
    }

    .hg-swatch {
        width: var(--hg-target);
        height: var(--hg-target);
    }

    .hg-swatches {
        gap: 8px;
    }

    .hg-iconpicker__grid {
        grid-template-columns: repeat(auto-fill, minmax(var(--hg-target), 1fr));
        gap: 8px;
    }

    .hg-iconpicker__item {
        min-height: var(--hg-target);
    }

    /* The eye of the grid note: a small round button in a small pill; its box is 44 px, reaching out over the pill's edge. */
    .hg-gridnote__eye {
        width: var(--hg-target);
        height: var(--hg-target);
        margin: -10px -4px -10px -10px;
    }

    .hg-measurebar .hg-button,
    .hg-drawbar .hg-button,
    .hg-modebar .hg-button {
        min-height: var(--hg-target);
    }

    /* The buttons of the map itself (zoom, compass, fullscreen, find me) and the attribution "i": Mapbox draws them 29 and 24 px. */
    .mapboxgl-ctrl-group button {
        width: var(--hg-target);
        height: var(--hg-target);
    }

    .mapboxgl-ctrl-attrib.mapboxgl-compact {
        min-height: 40px;
        padding-right: 40px;
        border-radius: 22px;
    }

    .mapboxgl-ctrl-attrib-button {
        width: var(--hg-target);
        height: var(--hg-target);
        right: -2px;
        top: -2px;
        border-radius: 22px;
    }
}

/* ------------------------------------------------------- pin version history -- */
/* The last ten states of a pin, in its card. Each row is one change with a Restore button; every target is at least 44 px. */
.hg-history { margin: 0.5rem 0; }
.hg-history > summary { min-height: 44px; display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 600; }
.hg-history__count { color: var(--hg-text-dim); font-weight: 400; }
.hg-history__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.25rem; }
.hg-history__row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "when restore" "what restore"; column-gap: 0.75rem; align-items: center; min-height: 44px; }
.hg-history__when { grid-area: when; color: var(--hg-text-dim); font-size: 0.75rem; }
.hg-history__what { grid-area: what; overflow-wrap: anywhere; }
.hg-history__restore { grid-area: restore; min-height: 44px; min-width: 44px; }

/* The date of the satellite picture, in the map's credits (set by hgMap.setImageryNote). */
.hg-imagery-note { margin-left: 0.5rem; white-space: nowrap; }
.hg-imagery-note::before { content: "\00b7\00a0"; }

/* ------------------------------------------------------------------ bottom sheet -- */
/*
 * A phone held upright: the panel is a bottom sheet instead of a wall down the left side. It has three heights, cycled by its handle: peek (only the
 * tabs), half and full. The map above it stays visible and usable. Every other layout keeps the side panel. The 40 px strip at the foot of every
 * panel (--hg-attrib-clear) is kept, so the Mapbox logo and credits are never covered.
 */
.hg-sheet-handle { display: none; }

html[data-layout="phone"] .hg-panel--grid {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    border-right: 0;
    border-top: 1px solid var(--hg-border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.55);
    height: 52vh;
    height: 52dvh;
    max-height: calc(100% - 56px);
}

/* Folded down: the handle and the tab row (the title is left out), above the strip kept for the Mapbox logo and credits. */
html[data-layout="phone"] .hg-panel--sheet-peek { height: calc(var(--hg-attrib-clear) + 44px + 60px + env(safe-area-inset-bottom, 0px)); }
html[data-layout="phone"] .hg-panel--sheet-peek .hg-panel__header h2 { display: none; }
html[data-layout="phone"] .hg-panel--sheet-full { height: 90vh; height: 90dvh; }
html[data-layout="phone"] .hg-panel--sheet-peek .hg-panel__body,
html[data-layout="phone"] .hg-panel--sheet-peek > :not(.hg-sheet-handle):not(.hg-panel__header) { display: none; }

html[data-layout="phone"] .hg-sheet-handle {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    cursor: pointer;
}

/* A finger on the handle is a drag of the sheet, not a scroll or a pan of the page: without this the browser takes the gesture and cancels it. */
.hg-sheet-handle { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }

.hg-sheet-handle__bar { width: 44px; height: 5px; border-radius: 3px; background: var(--hg-border-control, #727d66); }

/* On an upright phone the grid reference of the pointer is in the coordinate bar, and a touch leaves the label stuck on the map under the sheet: leave it out. */
html[data-layout="phone"] .hg-cursor-readout { display: none !important; }

/* ---------------------------------------------------------------- phone tabs -- */
/* An upright phone has four tabs, each with its name under the icon: icons alone were small and unlabelled. */
.hg-tab__label { display: none; }

html[data-layout="phone"] .hg-tabrow { display: flex; width: 100%; gap: 4px; }

html[data-layout="phone"] .hg-tab {
    flex: 1 1 0;
    min-width: 44px;
    width: auto;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

html[data-layout="phone"] .hg-tab__label { display: block; font-size: 12px; line-height: 1.1; }

/* The tabs carry their names on an upright phone, so the title line above them said the same thing twice. */
html[data-layout="phone"] .hg-panel__header h2 { display: none; }

/* The page can be pinch-zoomed (panels, cards, text) for people who need it; the map keeps its own gestures: a pinch on the map zooms the MAP, never the page. */
.hg-map { touch-action: none; }

/* ------------------------------------------------------------ phone header: map style menu + search -- */
.hg-phone-only { display: none; }

html[data-layout="phone"] .hg-phone-only {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 17px;
}

/* The four basemap chips give way to one button that opens a list of them, so Search can have a place in the header. */
html[data-layout="phone"] .hg-toolbar__group--center .hg-chip { display: none; }

/* Search is a header button on a phone, not a dock tool. */
html[data-layout="phone"] .hg-toolbar__tools [title="Search panel"] { display: none; }

.hg-basemap-menu {
    position: fixed;
    z-index: 8;
    top: calc(var(--hg-toolbar-height) - 2px);
    left: 8px;
    min-width: 220px;
    display: grid;
    padding: 6px;
    gap: 2px;
    background: var(--hg-bg-panel);
    border: 1px solid var(--hg-border-control, var(--hg-border));
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.hg-basemap-menu__item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 12px;
    background: transparent;
    color: var(--hg-text);
    border: 0;
    border-radius: 8px;
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.hg-basemap-menu__item--active { background: var(--hg-accent); color: #1a1d12; }

/* Search is a sheet on a phone, like the side panel: full width on the bottom edge. */
html[data-layout="phone"] .hg-panel--search {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 60vh;
    height: 60dvh;
    max-height: calc(100% - 56px);
    border-left: 0;
    border-top: 1px solid var(--hg-border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.55);
}
