/* =========================================================
   PUBLIC BUS LIVE - STYLES (v3)
   Palette: prairie night (deep spruce) + canola gold
   Layout: full-screen map, floating header, desktop side card,
           mobile draggable bottom sheet
   ========================================================= */

/* ===== TOKENS ===== */
:root {
    --ink: #14231c;
    --ink-2: #1e3329;
    --ink-3: #2b4639;
    --cream: #f6f2e8;
    --surface: #ffffff;
    --surface-2: #f4f1e8;
    --surface-3: #ebe6d8;
    --gold-soft: #fff1c9;
    --gold: #f2b632;
    --gold-ink: #3a2a00;
    --sky: #1f7fd1;
    --text: #18201c;
    --muted: #5f6a63;
    --line: #e2dccb;
    --danger: #d7263d;
    --danger-bg: #fde3e5;
    --ok: #2e8b57;
    --shadow-sm: 0 1px 3px rgba(20, 35, 28, 0.12), 0 1px 2px rgba(20, 35, 28, 0.08);
    --shadow-md: 0 6px 20px rgba(20, 35, 28, 0.16);
    --shadow-lg: 0 18px 50px rgba(20, 35, 28, 0.28);
    --radius: 16px;
    --panel-w: 384px;
    --gap: 12px;
    --header-h: 56px;
    --sheet-h: 148px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: "JetBrains Mono", ui-monospace, monospace;
}

/* ===== BASE ===== */
* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--surface-3);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    overscroll-behavior: none;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 2px;
}

svg {
    flex: 0 0 auto;
}

/* ===== MAP ===== */
.rb-map {
    position: fixed;
    inset: 0;
    background: #f2f3f0;
    z-index: 0;
}

.leaflet-control-attribution {
    font-size: 10px;
    background: rgba(255, 255, 255, 0.75) !important;
    border-radius: 6px 0 0 0;
}

.leaflet-control-zoom {
    border: 0 !important;
    box-shadow: var(--shadow-md) !important;
    border-radius: 12px !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    color: var(--ink) !important;
    font-size: 20px !important;
}

.leaflet-top.leaflet-right {
    top: calc(var(--header-h) + var(--gap) * 2 + var(--safe-top));
    right: 4px;
}

/* ===== FLOATING HEADER ===== */
.rb-header {
    position: fixed;
    top: calc(var(--gap) + var(--safe-top));
    left: var(--gap);
    right: var(--gap);
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    z-index: 1000;
    pointer-events: none;
}

.rb-header > * {
    pointer-events: auto;
}

.rb-brand {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 100%;
    padding: 0 16px 0 8px;
    background: var(--surface);
    color: var(--ink);
    border-radius: 999px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    min-width: 0;
}

.rb-brand__logo {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--ink);
}

.rb-brand__logo--lg {
    width: 48px;
    height: 48px;
    border-radius: 14px;
}

.rb-brand__text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.rb-brand__name {
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.rb-status {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-status::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 6px;
    border-radius: 50%;
    background: #22c55e;
    vertical-align: 1px;
    animation: rb-blink 2s infinite;
}

.rb-status.is-error {
    color: var(--danger);
}

.rb-status.is-error::before {
    background: #ff6b57;
    animation: none;
}

@keyframes rb-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* refresh progress: thin gold line along the bottom of the brand pill */
.rb-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(242, 182, 50, 0.22);
}

.rb-progress span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--gold);
}

@keyframes rb-progress {
    from { width: 0; }
    to { width: 100%; }
}

.rb-header__actions {
    display: flex;
    gap: 8px;
}

.rb-chipbtn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
}

.rb-chipbtn:hover {
    background: var(--surface-2);
}

.rb-chipbtn--icon {
    padding: 0 12px;
    font-family: var(--mono);
    font-size: 13px;
}

/* ===== FLOATING MAP BUTTONS ===== */
.rb-fab {
    position: fixed;
    right: var(--gap);
    bottom: calc(var(--gap) + 18px);
    z-index: 950;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: bottom 0.25s ease;
}

.rb-fab__btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-md);
}

