* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; overscroll-behavior: none; }

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  display: grid;
  grid-template-rows: auto auto 1fr;
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font: 400 1.0625rem/1.5 var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2 { text-wrap: balance; }
p, li { text-wrap: pretty; }

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

/* Элементы управления: мгновенный отклик на касание, без выделения текста */
button, .link {
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.chips button, .dots button, .next, .cal .c { transition: transform 150ms var(--ease-out); }
.chips button, .dots button { transition: transform 150ms var(--ease-out), background-color 150ms ease, color 150ms ease, border-color 150ms ease; }
.chips button:active, .dots button:active, .next:active { transform: scale(0.96); }
.cal .c:active { transform: scale(0.92); }

.facts dd, .score, .readout, .chart text, .weekdays, .rec .big, .outlook b { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--peach); outline-offset: 2px; }

/* Верхняя панель */
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 24px;
  padding: max(10px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 10px max(24px, env(safe-area-inset-left));
  background: var(--deep);
}
.brand { font: 800 0.9375rem/1 var(--display); color: var(--peach); white-space: nowrap; }
.dots { display: flex; gap: 4px; flex: 1 1 auto; min-width: 0; }
.tab-link {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--edge);
  color: var(--ink); text-decoration: none; font-size: 0.875rem; white-space: nowrap;
}
.dots button {
  border: 0; background: none; padding: 6px 10px; border-radius: 999px;
  color: var(--muted); font-size: 0.875rem; cursor: pointer;
}
.dots button[aria-current="true"] { background: var(--plum); color: var(--ink); }
.range { display: flex; align-items: center; gap: 10px; margin-left: auto; font-size: 0.875rem; color: var(--muted); }
.range input {
  background: var(--plum); border: 1px solid var(--edge); border-radius: 8px; padding: 4px 7px;
  color-scheme: dark; font-size: 0.875rem;
}
.link {
  border: 0; background: none; padding: 4px 0; color: var(--peach); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; font-size: 0.875rem;
}

.notice {
  display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center;
  padding: 8px 24px; background: var(--rose); color: var(--deep); font-size: 0.875rem;
}
.notice .link { color: var(--deep); font-weight: 500; }
.notice[hidden] { display: none; }

/* Слайды */
.deck {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  touch-action: manipulation;
  scrollbar-width: none;
}
.deck::-webkit-scrollbar { display: none; }

