/* Научные маршруты — аудиогид.
   Визуальный язык science-step.ru: серое «бетонное» поле, чёрный Inter Tight,
   нулевые радиусы, линейки 1px, плоские «маркерные» плашки
   (коралл — маршруты, лайм — «сейчас/включено», синий — главное действие). */

@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/InterTight-cyrillic.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter Tight";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/InterTight-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* поле и бумага */
  --ground: #e6e7e8;
  --ground-2: #d4dade;
  --paper: #ffffff;
  /* чернила (все пары проверены на AA: ink-2/ink-3 ≥ 5:1 и на ground, и на paper) */
  --ink: #111214;
  --ink-2: #3f454b;
  --ink-3: #5a6168;
  --rule: #111214;
  --rule-soft: #b9c0c6;
  /* акценты бренда */
  --coral: #fe634e;       /* только под чёрный текст: 6.3:1 */
  --coral-soft: #ffd9d2;
  --lime: #87ff00;        /* только под чёрный текст: 14.6:1 */
  --blue: #0051ff;        /* белый текст на синем: 5.8:1 */
  --blue-press: #0037b3;
  --crimson: #c4002f;     /* текст ошибки: 6.2:1 на white, 5.0:1 на ground */
  --crimson-soft: #fbe0e6;

  --font: "Inter Tight", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "Courier New", ui-monospace, "SF Mono", Menlo, monospace;

  --fs-micro: 0.75rem;   /* 12 — только моно-метки */
  --fs-small: 0.875rem;  /* 14 */
  --fs-ui: 1rem;         /* 16 */
  --fs-body: 1.0625rem;  /* 17 — основной текст на улице */
  --fs-lead: 1.25rem;    /* 20 */
  --fs-h2: 1.5rem;       /* 24 */
  --fs-h1: 1.875rem;     /* 30 */
  --fs-display: 2.5rem;  /* 40 */

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  --top-h: 56px;
  --tab-h: 64px;
  --player-h: 68px;
  --pane-w: 440px;
  --safe-b: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(.16, 1, .3, 1);
  --t-fast: 160ms;
  --t-med: 260ms;
  /* Плоский мир science-step.ru: без теней. Плавающие элементы отделяются линейкой 1px. */
  --lift: none;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.5;
  color: var(--ink);
  background: var(--ground);
  min-height: 100dvh;
  padding-top: var(--top-h);
  padding-bottom: calc(var(--tab-h) + var(--safe-b));
  font-feature-settings: "ss01" 0;
  overflow-x: hidden;
}
body.has-player { padding-bottom: calc(var(--tab-h) + var(--player-h) + var(--safe-b)); }
body.no-scroll { overflow: hidden; }
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; text-align: inherit; }
a { color: inherit; }
p { max-width: 64ch; }
::selection { background: var(--lime); color: var(--ink); }
input { caret-color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.btn-primary:focus-visible, .player-btn:focus-visible, .miniplayer :focus-visible { outline-color: var(--lime); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; }
.i-lg { width: 40px; height: 40px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--s4); top: -80px; z-index: 400; background: var(--ink); color: var(--paper); padding: var(--s3) var(--s4); font-weight: 600; text-decoration: none; }
.skip:focus { top: var(--s2); }