.rb-fab__btn--main {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: var(--sky);
    color: #fff;
}

/* ===== PANEL (DESKTOP CARD) ===== */
.rb-panel {
    position: fixed;
    top: calc(var(--header-h) + var(--gap) * 2 + var(--safe-top));
    left: var(--gap);
    bottom: var(--gap);
    width: var(--panel-w);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    z-index: 900;
    overflow: hidden;
}

.rb-panel__grip {
    display: none;
}

.rb-panel__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* ===== TABS ===== */
.rb-tabs {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid var(--line);
}

.rb-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 2px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    transition: background 0.15s, color 0.15s;
}

.rb-tab:hover {
    background: var(--surface-2);
}

.rb-tab.is-active {
    background: var(--gold-soft);
    color: var(--ink);
    box-shadow: inset 0 0 0 1.5px var(--gold);
}

.rb-tab.is-active svg {
    color: var(--ink);
}

.rb-pane {
    display: none;
    padding: 14px;
}

.rb-pane.is-active {
    display: block;
}

.rb-empty,
.rb-hint {
    margin: 4px 0 12px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.rb-empty {
    padding: 22px 14px;
    text-align: center;
    background: var(--surface-2);
    border-radius: 14px;
}

.rb-credit {
    padding: 12px 16px 16px;
    font-size: 11px;
    color: var(--muted);
}

/* ===== ROUTE SUMMARY ===== */
.rb-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    margin-bottom: 12px;
    background: var(--gold-soft);
    color: var(--ink);
    border-radius: 14px;
    border: 1px solid #f3d98a;
    font-size: 14px;
}

.rb-summary__label {
    display: block;
    margin-bottom: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8a6d1c;
}

.rb-summary__btn {
    flex: 0 0 auto;
    border: 0;
    border-radius: 10px;
    background: var(--ink);
    color: var(--cream);
    font-weight: 700;
    font-size: 13px;
    padding: 9px 14px;
}

.rb-mini {
    display: inline-block;
    min-width: 28px;
    margin: 2px 4px 2px 0;
    padding: 3px 6px;
    border-radius: 6px;
    font: 800 12px var(--mono);
    text-align: center;
    vertical-align: middle;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.rb-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: 3px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--danger-bg);
    color: #a3162a;
    font-size: 11px;
    font-weight: 700;
}

/* ===== ROUTE LIST ===== */
.rb-routes {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rb-route {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 54px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px 12px 8px 8px;
    transition: border-color 0.15s, background 0.15s;
}

.rb-route:hover {
    border-color: var(--ink-3);
}

.rb-route[aria-pressed="true"] {
    background: var(--surface-2);
    border-color: var(--ink);
    box-shadow: inset 4px 0 0 var(--ink);
}

.rb-route__num {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 44px;
    height: 36px;
    font: 800 15px var(--mono);
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.rb-route__name {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.rb-route__count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font: 600 12px var(--mono);
    color: var(--muted);
    white-space: nowrap;
}

.rb-route__check {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    border: 2px solid var(--line);
    color: transparent;
    font-size: 12px;
    font-weight: 800;
}

.rb-route[aria-pressed="true"] .rb-route__check {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--gold);
}

/* ===== STOP SEARCH ===== */
.rb-search {
    position: relative;
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.rb-search__icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.rb-search input {
    flex: 1;
    min-width: 0;
    height: 48px;
    font: 500 16px var(--font);
    padding: 0 14px 0 44px;
    border: 2px solid var(--line);
    border-radius: 14px;
    background: var(--surface-2);
    color: var(--text);
}

.rb-search input:focus {
    border-color: var(--ink);
    background: var(--surface);
    outline: none;
}

.rb-search button {
    height: 48px;
    border: 0;
    border-radius: 14px;
    background: var(--ink);
    color: var(--cream);
    font-weight: 700;
    padding: 0 18px;
}

.rb-results:not(:empty) {
    margin-bottom: 14px;
}

/* ===== BUTTONS ===== */
.rb-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 50px;
    margin-bottom: 12px;
    border: 0;
    border-radius: 14px;
    background: var(--gold);
    color: var(--gold-ink);
    font-weight: 700;
    font-size: 15px;
}

/* ===== STOP DETAIL ===== */
.rb-stophead {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
    margin-bottom: 12px;
    background: var(--surface-2);
    border-radius: 14px;
}

.rb-stophead__sign {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--sky);
    color: #fff;
}

