/* 226km.ru — общий стайлшит (редизайн 2026-08).
   Токены дизайн-системы: тёплый белый фон, Manrope + IBM Plex Mono,
   единственный акцент --accent. Градиентов на фонах нет; тени — только
   у оверлеев (модалки, тултипы). */

:root {
  --bg:            #fafaf9;
  --surface:       #ffffff;
  --surface-2:     #f5f5f4;
  --border:        #e7e5e4;
  --border-strong: #d6d3d1;
  --ink:           #1c1917;
  --ink-secondary: #57534e;
  --ink-muted:     #78716c;
  --accent:        #ea580c;
  --accent-text:   #c2410c;
  --accent-dark:   #9a3412;
  --ok:            #16a34a;
  --warn:          #f59e0b;
  --bad:           #dc2626;
  --run:  #c2410c; --run-bg:  #fff7ed;
  --bike: #15803d; --bike-bg: #f0fdf4;
  --swim: #1d4ed8; --swim-bg: #eff6ff;
  --r-card: 12px;
  --r-ctl: 8px;
  --r-chip: 99px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: var(--accent-text);
  text-decoration: none;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}
a:hover { color: var(--accent-dark); }

::selection { background: var(--accent); color: #fff; }

img { display: block; }

.container { max-width: 1200px; margin: 0 auto; }

.mono { font-family: 'IBM Plex Mono', monospace; }

.overline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3 { color: var(--ink); }

/* ---------- Иконки (Lucide-style, stroke наследует текст) ---------- */

.ico {
  width: 15px; height: 15px;
  vertical-align: -2px;
  display: inline-block;
  stroke: currentColor; fill: none;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.ico-sm { width: 13px; height: 13px; }

.dot-status {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  vertical-align: -2px;
}
.dot-ok   { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-bad  { background: var(--bad); }

/* ---------- Навигация ---------- */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 40px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 50;
}

.nav-logo { display: flex; align-items: center; }
.nav-logo-img { height: 30px; display: block; }

.nav-left { display: flex; align-items: center; gap: 28px; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
}

.nav-links a,
.nav-group > a,
.nav-grp {
  color: var(--ink-secondary);
  font-size: 14px;
  font-weight: 600;
  line-height: 64px;
  display: inline-block;
}
.nav-grp { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.nav-links a:hover, .nav-group > a:hover, .nav-grp:hover { color: var(--ink); }
.nav-links a.active, .nav-group > a.active, .nav-grp.active {
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* Дропдаун-группы */
.nav-group { position: relative; }
.nav-group > a::after, .nav-grp::after {
  content: ""; display: inline-block; margin-left: 6px;
  width: 6px; height: 6px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-3px);
}
.nav-drop {
  display: none;
  position: absolute; top: 100%; left: -14px;
  min-width: 176px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: 0 8px 24px rgba(28, 25, 23, .08);
  padding: 8px;
  z-index: 60;
}
.nav-group:hover .nav-drop, .nav-group:focus-within .nav-drop, .nav-group.open .nav-drop { display: block; }
.nav-grp[aria-expanded="true"]::after { transform: rotate(-135deg) translateY(-2px); }
.nav-drop a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--r-ctl);
  color: var(--ink-secondary);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}
.nav-drop a:hover { background: var(--surface-2); color: var(--ink); }
.nav-drop a.active { color: var(--ink); background: var(--surface-2); }

.nav-right { display: flex; align-items: center; gap: 12px; }

/* Мобильное меню: бургер + выезжающая панель (P1.11) */
.nav-burger { display: none; width: 44px; height: 44px; border: 0; background: none; padding: 10px; cursor: pointer; flex-direction: column; justify-content: center; gap: 5px; margin-left: -10px; }
.nav-burger span { display: block; height: 2px; background: var(--ink); border-radius: 2px; transition: transform 150ms ease, opacity 150ms ease; }
.nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav-drawer { display: none; }
@media (max-width: 760px) {
  .nav-burger { display: flex !important; }
  .nav-links { display: none !important; }
  .nav-drawer { display: none; position: fixed; left: 0; right: 0; top: 64px; bottom: 0; background: var(--surface); z-index: 49; overflow-y: auto; padding: 8px 16px 32px; }
  .nav-drawer:not([hidden]) { display: block; }
  .nav-drawer a { display: block; padding: 13px 8px; font-size: 17px; font-weight: 700; color: var(--ink); border-bottom: 1px solid var(--border); min-height: 48px; }
  .nav-drawer a.active { color: var(--accent-text); }
  .nav-drawer-more { font-family: 'IBM Plex Mono', monospace; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-muted); padding: 18px 8px 6px; }
  .nav-drawer-more ~ a { font-size: 15px; font-weight: 600; min-height: 44px; padding: 11px 8px; }
  body.nav-open { overflow: hidden; }
}

.chip {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--ink-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-chip);
  padding: 3px 12px;
  line-height: 1.5;
  white-space: nowrap;
}

.btn-cabinet {
  background: var(--ink);
  color: var(--bg) !important;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: var(--r-ctl);
  line-height: 1.2;
}
.btn-cabinet:hover { background: var(--accent); color: #fff !important; }

#nav-av {
  display: none; width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; border: 1.5px solid var(--border);
}
#nav-av.on { display: block; }
.nav-av-link { line-height: 1; }
.nav-gear { color: var(--ink-secondary); line-height: 1; display: inline-flex; align-items: center; }
.nav-gear:hover { color: var(--ink); }

