:root {
    --color-foreground: var(--color-secondary);
    --color-background: var(--color-initial);
    --color-border: var(--color-quaternary);
    --color-sidebar-border: var(--color-tertiary);
    --color-placeholder: var(--color-quinary);
    --color-helptext: var(--color-quinary);
    --color-loader: var(--color-primary);
    --color-route-dots: var(--color-secondary);
    --color-control: var(--color-secondary);
    --color-control-background: var(--color-initial);
    --color-control-background-hover: var(--color-tertiary);
    --color-control-hover: var(--color-foreground);
    --color-control-active: var(--color-foreground);
    --color-control-divider: var(--color-quaternary);
    --color-control-disabled: var(--color-quaternary);
    --color-icon: var(--color-secondary);
    --color-icon-light: var(--color-quaternary);
    --color-button: var(--color-quaternary);
    --color-primary-button: var(--color-primary);
    --color-button-border-hover: var(--color-quaternary);
    --color-button-hover: var(--color-quinary);
    --color-focus: var(--color-foreground);
    --color-attribution-background: var(--color-overlay-background);
    --color-input-border: var(--color-quaternary);

    --color-map-overlay: var(--color-primary);
    --color-route-dashes: #888888;


    --color-pin: var(--color-foreground);
    --color-pin-background: transparent;
    --color-pin-background-active: var(--color-quaternary);
    --color-pin-active: var(--color-foreground);
    --color-pin-hover: var(--color-foreground);
    --color-pin-background-hover: var(--color-tertiary);

    --color-shadow: var(--color-quinary);

    --shadow-size: 4px;

    --border-radius: 2px;
    --border-radius-small: 2px;
    --border-radius-leaflet-control: 4px;
}

@import 'milligram/milligram.sass';

::selection {
    background-color: var(--color-primary);
    color: white;
}

body {
    font-weight: normal;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100vw;
    height: 100vh;
}


header {
    padding: 10px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--color-header-background);
    flex-shrink: 0;
}

header h1 {
    font-size: 3rem;
    margin: 0;
}

header h1 a {
    line-height: 50px;
    display: block;
    height: 50px;
}

header h1 a, header h1 a:hover {
    color: var(--color-primary);
}

header h1 img {
    height: 50px;
    vertical-align: top;
    // I have no idea why we did this, but it breaks the header logo, so I disabled it.
    // margin-left: -10px;
    max-width: none;
}

@media (max-width: 500px) {
    header h1 span#subheader {
        display: none;
    }
}

header #user {
    text-align: right;
    padding: 0 0 3px 10px;
    color: var(--color-header-text);
}

header #user small {
    display: block;
    margin-top: -2px;
    color: inherit;
}

header #user small:empty {
    display: none;
}

header #user:hover {
    color: var(--color-header-text-hover);
}

input, textarea, select {
    font-family: inherit;
    color: inherit;
}

::-webkit-input-placeholder {
    color: var(--color-placeholder);
}

::-moz-placeholder {
    color: var(--color-placeholder);
}

.material-symbols {
    user-select: none;
}

hr {
    margin: 1.5rem 0;
}

main {
    flex-grow: 1;
    background-color: var(--color-background);
    border: 0 solid var(--color-border);
    border-top-width: 1px;
    padding: 10px;
    padding-top: 20px;
    position: relative;
}

body > *:not(header):not(main) {
    /* against stupid browser extensions */
    flex-basis: 0;
    overflow: hidden;
}

.loader {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    mask-image: url('../../img/loader.webp');
    mask-repeat: no-repeat;
    background-color: var(--color-loader);
    width: 100%;
    height: 100%;
}

main.map {
    background-color: var(--color-background);
    position: relative;
    padding: 0;
    border-top-width: 0;
    -ms-scroll-chaining: none;
    overscroll-behavior: contain;

    > .loader {
        display: block;
        mask-position: center;
    }
}

main.account form {
    max-width: 400px;
}

#modal-content form button[type=submit], #modal-content form .button.sso, #modal-content .answers .button {
    display: block;
    width: 100%;
}

form label:has(+[type=checkbox]) {
    float: right;
    width: calc(100% - 25px);
    margin-bottom: 1px;
}
form [type=checkbox] {
    margin-bottom: 1px;
}
form [type=checkbox]+.helptext {
    clear: both;
    display: block;
    mrgin-top: 1px;
    margin-bottom: 1px;
}

#modal-content p, main.account p {
    margin-bottom: 10px;
}

#modal-content :last-child {
    margin-bottom: 0;
}

.app-download-buttons {
    margin-top: 20px;
}

#map {
    position: absolute;
    z-index: 1;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
}

#sidebar {
    position: absolute;
    z-index: 2;
    top: 0;
    padding: 10px 10px 32px;
    width: 100%;
    bottom: 0;
    max-width: 420px;
    pointer-events: none;
    display: flex;
    gap: 1.5rem;
    flex-direction: column;
    overflow: hidden;
}

@media (max-width: 500px) {
    #sidebar {
        max-width: 500px;
    }
}