.rb-stophead__main {
    flex: 1;
    min-width: 0;
}

.rb-stophead__id {
    display: inline-block;
    margin-bottom: 2px;
    font: 800 12px var(--mono);
    color: var(--muted);
}

.rb-stophead__name {
    display: block;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.3;
}

.rb-stophead__dir {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.rb-stophead__actions {
    display: flex;
    gap: 4px;
}

.rb-iconbtn,
.rb-star {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink-3);
    box-shadow: var(--shadow-sm);
}

.rb-star {
    font-size: 20px;
    line-height: 1;
    color: #c9c2ae;
}

.rb-star.is-on {
    color: var(--gold);
}

.rb-notice {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--danger-bg);
    color: #a3162a;
    font-size: 13px;
    font-weight: 600;
}

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

.rb-arrival {
    width: 100%;
    display: grid;
    grid-template-columns: 48px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 10px 10px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    text-align: left;
}

.rb-arrival:hover {
    border-color: var(--ink-3);
}

.rb-arrival__route {
    display: grid;
    place-items: center;
    height: 36px;
    font: 800 15px var(--mono);
    border-radius: 10px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.rb-arrival__line {
    font-size: 14px;
    font-weight: 700;
    min-width: 0;
}

.rb-arrival__meta {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
}

.rb-arrival__eta {
    text-align: right;
    font: 800 20px var(--mono);
    color: var(--ink);
    line-height: 1;
}

.rb-arrival__eta small {
    display: block;
    margin-top: 3px;
    font: 600 11px var(--mono);
    color: var(--muted);
}

.rb-arrival__eta--clock {
    font-size: 14px;
}

.rb-arrival__eta.is-soon {
    color: var(--danger);
}

.rb-live {
    color: var(--ok);
    font-weight: 700;
}

/* ===== GENERIC LIST (FAV / NEAR / RESULTS) ===== */
.rb-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rb-list li + li {
    margin-top: 6px;
}

.rb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 54px;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 8px 12px 8px 8px;
}

.rb-item:hover {
    border-color: var(--ink-3);
}

.rb-item__sign {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--sky);
    color: #fff;
}

.rb-item__body {
    flex: 1;
    min-width: 0;
}

.rb-item__name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

.rb-item__id {
    font: 700 12px var(--mono);
    color: var(--muted);
}

.rb-item__dist {
    flex: 0 0 auto;
    text-align: right;
    font: 600 12px var(--mono);
    color: var(--muted);
}

