/* Основа: сброс, типографика, каркас приложения, фокус, служебные классы. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: var(--s6); overscroll-behavior-y: none; }
body {
  margin: 0; min-height: 100dvh; background: var(--milk); color: var(--ink);
  font: 400 var(--fs-15)/1.5 var(--font-ui); letter-spacing: .005em;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-x: clip; overscroll-behavior-y: none;
  transition: background-color var(--t-base) var(--ease-out), color var(--t-base) var(--ease-out);
}
h1, h2, h3, h4, p, ul, ol, figure, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
a { color: inherit; text-decoration: none; -webkit-tap-highlight-color: transparent; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent-tone) 35%, transparent); }

/* заголовки: serif задаёт характер, но без гигантизма */
.display { font-family: var(--font-display); font-weight: 450; letter-spacing: -.01em; line-height: 1.15; }
.h-date { font-family: var(--font-display); font-weight: 450; font-size: clamp(1.375rem, 5.9vw, var(--fs-30)); letter-spacing: -.015em; line-height: 1.12; }
.h-title { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-22); letter-spacing: -.01em; line-height: 1.2; }
.h-sub { font-family: var(--font-display); font-weight: 500; font-size: var(--fs-17); line-height: 1.25; }
.num { font-family: var(--font-display); font-variant-numeric: lining-nums tabular-nums; font-weight: 500; }
.muted { color: var(--ink-soft); }
.small { font-size: var(--fs-13); }
.tiny { font-size: var(--fs-12); }

/* видимый фокус для клавиатуры */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
:focus:not(:focus-visible) { outline: none; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* иконки */
.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 18px; height: 18px; }
.icon.lg { width: 28px; height: 28px; }
.icon.xl { width: 40px; height: 40px; }

/* ---------- каркас ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto;
  padding: calc(var(--s5) + var(--safe-top)) var(--s4) calc(var(--nav-h) + var(--nav-safe) + var(--s8)); }
.view { animation: view-in var(--t-base) var(--ease-out) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* нижняя навигация (телефон) */
.nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--nav-safe));
  padding-bottom: var(--nav-safe); background: color-mix(in srgb, var(--linen) 94%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: var(--sh-nav);
  display: grid; grid-template-columns: repeat(4, 1fr); }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink-soft);
  font-size: var(--fs-12); font-weight: 450; position: relative; min-height: 48px; transition: color var(--t-fast); }
.nav-item .icon { transition: transform var(--t-base) var(--ease-spring); }
.nav-item[aria-current="page"] { color: var(--accent); font-weight: 550; }
.nav-item[aria-current="page"] .icon { transform: translateY(-1px) scale(1.06); }
.nav-item[aria-current="page"]::before { content: ""; position: absolute; top: 6px; width: 40px; height: 30px; border-radius: var(--r-pill);
  background: var(--accent-wash); z-index: -1; animation: pill-in var(--t-base) var(--ease-spring); }
@keyframes pill-in { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.nav-brand, .nav-spacer, .nav-settings { display: none; }

/* рейка слева (компьютер) */
@media (min-width: 900px) {
  .app { flex-direction: row; }
  .nav { position: sticky; top: 0; left: auto; right: auto; bottom: auto; width: 96px; height: 100dvh; flex: none;
    padding: var(--s6) 0; background: transparent; box-shadow: inset -1px 0 0 var(--oat-line); -webkit-backdrop-filter: none; backdrop-filter: none;
    display: flex; flex-direction: column; align-items: stretch; gap: var(--s2); }
  .nav-brand { display: flex; justify-content: center; margin-bottom: var(--s6); }
  .nav-settings { display: flex; }
  .nav-brand img { width: 44px; height: 44px; border-radius: 12px; }
  .nav-spacer { display: block; flex: 1; }
  .nav-item { min-height: 64px; margin: 0 var(--s2); border-radius: var(--r-card); }
  .nav-item:hover { background: var(--oat); }
  .nav-item[aria-current="page"]::before { display: none; }
  .nav-item[aria-current="page"] { background: var(--accent-wash); }
  .main { max-width: 1120px; padding: var(--s8) var(--s10) var(--s12); }
}

/* оффлайн и очередь */
.net-banner { position: sticky; top: 0; z-index: 25; display: flex; align-items: center; gap: var(--s2); justify-content: center;
  padding: calc(var(--s2) + var(--safe-top)) var(--s4) var(--s2); background: var(--warn-wash); color: var(--ink); font-size: var(--fs-13);
  border-bottom: 1px solid var(--oat-line); animation: view-in var(--t-base) var(--ease-out) both; }

/* уменьшенное движение: только смена прозрачности */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* Небольшой запас над домашним индикатором, единый для навигации и контента. */
:root { --nav-h: 56px; --nav-safe: max(6px, calc(var(--safe-bottom) - 14px)); }
.net-banner .btn { flex: none; }
.net-chip { position: fixed; z-index: 26; top: calc(var(--safe-top) + var(--s2)); left: 50%; transform: translateX(-50%);
  max-width: calc(100% - var(--s8)); padding: var(--s2) var(--s3); border-radius: var(--r-pill); background: var(--oat); color: var(--ink-soft); font-size: var(--fs-12); }
.pull-refresh { position: fixed; z-index: 27; top: calc(var(--safe-top) + var(--s2)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: var(--s1); pointer-events: none; color: var(--ink-soft); font-size: var(--fs-12); white-space: nowrap; }
.pull-refresh-circle { display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-pill); background: var(--linen); box-shadow: var(--sh-float); }
.pull-refresh.is-busy .icon { animation: pull-spin 1s linear infinite; }
@keyframes pull-spin { to { transform: rotate(360deg); } }
