.rp {
    --rp-border: color-mix(in srgb, currentColor 18%, transparent);
    --rp-soft: color-mix(in srgb, currentColor 6%, transparent);
    --rp-accent: #2563eb;
    --rp-l0: #16a34a;
    --rp-l1: #d97706;
    --rp-l2: #ea580c;
    --rp-l3: #dc2626;
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    grid-template-areas:
        "form map"
        "results map";
    gap: 1rem;
    align-items: start;
}

.rp__form { grid-area: form; }
.rp__results { grid-area: results; display: grid; gap: 1rem; }

.rp__map-wrap {
    grid-area: map;
    position: sticky;
    top: 1rem;
    border: 1px solid var(--rp-border);
    border-radius: 16px;
    overflow: hidden;
}

.rp-map {
    height: min(80vh, 780px);
    min-height: 480px;
    background: #dbe5ef;
}

.rp-panel {
    border: 1px solid var(--rp-border);
    border-radius: 16px;
    padding: 1rem;
    background: var(--rp-soft);
}

.rp-panel h3 {
    margin: 0;
    font-size: 1.05rem;
}

.rp-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.rp-hint {
    margin: 0.4rem 0 0;
    font-size: 0.82rem;
    opacity: 0.72;
}

/* stops editor */
.rp-stops {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.rp-stop {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.5rem;
}

.rp-stop__badge {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    background: #2563eb;
}

.rp-stop--start .rp-stop__badge { background: var(--rp-l0); }
.rp-stop--end .rp-stop__badge { background: var(--rp-l3); }

.rp-stop__field { position: relative; }
.rp-stop__actions { display: flex; gap: 0.25rem; }

.rp-input {
    width: 100%;
    min-height: 42px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--rp-border);
    border-radius: 10px;
    font: inherit;
    box-sizing: border-box;
}

.rp-input:focus-visible {
    outline: 2px solid var(--rp-accent);
    outline-offset: 1px;
}

.rp-input.is-invalid {
    border-color: var(--rp-l3);
}

.rp-suggest {
    position: absolute;
    z-index: 1100;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--rp-border);
    border-radius: 10px;
    background: var(--card-strong, var(--card, #fff));
    color: var(--text-color, inherit);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.rp-suggest[hidden] { display: none; }

.rp-suggest li {
    padding: 0.5rem 0.65rem;
    border-radius: 8px;
    cursor: pointer;
}

.rp-suggest li:hover,
.rp-suggest li.is-active {
    background: var(--rp-soft);
    outline: 1px solid var(--rp-border);
}

.rp-icon-btn {
    display: inline-grid;
    place-items: center;
    min-width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--rp-border);
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
}

.rp-icon-btn:hover,
.rp-icon-btn:focus-visible {
    background: var(--rp-soft);
    border-color: var(--rp-accent);
}

.rp-link-btn {
    padding: 0.25rem 0;
    border: 0;
    background: none;
    color: var(--rp-accent);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.rp-link-btn:hover { text-decoration: underline; }

.rp-add {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0 0.9rem 36px;
}

.rp-add .rp-hint { margin: 0; }
.rp-add [hidden] { display: none; }

.rp-departure label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.rp-departure__row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.rp-submit {
    width: 100%;
    min-height: 46px;
}

.rp-submit:disabled {
    opacity: 0.6;
    cursor: progress;
}

.rp-status {
    margin-top: 0.75rem;
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--rp-border);
    font-size: 0.92rem;
}

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

.rp-status.is-error {
    border-color: var(--rp-l3);
    color: var(--rp-l3);
}

/* map overlays */
.rp-map-loading {
    position: absolute;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    background: rgba(15, 23, 42, 0.45);
    color: #fff;
    font-weight: 600;
}

.rp-map-loading[hidden] { display: none; }

.rp-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: rp-spin 0.8s linear infinite;
}

@keyframes rp-spin { to { transform: rotate(360deg); } }

.rp-recenter {
    display: grid;
    place-items: center;
    font-size: 1.1rem;
    text-decoration: none;
}

.rp-legend {
    display: grid;
    gap: 0.2rem;
    padding: 0.5rem 0.65rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.94);
    color: #0f172a;
    font-size: 0.78rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.rp-legend span { display: flex; align-items: center; gap: 0.4rem; }
.rp-legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }

.rp-marker { background: none; border: 0; }

.rp-pin {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}

