:root{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#17211b;background:#f4f7f4}*{box-sizing:border-box}body{margin:0}.topbar{height:58px;background:#183b2b;color:white;display:flex;align-items:center;justify-content:space-between;padding:0 18px}.topbar nav{display:flex;gap:14px;align-items:center}.topbar a{color:white;text-decoration:none}.topbar button{width:auto;background:#fff;color:#183b2b;padding:8px 12px}.app-shell{display:grid;grid-template-columns:320px 1fr;height:calc(100vh - 58px)}.sidebar{padding:16px;overflow:auto;background:white;border-right:1px solid #d9e0da}.sidebar h2{font-size:1rem;margin-top:20px}.sidebar label,.login-card label{display:grid;gap:5px;margin:10px 0}input,select,button{font:inherit;padding:10px;border:1px solid #aeb8b0;border-radius:7px}button{background:#246b47;color:white;border:0;cursor:pointer;width:100%;margin:6px 0}button:disabled{opacity:.5;cursor:not-allowed}#map{min-height:400px}.login-page{min-height:100vh;display:grid;place-items:center}.card{background:white;border:1px solid #d9e0da;border-radius:12px;padding:28px;box-shadow:0 8px 30px rgba(0,0,0,.08)}.login-card{width:min(420px,92vw)}.message{min-height:1.3em;color:#9a2a2a}.muted{color:#687269;font-size:.9rem}.admin-wrap{padding:24px;max-width:1100px;margin:auto}table{width:100%;border-collapse:collapse;background:white}th,td{text-align:left;padding:10px;border-bottom:1px solid #e1e6e2}td button{width:auto;padding:7px 12px}@media(max-width:760px){.app-shell{grid-template-columns:1fr;grid-template-rows:auto 60vh;height:auto}.sidebar{border-right:0}.topbar{position:sticky;top:0;z-index:5}}

.weather-forecast-day {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(127, 127, 127, 0.35);
}

.weather-forecast-day:last-child {
    border-bottom: 0;
}

#savedRouteDetailsPanel {
    margin-top: 1rem;
    padding: 0.9rem;
    border: 1px solid rgba(127, 127, 127, 0.4);
    border-radius: 0.5rem;
}

#savedRouteDetailsPanel button {
    margin-top: 0.4rem;
}

#savedRouteDetailsResult {
    line-height: 1.55;
}

.route-elevation-profile {
    margin: 1rem 0;
}

.route-elevation-profile svg {
    display: block;
    width: 100%;
    height: auto;
    min-height: 180px;
    overflow: visible;
    background: rgba(127, 127, 127, 0.06);
    border: 1px solid rgba(127, 127, 127, 0.35);
    border-radius: 0.45rem;
}

.route-profile-grid {
    stroke: currentColor;
    stroke-width: 1;
    opacity: 0.13;
}

.route-profile-area {
    fill: rgba(52, 152, 219, 0.22);
    stroke: none;
}

.route-profile-line {
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.route-profile-label {
    fill: currentColor;
    font-size: 13px;
}

.route-profile-axis-title {
    fill: currentColor;
    font-size: 14px;
    font-weight: 600;
}

.movement-settings-panel,
.route-activity-editor {
    margin: 0.9rem 0;
    padding: 0.85rem;
    border: 1px solid rgba(127, 127, 127, 0.38);
    border-radius: 0.55rem;
    background: rgba(127, 127, 127, 0.04);
}

.secondary-button {
    background: #687269;
}

.route-gradient-warning {
    padding: 0.7rem;
    border-left: 4px solid #b6402c;
    background: rgba(182, 64, 44, 0.1);
}

.route-profile-gradient {
    fill: none;
    stroke-width: 4;
    stroke-linecap: round;
}

.route-profile-flat {
    stroke: #3d8b5f;
}

.route-profile-moderate {
    stroke: #d4a017;
}

.route-profile-steep {
    stroke: #d66a24;
}

.route-profile-very-steep {
    stroke: #b52d2d;
}

.route-planner-panel {
    margin: 1rem 0;
    padding: 0.9rem;
    border: 1px solid rgba(127, 127, 127, 0.38);
    border-radius: 0.55rem;
    background: rgba(127, 127, 127, 0.04);
}

.route-planner-summary {
    padding: 0.7rem;
    line-height: 1.5;
    background: rgba(36, 107, 71, 0.08);
    border-radius: 0.45rem;
}

.route-planner-point {
    display: block;
    width: 18px;
    height: 18px;
    min-width: 18px;
    padding: 0;
    margin: 0;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #d35400;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.55);
    cursor: grab;
}

.route-planner-point:active {
    cursor: grabbing;
}

.danger-button {
    background: #a93226;
}

.saved-content-library {
    min-height: calc(100vh - 58px);
    padding: 1rem;
    background: #f4f1fa;
}

.saved-library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto 1rem;
}

.saved-library-header button {
    width: auto;
}

.saved-library-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    max-width: 1200px;
    margin: 0 auto 1rem;
    padding: 0.35rem;
    border-radius: 0.7rem;
    background: #ded3f0;
}

.saved-library-tab {
    margin: 0;
    background: transparent;
    color: #372450;
}

.saved-library-tab.active {
    background: #6d4b91;
    color: #fff;
}

.saved-library-filters {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.75rem;
    max-width: 1200px;
    margin: 0 auto 1rem;
    padding: 1rem;
    border: 1px solid #d1c4e2;
    border-radius: 0.75rem;
    background: #fff;
}

.saved-library-list {
    display: grid;
    gap: 0.85rem;
    max-width: 1200px;
    margin: 0 auto;
}

.saved-library-card {
    padding: 1rem;
    border: 1px solid #d6cbe5;
    border-radius: 0.8rem;
    background: #fff;
    box-shadow: 0 2px 8px rgba(45, 26, 70, 0.08);
}

.saved-library-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.saved-library-card-heading h3 {
    margin: 0;
}

.saved-library-card-heading span {
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: #ede5f7;
    color: #4a3167;
    white-space: nowrap;
}

.saved-library-stats {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.6rem;
}

.saved-library-stats div {
    padding: 0.55rem;
    border-radius: 0.45rem;
    background: #f6f3fa;
}

.saved-library-stats dt {
    font-size: 0.8rem;
    color: #6c6274;
}

.saved-library-stats dd {
    margin: 0.15rem 0 0;
    font-weight: 700;
}

.saved-library-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.8rem;
}

.saved-library-actions button {
    width: auto;
    margin: 0;
    padding: 0.55rem 0.75rem;
}

.saved-location-group {
    padding: 0.8rem;
    border-radius: 0.8rem;
    background: rgba(109, 75, 145, 0.08);
}

.saved-location-group > h2 {
    margin-top: 0;
    color: #4b3267;
}

.saved-location-group > h2 small {
    font-weight: 400;
}

.saved-library-empty {
    padding: 1rem;
    text-align: center;
    border-radius: 0.65rem;
    background: #fff;
}

.topbar nav button {
    margin: 0;
}

.saved-content-dialog {
    width: min(94vw, 620px);
    max-height: 90vh;
    padding: 0;
    border: 0;
    border-radius: 0.85rem;
    background: #f4f1fa;
    color: inherit;
}

.saved-content-dialog::backdrop {
    background: rgba(0, 0, 0, 0.62);
}

.saved-content-dialog form {
    display: grid;
    gap: 0.8rem;
    padding: 1rem;
    overflow-y: auto;
    max-height: 86vh;
}

.saved-content-dialog h2 {
    margin: 0;
    color: #4b3267;
}

.saved-content-dialog textarea {
    width: 100%;
    resize: vertical;
}

.saved-content-dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.saved-content-dialog-actions button {
    width: auto;
    margin: 0;
}

.saved-content-photo-preview {
    display: grid;
    gap: 0.55rem;
    padding: 0.65rem;
    border: 1px solid #d1c4e2;
    border-radius: 0.65rem;
    background: #fff;
}

.saved-content-photo-preview img {
    display: block;
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    border-radius: 0.45rem;
}

.saved-content-photo-preview[hidden] {
    display: none !important;
}

.saved-library-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    max-width: 1200px;
    margin: 0 auto 1rem;
}

.saved-library-toolbar button {
    width: auto;
    margin: 0;
}

.saved-detail-dialog {
    width: min(94vw, 760px);
}

.saved-detail-dialog article {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    max-height: 88vh;
    overflow-y: auto;
}

.saved-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.saved-detail-header h2 {
    margin: 0;
}

.saved-detail-header button {
    width: auto;
    flex-shrink: 0;
}

.saved-detail-type {
    margin: 0 0 0.2rem;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #6d4b91;
}

.saved-detail-photo[hidden] {
    display: none !important;
}

.saved-detail-photo img {
    display: block;
    width: 100%;
    max-height: 480px;
    object-fit: contain;
    border-radius: 0.7rem;
    background: #fff;
}

.saved-detail-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.7rem;
    margin: 0;
}

.saved-detail-grid > div {
    padding: 0.75rem;
    border-radius: 0.55rem;
    background: #fff;
    border: 1px solid #ded4ea;
}

.saved-detail-grid dt {
    margin-bottom: 0.2rem;
    color: #6c6274;
    font-size: 0.82rem;
}

.saved-detail-grid dd {
    margin: 0;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.saved-detail-notes {
    padding: 0.85rem;
    border-radius: 0.6rem;
    background: #fff;
    border: 1px solid #ded4ea;
}

.saved-detail-notes h3 {
    margin-top: 0;
}

.saved-detail-notes p {
    margin-bottom: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

@media (max-width: 720px) {
    .saved-content-library {
        padding: 0.65rem;
    }

    .saved-library-header {
        align-items: stretch;
        flex-direction: column;
    }

    .saved-library-header button {
        width: 100%;
    }

    .saved-library-card-heading {
        flex-direction: column;
    }

    .saved-library-card-heading span {
        white-space: normal;
    }

    .saved-library-actions {
        display: grid;
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .saved-library-actions button {
        width: 100%;
    }

    .saved-library-toolbar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .saved-library-toolbar button {
        width: 100%;
    }

    .saved-detail-header {
        flex-direction: column;
    }

    .saved-detail-header button {
        width: 100%;
    }

    .saved-detail-grid {
        grid-template-columns: 1fr;
    }

    .saved-content-dialog {
        width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
    }

    .saved-content-dialog form,
    .saved-detail-dialog article {
        max-height: calc(100vh - 2rem);
    }
}

@media (max-width: 420px) {
    .saved-library-actions {
        grid-template-columns: 1fr;
    }
}

.explorer-dialog {
    width: min(96vw, 1100px);
    max-height: 94vh;
    padding: 0;
    border: 0;
    border-radius: 0.9rem;
    background: #f4f1fa;
    color: inherit;
}

.explorer-dialog::backdrop {
    background: rgba(0, 0, 0, 0.68);
}

.explorer-shell {
    display: grid;
    gap: 1rem;
    max-height: 92vh;
    padding: 1rem;
    overflow-y: auto;
}

.explorer-header,
.explorer-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.explorer-header h2,
.explorer-section-header h3 {
    margin: 0;
}

.explorer-header button,
.explorer-section-header button {
    width: auto;
}

.explorer-eyebrow,
#explorerCatalogueCountry,
#explorerDetailCategory {
    margin: 0 0 0.2rem;
    color: #6d4b91;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.explorer-status {
    min-height: 1.3rem;
    margin: 0;
}

.explorer-country-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(270px, 1fr));
    gap: 1rem;
}

.explorer-country-card {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid #d7cce5;
    border-radius: 0.8rem;
    background: #fff;
}

.explorer-country-card h3,
.explorer-country-card p {
    margin: 0;
}

.explorer-country-card progress {
    width: 100%;
}

.explorer-category-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

.explorer-category-grid button {
    display: grid;
    gap: 0.15rem;
    text-align: left;
}

.explorer-filters {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(150px, 1fr));
    gap: 0.65rem;
}

.explorer-search-label {
    grid-column: 1 / -1;
}

.explorer-results {
    display: grid;
    gap: 0.5rem;
}

.explorer-result-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.55rem;
    align-items: stretch;
    padding: 0.55rem;
    border: 1px solid #d7cce5;
    border-radius: 0.65rem;
    background: #fff;
}

.explorer-result-main {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.7rem;
    align-items: center;
    width: 100%;
    text-align: left;
    background: transparent;
    color: inherit;
    border: 0;
}

.explorer-result-main small {
    display: block;
    margin-top: 0.2rem;
    color: #665e6e;
}

.explorer-completion-mark {
    display: grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    border: 2px solid currentColor;
    border-radius: 50%;
    font-weight: 800;
}

.explorer-empty {
    padding: 1rem;
    border-radius: 0.65rem;
    background: #fff;
}

.explorer-detail-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.65rem;
    margin: 0 0 1rem;
}

.explorer-detail-grid > div {
    padding: 0.7rem;
    border: 1px solid #d7cce5;
    border-radius: 0.6rem;
    background: #fff;
}

.explorer-detail-grid dt {
    margin-bottom: 0.2rem;
    color: #685f70;
    font-size: 0.82rem;
}

