:root{font:16px system-ui,sans-serif;background:#edf1ef;color:#18374a;color-scheme:light}
*{box-sizing:border-box}
[hidden]{display:none!important}
body{margin:0}
header{background:#18374a;color:#fff;min-height:3.5rem;display:flex;align-items:center;justify-content:space-between;padding:.6rem 1rem;gap:1rem}
h1{font-size:1.15rem;margin:0}
main{display:grid;min-height:calc(100dvh - 3.5rem);grid-template-columns:minmax(270px,360px) 1fr}
.panel{background:#fff;padding:1rem}
form{display:grid;gap:.55rem}
label,summary{font-weight:650}
.origin,.result,.actions{display:flex;gap:.6rem;align-items:center;justify-content:space-between;flex-wrap:wrap}
button,input,select{font:inherit;padding:.55rem .65rem;border:1px solid #bcc9cb;border-radius:.5rem}
input{width:100%;min-width:0}
button{color:#18374a;background:#edf3f3;cursor:pointer}
button:disabled{opacity:.6;cursor:wait}
#plan{background:#216847;color:white;border-color:#216847;flex:1;font-weight:700}
details{margin:.3rem 0;padding:.5rem 0}
summary{cursor:pointer}
.dimensions{display:grid;grid-template-columns:1fr 1fr;gap:.6rem;margin-top:.65rem}
.dimensions label{font-size:.85rem}
.note,#locations,#status{font-size:.88rem}
#status:empty{display:none}
#preview{border-top:1px solid #d2dddd;padding-top:.65rem;margin-top:.9rem}
#warning{padding:.7rem;background:#ffdb79;color:#3b2600;border-radius:.5rem;margin-bottom:.65rem}
#locations{display:block;margin-top:.5rem;color:#486071}
#map{min-height:360px;background:#dbe7e3}

.visually-hidden{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.destination-search{display:flex;gap:.5rem;align-items:center}
.destination-search input{flex:1}
#plan{flex:none;white-space:nowrap}
.phone-plan{display:none}
.trip-fields{display:grid;gap:.55rem;margin-top:.65rem}
#install{pointer-events:auto}
@media(max-width:700px){
  body:has(.navigator){height:100dvh;overflow:hidden}
  .app-header{position:fixed;bottom:calc(.85rem + env(safe-area-inset-bottom));left:.8rem;background:transparent;min-height:0;padding:0;z-index:3;pointer-events:none}
  .app-header h1{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
  .navigator{position:relative;display:block;height:100%;min-height:0}
  .navigator #map{position:absolute;inset:0;min-height:0}
  .planner-panel{position:absolute;z-index:2;inset:calc(.75rem + env(safe-area-inset-top)) .75rem auto;padding:0;background:transparent;pointer-events:none;max-height:calc(100dvh - 5rem);overflow:auto}
  .planner-panel form{pointer-events:none}
  .destination-search,#trip-options,#preview,#status:not(:empty){pointer-events:auto;background:white;border-radius:.8rem;box-shadow:0 2px 8px #18374a36}
  .destination-search{padding:.35rem}
  .destination-search input{border-color:transparent}
  #plan{min-width:3.4rem}
  .desktop-plan{display:none}
  .phone-plan{display:inline}
  #trip-options{justify-self:start;margin:0;padding:.55rem .8rem}
  #trip-options[open]{justify-self:stretch}
  #preview{margin-top:.45rem;padding:.65rem .75rem;border:0}
  #status:not(:empty){margin:.45rem 0 0;padding:.55rem .75rem}
  #preview #locations{overflow-wrap:anywhere}
  #warning{margin-bottom:.5rem;padding:.5rem .65rem;font-size:.9rem}
  .maplibregl-ctrl-top-right{top:auto;bottom:3rem}
}

#choices{display:flex;flex-wrap:wrap;gap:.4rem}
#choices button{min-height:44px;font-size:.875rem;text-align:left}
#choices button[aria-pressed="true"]{background:#0057ba;border-color:#0057ba;color:white}

#address-dialog{width:min(32rem,calc(100% - 2rem));max-height:80dvh;overflow:auto;border:0;border-radius:.9rem;padding:1rem;color:#18374a;box-shadow:0 4px 24px #18374a40}
#address-dialog::backdrop{background:#14293788}
#address-title{font-size:1.1rem;margin:0 0 .65rem}
#address-choices{display:grid;gap:.4rem;margin-bottom:.8rem}
#address-choices button{min-height:44px;text-align:left}
.driving-actions{display:flex;flex-wrap:wrap;gap:.5rem;margin-top:.55rem}
.driving-actions button{min-height:44px}
#start-driving{color:white;background:#216847;border-color:#216847;font-weight:700}
body:has(#driving:not([hidden])) .navigator{position:relative;display:block;height:calc(100dvh - 3.5rem)}
body:has(#driving:not([hidden])) #map{position:absolute;inset:0;min-height:0}
#driving{position:absolute;inset:0;z-index:2;pointer-events:none}
.turn-card{position:absolute;top:calc(.75rem + env(safe-area-inset-top));left:.75rem;right:.75rem;max-width:37rem;margin:auto;border-radius:.85rem;background:#263b48;color:#fff;padding:.8rem 1rem}
#turn-instruction{font-size:1.2rem}
#turn-distance{color:#b9d8e7;font-weight:700}
#replay-label,#driving-status{color:#ffdb79;font-size:.9rem}
#driving-status{margin:.25rem 0 0}
#driving-status:empty{display:none}
.driving-controls{position:absolute;bottom:calc(3.5rem + env(safe-area-inset-bottom));left:.75rem;right:.75rem;display:flex;align-items:end;justify-content:space-between;gap:.5rem}
.speed-box{display:grid;justify-items:center;min-width:64px;padding:.35rem .55rem;border-radius:.65rem;background:#fff;box-shadow:0 2px 8px #18374a36}
.speed-box strong{font-size:1.8rem;line-height:1}
#stop-driving{pointer-events:auto;color:#fff;background:#963c36;border-color:#963c36;min-height:44px}
@media(max-width:700px){
  body:has(#driving:not([hidden])) .navigator{height:100dvh}
}

#voice-option{display:flex;align-items:center;gap:.45rem;min-height:44px;font-size:.875rem}
#voice-enabled{width:auto}
#voice-toggle{pointer-events:auto;min-height:44px;margin-left:auto}

#following-turn{margin-top:.35rem;color:#d7e3e9;font-size:.9rem;overflow-wrap:anywhere}

.fleet-fields{display:grid;gap:.4rem;margin-top:.65rem}
#fleet-unit{width:100%}
.fleet-fields button{min-height:44px}

#stops-fieldset{min-width:0;margin:0;border:1px solid #bcc9cb;border-radius:.5rem;padding:.55rem}
#stops-fieldset legend{font-size:.875rem;font-weight:650}
#stop-rows{display:grid;gap:.55rem}
.stop-row{display:flex;flex-wrap:wrap;gap:.25rem;margin-bottom:.35rem}
.stop-row button{min-height:44px}
#itinerary{font-size:.875rem;margin:.35rem 0;padding-left:1.4rem;max-height:7rem;overflow:auto;overflow-wrap:anywhere}
#leg-label{color:#b9d8e7;font-size:.875rem;margin-bottom:.25rem}
#continue-leg{pointer-events:auto;min-height:44px;color:white;background:#216847;border-color:#216847}
/* Keep map controls beside the driving buttons when their labels wrap. */
body:has(#driving:not([hidden])) .maplibregl-ctrl-top-right{top:auto;bottom:calc(3.5rem + env(safe-area-inset-bottom))}
#driving .driving-controls{right:7rem}
.basemap-control{display:grid;justify-items:end;gap:.3rem}
.basemap-control .traffic-status{max-width:6rem;text-align:right}
.basemap-control button:disabled{cursor:default}

.guidance-buttons{min-width:0;display:flex;justify-content:flex-end;align-items:center;flex-wrap:wrap;gap:.5rem}

#stops-fieldset{pointer-events:auto;background:white}
#stops-fieldset:not(:has(.stop-row)){justify-self:start}

#move-first-stop{min-height:44px;margin-bottom:.4rem}

body:has(#pin-picker:not([hidden])) .navigator{position:relative;display:block;height:calc(100dvh - 3.5rem)}
body:has(#pin-picker:not([hidden])) #map{position:absolute;inset:0;min-height:0}
#pin-picker{position:absolute;z-index:4;left:.75rem;bottom:calc(2.5rem + env(safe-area-inset-bottom));width:min(25rem,calc(100% - 5rem));background:white;padding:.75rem;border-radius:.8rem;box-shadow:0 2px 8px #18374a36}
#pin-picker p{margin:.35rem 0}
#pin-picker label{display:block;margin-top:.35rem}
#saved-pin{max-width:100%;width:100%}
.pin-actions{display:flex;flex-wrap:wrap;gap:.3rem;margin-top:.45rem}
.pin-actions button,#pin-first-stop{min-height:44px}
@media(max-width:700px){body:has(#pin-picker:not([hidden])) .navigator{height:100dvh}}

.arrival-option{display:flex;align-items:center;gap:.4rem;font-size:.875rem;min-height:36px}
.arrival-option input{width:auto}
.stop-row .arrival-option{flex-basis:100%}
#arrival-note{margin:.4rem 0}

.basemap-control .basemap-toggle{width:auto;min-height:44px;padding:.4rem .65rem;background:#fff;border:1px solid #bcc9cb;box-shadow:0 2px 8px #18374a36}

.speed-boxes{display:flex;flex-direction:column;flex:none;gap:.35rem}
.speed-boxes .speed-box{width:64px;min-height:59px;align-content:center;text-align:center}
.speed-boxes small{font-size:.62rem;line-height:1;font-weight:700}
#speed-limit-box strong{font-size:1.5rem}

#destination-shortcuts{pointer-events:auto;background:#fff;border-radius:.75rem;padding:.45rem .65rem;justify-self:start;max-width:100%;margin:0}
#destination-shortcuts[open]{justify-self:stretch}
#destination-shortcuts summary{min-height:32px;align-content:center}
#yard-shortcut,#recent-searches button{width:100%;text-align:left;min-height:44px;overflow-wrap:anywhere}
#yard-shortcut small{display:block}
#recent-searches{display:grid;gap:.3rem;max-height:10rem;overflow:auto;margin:.35rem 0}
.basemap-control .basemap-toggle[aria-pressed="true"]{background:#216847;color:white}

#speed-data-status:empty,.driving-controls:has(#speed-limit-box[hidden]) #speed-data-status{display:none}
#speed-data-status,.traffic-status{background:white;color:#18374a;border-radius:.35rem;padding:.25rem .35rem;max-width:8rem;font-size:.7rem;line-height:1.15}
.traffic-status{display:block;margin-top:.25rem}

#tracker-open{justify-self:start;pointer-events:auto}
#tracker-driving{pointer-events:auto;min-height:44px}
#tracker-dialog{width:min(28rem,calc(100% - 2rem));max-height:85dvh;border:0;border-radius:.8rem;color:#18374a;padding:1rem}
#tracker-dialog::backdrop{background:#14293788}
#tracker-title{font-size:1.15rem;margin:0 0 .6rem}
.tracker-actions{display:flex;flex-wrap:wrap;gap:.5rem}
.tracker-marker{display:flex;align-items:center;gap:.3rem;border:2px solid white;border-radius:1rem;background:#1662ad;color:white;font-size:.72rem;font-weight:700;line-height:1;padding:.35rem .45rem;box-shadow:0 1px 5px #18374a80;white-space:nowrap}
.tracker-marker.stale{background:#697681}
.tracker-marker.own-bus{background:transparent;border:0;padding:0;box-shadow:none}
.own-bus-icon{display:block;width:36px;height:63px;filter:drop-shadow(0 1px 2px #18374ab0)}

#mph.over-limit{color:#b42318}

#rail-crossing-alert{margin-top:.6rem;padding:.65rem .5rem;background:#ffdb36;color:#201b06;border:3px solid #201b06;border-radius:.45rem;text-align:center;font-size:clamp(1rem,4.5vw,1.4rem);line-height:1.15}
#rail-crossing-distance{display:block;font-size:1rem;font-weight:700;margin-top:.25rem}
#crossing-coverage{position:absolute;z-index:2;bottom:2rem;left:.75rem;padding:.25rem .45rem;border-radius:.35rem;background:#fff;color:#263b48;font-size:.75rem;pointer-events:none}
/* CoachPilot trip itinerary */

#itinerary-panel {
    margin: 12px 0;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #ffffff;
    color: #0f172a;
    overflow: hidden;
}

#itinerary-panel > summary {
    padding: 14px;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
}

#itinerary-panel[hidden] {
    display: none;
}

#itinerary {
    list-style: none;
    margin: 0;
    padding: 16px;
}

#itinerary .itinerary-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 0;
    padding: 0 0 20px;
}

#itinerary .itinerary-item:last-child {
    padding-bottom: 0;
}

.itinerary-item:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 32px;
    bottom: 0;
    width: 2px;
    background: #cbd5e1;
}

.itinerary-marker {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2563eb;
    color: #ffffff;
    font-size: 15px;
    font-weight: 800;
}

.itinerary-start .itinerary-marker {
    background: #15803d;
}

.itinerary-final .itinerary-marker {
    background: #dc2626;
}

#itinerary button.itinerary-content {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    min-width: 0;
    margin: 0;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    color: #0f172a;
    text-align: left;
    cursor: pointer;
    white-space: normal;
    overflow-wrap: anywhere;
}

#itinerary button.itinerary-content:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

#itinerary button.itinerary-content:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.itinerary-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.6px;
    color: #64748b;
}

.itinerary-start .itinerary-label {
    color: #15803d;
}

.itinerary-final .itinerary-label {
    color: #dc2626;
}

.itinerary-address {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.4;
}

.itinerary-detail {
    font-size: 12px;
    line-height: 1.5;
    color: #475569;
}

#itinerary-total {
    padding: 14px 16px;
    border-top: 1px solid #e2e8f0;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 14px;
    font-weight: 700;
}
#itinerary-panel #itinerary {
    max-height: none;
    height: auto;
    overflow: visible;
}
/* CoachPilot numbered map markers */

button.route-stop-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    margin: 0;
    padding: 0;
    border: 3px solid #ffffff;
    border-radius: 50%;
    background: #2563eb;
    color: #ffffff;
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

button.route-stop-start {
    background: #15803d;
}

button.route-stop-intermediate {
    background: #2563eb;
}

button.route-stop-final {
    background: #dc2626;
}

button.route-stop-marker:hover {
    filter: brightness(1.15);
}

button.route-stop-marker:focus-visible {
    outline: 3px solid #0f172a;
    outline-offset: 2px;
}
/* CoachPilot collapsible trip editor */

#trip-editor {
    margin: 0;
    padding: 0;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    pointer-events: auto;
    overflow: hidden;
}

#trip-editor > summary {
    padding: 14px;
    background: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
    cursor: pointer;
}

#trip-editor[open] > summary {
    border-bottom: 1px solid #cbd5e1;
}

#trip-editor > form {
    padding: 12px;
    pointer-events: auto;
}

@media (min-width: 701px) {
    main.navigator {
        height: calc(100dvh - 3.5rem);
        min-height: 0;
        grid-template-rows: minmax(0, 1fr);
    }

    .planner-panel {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
    }
}
/* CoachPilot itinerary drag and drop */

button.itinerary-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    min-height: 44px;
    padding: 0;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #64748b;
    font-size: 26px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

button.itinerary-drag-handle:active {
    cursor: grabbing;
    background: #dbeafe;
    color: #2563eb;
}

#itinerary .itinerary-dragging {
    opacity: 0.45;
}

#itinerary .itinerary-drop-target {
    outline: 2px dashed #2563eb;
    outline-offset: 4px;
    border-radius: 8px;
    background: #eff6ff;
}

#itinerary-changes {
    padding: 12px;
    background: #fff7ed;
    border-top: 1px solid #fdba74;
    color: #9a3412;
}

#itinerary-changes p {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
}

#recalculate-trip {
    width: 100%;
    min-height: 44px;
    background: #216847;
    border-color: #216847;
    color: white;
    font-weight: 700;
}
/* CoachPilot Settings */

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}

#settings-open {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 26px;
    background: #ffffff;
    color: #18374a;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    pointer-events: auto;
}

#settings-dialog {
    width: min(420px, calc(100% - 32px));
    max-height: 85dvh;
    overflow-y: auto;
    padding: 20px;
    border: 0;
    border-radius: 16px;
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 8px 32px #00000040;
}