#sidebar section {
    position: relative;
    pointer-events: auto;
    background-color: var(--color-background);
    border-radius: var(--border-radius);
    overflow: hidden;
}

#sidebar section:not(:empty) {
    border: 2px solid var(--color-control-border);
    box-shadow: var(--color-shadow) 0 0 var(--shadow-size);
}

#sidebar section > div {
    border: 0 var(--color-sidebar-border) solid;
    border-top-width: 1px;
    transition: margin-bottom 150ms, opacity 150ms, background-color 150ms ease-in-out, color 150ms ease-in-out;

    overflow: hidden;
}

#sidebar section > div:first-child {
    border-top-width: 0;
}

#search {
    width: 0;
}

#sidebar #search {
    z-index: 4;
    min-height: 54px;
    min-width: 54px;
    width: 100%;
    transition: width 150ms;
    flex-shrink: 0;
}

#sidebar #search.loading {
    width: 5%;
    position: relative;

    > .loader {
        display: block;
        mask-position: 4px 3px;
    }
}

.leaflet-popup-content > .loader {
    width: 48px;
    height: 48px;
    position: initial;
    display: block;
}

.embed-link {
    z-index: 2;
    background-color: var(--color-header-background);
    color: var(--color-primary);
}

#embed-logo {
    font-size: 3rem;
    line-height: 100%;
    font-weight: 300;
    position: absolute;
    top: 0;
    left: 0;
    padding: 0 10px 0 0;
    letter-spacing: -.1rem;
    color: var(--color-primary);
}

#embed-logo span {
    display: inline-block;
    padding: 10px 0 10px 10px;
}

#embed-logo img {
    height: 50px;
    vertical-align: middle;
}

#embed-logo:hover {
    display: inline-block;
}

#embed-open {
    position: absolute;
    top: 0;
    right: 0;
    padding: 10px;
    color: var(--color-header-text);
}

#embed-open:hover {
    color: var(--color-header-text-hover);
}

main:not([data-view^=route]) #origin-input,
#search.loading #destination-input {
    margin-bottom: -55px;
    pointer-events: none;
    opacity: 0;
}

main:not([data-view^=route]) #destination-input {
    border-top-width: 0;
}

main:not([data-view=location]) #location-buttons,
main:not([data-view=route-search]) #route-search-buttons,
main:not([data-view=route-result]) #route-result-buttons {
    margin-bottom: -3.3rem;
    pointer-events: none;
    opacity: 0;
}

#resultswrapper {
    flex-grow: 1;
    flex-shrink: 1;
    display: flex;
    height: 100px;
    flex-direction: column;
}

#resultswrapper section {
    max-height: 100%;
    margin: 0;
}

h2 {
    font-size: 2.5rem;
    margin: 0 0 1rem;
}

.details-head h2 {
    margin: 0;
}

h4 {
    margin: 2rem 0 1rem;
}

section.details {
    display: flex;
    flex-direction: column;
    position: relative;
}

section.details > * {
    flex-shrink: 0;
    flex-grow: 0;
}

section.details > .details-head {
    padding: 11px 10px 8px;
}

section.details > .details-head > .button {
    font-size: 30px;
    line-height: 1.0;
    color: var(--color-button);
    margin: -2px -2px 0 0;
    transition: none;

    &:hover {
        color: var(--color-button-hover);
    }
}

#sidebar section.details > .details-body {
    overflow: auto;
    overscroll-behavior: contain;
    flex-grow: 1;
    flex-shrink: 1;
}

section.details {
    position: relative;

    > .loader {
        z-index: -1;
        display: block;
        mask-position: right 2px top 2px;
    }
}

#sidebar section.details.loading > .details-head {
    background-color: transparent;
}

#sidebar section.details.loading > .details-head .button {
    pointer-events: none;
    opacity: 0;
    line-height: 2;
}

#sidebar section.details.loading > .details-body,
#sidebar section.details.loading > .details-buttons {
    max-height: 0;
    opacity: 0;
}

#sidebar section.details:not(.loading) > .details-head {
    transition: background-color 50ms;
    background-color: var(--color-background);
}

#sidebar section.details:not(.loading) > .details-head .button {
    transition: opacity 150ms;
    pointer-events: auto;
    opacity: 1;
}

#sidebar section.details:not(.loading) > div.details-body,
#sidebar section.details:not(.loading) > div.details-buttons {
    max-height: 100vh;
    transition: max-height 150ms, opacity 50ms;
    transition-timing-function: ease-in;
    animation: show-details-body;
    animation-duration: 160ms;
    opacity: 1;
}

@keyframes show-details-body {
    from {
        overflow: hidden;
    }
    99% {
        overflow: hidden;
    }
    to {
        overflow: auto;
        -ms-scroll-chaining: none;
        overscroll-behavior: contain;
    }
}

#location-details .details-body {
    padding: 10px 10px 0;
}

#location-details dl {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    margin: 0;
    font-size: 90%;
}

#location-details dt {
    width: 39%;
    margin: 0 0 0.7rem;
    font-weight: 700;
}