.explorer-detail-grid dd {
    margin: 0;
    font-weight: 650;
    overflow-wrap: anywhere;
}

#explorerProgressForm {
    display: grid;
    gap: 0.75rem;
}

.explorer-completed-label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.75rem;
    border-radius: 0.6rem;
    background: #fff;
}

.explorer-completed-label input {
    width: auto;
}

.explorer-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.explorer-detail-actions button {
    width: auto;
}

@media (max-width: 760px) {
    .explorer-dialog {
        width: calc(100vw - 0.5rem);
        max-height: calc(100vh - 0.5rem);
    }

    .explorer-shell {
        max-height: calc(100vh - 1rem);
        padding: 0.7rem;
    }

    .explorer-header,
    .explorer-section-header {
        flex-direction: column;
    }

    .explorer-header button,
    .explorer-section-header button {
        width: 100%;
    }

    .explorer-filters {
        grid-template-columns: 1fr;
    }

    .explorer-search-label {
        grid-column: auto;
    }

    .explorer-result-row {
        grid-template-columns: 1fr;
    }

    .explorer-result-row > button {
        width: 100%;
    }

    .explorer-detail-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .explorer-detail-actions button {
        width: 100%;
    }
}

@media (max-width: 460px) {
    .explorer-country-grid,
    .explorer-category-grid,
    .explorer-detail-grid {
        grid-template-columns: 1fr;
    }
}

.explorer-country-choice {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid #d7cce5;
    border-radius: 0.8rem;
    background: #fff;
}

.explorer-country-choice h3,
.explorer-country-choice p {
    margin: 0;
}

.explorer-country-choice-buttons {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.explorer-country-choice-buttons button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    min-height: 4.5rem;
    text-align: left;
    background: #f5f1fa;
    color: inherit;
    border: 2px solid transparent;
}

.explorer-country-choice-buttons button.is-selected,
.explorer-country-choice-buttons button[aria-pressed="true"] {
    border-color: #65418a;
    background: #ece2f6;
    box-shadow: 0 0 0 2px rgba(101, 65, 138, 0.15);
}

.explorer-country-flag {
    font-size: 2rem;
    line-height: 1;
}

.explorer-country-heading {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
}

.explorer-country-card-flag {
    font-size: 2.4rem;
    line-height: 1;
}

@media (max-width: 460px) {
    .explorer-country-choice-buttons {
        grid-template-columns: 1fr;
    }
}

.explorer-completion-state {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.8rem;
    align-items: center;
    padding: 0.9rem;
    margin-bottom: 1rem;
    border: 2px solid;
    border-radius: 0.75rem;
    transition:
        background-color 160ms ease,
        border-color 160ms ease;
}

.explorer-completion-state.is-outstanding {
    border-color: #8b7e98;
    background: #f4f1f7;
}

.explorer-completion-state.is-completed {
    border-color: #287a49;
    background: #e8f7ee;
}

.explorer-completion-state-icon {
    display: grid;
    place-items: center;
    width: 2.8rem;
    height: 2.8rem;
    border: 2px solid currentColor;
    border-radius: 50%;
    font-size: 1.45rem;
    font-weight: 800;
}

.explorer-completion-state.is-outstanding
.explorer-completion-state-icon {
    color: #655d6d;
}

.explorer-completion-state.is-completed
.explorer-completion-state-icon {
    color: #1f6c3d;
}

.explorer-completion-state strong {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 1.08rem;
}

.explorer-completion-state p {
    margin: 0;
}

.explorer-save-confirmation {
    margin-bottom: 1rem;
    padding: 0.8rem;
    border: 1px solid #287a49;
    border-radius: 0.65rem;
    background: #e8f7ee;
    color: #174d2d;
    font-weight: 700;
}

.explorer-save-confirmation[hidden] {
    display: none !important;
}

#explorerSaveProgress:disabled {
    cursor: wait;
    opacity: 0.72;
}

@media (max-width: 460px) {
    .explorer-completion-state {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .explorer-completion-state-icon {
        margin: 0 auto;
    }
}

.explorer-home-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 1rem;
}

.explorer-home-actions button {
    width: auto;
}

@media (max-width: 600px) {
    .explorer-home-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .explorer-home-actions button {
        width: 100%;
    }
}

.explorer-photo-section {
    display: grid;
    gap: 0.75rem;
    padding: 0.85rem;
    border: 1px solid #d7cce5;
    border-radius: 0.7rem;
    background: #fff;
}

.explorer-photo-section h4,
.explorer-photo-section p {
    margin: 0;
}

.explorer-photo-help {
    color: #665e6e;
    font-size: 0.85rem;
}

.explorer-photo-gallery {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.7rem;
}

.explorer-photo-card {
    display: grid;
    gap: 0.45rem;
    margin: 0;
    padding: 0.55rem;
    border: 1px solid #d7cce5;
    border-radius: 0.6rem;
    background: #f8f6fb;
}

.explorer-photo-card img {
    display: block;
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 0.45rem;
    background: #eee;
}

.explorer-photo-card figcaption {
    overflow-wrap: anywhere;
    font-size: 0.85rem;
}

.explorer-photo-card button {
    width: 100%;
}

@media (max-width: 520px) {
    .explorer-photo-gallery {
        grid-template-columns: 1fr;
    }

    .explorer-photo-card img {
        height: auto;
        max-height: 380px;
        object-fit: contain;
    }
}

.explorer-personal-section {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid #d7cce5;
    border-radius: 0.8rem;
    background: #fff;
}

.explorer-personal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.explorer-personal-header h3,
.explorer-personal-header p {
    margin: 0;
}

.explorer-personal-header button {
    width: auto;
}

.explorer-personal-archive-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.explorer-personal-archive-toggle input {
    width: auto;
}

.explorer-personal-list {
    display: grid;
    gap: 0.65rem;
}

.explorer-personal-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.8rem;
    padding: 0.8rem;
    border: 1px solid #d7cce5;
    border-radius: 0.65rem;
    background: #f8f6fb;
}

.explorer-personal-card p {
    margin: 0.25rem 0 0;
    white-space: pre-wrap;
}

.explorer-personal-actions {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0.45rem;
}

.explorer-personal-actions button {
    width: auto;
}

@media (max-width: 700px) {
    .explorer-personal-header,
    .explorer-personal-card {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .explorer-personal-header button,
    .explorer-personal-actions button {
        width: 100%;
    }

    .explorer-personal-actions {
        display: grid;
        grid-template-columns: 1fr;
    }
}

.settings-menu-dialog {
    width: min(92vw, 680px);
    max-height: 88vh;
    padding: 0;
    border: 0;
    border-radius: 0.9rem;
    box-shadow:
        0 20px 60px rgba(20, 15, 25, 0.35);
}

.settings-menu-dialog::backdrop {
    background: rgba(15, 12, 18, 0.55);
}

.settings-menu-shell {
    display: grid;
    gap: 1rem;
    max-height: 88vh;
    padding: 1rem;
    overflow-y: auto;
    background: #f8f6fb;
}

.settings-menu-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.settings-menu-header h2,
.settings-menu-header p {
    margin: 0;
}

.settings-menu-eyebrow {
    color: #6b5d76;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.settings-menu-header button {
    width: auto;
}

.settings-menu-section {
    display: grid;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid #d7cce5;
    border-radius: 0.75rem;
    background: #fff;
}

.settings-menu-section h3,
.settings-menu-section p {
    margin: 0;
}

.settings-menu-section form {
    display: grid;
    gap: 0.7rem;
}

.settings-menu-section input[type="file"] {
    width: 100%;
}

.settings-menu-section .movement-settings-panel {
    margin-top: 0.25rem;
}

@media (max-width: 600px) {
    .settings-menu-dialog {
        width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
    }

    .settings-menu-shell {
        max-height: calc(100vh - 1rem);
    }

    .settings-menu-header {
        align-items: stretch;
        flex-direction: column;
    }

    .settings-menu-header button {
        width: 100%;
    }
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.topbar {
    position: relative;
    z-index: 30;
}

.topbar-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.fieldmarks-brand {
    flex: 0 0 auto;
    white-space: nowrap;
}

.topbar-search-wrap {
    position: relative;
    flex: 1 1 420px;
    width: min(48vw, 560px);
    min-width: 190px;
    max-width: 560px;
}

.topbar-search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 0.35rem;
    margin: 0;
}

.topbar-search-form input {
    width: 100%;
    min-width: 0;
    margin: 0;
}

.header-icon-button,
.header-toggle-button {
    display: inline-grid;
    place-items: center;
    width: 2.65rem;
    min-width: 2.65rem;
    height: 2.65rem;
    min-height: 2.65rem;
    padding: 0.55rem;
    border: 1px solid #b9b3bd;
    border-radius: 0.55rem;
    background: #f2f1f3;
    color: #77717b;
    cursor: pointer;
}

.header-icon-button:hover,
.header-toggle-button:hover {
    border-color: #9d7b3a;
    background: #fff7e5;
}

.header-icon-button svg,
.header-toggle-button svg {
    display: block;
    width: 1.35rem;
    height: 1.35rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.header-toggle-button {
    position: relative;
    margin: 0;
}

.header-toggle-button input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.header-toggle-button:has(input:checked) {
    border-color: #c58a1c;
    background: #fff3d2;
    color: #b87400;
}

.header-toggle-button:focus-within {
    outline: 3px solid rgba(197, 138, 28, 0.35);
    outline-offset: 2px;
}

.topbar-map-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 0 0 auto;
}

.topbar-search-results {
    position: absolute;
    top: calc(100% + 0.35rem);
    left: 0;
    right: 0;
    z-index: 80;
    max-height: min(55vh, 420px);
    overflow-y: auto;
    padding: 0.4rem;
    border: 1px solid #cfc8d5;
    border-radius: 0.6rem;
    background: #fff;
    box-shadow:
        0 14px 35px rgba(24, 18, 29, 0.25);
}

.topbar-search-results button {
    width: 100%;
    text-align: left;
}

@media (max-width: 980px) {
    .topbar {
        align-items: stretch;
    }

    .topbar-main {
        flex-wrap: wrap;
        width: 100%;
    }

    .topbar-search-wrap {
        order: 3;
        flex-basis: 100%;
        width: 100%;
        max-width: none;
    }

    .topbar-map-controls {
        margin-left: auto;
    }
}

@media (max-width: 620px) {
    .fieldmarks-brand {
        font-size: 1rem;
    }

    .topbar-map-controls {
        gap: 0.25rem;
    }

    .header-icon-button,
    .header-toggle-button {
        width: 2.45rem;
        min-width: 2.45rem;
        height: 2.45rem;
        min-height: 2.45rem;
        padding: 0.48rem;
    }

    .topbar-search-form input {
        font-size: 16px;
    }
}

.fieldmarks-selected-popup
.maplibregl-popup-content {
    min-width: 245px;
    padding: 0.75rem;
    border-radius: 0.75rem;
    box-shadow:
        0 12px 32px rgba(25, 20, 29, 0.28);
}

.fieldmarks-selected-popup
.maplibregl-popup-close-button {
    top: 0.25rem;
    right: 0.35rem;
    width: 2rem;
    height: 2rem;
    padding: 0;
    color: #665e6e;
    font-size: 1.4rem;
    line-height: 1;
    background: transparent;
}

.selected-location-popup-menu {
    display: grid;
    gap: 0.65rem;
}

.selected-location-popup-title {
    padding-right: 1.8rem;
    color: #2f2934;
    font-size: 0.95rem;
}

.selected-location-popup-actions {
    display: grid;
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
}

.selected-popup-action {
    display: grid;
    place-items: center;
    width: 100%;
    min-width: 0;
    height: 2.75rem;
    min-height: 2.75rem;
    padding: 0.55rem;
    border: 1px solid #c8c1cd;
    border-radius: 0.55rem;
    background: #f5f3f6;
    color: #5f5864;
}

.selected-popup-action:hover,
.selected-popup-action:focus-visible {
    border-color: #c58a1c;
    background: #fff3d2;
    color: #a96900;
}

.selected-popup-action.danger:hover,
.selected-popup-action.danger:focus-visible {
    border-color: #b24242;
    background: #fff0f0;
    color: #a12f2f;
}

.selected-popup-action svg {
    display: block;
    width: 1.4rem;
    height: 1.4rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 520px) {
    .fieldmarks-selected-popup
    .maplibregl-popup-content {
        min-width: 210px;
    }

    .selected-location-popup-actions {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }
}

.selected-popup-action {
    position: relative;
}

.selected-popup-tooltip {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 50%;
    z-index: 20;
    width: max-content;
    max-width: 150px;
    padding: 0.28rem 0.45rem;
    border-radius: 0.35rem;
    background: rgba(42, 37, 46, 0.94);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform:
        translate(-50%, -0.15rem);
    transition:
        opacity 120ms ease,
        transform 120ms ease,
        visibility 120ms ease;
}

.selected-popup-tooltip::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 50%;
    border: 0.3rem solid transparent;
    border-bottom-color:
        rgba(42, 37, 46, 0.94);
    transform: translateX(-50%);
}

