/* Bus Plovdiv: изглед Material 3 Expressive (собствени токени, без библиотеки). Схема от червен цвят #EB0000, допълнителен (tertiary) тюркоазен,
   повърхности неутрално сиви (без розово и лилаво). Светъл и тъмен режим, едър текст (big) и висок контраст (hc).
   Старите имена (--bg, --ink, --red...) остават като псевдоними на ролите, за да работят plan.css и разметката. */
:root {
  --md-primary: #b3000f; --md-on-primary: #ffffff; --md-primary-container: #ffe1c9; --md-on-primary-container: #3a1500;
  --md-secondary-container: #dde3ea; --md-on-secondary-container: #151d24;
  --md-tertiary: #00696e; --md-tertiary-container: #9cf0f5; --md-on-tertiary-container: #002022;
  --md-late: #ffdcc6; --md-on-late: #5a1b00;
  --md-ok: #146c2e; --md-ok-container: #b4f1bd; --md-on-ok-container: #002109;
  --md-warn-container: #ffdf9e; --md-on-warn-container: #261a00;
  --md-surface: #f9f9fa; --md-surface-lowest: #ffffff; --md-surface-low: #f3f3f4; --md-surface-c: #ededee; --md-surface-high: #e7e7e8; --md-surface-highest: #e1e2e3;
  --md-on-surface: #1a1c1d; --md-on-surface-variant: #43474b; --md-outline: #73777b; --md-outline-variant: #c3c7cb;
  --md-inverse-surface: #2e3132; --md-inverse-on-surface: #eff1f2; --md-scrim: rgba(0,0,0,.42);
  --sh-xs: 4px; --sh-s: 8px; --sh-m: 12px; --sh-l: 16px; --sh-xl: 28px; --sh-full: 999px;
  --el1: 0 1px 2px rgba(0,0,0,.3), 0 1px 3px 1px rgba(0,0,0,.15);
  --el3: 0 1px 3px rgba(0,0,0,.3), 0 4px 8px 3px rgba(0,0,0,.15);
  --spring: cubic-bezier(.34, 1.45, .64, 1); --emph: cubic-bezier(.2, 0, 0, 1); --emph-in: cubic-bezier(.05, .7, .1, 1);
  --nav-h: 72px; --vbar-h: 30px;
  --bg: var(--md-surface); --bg2: var(--md-surface-c); --card: var(--md-surface-lowest); --ink: var(--md-on-surface); --ink2: var(--md-on-surface-variant);
  --mute: #5d6166; --line: var(--md-outline-variant); --line2: var(--md-outline); --red: var(--md-primary); --red-d: var(--md-primary); --red-ink: var(--md-on-primary);
  --ok: var(--md-ok); --warn: #8a5100; --late: var(--md-on-late); --info: var(--md-tertiary); --focus: var(--md-tertiary);
  --rad: var(--sh-m); --sh: none; color-scheme: light;
  --fs: 16px;
}
html.dark {
  --md-primary: #ff6b5c; --md-on-primary: #1f0000; --md-primary-container: #8c0009; --md-on-primary-container: #ffdad4;
  --md-secondary-container: #3c4650; --md-on-secondary-container: #d9e3ee;
  --md-tertiary: #6fd6dc; --md-tertiary-container: #004f53; --md-on-tertiary-container: #9cf0f5;
  --md-late: #6b2a00; --md-on-late: #ffdcc6;
  --md-ok: #7fdc8e; --md-ok-container: #00531e; --md-on-ok-container: #b4f1bd;
  --md-warn-container: #5c4300; --md-on-warn-container: #ffdf9e;
  --md-surface: #111314; --md-surface-lowest: #0c0e0f; --md-surface-low: #1a1c1d; --md-surface-c: #1e2021; --md-surface-high: #282a2b; --md-surface-highest: #333536;
  --md-on-surface: #e2e2e3; --md-on-surface-variant: #c3c7cb; --md-outline: #8d9195; --md-outline-variant: #43474b;
  --md-inverse-surface: #e2e2e3; --md-inverse-on-surface: #2e3132;
  --card: var(--md-surface-low); --mute: #a9adb1; --warn: #ffb95c;
  --el1: 0 1px 3px rgba(0,0,0,.6); --el3: 0 4px 10px rgba(0,0,0,.6); color-scheme: dark;
}
html.big { --fs: 19px; --nav-h: 80px; }
html.hc { --ink2: var(--ink); --mute: var(--ink); --line: var(--ink); --line2: var(--ink); --md-on-surface-variant: var(--md-on-surface); --md-outline-variant: var(--md-on-surface); --md-outline: var(--md-on-surface); }
html.hc:not(.dark) { --md-primary: #8c000b; --md-surface-c: #ffffff; --md-surface-low: #ffffff; --md-surface-high: #ffffff; --md-secondary-container: #ffffff; }
html.hc.dark { --md-primary: #ff8a7e; --md-surface-c: #000; --md-surface-low: #000; --md-surface-high: #000; --md-secondary-container: #000; --md-surface: #000; }
html.hc .item, html.hc .dep, html.hc .btn, html.hc .near-card, html.hc .pl-opt, html.hc .code { outline: 1px solid var(--md-on-surface); }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--md-surface); color: var(--md-on-surface);
  font: 400 var(--fs)/1.45 "Roboto Flex", Roboto, "Google Sans Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden; overflow-wrap: break-word; hyphens: manual;
  padding-bottom: calc(var(--nav-h) + var(--vbar-h) + env(safe-area-inset-bottom)); }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--md-tertiary); outline-offset: 2px; }