#location-details dd {
    width: 60%;
    margin: 0 0 0.7rem;
    padding: 0 0 0 1rem;
}

#location-details dd > * {
    display: block;
}

main:not([data-view$=search]) #autocomplete,
main:not([data-view=location]) #location-details,
main:not([data-view=route-result]) #route-details,
main:not([data-view=route-result]) #route-options,
main:not(.show-details) #resultswrapper .details:not(#route-options),
main:not(.show-options) #resultswrapper #route-options {
    display: none;
}

main .buttons .details .material-symbols {
    transition: transform 250ms;
}

main.show-details .buttons .details .material-symbols {
    transform: scale(1, -1);
}

main.show-details #resultswrapper .details,
main.show-options #resultswrapper #route-options {
    animation: show-details;
    animation-duration: 150ms;
    animation-timing-function: ease-out;
}

@keyframes show-details {
    from {
        opacity: 0;
        top: 10px;
    }
    to {
        opacity: 1;
        top: 0;
    }
}

.route-options-fields {
    padding: 0 10px 5px;
}

.route-options-fields input, .route-options-fields select {
    margin-bottom: 1rem;
}

.route-options-buttons {
    display: flex;
    flex-wrap: wrap;
    padding: 0 0 15px 10px;
}

.route-options-buttons button {
    padding: 0 1rem;
    margin: 0 10px 0 0;
    flex-grow: 1;
}

.location {
    position: relative;
    padding: 5px 10px 5px 53px;
    height: 55px;
}

.location.location-form-value {
    margin: -10px -10px 5px -10px;
}

.location-answers .location.location-form-value, .location-answers a {
    margin-bottom: 5px;
    color: var(--color-foreground);
    display: block;
}

.location-answers {
    margin-bottom: 10px;
}

.location .icon {
    font-size: 36px;
    position: absolute;
    top: 9px;
    left: 9px;
    cursor: default;
    color: var(--color-icon);
    transition: color 150ms, transform 150ms, top 150ms;
    pointer-events: none;
}

.location > * {
    display: block;
    white-space: nowrap;
}

.location small {
    line-height: 1.1;
}

.location.focus {
    background-color: var(--color-tertiary);
    color: var(--color-focus);

    .icon {
        color: var(--color-focus);
    }
}

#autocomplete .location {
    cursor: pointer;
}

.location-label {
    white-space: nowrap;
}

.location-label-text {
    line-height: 100%;
    border-radius: var(--border-radius-small);
    white-space: nowrap;
    transform: translateX(-50%) translateY(-50%);
    text-align: center;

    span {
        line-height: 100%;
        color: var(--color-overlay-text);
        background-color: var(--color-overlay-background);
        vertical-align: 12%;
    }
}

.locationinput {
    position: relative;
    padding: 0;
}

.locationinput input {
    box-sizing: border-box;
    border-width: 0;
    height: 54px;
    transition: padding-bottom 150ms;
    line-height: 1.0;
    padding-left: 52px;
}

.locationinput small {
    position: absolute;
    left: 52px;
    top: 30px;
    line-height: 1.1;
    opacity: 1;
    transition: opacity 150ms;
}

.locationinput:not(.selected) small {
    opacity: 0;
    user-select: none; /* Likely future */
    pointer-events: none;
}

.locationinput:not(.selected) .icon {
    color: transparent;
}

.locationinput .icon::before {
    position: absolute;
    top: 0;
    left: 1px;
    content: "\e8b6"; /* unicode code point for the "search" ligature, so android 4.3.3 gets it */
    color: var(--color-icon-light);
    transition: color 150ms;
}

.locationinput.selected .icon::before {
    color: transparent;
}

.locationinput.selected input {
    padding-bottom: 25px;
}

#search .locationinput button {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 0;
    width: 42px;
    height: 42px;
    border-width: 0;
    transition: transform 150ms, opacity 150ms, top 150ms, right 150ms;
    font-size: 42px;
    color: var(--color-button);
    line-height: 1;
}

#search .locationinput button:hover {
    color: var(--color-button-hover);
}

#search button.locate {
    font-size: 35px;
    top: 5px;
}

main:not([data-random-location-groups]) button.random {
    display: none;
}

#search button.random {
    right: 45px;
    color: var(--color-button);

    &:hover {
        color: var(--color-button-hover);
    }
}

.locationinput:not(.empty) button.locate, .locationinput.empty button.clear,
main[data-view^=route] button.random, .locationinput:not(.empty) button.random {
    transform: scale(0.7);
    opacity: 0;
    pointer-events: none;
}

#route-dots {
    position: absolute;
    top: 43px;
    left: 15px;
    text-shadow: 2px 0 1px var(--color-route-dashes-shadow), -2px 0 1px var(--color-route-dashes-shadow);
    transition: top 150ms, opacity 150ms, color 150ms, transform 150ms;
    color: var(--color-route-dots);
    pointer-events: none;
}

main:not([data-view^=route]) #route-dots {
    position: absolute;
    top: 40px;
    opacity: 0;
}

main:not([data-view=route-result]) #route-dots {
    color: var(--color-icon-light); // TODO: wtf?
}