.rp-pin--start { background: var(--rp-l0); }
.rp-pin--via { background: #2563eb; }
.rp-pin--end { background: var(--rp-l3); }

.rp-wx {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #64748b;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    font-size: 0.95rem;
}

.rp-wx--l0 { border-color: var(--rp-l0); }
.rp-wx--l1 { border-color: var(--rp-l1); }
.rp-wx--l2 { border-color: var(--rp-l2); }
.rp-wx--l3 { border-color: var(--rp-l3); }

/* results */
.rp__results[hidden] { display: none; }
.rp-routes { display: grid; gap: 0.5rem; }

.rp-route {
    display: grid;
    gap: 0.25rem;
    padding: 0.7rem 0.85rem;
    border: 2px solid var(--rp-border);
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.rp-route:hover { border-color: var(--rp-accent); }
.rp-route.is-selected { border-color: var(--rp-accent); background: var(--rp-soft); }
.rp-route__title { font-weight: 700; }
.rp-route__meta { font-size: 0.9rem; opacity: 0.85; }
.rp-route__rain { font-size: 0.82rem; opacity: 0.8; }

.rp-tag {
    display: inline-block;
    margin-left: 0.25rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: var(--rp-soft);
    border: 1px solid var(--rp-border);
    font-size: 0.72rem;
    font-weight: 600;
}

.rp-risk {
    justify-self: start;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    color: #fff;
    font-size: 0.78rem;
    font-weight: 700;
    background: #64748b;
}

.rp-risk--l0 { background: var(--rp-l0); }
.rp-risk--l1 { background: var(--rp-l1); }
.rp-risk--l2 { background: var(--rp-l2); }
.rp-risk--l3 { background: var(--rp-l3); }

.rp-verdict {
    margin-top: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 10px;
    border-left: 5px solid #64748b;
    background: var(--rp-soft);
    font-weight: 600;
}

.rp-verdict--l0 { border-left-color: var(--rp-l0); }
.rp-verdict--l1 { border-left-color: var(--rp-l1); }
.rp-verdict--l2 { border-left-color: var(--rp-l2); }
.rp-verdict--l3 { border-left-color: var(--rp-l3); }

.rp-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.rp-nav__btn {
    flex: 1 1 calc(50% - 0.5rem);
    justify-content: center;
    text-align: center;
    cursor: pointer;
}

.rp-timeline {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: grid;
    gap: 0.4rem;
}

.rp-tl {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr);
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--rp-border);
    border-left: 5px solid #64748b;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.rp-tl:hover { background: var(--rp-soft); }
.rp-tl--l0 { border-left-color: var(--rp-l0); }
.rp-tl--l1 { border-left-color: var(--rp-l1); }
.rp-tl--l2 { border-left-color: var(--rp-l2); }
.rp-tl--l3 { border-left-color: var(--rp-l3); }
.rp-tl__time { font-weight: 700; font-variant-numeric: tabular-nums; }
.rp-tl__body { display: grid; gap: 0.1rem; }
.rp-tl__detail { font-size: 0.85rem; opacity: 0.85; }
.rp-warn { color: var(--rp-l2); font-weight: 600; }
.rp-credits { margin-top: 0.75rem; }

@media (max-width: 960px) {
    .rp {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "form"
            "map"
            "results";
    }

    .rp__map-wrap { position: relative; top: auto; }
    .rp-map { height: 55vh; min-height: 340px; }
}

/* save route form (planner) */
.rp-save { display: grid; gap: 0.75rem; margin-top: 0.75rem; }
.rp-save__field { display: grid; gap: 0.3rem; font-weight: 600; }
.rp-save textarea.rp-input { resize: vertical; }

.rp-vis, .rpr-vis {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.rp-vis legend, .rpr-vis legend { padding: 0; margin-bottom: 0.35rem; font-weight: 600; }

.rp-vis__opt, .rpr-vis__opt {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--rp-border);
    border-radius: 10px;
    cursor: pointer;
}

.rp-vis__opt:has(input:checked), .rpr-vis__opt:has(input:checked) {
    border-color: var(--rp-accent);
    background: var(--rp-soft);
}

.rp-vis__opt span, .rpr-vis__opt span { display: grid; gap: 0.1rem; }
.rp-vis__opt small, .rpr-vis__opt small { opacity: 0.72; }

/* moto routes tab */
.rpr {
    --rp-border: color-mix(in srgb, currentColor 18%, transparent);
    --rp-soft: color-mix(in srgb, currentColor 6%, transparent);
    --rp-accent: #2563eb;
    --rp-l0: #16a34a;
    --rp-l3: #dc2626;
    display: grid;
    gap: 1rem;
}

.rpr-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.rpr-pills { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.rpr-pill {
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--rp-border);
    border-radius: 999px;
    color: inherit;
    text-decoration: none;
    font-weight: 600;
}

.rpr-pill.is-active, .rpr-pill:hover { border-color: var(--rp-accent); background: var(--rp-soft); }

.rpr-empty { display: grid; gap: 0.75rem; justify-items: start; }

.rpr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.rpr-card {
    display: grid;
    gap: 0.6rem;
    align-content: start;
    padding: 1rem;
    border: 1px solid var(--rp-border);
    border-radius: 16px;
    background: var(--rp-soft);
}

.rpr-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.rpr-card__head h2, .rpr-card__head h3 { margin: 0; font-size: 1.1rem; }
.rpr-card__head a { color: inherit; text-decoration: none; }
.rpr-card__head a:hover { text-decoration: underline; }

.rpr-badge {
    flex: none;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
}

.rpr-badge--public { background: var(--rp-l0); }
.rpr-badge--private { background: #64748b; }

.rpr-path { font-weight: 600; overflow-wrap: anywhere; }

.rpr-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.9rem;
    font-size: 0.88rem;
    opacity: 0.85;
}

.rpr-desc { margin: 0; font-size: 0.92rem; }
.rpr-desc--full { overflow-wrap: anywhere; }

.rpr-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.rpr-back { color: inherit; font-weight: 600; text-decoration: none; justify-self: start; }
.rpr-back:hover { text-decoration: underline; }

.rpr-detail__grid {
    display: grid;
    grid-template-columns: minmax(300px, 460px) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

.rpr-detail__main { display: grid; gap: 0.75rem; align-content: start; }
.rpr-detail__main h3 { margin: 0; font-size: 1rem; }

.rpr-stops { margin: 0; padding-left: 1.4rem; display: grid; gap: 0.25rem; }

.rpr-map {
    height: min(70vh, 620px);
    min-height: 320px;
    border: 1px solid var(--rp-border);
    border-radius: 16px;
    overflow: hidden;
    background: #dbe5ef;
}

.rpr-pin {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    background: var(--rp-accent);
}

.rpr-pin--start { background: var(--rp-l0); }
.rpr-pin--end { background: var(--rp-l3); }

.rpr-manage { border-top: 1px solid var(--rp-border); padding-top: 0.75rem; display: grid; gap: 0.75rem; }
.rpr-manage summary { cursor: pointer; font-weight: 600; }
.rpr-manage[open] summary { margin-bottom: 0.75rem; }

.rpr-form { display: grid; gap: 0.75rem; margin-bottom: 0.75rem; }
.rpr-form label { display: grid; gap: 0.3rem; font-weight: 600; }
.rpr-form input[type="text"], .rpr-form textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--rp-border);
    border-radius: 10px;
    font: inherit;
    box-sizing: border-box;
}
.rpr-vis__opt { font-weight: 400; }
.rpr-vis__opt input { width: auto; }
.rp-vis__opt input, .rpr-vis__opt input { margin-top: 0.2rem; }

