/* ============================================================
   Коста-Рика 2026 — личный путеводитель
   Палитра: джунгли (teal) + песок (sand) + закат (coral)
   ============================================================ */

:root {
  color-scheme: light dark;

  /* === Палитра (темы) === */
  --jungle-900: #134e4a;
  --jungle-800: #115e59;
  --jungle-700: #0f766e;
  --jungle-600: #0d9488;
  --jungle-500: #14b8a6;
  --sand-50: #fdfbf7;
  --sand-100: #f7f2e8;
  --sand-200: #efe7d8;
  --coral: #f97316;
  --coral-soft: #fff1e6;
  --ink: #1c1917;
  --ink-soft: #44403c;
  --ink-mute: #78716c;
  --line: #e7e0d3;
  --ok: #16a34a;
  --warn: #dc2626;
  --card: #ffffff;
  --sticky-bg: rgba(253, 251, 247, .92);

  /* === Дизайн-токены (Фаза 2) === */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, .05);
  --shadow: 0 1px 2px rgba(28, 25, 23, .05), 0 8px 24px -12px rgba(28, 25, 23, .18);
  --shadow-lg: 0 4px 12px rgba(28, 25, 23, .12);
  --maxw: 1240px;
  --maxw-narrow: 720px;
  --topbar-h: 56px;
  --bottombar-h: 64px;
  --touch-target: 48px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16.5px;
  line-height: 1.65;
  color: var(--ink);
  background:
    radial-gradient(1200px 400px at 15% -100px, #eafaf6 0%, transparent 60%),
    var(--sand-50);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--jungle-700); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--jungle-900); }

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

/* ---------------- Topbar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(253, 251, 247, .92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  flex: 0 0 auto;
}

.brand-flag { font-size: 26px; line-height: 1; }

.brand-text {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .2px;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text small {
  font-weight: 500;
  font-size: 11.5px;
  color: var(--ink-mute);
}

.nav {
  display: flex;
  gap: 2px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background .15s, color .15s;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
}

.nav a:hover { background: var(--sand-200); color: var(--ink); }

.nav a.active {
  background: var(--jungle-700);
  color: #fff;
}

.nav-lock::before { content: "🔒 "; font-size: 11px; }

.burger {
  display: none;
  margin-left: auto;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
}

.burger span {
  display: block;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  margin: 4px 0;
}

/* ---------------- Layout ---------------- */

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 20px 60px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 34px;
}

.page:has(.toc) { grid-template-columns: minmax(0, 1fr) 268px; }

.prose { min-width: 0; }

/* ---------------- TOC ---------------- */

.toc { position: relative; }

.toc-box {
  position: sticky;
  top: 84px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 110px);
  overflow: auto;
  font-size: 13.5px;
}

.toc-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-mute);
  font-weight: 700;
  margin-bottom: 8px;
}

.toc nav ul, .toc > .toc-box > ul { list-style: none; margin: 0; padding: 0; }
.toc nav ul ul, .toc > .toc-box > ul ul { padding-left: 12px; border-left: 1px solid var(--line); margin-top: 2px; list-style: none; }

.toc nav a, .toc ul a {
  display: block;
  padding: 4px 6px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--ink-soft);
  line-height: 1.35;
}

.toc nav a:hover { background: var(--sand-100); color: var(--jungle-800); }

/* ---------------- Prose ---------------- */

.prose h1 {
  font-size: clamp(26px, 3.4vw, 36px);
  line-height: 1.2;
  margin: 4px 0 6px;
  letter-spacing: -.02em;
}

.prose h1 + p.lead {
  font-size: 17px;
  color: var(--ink-mute);
  margin-top: 0;
}

.prose h2 {
  font-size: clamp(20px, 2.4vw, 25px);
  margin: 42px 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  letter-spacing: -.01em;
  scroll-margin-top: 90px;
}

.prose h2:first-child { border-top: 0; padding-top: 0; }

.prose h3 {
  font-size: 18px;
  margin: 26px 0 8px;
  color: var(--jungle-900);
  scroll-margin-top: 90px;
}

.prose h4 { font-size: 16px; margin: 20px 0 6px; }

.prose p { margin: 10px 0; }

.prose ul, .prose ol { padding-left: 22px; margin: 10px 0; }
.prose li { margin: 4px 0; }

.prose strong { color: var(--ink); }

.prose hr { border: 0; border-top: 1px dashed var(--line); margin: 30px 0; }

.prose code {
  background: var(--sand-100);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: .9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.prose img { max-width: 100%; height: auto; border-radius: var(--radius); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.table-wrap table { margin: 0; min-width: 560px; }

.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14.5px;
  line-height: 1.5;
}

.prose > table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.prose thead th {
  background: var(--jungle-800);
  color: #fff;
  text-align: left;
  font-weight: 600;
  padding: 9px 12px;
  white-space: nowrap;
}

.prose tbody td, .prose tbody th {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
}

.prose tbody tr:nth-child(even) { background: var(--sand-100); }
.prose tbody tr:hover { background: var(--coral-soft); }

/* Blockquote -> callout */
.prose blockquote {
  margin: 16px 0;
  padding: 12px 16px;
  background: var(--coral-soft);
  border-left: 4px solid var(--coral);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink-soft);
}