/* ── Маркерные плашки ─────────────────────────────────────── */
.mark { padding: 0 .12em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.mark-coral { background: var(--coral); }
.mark-lime { background: var(--lime); }
.mono-label { font-family: var(--mono); font-weight: 700; font-size: var(--fs-micro); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.braces::before { content: "{\00a0"; }
.braces::after { content: "\00a0}"; }

/* ── Верхняя панель ─────────────────────────────────────── */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 120; height: var(--top-h);
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s4); background: var(--ground); border-bottom: 1px solid var(--rule);
}
.wordmark { display: flex; flex-direction: column; text-decoration: none; text-transform: uppercase; font-weight: 500; font-size: .9375rem; line-height: 1.05; letter-spacing: .14em; margin-right: auto; min-height: 44px; justify-content: center; }
.wordmark-line { display: block; white-space: nowrap; }
.sidenav { display: none; }
.autosound {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: 44px; padding: 0 var(--s3); border: 1px solid var(--rule); background: var(--paper);
  transition: background-color var(--t-fast) var(--ease);
}
.autosound-dot { width: 10px; height: 10px; border: 2px solid var(--ink); background: transparent; }
.autosound-text { display: flex; flex-direction: column; line-height: 1.05; }
.autosound-label { font-family: var(--mono); font-weight: 700; font-size: var(--fs-micro); letter-spacing: .06em; text-transform: uppercase; }
.autosound-state { font-size: var(--fs-small); font-weight: 600; }
.autosound:hover { background: var(--ground-2); }
.autosound[aria-pressed="true"] { background: var(--lime); }
.autosound[aria-pressed="true"] .autosound-dot { background: var(--ink); animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ── Нижний таббар ─────────────────────────────────────── */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 120;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--paper); border-top: 1px solid var(--rule);
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 48px; font-size: var(--fs-small); font-weight: 500; color: var(--ink-2); position: relative;
}
.tab-item .i { width: 22px; height: 22px; }
.tab-item.active { color: var(--ink); font-weight: 700; }
.tab-item.active::before { content: ""; position: absolute; top: -1px; left: 18%; right: 18%; height: 4px; background: var(--coral); }

