/* ============================================================================
   ВИТЕБСКОЕ НАПРАВЛЕНИЕ — ДИЗАЙН-СИСТЕМА
   ---------------------------------------------------------------------------
   Строгий справочный стиль: прямые углы, тонкие линейки, сдержанная палитра,
   акцент один — сигнальный красный. Никаких градиентов, теней и «подъёмов»
   при наведении: состояние показывается рамкой и фоном.

   1. Токены и темы          6. Схема направления
   2. Базовая раскладка      7. Карточки станций и маршрутов
   3. Шапка и меню           8. Табло и списки поездов
   4. Типографика и кнопки   9. Страницы: расписание / станция / маршрут
   5. Секции главной        10. Адаптив, печать, анимации
   ========================================================================== */

/* ============================================================ 1. ТОКЕНЫ === */

:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
    /* Заголовки — антиква: справочник, а не лендинг */
    --serif: 'PT Serif', 'Noto Serif', Georgia, 'Times New Roman', serif;

    /* Цвета веток: приглушённые, различимые на белом */
    --line-main: #b02a24;
    --line-novgorod: #1f5f9e;
    --line-gatchina: #b8722a;
    --line-luga: #2c6b52;

    --from: #a86a10;
    --to: #1f5f9e;
    --accent: #b02a24;
    --accent-soft: rgba(176, 42, 36, .08);

    /* Прямые углы — базовое правило. Пилюли оставлены только там, где это
       элемент управления, а не блок: чипы, табы, сегменты, счётчики. */
    --radius-xs: 2px;
    --radius-sm: 3px;
    --radius: 4px;
    --radius-lg: 5px;
    --radius-full: 999px;

    --gap: 16px;
    --pad: 22px;
    --maxw: 1240px;

    --ease: cubic-bezier(.22, .8, .28, 1);
    --t-fast: .13s var(--ease);
    --t: .2s var(--ease);

    --rule: 1px;
}

/* --- светлая тема: бумага, чернила, линейка --- */
html[data-theme="light"] {
    --bg: #f3f1ec;
    --bg-grad: linear-gradient(rgba(24, 30, 40, .026) 1px, transparent 1px),
        linear-gradient(90deg, rgba(24, 30, 40, .026) 1px, transparent 1px);
    --bg-size: 36px 36px;
    --surface: #ffffff;
    --surface-2: #f7f6f2;
    --surface-3: #edeae3;
    --border: #ddd8cd;
    --border-strong: #b9b3a5;
    --text: #14181f;
    --text-2: #4e5460;
    --text-3: #7d838e;
    --station: #a9a396;
    --station-ring: #ffffff;
    --grid: #e7e3da;
    --shadow-sm: 0 0 0 1px rgba(20, 24, 31, .02);
    --shadow: 0 1px 0 rgba(20, 24, 31, .04);
    --shadow-lg: 0 8px 24px -12px rgba(20, 24, 31, .28);
    --hero-grad: #14181f;
    --hero-text: #f4f2ed;
    --hero-dim: #9aa1ad;
    --scrim: rgba(20, 24, 31, .55);
    --ok: #1f6b4a;
    --warn: #8a5a12;
}

/* --- тёмная тема: ночной пульт --- */
html[data-theme="dark"] {
    --bg: #101318;
    --bg-grad: linear-gradient(rgba(255, 255, 255, .022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .022) 1px, transparent 1px);
    --bg-size: 36px 36px;
    --surface: #171b21;
    --surface-2: #1c2128;
    --surface-3: #232932;
    --border: #2b323c;
    --border-strong: #3f4854;
    --text: #e8e9ec;
    --text-2: #a8aeb8;
    --text-3: #79808c;
    --station: #4d5765;
    --station-ring: #171b21;
    --grid: #1f252d;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3);
    --shadow-lg: 0 12px 28px -14px rgba(0, 0, 0, .7);
    --hero-grad: #0b0e13;
    --hero-text: #eceef1;
    --hero-dim: #8b929e;
    --scrim: rgba(0, 0, 0, .68);
    --ok: #3f9e73;
    --warn: #c08a35;
    --line-main: #d4574f;
    --line-novgorod: #5a9ad8;
    --line-gatchina: #d3924a;
    --line-luga: #4f9c7b;
    --accent: #d4574f;
    --accent-soft: rgba(212, 87, 79, .12);
    --from: #c8913a;
    --to: #5a9ad8;
}

/* ====================================================== 2. БАЗА / СЕТКА === */

*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background-color: var(--bg);
    background-image: var(--bg-grad);
    background-size: var(--bg-size);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'tnum' 0;
}

/* Длинные названия станций («Платформа №3 / Суворовский Проспект») не должны
   растягивать страницу шире экрана: переносим их, а не вылезаем за край. */
.wrap,
.hero-in,
.preview-in,
.footer-in,
.two-col,
.section-head,
.stat-row,
.info-grid,
.station-grid,
.search-grid,
.dest-grid,
.preview-grid { min-width: 0; }

h1,
h2,
h3,
h4,
p,
li,
dt,
dd,
td,
th,
a,
span,
b,
small { overflow-wrap: break-word; }

.section-head > div,
.two-col > *,
.stat-box,
.info-cell,
.station-tile,
.dest-card,
.leg,
.ds-chip,
.board-dest,
.train-path,
.hero-stat,
.branch-card { min-width: 0; }

img,
svg { max-width: 100%; }

a { color: inherit; text-decoration: none; }

button,
input,
select { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

.wrap {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--pad);
}

.section { padding: 46px 0; }

.section--tight { padding: 26px 0; }

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    padding-bottom: 12px;
    border-bottom: var(--rule) solid var(--border);
    flex-wrap: wrap;
}

.section-head h2 {
    font-family: var(--serif);
    font-size: clamp(1.22rem, 2.2vw, 1.6rem);
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.25;
}

.section-head p {
    color: var(--text-2);
    font-size: .9rem;
    margin-top: 5px;
    max-width: 82ch;
}

.grid {
    display: grid;
    gap: var(--gap);
}

.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fill, minmax(min(210px, 100%), 1fr)); }

.card {
    background: var(--surface);
    border: var(--rule) solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ======================================================== 3. ШАПКА / МЕНЮ === */

.topbar {
    position: sticky;
    top: 0;
    z-index: 60;
    background: var(--surface);
    border-bottom: var(--rule) solid var(--border);
}

/* Сигнальная полоса под шапкой — единственный «декоративный» элемент */
.topbar::after {
    content: '';
    display: block;
    height: 2px;
    background: linear-gradient(90deg,
        var(--line-main) 0 25%,
        var(--line-novgorod) 25% 50%,
        var(--line-gatchina) 50% 75%,
        var(--line-luga) 75% 100%);
}

.topbar-in {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 60px;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--pad);
    min-width: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 11px;
    font-weight: 700;
    letter-spacing: -.01em;
    flex-shrink: 0;
    min-width: 0;
}

