@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
    --ink: #0e1114;
    --ink-2: #14171a;
    --paper: #eceee4;
    --accent: #f2540b;
    --accent-soft: rgba(242, 84, 11, .12);
    --panel: rgba(14, 17, 20, .97);
    --line: rgba(255, 255, 255, .09);
    --line-2: rgba(255, 255, 255, .14);
    --fg: #f2f3f0;
    --fg-2: rgba(242, 243, 240, .68);
    --fg-3: rgba(242, 243, 240, .56);
    --danger: #ef4444;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
    --cond: 'Barlow Condensed', sans-serif;
    --sans: 'Space Grotesk', system-ui, sans-serif;
}

* { box-sizing: border-box; }
/* Elements toggled via the `hidden` attribute also get an explicit `display`
   from the rules below (e.g. .pbody, .result-view) — author CSS always beats
   the UA stylesheet's `[hidden]{display:none}` regardless of source order,
   so without this override both views would render at once. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--ink);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }

/* ---------- layout ---------- */
#ride-app { position: relative; width: 100vw; height: 100vh; overflow: hidden; background: var(--paper); }
#ride-map { position: absolute; inset: 0; }

.panel {
    position: absolute;
    left: 24px; top: 24px; bottom: 24px;
    width: 398px;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 16px;
    box-shadow: 0 18px 56px rgba(0, 0, 0, .4);
    color: var(--fg);
    overflow: hidden;
    z-index: 500;
}
.phead { display: flex; align-items: center; gap: 11px; padding: 19px 24px 17px; border-bottom: 1px solid var(--line); }
.logo { flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.wordmark { font: 700 18px/1 var(--cond); letter-spacing: .07em; text-transform: uppercase; }
.ghost { margin-left: auto; padding: 7px 12px; border: 1px solid rgba(255, 255, 255, .16); background: transparent; border-radius: 8px; color: rgba(242, 243, 240, .72); font: 500 11.5px var(--sans); cursor: pointer; }
.ghost:hover { border-color: rgba(255, 255, 255, .3); color: #fff; }

.pbody { flex: 1; min-height: 0; overflow: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 17px; }
.pfoot { padding: 18px 24px; border-top: 1px solid var(--line); }
.lbl { font: 600 10.5px/1 var(--cond); letter-spacing: .16em; text-transform: uppercase; color: rgba(242, 243, 240, .58); margin-bottom: 10px; }

/* ---------- segmented control (mode) ---------- */
.seg { display: flex; gap: 4px; padding: 4px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1); border-radius: 11px; }
.seg label { position: relative; flex: 1; text-align: center; padding: 10px 0; border-radius: 8px; font: 500 13px var(--sans); color: var(--fg-2); cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent); color: #14100d; font-weight: 600; }

/* ---------- address field ---------- */
[data-address-search] { position: relative; }
.field { display: flex; align-items: center; gap: 10px; padding: 12px 13px; background: rgba(255, 255, 255, .07); border: 1px solid var(--line-2); border-radius: 10px; }
.field svg { flex: none; }
.field .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.field input[data-address-search-input] { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--fg); font: 500 14px var(--sans); padding: 0; outline: none; }
.field input[data-address-search-input]::placeholder { color: var(--fg-3); }
.field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(242, 84, 11, .16); }
.field .x { flex: none; margin-left: auto; color: var(--fg-3); font-size: 15px; background: none; border: 0; cursor: pointer; line-height: 1; padding: 2px; }
.field .x:hover { color: var(--fg); }
.field.selected input[data-address-search-input] { cursor: default; }