/* ── Кнопки ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 0 var(--s5);
  font-size: .9375rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid transparent; transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-press); }
.btn-outline { border-color: var(--rule); background: var(--paper); color: var(--ink); }
.btn-outline:hover { background: var(--ground-2); }
.btn-quiet { min-height: 44px; padding: 0 var(--s2); text-transform: none; letter-spacing: 0; font-size: var(--fs-ui); color: var(--ink); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.btn-quiet:hover { text-decoration-thickness: 2px; }
.btn-block { width: 100%; }
.btn-sm { min-height: 44px; padding: 0 var(--s4); font-size: var(--fs-small); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ── Раскладка ─────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }
.pane { padding: var(--s6) var(--s4) var(--s8); }
.pane-head { margin-bottom: var(--s5); }
.display { font-size: var(--fs-display); font-weight: 300; line-height: 1; letter-spacing: .06em; text-transform: uppercase; }
.lede { margin-top: var(--s3); font-size: var(--fs-body); color: var(--ink-2); }
.section-title { font-size: var(--fs-small); font-family: var(--mono); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin: var(--s8) 0 var(--s3); padding-bottom: var(--s2); border-bottom: 1px solid var(--rule); }

/* ── Список маршрутов ─────────────────────────────────────── */
.resume { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s3) var(--s3) var(--s4); background: var(--lime); margin-bottom: var(--s4); }
.resume-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.resume-text .mono-label { color: var(--ink); margin-top: 2px; }
.resume-text strong { font-size: var(--fs-ui); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { display: flex; align-items: center; gap: var(--s2); min-height: 48px; padding: 0 var(--s3); background: var(--paper); border: 1px solid var(--rule); margin-bottom: var(--s4); }
.search .i { color: var(--ink-3); }
.search input { flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; outline: none; font-size: var(--fs-ui); }
.search input::placeholder { color: var(--ink-3); }
.search:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }
.route-list { display: grid; gap: var(--s4); }
.route-list-empty { padding: var(--s6) 0; color: var(--ink-2); }
.route-card { display: grid; grid-template-columns: 1fr; width: 100%; background: var(--paper); border: 1px solid var(--rule); transition: transform var(--t-fast) var(--ease); }
.route-card:hover .route-card-title .mark { background: var(--coral); }
.route-card:active { transform: translateY(1px); }
.route-cover { aspect-ratio: 16 / 9; background: var(--ground-2) center / cover no-repeat; position: relative; border-bottom: 1px solid var(--rule); filter: grayscale(.25) contrast(1.02); }
.route-cover-badge { position: absolute; left: var(--s3); bottom: var(--s3); padding: 4px var(--s2); background: var(--paper); font-family: var(--mono); font-weight: 700; font-size: var(--fs-micro); letter-spacing: .06em; text-transform: uppercase; }
.cover-walk { background-color: var(--coral-soft); }
.cover-bike { background-color: #e3f7cc; }
.cover-car { background-color: var(--ground-2); }
.cover-transit { background-color: #d9e3ff; }
.route-body { padding: var(--s4); display: grid; gap: var(--s2); }
.route-card-title { font-size: var(--fs-lead); font-weight: 600; line-height: 1.2; }
.route-card-title .mark { background: transparent; transition: background-color var(--t-fast) var(--ease); }
.route-card .desc { color: var(--ink-2); font-size: var(--fs-ui); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.route-meta { font-family: var(--mono); font-weight: 700; font-size: .8125rem; letter-spacing: .02em; color: var(--ink); }
.route-progress { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-small); color: var(--ink-2); }
.route-progress .bar { flex: 1; height: 4px; background: var(--ground-2); position: relative; overflow: hidden; }
.route-progress .bar > span { position: absolute; inset: 0; background: var(--ink); transform-origin: left; }
.route-card.is-active { outline: 4px solid var(--lime); outline-offset: -4px; }
.brand-link { display: inline-flex; align-items: center; gap: var(--s2); margin-top: var(--s8); min-height: 44px; font-size: var(--fs-small); color: var(--ink-2); text-decoration: underline; text-underline-offset: 4px; }
.brand-link .i { width: 16px; height: 16px; }

/* скелеты */
@keyframes skel-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.skel-card { background: var(--paper); border: 1px solid var(--rule-soft); }
.skel-cover { aspect-ratio: 16 / 9; }
.skel-body { padding: var(--s4); display: grid; gap: var(--s3); }
.skel-line { height: 14px; }
.w-40 { width: 40%; } .w-50 { width: 50%; } .w-60 { width: 60%; } .w-80 { width: 80%; } .w-90 { width: 90%; }
.skeleton { background: var(--ground); animation: skel-pulse 1.6s ease-in-out infinite; }

/* пустое / ошибка */
.empty-state { display: grid; justify-items: start; gap: var(--s3); padding: var(--s6) var(--s5); background: var(--paper); border: 1px solid var(--rule); }
.empty-state h2 { font-size: var(--fs-lead); font-weight: 600; }
.empty-state p { color: var(--ink-2); }
.empty-state.is-error { border-color: var(--crimson); }
.empty-state.is-error h2::before { content: ""; display: inline-block; width: 10px; height: 10px; background: var(--crimson); margin-right: var(--s2); vertical-align: .1em; }

/* ── Страница маршрута ─────────────────────────────────────── */
#viewRoute.pane { padding: 0; }
.route-page { display: flex; flex-direction: column; min-height: 100%; }
.route-page-top { padding: var(--s2) var(--s2); background: var(--ground); position: sticky; top: var(--top-h); z-index: 20; border-bottom: 1px solid var(--rule); }
.back-btn { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s2); font-weight: 600; font-size: var(--fs-ui); }
.back-btn:hover { text-decoration: underline; text-underline-offset: 4px; }
.route-page-cover .modal-cover { aspect-ratio: 16 / 9; background: var(--ground-2); border-bottom: 1px solid var(--rule); overflow: hidden; }
.route-page-cover img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(.25) contrast(1.02); }
.route-page-cover .modal-cover-gradient { aspect-ratio: 16 / 9; border-bottom: 1px solid var(--rule); }
.route-page-body { padding: var(--s5) var(--s4) var(--s4); flex: 1; }
.route-title { font-size: var(--fs-h1); font-weight: 400; line-height: 1.1; letter-spacing: .03em; text-transform: uppercase; }
.route-title .mark { padding: 0 .1em; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: var(--s5); border: 1px solid var(--rule); background: var(--paper); }
.fact { padding: var(--s2) var(--s3); border-left: 1px solid var(--rule); min-width: 0; }
.fact:first-child { border-left: 0; }
.fact dt { font-family: var(--mono); font-weight: 700; font-size: var(--fs-micro); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.fact dd { font-weight: 600; font-size: var(--fs-ui); line-height: 1.25; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; hyphens: auto; }
.route-desc { margin-top: var(--s5); }
.intro { margin-top: var(--s5); }
.intro-btn { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 64px; padding: var(--s2) var(--s3); background: var(--paper); border: 1px solid var(--rule); }
.intro-btn:hover { background: var(--ground-2); }
.intro-play { width: 48px; height: 48px; display: grid; place-items: center; background: var(--ink); color: var(--paper); flex-shrink: 0; }
.intro-btn.is-playing .intro-play { background: var(--lime); color: var(--ink); }
.intro-text { display: flex; flex-direction: column; line-height: 1.25; }
.intro-text strong { font-weight: 600; }
.intro-text span { color: var(--ink-2); font-size: var(--fs-small); }
.stops { list-style: none; display: grid; }
.stop { border-bottom: 1px solid var(--rule-soft); }
.stop:last-child { border-bottom: 0; }
.stop-btn { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: var(--s3); width: 100%; min-height: 64px; padding: var(--s3) 0; }
.stop-btn:hover .stop-title { text-decoration: underline; text-underline-offset: 4px; }
.stop-n { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--rule); background: var(--paper); font-family: var(--mono); font-weight: 700; font-size: var(--fs-ui); }
.stop.is-next .stop-n { background: var(--coral); }
.stop.is-played .stop-n { background: var(--ink); color: var(--paper); }
.stop.is-played .stop-n .i { width: 18px; height: 18px; }
.stop-text { min-width: 0; }
.stop-title { display: block; font-weight: 600; line-height: 1.25; }
.stop-sub { display: block; color: var(--ink-2); font-size: var(--fs-small); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-tag { font-family: var(--mono); font-weight: 700; font-size: var(--fs-micro); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.stop.is-next .stop-tag { color: var(--ink); background: var(--coral); padding: 2px 6px; }
.stops-note { margin-top: var(--s3); color: var(--ink-2); font-size: var(--fs-small); }
.route-page-actions {
  position: sticky; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 20;
  padding: var(--s3) var(--s4) var(--s4); background: var(--ground); border-top: 1px solid var(--rule);
  display: grid; gap: var(--s2); justify-items: center;
}
body.has-player .route-page-actions { bottom: calc(var(--tab-h) + var(--player-h) + var(--safe-b)); }
.permission-note { display: flex; gap: var(--s2); align-items: flex-start; font-size: var(--fs-small); color: var(--ink-2); justify-self: stretch; }
.permission-note .i { width: 18px; height: 18px; margin-top: 1px; color: var(--ink); }

/* ── Настройки ─────────────────────────────────────── */
.setting-group { background: var(--paper); border: 1px solid var(--rule); padding: var(--s4); margin-bottom: var(--s3); }
.setting-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4); }
.setting-label strong { display: block; font-size: var(--fs-ui); font-weight: 600; }
.setting-label p { font-size: var(--fs-small); color: var(--ink-2); margin-top: 2px; }
.switch { position: relative; flex-shrink: 0; width: 56px; height: 32px; margin-top: 2px; cursor: pointer; }
.switch input { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); opacity: 0; cursor: pointer; z-index: 1; margin: 0; }
.sw-track { position: absolute; inset: 0; border: 1px solid var(--rule); background: var(--ground); transition: background-color var(--t-fast) var(--ease); }
.sw-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: var(--ink); transition: transform var(--t-fast) var(--ease); }
.switch input:checked + .sw-track { background: var(--lime); }
.switch input:checked + .sw-track::after { transform: translateX(24px); }
.switch input:focus-visible + .sw-track { outline: 3px solid var(--blue); outline-offset: 2px; }
.range-wrap { margin-top: var(--s4); }
.range-wrap input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--ink); cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; font-size: var(--fs-small); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.range-labels strong { color: var(--ink); font-family: var(--mono); }
.chip-list { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.chip { min-height: 44px; padding: 0 var(--s3); border: 1px solid var(--rule); background: var(--paper); font-size: var(--fs-small); font-weight: 600; }
.chip:hover:not([disabled]) { background: var(--ground-2); }
.chip.active { background: var(--coral); }
.chip[disabled] { color: var(--ink-3); border-color: var(--rule-soft); cursor: not-allowed; }
.chip-hint { font-size: var(--fs-small); color: var(--ink-2); }
.setting-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.setting-link { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; font-weight: 600; }
.setting-link:hover span { text-decoration: underline; text-underline-offset: 4px; }
.status-list { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s4); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px var(--s2); border: 1px solid var(--rule-soft); font-size: var(--fs-small); color: var(--ink-2); }
.status-pill .dot { width: 8px; height: 8px; background: var(--ink-3); }
.status-pill[data-state="ok"] .dot { background: #1f9e00; }
.status-pill[data-state="warn"] .dot { background: #f5a300; }
.status-pill[data-state="error"] .dot { background: var(--crimson); }

/* ── Карта ─────────────────────────────────────── */
.view-map { position: relative; }
#map {
  width: 100%; height: calc(100dvh - var(--top-h) - var(--tab-h) - var(--safe-b));
  min-height: 320px; background: var(--ground-2);
}
body.has-player #map { height: calc(100dvh - var(--top-h) - var(--tab-h) - var(--player-h) - var(--safe-b)); }
#map [class*="-ground-pane"] { filter: grayscale(.85) contrast(1.04); }
/* Yandex's own zoom buttons and logo chips: flat like the rest (no shadow, square, 1px rule) */
#map [class*="-float-button"]:not([class*="-float-button-icon"]):not([class*="-float-button-text"]) { box-shadow: none !important; border: 1px solid var(--rule) !important; border-radius: 0 !important; }
#map [class*="-gotoymaps__container"], #map [class*="-gototaxi__container"] { box-shadow: none !important; }
.map-controls {
  position: absolute; top: var(--s3); left: var(--s3); z-index: 20;
  display: flex; background: var(--paper); border: 1px solid var(--rule); box-shadow: var(--lift);
}
.map-ctrl-btn { min-height: 44px; padding: 0 var(--s4); font-size: var(--fs-small); font-weight: 600; }
.map-ctrl-btn + .map-ctrl-btn { border-left: 1px solid var(--rule); }
.map-ctrl-btn.active { background: var(--ink); color: var(--paper); }
.locate-btn {
  position: absolute; right: var(--s3); top: var(--s3); z-index: 20;
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s3);
  background: var(--paper); border: 1px solid var(--rule); box-shadow: var(--lift); font-weight: 600; font-size: var(--fs-small);
}
.locate-btn:hover { background: var(--ground-2); }
.locate-btn.is-on .i { color: var(--blue); }
.map-loading {
  position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; gap: var(--s3);
  background: var(--ground-2); font-weight: 600; color: var(--ink-2);
}
.map-loading.is-done { display: none; }
.loader { width: 18px; height: 18px; border: 2px solid var(--ink); border-right-color: transparent; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.map-error-state {
  position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: var(--s3);
  padding: var(--s6); background: var(--ground);
}
.map-error-state h2 { font-size: var(--fs-h2); font-weight: 400; text-transform: uppercase; letter-spacing: .04em; }
.map-error-state p { color: var(--ink-2); }
.map-notice {
  position: absolute; top: calc(var(--s3) + 56px); left: var(--s3); right: var(--s3); z-index: 25;
  display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s2) var(--s2) var(--s3);
  background: var(--paper); border: 1px solid var(--crimson); box-shadow: var(--lift); font-size: var(--fs-small);
}
.map-notice p { flex: 1; }
.map-notice strong { color: var(--crimson); }