.logo-mark {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    background: var(--text);
    border-bottom: 3px solid var(--line-main);
    flex-shrink: 0;
}

html[data-theme="dark"] .logo-mark { background: var(--surface-3); border-bottom-color: var(--line-main); }

.logo-text { display: flex; flex-direction: column; line-height: 1.18; min-width: 0; }
.logo-text b {
    font-family: var(--serif);
    font-size: clamp(.84rem, 2.2vw, 1rem);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.logo-text span { font-size: .66rem; color: var(--text-3); font-weight: 600; letter-spacing: .09em; text-transform: uppercase; }

.nav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
}

.nav a {
    padding: 8px 13px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 550;
    color: var(--text-2);
    border-bottom: 2px solid transparent;
    transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
    white-space: nowrap;
}

.nav a:hover { color: var(--text); background: var(--surface-2); }

.nav a.active {
    color: var(--text);
    font-weight: 650;
    border-bottom-color: var(--accent);
    background: none;
}

.topbar-tools { display: flex; align-items: center; gap: 8px; }

.clock-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 11px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: var(--rule) solid var(--border);
    font-family: var(--mono);
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-2);
    white-space: nowrap;
}

.clock-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok);
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: var(--rule) solid var(--border);
    background: var(--surface);
    display: grid;
    place-items: center;
    font-size: 15px;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
}

.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }

/* Переключатель темы: показываем состояние сами, не полагаясь на текст кнопки.
   Символы ☀ и ☾ — обычные знаки, а не эмодзи, поэтому в строгом стиле уместны. */
#themeToggle { font-size: 0; color: var(--text-2); }
#themeToggle::before { content: '☀'; font-size: 15px; line-height: 1; }
html[data-theme="dark"] #themeToggle::before { content: '☾'; }
#themeToggle:hover { color: var(--text); }

.nav-burger { display: none; }

.nav-drawer {
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 8px var(--pad) 16px;
    background: var(--surface);
    border-bottom: var(--rule) solid var(--border);
}

.nav-drawer a {
    padding: 12px 4px;
    border-bottom: var(--rule) solid var(--border);
    font-size: .9rem;
    font-weight: 550;
    color: var(--text-2);
}

.nav-drawer a:last-child { border-bottom: none; }
.nav-drawer a:hover,
.nav-drawer a.active { color: var(--accent); }

/* ================================================== 4. ТИПОГРАФИКА / UI === */

h1,
h2,
h3,
h4 { font-family: var(--serif); }

h1 { font-size: clamp(1.55rem, 3.2vw, 2.2rem); font-weight: 700; letter-spacing: -.015em; line-height: 1.2; }
h2 { font-size: clamp(1.2rem, 2.3vw, 1.55rem); font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 1.06rem; font-weight: 700; }

.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Заголовок-надзаголовок: мелкая прописная надпись над блоком */
.eyebrow,
.field > label,
.board-head,
.share-popup-head,
.info-cell dt,
.footer h4,
.data-source b {
    font-family: var(--font);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: var(--rule) solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
    white-space: nowrap;
    text-align: center;
}

.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:active { background: var(--surface-3); }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn--primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); border-color: color-mix(in srgb, var(--accent) 86%, #000); }

.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--text-3); }

.btn--sm { padding: 7px 13px; font-size: .82rem; }
.btn--block { width: 100%; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 13px;
    border-radius: var(--radius-sm);
    border: var(--rule) solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: .83rem;
    font-weight: 550;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
    white-space: nowrap;
}

.chip:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }

.chip--active {
    background: var(--surface-3);
    border-color: var(--text-3);
    color: var(--text);
    font-weight: 650;
}

.chip-dot { width: 8px; height: 8px; border-radius: 1px; flex-shrink: 0; }

.chips-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: var(--rule) solid var(--border);
    font-family: var(--mono);
    font-size: .73rem;
    font-weight: 600;
    color: var(--text-2);
    white-space: nowrap;
}

.pill--live { background: color-mix(in srgb, var(--ok) 10%, transparent); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.pill--express { background: color-mix(in srgb, var(--line-gatchina) 12%, transparent); border-color: color-mix(in srgb, var(--line-gatchina) 35%, transparent); color: var(--line-gatchina); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.field > label {
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text-3);
}

.input,
select.input {
    width: 100%;
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    border: var(--rule) solid var(--border-strong);
    background: var(--surface);
    font-size: .93rem;
    font-weight: 450;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    min-width: 0;
}

.input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d838e' stroke-width='2.4' stroke-linecap='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 36px;
    cursor: pointer;
}

/* --- автокомплит станций --- */
.picker { position: relative; min-width: 0; }

.picker-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 40;
    max-height: 300px;
    overflow-y: auto;
    background: var(--surface);
    border: var(--rule) solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 4px;
}

.picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: none;
    border-radius: var(--radius-xs);
    cursor: pointer;
    text-align: left;
    transition: background var(--t-fast);
}

.picker-item:hover,
.picker-item.active { background: var(--surface-2); }
.picker-dot { width: 8px; height: 8px; border-radius: 1px; flex-shrink: 0; }
.picker-name { font-weight: 550; font-size: .89rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-meta { font-family: var(--mono); font-size: .71rem; color: var(--text-3); white-space: nowrap; flex-shrink: 0; }

/* --- тосты --- */
.toast-box {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
    width: max-content;
    max-width: 92vw;
}

.toast {
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--bg);
    font-weight: 550;
    font-size: .87rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn .22s var(--ease);
    text-align: center;
}

.toast.out { animation: toastOut .22s var(--ease) forwards; }

@keyframes toastIn { from { opacity: 0; } }
@keyframes toastOut { to { opacity: 0; } }

/* --- кнопка наверх --- */
.to-top {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 90;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    border: var(--rule) solid var(--border-strong);
    background: var(--surface);
    box-shadow: var(--shadow);
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t), background var(--t-fast);
}

.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { background: var(--surface-2); }

/* ======================================================== 5. ГЛАВНАЯ === */

.hero {
    position: relative;
    color: var(--hero-text);
    background: var(--hero-grad);
    border-bottom: 3px solid var(--accent);
}

/* Разметочная сетка вместо декоративного свечения */
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
    background-size: 44px 44px;
    pointer-events: none;
}

.hero-in {
    position: relative;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 54px var(--pad) 56px;
    display: grid;
    gap: 40px;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr);
    align-items: start;
}

/* Колонки первого экрана: min-width обязателен, иначе длинные подписи
   в полях поиска не дают колонкам сжиматься и форма вылезает за экран */
.hero-copy,
.hero-side { min-width: 0; }

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, .06);
    border: var(--rule) solid rgba(255, 255, 255, .22);
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.hero h1 { font-size: clamp(1.5rem, 4.2vw, 2.85rem); line-height: 1.12; }

.hero h1 em {
    font-style: italic;
    display: inline;
    color: #f0c9a0;
    background: none;
    -webkit-text-fill-color: currentColor;
}