.suggest { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin-top: 7px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px; background: #15191d; box-shadow: 0 12px 28px rgba(0, 0, 0, .35); overflow: hidden; list-style: none; padding: 0; }
.suggest li { padding: 11px 13px; border-bottom: 1px solid rgba(255, 255, 255, .06); cursor: pointer; font: 500 13.5px var(--sans); color: rgba(242, 243, 240, .88); }
.suggest li:last-child { border-bottom: 0; }
.suggest li:hover { background: rgba(255, 255, 255, .055); }

/* ---------- distance slider ---------- */
.distrow { display: flex; align-items: center; gap: 14px; }
.numbox { display: flex; align-items: baseline; gap: 5px; padding: 11px 14px; background: rgba(255, 255, 255, .06); border: 1px solid var(--line-2); border-radius: 10px; }
.numbox input { width: 3.2em; border: 0; background: transparent; font: 700 20px var(--mono); color: #fff; padding: 0; outline: none; }
.numbox u { text-decoration: none; font: 500 11px var(--cond); letter-spacing: .1em; text-transform: uppercase; color: rgba(242, 243, 240, .5); }
.ticks { display: flex; justify-content: space-between; margin-top: 9px; font: 500 10px var(--mono); color: rgba(242, 243, 240, .3); }

.range-slider {
    -webkit-appearance: none; appearance: none;
    flex: 1; height: 20px; background: transparent; margin: 0; cursor: pointer;
}
.range-slider::-webkit-slider-runnable-track { height: 4px; background: rgba(255, 255, 255, .12); border-radius: 2px; }
.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none; margin-top: -8px;
    width: 20px; height: 20px; border-radius: 50%;
    background: var(--accent); border: 3px solid var(--ink);
    box-shadow: 0 0 0 3px rgba(242, 84, 11, .22);
}
.range-slider::-moz-range-track { height: 4px; background: rgba(255, 255, 255, .12); border-radius: 2px; }
.range-slider::-moz-range-progress { height: 4px; background: var(--accent); border-radius: 2px; }
.range-slider::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--accent); border: 3px solid var(--ink);
    box-shadow: 0 0 0 3px rgba(242, 84, 11, .22);
}