#route-details .details-body > div:not(:last-child) {
    border: 0 var(--color-sidebar-border) solid;
    border-bottom-width: 1px;
}

.routeitem {
    padding: 3px 10px 2px 53px;
    position: relative;
}

.routeitem .icon {
    position: absolute;
    top: 4px;
    left: 12px;
    width: 29px;
    height: 21px;
    text-align: center;
}

.routeitem .icon .material-symbols {
    color: var(--color-icon);
    font-size: 21px;
}

.routeitem .icon img {
    opacity: 0.6;
    height: 21px;
}

#location-popup-buttons, #anywhere-popup-buttons, #attributions {
    display: none;
}

.location-popup .leaflet-popup-content {
    font-size: 16px;
    color: var(--color-foreground);
    overflow: hidden;
    line-height: 1.6;
    margin: 15px 10px 10px;
    padding: 0;
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background-color: var(--color-background);
    box-shadow: var(--color-shadow) 0 0 var(--shadow-size);
}

.leaflet-popup-content-wrapper {
    border-radius: var(--border-radius-small);
}

button, .button {
    color: var(--color-background);
    background-color: var(--color-primary-button);
    border-color: var(--color-primary-button);

    &:hover, &:active {
        background-color: var(--color-button-hover);
        border-color: var(--color-button-hover);
        color: var(--color-background);
    }

    &.button-clear {
        color: var(--color-primary-button);
        background-color: transparent;
        border-color: transparent;

        &:hover, &:active {
            color: var(--color-button-hover);
            background-color: transparent;
            border-color: transparent;
        }
    }

    &.button-outline {
        color: var(--color-primary-button);
        background-color: transparent;
        border-color: var(--color-primary-button);

        &:hover, &:active {
            color: var(--color-button-hover);
            background-color: transparent;
            border-color: var(--color-button-hover);
        }
    }

}


.location-popup {
    .leaflet-popup-content-wrapper {
        padding: 0;
    }

    .leaflet-popup-content {
        margin: 0;

        .buttons {
            border: 0 var(--color-border) solid;
            border-top-width: 1px;

            .button-clear {
                display: block;
                width: 100%;
                padding: 0 7px;
                margin: 0;
                line-height: 3.3rem;
            }
        }

        .location {
            margin-right: 24px;
            padding-right: 0;
            overflow: hidden;
        }

        .as-location .material-symbols {
            transform: rotate(-45deg);
        }
    }

    a.leaflet-popup-close-button {
        color: var(--color-button);
        font-size: 24px;
        width: 22px;
        top: 2px;

        &:hover {
            color: var(--color-button-hover);
        }
    }

    .leaflet-popup-tip-container::after {
        content: "";
        border-top-width: 1px;
        display: block;
        width: 28px;
        height: 20px;
        top: 0;
        left: 11px;
        margin: auto;
        position: absolute;
    }
}

.buttons {
    display: flex;
    flex-direction: row;
    margin-left: -1px;
    height: 3.3rem;
}

.buttons > button.button-clear, .buttons > .button.button-clear {
    width: 1px;
    flex-grow: 1;
    margin: 0;
    border: 0 var(--color-sidebar-border) solid;
    border-left-width: 1px;
    border-radius: 0;
    padding: 0;
    font-size: 1.3rem;
    line-height: 1.3;
    height: 3.3rem;
}

.buttons > *:hover, .buttons > *:active {
    background-color: var(--color-button-border-hover);
}

#search button, .leaflet-popup button, .details-head .button, .buttons.details-buttons button, .buttons.details-buttons .button {
    font-size: 1.3rem;
    line-height: 3.3rem;
    height: 3.3rem;
    padding: 0;
}

button .material-symbols, .button .material-symbols {
    font-size: 15px;
    vertical-align: -3px;
}

#route-summary {
    position: relative;
    padding: 6px 10px 5px 52px;
    height: 55px;
}

#route-summary > :not(.loader) {
    display: block;
    white-space: nowrap;
}

#route-summary .icon {
    font-size: 36px;
    position: absolute;
    top: 10px;
    left: 9px;
    cursor: default;
    color: var(--color-icon);
}

#route-summary small {
    line-height: 1.1;
}

#route-summary.loading {
    position: relative;

    > .loader {
        display: block;
        mask-position: 4px 4px;
    }
}

#route-summary.loading > * {
    display: none;
}

main:not([data-view=route-result]) #route-summary {
    margin-bottom: -55px;
    pointer-events: none;
    opacity: 0;
}

#route-summary button.options {
    position: absolute;
    top: 8px;
    right: 6px;
    padding: 0;
    width: 37px;
    height: 37px;
    border-width: 0;
    font-size: 36px;
    line-height: 1;
    color: var(--color-button);

    &:hover {
        color: var(--color-button-hover);
    }
}