.slide {
  flex: 0 0 100%;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 28px max(40px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(40px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

h1, h2, h3 { margin: 0; font-family: var(--display); }
h2 { font-weight: 500; font-size: 1.75rem; line-height: 1.15; }

.slide-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  border: 1px solid var(--edge); background: none; border-radius: 999px;
  padding: 6px 14px; font-size: 0.9375rem; cursor: pointer; color: var(--ink);
}
.chips button[aria-pressed="true"] { background: var(--peach); border-color: var(--peach); color: var(--deep); }

.readout { margin: 0; min-height: 1.5em; color: var(--muted); font-size: 1rem; }
.readout b { color: var(--ink); font-weight: 500; }
.readout .vals { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 2px; }
.readout .vals span { white-space: nowrap; }
.readout .vals i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }

/* Обложка */
.cover { padding-top: 0; }
.stripes {
  flex: 0 0 22vh; display: flex;
  margin: 0 calc(-1 * max(40px, env(safe-area-inset-right))) 0 calc(-1 * max(40px, env(safe-area-inset-left)));
}
.stripes span { flex: 1; }
.cover-text { max-width: 760px; margin: auto 0; }
.cover h1 {
  font-weight: 800; font-size: clamp(2.5rem, min(8vw, 11vh), 6rem); line-height: .95;
  letter-spacing: -0.03em; color: var(--peach);
}
.period { margin: 14px 0 0; color: var(--muted); }
.forecast { margin: 18px 0 0; font-size: clamp(1.25rem, 2.6vw, 1.75rem); line-height: 1.35; max-width: 30ch; }
.facts { display: flex; flex-wrap: wrap; gap: 14px 36px; margin: 28px 0 0; }
.facts div { min-width: 90px; }
.facts dt { font-size: 0.875rem; color: var(--muted); }
.facts dd { margin: 0; font: 500 1.875rem/1.1 var(--display); }
.next {
  margin-top: 30px; border: 0; border-radius: 999px; padding: 12px 22px;
  background: var(--coral); color: var(--deep); font-weight: 500; cursor: pointer;
}

/* Календарь */
.months { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px 22px; }
.month h3 { font-weight: 500; font-size: 0.8125rem; margin-bottom: 6px; }
.month h3 small { color: var(--muted); font-weight: 400; font-family: var(--text); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .c {
  aspect-ratio: 1; border-radius: 4px; border: 0; padding: 0; background: var(--c); cursor: pointer;
  display: grid; place-items: center; font-size: 0.6875rem; line-height: 1; color: var(--deep);
}
.cal .c.light { color: var(--ink); }
.cal .c.out { background: transparent; box-shadow: inset 0 0 0 1px var(--plum); cursor: default; }
.cal .c[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }
.cal-foot {
  display: flex; flex-wrap: wrap; gap: 8px 32px; align-items: center; margin-top: auto;
  position: sticky; bottom: calc(-1 * max(20px, env(safe-area-inset-bottom))); padding: 10px 0 14px; background: var(--night);
}
.legend { display: flex; align-items: center; gap: 4px; font-size: 0.8125rem; color: var(--muted); }
.legend i { width: 16px; height: 16px; border-radius: 4px; }
.legend span { margin: 0 6px; }
.rain-legend { gap: 18px; flex-wrap: wrap; }
.rain-legend span { margin: 0; display: inline-flex; align-items: center; gap: 8px; }
.rain-legend i { background: var(--coral); }
.hatch, .rain-legend i.hatch {
  background: repeating-linear-gradient(45deg, var(--lilac) 0 3px, var(--night) 3px 5px);
}

/* Графики */
.chart { flex: 1; min-height: 260px; position: relative; }
.chart svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.chart text { fill: var(--muted); font: 0.75rem var(--text); }
.chart .grid line { stroke: var(--plum); }
.chart .hit { fill: transparent; cursor: pointer; }
@media (hover: hover) and (pointer: fine) {
  .chart .hit:hover { fill: rgba(255, 233, 240, .06); }
}

.score { display: flex; align-items: baseline; gap: 18px; font-family: var(--display); }
.score b { font-weight: 800; font-size: clamp(2.5rem, 6vw, 4rem); line-height: 1; }
.score .f { color: var(--coral); }
.score .m { color: var(--lilac); }
.score span { color: var(--muted); font-size: 0.9375rem; font-family: var(--text); }

/* Рекорды */
.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.rec { background: var(--plum); border-radius: 18px; padding: 18px 20px; }
.rec h3 { font: 400 0.9375rem/1.3 var(--text); color: var(--muted); }
.rec .big { font: 800 clamp(1.75rem, 3vw, 2.375rem)/1.05 var(--display); overflow-wrap: anywhere; margin: 8px 0 4px; color: var(--peach); }
.rec p { margin: 0; font-size: 0.9375rem; }
.rec.wide { grid-column: span 2; }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 120px; margin-top: 10px; }
.weekdays div { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 4px; font-size: 0.8125rem; color: var(--muted); }
.weekdays i { width: 100%; background: var(--coral); border-radius: 6px 6px 2px 2px; min-height: 2px; }
.weekdays b { color: var(--ink); font-weight: 500; }

/* Прогноз */
.outlook { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; max-width: 44ch; }
.outlook li { font-size: clamp(1.25rem, 2.4vw, 1.625rem); line-height: 1.35; }
.outlook li b { font: 800 1.1em var(--display); color: var(--peach); }
.signoff { margin: auto 0 0; color: var(--muted); }

@media (max-width: 760px) {
  body { font-size: 1rem; }
  .bar { flex-wrap: wrap; padding-left: 16px; padding-right: 16px; gap: 8px 12px; }
  .dots { order: 3; flex-basis: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .dots::-webkit-scrollbar { display: none; }
  .dots button { white-space: nowrap; padding: 5px 9px; font-size: 0.8125rem; }
  .range { order: 2; flex-basis: 100%; min-width: 0; margin-left: 0; gap: 8px; font-size: 0.8125rem; }
  .range label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
  .range input { flex: 1; min-width: 0; width: 100%; padding: 4px; font-size: 0.8125rem; }
  .range .link { display: none; }
  .notice { padding: 8px 16px; font-size: 0.8125rem; }
  .slide { padding: 20px 16px max(20px, env(safe-area-inset-bottom)); gap: 14px; }
  .cover { padding-top: 0; }
  .stripes { flex-basis: 18vh; margin: 0 -16px; }
  h2 { font-size: 1.375rem; }
  .chips button { padding: 5px 11px; font-size: 0.875rem; }
  .facts { gap: 12px 24px; }
  .facts dd { font-size: 1.5rem; }
  .months { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 10px; }
  .rec.wide { grid-column: auto; }
  .chart { min-height: 240px; }
}

/* iOS приближает страницу, если шрифт поля меньше 16px */
@media (pointer: coarse) {
  .range input { font-size: 1rem; }
}

/* Уже 370px два месяца в ряд дают дни меньше 24px — ставим по одному */
@media (max-width: 369px) {
  .months { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Движение ----------
   Только первое появление: обложка при загрузке и каждый слайд при первом показе.
   Фильтры, выбор дня и столбика, листание с клавиатуры — без анимации. */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes grow { from { transform: scaleY(0.04); } }
@keyframes sweep { from { clip-path: inset(0 100% 0 0); } }
@keyframes fade { from { opacity: 0; } }

.chart .bar, .weekdays i { transform-box: fill-box; transform-origin: 50% 100%; }
/* Конечное значение тоже inset(): между inset() и none clip-path не интерполируется, полосы появлялись скачком */
.stripes { clip-path: inset(0 0 0 0); }

@media (prefers-reduced-motion: no-preference) {
  .stripes { animation: sweep 900ms var(--ease-in-out) both; }
  .cover-text > * { animation: rise 300ms var(--ease-out) both; animation-delay: calc(250ms + var(--i, 0) * 50ms); }
  .motion .slide:not(.in) [data-rise] { opacity: 0; }
  .motion .slide:not(.in) .bar, .motion .slide:not(.in) .weekdays i { transform: scaleY(0.04); }
  .slide.in:not(.done) [data-rise] { animation: rise 300ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 50ms); }
  .slide.in:not(.done) .bar, .slide.in:not(.done) .weekdays i { animation: grow 500ms var(--ease-out) both; animation-delay: var(--d, 0ms); }
}

@media (prefers-reduced-motion: reduce) {
  .motion .slide:not(.in) [data-rise], .motion .slide:not(.in) .chart svg, .motion .slide:not(.in) .weekdays { opacity: 0; }
  .slide.in:not(.done) [data-rise], .slide.in:not(.done) .chart svg, .slide.in:not(.done) .weekdays { animation: fade 200ms ease both; }
  .chips button, .dots button, .next, .cal .c { transition: none; }
  .deck { scroll-behavior: auto; }
}