.prose blockquote p:first-child { margin-top: 0; }
.prose blockquote p:last-child { margin-bottom: 0; }

.prose blockquote blockquote { background: var(--card); }

/* Task lists */
.prose li.task-list-item,
.prose input[type="checkbox"] { list-style: none; }

.prose .task-list-item input {
  accent-color: var(--jungle-700);
  width: 16px;
  height: 16px;
  margin-right: 8px;
  vertical-align: -2px;
  cursor: pointer;
}

.prose .task-list-item input:checked + span {
  color: var(--ink-mute);
  text-decoration: line-through;
}

/* Кнопка «сбросить отметки» под списками */
.checklist-tools {
  margin: -4px 0 18px;
  font-size: 13px;
}

.checklist-tools button {
  font: inherit;
  font-size: 12.5px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 3px 11px;
  cursor: pointer;
  min-height: 32px;
}

.checklist-tools button:hover { border-color: var(--jungle-600); color: var(--jungle-800); }

/* Progress bar for checklists.
   Фон — отдельная переменная, а не литерал: полоска липкая и полупрозрачная,
   в тёмной схеме светлый фон делал её собственный текст нечитаемым. */
.check-progress {
  position: sticky;
  top: 62px;
  z-index: 5;
  background: var(--sticky-bg);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-progress .bar {
  flex: 1;
  height: 7px;
  background: var(--sand-200);
  border-radius: 999px;
  overflow: hidden;
}

.check-progress .bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--jungle-600), var(--jungle-500));
  transition: width .25s;
}

/* ---------------- Home: hero ---------------- */

.hero {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--jungle-900);
  color: #fff;
  margin-bottom: 26px;
}

.hero img {
  display: block;
  width: 100%;
  height: clamp(240px, 38vw, 420px);
  object-fit: cover;
  object-position: center 30%;
  opacity: .72;
}

.hero-body {
  position: absolute;
  inset: auto 0 0 0;
  padding: clamp(18px, 4vw, 34px);
  background: linear-gradient(to top, rgba(10, 40, 38, .92), rgba(10, 40, 38, .25) 70%, transparent);
}

/* Step hero: без картинки, H1 видимый (D2) */
.step-hero {
  background: linear-gradient(135deg, var(--jungle-800), var(--jungle-700));
  padding: clamp(24px, 5vw, 40px);
  margin-bottom: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.step-hero .hero-body {
  position: static;
  background: none;
  padding: 0;
}

.step-hero .hero-body h1 {
  color: #fff;
  font-size: clamp(22px, 4vw, 32px);
  margin-bottom: 8px;
}

.step-hero .hero-body p {
  color: rgba(255, 255, 255, .9);
  font-size: clamp(14px, 1.8vw, 16px);
}

.hero:not(:has(img)) {
  min-height: 0;
  background: linear-gradient(135deg, var(--jungle-800), var(--jungle-700));
  padding: clamp(24px, 5vw, 40px);
}

.hero:not(:has(img)) .hero-body {
  position: static;
  padding: 0;
  background: none;
}

.step-kicker {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255, 255, 255, .7);
  margin-bottom: 8px;
}

.hero-body h1 {
  margin: 0 0 6px;
  color: #fff;
  font-size: clamp(26px, 4.4vw, 44px);
  text-shadow: 0 2px 16px rgba(0, 0, 0, .4);
}

.hero-body p { margin: 0; font-size: clamp(14px, 1.7vw, 17px); opacity: .95; }

.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.hero-tags span {
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .9);
  color: var(--jungle-900);
  font-weight: 650;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 13px;
  backdrop-filter: blur(4px);
}

/* Countdown */
.countdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 26px;
}

.countdown .cell {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
  box-shadow: var(--shadow);
}

.countdown .num {
  font-size: clamp(22px, 3.4vw, 32px);
  font-weight: 800;
  color: var(--jungle-800);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.countdown .lbl { font-size: 11.5px; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .06em; }

/* Home checklist */
.todo-list { list-style: none; padding: 0; margin: 12px 0 22px; }

.todo-list li { margin: 0; }

.todo-list label {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  margin: 8px 0;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: border-color .12s, background .12s;
  font-size: 15.5px;
  line-height: 1.5;
}

.todo-list label:hover { border-color: var(--jungle-500); }

.todo-list input {
  accent-color: var(--jungle-700);
  width: 17px;
  height: 17px;
  margin-top: 3px;
  flex: 0 0 auto;
  cursor: pointer;
}

.todo-list input:checked ~ span { color: var(--ink-mute); text-decoration: line-through; }
.todo-list input:checked { opacity: .8; }
.todo-list li:has(input:checked) label { background: var(--sand-100); }

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin: 18px 0 26px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 17px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  display: block;
  transition: transform .12s, box-shadow .12s, border-color .12s;
}

a.card:hover { transform: translateY(-2px); border-color: var(--jungle-500); box-shadow: 0 10px 30px -14px rgba(15, 118, 110, .5); }

.card .ico { font-size: 24px; }
.card h3 { margin: 8px 0 4px; font-size: 16.5px; color: var(--jungle-900); }
.card p { margin: 0; font-size: 14px; color: var(--ink-mute); line-height: 1.5; }