/* ---------- Кнопки ---------- */

.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 26px;
  border-radius: var(--r-ctl);
  border: none;
}
.btn-primary:hover { background: var(--accent-dark); color: #fff; }

.btn-secondary {
  display: inline-block;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  padding: 13px 24px;
  border-radius: var(--r-ctl);
  border: 1.5px solid var(--border-strong);
}
.btn-secondary:hover { border-color: var(--ink); color: var(--ink); }

/* ---------- Главная: hero ---------- */

.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 88px 40px 64px;
}
.hero .overline { margin-bottom: 24px; }
.hero h1 {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: clamp(40px, 5vw, 56px);
  line-height: 1.06;
  letter-spacing: -.02em;
  margin: 0 0 24px;
  max-width: 840px;
}
.hero p {
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink-secondary);
  max-width: 680px;
  margin: 0 0 16px;
}
.hero-actions { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

/* ---------- Карточки-разделы ---------- */

.cards {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 40px 64px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card:hover { border-color: var(--border-strong); color: var(--ink); }
.card-media { height: 220px; overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 24px 26px 0; }
.card-body .overline { font-size: 12px; margin-bottom: 12px; }
.card-body h3 { font-size: 16px; font-weight: 700; margin: 0 0 8px; }
.card-body p { font-size: 13px; color: var(--ink-secondary); margin: 0 0 24px; }

/* ---------- Внутренние страницы ---------- */

.page-header { max-width: 1200px; margin: 0 auto; padding: 56px 40px 44px; }
.page-header .overline { margin-bottom: 18px; }
.page-header h1 {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: clamp(34px, 4vw, 44px);
  line-height: 1.08;
  letter-spacing: -.02em;
  margin: 0 0 16px;
}
.page-header p {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-secondary);
  max-width: 640px;
  margin: 0;
}

.page-footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 40px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.page-footer, .page-footer .copyright { font-size: 13px; color: var(--ink-muted); }
.page-footer a { color: var(--ink-muted); }
.page-footer a:hover { color: var(--ink); }
.page-footer-next { font-weight: 600; }

@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr; }
  .nav { padding: 0 16px; gap: 10px; }
  .page-header, .hero, .cards, .page-footer { padding-left: 16px; padding-right: 16px; }
}

/* мобильная шапка: бургер вместо горизонтального свайпа */
@media (max-width: 760px) {
  .nav-left { gap: 10px; min-width: 0; }
  .nav-right .chip, .btn-cabinet { display: none; }
}
/* доступность: видимый фокус и skip-link (P1.15) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Широкие таблицы на телефоне: контейнер прокручивается, подсказка сверху (P1.14) */
.cal-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 760px) {
  .cal-scroll::before { content: "← таблица листается в сторону →"; display: block; font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-muted); margin-bottom: 6px; }
}

/* «Друзья» — только для вошедших (гостю там всё равно попросят войти) */
body:not(.authed) .nav-authed { display: none !important; }
/* парное правило: пункт для гостя исчезает после входа — им заменяется «Кабинет»
   в выдвижном меню, иначе на узком экране гостю негде войти (кнопка шапки там скрыта) */
body.authed .nav-guest { display: none !important; }

/* Нижняя панель разделов: постоянный доступ к основному на телефоне (этап 1 мобильной перестройки) */
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar:not([hidden]) {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: var(--surface); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 56px; padding: 7px 2px 8px; font-size: 11px; font-weight: 600; color: var(--ink-muted);
    text-decoration: none;
  }
  .tabbar a.on { color: var(--accent-text); }
  .tabbar .tb-i { font-size: 17px; line-height: 1; }
  body.has-tabbar { padding-bottom: 72px; }
  /* одна навигация: у вошедшего бургер не нужен, его место заняла панель */
  body.authed .nav-burger, body.authed #nav-drawer { display: none !important; }
  /* вкладки кабинета больше не разъезжаются на три ряда */
  .app-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .app-nav::-webkit-scrollbar { display: none; }
  .app-nav a { white-space: nowrap; flex: none; }
}

@media (max-width: 760px) {
  /* у вошедшего раздел уже назван в нижней панели — надстрочник и подпись только съедали экран */
  body.authed.has-tabbar .page-header .overline,
  body.authed.has-tabbar .page-header p { display: none; }
  body.authed.has-tabbar .page-header { padding-top: 18px; padding-bottom: 8px; }
}

/* Подменю раздела кабинета (те же стили и для страниц, отрендеренных сервером) */
.app-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 24px 0 8px; }
.app-nav a { font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: 99px; border: 1px solid #e7e5e4; color: #57534e; text-decoration: none; }
.app-nav a.on { background: #1c1917; color: #fafaf9; border-color: #1c1917; }
@media (max-width: 760px) {
  .app-nav { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-top: 16px; padding-bottom: 2px; }
  .app-nav::-webkit-scrollbar { display: none; }
  .app-nav a { flex: none; white-space: nowrap; }
}

/* Подменю раздела на витринных страницах показываем только вошедшему */
.app-nav.only-authed { display: none; }
body.authed .app-nav.only-authed { display: flex; }
