:root {
  --bg: #f6f7f9; --card: #fff; --fg: #15202b; --muted: #6b7785; --line: #e3e7ec;
  --acc: #0f766e; --acc2: #ccfbf1; --soon: #c2410c; --stop: #0f766e;
  --bus: #2563eb; --tram: #dc2626; --trolley: #7c3aed; --train: #0f766e; --coach: #b45309; --ferry: #0891b2;
  --hdr: 52px; --nav: 58px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1419; --card: #182028; --fg: #e7ecf1; --muted: #8b98a5; --line: #26313b; --acc: #2dd4bf; --acc2: #134e4a; --soon: #fb923c; --stop: #2dd4bf; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

#map { position: fixed; inset: 0; z-index: 0; background: var(--bg); }
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
.leaflet-container { font: inherit; }

header { position: fixed; top: 0; left: 0; right: 0; z-index: 20; height: var(--hdr); display: flex; gap: 8px; align-items: center;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: color-mix(in srgb, var(--card) 92%, transparent);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.logo { font-weight: 800; color: var(--acc); font-size: 18px; }
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; margin-left: auto; }
.seg button { white-space: nowrap; border: 0; background: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 14px; }
.seg button.on { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: 0 1px 2px #0002; }
#lang { width: auto; flex: none; border: 1px solid var(--line); background: var(--card); color: var(--fg); border-radius: 8px; padding: 5px; font: inherit; font-size: 14px; }

.vehnote { position: fixed; top: calc(var(--hdr) + 8px); left: 10px; z-index: 5; font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--card) 85%, transparent); color: var(--muted); border: 1px solid var(--line); pointer-events: none; }
/* «где я»: на телефоне едет над верхним краем шторки, на десктопе внизу справа на карте */
.fab { position: absolute; right: 12px; top: -58px; z-index: 5; width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--card); color: var(--acc); box-shadow: 0 2px 8px #0003; padding: 0; }
.vehnote.warn { color: var(--soon); border-color: var(--soon); }
.fab.on { background: var(--acc); color: #fff; }
.sheet[data-state=full] .fab { display: none; }

/* шторка */
.sheet { position: fixed; left: 0; right: 0; bottom: var(--nav); z-index: 10; background: var(--card); border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 24px #0003; display: flex; flex-direction: column; transition: height .22s ease, transform .22s ease;
  height: calc(100dvh - var(--hdr) - var(--nav) - 10px); }
.sheet[data-state=half] { height: 46dvh; }
.sheet[data-state=peek] { height: 108px; }
.sheet.dragging { transition: none; }
.grab { flex: none; height: 22px; display: flex; align-items: center; justify-content: center; cursor: grab; touch-action: none; }
.grab span { width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
#view { flex: 1; overflow: auto; padding: 0 14px 18px; overscroll-behavior: contain; }

nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav); display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 21; }
nav a { flex: 1; text-align: center; padding: 7px 0 8px; font-size: 12px; color: var(--muted); }
nav a span { display: block; font-size: 20px; line-height: 1.2; }
nav a.on { color: var(--acc); font-weight: 600; }