@media not all and (min-height: 700px) and (min-width: 1100px) {
    main[data-view=route-result] #sidebar #search:not(.focused) .locationinput {
        margin-bottom: -21px;
    }
    main[data-view=route-result] #sidebar #search:not(.focused) .locationinput input {
        padding-bottom: 28px;
    }
    main[data-view=route-result] #sidebar #search:not(.focused) .locationinput small {
        opacity: 0;
        user-select: none;
        pointer-events: none;
    }
    main[data-view=route-result] #sidebar #search:not(.focused) .locationinput .icon {
        transform: scale(0.6);
        top: -1px;
    }
    main[data-view=route-result] #sidebar #search:not(.focused) .locationinput button {
        transform: scale(0.6);
        top: -5px;
        right: -5px;
    }
    main[data-view=route-result] #sidebar #search:not(.focused) #route-dots {
        transform: scale(0.7);
        top: 32px;
    }
}

/* leaftlet levels control */
.leaflet-control-levels a, .leaflet-control-levels a:hover {
    width: auto;
    min-width: 26px;
    font-size: 14px;
    padding: 0 3px;
    white-space: nowrap;
}

.leaflet-touch .leaflet-control-levels a, .leaflet-touch .leaflet-control-levels a:hover {
    width: auto;
    min-width: 30px;
    line-height: 30px;
    font-size: 15px;
    padding: 0 3px;
}

.leaflet-control-levels a.current {
    font-weight: bold;
    color: var(--color-control-active);
    background-color: var(--color-control-background-active);
}

.leaflet-container {
    background-color: var(--color-leaflet-background);
}

.leaflet-container .leaflet-control-attribution {
    background-color: var(--color-attribution-background);
    color: var(--color-foreground);

    a {
        color: var(--color-primary);
    }

    a:hover {
        color: var(--color-foreground);
        text-decoration: none;
    }
}

.leaflet-control-user-location a {
    font-size: 20px;
}

.leaflet-bar, .leaflet-touch .leaflet-bar, .leaflet-control-expanding, .leaflet-control-overlays {
    overflow: hidden;
    background-color: var(--color-control-background);
    border-radius: var(--border-radius-leaflet-control);
    border: 2px solid var(--color-control-border);
    box-shadow: var(--color-control-shadow) 0 0 var(--shadow-size);
}

.leaflet-bar a {
    background-color: var(--color-control-background);
    color: var(--color-control);
    border-bottom-color: var(--color-control-divider);
}

.leaflet-bar a:first-child, .leaflet-bar a:last-child {
    border-radius: 0;
}

.leaflet-bar a:hover {
    background-color: var(--color-control-background-hover);
    color: var(--color-control-hover);
    border-bottom-color: var(--color-control-divider);
}

.leaflet-bar a:focus {
    color: var(--color-control);
}

.leaflet-bar a.leaflet-disabled {
    color: var(--color-control-disabled);
    background-color: var(--color-control-background); // todo: special disabled background color #f4f4f4 ?
}

.leaflet-bar .control-disabled, .leaflet-bar .control-disabled:focus {
    color: var(--color-control-disabled);
    // TODO: is this even used?
}

.leaflet-bottom .leaflet-control-scale {
    margin-bottom: 10px;
    margin-left: 10px;

    > .leaflet-control-scale-line {
        background-color: var(--color-attribution-background);
        color: var(--color-foreground);
        border-color: var(--color-foreground);
    }
}


/* fix for firefox */
.leaflet-fade-anim .leaflet-tile, .leaflet-zoom-anim .leaflet-zoom-animated {
    will-change: auto !important;
}

.c3nav-grid {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    line-height: 1;
    font-size: 16px;
    font-weight: bold;
    pointer-events: none;
    color: var(--color-grid-text);
}

.c3nav-grid-row, .c3nav-grid-column {
    position: absolute;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-style: solid;
    border-color: var(--color-grid-lines);
    overflow: hidden;
}

.c3nav-grid-row {
    left: 0;
    right: 0;
    border-width: 1px 0 0;
}

.c3nav-grid-row span {
    padding: 0 5px;
}

@media (max-width: 500px) {
    .c3nav-grid span:last-child {
        display: none;
    }
}

.c3nav-grid-column {
    top: 0;
    bottom: 0;
    flex-direction: column;
    border-width: 0 0 0 1px;
}

.c3nav-grid-column span {
    padding: 5px 0;
}


#modal {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background-color: var(--color-modal-backdrop);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 300ms;
    pointer-events: none;
}

#modal.show {
    opacity: 1;
    pointer-events: auto;
}

#modal-content {
    box-shadow: var(--color-shadow) 0 0 var(--shadow-size);
    border: 2px solid var(--color-modal-border);
    border-radius: var(--border-radius);
    background-color: var(--color-background);
    width: 380px;
    overflow: auto;
    -ms-scroll-chaining: none;
    overscroll-behavior: contain;
    position: relative;
}

#modal-content-inner {
    overflow: auto;
    padding: 20px;
    height: min-content;
    min-height: 150px;
    max-height: 95vh;
    max-width: 95vw;
}

#modal.loading #modal-content {
    position: relative;

    > .loader {
        display: block;
        mask-position: center;
    }
}

#close-modal {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 30px;
    padding: 0;
    color: var(--color-button);
}