.hero-lead {
    margin-top: 18px;
    font-size: clamp(.94rem, 1.4vw, 1.04rem);
    color: var(--hero-dim);
    max-width: 60ch;
    line-height: 1.7;
}

/* Статистика — таблица в линейку, а не набор карточек */
.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 0;
    margin-top: 30px;
    border-top: var(--rule) solid rgba(255, 255, 255, .2);
    border-bottom: var(--rule) solid rgba(255, 255, 255, .2);
}

.hero-stat {
    padding: 15px 14px 15px 0;
    border-right: var(--rule) solid rgba(255, 255, 255, .14);
    min-width: 0;
}

.hero-stat:last-child { border-right: none; }

.hero-stat b {
    display: block;
    font-family: var(--mono);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -.02em;
    line-height: 1.15;
}

.hero-stat span { font-size: .72rem; color: var(--hero-dim); font-weight: 550; }

/* --- панель выбора маршрута --- */
.hero-search {
    background: var(--surface);
    border: var(--rule) solid var(--border-strong);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 22px;
    color: var(--text);
}

.hero-search h3 { margin-bottom: 4px; }
.hero-search .muted { font-size: .84rem; margin-bottom: 16px; }

.search-grid {
    display: grid;
    /* minmax(0, …) обязательно: иначе инпуты не дают колонкам сжиматься
       и форма вылезает за экран на телефонах */
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 10px;
    align-items: end;
}

.swap-btn {
    width: 42px;
    height: 44px;
    border-radius: var(--radius-sm);
    border: var(--rule) solid var(--border-strong);
    background: var(--surface-2);
    cursor: pointer;
    font-size: 15px;
    display: grid;
    place-items: center;
    transition: background var(--t-fast), border-color var(--t-fast);
}

.swap-btn:hover { background: var(--surface-3); border-color: var(--text-3); }

.quick-routes {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 16px;
    padding-top: 15px;
    border-top: var(--rule) solid var(--border);
}

.quick-routes button {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: var(--rule) solid var(--border);
    background: var(--surface-2);
    font-size: .79rem;
    font-weight: 550;
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.quick-routes button:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* --- строка ближайших отправлений --- */
.ticker {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 14px 0 6px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.ticker-item {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: var(--rule) solid var(--border);
    font-size: .84rem;
    white-space: nowrap;
}

.ticker-item b { font-family: var(--mono); font-size: .92rem; }

/* --- полоса с направлениями под первым экраном --- */
.preview-band {
    background: #171b21;
    color: var(--hero-text);
    border-bottom: var(--rule) solid var(--border);
}

html[data-theme="light"] .preview-band { background: #1b2027; }

.preview-in {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 36px var(--pad) 40px;
}

.preview-head { margin-bottom: 22px; }
.preview-head h2 { font-size: clamp(1.15rem, 2.1vw, 1.5rem); }
.preview-head p { color: var(--hero-dim); font-size: .9rem; margin-top: 8px; max-width: 78ch; }

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(238px, 1fr));
    gap: 0;
    border: var(--rule) solid rgba(255, 255, 255, .16);
}

.branch-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    background: rgba(255, 255, 255, .03);
    border-right: var(--rule) solid rgba(255, 255, 255, .16);
    border-top: 3px solid var(--bc, #fff);
    color: var(--hero-text);
    transition: background var(--t-fast);
}

.branch-card:last-child { border-right: none; }
.branch-card:hover { background: rgba(255, 255, 255, .08); }

.branch-card-top { display: flex; align-items: center; gap: 10px; }
.branch-card-icon {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    font-family: var(--mono);
    font-size: .78rem;
    font-weight: 600;
    color: #fff;
    background: var(--bc, #fff);
    border-radius: var(--radius-xs);
    flex-shrink: 0;
}
.branch-card-name { font-family: var(--serif); font-weight: 700; font-size: 1.02rem; letter-spacing: -.005em; }

.branch-card-route {
    font-size: .83rem;
    color: var(--hero-dim);
    line-height: 1.6;
}

.branch-card-route b { color: var(--hero-text); font-weight: 600; }

.branch-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
    padding-top: 12px;
    border-top: var(--rule) solid rgba(255, 255, 255, .16);
}

.branch-stat {
    font-family: var(--mono);
    font-size: .71rem;
    font-weight: 550;
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    background: rgba(255, 255, 255, .08);
    white-space: nowrap;
}

.branch-card-go {
    font-size: .79rem;
    font-weight: 600;
    color: var(--hero-text);
    border-bottom: 1px solid var(--bc, #fff);
    align-self: flex-start;
    padding-bottom: 1px;
}

.preview-map .diagram-label { fill: rgba(255, 255, 255, .93) !important; }
.preview-map .diagram-meta { fill: rgba(255, 255, 255, .5) !important; }
.preview-map .diagram-caption { fill: rgba(255, 255, 255, .85) !important; }
.preview-map .diagram-dot { stroke: rgba(255, 255, 255, .5); }

.diagram-scroll {
    position: relative;
    overflow: auto;
    border: var(--rule) solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.diagram-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.diagram-scroll::-webkit-scrollbar-track { background: var(--surface-2); }
.diagram-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); }
.diagram-scroll::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

.diagram-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.diagram-toolbar .spacer { margin-left: auto; }

/* ================================================== 6. СХЕМА НАПРАВЛЕНИЯ === */

#diagram,
.diagram {
    display: block;
    width: 100%;
    height: auto;
    background: var(--surface);
}

/* Схема без явной высоты (в полосе-превью) подстраивается под контейнер */
.preview-map svg { background: transparent; }

.diagram-station { cursor: pointer; }
.diagram-station:focus-visible .diagram-dot { outline: 2px solid var(--accent); }

.diagram-dot { transition: r .16s var(--ease), fill .16s var(--ease); }
.diagram-station:hover .diagram-dot { r: 6.5; }

.diagram-label { fill: var(--text); font-family: var(--font); pointer-events: none; }
.diagram-label--big { fill: var(--text); }
.diagram-meta { fill: var(--text-3); font-size: 8.5px; font-family: var(--mono); pointer-events: none; }
.diagram-caption { font-family: var(--font); pointer-events: none; letter-spacing: .02em; text-transform: uppercase; }

/* Линии веток — тонкие, без «свечения» */
.diagram-line { opacity: .14 !important; }
.diagram-core { stroke-width: 2 !important; }

.diagram-route { stroke-dasharray: 9 6; animation: dash 1.4s linear infinite; }

@keyframes dash { to { stroke-dashoffset: -15; } }

.diagram-halo { animation: halo 2.4s var(--ease) infinite; }

@keyframes halo {
    50% { opacity: .3; }
}

/* ============================================= 7. КАРТОЧКИ МАРШРУТОВ / СТАНЦИЙ === */

.route-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 18px;
    border-radius: var(--radius);
    background: var(--surface);
    border: var(--rule) solid var(--border);
    border-left: 3px solid var(--border-strong);
    transition: border-color var(--t-fast), background var(--t-fast);
    position: relative;
    min-width: 0;
}