.card.accent { background: linear-gradient(160deg, #0f766e, #115e59); border-color: transparent; color: #fff; }
.card.accent h3, .card.accent p { color: #fff; }
.card.accent p { opacity: .85; }

/* Quick info strip */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 16px 0 26px;
}

.fact {
  background: var(--sand-100);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px 13px;
}

.fact .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-mute); }
.fact .v { font-weight: 700; font-size: 15.5px; color: var(--jungle-900); }

/* Timeline (home) */
.timeline { list-style: none; margin: 18px 0 26px; padding: 0 0 0 26px; border-left: 2px solid var(--sand-200); }

.timeline li { position: relative; margin: 0 0 16px; padding-left: 8px; }

.timeline li::before {
  content: "";
  position: absolute;
  left: -33px;
  top: 7px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--jungle-600);
  border: 3px solid var(--sand-50);
  box-shadow: 0 0 0 1.5px var(--jungle-600);
}

.timeline li.hot::before { background: var(--coral); box-shadow: 0 0 0 1.5px var(--coral); }

.timeline .date { font-weight: 700; color: var(--jungle-900); font-variant-numeric: tabular-nums; }
.timeline .what { display: block; color: var(--ink-soft); font-size: 15px; }

/* Alert / note boxes (для src-страниц) */
.note {
  border-radius: var(--radius);
  padding: 14px 17px;
  margin: 16px 0;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.note h4 { margin: 0 0 6px; font-size: 15px; }
.note p:last-child { margin-bottom: 0; }

.note.warn { background: #fff7ed; border-color: #fed7aa; }
.note.ok { background: #f0fdf4; border-color: #bbf7d0; }
.note.info { background: #eff6ff; border-color: #bfdbfe; }
.note.danger { background: #fef2f2; border-color: #fecaca; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 16px 0; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }

.chip {
  font-size: 13px;
  font-weight: 600;
  background: var(--sand-100);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 4px 11px;
  border-radius: 999px;
}

.chip.hot { background: var(--coral-soft); border-color: #fed7aa; color: #9a3412; }
.chip.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

/* ---------------- Gallery / maps ---------------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin: 18px 0 26px;
}

.gallery figure { margin: 0; }

.gallery img {
  width: 100%;
  height: 210px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
}

.gallery figcaption { font-size: 12.5px; color: var(--ink-mute); margin-top: 6px; line-height: 1.45; }

.map-frame {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  box-shadow: var(--shadow);
  margin: 16px 0;
}

.map-frame img, .map-frame svg { width: 100%; height: auto; display: block; border-radius: 8px; }

.map-frame .cap { font-size: 13px; color: var(--ink-mute); padding: 8px 4px 2px; }

/* ---------------- Documents (lock) ---------------- */

.lock-screen {
  max-width: 560px;
  margin: 30px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(22px, 4vw, 36px);
  box-shadow: var(--shadow);
  text-align: center;
}

.lock-screen .lock-ico { font-size: 44px; }
.lock-screen h1 { font-size: 24px; margin: 10px 0 6px; }
.lock-screen p { color: var(--ink-mute); font-size: 15px; margin-top: 0; }

.lock-form { display: flex; gap: 8px; margin-top: 18px; }

.lock-form input {
  flex: 1;
  font: inherit;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--sand-50);
}

.lock-form input:focus { outline: 2px solid var(--jungle-500); outline-offset: 1px; }

.lock-form button {
  font: inherit;
  font-weight: 700;
  padding: 11px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--jungle-700);
  color: #fff;
  cursor: pointer;
}

.lock-form button:hover { background: var(--jungle-800); }

.lock-err { color: var(--warn); font-size: 14px; min-height: 20px; margin-top: 10px; }
.lock-hint { font-size: 13px; color: var(--ink-mute); margin-top: 14px; }

.doc-list { display: none; }
.doc-list.show { display: block; animation: fade .3s ease; }

.doc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.doc-row .ico { font-size: 24px; }
.doc-row .meta { flex: 1; min-width: 0; }
.doc-row .name { font-weight: 700; font-size: 15px; word-break: break-all; }
.doc-row .sub { font-size: 13px; color: var(--ink-mute); }

.doc-row button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--jungle-600);
  background: var(--card);
  color: var(--jungle-800);
  padding: 8px 15px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.doc-row button:hover { background: var(--jungle-700); color: #fff; }
.doc-row button[disabled] { opacity: .55; cursor: progress; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- Footer ---------------- */

.footer {
  border-top: 1px solid var(--line);
  background: var(--sand-100);
  padding: 26px 20px;
  font-size: 14px;
  color: var(--ink-soft);
}

.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: space-between;
}

.footer-links { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.footer-links a { color: var(--ink-soft); text-decoration: none; }
.footer-links a:hover { color: var(--jungle-800); text-decoration: underline; }

/* ---------------- To top ---------------- */

.totop {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--jungle-700);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: .2s;
  box-shadow: 0 8px 24px -8px rgba(15, 118, 110, .7);
  z-index: 40;
  border: 0;
  padding: 0;
}

.totop.show { opacity: 1; pointer-events: auto; transform: none; }

/* ---------------- Toast ---------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translate(-50%, 8px);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 60;
  max-width: calc(100vw - 32px);
  text-align: center;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- Secret slots (парольные фрагменты) ---------------- */

.secret-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.secret-form input {
  font: inherit;
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
}

.secret-form button {
  font: inherit;
  font-size: 14px;
  padding: 6px 16px;
  border: 1px solid var(--jungle-700);
  background: var(--jungle-700);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
}

.secret-err { color: #b91c1c; font-size: 13.5px; }

.secret-slot.unlocked { background: var(--card); border-color: var(--jungle-500); }

.secret-body { overflow-x: auto; }

.secret-hide {
  font: inherit;
  font-size: 12.5px;
  margin-top: 10px;
  padding: 3px 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-mute);
  border-radius: 999px;
  cursor: pointer;
}


/* ---------------- Responsive ---------------- */

@media (max-width: 1080px) {
  .page:has(.toc) { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 880px) {
  .burger { display: block; }

  .nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--sand-50);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 10px 16px 16px;
    gap: 4px;
    box-shadow: var(--shadow);
  }

  .nav.open { display: flex; }
  .nav a { padding: 10px 14px; font-size: 15px; border-radius: 10px; }
  .topbar-inner { position: relative; }
  .countdown { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  body { font-size: 16px; }
  .page { padding: 18px 14px calc(var(--bottombar-h) + 28px); }
  .prose table { font-size: 13.5px; }
  .lock-form { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* === Редактируемые списки (assets/js/editable-list.js) === */
.editable-list,
.editable-summary { position: relative; }

.list-progress .prog-weight {
  font-size: 12.5px;
  color: var(--ink-mute);
  white-space: nowrap;
}
.list-progress .prog-weight.over { color: var(--warn); font-weight: 600; }
/* Полоску прогресса рисуют два движка: editable-list.js (.list-progress)
   и main.js (просто .check-progress) — селектор общий, иначе кнопка
   второго остаётся без стилей и берёт системные цвета. */
.check-progress .prog-reset {
  font: inherit;
  font-size: 12.5px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 2px 10px;
  cursor: pointer;
}
.check-progress .prog-reset:hover { border-color: var(--jungle-500); color: var(--jungle-700); }

.list-toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.list-toolbar button {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 4px 13px;
  cursor: pointer;
  min-height: 36px;
}
.list-toolbar button:hover { border-color: var(--jungle-500); color: var(--jungle-700); }
.list-toolbar button.on {
  background: var(--jungle-700);
  border-color: var(--jungle-700);
  color: #fff;
}
.list-toolbar .import-file { display: none; }

.li-ctl {
  display: inline-flex;
  gap: 4px;
  margin-left: auto;
  padding-left: 8px;
  flex: 0 0 auto;
}
.li-ctl button,
.h-ctl button {
  font: inherit;
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-mute);
  border-radius: 6px;
  padding: 3px 7px;
  cursor: pointer;
  min-width: 32px;
  min-height: 32px;
}
.li-ctl button:hover,
.h-ctl button:hover { border-color: var(--jungle-500); color: var(--jungle-700); }

.h-ctl {
  display: inline-flex;
  gap: 4px;
  margin-left: 10px;
  vertical-align: middle;
}
.h-text { display: inline; }

.li-edit,
.h-edit {
  font: inherit;
  border: 1px solid var(--jungle-500);
  border-radius: 8px;
  padding: 4px 8px;
  background: var(--card);
  color: var(--ink);
}
.li-edit { flex: 1; min-width: 180px; }

.add-row,
.add-section { display: flex; gap: 8px; margin: 6px 0 14px; }
.add-row input,
.add-section input {
  font: inherit;
  flex: 1;
  max-width: 420px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 7px 11px;
  background: var(--card);
}
.add-row input:focus,
.add-section input:focus { outline: none; border-color: var(--jungle-500); border-style: solid; }
.add-row button,
.add-section button {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 10px;
  padding: 7px 13px;
  cursor: pointer;
}
.add-row button:hover,
.add-section button:hover { border-color: var(--jungle-500); color: var(--jungle-700); }

.li-weight {
  font-size: 12.5px;
  color: var(--ink-mute);
  white-space: nowrap;
  padding-left: 6px;
}

.todo-list .li-text { flex: 1; min-width: 0; }
.editable-summary h3 { font-size: 17px; margin: 20px 0 4px; }
.editable-summary .summary-todo { margin-top: 6px; }

/* === Погода (assets/js/weather.js) === */
.weather {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin: 16px 0 22px;
}
.w-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-mute);
  margin-bottom: 8px;
}
.w-place { font-weight: 600; color: var(--ink-soft); font-size: 13.5px; }
.w-now { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.w-icon { font-size: 44px; line-height: 1; }
.w-main { min-width: 110px; }
.w-temp { font-size: 34px; font-weight: 700; line-height: 1.05; }
.w-feel { font-size: 13px; color: var(--ink-mute); }
.w-facts { display: flex; flex-direction: column; gap: 2px; font-size: 14px; color: var(--ink-soft); }
.w-days {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.w-day {
  background: var(--sand-50);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 13px;
  text-align: center;
}
.w-day b { color: var(--ink-soft); font-size: 12.5px; }
.w-day i { font-style: normal; font-size: 18px; }
.w-day .w-max { font-weight: 700; }
.w-day .w-min, .w-day .w-pop { color: var(--ink-mute); font-size: 12px; }
.w-day.today { border-color: var(--jungle-500); background: #f0fdfa; }
.w-note { margin-top: 10px; font-size: 13px; color: var(--ink-mute); }
.w-norms .w-temp { font-size: 26px; }

/* === Календарь (.ics) === */
.ics-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 4px 0 22px;
}
.btn-ics {
  display: inline-block;
  background: var(--jungle-700);
  color: #fff;
  font-weight: 600;
  font-size: 14.5px;
  padding: 9px 17px;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.btn-ics:hover { background: var(--jungle-800); }
.ics-hint { font-size: 13px; color: var(--ink-mute); }

/* === Офлайн-карта (assets/js/maps.js) === */
.map-box {
  height: 420px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin: 12px 0 6px;
  z-index: 0;
}
.map-box .leaflet-container {
  font: inherit;
  background: #e8f0ec;
}
.map-fallback {
  padding: 24px 16px;
  color: var(--ink-mute);
  font-size: 14.5px;
  text-align: center;
}
.map-box .leaflet-control-attribution {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.85);
}

/* ---------------- Бюджет: трекер трат ---------------- */

.fact .fact-sub { font-weight: 400; font-size: 12.5px; color: var(--ink-mute); }

.tx-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px; }
.tx-form input,
.tx-form select {
  font: inherit;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 7px 11px;
  background: var(--card);
}
.tx-form .tx-date { max-width: 165px; }
.tx-form .tx-note { flex: 1; min-width: 180px; }
.tx-form .tx-cat { max-width: 150px; }
.tx-form .tx-amount { max-width: 130px; }
.tx-form input:focus,
.tx-form select:focus { outline: none; border-color: var(--jungle-500); border-style: solid; }
.tx-form button,
.tx-tools button,
.jr-tools button {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 10px;
  padding: 7px 13px;
  cursor: pointer;
}
.tx-form button:hover,
.tx-tools button:hover,
.jr-tools button:hover { border-color: var(--jungle-500); color: var(--jungle-700); }

.tx-stats { margin: 0 0 14px; }
.tx-total { font-size: 16px; color: var(--ink-soft); }
.tx-total b { font-size: 24px; color: var(--jungle-900); margin-left: 4px; }
.tx-total span { font-size: 13px; color: var(--ink-mute); }
.tx-cats { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tx-cat-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13.5px;
}
.tx-cat-chip .c { color: var(--ink-mute); }
.tx-cat-chip b { color: var(--jungle-900); }
.tx-cat-chip .plan { font-style: normal; font-size: 11.5px; color: var(--ink-mute); }

.tx-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.tx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14.5px;
}
.tx-when { color: var(--ink-mute); font-size: 13px; white-space: nowrap; }
.tx-what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tx-kind {
  font-size: 12px;
  color: var(--jungle-800);
  background: #f0fdfa;
  border: 1px solid #ccfbf1;
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}
.tx-sum { font-weight: 700; color: var(--jungle-900); white-space: nowrap; }
.tx-del,
.jr-edit,
.jr-del {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--ink-mute);
  font-size: 15px;
  padding: 2px 6px;
  border-radius: 8px;
}
.tx-del:hover,
.jr-edit:hover,
.jr-del:hover { color: var(--warn); background: #fef2f2; }
.tx-empty,
.jr-empty {
  color: var(--ink-mute);
  font-size: 14.5px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
}
.tx-tools,
.jr-tools { margin-top: 4px; }
.tx-form .tx-cur { max-width: 115px; }
.tx-balances {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 10px 12px;
  background: var(--sand-100);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.tx-bal-lbl { font-size: 13.5px; color: var(--ink-soft); font-weight: 600; }
.tx-bal {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  color: var(--jungle-900);
  font-size: 14px;
}
.tx-bal input {
  font: inherit;
  width: 96px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.tx-bal input:focus { outline: none; border-color: var(--jungle-500); }
.tx-bal-hint { font-size: 12.5px; color: var(--ink-mute); margin-left: auto; }
.tx-cur-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.tx-cur-card {
  position: relative;
  padding: 10px 12px 10px 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.tx-cur-sym {
  position: absolute;
  left: 11px;
  top: 11px;
  font-size: 16px;
  font-weight: 700;
  color: var(--jungle-700);
}
.tx-cur-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.7;
}
.tx-cur-line b { color: var(--jungle-900); font-variant-numeric: tabular-nums; }
.tx-cur-line b.muted { color: var(--ink-mute); font-weight: 500; }
.tx-cur-line b.neg { color: var(--warn); }

/* ---------------- Журнал поездки ---------------- */

.jr-form { margin: 8px 0 18px; }
.jr-form-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.jr-form input,
.jr-form textarea {
  font: inherit;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 7px 11px;
  background: var(--card);
  width: 100%;
}
.jr-form .jr-date { max-width: 165px; }
.jr-form .jr-title { flex: 1; min-width: 180px; width: auto; }
.jr-form textarea { resize: vertical; line-height: 1.5; }
.jr-form input:focus,
.jr-form textarea:focus { outline: none; border-color: var(--jungle-500); border-style: solid; }
.jr-form-actions { display: flex; gap: 8px; margin-top: 8px; }
.jr-form-actions button {
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 10px;
  padding: 7px 13px;
  cursor: pointer;
}
.jr-form-actions .jr-submit { background: var(--jungle-800); border-color: var(--jungle-800); color: #fff; }
.jr-form-actions .jr-submit:hover { background: var(--jungle-900); color: #fff; }
.jr-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.jr-entry {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.jr-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.jr-when {
  font-size: 12.5px;
  color: #fff;
  background: var(--jungle-700);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
.jr-h { font-size: 16px; margin: 0; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.jr-btns { margin-left: auto; display: flex; gap: 2px; }
.jr-body { font-size: 15px; color: var(--ink-soft); overflow-wrap: anywhere; }

/* ---------------- Пошаговый маршрут ---------------- */

.now-card {
  display: block;
  margin: 0 0 22px;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--jungle-800), var(--jungle-600));
  color: #fff;
  box-shadow: var(--shadow);
  text-decoration: none;
}
.now-card:hover { color: #fff; filter: brightness(1.05); }
.now-kicker {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .85;
}
.now-title { display: block; font-size: 21px; font-weight: 700; margin-top: 4px; }
.now-summary { display: block; font-size: 14.5px; opacity: .95; margin-top: 4px; }
.now-when { display: block; font-size: 13px; opacity: .8; margin-top: 8px; }

.steps-index { display: flex; flex-direction: column; gap: 10px; }
.step-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
}
.step-card:hover { border-color: var(--jungle-500); color: var(--ink); }
.step-card.current {
  border-color: var(--jungle-600);
  background: linear-gradient(135deg, #f0fdfa, #fff);
  outline: 2px solid var(--jungle-500);
}
.step-badge {
  position: absolute;
  top: -10px;
  right: 12px;
  background: var(--jungle-700);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
}
.step-num {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sand-100);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-card.current .step-num { background: var(--jungle-700); color: #fff; }
.step-ic { flex: none; font-size: 26px; }
.step-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.step-title { font-weight: 700; font-size: 16.5px; color: var(--jungle-900); }
.step-summary { font-size: 13.5px; color: var(--ink-soft); overflow-wrap: anywhere; }
.step-when { flex: none; font-size: 13px; color: var(--ink-mute); white-space: nowrap; }

.step-kicker {
  display: inline-block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .1em;
  opacity: .85;
  margin-bottom: 6px;
}
.step-now {
  margin: 0 0 18px;
  padding: 11px 15px;
  border-radius: 12px;
  font-size: 14.5px;
}
.step-now.here { background: #f0fdfa; border: 1px solid #99f6e4; color: var(--jungle-900); }
.step-now.elsewhere { background: var(--sand-100); border: 1px solid var(--line); color: var(--ink-soft); }
.step-now a { font-weight: 600; }

.step-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 26px 0 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.step-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink-soft);
}
.step-nav a:hover { border-color: var(--jungle-500); color: var(--jungle-800); }
.step-nav .step-all { margin: 0 auto; }

/* ============================================================
   Фаза 2: Дизайн-система — компоненты
   ============================================================ */

/* --- Карточка события --- */
.event-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, border-color .15s;
}
.event-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--jungle-500);
}
.event-card.kind-flight {
  border-left: 4px solid var(--jungle-700);
}
.event-card.kind-train {
  border-left: 4px solid var(--coral);
}
.event-card.kind-stay {
  border-left: 4px solid var(--ok);
}
.event-card.kind-layover {
  border-left: 4px solid #8b5cf6;
}
.event-card.kind-transfer {
  border-left: 4px solid var(--ink-mute);
}

.event-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.event-card-icon {
  font-size: 24px;
  line-height: 1;
}
.event-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}
.event-card-body {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.5;
}
.event-card-time {
  font-size: 13px;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
}

/* --- Алерты --- */
.alert {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 12px 0;
  font-size: 14.5px;
  line-height: 1.5;
  border: 1px solid;
}
.alert-critical {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}
.alert-info {
  background: #f0f9ff;
  border-color: #bae6fd;
  color: #075985;
}
.alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}
.alert strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* --- Таймлайн --- */
.timeline {
  position: relative;
  padding-left: 28px;
  margin: 20px 0;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--line);
}
.timeline-item {
  position: relative;
  padding: 0 0 20px 0;
}
.timeline-item:last-child {
  padding-bottom: 0;
}
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--jungle-700);
}
.timeline-item.now .timeline-dot {
  background: var(--jungle-700);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, .2);
}
.timeline-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  margin-bottom: 2px;
}
.timeline-content {
  font-size: 14.5px;
  color: var(--ink-soft);
}

