/*
 * Основа: типографика, оболочка (шапка, нижняя панель), кнопки,
 * карточки, полоски прогресса, диалоги. Mobile-first.
 */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}
body.bare { padding-bottom: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; }
p { margin: 0 0 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; border-radius: var(--r-s); z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- типографика ---------- */
.h-page { font-family: var(--serif); font-weight: 700; font-size: clamp(28px, 7vw, 42px); line-height: 1.15; letter-spacing: -.01em; }
.h-sec { font-family: var(--serif); font-weight: 600; font-size: 24px; margin: 32px 0 12px; }
.display { font-family: var(--serif); font-size: 48px; line-height: 1; font-variant-numeric: lining-nums; }
.num { font-family: var(--serif); font-weight: 600; font-size: 44px; color: var(--accent); line-height: 1.05; font-variant-numeric: lining-nums tabular-nums; }
.num.mono { font-family: var(--sans); font-size: 28px; font-weight: 500; letter-spacing: .01em; }
.label { display: block; font-size: 14px; color: var(--muted); }
.label-strong { font-size: 17px; font-weight: 500; font-family: var(--sans); }
.muted { color: var(--muted); }
.lead { font-size: 19px; max-width: 52ch; }
.accent-t, .crisis-t { color: var(--accent); }
.link { color: var(--accent); text-underline-offset: 3px; }

/* ---------- оболочка ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--page-x);
  background: var(--bg); background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; font-family: var(--serif); font-size: 18px; font-weight: 500; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand .flag { flex: none; border-radius: 3px; }
.topnav { display: none; }

.view { display: block; max-width: 1280px; margin: 0 auto; padding: 20px var(--page-x) 40px; outline: none; }
.loading { padding: 40px 0; }

/* меню под шапкой (телефон, планшет): кнопка «Меню» раскрывает список разделов */
.menu-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 14px; font-weight: 500; cursor: pointer;
}
.menu-btn[aria-expanded="true"] { background: var(--text); color: var(--card); border-color: var(--text); }
.menu-panel {
  position: absolute; left: 0; right: 0; top: 100%;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  padding: 12px var(--page-x) 16px; background: var(--bg); border-bottom: 1px solid var(--line);
  box-shadow: 0 12px 24px -16px rgba(40, 30, 20, .35);
  animation: menu-in var(--t-fast) var(--ease);
}
.menu-panel a {
  display: flex; align-items: center; min-height: 48px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: var(--r-s); background: var(--card);
  text-decoration: none; font-size: 15px; line-height: 1.3;
}
.menu-panel a[aria-current="page"] { border-color: var(--text); font-weight: 500; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } }
@media (prefers-reduced-motion: reduce) { .menu-panel { animation: none; } }

/* шапка с полным меню — на широких экранах; уже — кнопка «Меню» */
@media (min-width: 1200px) {
  :root { --page-x: 48px; }
  .menu-btn, .menu-panel { display: none !important; }
  .topbar { padding: 0 var(--page-x); height: 72px; }
  .topnav { display: flex; gap: clamp(14px, 1.6vw, 26px); font-size: 15px; }
  .topnav a { text-decoration: none; color: var(--muted); padding: 6px 0; border-bottom: 1px solid transparent; transition: color var(--t-fast); }
  .topnav a:hover { color: var(--text); }
  .topnav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }
  .view { padding-top: 36px; padding-bottom: 64px; }
}

/* ---------- элементы ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-l); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border: 1px solid var(--accent); border-radius: var(--r);
  background: var(--accent); color: var(--accent-text);
  font: 500 16px var(--sans); text-decoration: none; cursor: pointer;
  transition: filter var(--t-fast), background var(--t-fast);
}
.btn:hover { filter: brightness(1.08); }
.btn:active { filter: brightness(.88); }
.btn:disabled { opacity: .4; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: transparent; background: color-mix(in srgb, var(--accent) 7%, transparent); filter: none; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn-wide { width: 100%; }

.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); flex: none; }
.seg button {
  min-height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-size: 14px; cursor: pointer; transition: background var(--t-fast), color var(--t-fast);
}
.seg button[aria-checked="true"] { background: var(--text); color: var(--card); }

.tag { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--muted); }
.tag.ok { color: var(--good); border-color: transparent; border-color: color-mix(in srgb, var(--good) 40%, transparent); }

.bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--accent); transition: width var(--t-fill) var(--ease); }
.bar i.on { width: var(--w); }

.sphere-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: middle; flex: none; }
.sphere-dot.big { width: 14px; height: 14px; margin-right: 12px; }

.back { display: inline-block; margin-bottom: 10px; font-size: 14px; color: var(--muted); text-decoration: none; padding: 8px 0; }
.back::before { content: "‹ "; }
.back:hover { color: var(--text); }

.field {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--card);
  font: 16px var(--sans); color: var(--text);
}
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px transparent; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }

.toast {
  position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 40;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: var(--r);
  background: var(--text); color: var(--card); font-size: 14px;
  opacity: 0; transform: translate(-50%, 8px); pointer-events: none;
  transition: opacity var(--t-rise) var(--ease), transform var(--t-rise) var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 1200px) { .toast { bottom: 32px; } }

.dialog {
  width: min(440px, calc(100% - 32px)); padding: 28px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(59, 47, 40, .12);
}
.dialog::backdrop { background: rgba(59, 47, 40, .28); }
.dialog h2 { font-family: var(--serif); font-size: 24px; margin-bottom: 10px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* появление блока с лёгким подъёмом */
.rise { animation: rise var(--t-rise) var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* заголовок экрана получает фокус программно — рамка не нужна */
.view h1[tabindex="-1"]:focus { outline: none; }