.route-card:hover {
    background: var(--surface-2);
    border-color: var(--border-strong);
    border-left-color: var(--accent);
}

/* Заголовок карточки: номер в списке слева, заголовок и бейдж — рядом
   в обычном потоке, поэтому длинные названия их не «наезжают» друг на друга */
.route-card-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.route-card-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-xs);
    background: var(--surface-3);
    font-family: var(--mono);
    font-size: .76rem;
    font-weight: 600;
    color: var(--text-3);
}

.route-card-titles {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.route-card-from,
.route-card-to {
    font-size: .95rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.route-card-to { color: var(--text); }

.route-card-head {
    display: flex;
    align-items: baseline;
    gap: 7px;
    flex-wrap: wrap;
    font-weight: 600;
    font-size: .95rem;
}

.route-card-arrow { color: var(--accent); font-weight: 600; flex-shrink: 0; }

/* Пометка маршрута («главный ход», «лужская ветка») — отдельная строка
   под названием, прижата влево, поэтому перекрытие невозможно в принципе */
.route-card-tag {
    align-self: flex-start;
    margin-top: 3px;
    padding: 2px 7px;
    border-radius: var(--radius-xs);
    background: none;
    border: var(--rule) solid var(--border-strong);
    color: var(--text-3);
    font-family: var(--font);
    font-size: .66rem;
    font-weight: 600;
    letter-spacing: .07em;
    text-transform: uppercase;
    line-height: 1.6;
}

.route-card-meta { display: flex; flex-wrap: wrap; gap: 5px 14px; font-size: .79rem; color: var(--text-2); font-weight: 450; }
.route-card-next { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .77rem; color: var(--text-2); padding-top: 9px; border-top: var(--rule) solid var(--border); }
.route-card-next-dest { font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- карточка «следующий поезд» --- */
.next-card {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--surface);
    border: var(--rule) solid var(--border);
    border-top: 3px solid var(--branch, var(--accent));
    box-shadow: var(--shadow-sm);
    position: relative;
}

.next-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; padding-bottom: 10px; border-bottom: var(--rule) solid var(--border); }

.next-badge {
    font-size: .69rem;
    font-weight: 650;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-3);
}

.next-station { font-family: var(--mono); font-size: .79rem; color: var(--text-3); font-weight: 550; }
.next-main { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.next-time {
    font-family: var(--mono);
    font-size: clamp(1.9rem, 5.4vw, 2.6rem);
    font-weight: 600;
    letter-spacing: -.03em;
    line-height: 1;
    color: var(--text);
}

.next-info { min-width: 0; flex: 1; }
.next-dest { font-weight: 600; font-size: 1rem; }
.next-meta { font-size: .81rem; color: var(--text-3); margin-top: 3px; }

.next-count {
    margin-left: auto;
    text-align: right;
    padding-left: 18px;
    border-left: var(--rule) solid var(--border);
}

.next-count-num { display: block; font-family: var(--mono); font-size: 1.7rem; font-weight: 600; line-height: 1; }
.next-count-num--small { font-family: var(--font); font-size: 1.05rem; letter-spacing: -.01em; }
.next-count-label { font-size: .73rem; color: var(--text-3); font-weight: 550; }
.next-empty { padding: 24px; text-align: center; color: var(--text-3); font-size: .88rem; }

/* =============================================== 8. ТАБЛО И СПИСКИ ПОЕЗДОВ === */

.board {
    border-radius: var(--radius);
    border: var(--rule) solid var(--border);
    background: var(--surface);
    overflow: hidden;
}

.board-head,
.board-row {
    display: grid;
    grid-template-columns: 74px 82px minmax(0, 1fr) 118px 84px;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
}

.board-head {
    background: var(--surface-2);
    border-bottom: var(--rule) solid var(--border-strong);
    font-size: .69rem;
    font-weight: 650;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text-3);
}

.board-row {
    border-bottom: var(--rule) solid var(--border);
    transition: background var(--t-fast);
    font-size: .87rem;
}

.board-row:last-child { border-bottom: none; }
.board-row:hover { background: var(--surface-2); }

.board-row--next {
    background: color-mix(in srgb, var(--ok) 7%, transparent);
    box-shadow: inset 3px 0 0 var(--ok);
}