/* --- Кнопки действий --- */
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch-target);
  min-width: var(--touch-target);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--jungle-700);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s;
  box-shadow: var(--shadow-sm);
}
.action-btn:hover {
  background: var(--jungle-800);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.action-btn:active {
  transform: translateY(0);
}
.action-btn:visited {
  color: #fff;
}
.action-btn-secondary {
  background: var(--card);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.action-btn-secondary:hover {
  background: var(--sand-100);
  border-color: var(--jungle-500);
}

/* --- Аккордеон --- */
.accordion {
  margin: 16px 0;
}
.accordion details {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 8px 0;
  overflow: hidden;
}
.accordion summary {
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::before {
  content: '▸';
  display: inline-block;
  transition: transform .2s;
  font-size: 12px;
}
.accordion details[open] summary::before {
  transform: rotate(90deg);
}
.accordion summary:hover {
  background: var(--sand-50);
}
.accordion .accordion-body {
  padding: 0 16px 16px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-soft);
}

/* --- Нижняя мобильная панель (WCAG 2.2 AA/AAA) --- */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottombar-h);
  background: rgba(253, 251, 247, .95);
  backdrop-filter: saturate(180%) blur(10px);
  border-top: 1px solid var(--line);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-inner {
  display: flex;
  align-items: stretch;
  height: 100%;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  color: var(--ink-mute);
  font-size: 11px;
  font-weight: 600;
  transition: color .15s;
  min-height: var(--touch-target);
  padding: 6px 0;
}
.bottom-nav a .nav-icon {
  font-size: 22px;
  line-height: 1;
}
.bottom-nav a:hover,
.bottom-nav a.active {
  color: var(--jungle-700);
}
.bottom-nav a.active {
  color: var(--jungle-800);
}

/* --- Статус офлайн/онлайн --- */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--ink-mute);
  background: var(--sand-100);
  border-radius: var(--radius-sm);
  margin: 12px 0;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
}
.status-dot.offline {
  background: var(--warn);
}

