/* ==========================================================================
   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;
    --hg-text: #e8eddf;
    --hg-text-dim: #a8b39a;
    --hg-accent: #ffd166;
    --hg-accent-dim: #c9a34e;
    --hg-danger: #ff6b52;
    --hg-panel-width: 300px;
    --hg-panel-width-search: 260px;
    --hg-toolbar-height: 48px;
    --hg-statusbar-height: 34px;
}

* {
    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;
    /* 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;
}

/* --------------------------------------------------------------- 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: 11px;
    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);
    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);
    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: 11px;
}

.hg-icon-button {
    background: transparent;
    border: 1px solid var(--hg-border);
    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);
    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);
    border-color: rgba(255, 107, 82, 0.35);
}

.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: 11px;
    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: 10px;
    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 -- */

/* Narrow screens: the panels float over the map, one at a time. */
@media (max-width: 900px) {
    .hg-body,
    .hg-body--both,
    .hg-body--grid,
    .hg-body--search,
    .hg-body--none {
        grid-template-columns: 1fr;
    }

    /* The panels float over the map, so the map always takes the one column. */
    .hg-body.hg-body > .hg-map,
    .hg-body.hg-body > .hg-panel--grid,
    .hg-body.hg-body > .hg-panel--search {
        grid-column: 1;
    }

    .hg-panel {
        position: absolute;
        top: 0;
        bottom: 0;
        width: min(320px, 88vw);
        z-index: 4;
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.55);
    }

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

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

    .hg-brand__text {
        display: none;
    }
}

/* Phones: the basemap chips shrink to their icons so the toolbar fits on one line. */
@media (max-width: 640px) {
    .hg-toolbar {
        gap: 6px;
        padding: 0 6px;
    }

    .hg-chip__label {
        display: none;
    }

    .hg-toolbar .hg-chip {
        padding: 7px 11px;
    }

    /* The Sign out button is one more button in a toolbar that was already full: the buttons are a little
       narrower (still 34 x 38 to touch), the gaps tighter and the thin separators dropped, so every button
       stays on the screen (tests/e2e/mobile.js checks this). */
    .hg-toolbar .hg-toolbar__group:last-child {
        gap: 4px;
    }

    .hg-toolbar .hg-toolbar__group:last-child .hg-icon-button {
        width: 34px;
    }

    .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);
    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;
    width: min(340px, 88vw);
    max-height: 340px;
    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: 10px;
    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: 11px;
    color: var(--hg-text);
}

.hg-iconspage__name {
    font-size: 10px;
    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: 12px;
    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;
}

.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);
}

/* 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: 10px;
}

.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);
}

.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;
}

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

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

/* --------------------------------------------------------------- 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: 11px;
    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: 5;
    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: 4;
    left: 50%;
    bottom: 16px;
    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: 4;
    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: 11px;
    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: 11px;
    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: 11px;
    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: 10px;
    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: 10.5px;
}

/* ------------------------------------------------- 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: 11px;
    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);
    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--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: 11px;
    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: 4;
    left: 50%;
    bottom: 16px;
    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: 11px;
    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: 11px;
    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: 8px;
        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__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: 10px;
    z-index: 5;
    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; }
}