.board-time { font-family: var(--mono); font-size: 1.02rem; font-weight: 600; }
.board-num { font-family: var(--mono); font-size: .82rem; color: var(--text-3); font-weight: 500; }
.board-dest { display: flex; align-items: center; gap: 9px; min-width: 0; }
.board-dot { width: 8px; height: 8px; border-radius: 1px; flex-shrink: 0; }
.board-dest-text { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.board-kind {
    font-size: .69rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    border: var(--rule) solid var(--border);
    background: var(--surface-2);
    color: var(--text-2);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.board-kind--express { background: color-mix(in srgb, var(--line-gatchina) 12%, transparent); border-color: color-mix(in srgb, var(--line-gatchina) 35%, transparent); color: var(--line-gatchina); }
.board-kind--seasonal { background: color-mix(in srgb, var(--line-luga) 12%, transparent); border-color: color-mix(in srgb, var(--line-luga) 35%, transparent); color: var(--line-luga); }
.board-left { text-align: right; font-size: .79rem; font-weight: 600; color: var(--text-3); font-family: var(--mono); }
.board-row--next .board-left { color: var(--ok); }
.board-left--far { font-weight: 500; opacity: .85; font-family: var(--font); font-size: .73rem; }

/* --- карточка поезда (страница маршрута) --- */
.train-card {
    border: var(--rule) solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    transition: border-color var(--t-fast);
}

.train-card + .train-card { margin-top: 10px; }
.train-card:hover { border-color: var(--border-strong); }
.train-card.open { border-color: var(--text-3); }

.train-head {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 15px 16px;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.train-dep { text-align: center; padding-right: 14px; border-right: var(--rule) solid var(--border); }
.train-dep b { display: block; font-family: var(--mono); font-size: 1.24rem; font-weight: 600; line-height: 1.1; }
.train-dep span { font-size: .68rem; color: var(--text-3); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }

.train-path { min-width: 0; }
.train-path-top { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .94rem; flex-wrap: wrap; }
.train-path-line { display: flex; align-items: center; gap: 8px; margin-top: 5px; color: var(--text-3); font-size: .77rem; flex-wrap: wrap; }

.train-arrow { color: var(--accent); }

.train-rail {
    position: relative;
    height: 2px;
    background: var(--surface-3);
    margin-top: 10px;
}

.train-rail::after {
    content: '';
    position: absolute;
    inset: 0;
    width: var(--fill, 40%);
    background: var(--accent);
}

.train-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.train-dur { font-family: var(--mono); font-weight: 600; font-size: .98rem; }
.train-num { font-family: var(--mono); font-size: .72rem; color: var(--text-3); font-weight: 500; }

.train-body {
    border-top: var(--rule) solid var(--border);
    padding: 6px 16px 18px;
    background: var(--surface-2);
    display: none;
}

.train-card.open .train-body { display: block; }

.stop-list { display: flex; flex-direction: column; }

.stop-item {
    display: grid;
    grid-template-columns: 62px 20px minmax(0, 1fr) 62px;
    gap: 10px;
    align-items: center;
    padding: 6px 0;
    font-size: .85rem;
    position: relative;
}

.stop-time { font-family: var(--mono); color: var(--text-2); font-size: .81rem; text-align: right; }
.stop-mark { display: grid; place-items: center; position: relative; height: 100%; }

.stop-mark::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--border-strong);
}

.stop-item:first-child .stop-mark::before { top: 50%; }
.stop-item:last-child .stop-mark::before { bottom: 50%; }

.stop-dot {
    position: relative;
    width: 9px;
    height: 9px;
    border-radius: 1px;
    background: var(--surface);
    border: 1.5px solid var(--border-strong);
    z-index: 1;
}

.stop-item.is-first .stop-dot,
.stop-item.is-last .stop-dot { width: 13px; height: 13px; border-width: 2.5px; }
.stop-item.is-first .stop-dot { border-color: var(--from); }
.stop-item.is-last .stop-dot { border-color: var(--to); }
.stop-item.is-pass .stop-dot { width: 5px; height: 5px; background: var(--border-strong); border: none; }

.stop-name { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-name a:hover { color: var(--accent); text-decoration: underline; }
.stop-item.is-pass .stop-name { color: var(--text-3); font-weight: 450; }
.stop-km { font-size: .73rem; color: var(--text-3); font-family: var(--mono); text-align: right; }

/* --- станция за пределами пригородной зоны --- */
.no-service {
    padding: 22px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: var(--rule) solid var(--border);
    border-left: 3px solid var(--warn);
    text-align: left;
}

.no-service-icon { display: none; }
.no-service h3 { margin-bottom: 8px; font-size: 1.04rem; }
.no-service p { font-size: .87rem; color: var(--text-2); line-height: 1.7; }
.no-service p + p { margin-top: 10px; }

/* --- плашка об источнике данных --- */
.data-source {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: var(--rule) solid var(--border);
    border-left: 3px solid var(--border-strong);
    font-size: .81rem;
    color: var(--text-2);
    line-height: 1.65;
}

.data-source b { color: var(--text); font-weight: 650; }
.data-source-icon { display: none; }

.notice--warn { border-left-color: var(--warn); }

/* ============================================ 8b. РАСПИСАНИЕ НА ДЕНЬ === */

.day-schedule {
    border: var(--rule) solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.ds-row {
    display: grid;
    grid-template-columns: 66px minmax(0, 1fr);
    gap: 0;
    border-bottom: var(--rule) solid var(--border);
}

.ds-row:last-child { border-bottom: none; }

.ds-row--now { background: var(--accent-soft); }

.ds-hour {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 6px;
    background: var(--surface-2);
    border-right: var(--rule) solid var(--border);
    font-family: var(--mono);
    line-height: 1.1;
}

.ds-hour b { font-size: 1.1rem; font-weight: 600; }
.ds-hour span { font-size: .66rem; color: var(--text-3); }
.ds-row--now .ds-hour { background: var(--accent-soft); }
.ds-row--now .ds-hour b { color: var(--accent); }

.ds-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
}

.ds-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 5px 10px;
    border-radius: var(--radius-xs);
    background: var(--surface);
    border: var(--rule) solid var(--border);
    font-size: .83rem;
    transition: border-color var(--t-fast), background var(--t-fast);
    /* длинные названия («Платформа №3 / Суворовский Проспект») не должны
       растягивать строку шире контейнера */
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
}

.ds-chip:hover {
    border-color: var(--text-3);
    background: var(--surface-2);
}

.ds-chip--soon {
    background: color-mix(in srgb, var(--ok) 9%, transparent);
    border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}

.ds-time { font-family: var(--mono); font-weight: 600; font-size: .86rem; }
.ds-chip--soon .ds-time { color: var(--ok); }
.ds-dest { display: inline-flex; align-items: center; gap: 7px; min-width: 0; font-weight: 500; max-width: 100%; }
.ds-dest span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22ch; }
.ds-dot { width: 7px; height: 7px; border-radius: 1px; flex-shrink: 0; }
.ds-num { font-family: var(--mono); font-size: .71rem; color: var(--text-3); }

.ds-legend {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 11px 16px;
    border-top: var(--rule) solid var(--border);
    background: var(--surface-2);
    font-size: .77rem;
    color: var(--text-2);
}

.ds-legend span { display: inline-flex; align-items: center; gap: 7px; }
.ds-legend-dot { width: 8px; height: 8px; border-radius: 1px; background: var(--ok); opacity: .5; }
.ds-legend-dot--soon { background: var(--ok); opacity: 1; }

/* --- расписание «по направлениям» --- */
.bydest {
    border: var(--rule) solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.bydest-row {
    display: grid;
    grid-template-columns: minmax(170px, 240px) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    padding: 12px 16px;
    border-bottom: var(--rule) solid var(--border);
}

.bydest-row:last-child { border-bottom: none; }
.bydest-row:hover { background: var(--surface-2); }

.bydest-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-wrap: wrap;
}