[hidden] { display: none !important; }
.pre { white-space: pre-line; }

/* горна лента (M3 small top app bar) */
.top { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 64px; padding: 8px 8px 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--md-surface); }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 800; font-size: 1.3em; letter-spacing: -.01em; min-height: 48px; }
.brand img { border-radius: var(--sh-m); }
.top-act { display: flex; gap: 4px; }
.tbtn { min-width: 48px; min-height: 48px; border: 0; background: transparent; border-radius: var(--sh-full); font-weight: 700; cursor: pointer; color: var(--md-on-surface-variant);
  display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; transition: background .2s, border-radius .35s var(--spring); }
.tbtn:hover { background: var(--md-surface-high); }
.tbtn:active { border-radius: var(--sh-m); }
#langBtn { box-shadow: inset 0 0 0 1px var(--md-outline); min-width: 56px; }
.net { background: var(--md-warn-container); color: var(--md-on-warn-container); padding: 10px 16px; font-weight: 700; font-size: .9em; }

main { max-width: 860px; margin: 0 auto; padding: 0 16px 32px; }
.pad { padding: 16px; }
h1 { font-size: 2em; line-height: 1.15; margin: 16px 0 6px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.15em; margin: 28px 0 10px; font-weight: 700; }
.sub { color: var(--md-on-surface-variant); margin: 0 0 12px; }
.muted { color: var(--mute); font-size: .9em; }

/* търсене (M3 search bar) */
.search { margin-top: 16px; display: flex; align-items: center; gap: 4px; background: var(--md-surface-high); border-radius: var(--sh-full); padding: 4px 4px 4px 8px; min-height: 60px; }
.search::before { content: ""; flex: none; width: 28px; height: 24px; background: var(--md-on-surface-variant);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.8l-.3-.3A6.5 6.5 0 1 0 14 15.5l.3.3v.8l5 5 1.5-1.5zm-6 0a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E") center / 24px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15.5 14h-.8l-.3-.3A6.5 6.5 0 1 0 14 15.5l.3.3v.8l5 5 1.5-1.5zm-6 0a4.5 4.5 0 1 1 0-9 4.5 4.5 0 0 1 0 9z'/%3E%3C/svg%3E") center / 24px no-repeat; }
.search input { flex: 1; min-width: 0; min-height: 52px; border: 0; background: transparent; padding: 0 6px; font-size: 1.05em; outline: none; }
.search:focus-within { outline: 2px solid var(--md-primary); }
.search input::placeholder { color: var(--md-on-surface-variant); }
.search .btn { min-height: 52px; padding: 0 16px; }

/* бутони: filled (red), tonal (по подразбиране), outlined (ghost); при натискане формата се сменя */
.btn { min-height: 48px; border: 0; background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-radius: var(--sh-full); padding: 0 20px;
  font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; letter-spacing: .01em;
  transition: border-radius .4s var(--spring), transform .4s var(--spring), background .2s, box-shadow .2s; }
