/* Разметка — нощна маркировка. Виж docs/brand-web-direction.md */
@font-face { font-family: 'Sofia Sans'; src: url('fonts/SofiaSans.woff2') format('woff2'); font-weight: 1 1000; font-display: swap; }
@font-face { font-family: 'Sofia Sans XC'; src: url('fonts/SofiaSansExtraCondensed.woff2') format('woff2'); font-weight: 1 1000; font-display: swap; }

:root {
  --asphalt: #0E1013; --asphalt-2: #171A1F; --asphalt-3: #22262D; --asphalt-4: #2E333B;
  --paint: #F2EFE6; --paint-dim: #9AA0A8; --paint-mute: #5A6069; --paint-faint: #353A42;
  --works: #FFC21A; --brake: #FF4D2E; --surge: #FF8A1F; --fog: #B7B2E8; --ice: #6FE3FF; --wind: #C7F36B; --rain: #4D9BFF;
  --r: 14px; --r-s: 9px;
  --sheet-w: 440px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --display: 'Sofia Sans XC', 'Sofia Sans', 'Arial Narrow', Arial, 'Noto Sans', sans-serif;
  --text: 'Sofia Sans', Arial, 'Noto Sans', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--asphalt); color: var(--paint); font-family: var(--text); font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased; overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums lining-nums; }
a { color: var(--paint); }
:focus-visible { outline: 2px solid var(--works); outline-offset: 2px; border-radius: 4px; }

#map, #map.maplibregl-map { position: fixed; inset: 0; width: 100%; height: 100%; }
.maplibregl-ctrl-attrib { background: rgba(14,16,19,.7) !important; color: var(--paint-dim); font-size: 11px; }
.maplibregl-ctrl-attrib a { color: var(--paint-dim) !important; }
.maplibregl-ctrl-group { background: var(--asphalt-2) !important; border: 1px solid var(--asphalt-4); box-shadow: none !important; }
.maplibregl-ctrl-group button { filter: invert(.9); }
.maplibregl-ctrl-group button + button { border-top: 1px solid #ccc !important; }

/* ——— горна лента ——— */
.top { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; z-index: 5; display: flex; align-items: center; gap: 10px; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { text-decoration: none; color: var(--paint); display: flex; align-items: center; gap: 10px; background: rgba(14,16,19,.86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--asphalt-4); border-radius: 999px; padding: 7px 14px 7px 12px; }
.brand-mark { width: 26px; height: 26px; }
.brand-name { font-family: var(--display); font-weight: 850; font-size: 22px; letter-spacing: .02em; text-transform: uppercase; line-height: 1; }
.live { display: flex; align-items: center; gap: 7px; background: rgba(14,16,19,.86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--asphalt-4); border-radius: 999px; padding: 8px 12px; font-size: 13px; color: var(--paint-dim); white-space: nowrap; }
.live b { color: var(--paint); font-weight: 650; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--paint); box-shadow: 0 0 0 0 rgba(242,239,230,.6); animation: livepulse 2.4s infinite; }
.live.late i { background: var(--works); animation: none; }
.live.dead i { background: var(--brake); animation: none; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(242,239,230,.5); } 70% { box-shadow: 0 0 0 8px rgba(242,239,230,0); } 100% { box-shadow: 0 0 0 0 rgba(242,239,230,0); } }
.layers { position: fixed; z-index: 4; top: calc(max(12px, env(safe-area-inset-top)) + 52px); left: 12px; display: flex; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 999px; background: rgba(14,16,19,.86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--asphalt-4); font-size: 13.5px; color: var(--paint-dim); font-weight: 600; white-space: nowrap; }
.chip[aria-pressed="true"] { color: var(--paint); background: rgba(34,38,45,.92); border-color: #4A505A; }
.chip[aria-pressed="false"] { opacity: .6; }
.chip[aria-pressed="false"] .sw { background: var(--paint-mute); }
.chip .sw { width: 10px; height: 3px; border-radius: 2px; background: currentColor; }

/* ——— лист (bottom sheet / страничен панел) ——— */
.sheet { position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; height: 92dvh; background: var(--asphalt); border-top: 1px solid var(--asphalt-4); border-radius: 20px 20px 0 0; display: flex; flex-direction: column; transform: translateY(calc(92dvh - var(--peek, 236px))); transition: transform .32s var(--ease); box-shadow: 0 -20px 60px rgba(0,0,0,.5); touch-action: none; }
.sheet.dragging { transition: none; }
.grab { padding: 9px 0 4px; display: grid; place-items: center; cursor: grab; flex: none; }
.grab span { display: block; width: 44px; height: 5px; border-radius: 3px; background: repeating-linear-gradient(90deg, var(--paint-mute) 0 8px, transparent 8px 12px); }
.tabs { display: flex; gap: 2px; padding: 4px 12px 10px; overflow-x: auto; scrollbar-width: none; flex: none; border-bottom: 1px solid var(--asphalt-3); }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 8px 11px; border-radius: 10px; font-weight: 650; font-size: 15px; color: var(--paint-dim); white-space: nowrap; position: relative; }
.tab[aria-selected="true"] { color: var(--paint); background: var(--asphalt-3); }
.tab .dot { position: absolute; top: 6px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--brake); }
.body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px calc(28px + env(safe-area-inset-bottom)); touch-action: pan-y; -webkit-overflow-scrolling: touch; }
.foot { margin-top: 26px; padding-top: 14px; border-top: 1px dashed var(--asphalt-4); font-size: 12.5px; color: var(--paint-mute); line-height: 1.5; }
.foot a { color: var(--paint-dim); }