a.bydest-head:hover .bydest-name { color: var(--accent); text-decoration: underline; }
.bydest-name { font-weight: 550; font-size: .89rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bydest-times {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.bydest-time {
    font-family: var(--mono);
    font-size: .81rem;
    font-weight: 550;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    background: var(--surface-2);
    border: var(--rule) solid var(--border);
    color: var(--text-2);
    transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.bydest-time:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

.bydest-time--soon {
    background: color-mix(in srgb, var(--ok) 10%, transparent);
    border-color: color-mix(in srgb, var(--ok) 40%, transparent);
    color: var(--ok);
}

/* --- сводка «Куда можно уехать» --- */
.dest-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
    gap: 8px;
}

.dest-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: var(--rule) solid var(--border);
    transition: border-color var(--t-fast), background var(--t-fast);
    min-width: 0;
}

a.dest-card:hover { border-color: var(--text-3); background: var(--surface-3); }
.dest-dot { width: 8px; height: 8px; border-radius: 1px; flex-shrink: 0; }
.dest-body { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 1px; }
.dest-name { font-weight: 550; font-size: .87rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dest-meta { font-size: .71rem; color: var(--text-3); }

/* ============================================== 8c. ПОДЕЛИТЬСЯ === */

.share-panel {
    padding: 20px;
    border-radius: var(--radius);
    background: var(--surface);
    border: var(--rule) solid var(--border);
}

.share-panel--compact { padding: 16px 18px; }
.share-head { margin-bottom: 14px; }
.share-head h3 { font-size: 1rem; margin-bottom: 3px; }
.share-head p { font-size: .81rem; }

.share {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: var(--rule) solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-size: .85rem;
    font-weight: 550;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
    white-space: nowrap;
    min-height: 40px;
}

.share-btn:hover { background: var(--surface-2); }

.share-ico {
    display: grid;
    place-items: center;
    min-width: 24px;
    height: 22px;
    padding: 0 4px;
    border-radius: var(--radius-xs);
    font-family: var(--mono);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: #fff;
    background: var(--text-3);
}

.share-btn--vk .share-ico { background: #2b5f9e; }
.share-btn--ok .share-ico { background: #a8702a; }
.share-btn--tg .share-ico { background: #3f7d99; }
.share-btn--copy .share-ico { background: var(--surface-3); color: var(--text-2); font-size: .9rem; }

.share-btn--done { background: color-mix(in srgb, var(--ok) 10%, transparent); border-color: var(--ok); color: var(--ok); }
.share-btn--done .share-ico { background: var(--ok); }

.share-url {
    margin-top: 14px;
    padding: 9px 13px;
    border-radius: var(--radius-xs);
    background: var(--surface-2);
    border: var(--rule) solid var(--border);
    font-family: var(--mono);
    font-size: .76rem;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: all;
}

/* --- плавающая кнопка «поделиться» --- */
.share-fab {
    position: fixed;
    right: 18px;
    bottom: 70px;
    z-index: 90;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    border: var(--rule) solid var(--border-strong);
    background: var(--surface);
    font-size: 16px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--t), background var(--t-fast);
}

.share-fab.show { opacity: 1; pointer-events: auto; }
.share-fab:hover { background: var(--surface-2); }

/* --- всплывающая панель «поделиться» --- */
.share-popup {
    position: fixed;
    z-index: 150;
    width: min(380px, calc(100vw - 24px));
    padding: 16px;
    border-radius: var(--radius);
    background: var(--surface);
    border: var(--rule) solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    animation: fadeUp .18s var(--ease);
}

.share-popup-head {
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 11px;
    padding-bottom: 9px;
    border-bottom: var(--rule) solid var(--border);
}

.share-popup .share { gap: 6px; }
.share-popup .share-btn { padding: 7px 12px; font-size: .81rem; min-height: 38px; }
.share-popup .share-ico { min-width: 22px; height: 21px; font-size: .64rem; }
.share-popup .share-url { margin-top: 11px; }

/* ================================================ 9. СТРАНИЦЫ === */

.page-head { padding: 32px 0 8px; }

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .8rem;
    color: var(--text-3);
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.breadcrumbs a { color: var(--text-2); font-weight: 500; border-bottom: 1px solid var(--border-strong); }
.breadcrumbs a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.breadcrumbs span.sep { opacity: .5; }

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0;
    margin-top: 22px;
    border: var(--rule) solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.stat-box {
    padding: 15px 17px;
    background: var(--surface);
    border-right: var(--rule) solid var(--border);
}

.stat-box:last-child { border-right: none; }

.stat-box b { display: block; font-family: var(--mono); font-size: 1.32rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; }
.stat-box span { font-size: .74rem; color: var(--text-3); font-weight: 550; }

/* Табы и сегменты — элементы управления, поэтому с закруглением */
.tabs {
    display: flex;
    gap: 0;
    padding: 0;
    background: none;
    border-bottom: var(--rule) solid var(--border-strong);
    border-radius: 0;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 20px;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    padding: 10px 16px;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: none;
    border-radius: 0;
    font-size: .87rem;
    font-weight: 550;
    color: var(--text-2);
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--t-fast), border-color var(--t-fast);
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 650; border-bottom-color: var(--accent); background: none; box-shadow: none; }

/* --- переключатель «по часам / по направлениям» --- */
.segmented {
    display: inline-flex;
    gap: 0;
    padding: 0;
    border-radius: var(--radius-sm);
    border: var(--rule) solid var(--border-strong);
    background: var(--surface);
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.segmented::-webkit-scrollbar { display: none; }

.seg {
    padding: 7px 14px;
    border: none;
    border-right: var(--rule) solid var(--border);
    background: none;
    border-radius: 0;
    font-size: .83rem;
    font-weight: 550;
    color: var(--text-2);
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--t-fast), color var(--t-fast);
}

.seg:last-child { border-right: none; }
.seg:hover { color: var(--text); background: var(--surface-2); }
.seg.active { background: var(--text); color: var(--surface); font-weight: 600; }

.panel { display: none; }
.panel.active { display: block; }

@keyframes fadeUp {
    from { opacity: 0; }
}

.notice {
    padding: 14px 17px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: var(--rule) solid var(--border);
    border-left: 3px solid var(--accent);
    font-size: .86rem;
    color: var(--text-2);
    line-height: 1.65;
}

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: var(--gap);
    align-items: start;
}
.sticky-side { position: sticky; top: 76px; }

/* --- инфо-сетка станции --- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0;
    border: var(--rule) solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.info-cell {
    padding: 13px 15px;
    background: var(--surface-2);
    border-right: var(--rule) solid var(--border);
    border-bottom: var(--rule) solid var(--border);
}

.info-cell dt { font-size: .68rem; font-weight: 650; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); margin-bottom: 5px; }
.info-cell dd { font-weight: 600; font-size: .97rem; }
.info-cell dd small { font-weight: 450; color: var(--text-3); font-size: .77rem; }

/* --- список остановок маршрута --- */
.leg-list { display: flex; flex-direction: column; gap: 0; }

.leg {
    display: grid;
    grid-template-columns: 74px minmax(0, 1fr) 74px;
    gap: 12px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 0;
    border-bottom: var(--rule) solid var(--border);
    transition: background var(--t-fast);
}

.leg:last-child { border-bottom: none; }
.leg:hover { background: var(--surface-2); }
.leg-time { font-family: var(--mono); font-size: .83rem; color: var(--text-2); text-align: right; }
.leg-time.out { color: var(--text-3); }
.leg-name { font-weight: 500; font-size: .89rem; display: flex; align-items: center; gap: 8px; min-width: 0; }
.leg-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leg-km { font-family: var(--mono); font-size: .77rem; color: var(--text-3); text-align: right; }
.leg--wait { background: var(--accent-soft); }

/* --- сетка станций (каталог) --- */
.station-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(255px, 100%), 1fr));
    gap: 0;
    border: var(--rule) solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}

.station-tile {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 12px 14px;
    background: var(--surface);
    border-right: var(--rule) solid var(--border);
    border-bottom: var(--rule) solid var(--border);
    transition: background var(--t-fast);
    min-width: 0;
}

.station-tile:hover { background: var(--surface-2); }
.station-tile-dot { width: 8px; height: 8px; border-radius: 1px; flex-shrink: 0; }