.btn:hover { box-shadow: var(--el1); }
.btn:active { border-radius: var(--sh-m); transform: scale(.97); }
.btn.red { background: var(--md-primary); color: var(--md-on-primary); }
.btn.ghost { background: transparent; color: var(--md-on-surface-variant); box-shadow: inset 0 0 0 1px var(--md-outline); }
.btn.ghost:hover { background: var(--md-surface-high); }
.btn.sm { min-height: 48px; padding: 0 16px; font-size: .9em; }
.btn svg { flex: none; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.actions .btn { flex-direction: column; min-height: 96px; gap: 6px; font-size: .92em; text-align: center; padding: 10px 6px; border-radius: var(--sh-xl); }
.actions .btn:first-child { background: var(--md-primary); color: var(--md-on-primary); }
.actions .btn:nth-child(2) { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }
.actions .btn:active { border-radius: var(--sh-l); }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

/* списъци (M3 list items) */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; border-radius: var(--sh-l); overflow: hidden; }
.list li { background: var(--md-surface-low); }
.list > li.empty { background: transparent; }
.item { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 16px; text-decoration: none; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; transition: background .2s; }
.item:hover { background: var(--md-surface-high); }
.item .nm { flex: 1; min-width: 0; font-weight: 600; }
.item .nm small { display: block; font-weight: 400; color: var(--md-on-surface-variant); }
.code { font-variant-numeric: tabular-nums; font-weight: 700; background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-radius: var(--sh-s); padding: 2px 8px; font-size: .85em; flex: none; }
.dist { color: var(--mute); font-size: .9em; flex: none; font-variant-numeric: tabular-nums; }
.chev { flex: none; color: var(--md-on-surface-variant); }

/* линия: цветът е на линията */
.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 48px; height: 36px; padding: 0 10px; border-radius: var(--sh-m);
  color: #fff; font-weight: 800; font-variant-numeric: tabular-nums; flex: none; background: #0059b3; transition: border-radius .4s var(--spring); }
a:hover > .chip, a:focus-visible > .chip { border-radius: var(--sh-full); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips a { text-decoration: none; display: inline-flex; min-height: 48px; align-items: center; }

/* табло */
.board-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.board-head h1 { flex: 1; min-width: 0; }
.star { min-width: 56px; min-height: 56px; margin-top: 12px; border: 0; border-radius: var(--sh-l); background: var(--md-surface-high); color: var(--md-on-surface-variant); cursor: pointer; font-size: 1.4em;
  transition: border-radius .45s var(--spring), background .2s, transform .45s var(--spring); }
.star.on { background: var(--md-primary); color: var(--md-on-primary); border-radius: var(--sh-full); }
.star:active { transform: scale(.9); }
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 6px 0 12px; font-size: .9em; color: var(--md-on-surface-variant); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: .85em; border-radius: var(--sh-s); padding: 4px 10px; min-height: 28px; }
.badge.live { background: var(--md-ok-container); color: var(--md-on-ok-container); }
.badge.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.6s infinite; }
.badge.sched { background: var(--md-warn-container); color: var(--md-on-warn-container); }
.badge.stale { background: var(--md-late); color: var(--md-on-late); }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