/* --- Блок «Сейчас» --- */
.now-banner {
  background: linear-gradient(135deg, var(--jungle-800), var(--jungle-700));
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
  box-shadow: var(--shadow-lg);
}
.now-banner h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
}
.now-banner p {
  margin: 0;
  font-size: 14.5px;
  opacity: .9;
}
.now-banner .now-time {
  margin-top: 8px;
  font-size: 13px;
  opacity: .7;
  font-variant-numeric: tabular-nums;
}

/* --- Quick links --- */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.quick-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  transition: border-color .15s, box-shadow .15s;
  min-height: var(--touch-target);
}
.quick-link:hover {
  border-color: var(--jungle-500);
  box-shadow: var(--shadow-sm);
  color: var(--jungle-700);
}
.quick-link-icon {
  font-size: 20px;
  line-height: 1;
}

.now-action {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14.5px;
}

.now-action label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--touch-target);
  cursor: pointer;
}

.now-action input {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--jungle-700);
}

.map-load-button {
  width: 100%;
  min-height: var(--touch-target);
  margin: 12px 0;
  padding: 12px 18px;
  border: 1px solid var(--jungle-700);
  border-radius: var(--radius);
  background: var(--jungle-700);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.map-load-button:hover { background: var(--jungle-800); }
.map-load-button:disabled { opacity: .65; cursor: wait; }

/* --- План Б --- */
.plan-b {
  background: var(--coral-soft);
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 16px 0;
  font-size: 14.5px;
  color: #9a3412;
}
.plan-b strong {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* --- Поиск (Фаза 4, D15) --- */
.search-bar {
  position: relative;
  margin: 16px 0;
}
.search-bar input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  font-size: 15px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  transition: border-color .15s;
  min-height: var(--touch-target);
}
.search-bar input:focus {
  outline: none;
  border-color: var(--jungle-700);
}
.search-bar::before {
  content: "🔍";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  pointer-events: none;
}
.search-bar .search-hint {
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 4px;
}
#search-results {
  margin: 12px 0;
  max-height: 400px;
  overflow-y: auto;
}
.search-count {
  font-size: 13px;
  color: var(--ink-mute);
  margin-bottom: 8px;
}
.search-empty {
  font-size: 14px;
  color: var(--ink-mute);
  padding: 20px;
  text-align: center;
}
.search-result {
  list-style: none;
  padding: 0;
  margin: 0;
}
.search-result-link {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin: 6px 0;
  text-decoration: none;
  color: var(--ink-soft);
  transition: border-color .15s, background .15s;
  min-height: var(--touch-target);
}
.search-result-link:hover {
  border-color: var(--jungle-500);
  background: var(--sand-50);
  color: var(--jungle-700);
}
.search-result-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}
.search-result-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.search-result-preview {
  font-size: 13px;
  color: var(--ink-mute);
  margin-top: 2px;
}