/* ===== MAP MARKERS: BUS ===== */
.rb-bus {
    position: relative;
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.rb-bus__heading {
    position: absolute;
    inset: 0;
    transition: transform 0.8s ease;
}

.rb-bus__heading svg {
    display: block;
    width: 48px;
    height: 48px;
}

.rb-bus__label {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font: 800 14px var(--mono);
    letter-spacing: -0.03em;
    pointer-events: none;
}

.rb-bus.is-followed::after {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    border: 3px solid var(--gold);
    animation: rb-ring 1.6s ease-out infinite;
}

@keyframes rb-ring {
    from { transform: scale(0.9); opacity: 1; }
    to { transform: scale(1.5); opacity: 0; }
}

.rb-bus--sm {
    transform: scale(0.72);
}

/* ===== MAP MARKERS: STOP ===== */
.rb-stop {
    position: relative;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: var(--sky);
    color: #fff;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

.rb-stop svg {
    width: 13px;
    height: 13px;
}

/* direction notch */
.rb-stop::after {
    content: "";
    position: absolute;
    left: 50%;
    top: -8px;
    margin-left: -4px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-bottom: 5px solid var(--sky);
    transform-origin: 4px 19px;
}

.rb-stop--E::after {
    transform: rotate(90deg);
}

.rb-stop--S::after {
    transform: rotate(180deg);
}

.rb-stop--W::after {
    transform: rotate(-90deg);
}

.rb-stop--X::after {
    display: none;
}

.rb-stop.is-fav {
    background: var(--gold);
    color: var(--ink);
}

.rb-stop.is-fav::after {
    border-bottom-color: var(--gold);
}

.rb-stop.is-alert {
    background: var(--danger);
}

.rb-stop.is-alert::after {
    border-bottom-color: var(--danger);
}

.rb-stop.is-current {
    transform: scale(1.3);
    box-shadow: 0 0 0 4px rgba(47, 143, 216, 0.35), 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* small dot version for mid zoom */
.rb-stop--dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border-width: 2px;
}

.rb-stop--dot svg,
.rb-stop--dot::after {
    display: none;
}

.rb-me {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1a73e8;
    border: 3px solid #fff;
    box-shadow: 0 0 0 8px rgba(26, 115, 232, 0.22), 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* ===== LEAFLET POPUP / TOOLTIP ===== */
.leaflet-popup-content-wrapper {
    border-radius: 14px;
    font-family: var(--font);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 14px 16px;
    font-size: 14px;
    line-height: 1.45;
}

.leaflet-tooltip {
    font-family: var(--font);
    font-weight: 600;
    border-radius: 8px;
    border: 0;
    box-shadow: var(--shadow-md);
}

.rb-pop__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 15px;
}

.rb-pop__meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.rb-pop__btn {
    margin-top: 10px;
    width: 100%;
    border: 0;
    border-radius: 10px;
    background: var(--ink);
    color: var(--cream);
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 700;
}

/* ===== WELCOME DIALOG ===== */
.rb-welcome {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(10, 20, 15, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.rb-welcome[hidden] {
    display: none;
}

.rb-welcome__box {
    width: 100%;
    max-width: 640px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: rb-pop 0.25s ease;
}

@keyframes rb-pop {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.rb-welcome__card {
    flex: 1;
    overflow-y: auto;
    padding: 22px 20px 8px;
}

.rb-welcome__head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.rb-welcome__head h2 {
    margin: 0;
    font-size: 21px;
    line-height: 1.2;
    letter-spacing: -0.01em;
}

.rb-welcome__sub {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.rb-welcome__label {
    margin: 20px 0 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--muted);
}

.rb-welcome__foot {
    padding: 12px 20px calc(16px + var(--safe-bottom));
    border-top: 1px solid var(--line);
    background: var(--surface);
}

.rb-seg {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 5px;
    background: var(--surface-2);
    border-radius: 14px;
}

.rb-seg__btn {
    border: 0;
    border-radius: 10px;
    min-height: 44px;
    background: transparent;
    font-weight: 700;
    color: var(--muted);
}

.rb-seg__btn.is-on {
    background: var(--ink);
    color: var(--cream);
    box-shadow: var(--shadow-sm);
}

.rb-allbtn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 52px;
    padding: 0 14px;
    margin-bottom: 8px;
    border: 2px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    font-weight: 700;
    text-align: left;
}

.rb-allbtn__icon {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: 2px solid var(--line);
    color: transparent;
    font-size: 13px;
}

.rb-allbtn[aria-pressed="true"] {
    border-color: var(--ink);
    background: var(--surface-2);
}

.rb-allbtn[aria-pressed="true"] .rb-allbtn__icon {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--gold);
}

.rb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 6px;
    padding-bottom: 8px;
}

.rb-gridbtn {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    min-height: 50px;
    padding: 6px 8px;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    text-align: left;
}

.rb-gridbtn[aria-pressed="true"] {
    border-color: var(--ink);
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--ink);
}

.rb-gridbtn__num {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 38px;
    height: 32px;
    border-radius: 8px;
    font: 800 14px var(--mono);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.rb-gridbtn__name {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
}

.rb-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 14px;
    cursor: pointer;
}

.rb-check input {
    width: 20px;
    height: 20px;
    accent-color: var(--ink);
}

.rb-btn--go {
    margin: 0;
    min-height: 54px;
    font-size: 16px;
}

/* ===== TOAST ===== */
.rb-toast {
    position: fixed;
    left: 50%;
    top: calc(var(--header-h) + var(--gap) * 2 + var(--safe-top));
    z-index: 3500;
    transform: translate(-50%, -10px);
    max-width: calc(100% - 32px);
    padding: 11px 18px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--cream);
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: var(--shadow-md);
}