/* ---------- direction dial ---------- */
.dial { position: relative; width: 184px; height: 184px; margin: 2px auto 0; border-radius: 50%; background: radial-gradient(circle, rgba(255, 255, 255, .075), rgba(255, 255, 255, .02)); border: 1px solid rgba(255, 255, 255, .12); }
.dial .sector { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from calc(var(--dial-angle, 0deg) - 22.5deg), rgba(242, 84, 11, .38) 0deg 45deg, transparent 45deg 360deg); transition: background .15s ease; }
.dial .ring { position: absolute; inset: 22px; border-radius: 50%; border: 1px dashed rgba(255, 255, 255, .13); }
.dial .grad { position: absolute; inset: 6px; border-radius: 50%; background: repeating-conic-gradient(rgba(255, 255, 255, .16) 0deg 0.5deg, transparent 0.5deg 15deg); -webkit-mask: radial-gradient(circle, transparent 78px, #000 78px); mask: radial-gradient(circle, transparent 78px, #000 78px); }
.dial .val { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
.dial .val b { display: block; font: 700 24px var(--mono); color: var(--accent); }
.dial .val u { display: block; text-decoration: none; font: 600 11px var(--cond); letter-spacing: .14em; text-transform: uppercase; color: var(--fg-3); margin-top: 2px; }
.dial .c { position: absolute; font: 600 10.5px var(--mono); color: rgba(242, 243, 240, .55); pointer-events: none; }
.dial .n { left: 50%; top: 8px; transform: translateX(-50%); }
.dial .e { right: 9px; top: 50%; transform: translateY(-50%); }
.dial .s { left: 50%; bottom: 8px; transform: translateX(-50%); }
.dial .o { left: 9px; top: 50%; transform: translateY(-50%); }
.dial-hotspot {
    position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px;
    border: 0; border-radius: 50%; background: transparent; cursor: pointer; padding: 0;
    transform: rotate(var(--a)) translateY(-84px) rotate(calc(-1 * var(--a)));
}
.dial-hotspot:hover { background: rgba(255, 255, 255, .1); }
.dial select[data-direction-select] { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.dashbtn { width: 100%; margin-top: 11px; padding: 10px; border: 1px dashed rgba(255, 255, 255, .2); background: transparent; border-radius: 9px; color: var(--fg-2); font: 500 12.5px var(--sans); cursor: pointer; }
.dashbtn:hover { border-color: rgba(255, 255, 255, .4); color: #fff; }
.dashbtn.on { border-style: solid; border-color: var(--accent); color: #fff; background: var(--accent-soft); }

/* ---------- difficulty cards ---------- */
.cards { display: flex; flex-direction: column; gap: 7px; }
.rc { position: relative; display: flex; align-items: center; gap: 13px; padding: 10px 13px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 10px; background: rgba(255, 255, 255, .04); cursor: pointer; }
.rc input { position: absolute; opacity: 0; pointer-events: none; }
.rc svg { flex: none; }
.rc b { display: block; font: 500 13.5px var(--sans); color: rgba(242, 243, 240, .86); }
.rc s { display: block; text-decoration: none; font-size: 11.5px; color: var(--fg-3); margin-top: 2px; }
.rc:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(242, 84, 11, .1); }
.rc:has(input:checked) b { color: #fff; font-weight: 600; }
.rc:has(input:checked) s { color: rgba(255, 180, 140, .9); }
.rc:has(input:checked) svg path { stroke: #f2540b; }

/* ---------- CTA ---------- */
.cta { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 15px; border: 0; border-radius: 11px; background: var(--accent); color: #14100d; font: 700 14px var(--sans); letter-spacing: .01em; box-shadow: 0 8px 24px rgba(242, 84, 11, .3); cursor: pointer; }
.cta:disabled { background: rgba(255, 255, 255, .08); color: rgba(242, 243, 240, .35); box-shadow: none; cursor: not-allowed; }
.ctahint { margin-top: 10px; text-align: center; font-size: 11.5px; color: rgba(242, 243, 240, .35); }
.regenerate-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-bottom: 9px; padding: 12px; border: 1px dashed rgba(255, 255, 255, .22); background: transparent; border-radius: 10px; color: var(--fg-2); font: 600 12.5px var(--sans); cursor: pointer; }
.regenerate-btn:hover { border-color: rgba(255, 255, 255, .4); color: #fff; background: rgba(255, 255, 255, .04); }
.regenerate-btn:disabled { opacity: .5; cursor: not-allowed; }

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

/* ---------- result view: stats / steps ---------- */
.result-view { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); border-bottom: 1px solid var(--line); }
.stats .s { padding: 18px 16px; border-right: 1px solid var(--line); }
.stats .s:last-child { border-right: 0; }
.stats .k { font: 600 11px var(--cond); letter-spacing: .12em; text-transform: uppercase; color: var(--fg-2); }
.stats .v { font: 700 26px var(--mono); color: #fff; margin-top: 6px; letter-spacing: -.01em; }
.stats .s:first-child .v { color: var(--accent); }
.stats .u { font-size: 11px; color: var(--fg-3); margin-top: 2px; }

.stepshd { padding: 16px 24px 9px; }
.stepshd .lbl { margin: 0; }
.steps { padding: 0 24px 16px; display: flex; flex-direction: column; gap: 7px; overflow: auto; flex: 1; min-height: 0; }
.step { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, .09); border-radius: 10px; background: rgba(255, 255, 255, .03); }
.step--leg { cursor: pointer; }
.step--leg:hover { border-color: rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .06); }
.step--leg.on:hover { border-color: var(--accent); }
.step .n { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font: 700 11.5px var(--mono); color: #14100d; }
.step .n.hollow { background: rgba(255, 255, 255, .1); }
.step .n.hollow i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: block; }
.step .n.hollow i.w { background: #fff; }
.step b { display: block; font: 500 13px var(--sans); color: #fff; }
.step s { display: block; text-decoration: none; font-size: 11px; color: var(--fg-3); margin-top: 2px; }
.step .t { flex: 1; min-width: 0; }
.step .chip { flex: none; position: relative; display: flex; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--line-2); border-radius: 8px; background: rgba(255, 255, 255, .06); }
.step .chip select { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.step.on { border-color: var(--accent); background: rgba(242, 84, 11, .1); }
.step.on s { color: rgba(255, 190, 160, .88); }
.step.on .chip { border-color: var(--accent); background: rgba(242, 84, 11, .2); }
.step.dim { opacity: .55; }
.recap { font-size: 12px; color: rgba(242, 243, 240, .45); margin-bottom: 12px; }

/* ---------- error alert / modal ---------- */
.alert { position: relative; padding: 20px 22px 22px; border: 1px solid rgba(185, 28, 28, .45); background: rgba(185, 28, 28, .14); border-radius: 11px; }
.alert .t { display: flex; align-items: center; gap: 9px; padding-right: 24px; font: 600 14px var(--sans); color: #fff; }
.alert .t i { flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--danger); display: grid; place-items: center; font: 700 11px var(--sans); color: #1a0b0b; font-style: normal; }
.alert p { margin: 12px 0 0; font-size: 12.5px; line-height: 1.6; color: rgba(255, 215, 215, .85); }
.alert .sug { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.alert .sug .lbl { color: rgba(255, 215, 215, .6); margin-bottom: 2px; }
.alert .sug button { display: block; width: 100%; text-align: left; padding: 11px 13px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06); border-radius: 9px; font: 500 12.5px var(--sans); color: #fff; cursor: pointer; }
.alert .sug button:hover { border-color: rgba(255, 255, 255, .32); background: rgba(255, 255, 255, .1); }

/* The error alert renders as a native <dialog> (assets/app.js calls
   showModal()/close()) instead of an inline banner in the form, so it's
   visible regardless of which panel view (form/result) is active, and
   gets a real backdrop + Escape-to-close for free. Padding/background/
   border-radius come from .alert above — do not reset them here, a
   `dialog.modal` selector outranks a bare `.alert` class selector and
   would silently clobber them (this bit us once already). */
dialog.modal { border: 0; max-width: 360px; width: calc(100vw - 48px); box-shadow: 0 24px 64px rgba(0, 0, 0, .5); font-family: var(--sans); }
dialog.modal.alert { background: var(--ink-2); }
dialog.modal::backdrop { background: rgba(0, 0, 0, .6); }
.modal-close { position: absolute; top: 15px; right: 15px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .7); font-size: 15px; line-height: 1; cursor: pointer; }
.modal-close:hover { background: rgba(255, 255, 255, .16); color: #fff; }

/* ---------- generation loading dialog ---------- */
dialog.modal.generating { background: var(--ink-2); border: 1px solid rgba(255, 255, 255, .12); border-radius: 20px; padding: 26px 22px; color: var(--fg); }
.gen-head { display: flex; align-items: center; gap: 12px; }
.gen-spinner { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(242, 84, 11, .25); border-top-color: var(--accent); animation: spinner-spin .8s linear infinite; }
.gen-title { font: 700 21px/1 var(--cond); letter-spacing: .05em; text-transform: uppercase; }
.gen-progress { margin-top: 20px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.gen-progress i { display: block; height: 5px; background: var(--accent); border-radius: 3px; width: 0; transition: width .3s ease; }
.gen-steps { margin-top: 18px; display: flex; flex-direction: column; gap: 11px; }
.gen-step { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--fg-3); }
.gen-step .gen-check { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .15); display: grid; place-items: center; font: 700 10px var(--sans); color: #14100d; }
.gen-step.is-active { color: #fff; }
.gen-step.is-active .gen-check { border-color: rgba(242, 84, 11, .6); }
.gen-step.is-done { color: rgba(242, 243, 240, .75); }
.gen-step.is-done .gen-check { border-color: transparent; background: var(--accent); }
.gen-foot { margin-top: 22px; display: flex; justify-content: flex-end; }
.gen-cancel { padding: 10px 14px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 10px; background: transparent; color: rgba(242, 243, 240, .72); font: 500 12.5px var(--sans); cursor: pointer; }
.gen-cancel:hover { border-color: rgba(255, 255, 255, .32); color: #fff; }

/* ---------- bottom-sheet chrome (drag handle, mobile-only popup action) ---------- */
/* Present in the DOM at every viewport width but only shown under the mobile
   breakpoint below — keeps the two states one rule apart instead of two
   places building different markup. */
.sheet-handle { display: none; border: 0; background: transparent; padding: 0; margin: 0; }
.step-popup .a .move-hint { display: none; }

/* ---------- Leaflet chrome ---------- */
.leaflet-control-zoom { border: none !important; border-radius: 10px !important; box-shadow: 0 3px 10px rgba(0, 0, 0, .14) !important; overflow: hidden; }
.leaflet-control-zoom a { width: 38px !important; height: 38px !important; line-height: 38px !important; color: var(--ink-2) !important; font-size: 19px !important; }
.leaflet-control-attribution { font-family: var(--sans); font-size: 10px !important; color: rgba(20, 23, 26, .5); }

.hint { position: absolute; right: 24px; bottom: 44px; z-index: 400; display: flex; align-items: center; gap: 9px; padding: 11px 14px; background: rgba(14, 17, 20, .9); border-radius: 10px; color: rgba(242, 243, 240, .78); font-size: 12px; box-shadow: 0 6px 18px rgba(0, 0, 0, .28); }
.hint i { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: block; }

.waypoint-pin { background: transparent; border: none; }
.waypoint-pin__badge {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--ink); border: 2.5px solid var(--accent);
    color: #fff; font: 700 14px var(--mono);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.waypoint-pin.waypoint-pin--active .waypoint-pin__badge {
    width: 40px; height: 40px; border-width: 3px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .45), 0 0 0 6px rgba(242, 84, 11, .18);
}
.waypoint-pin__badge--fuel { border-color: #16a34a; }

.origin-pin { background: transparent; border: none; }
.origin-pin__badge {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--ink); border: 3px solid #fff;
    display: grid; place-items: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.origin-pin__badge i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: block; }

.chevron-pin { background: transparent; border: none; }
.chevron-pin__arrow { fill: var(--ink-2); stroke: var(--accent); stroke-width: 1.3px; stroke-linejoin: round; }

.segment-popup-anchor { background: transparent; border: none; }

.fuel-station-pin { background: transparent; border: none; }
.fuel-station-pin__badge {
    display: flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 50%;
    background: #fff; border: 2px solid #16a34a;
    font-size: 13px; line-height: 1;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .25);
}

/* Leaflet popup reskinned to match the design's step popup card. */
.leaflet-popup-content-wrapper { background: #fff; border-radius: 14px; box-shadow: 0 18px 46px rgba(0, 0, 0, .3); }
.leaflet-popup-content { margin: 0; width: 274px !important; }
.leaflet-popup-close-button { color: rgba(20, 23, 26, .35) !important; }

.step-popup .h { padding: 16px 18px 13px; border-bottom: 1px solid rgba(0, 0, 0, .08); }
.step-popup .h .r { display: flex; align-items: center; gap: 10px; }
.step-popup .h .r i { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font: 700 12.5px var(--mono); color: #14100d; font-style: normal; }
.step-popup .h .r b { font: 600 15px var(--sans); color: var(--ink-2); }
.step-popup .h p { margin: 10px 0 0; font-size: 12px; line-height: 1.5; color: rgba(20, 23, 26, .55); }
.step-popup .a { padding: 13px 18px; display: flex; flex-direction: column; gap: 9px; }
.step-popup .a .popup-difficulty { display: flex; flex-direction: column; gap: 5px; font: 600 10.5px var(--cond); letter-spacing: .1em; text-transform: uppercase; color: rgba(20, 23, 26, .45); }
.step-popup .a .popup-difficulty select { padding: 9px 10px; border: 1px solid rgba(0, 0, 0, .14); border-radius: 8px; background: #fff; font: 500 13px var(--sans); text-transform: none; letter-spacing: normal; color: var(--ink-2); cursor: pointer; }
.step-popup .a button { display: block; width: 100%; text-align: center; padding: 11px; border: 1px solid rgba(0, 0, 0, .14); background: #fff; border-radius: 9px; font: 500 13px var(--sans); color: var(--ink-2); cursor: pointer; }
.step-popup .a button:hover { background: rgba(0, 0, 0, .03); }
.step-popup .a button.del { border-color: rgba(185, 28, 28, .3); background: rgba(185, 28, 28, .06); color: #b91c1c; font-weight: 600; }
.step-popup .a button.del:hover { background: rgba(185, 28, 28, .12); }
.step-popup .f { padding: 0 18px 14px; font-size: 11px; line-height: 1.45; color: rgba(20, 23, 26, .42); }
.step-popup .fuel-note { margin: 10px 0 0; font: 600 11.5px var(--sans); color: #16a34a; }

/* ---------- small screens: panel becomes a bottom sheet ---------- */
@media (max-width: 860px) {
    .panel {
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        width: auto;
        max-height: 86vh;
        border-radius: 22px 22px 0 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        transition: max-height .25s ease;
    }
    /* Tapping the handle collapses the sheet down to just this bar, so the
       map underneath becomes reachable again — there's no free-drag gesture
       (see specs/progress.md), just this one tap-to-toggle affordance. */
    .panel.is-collapsed { max-height: 34px; }
    .sheet-handle { display: flex; justify-content: center; align-items: center; width: 100%; padding: 12px 0; cursor: pointer; }
    .sheet-handle i { display: block; width: 40px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .2); }
    .phead { padding-top: 8px; }

    .dial { width: 150px; height: 150px; }
    .dial-hotspot { transform: rotate(var(--a)) translateY(-68px) rotate(calc(-1 * var(--a))); }
    /* The smaller dial can't fit the longest value ("Aléatoire") at the
       desktop font size without spilling past the dial's own circle. */
    .dial .val b { font-size: 17px; }

    /* The error alert docks to the bottom full-width instead of centering —
       same <dialog>, same JS, position/sizing only. */
    dialog.modal.alert {
        position: fixed;
        inset: auto 0 0 0;
        margin: 0;
        width: 100%;
        max-width: none;
        max-height: 82vh;
        overflow: auto;
        border-radius: 22px 22px 0 0;
    }

    /* The tronçon/fuel-station popup docks to the bottom full-width too,
       instead of anchoring near its marker — same content/handlers built in
       map.js (which also disables Leaflet's autoPan at this breakpoint, see
       popupOptions()), position/sizing only. This only actually resolves
       against the real viewport because map.js also reparents the popup out
       of Leaflet's (CSS-transformed) map pane on open — position:fixed
       inside a transformed ancestor targets that ancestor's box, not the
       screen, which is what silently broke this before (see
       dockPopupForMobile()). z-index above .panel (500) so it reads as a
       modal over the current sheet, not tucked behind it. */
    .leaflet-popup {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        transform: none !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: none !important;
        z-index: 600;
    }
    .leaflet-popup-tip-container { display: none !important; }
    .mobile-popup-backdrop { position: fixed; inset: 0; z-index: 550; background: rgba(14, 17, 20, .5); }
    .leaflet-popup-content-wrapper { border-radius: 22px 22px 0 0; max-height: 82vh; overflow: auto; }
    .leaflet-popup-content-wrapper::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        margin: 10px auto 4px;
        border-radius: 2px;
        background: rgba(20, 23, 26, .18);
    }
    /* Leaflet's own bundled stylesheet sets a lopsided default margin
       (13px 24px 13px 20px, sized for a small anchored bubble) at the same
       selector specificity as app.css's own `margin: 0` above — whichever
       loads last in the final bundle wins, and empirically that's Leaflet's,
       clobbering ours silently. Combined with the 100% width below, that
       margin was shifting the content ~20px off the left edge while
       overflowing past the right edge instead of sitting evenly inset —
       needs its own !important to actually stick. */
    .leaflet-popup-content { width: 100% !important; margin: 0 !important; box-sizing: border-box; }
    .step-popup .a .move-hint { display: block; }

    /* Right-anchored (as on desktop, clear of the sidebar) reads as
       off-center on a narrow phone width — center it like a toast instead. */
    .hint { left: 50%; right: auto; transform: translateX(-50%); max-width: calc(100vw - 32px); }
}