.geo-banner {
  position: absolute; left: var(--s3); right: var(--s3); top: calc(var(--s3) + 56px); z-index: 40;
  max-height: calc(100% - 80px); overflow-y: auto;
  display: none; flex-direction: column; gap: var(--s2); padding: var(--s4);
  background: var(--paper); border: 1px solid var(--rule); border-top: 6px solid var(--crimson); box-shadow: var(--lift);
}
.geo-banner.visible { display: flex; }
.geo-banner strong { font-size: var(--fs-ui); }
.geo-banner p { font-size: var(--fs-small); color: var(--ink-2); }
.geo-banner ol { font-size: var(--fs-small); color: var(--ink-2); padding-left: 1.2em; display: grid; gap: 2px; }
.geo-banner .banner-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }

/* ── Режим прогулки ─────────────────────────────────────── */
.walk {
  position: absolute; left: var(--s3); right: var(--s3); bottom: var(--s3); z-index: 30;
  background: var(--paper); border: 1px solid var(--rule); box-shadow: var(--lift);
  animation: rise var(--t-med) var(--ease);
}
@keyframes rise { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.walk-steps { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4) 0; }
.walk-bar { flex: 1; display: flex; gap: 3px; }
.walk-bar span { flex: 1; height: 6px; background: var(--ground-2); }
.walk-bar span.is-played { background: var(--ink); }
.walk-bar span.is-next { background: var(--coral); }
.walk-count { flex-shrink: 0; font-family: var(--mono); font-weight: 700; font-size: var(--fs-small); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.walk-body { padding: var(--s2) var(--s4) var(--s4); display: grid; gap: var(--s2); }
.walk-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s2); min-width: 0; }
.walk-end { flex-shrink: 0; font-size: var(--fs-small); padding: 0 var(--s1); margin: -10px calc(-1 * var(--s1)) -10px 0; }
.walk-title { font-size: var(--fs-lead); font-weight: 600; line-height: 1.2; min-width: 0; padding-top: 2px; }
.walk-dist { font-family: var(--mono); font-weight: 700; font-size: var(--fs-small); letter-spacing: -.02em; }
.walk-hint { font-size: var(--fs-small); color: var(--ink-2); display: flex; align-items: center; gap: var(--s2); }
.walk-hint .dot { width: 8px; height: 8px; flex-shrink: 0; background: var(--ink-3); }
.walk-hint.is-warn .dot { background: #f5a300; }
.walk-hint .btn-quiet { min-height: 32px; padding: 0 4px; font-size: var(--fs-small); }
.walk-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2); margin-top: var(--s1); }
.walk-actions .btn { min-width: 0; padding: 0 var(--s4); }
@media (max-height: 700px) {
  .walk-body { gap: 4px; padding-bottom: var(--s3); }
  .walk-title { font-size: var(--fs-ui); }
  .walk-actions .btn { min-height: 44px; }
}
.walk.is-done .walk-title .mark { background: var(--lime); }