.rb-toast.is-on {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ===== DESKTOP: KEEP FAB + ZOOM CLEAR OF PANEL ===== */
@media (min-width: 761px) {
    .leaflet-bottom.leaflet-left {
        left: calc(var(--panel-w) + var(--gap));
    }
}

/* ===== MOBILE: BOTTOM SHEET ===== */
@media (max-width: 760px) {
    :root {
        --header-h: 52px;
        --gap: 10px;
    }

    .rb-brand {
        padding-right: 14px;
    }

    .rb-brand__logo {
        width: 36px;
        height: 36px;
    }

    .rb-chipbtn {
        height: 44px;
        padding: 0 14px;
    }

    .leaflet-control-zoom {
        display: none;
    }

    .rb-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        height: var(--sheet-h);
        border-radius: 22px 22px 0 0;
        box-shadow: 0 -10px 40px rgba(20, 35, 28, 0.22);
        transition: height 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
        padding-bottom: var(--safe-bottom);
    }

    .rb-panel.is-dragging {
        transition: none;
    }

    .rb-status__time {
        display: none;
    }

    /* no sticky hover borders after a tap */
    .rb-route:hover:not([aria-pressed="true"]),
    .rb-item:hover,
    .rb-arrival:hover {
        border-color: var(--line);
    }

    .rb-panel__head {
        touch-action: none;
        cursor: grab;
    }

    .rb-panel__grip {
        display: block;
        padding: 10px 0 2px;
    }

    .rb-panel__grip span {
        display: block;
        width: 44px;
        height: 5px;
        margin: 0 auto;
        border-radius: 3px;
        background: #cfc8b4;
    }

    .rb-tabs {
        padding: 6px 10px 10px;
    }

    .rb-tab {
        padding: 7px 0;
        font-size: 10.5px;
    }

    .rb-tabs {
        gap: 2px;
    }

    .rb-fab {
        bottom: calc(var(--sheet-h) + 12px);
    }

    .rb-fab.is-hidden,
    body[data-sheet="full"] .rb-fab {
        opacity: 0;
        pointer-events: none;
    }

    .rb-pane {
        padding: 12px;
    }

    .rb-credit {
        padding-bottom: 24px;
    }

    .leaflet-bottom.leaflet-right {
        bottom: var(--sheet-h);
        transition: bottom 0.28s ease;
    }

    .rb-toast {
        top: auto;
        bottom: calc(var(--sheet-h) + 16px);
        transform: translate(-50%, 10px);
    }

    .rb-toast.is-on {
        transform: translate(-50%, 0);
    }

    .rb-welcome {
        align-items: end;
        padding: 0;
    }

    .rb-welcome__box {
        max-height: 94vh;
        border-radius: 24px 24px 0 0;
    }

    .rb-welcome__card {
        padding: 20px 16px 8px;
    }

    .rb-welcome__foot {
        padding-left: 16px;
        padding-right: 16px;
    }

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

/* ===== NARROW PHONES ===== */
@media (max-width: 380px) {
    .rb-chipbtn span[data-i18n="pickRoutes"] {
        display: none;
    }

    .rb-chipbtn {
        padding: 0 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ===== GHOST BUTTON ===== */
.rb-btn--ghost {
    background: var(--surface-2);
    color: var(--ink);
    border: 1px solid var(--line);
    font-size: 14px;
    min-height: 46px;
}

.rb-link {
    border: 0;
    background: none;
    color: var(--sky);
    font-weight: 700;
    font-size: 13px;
    padding: 4px 0;
}

/* ===== NEARBY: LIVE NEXT BUSES ===== */
.rb-next {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    font: 700 12px var(--mono);
    color: var(--ink);
}

.rb-next__item {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 6px 2px 2px;
    border-radius: 8px;
    background: var(--surface-2);
}

.rb-next__item .rb-mini {
    margin: 0 2px 0 0;
    min-width: 24px;
    padding: 2px 4px;
    font-size: 11px;
}

.rb-next__none {
    font: 500 12px var(--font);
    color: var(--muted);
}

/* ===== TRIP PLANNER ===== */
.rb-plan__fields {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 54px 8px 8px;
    background: var(--surface-2);
    border-radius: 16px;
}

.rb-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    height: 48px;
    background: var(--surface);
    border: 2px solid transparent;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.rb-field:focus-within {
    border-color: var(--sky);
}

.rb-field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    font: 500 16px var(--font);
    color: var(--text);
}

.rb-field__dot {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.rb-field__dot--from {
    background: #fff;
    border: 3px solid var(--sky);
}

.rb-field__dot--to {
    background: var(--danger);
    border-radius: 3px;
    transform: rotate(45deg);
}

.rb-swap {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

.rb-plan__when {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 2px 12px;
    color: var(--muted);
}

.rb-plan__when select,
.rb-plan__when input {
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    font: 600 14px var(--font);
    color: var(--text);
}

.rb-sugg:not(:empty) {
    margin-bottom: 12px;
}

.rb-item__sign--me {
    background: var(--sky);
}

.rb-item__sign--recent,
.rb-item__sign--map {
    background: var(--surface-3);
    color: var(--ink);
}

.rb-item__sign--place {
    background: var(--danger);
}

.rb-plan__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 4px 2px 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}

.rb-journey {
    margin-bottom: 8px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    overflow: hidden;
}

.rb-journey.is-open {
    border-color: var(--sky);
    box-shadow: 0 0 0 1px var(--sky), var(--shadow-sm);
}

.rb-journey__sum {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 12px 14px;
    border: 0;
    background: transparent;
    text-align: left;
}

.rb-journey__top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.rb-journey__time {
    font-weight: 800;
    font-size: 17px;
}

.rb-journey__dur {
    font: 800 15px var(--mono);
    color: var(--ink);
    white-space: nowrap;
}

.rb-journey__chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.rb-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 26px;
    padding: 0 8px;
    border-radius: 8px;
    font: 800 13px var(--mono);
}

.rb-chip--walk {
    background: var(--surface-2);
    color: var(--muted);
    font-family: var(--font);
    font-weight: 600;
}

.rb-chip__sep {
    color: #b9b2a0;
    font-weight: 700;
}

.rb-journey__meta {
    font-size: 13px;
    color: var(--muted);
}

.rb-journey__detail {
    padding: 0 14px 14px;
    border-top: 1px solid var(--line);
}

.rb-journey__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.rb-journey__actions .rb-btn {
    margin: 0;
    font-size: 13px;
}

/* timeline */
.rb-tl {
    list-style: none;
    margin: 14px 0;
    padding: 0;
}

.rb-tl__item {
    position: relative;
    display: flex;
    gap: 12px;
    padding: 0 0 14px 0;
    font-size: 14px;
    line-height: 1.45;
}

.rb-tl__item::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 16px;
    bottom: -2px;
    width: 3px;
    background: var(--c, #c9c2ae);
    border-radius: 2px;
}

.rb-tl__item--walk::before {
    background: repeating-linear-gradient(to bottom, #9aa39d 0 4px, transparent 4px 9px);
}

.rb-tl__item--end::before {
    display: none;
}

.rb-tl__dot {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    margin-top: 2px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--c, #9aa39d);
}

.rb-tl__item--end .rb-tl__dot {
    background: var(--danger);
    border-color: var(--danger);
}

.rb-tl__item .rb-mini {
    margin-right: 6px;
}

.rb-tl__row {
    margin-top: 4px;
}

.rb-tl__t {
    display: inline-block;
    min-width: 58px;
    margin-right: 6px;
    font: 800 13px var(--mono);
}

.rb-tl__sub {
    color: var(--muted);
    font-size: 13px;
}

.rb-tl__id {
    font: 600 11px var(--mono);
    color: var(--muted);
}

.rb-livebadge {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font: 700 12px var(--font);
}

.rb-livebadge.is-ok {
    background: #dcfce7;
    color: #166534;
}

.rb-livebadge.is-late {
    background: var(--danger-bg);
    color: #a3162a;
}

.rb-livebadge.is-early {
    background: #e0f2fe;
    color: #075985;
}

/* map pins for the trip */
.rb-pin--from {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 5px solid var(--sky);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.rb-pin--to {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--danger);
    color: #fff;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.rb-pin--to svg {
    transform: rotate(45deg);
}

/* long-press menu */
.rb-ctxpop .leaflet-popup-content {
    margin: 8px;
}

.rb-ctx {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 170px;
}

.rb-ctx__btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--sky);
    color: #fff;
    font-weight: 700;
    text-align: left;
}

.rb-ctx__btn--alt {
    background: var(--surface-2);
    color: var(--ink);
}

body.is-picking .rb-map {
    cursor: crosshair;
}

body.is-picking .leaflet-container {
    cursor: crosshair;
}

/* ===== COMPACT STOP CARD ===== */
.rb-stopcard {
    position: fixed;
    z-index: 960;
    left: calc(var(--panel-w) + var(--gap) * 2);
    bottom: var(--gap);
    width: 360px;
    max-width: calc(100% - var(--gap) * 2);
    padding: 12px;
    background: var(--surface);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    animation: rb-card-in 0.2s ease;
}

.rb-stopcard[hidden] {
    display: none;
}

@keyframes rb-card-in {
    from { transform: translateY(12px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.rb-card__head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rb-card__sign {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--sky);
    color: #fff;
}

.rb-card__title {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.rb-card__title b {
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rb-card__title span {
    font: 600 12px var(--mono);
    color: var(--muted);
}

.rb-card__close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
}

.rb-card__notice {
    margin: 10px 0 0;
}

.rb-card__msg {
    margin: 12px 2px 4px;
    font-size: 14px;
    color: var(--muted);
}

.rb-card__list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rb-card__row {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 8px 6px 6px;
    border: 0;
    border-radius: 12px;
    background: var(--surface-2);
    text-align: left;
}

.rb-card__route {
    display: grid;
    place-items: center;
    height: 28px;
    border-radius: 8px;
    font: 800 13px var(--mono);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.rb-card__line {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 600;
}

.rb-card__eta {
    font: 800 17px var(--mono);
    white-space: nowrap;
}

.rb-card__eta small {
    margin-left: 2px;
    font: 600 11px var(--mono);
    color: var(--muted);
}

.rb-card__eta.is-clock {
    font-size: 13px;
}

.rb-card__eta.is-soon {
    color: var(--danger);
}

.rb-card__actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
}

.rb-card__act {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 0 0 auto;
    min-width: 42px;
    height: 42px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

.rb-card__act[data-card="fav"] {
    font-size: 18px;
    color: #c9c2ae;
}

.rb-card__act[data-card="fav"].is-on {
    color: var(--gold);
}

.rb-card__act--wide {
    flex: 1;
    white-space: nowrap;
}

.rb-card__act--main {
    background: var(--ink);
    border-color: var(--ink);
    color: var(--cream);
}

@media (max-width: 760px) {
    .rb-stopcard {
        left: var(--gap);
        right: var(--gap);
        width: auto;
        max-width: none;
        bottom: calc(var(--sheet-h) + 8px);
    }

    body.card-open .rb-fab {
        opacity: 0;
        pointer-events: none;
    }

    /* peek = only the handle and the tabs */
    .rb-panel[data-state="peek"] .rb-panel__body {
        visibility: hidden;
    }

    .rb-panel[data-state="peek"] .rb-tabs {
        border-bottom: 0;
    }
}

/* ===== SEO HELPERS ===== */
.rb-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.rb-noscript {
    position: fixed;
    inset: 0;
    z-index: 5000;
    padding: 40px 24px;
    background: var(--surface);
    font-size: 16px;
    line-height: 1.5;
}