.deps { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dep { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 14px; align-items: center; padding: 14px 16px; background: var(--md-surface-low); border-radius: var(--sh-l);
  cursor: pointer; transition: background .2s, border-radius .45s var(--spring); }
.dep:hover { background: var(--md-surface-high); }
.dep:active { border-radius: var(--sh-xl); }
.dep:first-child { border-radius: var(--sh-xl) var(--sh-xl) var(--sh-l) var(--sh-l); }
.dep .dest { font-weight: 700; font-size: 1.05em; min-width: 0; }
.dep .dest small { display: block; color: var(--md-on-surface-variant); font-weight: 400; font-size: .82em; }
.dep .when { text-align: right; font-variant-numeric: tabular-nums; }
.dep .min { font-size: 2.1em; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.dep .min.now { color: var(--md-primary); font-size: 1.5em; }
.dep .min span { font-size: .45em; font-weight: 700; margin-left: 3px; letter-spacing: 0; }
.dep .clock { display: block; color: var(--md-on-surface-variant); font-size: .85em; margin-top: 4px; }
.delay { display: inline-flex; align-items: center; font-weight: 700; font-size: .78em; padding: 2px 8px; border-radius: var(--sh-s); background: var(--md-late); color: var(--md-on-late); margin-left: 4px; vertical-align: middle; }
.delay.early { background: var(--md-tertiary-container); color: var(--md-on-tertiary-container); }
.dep .tools { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: nowrap; }
.dep .tools > .btn { flex: 1 1 0; min-width: 0; min-height: 48px; padding: 0 6px; gap: 4px; font-size: .82em; white-space: nowrap; justify-content: center; }
.dep .tools > .btn svg { width: 16px; height: 16px; }
.dep.sched .min { color: var(--md-on-surface-variant); }
.empty { padding: 20px 4px; color: var(--md-on-surface-variant); }
main > * { animation: rise .4s var(--emph-in) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* бележки за промени */
.notice { background: var(--md-warn-container); color: var(--md-on-warn-container); border-radius: var(--sh-l); padding: 12px 16px; margin: 12px 0; }
.notice b { display: block; }
.notice p { margin: 4px 0 0; white-space: pre-line; }

/* карта */
.map { height: 56vh; min-height: 300px; border-radius: var(--sh-xl); overflow: hidden; margin: 12px 0; position: relative; z-index: 1; background: var(--md-surface-c); }
.map.full { height: calc(100vh - 250px - var(--nav-h)); height: calc(100dvh - 250px - var(--nav-h)); min-height: 280px; }
.map-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; font-weight: 700; cursor: pointer; padding: 0 16px 0 10px; border-radius: var(--sh-s); box-shadow: inset 0 0 0 1px var(--md-outline); }
.toggle:has(input:checked) { background: var(--md-secondary-container); box-shadow: none; }
.toggle input { width: 20px; height: 20px; accent-color: var(--md-primary); }
.vm { width: 34px; height: 34px; border-radius: 50%; color: #fff; font: 700 12px/34px Arial, sans-serif; text-align: center; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.45); }
.vm.sel { width: 42px; height: 42px; line-height: 42px; font-size: 14px; border-color: var(--md-primary); outline: 3px solid #fff; border-radius: 14px; }
.vm-wrap { position: absolute; }
.vm-arrow { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.sm-stop { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--md-primary); }
.sm-stop.big { width: 22px; height: 22px; border-width: 5px; }
.sm-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid #333; }
.sm-dot.past { border-color: #999; background: #ddd; }
.leaflet-container { font: inherit; background: var(--md-surface-c); }
.leaflet-popup-content-wrapper { border-radius: var(--sh-l); }
html.dark .leaflet-tile-pane { filter: brightness(.75) contrast(1.1) saturate(.6); }

/* курс на кола: вертикална линия на спирките */
.tl { list-style: none; margin: 8px 0 0; padding: 4px 12px; background: var(--md-surface-low); border-radius: var(--sh-xl); }
.tl li { position: relative; display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; min-height: 48px; }
.tl li::before { content: ""; position: absolute; left: 11px; top: 0; bottom: 0; width: 4px; border-radius: 2px; background: var(--md-primary); }
.tl li:first-child::before { top: 50%; } .tl li:last-child::before { bottom: 50%; }
.tl .dot { position: relative; z-index: 1; width: 16px; height: 16px; margin-left: 5px; border-radius: 50%; background: var(--md-surface-low); border: 4px solid var(--md-primary); }
.tl .nm { font-weight: 700; min-width: 0; }
.tl .nm a { text-decoration: none; }
.tl .tm { font-variant-numeric: tabular-nums; text-align: right; }
.tl li.past { color: var(--mute); }
.tl li.past::before { background: var(--md-outline-variant); }
.tl li.past .dot { border-color: var(--md-outline-variant); background: var(--md-outline-variant); }
.tl li.past .nm { font-weight: 400; }
.tl li.here { min-height: 34px; }
.tl li.here .dot { display: none; }
.tl li.here .bus { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 10px; background: var(--md-primary); color: var(--md-on-primary); font-size: 14px; display: grid; place-items: center; }
.tl li.here .nm { color: var(--md-primary); font-size: .9em; }
.tl li.mine .nm { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 3px; }

/* таблици */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table.tt { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.tt th, table.tt td { border-bottom: 1px solid var(--md-outline-variant); padding: 8px 6px; text-align: left; vertical-align: top; }
.times { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.times span { padding: 4px 8px; border-radius: var(--sh-s); background: var(--md-surface-low); }
.times span.past { color: var(--mute); text-decoration: line-through; background: transparent; }
.times span.next { background: var(--md-primary); color: var(--md-on-primary); font-weight: 700; }
select.sel { min-height: 56px; border: 1px solid var(--md-outline); border-radius: var(--sh-xs); background: var(--md-surface); padding: 0 12px; max-width: 100%; margin-top: 4px; }
/* сегментирани бутони */
.seg { display: inline-flex; border-radius: var(--sh-full); box-shadow: inset 0 0 0 1px var(--md-outline); overflow: hidden; flex-wrap: nowrap; }
.seg button { min-height: 48px; border: 0; background: transparent; padding: 0 14px; font-weight: 700; cursor: pointer; transition: background .25s var(--emph); white-space: nowrap; }
.seg button + button { border-left: 1px solid var(--md-outline); }
.seg button.on { background: var(--md-secondary-container); color: var(--md-on-secondary-container); }

/* долен лист (M3 bottom sheet): настройки, известие, QR */
.sheet { position: fixed; inset: 0; z-index: 2000; background: var(--md-scrim); display: flex; align-items: flex-end; justify-content: center; animation: fade .25s var(--emph); }
.sheet .in { background: var(--md-surface-low); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: var(--sh-xl) var(--sh-xl) 0 0;
  padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); animation: up .45s var(--emph-in); }
.sheet .in::before { content: ""; display: block; width: 32px; height: 4px; border-radius: 2px; background: var(--md-on-surface-variant); opacity: .45; margin: 6px auto 16px; }
.sheet h2 { margin-top: 0; font-size: 1.4em; }
.sheet .opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 6px 0; border-bottom: 1px solid var(--md-outline-variant); text-decoration: none; }
.sheet .opt { flex-wrap: wrap; }
.sheet .opt > span:first-child { flex: 1 1 120px; min-width: 0; }
.sheet .opt > .sw, .sheet .opt > .seg { flex: none; }
.sheet .close { width: 100%; margin-top: 16px; }
@keyframes up { from { transform: translateY(40%); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.sw { position: relative; width: 52px; height: 32px; flex: none; }
.sw input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.sw i { position: absolute; inset: 0; border-radius: 16px; background: var(--md-surface-highest); box-shadow: inset 0 0 0 2px var(--md-outline); transition: background .2s; }
.sw i::after { content: ""; position: absolute; top: 8px; left: 8px; width: 16px; height: 16px; border-radius: 50%; background: var(--md-outline); transition: all .35s var(--spring); }
.sw input:checked + i { background: var(--md-primary); box-shadow: none; }
.sw input:checked + i::after { left: 24px; top: 4px; width: 24px; height: 24px; background: var(--md-on-primary); }
.sw input:focus-visible + i { outline: 3px solid var(--md-tertiary); outline-offset: 2px; }
.qr-box { position: relative; background: #000; border-radius: var(--sh-xl); overflow: hidden; aspect-ratio: 1 / 1; max-height: 60vh; margin: 0 auto; }
.qr-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qr-box::after { content: ""; position: absolute; inset: 18%; border: 4px solid #fff; border-radius: var(--sh-xl); }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + var(--vbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 3000; max-width: 520px; margin: 0 auto;
  background: var(--md-inverse-surface); color: var(--md-inverse-on-surface); padding: 14px 16px; border-radius: var(--sh-s); font-weight: 600; white-space: pre-line; box-shadow: var(--el3); animation: up .35s var(--emph-in); }
.install { background: var(--md-primary-container); color: var(--md-on-primary-container); border-radius: var(--sh-xl); padding: 16px 18px; margin: 20px 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.install p { margin: 0; flex: 1 1 200px; white-space: pre-line; }
footer.foot { color: var(--mute); font-size: .85em; margin-top: 36px; padding-top: 12px; border-top: 1px solid var(--md-outline-variant); }
footer.foot a { color: var(--md-on-surface-variant); }
.spin { display: inline-block; width: 20px; height: 20px; border: 4px solid var(--md-secondary-container); border-top-color: var(--md-primary); border-radius: 50%; animation: sp .9s linear infinite; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 420px) {
  h1 { font-size: 1.65em; }
  .dep { gap: 6px 10px; padding: 12px 14px; }
  .dep .min { font-size: 1.85em; }
}
@media (min-width: 760px) {
  .two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
}
.near .walk { display: block; font-weight: 400; color: var(--md-on-surface-variant); font-size: .88em; }
.near .nx { margin-top: 4px; line-height: 1.9; }
.near .nx .chip { min-width: 34px; height: 24px; font-size: .8em; }
/* най-близките спирки на картата: лист отдолу над навигацията */
.near-card { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--vbar-h) + env(safe-area-inset-bottom)); z-index: 1460; max-width: 640px; margin: 0 auto;
  max-height: 40vh; overflow: auto; background: var(--md-surface-low); border-radius: var(--sh-xl) var(--sh-xl) 0 0; padding: 8px 16px 12px; box-shadow: var(--el3); animation: up .45s var(--emph-in); }
.near-card::before { content: ""; display: block; width: 32px; height: 4px; border-radius: 2px; background: var(--md-on-surface-variant); opacity: .45; margin: 4px auto 6px; }
.nc-h { display: flex; justify-content: space-between; align-items: center; }
.warn { color: var(--warn); font-weight: 700; }

/* долна навигация (M3 navigation bar), над тънката лента с видеото */
.navb { position: fixed; left: 0; right: 0; bottom: calc(var(--vbar-h) + env(safe-area-inset-bottom)); z-index: 1400; height: var(--nav-h); display: flex; justify-content: center;
  background: var(--md-surface-c); box-shadow: 0 -1px 0 var(--md-outline-variant); }
.navb .ni { flex: 1 1 0; max-width: 120px; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0 2px; border: 0; background: none; cursor: pointer;
  text-decoration: none; color: var(--md-on-surface-variant); font-size: 12px; font-weight: 600; }
html.big .navb .ni { font-size: 13px; }
.navb .ni i { display: grid; place-items: center; width: 56px; height: 32px; border-radius: var(--sh-full); transition: background .25s var(--emph), width .4s var(--spring); }
.navb .ni span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navb .ni[aria-current="page"] { color: var(--md-on-surface); font-weight: 800; }
.navb .ni[aria-current="page"] i { background: var(--md-secondary-container); color: var(--md-on-secondary-container); width: 64px; }
.navb .ni:active i { width: 48px; }
/* FAB за QR */
.fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + var(--vbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 1450; width: 64px; height: 64px; border: 0;
  border-radius: var(--sh-l); background: var(--md-primary); color: var(--md-on-primary); box-shadow: var(--el3); cursor: pointer; display: grid; place-items: center;
  transition: border-radius .45s var(--spring), transform .45s var(--spring); }
.fab:hover { border-radius: 22px; }
.fab:active { border-radius: var(--sh-full); transform: scale(.92); }
body:not(.v-home) .fab { display: none; }
@media (min-width: 900px) { .fab { right: calc(50% - 430px); } }

/* тънка лента най-долу: видеото „Как се ползва?“ */
.vbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500; display: flex; align-items: center; justify-content: center; gap: 6px;
  height: calc(var(--vbar-h) + env(safe-area-inset-bottom)); padding: 0 12px env(safe-area-inset-bottom); background: var(--md-surface-highest);
  color: var(--md-on-surface); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; overflow: hidden; }
.vbar span[aria-hidden] { color: var(--md-primary); font-size: 11px; }
.vbar:hover #vbarT { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body.v-home main, body.v-stop main, body.v-search main { padding-bottom: 96px; }

/* компактна плътност (M3 compact): повече информация на екрана, по-малко превъртане; зоните за докосване остават поне 48 px */
:root { --nav-h: 56px; }
html.big { --nav-h: 60px; }
.top { min-height: 52px; padding-top: max(2px, env(safe-area-inset-top)); padding-bottom: 2px; }
.brand { font-size: 1.12em; gap: 10px; }
.brand img { width: 28px; height: 28px; }
h1 { font-size: 1.5em; margin: 8px 0 2px; }
h2 { margin: 16px 0 6px; font-size: 1.05em; }
.sub { margin: 0 0 6px; font-size: .92em; }
main { padding-bottom: 16px; }
.search { margin-top: 8px; min-height: 48px; padding: 0 0 0 6px; }
.search input { min-height: 48px; }
.sbtn { flex: none; width: 48px; height: 48px; border: 0; border-radius: var(--sh-full); background: var(--md-primary); color: var(--md-on-primary); cursor: pointer;
  display: grid; place-items: center; transition: border-radius .4s var(--spring); }
.sbtn:active { border-radius: var(--sh-m); }
.actions { grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.actions .btn, .actions .btn:first-child, .actions .btn:nth-child(2) { min-height: 60px; padding: 6px 2px; gap: 2px; font-size: .8em; border-radius: var(--sh-l);
  background: var(--md-secondary-container); color: var(--md-on-secondary-container); white-space: nowrap; }
.actions .btn:first-child { background: var(--md-primary); color: var(--md-on-primary); }
.actions .btn svg { width: 24px; height: 24px; }
.row-btns { margin: 8px 0; gap: 6px; }
.btn.sm { min-height: 40px; padding: 0 14px; position: relative; }
.btn.sm::after { content: ""; position: absolute; inset: -4px 0; }
.item { min-height: 52px; padding: 6px 12px; gap: 12px; }
.chip { height: 32px; min-width: 44px; }
.chips { gap: 4px 6px; }
.star { min-width: 48px; min-height: 48px; margin-top: 6px; font-size: 1.2em; }
.status { margin: 2px 0 8px; }
.badge { min-height: 24px; padding: 2px 8px; }
/* табло: един ред на заминаване; „Извести ме“ е иконка вдясно, „Следи“ е докосване на реда, линията е докосване на номера */
.deps { gap: 4px; }
.dep { grid-template-columns: auto 1fr auto auto; gap: 0 10px; padding: 6px 4px 6px 12px; min-height: 60px; border-radius: var(--sh-m); }
.dep:first-child { border-radius: var(--sh-l) var(--sh-l) var(--sh-m) var(--sh-m); }
.dep .dest { font-size: 1em; line-height: 1.25; }
.dep .min { font-size: 1.75em; }
.dep .min.now { font-size: 1.25em; }
.dep .clock { margin-top: 2px; font-size: .8em; }
.dep .tools { grid-column: auto; }
.dep .tools > [data-fo], .dep .tools > a { display: none; }
.dep .tools > [data-al] { flex: none; width: 48px; min-height: 48px; padding: 0; font-size: 0; box-shadow: none; background: transparent; color: var(--md-on-surface-variant); }
.dep .tools > [data-al] svg { width: 22px; height: 22px; }
.dep .tools > [data-al]:hover { background: var(--md-surface-highest); }
.dep .chip { cursor: pointer; }
.tl li { min-height: 40px; }
.map { margin: 8px 0; }
.map.full { height: calc(100vh - 240px - var(--nav-h) - var(--vbar-h)); height: calc(100dvh - 240px - var(--nav-h) - var(--vbar-h)); }
.toggle { min-height: 40px; position: relative; }
.toggle::after { content: ""; position: absolute; inset: -4px 0; }
.notice { padding: 8px 12px; margin: 8px 0; }
.install { padding: 12px 14px; margin: 14px 0; }
/* навигация: 56 px, малки надписи */
.navb .ni { gap: 2px; font-size: 11px; }
html.big .navb .ni { font-size: 12px; }
.navb .ni i { height: 28px; width: 52px; }
.navb .ni[aria-current="page"] i { width: 60px; }
.fab { width: 56px; height: 56px; }
body.v-home main, body.v-stop main, body.v-search main { padding-bottom: 84px; }
@media (max-width: 360px) { .actions .btn { font-size: .74em; } }
/* второто действие на реда: „Виж линията“ като иконка */
.dep .tools { gap: 0; }
.dep .tools > a.btn { display: grid; place-items: center; flex: none; width: 40px; min-height: 48px; padding: 0; font-size: 0; box-shadow: none; background: transparent; color: var(--md-on-surface-variant); }
.dep .tools > a.btn::before { content: ""; width: 22px; height: 22px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 2a3 3 0 0 0-1 5.8V22h2V7.8A3 3 0 0 0 6 2zm12 0a3 3 0 1 0 0 6 3 3 0 0 0 0-6zm-1 7v4.5c0 1-.8 1.5-1.5 1.5h-5A3.5 3.5 0 0 0 7 18.5V20h2v-1.5c0-.8.7-1.5 1.5-1.5h5A3.5 3.5 0 0 0 19 13.5V9z'/%3E%3C/svg%3E") center / 22px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 2a3 3 0 0 0-1 5.8V22h2V7.8A3 3 0 0 0 6 2zm12 0a3 3 0 1 0 0 6 3 3 0 0 0 0-6zm-1 7v4.5c0 1-.8 1.5-1.5 1.5h-5A3.5 3.5 0 0 0 7 18.5V20h2v-1.5c0-.8.7-1.5 1.5-1.5h5A3.5 3.5 0 0 0 19 13.5V9z'/%3E%3C/svg%3E") center / 22px no-repeat; }
.dep .tools > a:hover { background: var(--md-surface-highest); }
.dep .tools > [data-al] { width: 40px; }
.dep { padding-right: 2px; gap: 0 8px; }
/* „Виж линията“: малък чип с номера на линията и стрелка */
.dep .tools > a.btn { width: auto; min-width: 44px; padding: 0 4px; }
.dep .tools > a.btn::before { content: attr(data-l) "\00a0›"; width: auto; height: 28px; line-height: 26px; padding: 0 8px; border-radius: var(--sh-s); border: 1px solid var(--md-outline);
  font-size: 13px; font-weight: 800; color: var(--md-on-surface); -webkit-mask: none; mask: none; background: transparent; white-space: nowrap; }
.dep .tools > [data-al] { color: var(--md-on-surface); }
.dep:active { background: var(--md-surface-highest); }
/* еднократната подсказка */
.coach { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: var(--md-secondary-container); color: var(--md-on-secondary-container); border-radius: var(--sh-l); padding: 10px 12px; margin: 0 0 8px; }
.coach p { margin: 0; flex: 1 1 220px; font-size: .9em; }
.coach .btn { background: var(--md-surface-lowest); color: var(--md-on-surface); }
/* QR е в реда с действията на началото: плаващият бутон не се показва (не покрива редовете) */
.fab { display: none !important; }
body.v-home main, body.v-stop main, body.v-search main { padding-bottom: 16px; }
.toast.upd { border: 0; text-align: left; cursor: pointer; font: inherit; font-weight: 700; display: block; width: auto; }

/* авторските права на картата: малък надпис, свива се до кръгче „i“ */
.leaflet-control-attribution.att { font-size: 11px; line-height: 1.4; color: var(--md-on-surface-variant); background: color-mix(in srgb, var(--md-surface) 78%, transparent);
  border-radius: 12px 0 0 0; padding: 2px 8px; margin: 0; cursor: default; max-width: calc(100vw - 80px); }
.leaflet-control-attribution.att a { color: var(--md-on-surface-variant); text-decoration: none; }
.leaflet-control-attribution.att.min { width: 28px; height: 28px; padding: 0; margin: 0 8px 8px 0; border-radius: 50%; overflow: hidden; color: transparent; font-size: 0; cursor: pointer; position: relative;
  box-shadow: var(--el1); background: color-mix(in srgb, var(--md-surface) 88%, transparent); }
.leaflet-control-attribution.att.min::after { content: "i"; position: absolute; inset: 0; display: grid; place-items: center; font: 700 14px/1 Georgia, serif; color: var(--md-on-surface-variant); }
.leaflet-control-attribution.att.min::before { content: ""; position: absolute; inset: -10px; }
.leaflet-control-attribution.att.min a { pointer-events: none; }
.pl-osm { font-size: 11px; }
/* бутон „Моето място“ на картата (малък FAB, 40 px видимо, 48 px за докосване) */
.leaflet-control.loc-btn { width: 40px; height: 40px; margin: 10px 0 0 10px; border: 0; border-radius: 12px; background: var(--md-surface-container-high, #fff); color: var(--md-on-surface-variant, #444);
  box-shadow: 0 1px 4px rgba(0,0,0,.35); display: grid; place-items: center; cursor: pointer; position: relative; padding: 0; }
.leaflet-control.loc-btn::after { content: ''; position: absolute; inset: -4px; }
.leaflet-control.loc-btn.on { color: #1a73e8; }
.leaflet-control.loc-btn.fol { background: #1a73e8; color: #fff; }
.me-wrap { position: absolute; }
.me-dot { position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 4px rgba(0,0,0,.4); box-sizing: border-box; }
.me-h { position: absolute; left: 0; top: 0; width: 22px; height: 22px; }
.me-h::before { content: ''; position: absolute; left: 6px; top: -9px; border: 5px solid transparent; border-bottom: 9px solid #1a73e8; }
#toast { white-space: pre-line; }

/* карта: избрана кола (малка карта долу, надписи на следващата и последната спирка) */
.sel-card { padding: 4px 14px 10px; }
.sel-card .sc-t { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; }
.sel-card .sc-t span:last-child { overflow-wrap: anywhere; }
.sel-card .sc-l { margin: 4px 0 0; font-size: 14px; line-height: 1.35; }
.sel-card .sc-d { color: var(--warn); font-weight: 700; }
.sel-card .sc-d.early { color: inherit; }
.sel-card .sc-a { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sel-card .sc-a .btn { min-height: 40px; padding: 0 10px; gap: 4px; }
.leaflet-tooltip.sel-tt { background: var(--md-surface-lowest); color: var(--md-on-surface); border: 0; border-radius: 8px; padding: 2px 8px; font: 600 12px/1.3 Arial, sans-serif; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.leaflet-tooltip.sel-tt.end { font-weight: 800; }
.leaflet-tooltip.sel-tt::before { display: none; }

/* стрелки по посоката на движение (остатъкът от курса) */
.flow-a i { display: block; width: 7px; height: 7px; box-sizing: border-box; border-top: 2px solid #fff; border-right: 2px solid #fff; opacity: 1; filter: drop-shadow(0 0 1px rgba(0,0,0,.6)); }
.sel-card .sc-r { font-size: 12px; }

/* линия: първи и последен курс за днес */
.fl { margin: -4px 0 8px; font-size: 13px; line-height: 1.4; color: var(--md-on-surface-variant); }
.fl p { margin: 0; overflow-wrap: anywhere; }

/* посока на колата: малък връх на ръба на кръга (върти се само .vm-p, номерът стои изправен) */
.vm { position: relative; }
.vm-p { position: absolute; inset: -2px; border-radius: 50%; pointer-events: none; transition: transform .5s ease; }
.vm-p[hidden] { display: none; }
.vm-p::before { content: ""; position: absolute; left: 50%; top: -6px; margin-left: -4px; border: 4px solid transparent; border-top: 0; border-bottom: 5px solid rgba(255,255,255,.75); }
.vm.sel .vm-p::before { top: -9px; }
.zdot .vm:not(.sel) .vm-p { display: none; }
@media (prefers-reduced-motion: reduce) { .vm-p { transition: none; } }
.vm-b { vertical-align: middle; margin-top: -2px; }
/* избрана кола: другите избледняват, за да се откроява линията */
.leaflet-container:has(.vm.sel) .vm-wrap:not(:has(.vm.sel)) { opacity: .3; transition: opacity .25s; }
.leaflet-container .vm-wrap { transition: opacity .25s; }