.selected-popup-action:hover
.selected-popup-tooltip,
.selected-popup-action:focus-visible
.selected-popup-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

.selected-location-popup-actions
.selected-popup-action:nth-child(3n + 1)
.selected-popup-tooltip {
    left: 0;
    transform:
        translate(0, -0.15rem);
}

.selected-location-popup-actions
.selected-popup-action:nth-child(3n + 1):hover
.selected-popup-tooltip,
.selected-location-popup-actions
.selected-popup-action:nth-child(3n + 1):focus-visible
.selected-popup-tooltip {
    transform: translate(0, 0);
}

.selected-location-popup-actions
.selected-popup-action:nth-child(3n)
.selected-popup-tooltip {
    right: 0;
    left: auto;
    transform:
        translate(0, -0.15rem);
}

.selected-location-popup-actions
.selected-popup-action:nth-child(3n):hover
.selected-popup-tooltip,
.selected-location-popup-actions
.selected-popup-action:nth-child(3n):focus-visible
.selected-popup-tooltip {
    transform: translate(0, 0);
}

.selected-location-popup-actions
.selected-popup-action:nth-child(3n + 1)
.selected-popup-tooltip::before {
    left: 1.25rem;
}

.selected-location-popup-actions
.selected-popup-action:nth-child(3n)
.selected-popup-tooltip::before {
    right: 1.25rem;
    left: auto;
}

.app-shell {
    position: relative;
}

.map-layer-control {
    position: absolute;
    top: clamp(10.5rem, 22vh, 15rem);
    right: 0.65rem;
    z-index: 25;
    display: grid;
    justify-items: end;
    gap: 0.4rem;
    max-height: calc(100% - 1rem);
    pointer-events: none;
}

.map-layer-toggle,
.map-layer-menu {
    pointer-events: auto;
}

.map-layer-toggle {
    display: grid;
    place-items: center;
    width: 2.55rem;
    min-width: 2.55rem;
    height: 2.55rem;
    min-height: 2.55rem;
    padding: 0.5rem;
    border: 0;
    border-radius: 0.3rem;
    background: #fff;
    color: #4d4851;
    box-shadow:
        0 1px 4px rgba(0, 0, 0, 0.28);
    cursor: pointer;
}

.map-layer-toggle:hover,
.map-layer-toggle:focus-visible,
.map-layer-toggle.active {
    background: #fff3d2;
    color: #a96900;
}

.map-layer-toggle svg {
    display: block;
    width: 1.4rem;
    height: 1.4rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.map-layer-menu {
    width: min(17rem, calc(100vw - 2rem));
    padding: 0.75rem;
    border: 1px solid #cbc4d0;
    border-radius: 0.65rem;
    background: #fff;
    box-shadow:
        0 12px 32px rgba(25, 20, 29, 0.25);
}

.map-layer-menu[hidden] {
    display: none;
}

.map-layer-menu label {
    display: block;
    margin-bottom: 0.4rem;
    color: #38323d;
    font-size: 0.82rem;
    font-weight: 700;
}

.map-layer-menu select {
    width: 100%;
    margin: 0;
}

@media (max-width: 700px) {
    .map-layer-control {
        top: clamp(11.5rem, 27vh, 16rem);
        right: 0.5rem;
    }

    .map-layer-toggle {
        width: 2.45rem;
        min-width: 2.45rem;
        height: 2.45rem;
        min-height: 2.45rem;
    }

    .map-layer-menu {
        width: min(
            17rem,
            calc(100vw - 1.5rem)
        );
        max-height: min(
            55vh,
            24rem
        );
        overflow-y: auto;
    }
}
}

@media (max-height: 700px) {
    .map-layer-control {
        top: clamp(9rem, 25vh, 11.5rem);
    }

    .map-layer-menu {
        max-height: 50vh;
        overflow-y: auto;
    }
}

@media (
    max-width: 700px
) and (
    max-height: 700px
) {
    .map-layer-control {
        top: clamp(9.5rem, 28vh, 12rem);
    }
}

/* Fine-tune floating Layers control spacing */
.map-layer-control {
    top: clamp(13.25rem, 27vh, 18rem);
}

@media (max-width: 700px) {
    .map-layer-control {
        top: clamp(14rem, 31vh, 19rem);
    }
}

@media (max-height: 700px) {
    .map-layer-control {
        top: clamp(11rem, 30vh, 14rem);
    }
}

@media (
    max-width: 700px
) and (
    max-height: 700px
) {
    .map-layer-control {
        top: clamp(11.75rem, 33vh, 14.75rem);
    }
}

.weather-current-panel {
    display: grid;
    gap: 0.65rem;
}

.weather-current-panel h3 {
    margin-bottom: 0;
}

.weather-forecast-disclosure {
    overflow: hidden;
    border: 1px solid #d3ccd8;
    border-radius: 0.65rem;
    background: #fff;
}

.weather-forecast-disclosure[hidden] {
    display: none;
}

.weather-forecast-disclosure summary {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.7rem 0.8rem;
    color: #3e3744;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.weather-forecast-disclosure summary::-webkit-details-marker {
    display: none;
}

.weather-forecast-disclosure summary::after {
    content: "▾";
    margin-left: auto;
    color: #766d7d;
    transition: transform 150ms ease;
}

.weather-forecast-disclosure[open]
summary::after {
    transform: rotate(180deg);
}

.weather-forecast-disclosure summary:hover,
.weather-forecast-disclosure summary:focus-visible {
    background: #fff5dc;
}

.weather-forecast-panel {
    padding: 0 0.75rem 0.75rem;
}

.weather-forecast-panel[hidden] {
    display: none;
}

.astronomy-panel {
    display: grid;
    gap: 0.65rem;
}

.astronomy-panel h3,
.astronomy-panel p {
    margin-bottom: 0;
}

.sun-icon-key {
    display: flex;
    gap: 0.45rem;
    font-size: 1.2rem;
}

.sun-times-decorated {
    display: grid;
    gap: 0.45rem;
}

.sun-time-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sun-time-item > span:first-child {
    flex: 0 0 auto;
    font-size: 1.15rem;
}

.lunar-phase-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem;
    border: 1px solid #d3ccd8;
    border-radius: 0.65rem;
    background:
        linear-gradient(
            135deg,
            #f8f6fb,
            #eee9f4
        );
}

.lunar-phase-result > span:last-child {
    display: grid;
    gap: 0.15rem;
}

.lunar-phase-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 2rem;
    line-height: 1;
}

#lunarPhaseText {
    color: #655d6b;
    font-size: 0.88rem;
}

@media (max-width: 520px) {
    .weather-forecast-disclosure summary {
        padding: 0.75rem;
    }

    .lunar-phase-result {
        align-items: flex-start;
    }
}

/* Sidebar top icon controls */
.sidebar-map-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    margin: 0 0 0.9rem;
    padding: 0.65rem;
    border-bottom: 1px solid #d8d1dc;
}

.sidebar-map-icon-button {
    display: grid;
    place-items: center;
    width: 2.8rem;
    min-width: 2.8rem;
    height: 2.8rem;
    min-height: 2.8rem;
    padding: 0.55rem;
    border: 1px solid #bbb5bf;
    border-radius: 0.65rem;
    background: #f2f1f3;
    color: #77717b;
}

.sidebar-map-icon-button:hover,
.sidebar-map-icon-button:focus-visible {
    border-color: #c58a1c;
    background: #fff7e5;
}

.sidebar-map-icon-button.active {
    border-color: #c58a1c;
    background: #fff3d2;
    color: #b87400;
}

.sidebar-map-icon-button:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.sidebar-map-icon-button svg {
    display: block;
    width: 1.45rem;
    height: 1.45rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.85;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.fieldmarks-original-control-hidden {
    display: none !important;
}

/* Selected-location panel */
.sidebar-selected-location-panel {
    display: grid;
    gap: 0.7rem;
    margin-bottom: 1rem;
}

.sidebar-selected-location-panel[hidden] {
    display: none;
}

.sidebar-selected-location-panel > h2 {
    margin-top: 0;
}

.sidebar-selected-actions {
    display: grid;
    gap: 0.45rem;
}

.fieldmarks-user-hidden {
    display: none !important;
}

/* Settings checkbox rows */
.settings-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
}

.settings-checkbox-row input {
    flex: 0 0 auto;
    width: auto;
    margin-top: 0.2rem;
}

/* Hide the emoji key above the sun information */
.sun-icon-key {
    display: none !important;
}

/* Replace emoji spans with reliable drawn symbols */
.sun-time-item > span:first-child {
    position: relative;
    display: inline-block;
    flex: 0 0 auto;
    width: 1.7rem;
    height: 1.35rem;
    overflow: visible;
    color: transparent;
    font-size: 0;
}

/* Sunrise: full sun sitting on a line */
.sun-time-item:first-child
> span:first-child::before {
    content: "";
    position: absolute;
    left: 0.43rem;
    top: 0.12rem;
    width: 0.75rem;
    height: 0.75rem;
    border: 2px solid #c47d00;
    border-radius: 50%;
    background: #ffc84d;
}

.sun-time-item:first-child
> span:first-child::after {
    content: "";
    position: absolute;
    left: 0.08rem;
    right: 0.08rem;
    bottom: 0.1rem;
    height: 2px;
    background: #87694a;
}

/* Sunset: half sun sitting on a line */
.sun-time-item:nth-child(2)
> span:first-child::before {
    content: "";
    position: absolute;
    left: 0.43rem;
    bottom: 0.1rem;
    width: 0.75rem;
    height: 0.38rem;
    border: 2px solid #c47d00;
    border-bottom: 0;
    border-radius:
        0.75rem 0.75rem 0 0;
    background: #ffc84d;
}

.sun-time-item:nth-child(2)
> span:first-child::after {
    content: "";
    position: absolute;
    left: 0.08rem;
    right: 0.08rem;
    bottom: 0.08rem;
    height: 2px;
    background: #87694a;
}

@media (max-width: 600px) {
    .sidebar-map-toolbar {
        position: sticky;
        top: 0;
        z-index: 5;
        background: inherit;
    }

    .sidebar-map-icon-button {
        width: 3rem;
        min-width: 3rem;
        height: 3rem;
        min-height: 3rem;
    }
}

html.fieldmarks-measuring
.fieldmarks-selected-popup {
    display: none !important;
}

/* Measurement result directly below icon row */
.sidebar-measurement-panel {
    display: grid;
    gap: 0.35rem;
    margin: -0.35rem 0 0.9rem;
    padding: 0.7rem 0.8rem;
    border: 1px solid #d3a21f;
    border-radius: 0.6rem;
    background: #fff3a8;
    color: #ad2525;
}

.sidebar-measurement-panel[hidden] {
    display: none;
}

.sidebar-measurement-panel p {
    margin: 0;
}

.measurement-distance-result {
    color: #a92121 !important;
    font-weight: 800;
}

.measurement-point-info {
    color: #a92121;
    font-size: 0.82rem;
    font-weight: 600;
}

/* Settings units */
.settings-distance-unit-row {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.8rem;
}

.settings-distance-unit-row > span {
    font-weight: 700;
}

.settings-distance-unit-row select {
    width: 100%;
}

/* Shared framed sidebar panels */
.sidebar-framed-panel,
.sidebar-selected-location-panel,
.weather-current-panel,
.astronomy-panel {
    overflow: hidden;
    border: 1px solid #cbc6ce;
    border-radius: 0.65rem;
    background: #fff;
}

.sidebar-framed-panel {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 1rem;
    padding: 0 0.75rem 0.75rem;
}

.sidebar-selected-location-panel {
    gap: 0.7rem;
    padding: 0 0.75rem 0.75rem;
}

.weather-current-panel,
.astronomy-panel {
    gap: 0.65rem;
    padding: 0 0.7rem 0.7rem;
}

/* Grey title bars */
.sidebar-framed-panel > h2,
.sidebar-selected-location-panel > h2,
.weather-current-panel > h3,
.astronomy-panel > h3 {
    margin:
        0 -0.75rem 0.15rem;
    padding: 0.62rem 0.75rem;
    border-bottom: 1px solid #cbc6ce;
    background: #e8e7e9;
    color: #39343c;
    font-size: 1rem;
    line-height: 1.25;
}

.weather-current-panel > h3,
.astronomy-panel > h3 {
    margin-left: -0.7rem;
    margin-right: -0.7rem;
    padding-left: 0.7rem;
    padding-right: 0.7rem;
}

/* Sunrise and sunset cards */
.sun-times-result {
    margin: 0;
}

.sun-times-decorated {
    display: grid;
    gap: 0.55rem;
}

.sun-time-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 3.2rem;
    padding: 0.65rem 0.7rem;
    border: 1px solid #d3ccd8;
    border-radius: 0.65rem;
    background:
        linear-gradient(
            135deg,
            #f8f6fb,
            #eee9f4
        );
}

/* Match route-planner framed appearance */
#routePlannerPanel {
    border: 1px solid #cbc6ce;
    border-radius: 0.65rem;
}

