/* Travel Journal - mobile first, one stylesheet for login and app. */

:root {
    --bg: #eef1f5;
    --surface: #ffffff;
    --surface-2: #f6f8fa;
    --text: #17202b;
    --muted: #667385;
    --border: #dfe4ea;
    --accent: #1f6f5c;
    --accent-strong: #175546;
    --accent-soft: #e4f1ed;
    --danger: #b3261e;
    --danger-soft: #fbeceb;
    --shadow: 0 2px 10px rgba(20, 30, 45, 0.1);
    --shadow-lg: 0 12px 32px rgba(20, 30, 45, 0.22);
    --radius: 12px;
    --radius-sm: 8px;
    --sheet-peek: 64px;
    --tap: 44px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12171d;
        --surface: #1b222b;
        --surface-2: #222b35;
        --text: #e9edf2;
        --muted: #9aa7b6;
        --border: #303b47;
        --accent: #4cbfa2;
        --accent-strong: #6ad3b7;
        --accent-soft: #1f3630;
        --danger: #ef7b73;
        --danger-soft: #3a2422;
        --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.25;
}

/* ---------------------------------------------------------------- buttons */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--tap);
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    touch-action: manipulation;
}

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

.button:active {
    transform: translateY(1px);
}

.button:focus-visible,
.field__input:focus-visible,
.icon-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.button--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.button--primary:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}

.button--danger {
    background: var(--danger-soft);
    border-color: transparent;
    color: var(--danger);
}

.button--ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}

.button--ghost:hover {
    color: var(--text);
    border-color: var(--border);
}

.button--block {
    width: 100%;
}

.button--small {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 0.9rem;
}

.button[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--tap);
    min-height: var(--tap);
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

/* `hidden` has to win over the display above, e.g. for the panel back button on the top level. */
.icon-button[hidden],
.button[hidden] {
    display: none;
}

/* ----------------------------------------------------------------- fields */

.field {
    display: block;
    margin-bottom: 14px;
}

.field__label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.field__input {
    display: block;
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

textarea.field__input {
    min-height: 96px;
    resize: vertical;
}

.field-row {
    display: grid;
    gap: 0 12px;
    grid-template-columns: 1fr 1fr;
}

/* ------------------------------------------------------------ date picker */

.datepicker {
    position: relative;
}

.datepicker .field__input {
    padding-right: 42px;
}

.datepicker__toggle {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: var(--tap);
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--muted);
    cursor: pointer;
}

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

.datepicker__popup {
    position: fixed;
    z-index: 2200;
    width: 292px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.datepicker__tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
    margin-bottom: 10px;
    padding: 3px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.datepicker__tab {
    padding: 6px 0;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
}

.datepicker__tab--active {
    background: var(--surface);
    box-shadow: var(--shadow);
    color: var(--text);
}

.datepicker__nav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-bottom: 8px;
}

.datepicker__title {
    flex: 1;
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    text-align: center;
}

.datepicker__navbtn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 1rem;
    cursor: pointer;
}

.datepicker__navbtn:hover {
    background: var(--surface-2);
    color: var(--text);
}

.datepicker__grid--days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.datepicker__grid--wide {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.datepicker__weekday {
    padding: 4px 0;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
}

.datepicker__cell {
    padding: 0;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}

.datepicker__grid--days .datepicker__cell {
    height: 34px;
}

.datepicker__grid--wide .datepicker__cell {
    height: 40px;
}

.datepicker__cell:hover {
    background: var(--accent-soft);
}

.datepicker__cell--outside {
    color: var(--muted);
    opacity: 0.5;
}

.datepicker__cell--today {
    box-shadow: inset 0 0 0 1px var(--accent);
}

.datepicker__cell--selected {
    background: var(--accent);
    color: #fff;
}

.datepicker__cell--selected:hover {
    background: var(--accent-strong);
}

.datepicker__footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

.form-error {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 0.9rem;
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 18px;
}

/* ------------------------------------------------------------------ login */

.page--login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
}

.login {
    width: 100%;
    max-width: 360px;
}

.login__title {
    margin-bottom: 24px;
    font-size: 1.5rem;
    text-align: center;
}

.login__form {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
}

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

.page--app {
    display: flex;
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    overflow: hidden;
}

.layout {
    position: relative;
    flex: 1;
    min-height: 0;
}

.map-area {
    position: absolute;
    inset: 0;
    /* Own stacking context, so the Leaflet controls (z-index 1000) stay below the sheet and the search. */
    z-index: 0;
}