#close-modal:hover {
    color: var(--color-button-hover);
}

.share-ui {
    text-align: center;
}

.share-ui h3 {
    text-align: left;
    margin: 0;
}

.share-ui img {
    width: 100%;
    max-width: 50vh;
}

.share-ui input {
    margin: 0;
}

.share-ui p button {
    margin-top: 10px;
    margin-bottom: 0;
}

body:not(.mobileclient) .share-ui p {
    display: none;
}

main > .share-ui, #reload-msg, #app-ad, main > .theme-selection {
    display: none;
}


ul.errorlist {
    margin-bottom: 0.5rem;
    color: red;
    list-style-type: none;
}

ul.messages {
    list-style-type: none;
    margin: 0 0 1.0rem;
}

ul.messages li {
    padding: 1.0rem;
    border-radius: 0.4rem;
    pointer-events: auto;

    --message-color-bg: var(--color-background);
    --message-color-fg: var(--color-foreground);
    --message-color-border: var(--message-color-fg);
    --message-color-shadow: var(--message-color-fg);

    color: var(--message-color-fg);
    //box-shadow: var(--message-color-shadow) 0 0 calc(var(--shadow-size) * 3), inset var(--message-color-shadow) 0 0 var(--shadow-size);
    //border: 2px solid var(--message-color-border);
    border: 0.1rem solid var(--message-color-border);
    background-color: var(--message-color-bg);
}

ul.messages li.alert-info {
    --message-color-fg: #006688;
    --message-color-bg: #DDE4FF;
    --message-color-border: #006688;
}

ul.messages li.alert-success {
    --message-color-fg: #338800;
    --message-color-bg: #E4FFDD;
    --message-color-border: #339900;
}

ul.messages li.alert-warning {
    --message-color-fg: #CC6600;
    --message-color-bg: #FFFFDD;
    --message-color-border: #FF9900;
}

ul.messages li.alert-danger {
    --message-color-fg: #CC0000;
    --message-color-bg: #FFEEEE;
    --message-color-border: #CC0000;
}

.app-ads {
    position: absolute;
    z-index: 10;
    bottom: 0;
    right: 0;
    left: 0;
    padding: 0;
    text-align: center;
    display: none;
}

.app-ads div {
    background-color: var(--color-background);
    box-shadow: 0 0 var(--shadow-size) var(--color-shadow);
    border-radius: var(--border-radius-small);
    overflow: hidden;
    display: inline-block;
    margin: 0 10px 25px;
    padding: 10px;
    vertical-align: middle;
}

.app-ads .close {
    float: right;
    color: inherit;
    line-height: 16px;
    margin-left: 10px;
}

#messages {
    z-index: 5;
    position: absolute;
    top: -20px;
    width: 100vw;
    padding: 10px;
    pointer-events: none;
}

.mobileclient #messages {
    top: 0;
}

#messages:empty {
    display: none;
}

#messages ul.messages {
    margin: auto;
    max-width: 700px;
}

#messages ul.messages .close {
    float: right;
    color: inherit;
}

.search-form input {
    max-width: 400px;
    vertical-align: top;
    margin-right: 10px;
}

.filter-form {
    margin-bottom: 0;
}

.filter-form input, .filter-form select {
    width: auto;
    vertical-align: top;
    margin-right: 10px;
}

.filter-form input[type=number] {
    width: 100px;
}

.columns {
    display: flex;
    width: 100%;
}

.columns > div {
    padding-right: 10px;
    flex-grow: 1;
}

.columns > div > h4:first-child {
    margin-top: 0;
}

.columns form {
    margin-bottom: 0;
}

main.control p {
    margin-bottom: 1.0rem;
}

main.control h4, main.control h2 {
    margin-bottom: 0.8rem;
}

main.control h4 {
    margin-top: 2.5rem;
}

main.control form tr > * {
    white-space: nowrap;
}

main.control select[multiple] {
    display: block;
    width: 300px;
    height: 100px;
}

.button-cell {
    padding-top: 4px;
    padding-bottom: 4px;
    text-align: right;
}

.button-cell button, .button-cell .button, .button-cell form {
    margin: 0;
}

.input-cell {
    padding-top: 6px;
    padding-bottom: 6px;
}

.input-cell input, .input-cell select {
    margin: 0;
}

main .narrow {
    max-width: 400px;
    margin: auto;
}

main .narrow p, main .narrow form, main .narrow button {
    margin-bottom: 1.0rem;
}

main .narrow form button, main .narrow form .button {
    width: 100%;
}

main form, #modal form {
    > p {
        margin-bottom: 15px;

        > :last-child {
            margin-bottom: 0;
        }
    }

    .helptext {
        display: block;
        margin-top: -15px;
        font-style: italic;
        color: var(--color-helptext);
    }

    input, textarea {
        border: 1px solid var(--color-border);
    }

    textarea {
        resize: none;
        height: 100px;
        color: var(--color-foreground);
    }

    select[multiple] {
        height: 100px;

        option {
            color: var(--color-foreground);
        }
    }
}


.user-permissions-form label {
    font-weight: 400;
    width: auto;
    display: inline;
}