.rpr-danger { color: var(--rp-l3); border-color: var(--rp-l3); }

.rpr-reviews { display: grid; gap: 0.75rem; }
.rpr-reviews h3 { margin: 0; }
.rpr-stars { display: flex; gap: 0.25rem; margin-top: 0.35rem; }
.rpr-star-btn { background: none; border: 0; padding: 0; color: #d1d5db; font-size: 1.7rem; cursor: pointer; }

.rpr-review-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.rpr-review-list li { padding: 0.75rem; border: 1px solid var(--rp-border); border-radius: 12px; display: grid; gap: 0.3rem; }

@media (max-width: 960px) {
    .rpr-detail__grid { grid-template-columns: minmax(0, 1fr); }
    .rpr-map { height: 50vh; }
}

/* shared map controls (fullscreen / satellite / my location) */
.rpm-btn {
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    text-decoration: none;
    cursor: pointer;
}

.rpm-btn.is-active { background: #2563eb; color: #fff; }

.rpm-toast {
    position: absolute;
    left: 50%;
    bottom: 1rem;
    z-index: 1000;
    transform: translateX(-50%);
    max-width: calc(100% - 2rem);
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.9);
    color: #fff;
    font-size: 0.88rem;
}

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

.rp__map-wrap:fullscreen,
.rp__map-wrap.is-fullscreen,
.rpr-map.is-fullscreen {
    border-radius: 0;
    background: #dbe5ef;
}

.rp__map-wrap.is-fullscreen,
.rpr-map.is-fullscreen {
    position: fixed;
    inset: 0;
    top: 0;
    z-index: 2000;
    width: auto;
    height: auto;
    min-height: 0;
}

.rp__map-wrap:fullscreen .rp-map,
.rp__map-wrap.is-fullscreen .rp-map {
    height: 100%;
    max-height: none;
}

/* map click popup: set start / stop / destination */
.rp-pick { display: grid; gap: 0.35rem; }

.rp-pick__btn {
    padding: 0.45rem 0.7rem;
    border: 1px solid rgba(37, 99, 235, 0.35);
    border-radius: 8px;
    background: #fff;
    color: #1e3a8a;
    font: inherit;
    font-size: 0.88rem;
    text-align: left;
    cursor: pointer;
}

.rp-pick__btn:hover { background: #eff6ff; }