/* ── Мини-плеер ─────────────────────────────────────── */
.miniplayer {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 110;
  height: var(--player-h); background: var(--ink); color: var(--paper);
  display: none; flex-direction: column;
}
.miniplayer.visible { display: flex; animation: rise var(--t-med) var(--ease); }
.audio-bar { height: 28px; margin-top: -14px; margin-bottom: -10px; display: flex; align-items: center; cursor: pointer; touch-action: none; position: relative; z-index: 1; }
.audio-bar-track { width: 100%; height: 4px; background: #3a3f45; position: relative; }
.audio-fill { position: absolute; inset: 0; background: var(--lime); transform-origin: left center; transform: scaleX(0); }
.audio-bar:focus-visible { outline-offset: 0; }
.miniplayer-row { flex: 1; display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2) 0 var(--s3); min-width: 0; }
.player-btn { width: 48px; height: 48px; display: grid; place-items: center; background: var(--lime); color: var(--ink); flex-shrink: 0; }
.player-btn .i { width: 22px; height: 22px; }
.player-unlock { width: auto; display: inline-flex; gap: var(--s2); padding: 0 var(--s3); font-weight: 600; font-size: var(--fs-small); animation: pulse 1.6s var(--ease) infinite; }
.miniplayer-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.miniplayer-title { font-weight: 600; font-size: var(--fs-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.miniplayer-sub { font-size: var(--fs-small); color: #c9cfd5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.miniplayer-next { font-family: var(--mono); font-size: var(--fs-micro); font-weight: 700; color: var(--lime); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-close { width: 44px; height: 44px; display: grid; place-items: center; color: var(--paper); flex-shrink: 0; }
.player-close:hover { color: var(--lime); }

/* ── Нижний лист точки ─────────────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 200; background: rgba(17, 18, 20, .55); display: none; align-items: flex-end; justify-content: center; }
.sheet-backdrop.open { display: flex; animation: fade var(--t-fast) linear; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: relative; width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--ground); border-top: 1px solid var(--rule); padding-bottom: var(--safe-b);
}
.sheet-backdrop.open .sheet { animation: sheet-up var(--t-med) var(--ease); }
@keyframes sheet-up { from { transform: translateY(40px); } to { transform: none; } }
.sheet-grip { width: 48px; height: 4px; background: var(--ink); margin: var(--s2) auto; }
.sheet-close { position: absolute; top: var(--s2); right: var(--s2); z-index: 3; width: 48px; height: 48px; display: grid; place-items: center; background: var(--paper); border: 1px solid var(--rule); }
.sheet-close:hover { background: var(--ground-2); }
.sheet .modal-cover { aspect-ratio: 16 / 9; overflow: hidden; background: var(--ground-2); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.sheet .modal-cover img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(.25) contrast(1.02); }
.sheet-body { padding: var(--s4); display: grid; gap: var(--s3); }
.point-context { font-family: var(--mono); font-weight: 700; font-size: .8125rem; letter-spacing: .02em; margin-top: calc(-1 * var(--s2)); }
.point-title { font-size: var(--fs-h2); font-weight: 400; line-height: 1.15; letter-spacing: .02em; text-transform: uppercase; padding-right: 56px; }
#pointModalCoverWrap:not(:empty) + .sheet-body .point-title { padding-right: 0; }
.btn-listen { min-height: 56px; font-size: var(--fs-ui); }
.btn-listen.is-playing { background: var(--lime); color: var(--ink); }
.point-desc { font-size: var(--fs-body); }
.point-desc-full { white-space: pre-line; }
#pointModalDescToggle { justify-self: start; }
.point-chip-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.point-chip-row:empty { display: none; }
.next-chip { font-family: var(--mono); font-weight: 700; font-size: var(--fs-micro); padding: 4px var(--s2); background: var(--lime); }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); padding: 0 var(--s4) var(--s4); }
.sheet-actions .btn:only-child { grid-column: 1 / -1; }

/* ── Первый запуск ─────────────────────────────────────── */
.onboarding { position: fixed; inset: 0; z-index: 300; background: var(--ground); overflow-y: auto; }
.onboarding:focus { outline: none; }
.onboarding-inner { max-width: 560px; margin: 0 auto; min-height: 100%; padding: calc(var(--s10) + env(safe-area-inset-top, 0px)) var(--s5) calc(var(--s6) + var(--safe-b)); display: flex; flex-direction: column; }
.onboarding-title { font-size: clamp(2.5rem, 13vw, 4.25rem); font-weight: 300; line-height: .98; letter-spacing: .08em; text-transform: uppercase; }
.onboarding-line { display: block; }
.mark-wipe { position: relative; background: transparent; }
.mark-wipe::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--coral); transform-origin: left; animation: wipe 700ms var(--ease) 150ms both; }
.onboarding-title .onboarding-line:last-child { position: relative; z-index: 0; }
@keyframes wipe { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.onboarding-lede { margin-top: var(--s5); font-size: var(--fs-lead); line-height: 1.35; }
.onboarding-steps { list-style: none; margin-top: var(--s8); display: grid; border-top: 1px solid var(--rule); }
.onboarding-steps li { display: grid; grid-template-columns: 44px 1fr; gap: var(--s3); padding: var(--s4) 0; border-bottom: 1px solid var(--rule); }
.onboarding-steps strong { font-size: var(--fs-lead); font-weight: 600; line-height: 1.2; }
.onboarding-steps p { color: var(--ink-2); margin-top: 2px; }
.step-n { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--rule); background: var(--paper); font-family: var(--mono); font-weight: 700; font-size: var(--fs-lead); }
.step-n-lime { background: var(--lime); }
.onboarding-actions { margin-top: auto; padding-top: var(--s8); display: grid; gap: var(--s2); justify-items: center; }

/* ── Тосты ─────────────────────────────────────── */
.toast-root { position: fixed; left: var(--s3); right: var(--s3); bottom: calc(var(--tab-h) + var(--safe-b) + var(--s3)); z-index: 350; display: grid; justify-items: center; gap: var(--s2); pointer-events: none; }
body.has-player .toast-root { bottom: calc(var(--tab-h) + var(--player-h) + var(--safe-b) + var(--s3)); }
.toast { max-width: 440px; padding: var(--s3) var(--s4); background: var(--ink); color: var(--paper); font-size: var(--fs-ui); box-shadow: var(--lift); opacity: 0; transform: translateY(8px); transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease); }
.toast.visible { opacity: 1; transform: none; }
.toast-error::before, .toast-success::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: var(--s2); vertical-align: .05em; }
.toast-error::before { background: #ff4d6d; }
.toast-success::before { background: var(--lime); }

/* ── Узкие экраны ─────────────────────────────────────── */
@media (max-width: 359px) {
  .pane { padding-left: var(--s3); padding-right: var(--s3); }
  .display { font-size: 2.125rem; }
  .wordmark { font-size: .8125rem; letter-spacing: .1em; }
  .autosound { padding: 0 var(--s2); }
  .locate-label { display: none; }
  .map-ctrl-btn { padding: 0 var(--s3); }
  .sheet-actions { grid-template-columns: 1fr; }
}

/* Факты маршрута 2×2: «Пешком», «2,1 км» и т. п. не должны обрезаться на 375px */
@media (max-width: 420px) {
  .facts { grid-template-columns: repeat(2, 1fr); }
  .fact:nth-child(3) { border-left: 0; }
  .fact:nth-child(n + 3) { border-top: 1px solid var(--rule); }
}

/* Узкий или низкий экран: липкая панель старта не должна съедать полэкрана */
.permission-short { display: none; }
@media (max-width: 380px), (max-height: 700px) {
  .permission-full { display: none; }
  .permission-short { display: inline; }
  .permission-note { align-items: center; }
  .permission-note .i { margin-top: 0; }
  .route-page-actions { padding-top: var(--s2); padding-bottom: var(--s2); gap: var(--s1); }
}

/* ── Десктоп: список слева, карта справа ─────────────────────── */
@media (min-width: 960px) {
  :root { --top-h: 64px; }
  body, body.has-player { padding-bottom: 0; overflow: hidden; height: 100dvh; }
  .topbar { padding: 0 var(--s6); gap: var(--s6); }
  .wordmark { font-size: 1rem; margin-right: 0; width: calc(var(--pane-w) - var(--s12)); }
  .sidenav { display: flex; gap: var(--s1); margin-right: auto; }
  .sidenav-btn { min-height: 44px; padding: 0 var(--s4); font-size: var(--fs-small); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; border: 1px solid transparent; }
  .sidenav-btn:hover { border-color: var(--rule); }
  .sidenav-btn.active { background: var(--ink); color: var(--paper); }
  .tabbar { display: none; }
  .layout { display: grid; grid-template-columns: var(--pane-w) 1fr; height: calc(100dvh - var(--top-h)); }
  .pane { grid-column: 1; grid-row: 1; overflow-y: auto; height: 100%; border-right: 1px solid var(--rule); padding: var(--s8) var(--s6); }
  body.has-player .pane { padding-bottom: calc(var(--player-h) + var(--s8)); }
  #viewRoute.pane { padding: 0; }
  #viewMap { display: block; grid-column: 2; grid-row: 1; height: 100%; }
  #map, body.has-player #map { height: 100%; }
  .route-page-top { top: 0; }
  .route-page-actions { bottom: 0; }
  body.has-player .route-page-actions { bottom: var(--player-h); }
  .miniplayer { right: auto; width: var(--pane-w); bottom: 0; border-right: 1px solid var(--rule); }
  .toast-root, body.has-player .toast-root { left: calc(var(--pane-w) + var(--s4)); bottom: var(--s6); }
  .walk { left: auto; right: var(--s4); bottom: var(--s4); width: 400px; }
  .geo-banner { left: auto; right: var(--s4); width: 400px; }
  .map-notice { left: var(--s4); right: auto; width: 420px; }
  .sheet-backdrop { align-items: center; padding: var(--s6); }
  .sheet { border: 1px solid var(--rule); max-height: 88dvh; }
  .sheet-grip { display: none; }
  .sheet-close { top: var(--s3); right: var(--s3); }
  .locate-label { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .mark-wipe::before { transform: none; }
  .skeleton { animation: none; }
}