.fields {
    display: flex;
    align-items: center;
}

.fields .field {
    flex-grow: 1;
}

.fields .field > * {
    width: 100%;
    margin: 0;
}

.fields .field input {
    margin: 0;
}

.fields .field:not(:first-child) {
    margin-left: 10px;
}

@media (max-width: 500px) {
    .fields {
        flex-direction: column;
        align-items: stretch;
    }
    .fields .field:not(:first-child) {
        margin-left: 0;
        margin-top: 10px;
    }
}

button + button {
    margin-left: 5px;
}

.red {
    color: #9c0900;
}

.green {
    color: #28b62c;
}

.material-symbols {
    text-transform: none !important;
}

.helptext {
    display: block;
    margin-top: -1rem;
    font-style: italic;
    margin-bottom: 0.5rem;
    font-size: 80%;
}

.smalltable {
    font-size: 80%;

    td, th {
        padding: 2px;
    }
}

table td select:last-child {
    margin-bottom: 0;
}


@keyframes blinking {
    0%, 49% {
        color: #4000ff;
    }
    50%, 100% {
        color: #d900ff;
    }
}

blink {
    animation-name: blinking;
    animation-iteration-count: infinite;
    animation-timing-function: cubic-bezier(.5, 0, 1, 1);
    animation-duration: 1.7s;
}

.leaflet-control-container {
    > .leaflet-bottom.leaflet-right {
        max-height: 100%;
        display: flex;
        flex-direction: column;
        flex-wrap: wrap-reverse;
        align-items: end;
        justify-content: end;
    }
}

@media screen and (max-width: 320px) {
    header {
        height: 40px;
    }

    header h1 a {
        height: 30px;
    }

    header #user {
        font-size: 0.8em;
    }

    .leaflet-touch .leaflet-control-levels a, .leaflet-touch .leaflet-control-levels a:hover, .leaflet-touch .leaflet-bar a, .leaflet-touch .leaflet-bar a:hover {
        width: 22px;
        height: 22px;
        line-height: 22px;
        min-width: 22px;
        max-width: 22px;
    }

    #sidebar #search {
        min-height: 40px;
        min-width: 40px;
    }

    .location {
        height: 40px;
    }

    main:not([data-view^="route"]) #origin-input, #search.loading #destination-input {
        margin-bottom: -40px;
    }

    .locationinput input {
        height: 40px;
        padding-left: 40px;
    }

    .locationinput small {
        left: 40px;
        top: 22px;
    }

    #search .locationinput button {
        top: 4px;
        font-size: 32px;
        width: 32px;
        height: 32px;
    }

    .location .icon {
        font-size: 32px;
        top: 5px;
        left: 5px;
    }

    #autocomplete .location span {
        line-height: 1;
    }

    section.details > .details-head {
        padding: 7px 6px 4px;
    }

    #search button, .leaflet-popup button, .details-head .button, .buttons.details-buttons button, .buttons.details-buttons .button {
        font-size: 1rem;
    }

    #route-dots {
        font-size: 20px;
        top: 40px;
        left: 21px;
    }
}

[data-embed] .leaflet-top.leaflet-right {
    margin-top: 48px;
}

.leaflet-control-expanding {
    background-clip: padding-box;

    &.leaflet-control-expanded > .collapsed-toggle {
        display: none;
    }

    > .collapsed-toggle {
        display: block;
        width: 26px;
        height: 26px;
        line-height: 26px;
        text-align: center;
        font-family: 'Material Symbols Outlined';
        font-size: 26px;

        color: var(--color-control);

        .leaflet-touch & {
            width: 30px;
            height: 30px;
        }
    }

    > .pin-toggle {
        display: none;
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        color: var(--color-pin);
        font-size: 1.5rem;
        width: 2.5rem;
        height: 2.5rem;
        line-height: 2.2rem;
        border-radius: var(--border-radius-leaflet-control);
        text-align: center;
        cursor: pointer;
        background: var(--color-pin-background);
        border: 1px solid var(--color-pin-border);
        box-shadow: inset var(--color-shadow) 0 0 var(--shadow-size);


        &.active {
            background: var(--color-pin-background-active);
            color: var(--color-pin-active);
            border-color: var(--color-pin-border-active);
        }

        &:hover {
            color: var(--color-pin-hover);
            background: var(--color-pin-background-hover);
            border-color: var(--color-pin-border-hover);
        }
    }

    &.leaflet-control-expanded > .pin-toggle {
        display: block;
        .leaflet-touch & {
            display: none;
        }
    }

    > .leaflet-control-expanding-content {
        padding: 1rem 4rem 1rem 1rem;

        .leaflet-touch & {
            padding: 1rem;
        }
    }

    &:not(.leaflet-control-expanded) > .leaflet-control-expanding-content {
        display: none;
    }
}