#sidebarMapDataPanel[hidden],
.sidebar-framed-panel[hidden] {
    display: none;
}

@media (max-width: 600px) {
    .sidebar-measurement-panel {
        margin-top: -0.25rem;
    }
}

/* Four centred map-action icons */
.sidebar-map-toolbar {
    flex-wrap: wrap;
}

/* Measurement close button */
.sidebar-measurement-panel {
    position: relative;
    padding-right: 2.5rem;
}

.measurement-panel-close {
    position: absolute;
    top: 0.28rem;
    right: 0.35rem;
    display: grid;
    place-items: center;
    width: 1.75rem;
    min-width: 1.75rem;
    height: 1.75rem;
    min-height: 1.75rem;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #b11f27;
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1;
}

.measurement-panel-close:hover,
.measurement-panel-close:focus-visible {
    background: rgba(177, 31, 39, 0.12);
    color: #86151b;
}

/* Route Planner displayed below toolbar */
.sidebar-route-planner-panel {
    display: grid;
    gap: 0.65rem;
    margin: -0.35rem 0 0.9rem;
    padding: 0.75rem;
    border: 1px solid #cbc6ce;
    border-radius: 0.65rem;
    background: #fff;
}

.sidebar-route-planner-panel[hidden] {
    display: none;
}

.sidebar-route-planner-panel
#routePlannerControls {
    display: grid;
    gap: 0.6rem;
}

.sidebar-route-planner-panel
#routePlannerControls[hidden] {
    display: none;
}

/* Your Map Data contents */
#sidebarMapDataPanel
.map-data-subheading {
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #554f58;
    font-size: 0.9rem;
}

#sidebarMapDataPanel > p,
#sidebarMapDataPanel > label {
    margin: 0;
}

#sidebarMapDataPanel
.fieldmarks-original-control-hidden {
    display: none !important;
}

@media (max-width: 420px) {
    .sidebar-map-toolbar {
        gap: 0.45rem;
    }

    .sidebar-map-icon-button {
        width: 2.75rem;
        min-width: 2.75rem;
        height: 2.75rem;
        min-height: 2.75rem;
    }
}

/* Keep every Route Planner control inside its panel */
.sidebar-route-planner-panel,
.sidebar-route-planner-panel *,
.sidebar-route-planner-panel *::before,
.sidebar-route-planner-panel *::after {
    box-sizing: border-box;
}

.sidebar-route-planner-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.sidebar-route-planner-panel
#routePlannerControls {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.sidebar-route-planner-panel label {
    display: grid;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    gap: 0.35rem;
}

.sidebar-route-planner-panel input,
.sidebar-route-planner-panel select,
.sidebar-route-planner-panel textarea,
.sidebar-route-planner-panel button {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin-right: 0;
    margin-left: 0;
}

.sidebar-route-planner-panel input[type="file"] {
    overflow: hidden;
    font-size: 0.82rem;
}

.sidebar-route-planner-panel textarea {
    resize: vertical;
    overflow-wrap: anywhere;
}

.sidebar-route-planner-panel
.route-planner-summary {
    width: 100%;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.sidebar-route-planner-panel
.saved-content-photo-preview {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.sidebar-route-planner-panel
.saved-content-photo-preview img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
}

@media (max-width: 600px) {
    .sidebar-route-planner-panel {
        padding: 0.65rem;
    }
}

/* Hide the old unstyled status paragraph */
.fieldmarks-status-source-hidden {
    display: none !important;
}

/* Configurable FieldMarks status notification */
.fieldmarks-status-toast {
    position: absolute;
    z-index: 80;
    width: max-content;
    max-width:
        min(34rem, calc(100% - 2rem));
    padding: 0.55rem 0.85rem;
    border: 1px solid
        rgba(115, 96, 38, 0.42);
    border-radius: 0.55rem;
    background:
        rgba(255, 249, 218, 0.96);
    color: #6f2727;
    box-shadow:
        0 5px 18px
        rgba(30, 24, 34, 0.2);
    font-size: 0.84rem;
    font-weight: 650;
    line-height: 1.35;
    text-align: center;
    overflow-wrap: anywhere;
    pointer-events: none;
    opacity: 0;
    transform:
        translate(-50%, -0.35rem);
    transition:
        opacity 160ms ease,
        transform 160ms ease;
}

.fieldmarks-status-toast[hidden] {
    display: none;
}

.fieldmarks-status-toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.fieldmarks-status-toast.position-top {
    top: 1rem;
    left: 50%;
}

.fieldmarks-status-toast.position-middle {
    top: 50%;
    left: 50%;
    transform:
        translate(-50%, calc(-50% - 0.35rem));
}

.fieldmarks-status-toast.position-middle.visible {
    transform: translate(-50%, -50%);
}

.fieldmarks-status-toast.position-bottom {
    bottom: 1rem;
    left: 50%;
}

.fieldmarks-status-toast.position-sidebar {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    left: 50%;
    width: calc(100% - 1rem);
    max-width: none;
    margin: 0.75rem 0 0.25rem;
}

.fieldmarks-status-toast.position-sidebar.visible {
    transform: translate(-50%, 0);
}

/* Settings subsection */
.settings-subsection {
    display: grid;
    gap: 0.7rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid #d4ced7;
}

.settings-subsection h3 {
    margin: 0;
}

.settings-subsection label {
    display: grid;
    gap: 0.35rem;
}

.settings-subsection select {
    width: 100%;
    max-width: 100%;
}

@media (max-width: 600px) {
    .fieldmarks-status-toast {
        max-width: calc(100% - 1rem);
        font-size: 0.8rem;
    }

    .fieldmarks-status-toast.position-top {
        top: 0.6rem;
    }

    .fieldmarks-status-toast.position-bottom {
        bottom: 0.6rem;
    }
}

.app-shell {
    position: relative;
}

#map {
    position: relative;
}

/* Selected-location MWIS card */
.selected-location-mwis {
    display: grid;
    gap: 0.6rem;
    margin-top: 0.7rem;
    padding: 0.7rem;
    border: 1px solid #c9c4cc;
    border-radius: 0.65rem;
    background:
        linear-gradient(
            135deg,
            #f4f3f5,
            #e9e7eb
        );
}

.selected-location-mwis[hidden] {
    display: none;
}

.selected-location-mwis-heading {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.selected-location-mwis-icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: #fff3d2;
    color: #a86800;
}

.selected-location-mwis-icon svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.selected-location-mwis p {
    margin: 0;
}

.selected-location-mwis button {
    width: 100%;
    max-width: 100%;
}

.selected-location-mwis-notice {
    color: #655e68;
    font-size: 0.76rem;
    line-height: 1.4;
}

/* Popup MWIS icon */
#selectedPopupMwis {
    color: #a86800;
}

/* MWIS Settings */
.mwis-settings-section {
    display: grid;
    gap: 0.8rem;
}

.mwis-settings-section > h3 {
    margin-bottom: 0;
}

.mwis-settings-notice {
    padding: 0.65rem;
    border: 1px solid #d7c77b;
    border-radius: 0.55rem;
    background: #fff8d9;
}

.mwis-settings-fields {
    display: grid;
    gap: 0.85rem;
}

.mwis-settings-region {
    display: grid;
    gap: 0.35rem;
    padding: 0.65rem;
    border: 1px solid #d3ced6;
    border-radius: 0.55rem;
    background: #f8f7f9;
}

.mwis-settings-region > span:first-child {
    display: grid;
    gap: 0.1rem;
}

.mwis-settings-region input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.mwis-settings-region input.invalid {
    border-color: #b2222c;
    outline:
        2px solid rgba(178, 34, 44, 0.17);
}

.mwis-settings-region small {
    overflow-wrap: anywhere;
}

.mwis-default-url {
    color: #706873;
}

.mwis-url-error {
    color: #a51e27;
    font-weight: 700;
}

.mwis-settings-actions {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        minmax(0, 1fr);
    gap: 0.6rem;
}

.mwis-settings-actions button {
    width: 100%;
    max-width: 100%;
}

@media (max-width: 600px) {
    .mwis-settings-actions {
        grid-template-columns: 1fr;
    }

    .mwis-settings-region {
        padding: 0.55rem;
    }
}

/* Stable external-link action in selected marker popup */
.selected-popup-external-link {
    display: grid;
    place-items: center;
    box-sizing: border-box;
    text-decoration: none;
    cursor: pointer;
}

.selected-popup-external-link:visited {
    color: inherit;
}

.selected-popup-external-link:hover,
.selected-popup-external-link:focus-visible {
    text-decoration: none;
}

/* MWIS is now a native popup button */
#selectedPopupMwis {
    display: grid;
    place-items: center;
    cursor: pointer;
}

#selectedPopupMwis svg {
    pointer-events: none;
}

#selectedPopupMwis
.selected-popup-tooltip {
    pointer-events: none;
}

/* Collapsible FieldMarks sidebar */
.sidebar {
    transition:
        width 220ms ease,
        min-width 220ms ease,
        max-width 220ms ease,
        flex-basis 220ms ease,
        padding 220ms ease,
        opacity 160ms ease;
}

/* Arrow attached to the outside edge of the menu */
.fieldmarks-sidebar-toggle {
    position: fixed;
    z-index: 110;
    display: grid;
    place-items: center;
    width: 2rem;
    min-width: 2rem;
    height: 2.75rem;
    min-height: 2.75rem;
    margin: 0;
    padding: 0;
    border: 1px solid #bcb6c0;
    border-left-width: 0;
    border-radius: 0 0.55rem 0.55rem 0;
    background: rgba(255, 255, 255, 0.97);
    color: #504a53;
    box-shadow:
        3px 2px 9px
        rgba(31, 27, 34, 0.16);
    cursor: pointer;
    transition:
        left 220ms ease,
        background 120ms ease,
        color 120ms ease;
}

.fieldmarks-sidebar-toggle:hover,
.fieldmarks-sidebar-toggle:focus-visible {
    background: #f0edf2;
    color: #251f28;
}

.fieldmarks-sidebar-toggle svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

/*
 * Collapse the sidebar completely so the map expands
 * into the space previously occupied by the menu.
 */
body.fieldmarks-sidebar-is-collapsed
.sidebar {
    flex: 0 0 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border-width: 0 !important;
    overflow: hidden !important;
    opacity: 0;
    pointer-events: none;
}

/*
 * Support layouts where app-shell uses a two-column
 * CSS grid rather than flexbox.
 */
body.fieldmarks-sidebar-is-collapsed
.app-shell {
    grid-template-columns:
        0 minmax(0, 1fr) !important;
}

/* Top toolbar remains visible over the map */
#sidebarMapToolbar.fieldmarks-floating-toolbar {
    position: fixed !important;
    z-index: 105;
    top:
        var(
            --fieldmarks-floating-toolbar-top,
            5rem
        ) !important;
    left:
        var(
            --fieldmarks-floating-toolbar-left,
            0.75rem
        ) !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    width: max-content !important;
    max-width: calc(100vw - 4rem) !important;
    margin: 0 !important;
    padding: 0.4rem !important;
    border: 1px solid
        rgba(132, 124, 136, 0.6);
    border-radius: 0.7rem;
    background:
        rgba(255, 255, 255, 0.96);
    box-shadow:
        0 5px 18px
        rgba(29, 25, 32, 0.2);
    opacity: 1 !important;
    pointer-events: auto !important;
    overflow-x: auto;
    overscroll-behavior: contain;
}

/*
 * Keep the floating icon controls at their original
 * compact size rather than stretching across the map.
 */
#sidebarMapToolbar.fieldmarks-floating-toolbar
button,
#sidebarMapToolbar.fieldmarks-floating-toolbar
a {
    flex: 0 0 auto;
}

/* Prevent the map canvas being covered by stale widths */
body.fieldmarks-sidebar-is-collapsed
#map {
    width: 100% !important;
}

/* Mobile positioning */
@media (max-width: 700px) {
    #sidebarMapToolbar.fieldmarks-floating-toolbar {
        top: 0.55rem !important;
        left: 0.55rem !important;
        max-width: calc(100vw - 3.7rem) !important;
    }

    .fieldmarks-sidebar-toggle {
        width: 1.85rem;
        min-width: 1.85rem;
        height: 2.55rem;
        min-height: 2.55rem;
    }
}

/* Compact place-search control */
header input[type="search"],
.app-header input[type="search"],
.top-bar input[type="search"],
#placeSearch,
#placeSearchInput,
#locationSearch,
#searchPlace {
    box-sizing: border-box;
    width: clamp(9rem, 18vw, 15rem);
    max-width: 15rem;
    height: 2rem;
    min-height: 2rem;
    padding: 0.22rem 0.65rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.15;
}

/*
 * Also reduce the surrounding form where the search
 * field is placed inside a wider flex container.
 */
header form:has(input[type="search"]),
.app-header form:has(input[type="search"]),
.top-bar form:has(input[type="search"]) {
    flex: 0 1 15rem;
    width: auto;
    max-width: 15rem;
    min-width: 9rem;
}