@media (min-width: 900px) {
  .sheet { left: 12px; top: 74px; bottom: 12px; right: auto; width: var(--sheet-w); height: auto; border: 1px solid var(--asphalt-4); border-radius: 18px; transform: none !important; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
  .grab { display: none; }
  .tabs { padding-top: 12px; gap: 0; }
  .tab { padding: 8px 9px; font-size: 14.5px; }
  .layers { left: calc(var(--sheet-w) + 24px); top: calc(max(12px, env(safe-area-inset-top)) + 4px); }
  .top { right: auto; }
  .top .live { margin-left: 0; }
  .maplibregl-ctrl-top-right { top: 6px; }
}

/* ——— типография ——— */
.kicker { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--paint-dim); }
.big { font-family: var(--display); font-weight: 850; font-size: clamp(56px, 16vw, 76px); line-height: .9; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.big small { font-size: .38em; font-weight: 700; color: var(--paint-dim); letter-spacing: 0; margin-left: 6px; }
.h { font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1; margin: 0; }
.h2 { font-family: var(--display); font-weight: 800; font-size: 22px; line-height: 1.05; margin: 26px 0 10px; display: flex; align-items: baseline; gap: 8px; }
.h2 .count { font-family: var(--text); font-size: 14px; color: var(--paint-mute); font-weight: 600; }
.muted { color: var(--paint-dim); }
.mute { color: var(--paint-mute); }
.delta { font-weight: 700; }
.delta.up { color: var(--surge); } .delta.down { color: var(--ice); } .delta.flat { color: var(--paint-dim); }
p { margin: 6px 0; }

/* ——— „Лента“ — подписът ——— */
.lane { display: flex; align-items: flex-end; gap: 2px; height: 64px; position: relative; }
.lane .d { flex: 1; min-width: 2px; border-radius: 2px; background: var(--paint-mute); position: relative; transition: height .5s var(--ease); }
.lane .d.n { background: transparent; box-shadow: inset 0 0 0 1px var(--paint-faint); }
.lane .d.on { background: var(--paint); }
.lane .d.busy { background: var(--works); } .lane .d.surge { background: var(--surge); } .lane .d.jam { background: var(--brake); }
.lane .d.now { box-shadow: 0 0 0 1.5px var(--works); }
.lane .d.fut { background: transparent; box-shadow: inset 0 0 0 1px var(--paint-mute); }
.lane .d.best { background: var(--paint); }
.lane-axis { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--paint-mute); margin-top: 5px; font-variant-numeric: tabular-nums; }
.lane-dash { height: 4px; background: repeating-linear-gradient(90deg, var(--paint-mute) 0 18px, transparent 18px 30px); border-radius: 2px; opacity: .7; }
.lane-dash.flow { animation: flow linear infinite; background-size: 30px 4px; }
@keyframes flow { from { background-position: 0 0; } to { background-position: 30px 0; } }
.duo { position: relative; height: 96px; }
.duo svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* ——— карти/редове ——— */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 16px; }
.stat { background: var(--asphalt-2); border: 1px solid var(--asphalt-3); border-radius: var(--r-s); padding: 9px 9px 8px; text-align: left; }
.stat b { display: block; font-family: var(--display); font-size: 28px; font-weight: 850; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--paint-dim); line-height: 1.15; display: block; margin-top: 3px; }
.stat.hot b { color: var(--brake); } .stat.warm b { color: var(--surge); } .stat.works b { color: var(--works); } .stat.cold b { color: var(--ice); }
.rows { display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: 4px 1fr auto; gap: 12px; align-items: center; background: var(--asphalt-2); border: 1px solid var(--asphalt-3); border-radius: var(--r-s); padding: 11px 12px 11px 0; text-align: left; width: 100%; overflow: hidden; }
.row:hover { border-color: var(--asphalt-4); background: #1B1F25; }
.row .bar { align-self: stretch; border-radius: 0 3px 3px 0; background: var(--paint-mute); }
.row .t { font-weight: 700; font-size: 15.5px; line-height: 1.2; }
.row .s { font-size: 13px; color: var(--paint-dim); margin-top: 2px; line-height: 1.3; }
.row .v { text-align: right; font-family: var(--display); font-weight: 800; font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.row .v small { display: block; font-family: var(--text); font-size: 11.5px; font-weight: 600; color: var(--paint-dim); margin-top: 2px; }
.st-jam .bar, .st-slow .bar { background: var(--brake); } .st-surge .bar { background: var(--surge); } .st-busy .bar { background: var(--works); } .st-empty .bar { background: var(--paint-dim); }
.hz-fog .bar { background: var(--fog); } .hz-ice .bar, .hz-snow .bar { background: var(--ice); } .hz-wind .bar { background: var(--wind); } .hz-rain .bar, .hz-storm .bar { background: var(--rain); }
.cl-full .bar { background: var(--brake); } .cl-lane .bar { background: var(--works); } .cl-other .bar { background: var(--paint-mute); }
.tag { display: inline-block; font-size: 11.5px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; padding: 2px 7px; border-radius: 5px; background: var(--asphalt-3); color: var(--paint-dim); vertical-align: 1px; }
.tag.jam, .tag.slow, .tag.full { background: rgba(255,77,46,.16); color: #FF7A60; } .tag.surge { background: rgba(255,138,31,.15); color: var(--surge); } .tag.busy, .tag.works, .tag.late { background: rgba(255,194,26,.14); color: var(--works); }
.tag.fog { background: rgba(183,178,232,.15); color: var(--fog); } .tag.ice, .tag.snow { background: rgba(111,227,255,.13); color: var(--ice); } .tag.wind { background: rgba(199,243,107,.13); color: var(--wind); } .tag.rain, .tag.storm { background: rgba(77,155,255,.15); color: var(--rain); }
.empty-state { padding: 18px 14px; border: 1px dashed var(--asphalt-4); border-radius: var(--r-s); color: var(--paint-dim); font-size: 14.5px; }
.empty-state b { color: var(--paint); }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
.seg button { white-space: nowrap; padding: 8px 12px; border-radius: 9px; background: var(--asphalt-2); border: 1px solid var(--asphalt-3); font-weight: 650; font-size: 14px; color: var(--paint-dim); }
.seg button[aria-pressed="true"] { background: var(--paint); color: var(--asphalt); border-color: var(--paint); }
.scroller { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; }
.scroller::-webkit-scrollbar { display: none; }
.field { display: flex; gap: 8px; align-items: center; }
.field input[type=date], .field input[type=search] { background: var(--asphalt-2); border: 1px solid var(--asphalt-3); border-radius: 9px; padding: 8px 10px; color: var(--paint); min-width: 0; }
.field input[type=search] { flex: 1; }
.card { background: var(--asphalt-2); border: 1px solid var(--asphalt-3); border-radius: var(--r); padding: 14px; }
.card + .card { margin-top: 8px; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.kv div b { display: block; font-family: var(--display); font-weight: 850; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.kv div span { font-size: 12.5px; color: var(--paint-dim); }
.back { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; color: var(--paint-dim); margin-bottom: 10px; font-size: 14.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--paint-dim); margin-top: 8px; }
.legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.bestline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.bestline .big { font-size: clamp(48px, 14vw, 64px); }
.strip { display: grid; grid-template-columns: 70px 1fr 50px; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--asphalt-3); font-size: 14px; }
.strip:last-child { border-bottom: 0; }
.strip .lane { height: 26px; gap: 1.5px; }
.strip b { font-family: var(--display); font-weight: 800; font-size: 20px; text-align: right; font-variant-numeric: tabular-nums; }
.route { position: relative; padding-left: 22px; }
.route::before { content: ''; position: absolute; left: 7px; top: 10px; bottom: 10px; width: 3px; background: repeating-linear-gradient(180deg, var(--paint-mute) 0 10px, transparent 10px 17px); }
.route .stop { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; font-size: 14.5px; width: 100%; text-align: left; }
.route .stop::before { content: ''; position: absolute; left: -20px; width: 11px; height: 11px; border-radius: 50%; background: var(--asphalt); border: 2px solid var(--paint-mute); }
.route .stop.st-jam::before, .route .stop.st-slow::before { background: var(--brake); border-color: var(--brake); }
.route .stop.st-surge::before { background: var(--surge); border-color: var(--surge); }
.route .stop.st-busy::before { background: var(--works); border-color: var(--works); }
.route .stop .km { color: var(--paint-mute); font-size: 12.5px; font-variant-numeric: tabular-nums; margin-right: 6px; }
.route .stop .r { color: var(--paint-dim); font-variant-numeric: tabular-nums; font-size: 13.5px; white-space: nowrap; }
.banner { background: rgba(255,194,26,.1); border: 1px solid rgba(255,194,26,.35); color: #FFD966; border-radius: var(--r-s); padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.skeleton { height: 64px; border-radius: 6px; background: var(--asphalt-2); }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 10px; background: var(--paint); color: var(--asphalt); font-weight: 750; text-decoration: none; }
.btn.ghost { background: var(--asphalt-2); color: var(--paint); border: 1px solid var(--asphalt-4); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ex-card { background: var(--asphalt-2); border: 1px solid var(--asphalt-3); border-radius: var(--r); padding: 12px; }
.ex-card .nm { font-family: var(--display); font-weight: 850; font-size: 24px; line-height: 1; }
.ex-card .sub { font-size: 12px; color: var(--paint-mute); margin: 2px 0 8px; }
.ex-card .n { font-family: var(--display); font-weight: 850; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.ex-card .lane { height: 34px; gap: 1.5px; margin-top: 8px; }

/* ——— маркери ——— */
.pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--brake); border: 2px solid var(--asphalt); position: relative; pointer-events: none; }
.pulse::after { content: ''; position: absolute; inset: -9px; border-radius: 50%; border: 2px solid var(--brake); animation: brake 1.6s var(--ease) infinite; }
@keyframes brake { 0% { transform: scale(.4); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
.maplibregl-popup-content { background: var(--asphalt-2); color: var(--paint); border: 1px solid var(--asphalt-4); border-radius: 10px; padding: 8px 11px; font: 600 13.5px/1.3 var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.maplibregl-popup-tip { border-top-color: var(--asphalt-4) !important; border-bottom-color: var(--asphalt-4) !important; }

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

/* ——— маршрут ——— */
.places { position: relative; display: flex; flex-direction: column; gap: 6px; padding-right: 46px; }
.place { position: relative; }
.place input { width: 100%; background: var(--asphalt-2); border: 1px solid var(--asphalt-4); border-radius: 11px; padding: 12px 12px 12px 34px; color: var(--paint); font-size: 16px; }
.place input:focus { outline: none; border-color: var(--paint-dim); }
.place-dot { position: absolute; left: 13px; top: 50%; width: 11px; height: 11px; margin-top: -5.5px; border-radius: 50%; background: var(--paint); }
.place-dot.to { background: var(--works); border-radius: 2px; }
.swap { position: absolute; right: 0; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border-radius: 10px; background: var(--asphalt-2); border: 1px solid var(--asphalt-4); font-size: 18px; }
.sugg { display: none; position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: var(--asphalt-2); border: 1px solid var(--asphalt-4); border-radius: 11px; overflow: hidden; box-shadow: 0 16px 40px rgba(0,0,0,.6); }
.sugg.open { display: block; }
.sugg button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--asphalt-3); }
.sugg button:last-child { border-bottom: 0; }
.sugg button:hover, .sugg button.sel { background: var(--asphalt-3); }
.sugg b { display: block; font-weight: 700; } .sugg span { font-size: 13px; color: var(--paint-dim); }
.sugg .none { padding: 12px; color: var(--paint-dim); font-size: 14px; }
.ghostbtn { padding: 8px 12px; border-radius: 9px; background: transparent !important; border: 1px dashed var(--asphalt-4) !important; color: var(--paint-dim) !important; font-weight: 650; font-size: 14px; }
.route .stop.st-incident::before { background: var(--brake); border-color: var(--paint); }
.route .stop.st-closure::before { background: var(--works); border-color: var(--works); border-radius: 2px; }
.route .stop.st-closure.full::before { background: var(--brake); border-color: var(--brake); }
.cl-lane .bar, .cl-other .bar { background: var(--works); }
.route .stop.st-wx::before { width: 7px; height: 7px; left: -18px; background: var(--asphalt); border-color: rgba(111,227,255,.5); }
.route .stop.st-wx.hz::before { background: var(--ice); border-color: var(--ice); }
.route .stop .r { text-align: right; }
.tag.incident { background: var(--brake); color: #fff; }
.st-incident .bar { background: var(--brake); box-shadow: 0 0 12px var(--brake); }