.station-tile-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.station-tile-name {
    font-weight: 550;
    font-size: .89rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.station-tile-meta {
    font-family: var(--mono);
    font-size: .72rem;
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.station-tile-body .pill { align-self: flex-start; margin-top: 4px; }
.station-tile-num { font-family: var(--mono); font-size: .74rem; color: var(--text-3); font-weight: 500; flex-shrink: 0; }

/* --- справочный текст --- */
.prose {
    font-size: .92rem;
    color: var(--text-2);
    line-height: 1.8;
    max-width: 88ch;
}

.prose h2 { color: var(--text); margin-bottom: 12px; font-size: 1.16rem; }
.prose h3 { color: var(--text); margin: 22px 0 8px; font-size: 1rem; }
.prose p + p { margin-top: 11px; }
.prose a { color: var(--accent); font-weight: 550; border-bottom: 1px solid var(--accent-soft); }
.prose a:hover { border-bottom-color: var(--accent); }
.prose ul { margin: 11px 0 11px 20px; }
.prose li { margin-bottom: 5px; }
.prose strong { color: var(--text); font-weight: 650; }

/* --- перечень условий: термин сверху, значение под ним ---
   Применяется для справочных сведений, не относящихся к линии: так они
   читаются как таблица условий, а не как рекламный блок. */
.facts-list {
    margin: 8px 0 16px;
    border-top: var(--rule) solid var(--border);
}

.facts-list dt {
    padding: 11px 0 0;
    font-family: var(--font);
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text-3);
}

.facts-list dd {
    margin: 0;
    padding: 4px 0 11px;
    border-bottom: var(--rule) solid var(--border);
    font-size: .92rem;
    line-height: 1.6;
    color: var(--text);
}

/* Строка об исполнителе услуги: мельче основного текста */
.source-note {
    font-size: .82rem;
    color: var(--text-3);
    border-left: 3px solid var(--border-strong);
    padding-left: 13px;
}

/* --- рекламный блок ---
   Единственный блок на сайте, которому позволено выделяться: акцентная
   рамка сверху, лёгкая заливка и кнопка действия. Собран компактно:
   текст и кнопка слева, условия — таблицей справа, поэтому блок занимает
   немного места и не разрывает справочный материал. */
.card.offer {
    padding: 20px 24px 16px;
    border: var(--rule) solid var(--border-strong);
    border-top: 3px solid var(--accent);
    background: linear-gradient(180deg,
        color-mix(in srgb, var(--accent) 5%, var(--surface)) 0,
        var(--surface) 160px);
}

.offer-body {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    gap: 12px 38px;
    align-items: start;
}

.offer-head { min-width: 0; }

.offer-label {
    display: inline-block;
    margin-bottom: 10px;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    background: var(--surface-3);
    border: var(--rule) solid var(--border-strong);
    font-size: .64rem;
    font-weight: 650;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-2);
}

.offer-head h2 {
    font-size: 1.12rem;
    letter-spacing: -.005em;
}

.offer-lead {
    margin-top: 7px;
    font-size: .86rem;
    line-height: 1.6;
    color: var(--text-2);
    max-width: 46ch;
}

.offer-cta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.offer-cta .btn { padding: 10px 24px; font-size: .9rem; }

.offer-cta-note {
    font-size: .76rem;
    color: var(--text-3);
}

/* Условия: в блоке они идут строками «термин — значение» */
.card.offer .facts-list {
    margin: 0;
    border-top: none;
}

.card.offer .facts-list dt {
    padding: 7px 0 0;
    font-size: .67rem;
    letter-spacing: .07em;
}

.card.offer .facts-list dd {
    padding: 2px 0 7px;
    font-size: .87rem;
}

.card.offer .facts-list dd:last-child { border-bottom: none; }

.offer-note {
    margin-top: 14px;
    padding-top: 11px;
    border-top: var(--rule) solid var(--border);
    font-size: .75rem;
    line-height: 1.6;
    color: var(--text-3);
}

/* Кнопка внутри .prose: правила для ссылок в тексте (цвет акцента,
   подчёркивание, кегль) не должны на неё распространяться, иначе надпись
   сливается с фоном кнопки */
.prose .btn,
.prose .btn:hover {
    color: var(--text);
    border-bottom: none;
    font-size: .9rem;
    font-weight: 600;
}

.prose .btn--primary,
.prose .btn--primary:hover {
    color: #fff;
    font-size: .95rem;
}

/* --- страница ошибки --- */
.err-code {
    font-family: var(--mono);
    font-size: clamp(2.6rem, 9vw, 4.4rem);
    font-weight: 600;
    letter-spacing: -.03em;
    line-height: 1;
    color: var(--text);
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 3px solid var(--accent);
    display: inline-block;
}

/* --- подвал --- */
.footer {
    margin-top: 40px;
    padding: 34px 0;
    border-top: var(--rule) solid var(--border-strong);
    background: var(--surface);
}

.footer-in {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 var(--pad);
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) repeat(auto-fit, minmax(150px, 1fr));
    gap: 26px;
}

.footer h4 { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); margin-bottom: 11px; font-weight: 650; }
.footer ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.footer a { color: var(--text-2); font-size: .85rem; }
.footer a:hover { color: var(--accent); text-decoration: underline; }
.footer-note { margin-top: 24px; padding-top: 18px; border-top: var(--rule) solid var(--border); font-size: .77rem; color: var(--text-3); line-height: 1.7; }

/* ================================================ 10. АДАПТИВ === */

@media (max-width: 1080px) {
    .hero-in { grid-template-columns: 1fr; padding: 42px var(--pad) 46px; gap: 30px; }
    .two-col { grid-template-columns: 1fr; }
    .sticky-side { position: static; }
}