/* Keep the search button compact if one is present */
header form:has(input[type="search"]) button,
.app-header form:has(input[type="search"]) button,
.top-bar form:has(input[type="search"]) button {
    min-height: 2rem;
    height: 2rem;
    padding-top: 0.2rem;
    padding-bottom: 0.2rem;
}

/* Compact icon-only header controls */
.fieldmarks-header-icon-button {
    position: relative;
    display: inline-grid !important;
    place-items: center;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: 2.5rem !important;
    min-width: 2.5rem !important;
    max-width: 2.5rem !important;
    height: 2.5rem !important;
    min-height: 2.5rem !important;
    max-height: 2.5rem !important;
    padding: 0.45rem !important;
    overflow: visible;
}

.fieldmarks-header-icon-button > svg {
    display: block;
    width: 1.45rem;
    height: 1.45rem;
    flex: none;
    fill: currentColor;
    stroke: none;
    pointer-events: none;
}

/* Outlined system icons */
.fieldmarks-settings-icon > svg,
.fieldmarks-map-refresh-icon > svg,
.fieldmarks-sign-out-icon > svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Filled supplied route/location icons */
.fieldmarks-my-routes-icon > svg,
.fieldmarks-my-locations-icon > svg {
    fill: currentColor;
    stroke: none;
}

/* Accessible hover labels */
.fieldmarks-header-tooltip {
    position: absolute;
    z-index: 160;
    top: calc(100% + 0.45rem);
    left: 50%;
    width: max-content;
    max-width: 14rem;
    padding: 0.3rem 0.48rem;
    border-radius: 0.35rem;
    background: rgba(30, 27, 32, 0.96);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform:
        translate(-50%, -0.2rem);
    transition:
        opacity 120ms ease,
        transform 120ms ease,
        visibility 120ms ease;
}

.fieldmarks-header-icon-button:hover
.fieldmarks-header-tooltip,
.fieldmarks-header-icon-button:focus-visible
.fieldmarks-header-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

@media (max-width: 700px) {
    header input[type="search"],
    .app-header input[type="search"],
    .top-bar input[type="search"],
    #placeSearch,
    #placeSearchInput,
    #locationSearch,
    #searchPlace {
        width: clamp(7rem, 34vw, 11rem);
        max-width: 11rem;
    }

    header form:has(input[type="search"]),
    .app-header form:has(input[type="search"]),
    .top-bar form:has(input[type="search"]) {
        flex-basis: 11rem;
        max-width: 11rem;
        min-width: 7rem;
    }

    .fieldmarks-header-icon-button {
        width: 2.35rem !important;
        min-width: 2.35rem !important;
        max-width: 2.35rem !important;
        height: 2.35rem !important;
        min-height: 2.35rem !important;
        max-height: 2.35rem !important;
        padding: 0.42rem !important;
    }

    .fieldmarks-header-icon-button > svg {
        width: 1.35rem;
        height: 1.35rem;
    }
}

/* Allow centred search and visible tooltips */
header,
.app-header,
.top-bar {
    position: relative;
    overflow: visible !important;
}

/*
 * Centre the complete search form relative to the
 * header, independently of the logo and right controls.
 */
header form:has(input[type="search"]),
.app-header form:has(input[type="search"]),
.top-bar form:has(input[type="search"]) {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 4;
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap !important;
    gap: 0.35rem;
    width: min(24rem, 38vw);
    max-width: min(24rem, 38vw);
    min-width: 13rem;
    margin: 0 !important;
    transform: translate(-50%, -50%);
}

/* Thinner and shorter search field */
header form:has(input[type="search"])
input[type="search"],
.app-header form:has(input[type="search"])
input[type="search"],
.top-bar form:has(input[type="search"])
input[type="search"] {
    flex: 1 1 auto;
    box-sizing: border-box;
    width: auto !important;
    min-width: 0;
    max-width: none !important;
    height: 1.95rem !important;
    min-height: 1.95rem !important;
    margin: 0 !important;
    padding: 0.2rem 0.62rem !important;
    font-size: 0.84rem;
    line-height: 1.1;
}

/* Search submit remains directly alongside the input */
header form:has(input[type="search"])
button[type="submit"],
.app-header form:has(input[type="search"])
button[type="submit"],
.top-bar form:has(input[type="search"])
button[type="submit"] {
    display: inline-grid !important;
    place-items: center;
    flex: 0 0 auto;
    box-sizing: border-box;
    width: auto !important;
    min-width: 4rem;
    height: 1.95rem !important;
    min-height: 1.95rem !important;
    margin: 0 !important;
    padding: 0.2rem 0.65rem !important;
    white-space: nowrap;
}

/* Reliable header hover labels */
.fieldmarks-header-icon-button {
    position: relative;
    overflow: visible !important;
}

.fieldmarks-header-icon-button::after {
    content:
        attr(data-fieldmarks-tooltip);
    position: absolute;
    z-index: 500;
    top: calc(100% + 0.42rem);
    left: 50%;
    width: max-content;
    max-width: 14rem;
    padding: 0.32rem 0.5rem;
    border-radius: 0.35rem;
    background: rgba(30, 27, 32, 0.97);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 650;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform:
        translate(-50%, -0.2rem);
    transition:
        opacity 120ms ease,
        transform 120ms ease,
        visibility 120ms ease;
}

.fieldmarks-header-icon-button:hover::after,
.fieldmarks-header-icon-button:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

/* Remove the earlier nested tooltip */
.fieldmarks-header-tooltip {
    display: none !important;
}

/* Explorer is an outlined icon */
.fieldmarks-explorer-icon > svg {
    fill: none !important;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Improved cog treatment */
.fieldmarks-settings-icon-v2 > svg {
    fill: none !important;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/*
 * On narrower screens, keep the search in the header
 * flow so it cannot overlap the logo or control icons.
 */
@media (max-width: 900px) {
    header form:has(input[type="search"]),
    .app-header form:has(input[type="search"]),
    .top-bar form:has(input[type="search"]) {
        position: static;
        width: min(19rem, 42vw);
        max-width: min(19rem, 42vw);
        min-width: 10rem;
        transform: none;
    }
}

@media (max-width: 650px) {
    header form:has(input[type="search"]),
    .app-header form:has(input[type="search"]),
    .top-bar form:has(input[type="search"]) {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        order: 20;
    }
}

/*
 * JavaScript controls normal visibility, while hidden
 * ensures the arrow can never remain as a floating
 * control over Routes, Locations or Explorer.
 */
#fieldmarksSidebarToggle[hidden] {
    display: none !important;
}

/*
 * This overrides inline display values and hidden-state
 * changes made by the existing sidebar functions.
 */
body.fieldmarks-non-map-screen
#fieldmarksSidebarToggle {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Sun, Moon and Tides panel */
.tide-information-panel {
    margin-top: 0.9rem;
    padding-top: 0.9rem;
    border-top: 1px solid
        rgba(110, 103, 115, 0.3);
}

.tide-information-panel h4 {
    margin:
        0 0 0.55rem;
    font-size: 0.98rem;
}

.tide-information-result {
    margin: 0;
    padding: 0.65rem;
    border-radius: 0.55rem;
    background:
        rgba(229, 238, 246, 0.65);
}

.tide-information-result p {
    margin:
        0 0 0.42rem;
}

.tide-information-result p:last-child {
    margin-bottom: 0;
}

.tide-information-result.loading {
    opacity: 0.78;
}

.tide-information-result.tide-not-near-coast {
    font-weight: 650;
    text-align: center;
    background:
        rgba(235, 235, 235, 0.72);
}

.tide-information-result.error {
    background:
        rgba(255, 232, 226, 0.82);
}

.tide-navigation-warning {
    margin:
        0.65rem 0 0;
    padding:
        0.5rem 0.6rem;
    border-left:
        4px solid #b64235;
    background:
        rgba(255, 232, 226, 0.76);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.35;
}

.tide-limitations {
    margin-top: 0.55rem;
    font-size: 0.78rem;
}

.tide-limitations summary {
    cursor: pointer;
    font-weight: 650;
}

.tide-limitations p {
    margin:
        0.45rem 0 0;
    line-height: 1.4;
}

/* Tide distance Settings */
.tide-distance-settings {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid
        rgba(110, 103, 115, 0.28);
}

.tide-distance-settings h4 {
    margin:
        0 0 0.65rem;
}

.tide-distance-setting-control {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.7rem;
    margin-top: 0.45rem;
}

#tideCoastDistanceSetting {
    width: 100%;
}

#tideCoastDistanceValue {
    min-width: 4.8rem;
    padding:
        0.25rem 0.4rem;
    border-radius: 0.35rem;
    background:
        rgba(230, 230, 230, 0.8);
    font-weight: 700;
    text-align: center;
}

.tide-information-panel {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(127, 127, 127, 0.35);
}

.tide-information-panel h4 {
    margin: 0 0 0.45rem;
}

.tide-information-result {
    margin-bottom: 0.45rem;
}

.tide-information-warning {
    margin-bottom: 0;
}

.tide-information-result {
    white-space: pre-line;
    line-height: 1.55;
}

/*
 * Responsive FieldMarks top bar.
 *
 * Keep all existing controls and functionality while
 * allowing the header to reflow before controls overlap.
 */

.topbar,
.topbar-main,
.topbar nav,
.topbar-search-wrap,
.topbar-search-form,
.topbar-map-controls {
    box-sizing: border-box;
}

.topbar-main {
    min-width: 0;
}

.topbar-search-wrap {
    min-width: 0;
}

.topbar-map-controls {
    flex: 0 0 auto;
}

.topbar nav {
    min-width: 0;
}

/*
 * Move the search form back into the normal flex layout
 * before the absolutely-centred version can collide with
 * controls on either side.
 */
@media (max-width: 1100px) {
    .topbar {
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center;
        gap: 0.45rem 0.7rem;
    }

    .topbar-main {
        display: flex !important;
        flex: 1 1 100%;
        align-items: center;
        gap: 0.55rem;
        width: 100%;
        min-width: 0;
    }

    .topbar-search-wrap {
        flex: 1 1 12rem;
        min-width: 7rem;
    }

    .topbar form:has(input[type="search"]) {
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        transform: none !important;
    }

    .topbar nav {
        display: flex !important;
        flex: 1 1 100%;
        flex-wrap: wrap !important;
        align-items: center;
        gap: 0.4rem;
        width: 100%;
    }

    .topbar nav > * {
        flex: 0 0 auto;
    }
}

/*
 * Compact the icon controls gradually rather than allowing
 * them to overlap.
 */
@media (max-width: 820px) {
    .fieldmarks-header-icon-button,
    .topbar .header-icon-button,
    .topbar .header-toggle-button {
        width: 2.15rem !important;
        min-width: 2.15rem !important;
        max-width: 2.15rem !important;
        height: 2.15rem !important;
        min-height: 2.15rem !important;
        max-height: 2.15rem !important;
        padding: 0.36rem !important;
    }

    .fieldmarks-header-icon-button > svg,
    .topbar .header-icon-button > svg,
    .topbar .header-toggle-button > svg {
        width: 1.2rem !important;
        height: 1.2rem !important;
    }

    .topbar-main {
        gap: 0.4rem;
    }

    .topbar-map-controls {
        gap: 0.3rem;
    }
}

/*
 * At phone width, put the search field on its own row.
 * Navigation buttons wrap naturally beneath it.
 */
@media (max-width: 620px) {
    .topbar-main {
        flex-wrap: wrap !important;
    }

    .fieldmarks-brand {
        flex: 1 1 auto;
    }

    .topbar-map-controls {
        margin-left: auto;
    }

    .topbar-search-wrap {
        flex: 1 1 100%;
        order: 20;
        width: 100%;
    }

    .topbar nav {
        justify-content: flex-start;
    }

    .topbar nav > button,
    .topbar nav > a {
        width: auto !important;
        min-width: 0;
        margin: 0 !important;
        padding: 0.42rem 0.58rem;
        font-size: 0.82rem;
    }
}

/*
 * Very narrow screens retain usable touch targets while
 * fitting the three map controls beside the brand.
 */
@media (max-width: 390px) {
    .fieldmarks-header-icon-button,
    .topbar .header-icon-button,
    .topbar .header-toggle-button {
        width: 2rem !important;
        min-width: 2rem !important;
        max-width: 2rem !important;
        height: 2rem !important;
        min-height: 2rem !important;
        max-height: 2rem !important;
        padding: 0.32rem !important;
    }

    .topbar nav {
        gap: 0.3rem;
    }

    .topbar nav > button,
    .topbar nav > a {
        padding: 0.38rem 0.48rem;
        font-size: 0.78rem;
    }
}

/*
 * Final responsive top-bar structure.
 *
 * Below 1100px:
 * Row 1 = FieldMarks brand and search
 * Row 2 = every header control
 *
 * The header grows vertically rather than allowing controls
 * to overlap the map or sidebar toolbar.
 */