.leaflet-control-key > .leaflet-control-expanding-content {
    display: grid;
    gap: 1rem;
    grid-template-columns: 2rem 1fr;

    > .key {
            display: grid;
            grid-column: span 2;
            grid-template-columns: subgrid;
            line-height: 2rem;

            > .key-color {
                border-radius: var(--border-radius-small);
                width: 2rem;
                height: 2rem;
                box-shadow: var(--color-foreground) 0 0 calc(var(--shadow-size) / 2), inset var(--color-foreground) 0 0 2px;
            }
        }
}

.leaflet-control-overlays > .leaflet-control-expanding-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;

    .overlay-group {
        display: flex;
        flex-direction: column;
        h4 {
            margin-top: 0;
            margin-bottom: 0;
            cursor: pointer;

            &::before {
                font-family: 'Material Symbols Outlined';
                content: 'arrow_right';
                vertical-align: middle;
            }
        }

        label {
            margin-left: 3ch;
        }
    }

    .overlay-group.expanded h4::before {
        content: 'arrow_drop_down';
    }

    .overlay-group:not(.expanded) label {
        height: 0;
        overflow: hidden;
        margin-top: 0;
        margin-bottom: 0;
    }

    label {
        cursor: pointer;
        margin-bottom: 0;
    }

    input[type=checkbox] {
        margin-right: 0.5rem;
        margin-bottom: 0;
    }
}

.leaflet-control-quests > .leaflet-control-expanding-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;

    h4 {
        margin: 0;
    }

    label {
        cursor: pointer;
        margin-bottom: 0;
    }

    input[type=checkbox] {
        margin-right: 0.5rem;
        margin-bottom: 0;
    }
}


.leaflet-top.leaflet-right {
    z-index: 2000;
}


@media (max-width: 500px) {
    :root {
        --control-container-minus-size: 100px;
    }
    main[data-view=search] {
        --control-container-minus-size: 70px;
    }
    main[data-view^=route] {
        --control-container-minus-size: 160px;
    }


    .leaflet-control-container > .leaflet-bottom.leaflet-right {
        max-height: calc(100% - var(--control-container-minus-size) - 50px);
    }

    .leaflet-top.leaflet-right {
        margin-top: var(--control-container-minus-size);
    }
}

.data-overlay-popup {
    .leaflet-popup-content {
        margin: 0;

        > h4, a {
            margin: 8px 12px 4px;
        }

        > table {
            width: calc(100% + 2px);
            margin: 4px -2px;
            border-collapse: collapse;

            th, td {
                padding: 4px 12px;
                border: 1px solid var(--color-border);
                &:first-child {
                    border-left: 0;
                }
                &:last-child {
                    border-right: 0;
                }
            }
        }
    }
}

.location-load-info {
    transform: translateX(-50%) translateY(150%);
    border: 1px solid var(--color-overlay-background);
    margin: 2px auto auto;
    width: 40px;
    height: 8px;
    > .load-indicator {
        --location-load-color: red;
        --location-load-color: color-mix(in hsl, green, red var(--location-load-value));
        display: block;
        width: 100%;
        height: 100%;
        appearance: none;
        border: 2px solid var(--location-load-color);
        background: white;

        &::after {
            content: '';
            display: block;
            height: 100%;
            width: var(--location-load-value);
            background: var(--location-load-color);
        }
    }
}

.symbol-icon, .text-icon {
    --icon-color: var(--color-primary);
    > span {
        display: inline-block;
        width: 30px;
        height: 30px;
        line-height: 30px;
        text-align: center;
        font-size: 22px;
        background-color: white;
        color: var(--icon-color);
        border-radius: 100%;
        box-shadow: 0 0 0 5px color-mix(in srgb, transparent, var(--icon-color) 60%);

        transition: color, background-color 150ms ease-in-out;

        cursor: default;
    }

    &.symbol-icon {
        font-family: 'Material Symbols Outlined';
    }

    &.symbol-icon-interactive, &.text-icon-interactive {
        > span {
            cursor: pointer;

            &:hover {
                background-color: var(--icon-color);
                color: white;
            }
        }
    }

    &.symbol-icon-empty {
        > span {
            width: 14px;
            height: 14px;
            line-height: 14px;
            font-size: 10px;
        }
    }
}

.marker-cluster {
    span {
        display: inline-block;
        width: 30px;
        height: 30px;
        line-height: 30px;
        text-align: center;
        background-color: white;
        color: var(--cluster-marker-color);
        font-weight: bold;
        border-radius: 100%;

        box-shadow: 0 0 0 5px color-mix(in srgb, transparent, var(--cluster-marker-color) 60%);

        transition: color, background-color 150ms ease-in-out;

        cursor: pointer;

        &:hover {
            background-color: var(--cluster-marker-color);
            color: white;
        }
    }
}

.beacon-quest-scanner {
    margin-bottom: 1rem;
}

.ap-name-bssid-result, .beacon-quest-scanner > table {
    display: block;
    max-height: 30vh;
    overflow: scroll;
    border-radius: 4px;
    border: 1px solid gray;
    padding: 4px 0;
    box-shadow: inset 0 0 1px gray;

    thead {
        border-bottom: 1px solid gray;
    }

    td, th {
        padding: 0 8px;
        border: none;
        font-size: 0.9em;
    }
}