/* десктоп: панель слева, карта справа */
@media (min-width: 900px) {
  .sheet, .sheet[data-state] { top: var(--hdr); bottom: 0; right: auto; width: 420px; height: auto; border-radius: 0; transform: none !important; box-shadow: 4px 0 16px #0002; }
  .grab { display: none; }
  .fab, .sheet[data-state=full] .fab { display: flex; position: fixed; top: auto; right: 16px; bottom: 24px; }
  #view { padding-top: 6px; padding-bottom: calc(var(--nav) + 18px); }
  nav { right: auto; width: 420px; }
  .vehnote { left: 432px; }
}

h2 { font-size: 18px; margin: 16px 0 8px; } h3 { font-size: 15px; margin: 16px 0 6px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .grow { flex: 1; min-width: 0; } .big { font-size: 18px; font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.card { display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 8px 0; }
.ttl { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.deps { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-variant-numeric: tabular-nums; }
.deps.col { flex-direction: column; gap: 2px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 26px; padding: 0 6px; border-radius: 7px;
  color: #fff; font-weight: 700; font-size: 14px; background: var(--bus); flex: none; white-space: nowrap; }
.badge.lg { min-width: 46px; height: 34px; font-size: 17px; }
.m-tram { background: var(--tram); } .m-trolley { background: var(--trolley); } .m-train { background: var(--train); }
.m-coach { background: var(--coach); } .m-ferry { background: var(--ferry); }
.soon { color: var(--soon); }
.btn { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 14px; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; font-weight: 600; }
.search, select, input[type=date], input[type=time], .tf input { width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 12px; padding: 11px 12px; font: inherit; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.grid a { display: flex; flex-direction: column; align-items: center; gap: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; }
.grid small { font-size: 10px; color: var(--muted); text-align: center; line-height: 1.15; max-height: 2.3em; overflow: hidden; }
.list { display: flex; flex-direction: column; }
.list > a, .list > .dep { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.dep { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.grp { padding: 7px 0; }
.tms { display: flex; gap: 10px; font-variant-numeric: tabular-nums; flex: none; }
.tms > * { min-width: 46px; text-align: right; }
.tm { font-weight: 700; font-variant-numeric: tabular-nums; }
.pst { opacity: .4; } .nx { background: var(--acc2); border-radius: 6px; }
.head { margin: 2px 0 8px; }
.back { border: 0; background: none; font-size: 28px; line-height: 1; padding: 0 6px 0 0; color: var(--muted); }
.star { border: 0; background: none; font-size: 26px; color: var(--line); padding: 0 4px; }
.star.on { color: #f59e0b; }
.chips { display: flex; gap: 6px; margin: 8px 0; flex-wrap: wrap; align-items: center; }
.chips button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 7px 12px; font-size: 14px; }
.chips button.on { background: var(--acc); border-color: var(--acc); color: #fff; }
.chips input[type=date] { width: auto; padding: 6px 8px; font-size: 14px; }
.dirs button { text-align: left; }
.next { background: var(--bg); border: 1px solid var(--acc); border-radius: 12px; padding: 9px 12px; margin: 8px 0; }
.tt { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; background: var(--bg); border-radius: 12px; overflow: hidden; }
.tt th { width: 44px; text-align: center; padding: 7px 0; background: var(--line); font-weight: 700; }
.tt td { padding: 5px 8px; border-bottom: 1px solid var(--line); }
.tt td span { display: inline-block; min-width: 26px; padding: 2px 3px; text-align: center; }
.tt tr.past { opacity: .45; }
.mini { margin-left: auto; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.pinico { color: var(--acc); }
.hint { margin-top: 18px; }

/* маршрут */
.tf { display: grid; gap: 8px; padding-top: 2px; }
.tf .row { flex-wrap: wrap; }
.tf .time { width: 110px; }
.ac { position: relative; }
.ac .dot { position: absolute; left: 12px; top: 17px; width: 10px; height: 10px; border-radius: 50%; z-index: 1; }
.dot.a { background: #16a34a; } .dot.b { background: #dc2626; }
.tf .ac input { padding-left: 32px; padding-right: 44px; }
.swap { position: absolute; right: 6px; top: -27px; z-index: 2; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); }
.sug { position: absolute; left: 0; right: 0; top: 100%; z-index: 4; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 6px 18px #0003; }
.sug:empty { display: none; }
.sug button { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 10px 12px; }
.jr summary { list-style: none; cursor: pointer; } .jr summary::-webkit-details-marker { display: none; }
.jr.sel { border-color: var(--acc); box-shadow: 0 0 0 1px var(--acc) inset; }
.strip { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.strip .badge { min-width: 30px; height: 24px; font-size: 13px; }
.walk { font-size: 13px; color: var(--muted); } .arr { color: var(--muted); }
.right { text-align: right; flex: none; }
.legs { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.leg { display: flex; gap: 10px; padding: 5px 0; align-items: flex-start; }
.leg .tm { width: 46px; flex: none; }
.leg.off { border-bottom: 1px dashed var(--line); padding-bottom: 8px; margin-bottom: 4px; }
.leg.walk { color: var(--muted); }
.leg .badge { height: 22px; min-width: 30px; font-size: 12px; vertical-align: middle; }
.foot { margin-top: 18px; } .foot a { text-decoration: underline; }
.err { color: var(--soon); }

/* значки на карте */
.veh span { display: inline-block; transform: translate(-50%, -50%); padding: 1px 5px; border-radius: 6px; color: #fff; font: 700 11px/16px system-ui, sans-serif;
  border: 2px solid #fff; box-shadow: 0 1px 4px #0005; white-space: nowrap; }
.pin span { display: block; width: 26px; height: 26px; transform: translate(-50%, -100%); border-radius: 50% 50% 50% 0; rotate: -45deg; border: 2px solid #fff; box-shadow: 0 2px 6px #0005; }
.pin.a span { background: #16a34a; } .pin.b span { background: #dc2626; } .pin.p span { background: #2563eb; }
.stoptip { font-size: 12px; padding: 2px 6px; }