/* --- Mobile-first (до 768px) --- */
@media (max-width: 768px) {
  .bottom-nav {
    display: block;
  }
  .page {
    padding-bottom: calc(var(--bottombar-h) + 20px);
  }
  .topbar .nav {
    display: none;
  }
  .topbar .burger {
    display: block;
  }
  .hero img {
    height: 200px;
  }
  .hero-body h1 {
    font-size: 24px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .countdown {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Desktop: скрываем bottom-nav --- */
@media (min-width: 769px) {
  .bottom-nav {
    display: none !important;
  }
}

/* ============================================================
   Фаза 2.4: Тёмная тема (половина перелётов ночью)
   ============================================================ */

@media (prefers-color-scheme: dark) {
  :root {
    --sand-50: #0f1419;
    --sand-100: #1a2028;
    --sand-200: #2a3340;
    --ink: #e7e5e4;
    --ink-soft: #d6d3d1;
    --ink-mute: #a8a29e;
    --line: #2a3340;
    --card: #1a2028;
    --jungle-700: #2dd4bf;
    --jungle-800: #14b8a6;
    --coral: #fb923c;
    --coral-soft: #1c140a;
    --ok: #4ade80;
    --warn: #f87171;
    --sticky-bg: rgba(15, 20, 25, .92);
  }

  body {
    background: var(--sand-50);
    color: var(--ink);
  }

  .topbar {
    background: rgba(15, 20, 25, .92);
    border-bottom-color: var(--line);
  }

  .brand, .nav a, .brand-text {
    color: var(--ink);
  }

  .nav a:hover {
    background: var(--sand-200);
  }

  .nav a.active {
    background: #0f766e;
    color: #fff;
  }

  .burger {
    background: var(--card);
    border-color: var(--line);
  }

  .burger span { background: var(--ink); }

  .event-card, .quick-link, .accordion details {
    background: var(--card);
    border-color: var(--line);
  }

  .event-card:hover, .quick-link:hover {
    border-color: var(--jungle-700);
  }

  /* Сплошные кнопки-«плашки». В светлой схеме это белый текст по тёмной
     бирюзе; в тёмной --jungle-700/800 переворачиваются в светлую бирюзу,
     и тот же белый текст на ней почти не читается (1.86 при норме 4.5).
     Поэтому в тёмной схеме пара цветов инвертируется: тёмный текст по
     светлой заливке. Список селекторов — все места, где бирюза служит
     фоном, а не текстом. */
  .lock-form button,
  .secret-form button,
  .doc-row button:hover,
  .totop,
  .btn-ics,
  .jr-when,
  .step-badge,
  .step-card.current .step-num,
  .action-btn,
  .map-load-button,
  .list-toolbar button.on,
  .jr-form-actions .jr-submit {
    background: #2dd4bf;
    border-color: #2dd4bf;
    color: #06251f;
  }

  .lock-form button:hover,
  .doc-row button:hover,
  .totop:hover,
  .btn-ics:hover,
  .action-btn:hover,
  .map-load-button:hover,
  .jr-form-actions .jr-submit:hover {
    background: #5eead4;
    color: #06251f;
  }

  /* --jungle-900 остаётся тёмным (он же фон .hero), поэтому как цвет
     текста в тёмной схеме его переопределяем поимённо. */
  a:hover,
  .step-title,
  .tx-total b,
  .tx-cat-chip b,
  .tx-sum,
  .tx-cur-line b,
  .tx-bal {
    color: #5eead4;
  }

  .step-now.here {
    background: #102925;
    border-color: #134e4a;
    color: #99f6e4;
  }

  .action-btn-secondary {
    background: var(--card);
    color: var(--ink);
    border-color: var(--line);
  }

  .action-btn-secondary:hover {
    background: var(--sand-100);
  }

  .bottom-nav {
    background: rgba(15, 20, 25, .95);
    border-top-color: var(--line);
  }

  .bottom-nav a {
    color: var(--ink-mute);
  }

  .bottom-nav a:hover,
  .bottom-nav a.active {
    color: var(--jungle-700);
  }

  .step-hero {
    background: linear-gradient(135deg, #064e3b, #065f46);
  }

  .alert-critical {
    background: #1c0a0a;
    border-color: #451a1a;
    color: #fca5a5;
  }

  .alert-warning {
    background: #1c140a;
    border-color: #45320a;
    color: #fcd34d;
  }

  .alert-info {
    background: #0a1428;
    border-color: #0a3245;
    color: #93c5fd;
  }

  .plan-b {
    background: #1c140a;
    border-color: #45320a;
    color: #fed7aa;
  }

  .note.info,
  .note.ok,
  .note.warn,
  .note.danger,
  .prose blockquote { color: var(--ink); }

  .note.info { background: #0a2033; border-color: #1d4f73; }
  .note.ok { background: #0d2618; border-color: #27643f; }
  .note.warn { background: #2b1d08; border-color: #6b4610; }
  .note.danger { background: #2b1010; border-color: #6b2525; }

  .now-banner {
    background: linear-gradient(135deg, #064e3b, #065f46);
  }

  .now-card {
    background: linear-gradient(135deg, #115e59, #0f766e);
  }

  .fact .v,
  .card h3,
  .prose h3,
  .timeline .date {
    color: #5eead4;
  }

  .w-day.today,
  .step-card.current {
    background: #102925;
  }

  /* Таблицы в тёмной теме */
  table {
    border-color: var(--line);
  }

  th {
    background: var(--sand-100);
    color: var(--ink);
  }

  /* В тёмной схеме --jungle-800 переворачивается в светлый бирюзовый,
     и белый текст шапки садится на светлый фон. Селектор повторяем
     целиком: голый `th` выше по специфичности проигрывает. */
  .prose thead th {
    background: #115e59;
    color: #fff;
  }

  td {
    border-color: var(--line);
  }

  tr:nth-child(even) {
    background: var(--sand-100);
  }
}

@media print {
  .topbar, .footer, .totop, .toc, .checklist-tools, .bottom-nav { display: none !important; }
  body { background: #fff; }
  .page { display: block; padding: 0; }
}
