:root {
  --ink: #14221c;
  --muted: #617269;
  --paper: #f8faf7;
  --panel: #ffffff;
  --line: #dce4df;
  --forest: #173f2c;
  --moss: #2d6a4f;
  --lime: #b8d84b;
  --candidate: #e6a800;
  --unknown: #78837e;
  --forbidden: #d33f32;
  --confirmed: #27935a;
  --shadow: 0 16px 42px rgba(16, 36, 27, .16);
  --profile-height: 250px;
  --profile-collapsed-height: 52px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input { font: inherit; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 2000; background: white; padding: .75rem 1rem; border-radius: .5rem; }
.skip-link:focus { top: 1rem; }

.topbar { height: 68px; display: flex; align-items: center; gap: 1rem; padding: 0 1.1rem; background: #101915; color: white; border-bottom: 1px solid rgba(255,255,255,.08); position: relative; z-index: 1001; }
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; min-width: 0; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: #101915; background: var(--lime); font-size: 1.75rem; line-height: 1; transform: rotate(-8deg); }
.brand strong { display: block; font-size: 1.08rem; letter-spacing: .02em; }
.brand small { display: block; color: #aebbb4; font-size: .68rem; margin-top: .1rem; letter-spacing: .025em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .55rem; }
.primary-button, .ghost-button, .icon-button, .planner-button, .secondary-button, .osmand-button { border: 0; border-radius: .65rem; cursor: pointer; font-weight: 750; }
.primary-button { padding: .68rem .9rem; color: #152016; background: var(--lime); text-decoration: none; }
.primary-button.inline { display: inline-flex; }
.ghost-button { padding: .65rem .8rem; color: #dce8e0; background: rgba(255,255,255,.07); }
.planner-button { padding: .65rem .8rem; color: #e9f3ed; background: rgba(184,216,75,.14); border: 1px solid rgba(184,216,75,.3); }
.planner-button.active { color: #152016; background: var(--lime); }
.icon-button { width: 40px; height: 40px; color: white; background: rgba(255,255,255,.08); }
.mobile-only { display: none; }

.workspace { height: calc(100% - 68px); display: block; overflow: hidden; }
body.profile-visible .workspace { height: calc(100% - 68px - var(--profile-height)); }
body.profile-visible.profile-collapsed .workspace { height: calc(100% - 68px - var(--profile-collapsed-height)); }
.sidebar { min-width: 0; height: 100%; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); z-index: 800; }
.intro { padding: 1.3rem 1.3rem .9rem; }
.eyebrow { margin: 0 0 .45rem; color: var(--moss); font-size: .73rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.intro h1 { margin: 0; max-width: 330px; font-size: clamp(1.55rem, 2.1vw, 2.15rem); line-height: 1.04; letter-spacing: -.045em; }
.intro > p:last-child { margin: .7rem 0 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.legal-warning { margin: 0 1.3rem .9rem; padding: .75rem .85rem; display: grid; gap: .2rem; border-left: 4px solid var(--candidate); background: #fff8db; border-radius: 0 .55rem .55rem 0; font-size: .77rem; line-height: 1.4; }
.legal-warning span { color: #625a36; }
.filters { padding: 0 1.3rem .9rem; border-bottom: 1px solid var(--line); }
.search-wrap input { width: 100%; padding: .68rem .75rem; border: 1px solid var(--line); border-radius: .65rem; outline: none; background: #fbfcfb; }
.search-wrap input:focus { border-color: var(--moss); box-shadow: 0 0 0 3px rgba(45,106,79,.12); }
.filter-row { display: flex; flex-wrap: wrap; gap: .38rem; margin-top: .62rem; }
.filter-chip { padding: .38rem .55rem; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--muted); font-size: .72rem; cursor: pointer; }
.filter-chip span { display: inline-grid; place-items: center; min-width: 1.1rem; height: 1.1rem; margin-left: .16rem; border-radius: 1rem; background: #edf1ee; font-size: .65rem; }
.filter-chip.active { color: white; background: var(--forest); border-color: var(--forest); }
.filter-chip.candidate.active { background: var(--candidate); border-color: var(--candidate); color: #302500; }
.filter-chip.unknown.active { background: var(--unknown); border-color: var(--unknown); color: white; }
.filter-chip.forbidden.active { background: var(--forbidden); border-color: var(--forbidden); color: white; }

.list-section { min-height: 0; display: flex; flex: 1; flex-direction: column; }
.list-heading { display: flex; align-items: center; justify-content: space-between; padding: .8rem 1.3rem .5rem; }
.list-heading h2 { margin: 0; font-size: .82rem; text-transform: uppercase; letter-spacing: .09em; }
.text-button { padding: .25rem; border: 0; background: none; color: var(--moss); font-size: .72rem; font-weight: 800; cursor: pointer; }
.route-list { min-height: 0; overflow-y: auto; padding: 0 .75rem .8rem; }
.route-card { width: 100%; display: grid; grid-template-columns: 5px 1fr auto; gap: .7rem; padding: .76rem .62rem; border: 0; border-bottom: 1px solid #edf1ee; background: white; color: inherit; text-align: left; cursor: pointer; }
.route-card:hover, .route-card:focus-visible { background: #f4f8f5; outline: none; }
.route-card.active { background: #edf5ef; border-radius: .55rem; }
.route-stripe { width: 5px; min-height: 46px; border-radius: 99px; background: var(--unknown); }
.route-stripe.kandidat { background: var(--candidate); }
.route-stripe.zakaz { background: var(--forbidden); }
.route-stripe.potvrdeny { background: var(--confirmed); }
.route-main strong { display: block; font-size: .83rem; line-height: 1.25; }
.route-main small { display: block; color: var(--muted); margin-top: .28rem; font-size: .7rem; }
.route-distance { color: var(--ink); font-size: .7rem; font-weight: 800; white-space: nowrap; }
.empty-state { padding: 1.3rem; color: var(--muted); font-size: .84rem; text-align: center; }
.sidebar-footer { padding: .65rem 1.3rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .67rem; }
.download-links { display: flex; gap: .65rem; }
.download-links a { color: var(--moss); font-weight: 800; }

.map-shell { position: relative; min-width: 0; height: 100%; background: #dde6e0; }
#map { width: 100%; height: 100%; }
.map-legend { position: absolute; left: 14px; bottom: 22px; z-index: 500; display: flex; flex-wrap: wrap; gap: .55rem; padding: .55rem .7rem; border: 1px solid rgba(20,34,28,.1); border-radius: .65rem; background: rgba(255,255,255,.94); box-shadow: 0 8px 22px rgba(20,34,28,.12); font-size: .68rem; }
.map-legend[hidden] { display: none; }
.map-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.legend-line { width: 20px; border-top: 4px solid; border-radius: 4px; }
.candidate { color: var(--candidate); }
.legend-line.candidate { border-color: var(--candidate); }
.legend-line.unknown { border-color: var(--unknown); border-top-style: dashed; }
.legend-line.forbidden { border-color: var(--forbidden); }
.legend-line.confirmed { border-color: var(--confirmed); }
.map-message { position: absolute; top: 12px; left: 50%; z-index: 600; transform: translateX(-50%); padding: .65rem .8rem; border-radius: .55rem; background: #fff; box-shadow: var(--shadow); font-size: .78rem; }
.map-shell.planning #map { cursor: crosshair; }
.planner-panel { position: absolute; top: 14px; right: 14px; z-index: 700; width: min(370px, calc(100% - 28px)); max-height: calc(100% - 28px); overflow-y: auto; padding: 1rem; border: 1px solid rgba(20,34,28,.12); border-radius: .9rem; background: rgba(255,255,255,.97); box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.planner-panel[hidden] { display: none; }
.planner-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; }
.planner-head h2 { margin: 0; font-size: 1.3rem; letter-spacing: -.025em; }
.planner-head .eyebrow { margin-bottom: .18rem; }
.planner-close { position: static; flex: 0 0 auto; }
.planner-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; margin: .9rem 0 .7rem; padding: .3rem; border-radius: .7rem; background: #edf2ee; }
.planner-tab { padding: .58rem .45rem; border: 0; border-radius: .5rem; background: transparent; color: var(--muted); font-size: .78rem; font-weight: 800; cursor: pointer; }
.planner-tab.active { color: white; background: var(--forest); box-shadow: 0 4px 12px rgba(23,63,44,.18); }
.planner-instructions { padding: .65rem .72rem; border-left: 3px solid #6d3bd1; border-radius: 0 .5rem .5rem 0; color: #463c5c; background: #f2edff; font-size: .78rem; line-height: 1.4; }
.planner-field { display: grid; gap: .35rem; margin-top: .75rem; }
.planner-field[hidden] { display: none; }
.planner-field label { color: var(--muted); font-size: .7rem; font-weight: 800; }
.planner-field select { width: 100%; padding: .62rem .68rem; border: 1px solid var(--line); border-radius: .55rem; color: var(--ink); background: white; font: inherit; font-size: .82rem; }
.planner-priority { display: grid; gap: .18rem; margin-top: .75rem; padding: .65rem .72rem; border: 1px solid var(--line); border-radius: .6rem; background: #f8faf8; }
.planner-priority strong { font-size: .75rem; }
.planner-priority span { color: var(--muted); font-size: .69rem; line-height: 1.4; }
.planner-actions { display: grid; grid-template-columns: 1fr auto; gap: .45rem; margin-top: .8rem; }
.planner-actions .primary-button { font-size: .78rem; }
.planner-actions .primary-button:disabled { cursor: not-allowed; opacity: .45; }
.secondary-button { padding: .65rem .75rem; color: var(--moss); background: #edf5ef; font-size: .76rem; }
.planner-status { margin-top: .65rem; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.route-result { margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.variant-nav { display: grid; grid-template-columns: 2.6rem 1fr 2.6rem; align-items: center; gap: .55rem; margin-bottom: .65rem; text-align: center; }
.variant-nav[hidden] { display: none; }
.variant-nav small { display: block; color: var(--muted); font-size: .62rem; }
.variant-nav strong { display: block; margin-top: .08rem; font-size: .88rem; }
.variant-arrow { width: 2.6rem; height: 2.6rem; border: 0; border-radius: 50%; color: white; background: #6d3bd1; cursor: pointer; font-size: 1.25rem; font-weight: 800; line-height: 1; box-shadow: 0 2px 8px #34215b2b; }
.variant-arrow:hover { background: #5930ac; }
.variant-arrow:focus-visible { outline: 3px solid #c8b5f4; outline-offset: 2px; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.result-stats div { padding: .55rem .62rem; border-radius: .55rem; background: #f2f5f3; }
.result-stats small { display: block; color: var(--muted); font-size: .62rem; }
.result-stats strong { display: block; margin-top: .12rem; font-size: .82rem; }
.result-road-types { margin-top: .55rem; padding: .58rem .62rem; border: 1px solid var(--line); border-radius: .55rem; background: #fafcfa; }
.result-road-types > small { display: block; margin-bottom: .38rem; color: var(--muted); font-size: .62rem; font-weight: 800; }
#result-road-breakdown { display: flex; flex-wrap: wrap; gap: .28rem; }
.road-type-chip { display: inline-flex; align-items: center; gap: .28rem; padding: .25rem .36rem; border-radius: 999px; background: #edf2ee; color: var(--ink); font-size: .59rem; font-weight: 750; }
.road-type-chip i { width: 7px; height: 7px; border-radius: 50%; }
.result-warning { margin-top: .6rem; padding: .6rem .7rem; border-left: 3px solid var(--candidate); border-radius: 0 .5rem .5rem 0; color: #625a36; background: #fff8db; font-size: .68rem; line-height: 1.42; }
.osmand-button { width: 100%; margin-top: .6rem; padding: .68rem .75rem; color: white; background: #6d3bd1; font-size: .78rem; }
.planner-sources { margin-top: .72rem; color: var(--muted); font-size: .67rem; line-height: 1.42; }
.planner-sources summary { color: var(--moss); font-weight: 800; cursor: pointer; }
.planner-sources p { margin: .35rem 0 0; }
.planner-marker-wrap { background: none; border: 0; }
.planner-marker { width: 34px; height: 34px; display: grid; place-items: center; border: 3px solid white; border-radius: 50% 50% 50% 5px; color: white; background: #6d3bd1; box-shadow: 0 5px 14px rgba(40,24,72,.38); font-size: .78rem; font-weight: 900; transform: rotate(-45deg); }
.planner-marker b { transform: rotate(45deg); }
.planner-marker { line-height: 1; }
.planner-marker { text-indent: 0; }
.legend-line.planned { border-color: #6d3bd1; }
.profile-panel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; height: var(--profile-height); display: grid; grid-template-columns: 250px minmax(0, 1fr); border-top: 1px solid #cad6cf; background: #fff; box-shadow: 0 -12px 35px rgba(16,36,27,.15); }
.profile-panel[hidden] { display: none; }
.profile-panel.collapsed { height: var(--profile-collapsed-height); display: block; }
.profile-controls { min-width: 0; padding: .9rem 1rem; border-right: 1px solid var(--line); background: #f8faf8; overflow-y: auto; }
.profile-controls .eyebrow { margin-bottom: .55rem; }
.profile-heading-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.profile-heading-row .eyebrow { margin: 0; }
.profile-toggle { display: inline-flex; align-items: center; gap: .35rem; flex: 0 0 auto; padding: .42rem .58rem; border: 1px solid var(--line); border-radius: .5rem; color: var(--forest); background: white; cursor: pointer; font-size: .67rem; font-weight: 850; }
.profile-toggle span { font-size: .95rem; line-height: .7; transition: transform .18s ease; }
.profile-panel:not(.collapsed) .profile-panel-content { margin-top: .55rem; }
.profile-panel.collapsed .profile-controls { height: var(--profile-collapsed-height); display: flex; align-items: center; padding: .45rem 1rem; border-right: 0; border-bottom: 0; overflow: hidden; }
.profile-panel.collapsed .profile-heading-row { width: 100%; }
.profile-panel.collapsed .profile-panel-content, .profile-panel.collapsed .profile-chart-wrap { display: none; }
.profile-panel.collapsed .profile-toggle span { transform: rotate(180deg); }
.profile-switch { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem; padding: .25rem; border-radius: .65rem; background: #e8eeea; }
.profile-mode { padding: .52rem .35rem; border: 0; border-radius: .48rem; color: var(--muted); background: transparent; font-size: .72rem; font-weight: 850; cursor: pointer; }
.profile-mode.active { color: white; background: var(--forest); box-shadow: 0 3px 10px rgba(23,63,44,.18); }
.profile-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: .32rem; margin-top: .55rem; }
.profile-metrics div { padding: .42rem .45rem; border: 1px solid var(--line); border-radius: .48rem; background: white; }
.profile-metrics small { display: block; color: var(--muted); font-size: .55rem; }
.profile-metrics strong { display: block; margin-top: .1rem; font-size: .7rem; white-space: nowrap; }
.profile-legend { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem .5rem; margin-top: .55rem; color: var(--muted); font-size: .59rem; }
.profile-legend span { display: flex; align-items: center; gap: .3rem; min-width: 0; }
.profile-legend i { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 3px; }
.profile-chart-wrap { position: relative; min-width: 0; padding: .75rem 1.2rem .55rem; overflow: hidden; }
.profile-chart-head { display: flex; align-items: flex-start; justify-content: space-between; min-height: 38px; }
.profile-chart-head h2 { margin: 0; font-size: .9rem; letter-spacing: -.015em; }
.profile-chart-head p { margin: .2rem 0 0; color: var(--muted); font-size: .62rem; }
#profile-chart { width: 100%; height: calc(100% - 38px); min-height: 150px; overflow: visible; }
#profile-chart text { fill: #65756d; font: 11px Inter, ui-sans-serif, system-ui, sans-serif; }
#profile-chart .axis-line { stroke: #ccd7d1; stroke-width: 1; }
#profile-chart .grid-line { stroke: #e3e9e5; stroke-width: 1; stroke-dasharray: 4 5; }
#profile-chart .road-segment { stroke: rgba(255,255,255,.72); stroke-width: .6; }
#profile-chart .elevation-area { fill: rgba(45,106,79,.17); }
#profile-chart .elevation-line { fill: none; stroke: #2d6a4f; stroke-width: 3; vector-effect: non-scaling-stroke; }
.profile-tooltip { position: absolute; z-index: 2; top: 58px; max-width: 220px; padding: .42rem .55rem; border: 1px solid var(--line); border-radius: .45rem; color: white; background: rgba(20,34,28,.94); box-shadow: 0 5px 14px rgba(20,34,28,.2); font-size: .64rem; pointer-events: none; transform: translateX(-50%); white-space: nowrap; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-interactive { transition: stroke-width .12s ease, opacity .12s ease; }
.profile-map-position { filter: drop-shadow(0 2px 5px rgba(35,20,65,.55)); }

dialog { color: var(--ink); border: 0; border-radius: 1rem; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(9,18,13,.58); backdrop-filter: blur(2px); }
.dialog-close { position: absolute; top: .75rem; right: .75rem; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #edf2ee; color: var(--ink); font-size: 1.4rem; cursor: pointer; }
.detail-dialog { width: min(570px, calc(100% - 2rem)); max-height: calc(100% - 2rem); padding: 1.35rem; }
.detail-dialog h2 { margin: .2rem 2.3rem .35rem 0; font-size: 1.45rem; line-height: 1.1; }
.status-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .34rem .54rem; border-radius: 99px; font-size: .69rem; font-weight: 850; }
.status-pill.kandidat { color: #514000; background: #fff0ac; }
.status-pill.nezname { color: white; background: var(--unknown); }
.status-pill.zakaz { color: white; background: var(--forbidden); }
.status-pill.potvrdeny { color: white; background: var(--confirmed); }
.detail-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 1rem 0; }
.detail-meta div { padding: .65rem; border: 1px solid var(--line); border-radius: .6rem; background: #fafcfa; }
.detail-meta small { display: block; color: var(--muted); font-size: .65rem; }
.detail-meta strong { display: block; margin-top: .18rem; font-size: .82rem; }
.evidence-box { margin-top: .7rem; padding: .8rem; border-radius: .65rem; background: #f2f5f3; font-size: .8rem; line-height: 1.48; }
.evidence-box.warning { background: #fff7db; }
.evidence-box h3 { margin: 0 0 .25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; }
.detail-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1rem; }
.detail-actions a { padding: .58rem .7rem; border-radius: .55rem; color: var(--moss); background: #edf5ef; font-size: .74rem; font-weight: 800; text-decoration: none; }
.about-dialog { width: min(760px, calc(100% - 2rem)); padding: 1.5rem; }
.about-dialog h2 { max-width: 620px; margin: .1rem 2rem 1.2rem 0; font-size: 1.6rem; }
.method-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.method-grid article { position: relative; padding: .85rem .9rem; border: 1px solid var(--line); border-radius: .7rem; }
.method-grid h3 { margin: 0 0 .25rem; font-size: .88rem; }
.method-grid p { margin: 0; color: var(--muted); font-size: .77rem; line-height: 1.45; }
.status-dot { position: absolute; top: .95rem; left: .85rem; width: 10px; height: 10px; border-radius: 50%; background: var(--unknown); }
.status-dot.candidate { background: var(--candidate); }
.status-dot.forbidden { background: var(--forbidden); }
.status-dot.confirmed { background: var(--confirmed); }
.about-note { margin: 1rem 0; color: var(--muted); font-size: .8rem; }

@media (max-width: 760px) {
  :root { --profile-height: 290px; }
  .topbar { height: 60px; padding: 0 .7rem; }
  .brand small, .ghost-button { display: none; }
  .topbar-actions { gap: .35rem; }
  .planner-button { padding: .58rem .62rem; font-size: .72rem; }
  .primary-button { padding: .6rem .7rem; font-size: .75rem; }
  .workspace { height: calc(100% - 60px); display: block; }
  body.profile-visible .workspace { height: calc(100% - 60px - var(--profile-height)); }
  body.profile-visible.profile-collapsed .workspace { height: calc(100% - 60px - var(--profile-collapsed-height)); }
  .map-shell { height: 100%; }
  .planner-panel { top: 8px; right: 8px; width: calc(100% - 16px); max-height: calc(100% - 16px); }
  .profile-panel { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .profile-controls { padding: .55rem .7rem; border-right: 0; border-bottom: 1px solid var(--line); overflow: visible; }
  .profile-controls .eyebrow { display: none; }
  .profile-panel.collapsed .profile-controls .eyebrow { display: block; margin: 0; }
  .profile-switch { width: 220px; }
  .profile-metrics { position: absolute; top: .55rem; right: .7rem; width: calc(100% - 244px); margin: 0; }
  .profile-legend { display: none; }
  .profile-chart-wrap { padding: .5rem .65rem .35rem; }
  .profile-chart-head { min-height: 34px; }
  .profile-chart-head p { display: none; }
  #profile-chart { min-height: 145px; height: calc(100% - 32px); }
  .map-legend { left: 10px; right: 10px; bottom: 12px; justify-content: center; }
  .method-grid { grid-template-columns: 1fr; }
  .detail-meta { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .profile-switch { width: 190px; }
  .profile-metrics { width: calc(100% - 210px); }
  .profile-metrics div:nth-child(n+2) { display: none; }
  .profile-metrics { grid-template-columns: 1fr; }
}

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