/* Native map canvas + a small, responsive Material-inspired web workspace.
   One layout, with explicit high-contrast and reduced-motion alternatives. */
:root{--map-bg:#edf0e9;--map-road:#fff;--map-outline:#aab1b3;--map-foot:#727e80;--map-water:#a4d5ec;--map-park:#c0ddb8;--map-building:#d0cbc5;--map-label:#263439;--map-pin:#00677e;--map-closed:#a51d35;--map-traffic:#a45a00;--map-cap:#6546a7;--muted:#516578;--line:#c8d6e0;--shadow:0 6px 24px #172b3c23}
:root:not([data-contrast=high]){--bg:#f8fafc;--surface:#e9f0f5;--ink:#172b3c;--accent:#00677e;--on:#fff}
@media(prefers-color-scheme:dark){:root:not([data-theme=light]){--map-bg:#202b2b;--map-road:#657078;--map-outline:#3c474c;--map-foot:#b1bdc0;--map-water:#294b62;--map-park:#314e39;--map-building:#404748;--map-label:#e2e8e8;--map-pin:#75e1f3;--map-closed:#ff8190;--map-traffic:#ffc076;--map-cap:#d6baff;--muted:#b4c6d6;--line:#43566a;--shadow:0 6px 24px #0005}:root:not([data-theme=light]):not([data-contrast=high]){--bg:#111e2b;--surface:#203247;--ink:#edf5ff;--accent:#75e1f3;--on:#082b35}}
:root[data-theme=dark]{--map-bg:#202b2b;--map-road:#657078;--map-outline:#3c474c;--map-foot:#b1bdc0;--map-water:#294b62;--map-park:#314e39;--map-building:#404748;--map-label:#e2e8e8;--map-pin:#75e1f3;--map-closed:#ff8190;--map-traffic:#ffc076;--map-cap:#d6baff;--muted:#b4c6d6;--line:#43566a;--shadow:0 6px 24px #0005}
:root[data-theme=dark]:not([data-contrast=high]){--bg:#111e2b;--surface:#203247;--ink:#edf5ff;--accent:#75e1f3;--on:#082b35}
:root[data-contrast=high]{--line:var(--ink);--muted:var(--ink);--map-bg:var(--bg);--map-label:var(--ink);--map-outline:var(--ink);--map-pin:var(--accent)}
[hidden]{display:none!important}.sr-only{position:absolute!important;width:1px!important;height:1px!important;overflow:hidden;clip-path:inset(50%);white-space:nowrap;margin:-1px;padding:0!important}
.map-workspace{height:100dvh;overflow:hidden;line-height:1.45}
.map-workspace main{height:100%;margin:0;padding:0;max-width:none}
.viewer,.viewer-layout,.viewer-map-panel,#world-panel{height:100%;margin:0;padding:0;min-width:0}
.viewer-layout,#world-panel{position:relative}
.viewer-heading,.map-workspace footer{display:none}
#world-panel>.viewer-map-wrap{position:absolute;inset:0;overflow:hidden;background:var(--map-bg)}
#world-map{display:block;width:100%;height:100%;touch-action:none;cursor:grab;outline-offset:-4px}
#world-map:active,#viewer-map:active{cursor:grabbing}
.map-workspace header{position:fixed;right:16px;top:16px;z-index:5;gap:6px;padding:5px;border:1px solid var(--line);border-radius:26px;background:var(--bg);box-shadow:var(--shadow);max-width:calc(100% - 32px);flex-wrap:nowrap}
.map-workspace header .brand{display:none}
.map-workspace button{min-height:44px;font-size:.875rem;justify-content:center;gap:8px;line-height:1.35}
.map-workspace header button,.map-actions button,.route-tools button,.route-heading button,#route-add,#provider-close{background:var(--surface);color:var(--ink);padding:10px 16px}
.map-workspace button:disabled{opacity:.5;cursor:not-allowed}
.map-workspace button svg{flex:none;width:20px;height:20px}
.public-search{position:absolute;z-index:4;left:16px;bottom:52px;top:auto;width:min(24rem,calc(100vw - 32px));max-height:calc(100dvh - 84px);padding:14px;background:var(--bg);border:1px solid var(--line);border-radius:26px;box-shadow:var(--shadow);overflow:auto;overscroll-behavior:contain}
.search-brand{display:flex;align-items:center;gap:10px;font-weight:750;font-size:1.05rem;margin-bottom:12px;letter-spacing:-.025em}
.search-brand-mark{display:grid;place-items:center;background:var(--accent);color:var(--on);border-radius:13px;width:36px;height:36px;flex:none}
.search-brand small{color:var(--muted);font-size:.75rem;font-weight:500;margin-left:auto}
.search-pill{display:flex;align-items:center;gap:8px;background:var(--surface);border:1px solid var(--line);border-radius:28px;min-height:56px;padding:4px 4px 4px 13px}
.search-pill:focus-within{border-color:var(--accent);outline:1px solid var(--accent)}
.search-pill>svg{width:22px;height:22px;flex:0 0 22px;color:var(--muted)}
.search-pill input{flex:1;min-width:0;width:0;border:0;background:transparent;color:var(--ink);font:inherit;padding:8px 0;outline:none}
.search-pill input:focus-visible{outline:none}
.search-pill button{flex:none;width:46px;height:46px;padding:0;border-radius:50%}
.map-actions{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}
.map-actions #directions-toggle{background:var(--accent);color:var(--on);min-height:48px}
.viewer-note{font-size:.82rem;color:var(--muted);margin:8px 0;overflow-wrap:anywhere}
.viewer-note:empty,.viewer-results:empty,#route-summary:empty{display:none}
.viewer-results{display:grid;gap:6px;margin:10px 0 0;max-height:35dvh;overflow:auto;overscroll-behavior:contain}
.viewer-result{display:block;text-align:left;width:100%;color:var(--ink);background:var(--surface);border:1px solid transparent;border-radius:16px;padding:12px;font-weight:600;overflow-wrap:anywhere}
.viewer-result small{font-size:.78rem;color:var(--muted);margin-top:4px;font-weight:400}
.viewer-result:hover,.viewer-result[aria-current=true]{border-color:var(--accent)}
#place-detail,#directions{margin-top:14px;padding-top:14px;border-top:1px solid var(--line);overflow-wrap:anywhere}
#place-detail h2,#directions h2{font-size:1.25rem;line-height:1.25;letter-spacing:-.025em;margin:0 0 10px}
#place-detail dl,.viewer-detail dl{display:grid;grid-template-columns:minmax(0,auto) minmax(0,1fr);gap:8px 12px;font-size:.875rem;margin:10px 0 16px}
#place-detail dt,.viewer-detail dt{color:var(--muted)}#place-detail dd,.viewer-detail dd{margin:0;font-weight:550}
#place-detail button{margin:4px 4px 0 0}
.route-heading,.settings-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:12px}
.route-heading h2,.settings-head h2{margin:0}
.route-heading button,#provider-close{width:44px;height:44px;padding:0;font-size:1.5rem}
#route-mode,.legacy-map-tools input,.legacy-map-tools select,.preferences select{width:100%;font:inherit;color:var(--ink);background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:10px;min-height:48px}
.route-stop{margin:12px 0;display:grid;grid-template-columns:24px minmax(0,1fr);gap:8px;align-items:start}
.stop-marker{display:grid;place-items:center;border:1px solid var(--accent);color:var(--accent);height:24px;width:24px;border-radius:50%;font-weight:750;font-size:.8rem;margin-top:34px}
.stop-label{display:block;font-size:.8rem;font-weight:650;margin-bottom:4px;color:var(--muted)}
.stop-form{display:flex;gap:4px;align-items:center}
.stop-form input{flex:1;min-width:0;width:0;border:1px solid var(--line);color:var(--ink);background:var(--surface);border-radius:14px;font:inherit;padding:10px;min-height:48px}
.stop-form button{flex:none;padding:8px 12px}
.route-tools{display:flex;gap:4px;flex-wrap:wrap;margin-top:4px}
.route-tools button{padding:5px 12px;min-height:44px}
.stop-results{max-height:14rem;margin-top:6px}
.stop-status{font-size:.78rem;color:var(--muted);margin:4px 0}
#route-add,#route-calculate{margin:4px 4px 0 0;min-height:48px}
#route-summary{margin-top:12px;background:var(--surface);border-radius:20px;padding:14px}
#route-summary h3{margin:0;font-size:1.5rem}#route-summary p{margin:6px 0;font-size:.875rem}
.viewer-map-controls{position:absolute;right:16px;bottom:48px;display:grid;gap:8px;z-index:2}
.viewer-map-controls button{width:48px;height:48px;min-height:48px;border-radius:17px;background:var(--bg);color:var(--ink);border:1px solid var(--line);box-shadow:var(--shadow);padding:0;font-size:1.35rem}
.viewer-map-controls #world-locate{background:var(--accent);color:var(--on);border-color:var(--accent)}
#world-panel>.viewer-map-top{position:absolute;right:76px;bottom:48px;z-index:2;display:flex;align-items:center;gap:6px;max-width:min(26rem,calc(100% - 92px));border-radius:16px;background:var(--bg);padding:4px 8px;box-shadow:var(--shadow)}
#world-panel>.viewer-map-top[data-ready=true]{display:none}
#world-retry{padding:7px 12px;min-height:44px}
#world-status{font-size:.78rem;overflow-wrap:anywhere}
#world-help,#startup-location-note{position:absolute;bottom:0;left:0;z-index:2;margin:0;background:var(--bg);padding:4px 9px;border-radius:0 10px 0 0;font-size:.68rem;max-width:calc(100% - 8px);color:var(--ink)}
#startup-location-note{bottom:29px;font-size:.7rem;border-radius:0 10px 10px 0}#world-selection{position:absolute;left:16px;bottom:56px;z-index:1;max-width:calc(100% - 100px);padding:6px 10px;background:var(--bg);border-radius:10px;display:none}
#provider-tools{position:fixed;z-index:8;inset:16px 16px 16px auto;width:min(48rem,calc(100vw - 32px));max-height:calc(100dvh - 32px);overflow:auto;overscroll-behavior:contain;background:var(--bg);border:1px solid var(--line);border-radius:28px;padding:20px;box-shadow:0 0 0 100vmax #0006,var(--shadow);margin:0}
#provider-tools:not([open]){display:none}
#provider-tools .preferences,#provider-tools .legacy-map-tools,#local-map-panel,#search-privacy{padding:14px;border:1px solid var(--line);border-radius:20px;margin:12px 0}
#provider-tools .metrics,#provider-tools .regions{margin:12px 0}
#provider-tools .metrics article,#provider-tools .regions article,#provider-tools aside{border-radius:20px}
#provider-tools label{display:block;margin:8px 0;font-weight:600}
#provider-tools .viewer-map-wrap{position:relative;border:1px solid var(--line);border-radius:18px;overflow:hidden}
#viewer-map{display:block;width:100%;height:clamp(240px,45dvh,520px);touch-action:none;cursor:grab}
#local-map-panel .viewer-map-controls{right:10px;bottom:10px}
#local-map-panel .viewer-map-top,.viewer-search-row,.catalogue-page-controls,.workspace-tabs{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.viewer-search-row input{flex:1 1 12rem;min-width:0}.workspace-tabs{margin-bottom:10px}.workspace-tabs button[aria-pressed=false]{background:var(--surface);color:var(--ink)}
#provider-tools input[type=search],#provider-tools select{max-width:100%;min-width:0}
.viewer-switch{display:flex!important;align-items:center;gap:8px}.viewer-switch input{width:24px;height:24px;accent-color:var(--accent)}
#viewer-detail{background:var(--surface);border-radius:20px;padding:16px;margin-top:12px;overflow-wrap:anywhere}
.viewer-legend{font-size:.75rem;color:var(--muted);display:flex;gap:10px;flex-wrap:wrap}
#world-downloads a{display:block;padding:10px;overflow-wrap:anywhere}
#world-downloads details{border-left:1px solid var(--line);padding-left:12px}
@media(max-width:850px){.public-search{top:auto;bottom:46px;left:8px;width:calc(100vw - 76px);max-height:65dvh;padding:12px;border-radius:24px}.search-brand{margin-bottom:8px}.map-workspace header{top:8px;bottom:auto;left:auto;right:8px;max-width:calc(100% - 16px)}.viewer-map-controls{right:8px;bottom:44px}.viewer-results{max-height:30dvh}#world-panel>.viewer-map-top{bottom:104px;right:64px}#startup-location-note{bottom:29px}#provider-tools{inset:8px;width:auto;max-height:calc(100dvh - 16px);padding:14px}}
@media(max-width:380px){.search-pill>svg{display:none}.public-search{padding:8px}.search-brand small{display:none}}
@media(max-height:500px){.public-search{max-height:calc(100dvh - 105px)}.map-workspace header{top:8px;bottom:auto}.viewer-map-controls{gap:4px;bottom:26px}.viewer-map-controls button{width:44px;height:44px}}
@media(prefers-reduced-motion:no-preference){:root:not([data-motion=reduce]) .public-search button,:root:not([data-motion=reduce]) .viewer-map-controls button{transition:background .16s,border-radius .16s,transform .12s}}
@media(forced-colors:active){.public-search,.search-pill,.viewer-map-controls button,#provider-tools,.viewer-result{border:1px solid CanvasText}}

#local-map-panel #viewer-fit{width:auto;padding:8px 12px;font-size:.8rem} .stop-status:empty{display:none}.map-actions:has(>button:not([hidden])){margin-top:10px}.map-actions:not(:has(>button:not([hidden]))){display:none}

/* Search grows upwards, away from the attribution strip and map controls. */
@media(max-width:850px){.public-search{width:calc(100vw - 76px)}.search-brand{flex-wrap:wrap}.search-brand small{display:none}.search-pill{padding-left:8px}#world-panel>.viewer-map-top{bottom:auto;top:66px;right:8px;max-width:calc(100% - 16px)}}
@media(max-width:360px){.search-brand-mark{width:28px;height:28px}.search-brand{gap:6px;font-size:.94rem}.search-pill button{width:44px;height:44px}.public-search{padding:8px}}

/* Compact directions: one heading, grouped endpoints and secondary options.
   Keep the same 44px interactive targets and allow text scaling/wrapping. */
.public-search:has(#directions:not([hidden])) .search-brand{display:none}
#directions{margin:0;padding:0;border:0}
#directions .route-heading{margin:0 0 4px;min-height:44px;gap:4px;flex-wrap:wrap}
#directions .route-heading h2{margin:0;font-size:1.15rem;flex:1 1 auto}
#directions .route-heading select{flex:0 1 auto;width:auto;max-width:100%;font-size:.875rem}
#directions-close{flex:none}
#directions-close{background:transparent;color:var(--muted);border-radius:50%}
#directions #route-mode{min-height:44px;padding:6px 8px;border-radius:12px}
#route-stops{position:relative;margin:10px 0 0;display:grid;gap:8px}
.route-stop{margin:0;display:grid;grid-template-columns:24px minmax(0,1fr);gap:8px;align-items:start}
.route-stop .stop-body{min-width:0}
.stop-marker{position:relative;margin-top:30px;width:24px;height:24px;border:1px solid var(--line);color:var(--muted);background:var(--bg);z-index:1}
.route-stop[data-selected=true] .stop-marker{color:var(--accent);border-color:var(--accent)}
.route-stop:not(:last-child) .stop-marker:after{content:"";position:absolute;top:calc(100% + 4px);left:50%;height:22px;border-left:1px dotted var(--line)}
.stop-heading{display:flex;align-items:center;justify-content:space-between;gap:4px;flex-wrap:wrap;min-height:20px;margin-bottom:3px}
.stop-label{margin:0;font-size:.78rem;line-height:1.35}
.stop-form{gap:4px;min-width:0}
.stop-form input{min-height:44px;padding:8px 10px;border-radius:12px;font-size:.9rem}
.stop-form .stop-find{width:44px;height:44px;min-height:44px;padding:0;border-radius:12px;background:var(--surface);color:var(--accent);border:1px solid var(--line)}
.stop-form .stop-find:hover{border-color:var(--accent)}
.route-tools{display:flex;gap:2px;margin:0}
.route-tools:empty{display:none}
.route-tools button{width:44px;min-width:44px;height:44px;min-height:44px;padding:0;border-radius:12px;background:transparent;color:var(--muted);font-size:1.1rem}
.route-tools button:hover{background:var(--surface);color:var(--ink)}
.stop-status{margin:4px 0 0;font-size:.78rem}
.stop-results{max-height:14rem;margin:6px 0 0}
.route-action-row{display:flex;gap:8px;flex-wrap:wrap;margin:8px 0 2px}
.route-action-row button{flex:1 1 auto;background:transparent;color:var(--accent);min-height:44px;margin:0;padding:4px 8px;border-radius:12px}
.route-action-row button:hover{background:var(--surface)}
.route-options{margin:0;border-top:1px solid var(--line)}
.route-options summary{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:44px;font-size:.85rem;font-weight:600;list-style:none;padding:4px 2px}
.route-options summary::-webkit-details-marker{display:none}
.route-options summary:after{content:"";width:7px;height:7px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(45deg);margin:0 5px 4px 0;flex:none}
.route-options[open] summary:after{transform:rotate(225deg);margin-top:5px}
#route-online-state{font-size:.75rem;color:var(--muted);font-weight:400;margin-left:auto}
.route-consent{display:flex;align-items:center;gap:8px;font-size:.85rem;line-height:1.4;min-height:44px}
.route-consent input{accent-color:var(--accent);width:20px;height:20px;flex:none;margin:0}
.route-privacy,.route-disclosure{font-size:.75rem;color:var(--muted);line-height:1.4;margin:0 0 8px}
.route-privacy a{color:var(--ink)}
.route-options[open]+.route-disclosure{display:none}
#route-calculate{width:100%;margin:2px 0 0;min-height:48px}
.stop-form input:focus{outline:2px solid var(--accent);outline-offset:1px}
#route-summary{margin-top:8px;border-radius:16px;padding:12px}
@media(max-width:850px){.public-search:has(#directions:not([hidden])){max-height:calc(100dvh - 112px)}}

/* Restore reorder arrows without adding a separate full-height action row. */
.route-stop .stop-heading:has(.route-tools:not(:empty)){min-height:44px}
.route-stop:has(.route-tools:not(:empty)) .stop-marker{margin-top:54px}
.route-tools button:focus-visible{outline-offset:1px}
