/* «Когда менять резину» — стили. Сначала телефон, потом широкий экран. Цвета — токенами:
   светлая и тёмная тема меняют только значения. Цвета графика проверены валидатором палитры
   (различимость при дальтонизме и контраст к фону). */
:root {
  color-scheme: light;
  --plane: #f9f9f7;  --surface: #fcfcfb;  --ink: #0b0b0b;  --ink2: #52514e;  --muted: #898781;
  --grid: #e1e0d9;   --axis: #c3c2b7;     --border: rgba(11, 11, 11, .10);   --past: #f0efec;
  --link: #1c5cab;   --btn: #2a78d6;      --btn-ink: #fff;
  /* график: синяя — средняя за 7 дней (главная линия), серая — среднесуточная, оранжевая — порог +7 */
  --ma: #2a78d6;     --mean: #898781;     --band: rgba(42, 120, 214, .14);   --thr: #eb6834;
  /* состояния — всегда со значком и словами, цвет не единственный признак */
  --good: #0ca30c;   --warning: #fab219;  --critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --plane: #0d0d0d;  --surface: #1a1a19;  --ink: #f0efec;  --ink2: #c3c2b7;  --muted: #898781;
    --grid: #2c2c2a;   --axis: #383835;     --border: rgba(255, 255, 255, .10); --past: #232321;
    --link: #86b6ef;   --btn: #3987e5;
    --ma: #3987e5;     --band: rgba(57, 135, 229, .22);   --thr: #d95926;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--plane); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); }
main, .top, .foot { max-width: 760px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 8px 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
.lead { color: var(--ink2); margin: 0 0 16px; }
.muted { color: var(--ink2); font-size: .9rem; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; padding-bottom: 6px; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 650; color: var(--ink); text-decoration: none; }
.top-bot { font-size: .9rem; }
.crumbs { font-size: .9rem; margin: 6px 0 0; }

.card, .tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin: 0 0 16px;
}

/* плашка-вердикт: полоса слева — цвет состояния, рядом значок и слова */
.tile { border-left: 6px solid var(--st); }
.tile-head { display: flex; align-items: flex-start; gap: 10px; }
.tile-head .ico { font-size: 1.6rem; line-height: 1.2; }
.tile h2 { font-size: 1.45rem; line-height: 1.25; margin: 0; }
.tile p { margin: 8px 0 0; }
.tile-sub { color: var(--ink2); }
.tile .law { color: var(--ink2); font-size: .92rem; }
.st-now, .st-law { --st: var(--critical); }
.st-soon { --st: var(--warning); }
.st-wait { --st: var(--good); }

.cta, .btn {
  display: inline-block; background: var(--btn); color: var(--btn-ink); text-decoration: none;
  font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 11px 16px; cursor: pointer;
}
.cta { margin: 0 0 16px; }
.btn:disabled { opacity: .6; cursor: progress; }

.summary { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin: 0 0 16px; }

/* метка состояния: точка цвета состояния + текст обычным цветом */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--ink2); white-space: nowrap; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--st); flex: none; }

.search {
  width: 100%; font: inherit; padding: 10px 12px; margin: 0 0 12px;
  border: 1px solid var(--axis); border-radius: 10px; background: var(--plane); color: var(--ink);
}
.cities { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 4px 16px; }
.cities li { display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
             padding: 6px 0; border-bottom: 1px solid var(--grid); }
.cities li[hidden] { display: none; }

.explain p { margin: 0 0 10px; }
.foot { color: var(--ink2); font-size: .85rem; padding-top: 4px; padding-bottom: 32px; }
.foot p { margin: 4px 0; }

/* ── график ── */
.chart { position: relative; margin: 4px 0 8px; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--btn); outline-offset: 4px; border-radius: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .85rem; color: var(--ink2); margin: 0 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.c-past { fill: var(--past); }
.c-grid { stroke: var(--grid); stroke-width: 1; }
.c-zero { stroke: var(--axis); stroke-width: 1; }
.c-ax { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.c-note { fill: var(--ink2); font-size: 12px; }
.c-band { fill: var(--band); }
.c-mean { fill: none; stroke: var(--mean); stroke-width: 1.5; stroke-linejoin: round; }
.c-dot { fill: var(--mean); stroke: var(--surface); stroke-width: 2; }
.c-ma { fill: none; stroke: var(--ma); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; }
.c-thr { stroke: var(--thr); stroke-width: 2; stroke-dasharray: 6 4; }
.c-today { stroke: var(--ink2); stroke-width: 1; stroke-dasharray: 3 3; }
.c-sw { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.c-sw-lab { fill: var(--ink); font-size: 13px; font-weight: 700; }
.c-frost { fill: var(--ink2); font-size: 13px; }
.c-cross { stroke: var(--ink2); stroke-width: 1; }
.c-hit { fill: transparent; }
.c-tip {
  position: absolute; top: 0; pointer-events: none; min-width: 170px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12); padding: 8px 10px; font-size: .85rem; line-height: 1.35;
}
.c-tip .d { color: var(--ink2); margin-bottom: 4px; }
.c-tip .r { display: flex; align-items: center; gap: 8px; }
.c-tip .r b { min-width: 3.6em; font-variant-numeric: tabular-nums; }
.c-tip .k, .legend .k { width: 16px; height: 0; border-top: 3px solid var(--ma); flex: none; }
.k.mean { border-top: 2px solid var(--mean); }
.k.band { height: 10px; border: 0; background: var(--band); }
.k.thr { border-top: 2px dashed var(--thr); }
.k.sw { width: 12px; height: 12px; border: 2px solid var(--ink); border-radius: 50%; }

.days summary { cursor: pointer; color: var(--link); margin-top: 6px; }
.table-wrap { overflow-x: auto; }
.days table { border-collapse: collapse; width: 100%; font-size: .88rem; margin-top: 8px; font-variant-numeric: tabular-nums; }
.days th, .days td { text-align: right; padding: 4px 6px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.days th:first-child, .days td:first-child { text-align: left; }
.days th { color: var(--ink2); font-weight: 600; }
.days tr.past td { color: var(--ink2); }
.days tr.today td { background: var(--past); font-weight: 600; }

@media (min-width: 640px) {
  h1 { font-size: 2.1rem; }
  .cities { grid-template-columns: 1fr 1fr; }
  .cities.near { grid-template-columns: 1fr 1fr 1fr; }
}