/* On phones the place search spans the width, the zoom buttons move below it. */
.map-area .leaflet-top.leaflet-left {
    top: calc(10px + var(--tap) + 6px);
}

.map {
    width: 100%;
    height: 100%;
    background: var(--surface-2);
}

/* ---------------------------------------------------------------- sidebar */

.sidebar {
    position: absolute;
    z-index: 800;
    display: flex;
    flex-direction: column;
    border-top: 1px solid var(--border);
    background: var(--surface);
    inset: auto 0 0 0;
    height: 72dvh;
    border-radius: 16px 16px 0 0;
    box-shadow: var(--shadow-lg);
    transform: translateY(calc(100% - var(--sheet-peek)));
    transition: transform 0.25s ease;
}

.sidebar--open {
    transform: translateY(0);
}

.sidebar__grip {
    display: block;
    width: 100%;
    height: 22px;
    flex: 0 0 auto;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.sidebar__grip::before {
    display: block;
    width: 42px;
    height: 4px;
    margin: 9px auto 0;
    border-radius: 2px;
    background: var(--border);
    content: "";
}

.panel-header {
    display: flex;
    height: 42px;
    flex: 0 0 auto;
    align-items: center;
    gap: 4px;
    padding: 0 12px 0 4px;
}

.panel-header__back {
    font-size: 0.9rem;
    color: var(--accent);
}

.panel-header__title {
    overflow: hidden;
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Logout lives in the panel head, there is no top bar. */
.panel-header__logout {
    flex: 0 0 auto;
    margin-left: auto;
}

.panel {
    flex: 1;
    padding: 4px 16px calc(24px + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ------------------------------------------------------------ panel parts */

.section {
    margin-bottom: 22px;
}

.section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.section__title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.meta {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.875rem;
}

.text {
    margin: 0 0 8px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.empty {
    padding: 14px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-size: 0.9rem;
    text-align: center;
}

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

.list__item {
    display: flex;
    width: 100%;
    min-height: var(--tap);
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.list__item:hover {
    border-color: var(--accent);
    background: var(--surface-2);
}

.list__item--active {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.list__index {
    display: flex;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
}

.list__body {
    min-width: 0;
    flex: 1;
}

.list__title {
    overflow: hidden;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list__meta {
    color: var(--muted);
    font-size: 0.82rem;
}

.list__chevron {
    color: var(--muted);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.actions .button {
    flex: 1 1 auto;
}

/* ------------------------------------------------------------ trip filter */

.filter {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.filter .field__input {
    min-width: 0;
}

.filter__search {
    flex: 1 1 auto;
}

.filter__year {
    flex: 0 0 auto;
    width: auto;
    padding-right: 28px;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
        linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

.filter__clear {
    flex: 0 0 auto;
    min-width: var(--tap);
    padding: 0 12px;
    color: var(--muted);
}

.filter__summary {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 0.82rem;
}

.filter__summary[hidden] {
    display: none;
}

.empty__text {
    margin: 0 0 10px;
}

/* ---------------------------------------------------------------- gallery */

.grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, 1fr);
}

@media (min-width: 520px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.tile {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
}

.tile__media {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tile__badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 7px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.72rem;
}

.tile__caption {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 14px 8px 6px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
    color: #fff;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

/* --------------------------------------------------------------- lightbox */

.lightbox {
    position: fixed;
    z-index: 2000;
    display: grid;
    background: rgba(8, 12, 18, 0.94);
    inset: 0;
    grid-template-rows: 1fr auto;
    grid-template-columns: 1fr;
}

.lightbox[hidden] {
    display: none;
}

.lightbox__stage {
    display: flex;
    min-height: 0;
    align-items: center;
    justify-content: center;
    padding: 48px 8px 8px;
    grid-row: 1;
    grid-column: 1;
}

.lightbox__stage img,
.lightbox__stage video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.lightbox__close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    min-width: var(--tap);
    min-height: var(--tap);
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
}

.lightbox__nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: none;
    width: 52px;
    height: 52px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    transform: translateY(-50%);
    cursor: pointer;
}

.lightbox__nav--prev {
    left: 10px;
}

.lightbox__nav--next {
    right: 10px;
}

.lightbox__bar {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    grid-row: 2;
    grid-column: 1;
}

.lightbox__caption {
    margin: 0 0 2px;
    overflow-wrap: anywhere;
}

.lightbox__origin {
    margin: 0;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.85rem;
}

/*
 * Says what is happening only while it happens, over the picture itself. A
 * permanent line in the bar would explain the same thing on every single photo.
 */
.lightbox__flash {
    position: absolute;
    top: 64px;
    left: 50%;
    z-index: 3;
    margin: 0;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%);
    opacity: 1;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.lightbox__flash[hidden] {
    display: none;
}

.lightbox__flash--fading {
    opacity: 0;
}

/* Only the downscaled copy is on screen, the original is one tap away. */
.lightbox__stage img.is-preview {
    cursor: zoom-in;
}

.lightbox__buttons {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
}

.lightbox__buttons .button {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.25);
}

.lightbox__buttons .button:hover {
    background: rgba(255, 255, 255, 0.12);
}

.lightbox__counter {
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.lightbox__admin {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* --------------------------------------------------------- shuffle screen */

.shuffle {
    position: fixed;
    z-index: 2000;
    display: grid;
    background: rgba(8, 12, 18, 0.96);
    inset: 0;
    grid-template-rows: 1fr auto;
    grid-template-columns: 1fr;
}

.shuffle[hidden] {
    display: none;
}

.shuffle__top {
    position: absolute;
    top: 8px;
    right: 8px;
    left: 8px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.shuffle__mix {
    border-color: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.shuffle__mix:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.shuffle__close {
    min-width: var(--tap);
    min-height: var(--tap);
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
}

.shuffle__stage {
    display: flex;
    min-height: 0;
    align-items: center;
    justify-content: center;
    padding: 56px 8px 8px;
    grid-row: 1;
    grid-column: 1;
}

.shuffle__image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.shuffle__image--ready {
    opacity: 1;
}

.shuffle__message {
    margin: 0;
    padding: 0 16px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

/* The arrows are the way through the deck, so they stay on phones as well. */
.shuffle__nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 52px;
    height: 52px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    transform: translateY(-50%);
    cursor: pointer;
}

.shuffle__nav:hover {
    background: rgba(255, 255, 255, 0.26);
}

.shuffle__nav--prev {
    left: 10px;
}

.shuffle__nav--next {
    right: 10px;
}

.shuffle__bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    /* Room on the right for the small map, which floats above this bar. */
    padding: 12px 154px calc(14px + env(safe-area-inset-bottom)) 16px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    grid-row: 2;
    grid-column: 1;
}

.shuffle__info {
    min-width: 0;
    flex: 1;
}

.shuffle__caption {
    margin: 0 0 2px;
    overflow-wrap: anywhere;
}

.shuffle__origin {
    margin: 0;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.85rem;
    text-overflow: ellipsis;
}

.shuffle__counter {
    display: inline-block;
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- mini map */

/* Floats in the corner instead of sitting in the bar, so the photo keeps the
   full height of the screen. */
.minimap {
    position: absolute;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 3;
    width: 132px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.minimap[hidden] {
    display: none;
}

.minimap__map {
    height: 92px;
    background: var(--surface-2);
}

/* Leaflet's attribution has to stay, it is just scaled down to the small map. */
.minimap__map .leaflet-control-attribution {
    padding: 0 3px;
    font-size: 8px;
    line-height: 1.4;
}

.minimap__link {
    display: block;
    width: 100%;
    padding: 6px 8px;
    border: 0;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.78rem;
    overflow: hidden;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.minimap__link:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
}

/* ------------------------------------------------------------------ modal */

.modal {
    position: fixed;
    z-index: 2100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    background: rgba(8, 12, 18, 0.5);
    inset: 0;
}

.modal[hidden] {
    display: none;
}

.modal__box {
    width: 100%;
    max-width: 520px;
    max-height: 92dvh;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    border-radius: 16px 16px 0 0;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
}

.modal__title {
    margin-bottom: 16px;
    font-size: 1.1rem;
}

/* ------------------------------------------------------------ map overlay */

/* Top right, the Leaflet zoom buttons sit in the top left corner. */
/* On phones the search spans the whole width of the map, on wider screens
   it becomes a compact box in the top right corner (see media query below). */
.search {
    position: absolute;
    top: 10px;
    right: 10px;
    left: 10px;
    z-index: 700;
    display: flex;
    gap: 6px;
}

.search__input {
    min-width: 0;
    min-height: var(--tap);
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    box-shadow: var(--shadow);
}

.search__button {
    flex: 0 0 auto;
    box-shadow: var(--shadow);
}

.search-results {
    position: absolute;
    top: calc(10px + var(--tap) + 6px);
    right: 10px;
    left: 10px;
    z-index: 700;
    max-height: 46dvh;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
}

.search-results[hidden] {
    display: none;
}

.search-result-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-result-row .button {
    flex: 0 0 auto;
    margin-right: 6px;
}

.search-result {
    display: block;
    width: 100%;
    min-width: 0;
    flex: 1;
    min-height: var(--tap);
    padding: 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.search-result:hover {
    background: var(--surface-2);
}

.search-result__name {
    font-size: 0.9rem;
}

.search-result__meta {
    color: var(--muted);
    font-size: 0.78rem;
}

/* One row below the search bar, so the two never overlap. */
.pick-hint {
    position: absolute;
    top: calc(10px + var(--tap) + 8px);
    left: 50%;
    z-index: 750;
    display: flex;
    width: max-content;
    max-width: calc(100% - 20px);
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 14px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%);
}

.pick-hint[hidden] {
    display: none;
}

.pick-hint .button {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}

.map--picking {
    cursor: crosshair;
}

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

.map-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    border-radius: 50%;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.map-pin--muted {
    opacity: 0.45;
}

.map-pin--search {
    background: var(--danger);
}

/* A place outside the open trip: a translucent core in an even softer ring of
   the same colour. The ring carries no border of its own, it is the halo, the
   core keeps a light one so it stays readable over a busy map. */
.map-pin--dot {
    border: 0;
    box-shadow: none;
}

.map-pin__core {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
}

/* The mini map only ever shows one spot, its size is not set from JS. */
.map-pin--photo {
    width: 16px;
    height: 16px;
    background: var(--accent);
}

.popup__title {
    margin-bottom: 2px;
    font-size: 1rem;
    font-weight: 600;
}

.popup__meta {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.82rem;
}

.popup__text {
    margin: 0 0 10px;
    max-width: 220px;
    font-size: 0.88rem;
}

.leaflet-popup-content {
    margin: 12px 14px;
}

/* ------------------------------------------------------------------ toast */

.toast {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 50%;
    z-index: 2200;
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: 999px;
    background: var(--text);
    color: var(--surface);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%);
}

.toast[hidden] {
    display: none;
}

.toast--error {
    background: var(--danger);
    color: #fff;
}

/* --------------------------------------------------------------- progress */

.progress {
    height: 6px;
    margin-top: 10px;
    border-radius: 3px;
    background: var(--surface-2);
    overflow: hidden;
}

.progress__bar {
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width 0.15s linear;
}

.progress__label {
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.85rem;
}

/* ------------------------------------------------------------- reordering */

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

.reorder__item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.reorder__title {
    overflow: hidden;
    flex: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ------------------------------------------------- larger phones, tablets */

@media (min-width: 600px) {
    .search,
    .search-results {
        left: auto;
        width: 380px;
    }
}

/* ----------------------------------------------------- desktop and tablet */

@media (min-width: 900px) {
    .layout {
        display: grid;
        grid-template-columns: 1fr minmax(320px, 24%);
        /* Keep the single row at viewport height, otherwise it grows with the panel content and nothing scrolls. */
        grid-template-rows: minmax(0, 1fr);
    }

    .map-area {
        position: relative;
        inset: auto;
        grid-column: 1;
    }

    .sidebar {
        position: relative;
        border-top: 0;
        border-left: 1px solid var(--border);
        border-radius: 0;
        box-shadow: none;
        grid-column: 2;
        inset: auto;
        height: auto;
        min-height: 0;
        transform: none;
    }

    .sidebar__grip {
        display: none;
    }

    .map-area .leaflet-top.leaflet-left {
        top: 0;
    }

    .panel-header {
        height: 52px;
        padding-top: 8px;
    }

    .lightbox {
        grid-template-rows: 1fr auto;
    }

    .lightbox__nav {
        display: block;
    }

    .lightbox__stage {
        padding: 56px 76px 8px;
    }

    .shuffle__stage {
        padding: 64px 76px 8px;
    }

    .shuffle__bar {
        padding-right: 264px;
    }

    .minimap {
        width: 240px;
    }

    .minimap__map {
        height: 160px;
    }

    .minimap__link {
        font-size: 0.85rem;
    }

    .modal {
        align-items: center;
        padding: 24px;
    }

    .modal__box {
        border-radius: var(--radius);
    }

    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1400px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .sidebar,
    .shuffle__image,
    .progress__bar {
        transition: none;
    }
}

body.no-scroll {
    overflow: hidden;
}
