@media (min-width: 861px) and (max-width: 1199px) {
    .top {
        height: auto;
        min-height: 112px;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: auto auto;
        gap: 8px 20px;
        padding-block: 9px;
    }
    .brand {
        grid-column: 1;
        grid-row: 1;
    }
    .brand .trip-title {
        width: min(42vw, 360px);
    }
    .top-search {
        width: min(420px, 60vw);
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: center;
    }
    .top-actions {
        grid-column: 2;
        grid-row: 1;
    }
}

@media (max-width: 960px) {
    .workspace {
        grid-template-columns: minmax(0, 1fr);
    }
    .map-panel {
        position: relative;
        top: 0;
        order: -1;
    }
    #map {
        height: 380px;
    }
}
body.preview-mode .handle,
body.preview-mode .day-handle,
body.preview-mode .spot-actions,
body.preview-mode .spot-toggle,
body.preview-mode .add-place,
body.preview-mode .add-day,
body.preview-mode .day-options,
body.preview-mode .day-duplicate,
body.preview-mode .title-edit,
body.preview-mode .manage-tags {
    display: none !important;
}
body.preview-mode .date-box.editable {
    cursor: default;
    pointer-events: none;
}
body.preview-mode .date-box.editable::after {
    display: none;
}
body.preview-mode .spots {
    padding: 6px;
}
body.preview-mode .spot {
    grid-template-columns: 1fr;
    padding: 6px 8px;
    cursor: default;
}
@media (max-width: 860px) {
    .top {
        height: auto;
        min-height: 68px;
        grid-template-columns: minmax(0, 1fr) auto auto;
        gap: 8px;
        padding: 11px 16px;
    }
    .brand-meta > small {
        display: none;
    }
    .brand .trip-title {
        width: min(46vw, 260px);
        font-size: 18px;
    }
    .budget-total {
        max-width: 100px;
    }
    .currency-picker-grid { grid-template-columns: 1fr; }
    .currency-picker-arrow { justify-self: center; transform: rotate(90deg); }
    .exchange-rate-card { align-items: flex-start; flex-direction: column; gap: 6px; }
    .top-search {
        width: 38px;
        height: 38px;
        justify-content: center;
        padding: 0;
    }
    .top-search-label,
    .top-search kbd {
        display: none;
    }
    /* Keep search directly accessible and collapse file/tools actions. */
    .top-actions {
        position: relative;
    }
    .top-actions > .hamburger {
        display: grid;
        gap: 4px;
        justify-content: center;
        align-content: center;
        cursor: pointer;
        padding: 9px;
        border: 1px solid #ffffff40;
        border-radius: 4px;
        background: transparent;
    }
    .top-actions > .hamburger span {
        display: block;
        width: 20px;
        height: 2px;
        background: #fff;
        border-radius: 2px;
    }
    .top-actions > .hamburger:hover {
        background: #ffffff14;
    }
    /* Hidden until opened; when open, drop the items into a panel. */
    .top-actions .nav-menu-items {
        display: none;
    }
    .top-actions.nav-open .nav-menu-items {
        display: flex;
        position: absolute;
        right: 0;
        top: calc(100% + 8px);
        z-index: 40;
        flex-direction: column;
        align-items: stretch;
        width: min(240px, calc(100vw - 32px));
        padding: 7px;
        background: #1d2d36;
        border: 1px solid #ffffff26;
        border-radius: 8px;
        box-shadow: 0 12px 28px #0b141b66;
    }
    .top-actions.nav-open .nav-menu-items > button {
        width: 100%;
        text-align: left;
    }
    .top-actions.nav-open #exportBtn { order: -3; }
    .top-actions.nav-open #importBtn { order: -2; }
    .top-actions.nav-open .github-control { order: -1; }
    .top-actions.nav-open .github-control {
        display: flex;
    }
    .top-actions.nav-open #githubOpenBtn {
        width: 100%;
        text-align: left;
    }
    .top-actions.nav-open .github-menu {
        top: calc(100% + 6px);
        right: 0;
    }
    /* Flatten secondary actions below the three priority file/sync actions. */
    .nav-menu-items .manage-menu > summary {
        display: none;
    }
    .nav-menu-items .manage-menu-items {
        position: static;
        min-width: 0;
        padding: 0;
        background: transparent;
        border: 0;
        box-shadow: none;
        gap: 2px;
        margin-top: 4px;
        padding-top: 4px;
        border-top: 1px solid #ffffff26;
    }
    .nav-menu-items .manage-menu-items button {
        color: #fff;
        border: 0;
        padding: 9px 12px;
        font-size: 13px;
    }
    .nav-menu-items .manage-menu-items button:hover {
        background: #ffffff14;
    }
    .nav-menu-items .manage-menu-title {
        color: #bcc8c8;
    }
    .nav-menu-items .manage-menu-divider {
        background: #ffffff26;
    }
    .nav-menu-items .manage-menu-danger {
        color: #ffaaa3;
    }
    .map-bar {
        flex-wrap: wrap;
    }
    .map-bar strong {
        order: 1;
        flex: 1 1 180px;
    }
    .map-preview-btn {
        order: 2;
    }
    .route-key {
        order: 3;
        margin-right: auto;
    }
    .route-profile {
        order: 4;
    }
    .intro {
        display: block;
    }
    .intro p {
        text-align: left;
        margin-top: 10px;
    }
    .workspace {
        gap: 16px;
    }
    main {
        padding-top: 21px;
    }
    .map-foot {
        font-size: 12px;
    }
    .notes-dialog-content { padding: 16px; }
    .notes-dialog textarea,
    .trip-notes-preview { min-height: 52vh; }
    .hours-input-row {
        grid-template-columns: 1fr;
    }
    .github-dialog-content { padding: 16px; }
    .github-fields-two,
    .github-fields-ref { grid-template-columns: 1fr; }
    .github-actions button { width: 100%; }
    .change-preview-detail {
        grid-template-columns: 1fr auto minmax(0, 1fr);
    }
    .change-preview-detail b {
        grid-column: 1 / -1;
    }
    .spot-hours {
        width: 100%;
    }
    .spot-hours-detail {
        display: none;
    }
    .spot-hours.is-complete:hover .spot-hours-rail,
    .spot-hours.is-complete:focus-visible .spot-hours-rail {
        opacity: 1;
    }
    .day-schedule-body {
        padding-inline: 12px;
    }
    .day-schedule-axis,
    .day-schedule-row {
        grid-template-columns: minmax(88px, 0.8fr) minmax(150px, 2.2fr);
        gap: 8px;
    }
    .day-schedule-axis {
        grid-template-columns: minmax(88px, 0.8fr) minmax(150px, 2.2fr);
    }
}

@media (min-width: 601px) and (max-width: 860px) {
    .top {
        min-height: 112px;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-rows: auto auto;
        gap: 8px 20px;
        padding-block: 9px;
    }
    .brand .trip-title {
        width: min(55vw, 360px);
        font-size: 20px;
    }
    .top-search {
        width: min(420px, 65vw);
        height: auto;
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: center;
        justify-content: space-between;
        padding: 9px 11px;
    }
    .top-search-label,
    .top-search kbd {
        display: initial;
    }
    .top-search-label {
        display: block;
    }
    .top-actions {
        grid-column: 2;
        grid-row: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .day-head,
    .tag-bar,
    .spot-hours,
    .spot-hours-icon,
    .spot-hours-rail,
    .spot-hours-segment,
    .spot-hours-detail {
        transition: none;
    }
}