#settings-dialog::backdrop {
    background: #0f172a99;
}

.settings-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 14px;
    border-bottom: 1px solid #e2e8f0;
}

.settings-heading h2 {
    margin: 0;
    font-size: 21px;
}

#settings-close {
    width: 40px;
    height: 40px;
    padding: 0;
}

.settings-section {
    margin: 20px 0;
}

.settings-section h3 {
    font-size: 16px;
    margin: 0 0 12px;
}

.settings-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    cursor: pointer;
}

.settings-option:has(input:checked) {
    border-color: #2563eb;
    background: #eff6ff;
}

.settings-option input {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    accent-color: #2563eb;
}

.settings-option span {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-option small {
    font-size: 13px;
    font-weight: 400;
    color: #64748b;
}

.settings-note {
    font-size: 13px;
    color: #64748b;
}

#settings-done {
    width: 100%;
    min-height: 44px;
    background: #216847;
    border-color: #216847;
    color: white;
    font-weight: 700;
}

body:has(#driving:not([hidden])) #settings-open,
body:has(#pin-picker:not([hidden])) #settings-open {
    display: none;
}
/* Saved Trips floating popup */
#saved-trips-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    width: min(360px, calc(100vw - 32px));
    max-height: 80vh;
    overflow-y: auto;
    box-sizing: border-box;
    z-index: 10000;
    border: 1px solid #94a3b8;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
}

#saved-trips-dialog:not([open]) {
    display: none;
}