@media (max-width: 1100px) {
    .topbar {
        display: grid !important;
        grid-template-columns:
            max-content minmax(0, 1fr);
        grid-template-rows:
            auto auto;
        align-items: center;
        gap: 0.55rem 0.75rem;
        width: 100%;
        padding:
            0.65rem 0.75rem !important;
        overflow: visible !important;
    }

    /*
     * Allow the children of topbar-main to participate
     * directly in the two-row topbar grid.
     */
    .topbar-main {
        display: contents !important;
    }

    .fieldmarks-brand {
        grid-column: 1;
        grid-row: 1;
        align-self: center;
        white-space: nowrap;
    }

    .topbar-search-wrap {
        grid-column: 2;
        grid-row: 1;
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .topbar form:has(input[type="search"]),
    .topbar-search-form {
        position: static !important;
        display: flex !important;
        width: 100% !important;
        max-width: none !important;
        min-width: 0 !important;
        margin: 0 !important;
        transform: none !important;
    }

    .topbar-search-form input[type="search"] {
        flex: 1 1 auto;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
    }

    /*
     * Map visibility controls begin the second row.
     */
    .topbar-map-controls {
        grid-column: 1;
        grid-row: 2;
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: nowrap !important;
        gap: 0.35rem;
        min-width: max-content;
        margin: 0 !important;
    }

    /*
     * Routes, Locations, Explorer, Settings and Sign Out
     * remain together alongside the map controls.
     */
    .topbar nav {
        grid-column: 2;
        grid-row: 2;
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: wrap !important;
        gap: 0.35rem;
        width: 100%;
        min-width: 0;
        margin: 0 !important;
    }

    .topbar nav > *,
    .topbar-map-controls > * {
        flex: 0 0 auto;
        margin: 0 !important;
    }
}

/*
 * Keep the same two-row structure at tablet width.
 * Only reduce spacing and icon size.
 */
@media (max-width: 820px) {
    .topbar {
        gap: 0.45rem 0.55rem;
        padding:
            0.55rem 0.6rem !important;
    }

    .topbar-map-controls,
    .topbar nav {
        gap: 0.28rem;
    }

    .fieldmarks-header-icon-button,
    .topbar .header-icon-button,
    .topbar .header-toggle-button {
        width: 2.15rem !important;
        min-width: 2.15rem !important;
        max-width: 2.15rem !important;
        height: 2.15rem !important;
        min-height: 2.15rem !important;
        max-height: 2.15rem !important;
        padding: 0.36rem !important;
    }

    .fieldmarks-header-icon-button > svg,
    .topbar .header-icon-button > svg,
    .topbar .header-toggle-button > svg {
        width: 1.2rem !important;
        height: 1.2rem !important;
    }
}

/*
 * On narrow phones, keep the logo and search together in
 * the first row. The complete control area remains beneath.
 */
@media (max-width: 620px) {
    .topbar {
        grid-template-columns:
            max-content minmax(0, 1fr) !important;
    }

    .fieldmarks-brand {
        grid-column: 1 !important;
        grid-row: 1 !important;
        order: initial !important;
    }

    .topbar-search-wrap {
        grid-column: 2 !important;
        grid-row: 1 !important;
        order: initial !important;
        width: 100% !important;
    }

    .topbar form:has(input[type="search"]),
    .topbar-search-form {
        order: initial !important;
        width: 100% !important;
        max-width: none !important;
    }

    .topbar-map-controls {
        grid-column: 1 !important;
        grid-row: 2 !important;
        margin-left: 0 !important;
    }

    .topbar nav {
        grid-column: 2 !important;
        grid-row: 2 !important;
        order: initial !important;
        justify-content: flex-start !important;
    }

    .topbar nav > button,
    .topbar nav > a {
        width: auto !important;
        min-width: 0 !important;
        margin: 0 !important;
    }
}

/*
 * At very narrow widths, allow only the second control row
 * to wrap. It remains fully inside the green header.
 */
@media (max-width: 430px) {
    .topbar {
        grid-template-columns: 1fr !important;
        grid-template-rows:
            auto auto auto !important;
    }

    .fieldmarks-brand {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    .topbar-search-wrap {
        grid-column: 1 !important;
        grid-row: 2 !important;
    }

    .topbar-map-controls {
        grid-column: 1 !important;
        grid-row: 3 !important;
    }

    .topbar nav {
        grid-column: 1 !important;
        grid-row: 3 !important;
        padding-left: 7rem;
    }
}

/*
 * Dynamic responsive header height.
 *
 * Below 1100px the topbar grows naturally to contain both
 * rows. The application shell then occupies the remaining
 * viewport beneath it.
 */
@media (max-width: 1100px) {
    body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    .topbar {
        position: relative;
        flex: 0 0 auto;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
    }

    .app-shell {
        flex: 1 1 auto;
        height: auto !important;
        min-height: 0;
    }

    /*
     * Keep the sidebar toolbar within the sidebar instead
     * of fixing it over the header or map.
     */
    #sidebarMapToolbar.fieldmarks-floating-toolbar {
        position: sticky !important;
        top: 0 !important;
        left: auto !important;
        right: auto !important;
        z-index: 5;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 0 0.9rem !important;
    }
}

/*
 * On the existing single-column mobile layout, allow the
 * map and sidebar to size naturally beneath the full header.
 */
@media (max-width: 760px) {
    .app-shell {
        height: auto !important;
        min-height: 0;
    }
}

/*
 * FieldMarks administration, governance and health pages.
 */
.admin-page {
    min-height: 100vh;
    background: #f3f5f3;
}

.admin-topbar {
    height: auto;
    min-height: 58px;
    flex-wrap: wrap;
    gap: 0.7rem 1rem;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
}

.admin-navigation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.admin-navigation a,
.admin-navigation button {
    width: auto;
    min-height: 2.35rem;
    margin: 0;
    padding: 0.45rem 0.7rem;
    border-radius: 0.5rem;
}

.admin-navigation a {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.admin-governance-wrap {
    max-width: 1280px;
}

.admin-page-heading {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(18rem, 32rem);
    align-items: end;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.admin-page-heading h1,
.admin-page-heading p {
    margin-top: 0;
}

.admin-page-heading h1 {
    margin-bottom: 0;
}

.admin-page-heading > p {
    margin-bottom: 0;
    color: #586159;
    line-height: 1.55;
}

.admin-eyebrow {
    margin-bottom: 0.25rem;
    color: #647067;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.admin-summary-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(13rem, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.admin-summary-card {
    display: grid;
    gap: 0.45rem;
    min-width: 0;
    padding: 1rem;
    border: 1px solid #d4dbd5;
    border-radius: 0.8rem;
    background: #fff;
    color: inherit;
    text-decoration: none;
    box-shadow: 0 3px 12px rgba(24, 59, 43, 0.06);
}

a.admin-summary-card:hover,
a.admin-summary-card:focus-visible {
    border-color: #699177;
    box-shadow: 0 5px 18px rgba(24, 59, 43, 0.12);
}

.admin-summary-card span {
    color: #5e6760;
    line-height: 1.45;
}

.admin-panel {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid #d4dbd5;
    border-radius: 0.8rem;
    background: #fff;
    box-shadow: 0 3px 12px rgba(24, 59, 43, 0.06);
}

.admin-panel h2:first-child {
    margin-top: 0;
}

.admin-panel li {
    margin-bottom: 0.55rem;
    line-height: 1.5;
}

.admin-table-scroll {
    max-width: 100%;
    overflow-x: auto;
}

.admin-data-table {
    min-width: 980px;
}

.admin-data-table th,
.admin-data-table td {
    vertical-align: top;
    line-height: 1.45;
}

.admin-overall-health {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.9rem 1rem;
    border: 1px solid;
    border-radius: 0.75rem;
}

.admin-health-grid {
    display: grid;
    grid-template-columns:
        repeat(auto-fit, minmax(18rem, 1fr));
    gap: 1rem;
}

.admin-health-marker {
    padding: 1rem;
    border: 1px solid;
    border-radius: 0.8rem;
    background: #fff;
}

.admin-health-marker-heading {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
}

.admin-health-marker p {
    margin-bottom: 0;
    line-height: 1.5;
}

.admin-health-dot {
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 50%;
    background: currentColor;
}

.admin-health-status {
    font-size: 0.8rem;
    font-weight: 750;
    text-transform: uppercase;
}

.admin-health-good {
    border-color: #8db69a;
    background: #f2faf4;
    color: #245d37;
}

.admin-health-warning {
    border-color: #d2a948;
    background: #fff9e8;
    color: #795a09;
}

.admin-health-critical {
    border-color: #cf7a7a;
    background: #fff2f2;
    color: #8f2929;
}

.admin-information-columns {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

@media (max-width: 760px) {
    .admin-page-heading {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .admin-information-columns {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .admin-health-grid {
        grid-template-columns: 1fr;
    }
}


/* Saved Location category controls */
.saved-location-category-toggle {
    align-items: center;
    display: flex;
    gap: 0.55rem;
}
.saved-location-category-toggle input {
    margin: 0;
    width: auto;
}


.saved-library-heading-actions { align-items:center; display:flex; flex-wrap:wrap; gap:.75rem; }
.saved-library-heading-actions h1 { margin:0; }
.saved-route-details-header { border-bottom:1px solid #d6d9dc; margin-bottom:1rem; padding-bottom:.75rem; }
.saved-route-details-kicker { color:#4b5563; font-size:.78rem; font-weight:700; letter-spacing:.08em; margin:0 0 .25rem; text-transform:uppercase; }
.saved-route-details-header h2, .saved-route-title { color:#123f65; font-size:clamp(1.35rem,2vw,1.8rem); font-weight:750; line-height:1.2; margin:0; }
.fieldmarks-unified-tooltip-host { overflow:visible !important; position:relative !important; }
.fieldmarks-unified-tooltip {
    background: #f2f1f3;
    border: 1px solid #b9b3bd;
    border-radius: .35rem;
    bottom: calc(100% + .45rem);
    box-shadow: 0 3px 10px rgba(31, 27, 34, .16);
    box-sizing: border-box;
    color: #3f3942;
    display: block;
    font-size: .75rem;
    font-weight: 600;
    left: 50%;
    line-height: 1.25;
    max-width: min(18rem, calc(100vw - 1rem));
    min-width: max-content;
    opacity: 0;
    padding: .42rem .58rem;
    pointer-events: none;
    position: absolute;
    text-align: center;
    transform: translate(-50%, 0);
    transition:
        opacity 80ms linear,
        visibility 80ms linear;
    visibility: hidden;
    white-space: normal;
    width: max-content;
    z-index: 10000;
}
.fieldmarks-unified-tooltip-host:hover
    > .fieldmarks-unified-tooltip,
.fieldmarks-unified-tooltip-host:focus-visible
    > .fieldmarks-unified-tooltip,
.fieldmarks-unified-tooltip-host:focus-within
    > .fieldmarks-unified-tooltip {
    opacity: 1;
    visibility: visible;
}
.topbar .fieldmarks-unified-tooltip { bottom:auto; top:calc(100% + .45rem); }


/* Keep long top navigation tooltip labels on-screen. */
nav .fieldmarks-unified-tooltip {
    bottom: auto;
    top: calc(100% + .45rem);
}

nav button:first-child .fieldmarks-unified-tooltip {
    left: 0;
    transform: none;
}

nav button:last-child .fieldmarks-unified-tooltip,
nav a:last-child .fieldmarks-unified-tooltip {
    left: auto;
    right: 0;
    transform: none;
}


/* Immediate light-grey tooltips */
.fieldmarks-unified-tooltip-host {
    overflow: visible !important;
    position: relative !important;
}

.fieldmarks-unified-tooltip-host
    > .fieldmarks-unified-tooltip {
    background: #e9e9e9 !important;
    border: 1px solid #b7b7b7 !important;
    border-radius: 2px !important;
    bottom: calc(100% + .38rem);
    box-shadow: 0 2px 5px rgba(0, 0, 0, .28);
    box-sizing: border-box;
    color: #2f2f2f !important;
    display: block;
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 400;
    left: 50%;
    line-height: 1.2;
    max-width: min(18rem, calc(100vw - 1rem));
    opacity: 0;
    padding: 3px 6px;
    pointer-events: none;
    position: absolute;
    text-align: center;
    transform: translateX(-50%);
    transition: none !important;
    visibility: hidden;
    white-space: normal;
    width: max-content;
    z-index: 10000;
}

.fieldmarks-unified-tooltip-host:hover
    > .fieldmarks-unified-tooltip,
.fieldmarks-unified-tooltip-host:focus-visible
    > .fieldmarks-unified-tooltip,
.fieldmarks-unified-tooltip-host:focus-within
    > .fieldmarks-unified-tooltip {
    opacity: 1;
    visibility: visible;
}

.topbar .fieldmarks-unified-tooltip,
nav .fieldmarks-unified-tooltip {
    bottom: auto !important;
    top: calc(100% + .38rem) !important;
}

nav button:first-child
    > .fieldmarks-unified-tooltip {
    left: 0;
    transform: none;
}

nav button:last-child
    > .fieldmarks-unified-tooltip,
nav a:last-child
    > .fieldmarks-unified-tooltip {
    left: auto;
    right: 0;
    transform: none;
}


/* Single immediate tooltip system */
.fieldmarks-unified-tooltip {
    display: none !important;
}

[data-fieldmarks-tooltip] {
    overflow: visible !important;
    position: relative !important;
}

[data-fieldmarks-tooltip]::after {
    background: #e9e9e9;
    border: 1px solid #b7b7b7;
    border-radius: 2px;
    bottom: calc(100% + .38rem);
    box-shadow: 0 2px 5px rgba(0, 0, 0, .28);
    box-sizing: border-box;
    color: #2f2f2f;
    content: attr(data-fieldmarks-tooltip);
    display: block;
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 400;
    left: 50%;
    line-height: 1.2;
    max-width: min(18rem, calc(100vw - 1rem));
    opacity: 0;
    padding: 3px 6px;
    pointer-events: none;
    position: absolute;
    text-align: center;
    transform: translateX(-50%);
    transition: none;
    visibility: hidden;
    white-space: normal;
    width: max-content;
    z-index: 2147483647;
}

[data-fieldmarks-tooltip]:hover::after,
[data-fieldmarks-tooltip]:focus-visible::after,
[data-fieldmarks-tooltip]:focus-within::after {
    opacity: 1;
    visibility: visible;
}

.topbar [data-fieldmarks-tooltip]::after,
nav [data-fieldmarks-tooltip]::after {
    bottom: auto;
    top: calc(100% + .38rem);
}

nav [data-fieldmarks-tooltip]:first-child::after {
    left: 0;
    transform: none;
}

nav [data-fieldmarks-tooltip]:last-child::after {
    left: auto;
    right: 0;
    transform: none;
}

/* Side menu controls use exactly the same timing and style. */
.sidebar [data-fieldmarks-tooltip]::after {
    bottom: calc(100% + .38rem);
    top: auto;
}


/* Final page-level tooltip: independent of control CSS. */
[data-fieldmarks-tooltip]::after {
    content: none !important;
    display: none !important;
}

#fieldmarksPageTooltip {
    background: #e9e9e9;
    border: 1px solid #b7b7b7;
    border-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .28);
    box-sizing: border-box;
    color: #2f2f2f;
    font-family: Arial, sans-serif;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.2;
    max-width: min(18rem, calc(100vw - 12px));
    padding: 3px 6px;
    pointer-events: none;
    position: fixed;
    text-align: center;
    transition: none !important;
    white-space: normal;
    width: max-content;
    z-index: 2147483647;
}

#fieldmarksPageTooltip[hidden] {
    display: none !important;
}


/* Route and location library visual summaries */
.saved-library-route-summary {
    align-items: stretch;
    display: grid;
    gap: .7rem;
    grid-template-columns: minmax(190px, 1.1fr) minmax(190px, 1.1fr) minmax(260px, 1.5fr);
    margin-top: .8rem;
}
.saved-library-location-media { margin-top: .8rem; max-width: 360px; }
.saved-library-map-thumbnail,
.saved-library-elevation-thumbnail {
    background: #eef1ee;
    border: 1px solid #d6cbe5;
    border-radius: .55rem;
    min-height: 120px;
    overflow: hidden;
    position: relative;
}
.saved-library-map-thumbnail img,
.saved-library-map-thumbnail > div,
.saved-library-map-svg,
.saved-library-elevation-thumbnail svg {
    display: block;
    height: 100%;
    min-height: 120px;
    object-fit: cover;
    width: 100%;
}
.saved-library-map-thumbnail > div[hidden] { display: none !important; }
.saved-library-map-fallback { align-items: center; color: #687269; display: grid; min-height: 120px; place-items: center; }
.saved-library-map-svg { background: #eef2ed; }
.saved-library-map-grid { fill: none; opacity: .34; stroke: #a8b7aa; stroke-width: 1; }
.saved-library-map-route { fill: none; stroke: #246b47; stroke-linecap: round; stroke-linejoin: round; stroke-width: 4; }
.saved-library-map-pin { fill: #246b47; stroke: #fff; stroke-width: 3; }
.saved-library-map-pin-centre { fill: #fff; }
.saved-library-elevation-thumbnail { background: #f6f3fa; }
.saved-library-elevation-area { fill: rgba(109, 75, 145, .18); }
.saved-library-elevation-line { fill: none; stroke: #6d4b91; stroke-linecap: round; stroke-linejoin: round; stroke-width: 3; }
.saved-library-elevation-thumbnail text { fill: #5f5667; font-size: 11px; }
.saved-library-elevation-unavailable { align-items: center; color: #6c6274; display: grid; font-size: .85rem; place-items: center; }
.saved-library-route-summary .saved-library-stats { align-content: stretch; margin: 0; }
.saved-library-route-summary .saved-library-stats div { display: grid; min-height: 0; place-content: center start; }
@media (max-width: 900px) {
    .saved-library-route-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .saved-library-route-summary .saved-library-stats { grid-column: 1 / -1; }
}
@media (max-width: 620px) {
    .saved-library-route-summary { grid-template-columns: 1fr; }
    .saved-library-route-summary .saved-library-stats { grid-column: auto; }
    .saved-library-location-media { max-width: none; }
}


/* Key-free OpenFreeMap library thumbnails */
.saved-library-mini-map-canvas {
    height: 100%;
    min-height: 120px;
    width: 100%;
}

.saved-library-mini-map-fallback,
.saved-library-mini-map-fallback
.saved-library-map-svg,
.saved-library-mini-map-fallback
.saved-library-map-fallback {
    height: 100%;
    min-height: 120px;
    width: 100%;
}

.saved-library-mini-map-fallback[hidden] {
    display: none !important;
}

.saved-library-map-thumbnail
.maplibregl-map {
    font: inherit;
    height: 100%;
    min-height: 120px;
    width: 100%;
}

.saved-library-map-thumbnail
.maplibregl-control-container {
    font-size: 8px;
}

.saved-library-map-thumbnail
.maplibregl-ctrl-attrib {
    background: rgba(255, 255, 255, .82);
    font-size: 8px;
    line-height: 1.1;
    padding: 1px 3px;
}

.saved-library-map-thumbnail
.maplibregl-ctrl-attrib-button {
    height: 18px;
    min-height: 18px;
    min-width: 18px;
    width: 18px;
}



.settings-thumbnail-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns:
        repeat(auto-fit, minmax(210px, 1fr));
    margin-top: 1rem;
}

.settings-thumbnail-card {
    background: #fff;
    border: 1px solid rgba(84, 64, 105, .25);
    border-radius: .7rem;
    box-shadow: 0 4px 16px rgba(45, 26, 70, .12);
    color: #241a2f;
    cursor: pointer;
    margin: 0;
    overflow: hidden;
    padding: 0;
    text-align: left;
    transition:
        box-shadow .16s ease,
        transform .16s ease;
}

.settings-thumbnail-card:hover,
.settings-thumbnail-card:focus-visible {
    box-shadow: 0 7px 22px rgba(45, 26, 70, .22);
    transform: translateY(-2px);
}

.settings-thumbnail-card img {
    aspect-ratio: 16 / 9;
    display: block;
    object-fit: cover;
    pointer-events: none;
    width: 100%;
}

.settings-thumbnail-card > span {
    display: grid;
    gap: .3rem;
    padding: .85rem;
    pointer-events: none;
}

.settings-thumbnail-card small {
    color: #687269;
    line-height: 1.4;
}

.settings-thumbnail-detail {
    background: #fff;
    border: 1px solid rgba(127, 127, 127, .38);
    border-radius: .7rem;
    margin-top: 1rem;
    padding: 1rem;
}

.settings-submenu-header {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.settings-submenu-header h3 {
    margin: 0;
}

.settings-submenu-close {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 1.45rem;
    height: 2.2rem;
    justify-content: center;
    line-height: 1;
    margin: 0;
    padding: 0;
    width: 2.2rem;
}

.settings-checkbox-row {
    align-items: start;
    display: grid;
    gap: .75rem;
    grid-template-columns: auto 1fr;
    margin-bottom: 1rem;
}

.settings-checkbox-row input {
    margin-top: .25rem;
}

.settings-checkbox-row span,
.settings-checkbox-row small {
    display: block;
}

.settings-checkbox-row small {
    color: #687269;
    margin-top: .25rem;
}

.settings-submenu-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.settings-submenu-actions button {
    margin: 0;
    width: auto;
}

.settings-embedded-existing-panel {
    border: 0;
    margin: 0;
    padding: 0;
}

.fieldmarks-hide-selected-actions #saveLocation,
.fieldmarks-hide-selected-actions #copySelectedCoordinates,
.fieldmarks-hide-selected-actions #openSelectedGoogleMaps,
.fieldmarks-hide-selected-actions #openSelectedAppleMaps,
.fieldmarks-hide-selected-actions #searchSelectedArea,
.fieldmarks-hide-selected-actions #clearSelectedLocation {
    display: none !important;
}

.fieldmarks-hide-sun-moon #sunTimesPanel {
    display: none !important;
}

@media (max-width: 680px) {
    .settings-thumbnail-grid {
        grid-template-columns: 1fr;
    }
}

/*
 * Settings screen navigation:
 * author display rules must never override the hidden state.
 */
#settingsThumbnailGrid[hidden],
.settings-thumbnail-detail[hidden] {
    display: none !important;
}

.settings-menu-shell.is-showing-submenu
    #settingsThumbnailGrid {
    display: none !important;
}

.settings-menu-shell.is-showing-submenu
    .settings-thumbnail-detail:not([hidden]) {
    display: block;
    margin-top: 0;
    min-height: 100%;
}

.settings-menu-shell.is-showing-submenu
    .settings-menu-header {
    margin-bottom: 1rem;
}

.settings-menu-guidance {
    color: #687269;
    margin: .15rem 0 .8rem;
}

/*
 * The top navigation Settings control is intentionally compact.
 * Thumbnail cards and submenu buttons retain their normal sizes.
 */
#openSettingsMenu {
    font-size: .55rem;
    line-height: 1.05;
    min-height: 0;
    padding: .22rem .38rem;
}

/*
 * Compact Settings thumbnails.
 * These rules affect only the seven cards inside Settings.
 */
#settingsThumbnailGrid {
    grid-template-columns:
        repeat(auto-fit, minmax(105px, 1fr));
    gap: .5rem;
}

#settingsThumbnailGrid .settings-thumbnail-card img {
    aspect-ratio: 16 / 9;
}

#settingsThumbnailGrid .settings-thumbnail-card > span {
    gap: .15rem;
    padding: .42rem;
}

#settingsThumbnailGrid .settings-thumbnail-card strong {
    font-size: .72rem;
    line-height: 1.15;
}

#settingsThumbnailGrid .settings-thumbnail-card small {
    font-size: .58rem;
    line-height: 1.2;
}

/*
 * The main Settings screen must contain thumbnails only.
 * All setting controls belong inside a submenu panel.
 */
.settings-menu-shell:not(.is-showing-submenu)
    > :not(
        .settings-menu-header,
        .settings-menu-guidance,
        #settingsThumbnailGrid
    ) {
    display: none !important;
}

.settings-menu-shell.is-showing-submenu
    > :not(
        .settings-menu-header,
        .settings-menu-guidance,
        .settings-thumbnail-detail
    ) {
    display: none !important;
}

.settings-menu-shell.is-showing-submenu
    .settings-thumbnail-detail[hidden] {
    display: none !important;
}

.settings-menu-shell.is-showing-submenu
    .settings-thumbnail-detail:not([hidden]) {
    display: block !important;
}

/*
 * The main Settings screen owns the Back to map button.
 * Submenus use only their green close control.
 */
.settings-menu-shell.is-showing-submenu
    #closeSettingsMenu {
    display: none !important;
}

/* Large visual map-layer picker */
.map-layer-menu {
    width: min(52rem, calc(100vw - 2rem));
    min-width: min(34.375rem, calc(100vw - 2rem));
    max-height: min(78vh, 45rem);
    padding: 1rem;
    overflow-y: auto;
}

.map-layer-menu-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .85rem;
}

.map-layer-menu-header h2 {
    margin: 0;
    color: #302b33;
    font-size: 1.2rem;
}

.map-layer-menu-kicker {
    margin: 0 0 .15rem;
    color: #a96900;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.map-layer-menu-intro {
    margin: .2rem 0 0;
    color: #6b6470;
    font-size: .82rem;
}

.map-layer-menu-close {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 2rem;
    min-width: 2rem;
    height: 2rem;
    min-height: 2rem;
    padding: 0;
    border-radius: 999px;
    font-size: 1.25rem;
    line-height: 1;
}

.map-layer-visual-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .7rem;
}

.map-layer-card {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: 2px solid #d8d1dc;
    border-radius: .7rem;
    background: #fff;
    color: #342f38;
    text-align: left;
    box-shadow: none;
}

.map-layer-card:hover,
.map-layer-card:focus-visible {
    border-color: #b27b16;
    background: #fffaf0;
}

.map-layer-card.selected {
    border-color: #a96900;
    box-shadow: 0 0 0 2px rgba(169, 105, 0, .18);
}

.map-layer-card:disabled {
    opacity: .42;
    cursor: not-allowed;
}

.map-layer-preview {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background-color: #d8ded8;
    background-position: center;
    background-size: cover;
}

.map-layer-preview::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}

.map-layer-preview-terrain::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background:
        linear-gradient(
            135deg,
            rgba(255, 255, 255, .08),
            rgba(38, 51, 38, .34)
        );
    mix-blend-mode: multiply;
}

.map-layer-card-copy {
    display: grid;
    gap: .18rem;
    padding: .58rem .65rem .65rem;
}

.map-layer-card-copy strong {
    font-size: .82rem;
    line-height: 1.2;
}

.map-layer-card-copy small {
    color: #6d6671;
    font-size: .68rem;
    line-height: 1.3;
}

.map-layer-list-control {
    display: grid;
    grid-template-columns: auto minmax(12rem, 1fr);
    align-items: center;
    gap: .7rem;
    margin-top: .9rem;
    padding-top: .85rem;
    border-top: 1px solid #ddd6e1;
}

.map-layer-list-control label {
    margin: 0;
    white-space: nowrap;
}

.map-layer-list-control select {
    width: 100%;
}

.map-layer-preview-note {
    margin: .55rem 0 0;
    color: #766f79;
    font-size: .65rem;
}

@media (max-width: 900px) {
    .map-layer-visual-list {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 550px) {
    .map-layer-control {
        right: .5rem;
        left: .5rem;
        justify-items: end;
    }

    .map-layer-menu {
        width: calc(100vw - 1rem);
        min-width: 0;
        max-height: 72vh;
        padding: .75rem;
    }

    .map-layer-visual-list {
        grid-template-columns: 1fr;
    }

    .map-layer-card {
        grid-template-columns: 7.5rem minmax(0, 1fr);
        grid-template-rows: auto;
        align-items: stretch;
    }

    .map-layer-preview {
        height: 100%;
        min-height: 5.4rem;
        aspect-ratio: auto;
    }

    .map-layer-list-control {
        grid-template-columns: 1fr;
        gap: .35rem;
    }
}

/*
 * Compact visual map-layer cards:
 * approximately half the original card footprint.
 */
.map-layer-menu:not(:has(.map-layer-visual-list[hidden])) {
    width: min(42rem, calc(100vw - 2rem));
}

.map-layer-visual-list {
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    gap: .42rem;
}

.map-layer-card {
    border-width: 1px;
    border-radius: .5rem;
}

.map-layer-card-copy {
    gap: .1rem;
    padding: .34rem .4rem .42rem;
}

.map-layer-card-copy strong {
    font-size: .68rem;
}

.map-layer-card-copy small {
    font-size: .55rem;
    line-height: 1.2;
}

.map-layer-preview {
    aspect-ratio: 2 / 1;
}

.map-layer-visual-list[hidden],
.map-layer-list-control[hidden],
.map-layer-preview-note[hidden] {
    display: none !important;
}

.settings-choice-group {
    display: grid;
    gap: .65rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.settings-choice-group legend {
    margin-bottom: .55rem;
    font-weight: 700;
}

.settings-radio-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
    gap: .65rem;
    padding: .7rem;
    border: 1px solid #d8d1dc;
    border-radius: .65rem;
    background: #fff;
}

.settings-radio-row input {
    margin-top: .18rem;
}

.settings-radio-row span {
    display: grid;
    gap: .15rem;
}

.settings-radio-row small {
    color: #6d6671;
}

@media (max-width: 900px) {
    .map-layer-visual-list {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .map-layer-visual-list {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 550px) {
    .map-layer-visual-list {
        grid-template-columns: 1fr;
    }

    .map-layer-card {
        grid-template-columns:
            5.25rem minmax(0, 1fr);
    }

    .map-layer-preview {
        min-height: 3.7rem;
    }
}
/* Outdoor challenge administration */
.challenge-admin-wrap{max-width:1400px}
.challenge-admin-message{padding:.85rem 1rem;border-radius:.65rem;background:rgba(36,107,71,.12);color:#17482f;font-weight:700}
.challenge-admin-error{background:rgba(166,45,45,.12);color:#8d2020}
.challenge-admin-form{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem}
.challenge-admin-form label{display:grid;gap:.35rem}
.challenge-admin-form input,.challenge-admin-form select,.challenge-admin-form textarea{width:100%}
.challenge-admin-wide{grid-column:1/-1}
.challenge-admin-check{display:flex!important;align-items:center;gap:.5rem!important}
.challenge-admin-check input{width:auto}
.challenge-admin-form>button{width:max-content;min-width:10rem}
.challenge-admin-card-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(310px,1fr));gap:1rem}
.challenge-admin-card{display:grid;gap:.75rem;padding:.9rem;border:1px solid #d8ddd9;border-radius:.8rem;background:#fff}
.challenge-admin-card>img{width:100%;aspect-ratio:16/9;object-fit:cover;border-radius:.6rem}
.challenge-admin-card form{margin:0}
.challenge-admin-card .danger-button{width:auto}
.challenge-admin-link-button{display:inline-block;width:max-content;padding:.6rem .8rem;border-radius:.45rem;background:#246b47;color:#fff;text-decoration:none}
.challenge-admin-picker{max-width:32rem;margin-bottom:1rem}
.challenge-admin-picker label{display:grid;gap:.35rem}
.challenge-admin-two-column{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;margin-bottom:1rem}
.challenge-admin-two-column form{align-content:start;padding:.85rem;border:1px solid #d8ddd9;border-radius:.75rem;background:#fff}
@media(max-width:760px){.challenge-admin-form,.challenge-admin-two-column{grid-template-columns:1fr}.challenge-admin-wide{grid-column:auto}}
/* Public Outdoor Challenges */
.challenge-nav-link{display:grid;place-items:center;width:2.35rem;min-width:2.35rem;height:2.35rem;padding:.42rem;border-radius:.5rem;background:#fff;color:#183b2b!important}
.challenge-nav-link svg{width:1.35rem;height:1.35rem;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.challenge-page{min-height:100vh;background:#eef3ef}
.challenge-brand{color:#fff;text-decoration:none}
.challenge-page-shell{width:min(1180px,calc(100% - 2rem));margin:0 auto;padding:1.25rem 0 3rem}
.challenge-page-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:1rem}
.challenge-page-heading h1{margin:0;color:#183b2b}
.challenge-eyebrow{margin:0 0 .2rem;color:#987000;font-size:.72rem;font-weight:800;letter-spacing:.1em;text-transform:uppercase}
.challenge-back-link{display:inline-block;width:auto;padding:.6rem .85rem;color:#fff;text-decoration:none}
.challenge-breadcrumb{display:flex;flex-wrap:wrap;gap:.4rem;margin-bottom:1rem;font-size:.88rem}
.challenge-breadcrumb a{color:#245d42}
.challenge-status{padding:.75rem 1rem;border-radius:.65rem;font-weight:700}
.challenge-status-success{background:#dcecdf;color:#194c30}
.challenge-status-error{background:#f2dada;color:#842323}
.challenge-card-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1rem}
.challenge-card{display:grid;grid-template-rows:auto 1fr;overflow:hidden;border:1px solid #d2dbd4;border-radius:.85rem;background:#fff;color:#24342b;text-decoration:none;box-shadow:0 4px 16px rgba(20,45,31,.08)}
.challenge-card:hover,.challenge-card:focus-visible{transform:translateY(-2px);box-shadow:0 8px 22px rgba(20,45,31,.14)}
.challenge-card-image,.challenge-detail-image{position:relative;display:block;overflow:hidden;background:#dce5de}
.challenge-card-image{aspect-ratio:16/9}
.challenge-card-image img,.challenge-detail-image img{width:100%;height:100%;object-fit:cover}
.challenge-card.is-complete .challenge-card-image img,.challenge-detail-image.is-complete img{filter:grayscale(1);opacity:.3}
.challenge-complete-trophy{position:absolute;inset:50% auto auto 50%;transform:translate(-50%,-50%);display:grid;place-items:center;width:4.4rem;height:4.4rem;border-radius:999px;background:rgba(255,255,255,.9);font-size:2.35rem;box-shadow:0 5px 18px rgba(0,0,0,.18)}
.challenge-card-body{display:grid;align-content:start;gap:.35rem;padding:.85rem}
.challenge-card-body>strong{font-size:1.05rem}
.challenge-card-body>small{color:#637068;line-height:1.4}
.challenge-activity-label{display:flex;align-items:center;gap:.35rem;margin:0;color:#846100;font-size:.72rem;font-weight:800;letter-spacing:.04em;text-transform:uppercase}
.challenge-card-progress{margin-top:.25rem;color:#2f6648;font-size:.8rem;font-weight:700}
.challenge-category-intro{padding:1rem;border-radius:.85rem;background:#fff}
.challenge-category-intro h2{margin:.3rem 0}
.challenge-detail-hero{display:grid;grid-template-columns:minmax(260px,.8fr) minmax(0,1.2fr);gap:1.2rem;padding:1rem;border-radius:.9rem;background:#fff}
.challenge-detail-image{min-height:230px;border-radius:.75rem}
.challenge-detail-hero h2{margin:.4rem 0}
.challenge-progress-summary{color:#245d42}
.challenge-item-toolbar{display:flex;align-items:end;gap:.75rem;margin:1rem 0}
.challenge-item-toolbar label{display:grid;flex:1;gap:.3rem}
.challenge-item-toolbar button{width:auto;margin:0}
.challenge-progress-form{display:grid;gap:1rem}
.challenge-item-list{display:grid;gap:.55rem}
.challenge-item-row{display:grid;grid-template-columns:minmax(0,1fr) minmax(150px,210px);gap:1rem;align-items:center;padding:.75rem;border:1px solid #d5ddd7;border-radius:.7rem;background:#fff}
.challenge-item-row.is-complete{border-color:#75a685;background:#f3faf5}
.challenge-item-row[hidden]{display:none!important}
.challenge-item-check{display:grid;grid-template-columns:auto auto minmax(0,1fr);align-items:start;gap:.6rem}
.challenge-item-check input{margin-top:.2rem}
.challenge-item-check span:last-child{display:grid;gap:.18rem}
.challenge-item-check small{color:#68736c}
.challenge-item-icon{font-size:1.2rem}
.challenge-item-date{display:grid;gap:.3rem;font-size:.78rem;font-weight:700}
.challenge-item-date input{width:100%}
.challenge-progress-actions{position:sticky;bottom:0;padding:.75rem;border-top:1px solid #ccd6cf;background:rgba(238,243,239,.96)}
.challenge-progress-actions button{width:auto}
@media(max-width:900px){.challenge-card-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:760px){.challenge-topbar{height:auto;min-height:58px;flex-wrap:wrap;gap:.5rem;padding-block:.55rem}.challenge-topbar nav{flex-wrap:wrap;gap:.55rem}.challenge-detail-hero{grid-template-columns:1fr}}
@media(max-width:550px){.challenge-page-shell{width:min(100% - 1rem,550px);padding-top:.75rem}.challenge-page-heading{align-items:stretch;flex-direction:column}.challenge-back-link{width:max-content}.challenge-card-grid{grid-template-columns:1fr}.challenge-item-toolbar{align-items:stretch;flex-direction:column}.challenge-item-toolbar button{width:100%}.challenge-item-row{grid-template-columns:1fr}.challenge-item-date{margin-left:2.6rem}.challenge-progress-actions button{width:100%}}
/* Compact Add Route close control and linked brand */
.fieldmarks-home-link {
    color: inherit;
    text-decoration: none;
}

.fieldmarks-home-link:hover,
.fieldmarks-home-link:focus-visible {
    text-decoration: underline;
    text-underline-offset: .18em;
}

.admin-brand-link {
    color: #fff;
}

#addRouteDialog .saved-content-dialog-header {
    position: relative;
    padding-right: 4.3rem;
}

.add-route-dialog-close {
    position: absolute;
    top: .15rem;
    right: .15rem;
    display: inline-flex;
    align-items: center;
    gap: .22rem;
    width: auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: .2rem .35rem;
    border: 0;
    border-radius: .35rem;
    background: transparent;
    color: #4f5751;
    box-shadow: none;
    font-weight: 700;
    line-height: 1;
}

.add-route-dialog-close span {
    font-size: 1.15rem;
    line-height: .9;
}

.add-route-dialog-close small {
    font-size: .64rem;
    font-weight: 700;
}

.add-route-dialog-close:hover,
.add-route-dialog-close:focus-visible {
    background: rgba(30, 68, 46, .09);
    color: #173e2a;
}
/* Administrator technical information */
.admin-technical-wrap{max-width:1450px}
.technical-chip-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:.55rem}
.technical-status-chip{display:block;padding:.65rem .75rem;border:1px solid #d5ddd7;border-radius:.6rem;background:#fff;font-size:.82rem;font-weight:700}
.technical-status-chip.is-ready{border-color:#79a98a;background:#eef8f1;color:#245c3d}
.technical-status-chip.is-missing{border-color:#c88989;background:#fff1f1;color:#8a2929}
.admin-technical-wrap code{font-size:.78rem;overflow-wrap:anywhere}