@media (max-width: 900px) {
    :root { --pad: 16px; --gap: 14px; }

    .nav { display: none; }
    .nav-burger { display: grid; }
    .nav-drawer.open { display: flex; }
    .logo-text span { display: none; }
    .clock-pill { display: none; }

    .board-head,
    .board-row { grid-template-columns: 62px minmax(0, 1fr) 74px; gap: 10px; padding: 10px 13px; }
    .board-num,
    .board-kind { display: none; }
    .board-time { font-size: .95rem; }

    .section { padding: 32px 0; }
    .hero-stat { padding: 13px 12px 13px 0; }
    .hero-stat b { font-size: 1.3rem; }

    .footer-in { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
    .train-head { grid-template-columns: 76px minmax(0, 1fr); gap: 12px; padding: 14px; }
    .train-side { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; text-align: left; padding-top: 9px; border-top: var(--rule) solid var(--border); }
    .stop-item { grid-template-columns: 52px 18px minmax(0, 1fr) 50px; gap: 8px; font-size: .81rem; }
    .stop-km { font-size: .67rem; }
}

@media (max-width: 600px) {
    :root { --pad: 13px; }

    /* Кнопки в один столбик: в строку они не помещаются и режутся краем */
    .hero-search .btn { width: 100%; }

    .preview-in { padding: 26px var(--pad) 28px; }
    .preview-head { margin-bottom: 16px; }
    .preview-grid { grid-template-columns: 1fr; }
    .branch-card { padding: 16px; gap: 10px; border-right: none; border-bottom: var(--rule) solid rgba(255, 255, 255, .16); }
    .branch-card:last-child { border-bottom: none; }

    .hero-in { padding: 30px var(--pad) 34px; }
    .hero-search { padding: 16px; }
    .search-grid { grid-template-columns: minmax(0, 1fr); }
    .swap-btn { width: 100%; height: 40px; }
    .swap-btn::after { content: ' поменять местами'; font-size: .77rem; font-weight: 550; color: var(--text-3); }

    .hero-stats { grid-template-columns: 1fr 1fr; }
    .hero-stat:nth-child(2n) { border-right: none; }
    .hero-stat { border-bottom: var(--rule) solid rgba(255, 255, 255, .14); }
    .hero-stat:nth-last-child(-n+2) { border-bottom: none; }

    .section { padding: 24px 0; }
    .section-head { margin-bottom: 14px; padding-bottom: 10px; }

    .board-head { display: none; }
    .board-row { grid-template-columns: 58px minmax(0, 1fr) 62px; padding: 10px 12px; }
    .board-time { font-size: .9rem; }

    .two-col { gap: 12px; }
    .stat-row { grid-template-columns: 1fr 1fr; }
    .stat-box { padding: 12px 13px; }
    .stat-box b { font-size: 1.1rem; }
    .stat-box:nth-child(2n) { border-right: none; }

    .station-grid { grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); }
    .station-tile { padding: 10px 11px; gap: 8px; }
    .station-tile-name { font-size: .8rem; }
    .station-tile-meta { font-size: .65rem; }
    .station-tile-num { display: none; }

    .next-card { padding: 16px; }
    .next-main { gap: 12px; }
    .next-count { margin-left: 0; padding-left: 0; border-left: none; text-align: left; padding-top: 10px; border-top: var(--rule) solid var(--border); width: 100%; }
    .next-count-num { font-size: 1.4rem; display: inline; margin-right: 6px; }

    .leg { grid-template-columns: 58px minmax(0, 1fr) 58px; gap: 8px; padding: 8px; }
    .leg-name { font-size: .81rem; }
    .leg-time { font-size: .75rem; }
    .leg-km { font-size: .69rem; }

    /* расписание на день на телефонах */
    .ds-row { grid-template-columns: 52px minmax(0, 1fr); }
    .ds-hour { padding: 10px 4px; }
    .ds-hour b { font-size: 1rem; }
    .ds-items { padding: 8px 9px; gap: 5px; }
    .ds-chip { padding: 5px 9px; font-size: .77rem; gap: 7px; }
    .ds-time { font-size: .82rem; }
    .ds-num { display: none; }
    .ds-legend { padding: 10px 12px; font-size: .71rem; }

    /* расписание по направлениям на телефонах */
    .bydest-row { grid-template-columns: 1fr; gap: 8px; padding: 11px 12px; }
    .bydest-time { font-size: .75rem; padding: 2px 7px; }
    .bydest-name { font-size: .83rem; }

    /* поделиться */
    .share-panel { padding: 16px; }
    .share { gap: 6px; }
    .share-btn { padding: 8px 12px; font-size: .79rem; gap: 7px; min-height: 38px; }
    .share-ico { min-width: 22px; height: 21px; font-size: .64rem; }
    .share-url { font-size: .71rem; }

    .dest-grid { grid-template-columns: 1fr; gap: 6px; }
    .dest-card { padding: 10px 12px; }

    .diagram-toolbar { gap: 6px; }
    .footer-in { gap: 18px; grid-template-columns: 1fr; }

    /* Рекламный блок на телефонах: одна колонка, кнопка во всю ширину */
    .card.offer { padding: 18px 16px 14px; }
    .offer-body { grid-template-columns: 1fr; gap: 14px; }
    .offer-lead { max-width: none; }
    .offer-cta { margin-top: 12px; }
    .offer-cta .btn { width: 100%; }
    .offer-cta-note { text-align: center; width: 100%; }
    .card.offer .facts-list dt { padding-top: 8px; }
    .card.offer .facts-list dd { padding-bottom: 8px; }
}

@media (max-width: 420px) {
    .station-grid { grid-template-columns: 1fr; }
    .stat-row { grid-template-columns: 1fr 1fr; }
    .hero-stat b { font-size: 1.15rem; }
    .board-row { grid-template-columns: 52px minmax(0, 1fr) 56px; }
    .to-top { right: 12px; bottom: 12px; width: 38px; height: 38px; }
}

/* --- печать --- */
@media print {
    .topbar,
    .to-top,
    .share-fab,
    .footer,
    .hero-search,
    .diagram-toolbar { display: none; }

    body { background: #fff; color: #000; background-image: none; }
    .card,
    .board,
    .train-card,
    .stat-row { box-shadow: none; border-color: #bbb; }
    .train-body { display: block !important; }
    .hero { background: none; color: #000; border-bottom: 2px solid #000; }
    .hero-lead,
    .hero-stat span { color: #333; }
    .preview-band { background: none; color: #000; }
    .branch-card { border-color: #bbb; color: #000; background: none; }
    .branch-card-route,
    .branch-card-route b,
    .branch-stat,
    .branch-card-go { color: #000; }
}

/* --- уважение к настройкам анимации --- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   ФИКС: страница станции на мобильных — на всю ширину
   ============================================================ */

@media (max-width: 900px) {
    /* Убираем двухколоночную сетку, всё в одну колонку */
    .two-col {
        display: block !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .two-col > * {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /* Снимаем sticky */
    .sticky-side {
        position: static !important;
        width: 100% !important;
    }

    /* Все секции — на всю ширину */
    .wrap,
    .section,
    .page-head {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 13px !important;
        padding-right: 13px !important;
        box-sizing: border-box !important;
    }

    /* Инфо-сетка станции — на всю ширину */
    .info-grid {
        grid-template-columns: 1fr 1fr !important;
        width: 100% !important;
    }

    /* Статистика — на всю ширину */
    .stat-row {
        grid-template-columns: 1fr 1fr !important;
        width: 100% !important;
    }

    /* Табы — на всю ширину, без обрезки */
    .tabs {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Board, train-card, day-schedule — на всю ширину */
    .board,
    .train-card,
    .day-schedule,
    .bydest,
    .station-grid,
    .dest-grid,
    .route-card,
    .next-card,
    .share-panel,
    .card,
    .prose {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Карточки маршрутов — в одну колонку */
    .route-card {
        padding: 14px 16px !important;
    }

    /* Диаграмма — на всю ширину, скролл внутри */
    .diagram-scroll,
    #diagramWrapper {
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 420px) {
    /* На очень узких — инфо-сетка в одну колонку */
    .info-grid,
    .stat-row {
        grid-template-columns: 1fr !important;
    }

    .info-cell {
        border-right: none !important;
    }

    .station-grid {
        grid-template-columns: 1fr !important;
    }
}