:root {
    color-scheme: light;
    --ink: #233b4b;
    --muted: #5c6f7c;
    --accent: #175e9a;
    --line: #dce4e8;
    --shadow: 0 6px 28px #233b4b1c, 0 1px 4px #233b4b14;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.5 system-ui, sans-serif; color: var(--ink); background: #f4f5f2; }
#map { position: absolute; inset: 0; }
.routing-panel {
    position: absolute; z-index: 2; top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left)); width: 340px;
    max-height: calc(100dvh - 100px); display: flex; flex-direction: column;
    padding: 20px; border: 1px solid #ffffff; border-radius: 16px;
    background: #fffffff5; box-shadow: var(--shadow);
}
.panel-header { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
#panel-content { min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--ink); color: #fff; font-size: 22px; font-weight: 800; }
h1 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -.5px; }
h1 span { font-weight: 400; color: var(--muted); }
.eyebrow { margin: 3px 0 0; font-size: 11px; color: var(--muted); }
.map-hint { margin: 18px 0; font-size: 13px; color: var(--muted); }
.point-field { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.point-field > div { flex: 1; min-width: 0; }
.point-badge { display: grid; place-items: center; flex: 0 0 26px; height: 26px; font-weight: 700; font-size: 12px; color: #fff; }
.start { background: #23785b; border-radius: 50%; }
.end { background: #ad4c3b; border-radius: 6px; }
label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; }
input, button { font: inherit; }
input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #bac9d2; border-radius: 9px; background: #f8fafb; color: var(--ink); font-variant-numeric: tabular-nums; }
input:hover { border-color: #819aaa; }
input::placeholder { color: var(--muted); }
.field-hint { margin: 6px 0 16px 36px; color: var(--muted); font-size: 11px; }
.routing-panel button { width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 9px; font-weight: 600; color: #fff; background: var(--accent); cursor: pointer; touch-action: manipulation; transition: background .15s; }
.routing-panel button:hover { background: #124d80; }
.routing-panel button.secondary { color: var(--ink); background: #edf2f5; font-size: 12px; }
.routing-panel button.secondary:hover { background: #dee8ee; }
.routing-panel button:disabled { opacity: .55; cursor: default; }
.secondary-actions { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8px; margin-top: 8px; }
.routing-panel button.icon-button { flex: 0 0 44px; width: 44px; margin-left: auto; background: #edf2f5; color: var(--ink); padding: 0; font-size: 23px; }
.routing-panel button.icon-button:hover { background: #dee8ee; }
:focus-visible { outline: 3px solid #ca8717; outline-offset: 3px; }
#route-info { margin-top: 16px; padding: 12px 14px; border-radius: 9px; background: #eef5fa; color: #214d70; white-space: pre-line; font-variant-numeric: tabular-nums; }
#route-info:empty { display: none; }
#route-info.error { color: #8d3024; background: #fff0ec; }
details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; font-size: 12px; color: var(--muted); }
summary { min-height: 28px; cursor: pointer; color: var(--ink); font-weight: 500; }
.map-legend { padding: 0; margin: 8px 0 0; list-style: none; display: grid; gap: 9px; }
.map-legend li { display: flex; align-items: center; gap: 10px; }
.legend-line { width: 30px; flex-shrink: 0; border-top: 4px solid; }
.legend-line.motorway { color: #eeb077; }
.legend-line.main-road { color: #f4d397; }
.legend-line.local-road { height: 5px; border: 1px solid #cccac4; background: #fff; }
.legend-line.country-border { border-top: 2px dashed #83738f; }
.legend-line.region-border { border-top: 1px dashed #a39ab6; }
.legend-line.route { border-top: 4px solid #175e9a; }
.route-marker { display: grid; place-items: center; width: 32px; height: 32px; border: 3px solid #fff; box-shadow: 0 2px 6px #233b4b55; color: #fff; font: 700 14px/1 system-ui, sans-serif; }
#loading { position: absolute; z-index: 3; top: 18px; left: 50%; transform: translateX(-50%); max-width: min(450px, 85vw); padding: 12px 18px; border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
#coords { position: absolute; bottom: 46px; right: 12px; background: #fffffff0; color: var(--muted); padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; font: 11px/1.4 ui-monospace, monospace; pointer-events: none; }
.maplibregl-ctrl-group { border-radius: 10px; overflow: hidden; }
.maplibregl-ctrl-group:not(:empty) { box-shadow: var(--shadow); }
.maplibregl-ctrl-group button { width: 40px; height: 40px; min-height: 40px; border-radius: 0; }
.maplibregl-ctrl-top-right { top: env(safe-area-inset-top); right: env(safe-area-inset-right); }
.maplibregl-ctrl-bottom-left, .maplibregl-ctrl-bottom-right { bottom: env(safe-area-inset-bottom); }
.maplibregl-ctrl-attrib { font-size: 10px; }
noscript { position: absolute; z-index: 4; inset: 20px auto auto 20px; padding: 20px; background: #fff; }
@media (max-width: 700px) {
    .routing-panel { top: auto; bottom: calc(48px + env(safe-area-inset-bottom)); left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); width: auto; max-height: 46dvh; padding: 14px; border-radius: 14px; }
    .panel-header { gap: 9px; }
    .brand-mark { width: 32px; height: 32px; font-size: 19px; border-radius: 9px; }
    h1 { font-size: 18px; }
    .map-hint { margin: 12px 0; }
    .point-field { margin: 9px 0; }
    input { font-size: 16px; }
    #coords { top: max(10px, env(safe-area-inset-top)); bottom: auto; left: max(10px, env(safe-area-inset-left)); right: auto; }
    #loading { top: max(50px, env(safe-area-inset-top)); }
}
@media (prefers-reduced-motion: reduce) { .routing-panel button { transition: none; } }
