/* ---------- Полярная тёмная тема ---------- */
:root {
  --bg:            #060b14;
  --bg-card:       rgba(17, 27, 43, 0.72);
  --border:        rgba(120, 190, 200, 0.16);
  --text:          #e8f1f5;
  --text-dim:      #8ea3b5;
  --text-faint:    #74889c;

  --aurora-green:  #4dffb8;
  --aurora-teal:   #35d6e8;
  --aurora-violet: #9b7bff;
  --aurora-pink:   #ff6fae;

  --ok:    #4dffb8;
  --mid:   #ffd166;
  --bad:   #ff7a8a;

  --radius: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Мягкое «сияние» на фоне */
.aurora-bg {
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 90vh;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(60% 45% at 20% 10%, rgba(77, 255, 184, 0.16), transparent 70%),
    radial-gradient(55% 40% at 70% 0%,  rgba(155, 123, 255, 0.16), transparent 70%),
    radial-gradient(45% 35% at 45% 25%, rgba(53, 214, 232, 0.12), transparent 70%);
  filter: blur(30px);
  animation: drift 26s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-3%, 0, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  .aurora-bg { animation: none; }
}

/* ---------- Шапка ---------- */
.topbar {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 34px 20px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.02em;
  background: linear-gradient(100deg, var(--aurora-green), var(--aurora-teal) 45%, var(--aurora-violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Регион — второй строкой заголовка, без градиента */
.topbar__region {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.topbar__place {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 14px;
}

/* Выбор точки наблюдения */
.point {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.point__label {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.point__select {
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: rgba(53, 214, 232, 0.1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.point__select:hover { background: rgba(53, 214, 232, 0.18); border-color: rgba(53, 214, 232, 0.45); }
.point__select:focus-visible { outline: 2px solid var(--aurora-teal); outline-offset: 2px; }

/* Список вариантов рисует система — задаём тёмный фон явно */
.point__select option { background: #0f1c2e; color: var(--text); }

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.updated {
  color: var(--text-faint);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.btn {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: rgba(53, 214, 232, 0.12);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.btn:hover  { background: rgba(53, 214, 232, 0.22); border-color: rgba(53, 214, 232, 0.45); }

.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: progress; }

/* Видимый фокус с клавиатуры — единый для всех элементов управления */
.btn:focus-visible,
.tabs__btn:focus-visible {
  outline: 2px solid var(--aurora-teal);
  outline-offset: 2px;
}

.btn--ghost { background: transparent; margin-top: 10px; }

/* ---------- Вкладки ---------- */
.tabs {
  position: relative;
  z-index: 2;
  max-width: 1040px;
  margin: 18px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 10px;
}

.tabs__btn {
  flex: 1;
  font: inherit;
  text-align: left;
  color: var(--text-dim);
  background: rgba(17, 27, 43, 0.6);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 16px;
  cursor: pointer;
  transition: color 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.tabs__btn:hover { background: rgba(53, 214, 232, 0.12); }

.tabs__btn[aria-selected="true"] {
  color: var(--text);
  background: rgba(53, 214, 232, 0.16);
  border-color: rgba(53, 214, 232, 0.5);
}

.tabs__title { display: block; font-size: 15px; font-weight: 650; }
.tabs__sub   { display: block; font-size: 12px; color: var(--text-faint); margin-top: 1px; }

.tabs__btn[aria-selected="true"] .tabs__sub { color: var(--text-dim); }

.tabs__short { display: none; }

/* На узком экране навигация уезжает вниз, как в мобильных приложениях */
@media (max-width: 719px) {
  .tabs {
    position: fixed;
    inset: auto 0 0 0;
    margin: 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    gap: 8px;
    background: rgba(6, 11, 20, 0.92);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
  }

  .tabs__btn { text-align: center; padding: 9px 6px; }
  .tabs__title { font-size: 13px; }
  .tabs__sub { display: none; }

  /* Три кнопки в ряд: длинная подпись на 375 px переносилась бы */
  .tabs__long { display: none; }
  .tabs__short { display: inline; }

  /* чтобы панель не перекрывала последнюю карточку */
  .wrap { padding-bottom: 92px; }
}

/* ---------- Сетка ---------- */
.wrap {
  position: relative;
  z-index: 1;
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 20px 50px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .topbar { padding-top: 24px; }
}

/* ---------- Карточки ---------- */
.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  min-height: 190px;
}

.card--wide { margin-top: 18px; }

.card__label {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Переключение состояний: loading / ok / stale / error */
.card__loading,
.card__body,
.card__stale,
.card__error { display: none; }

.card[data-state="loading"] .card__loading { display: block; color: var(--text-faint); }
.card[data-state="ok"]      .card__body    { display: block; }
.card[data-state="error"]   .card__error   { display: block; }

.card[data-state="error"] { border-color: rgba(255, 122, 138, 0.3); }

/* Место под данные на самый первый заход, когда кэша ещё нет: карточка в
   «загрузке» занимает примерно столько же, сколько с данными, и страница не
   прыгает, когда они приходят. Значения сняты с живой страницы и взяты чуть
   ниже типичных, чтобы пустая карточка не оказалась выше заполненной. */
#verdict-card[data-state="loading"]  { min-height: 240px; }
#window-card[data-state="loading"]   { min-height: 370px; }
#kp-card[data-state="loading"],
#cloud-card[data-state="loading"]    { min-height: 480px; }
#forecast-card[data-state="loading"] { min-height: 500px; }
#best-card[data-state="loading"]     { min-height: 290px; }
#places-card[data-state="loading"]   { min-height: 860px; }

@media (max-width: 719px) {
  #verdict-card[data-state="loading"]  { min-height: 340px; }
  #window-card[data-state="loading"]   { min-height: 480px; }
  #kp-card[data-state="loading"]       { min-height: 240px; }
  #cloud-card[data-state="loading"]    { min-height: 470px; }
  #forecast-card[data-state="loading"] { min-height: 1000px; }
  #places-card[data-state="loading"]  { min-height: 1300px; }
}
.card__error-text { margin: 0; color: var(--bad); }

/* Данные из кэша: показываем, но приглушённо — видно, что они не живые */
.card[data-state="stale"] { border-color: rgba(255, 209, 102, 0.28); }

.card[data-state="stale"] .card__body {
  display: block;
  /* Приглушаем цвет, а не прозрачность: при opacity 0,42 основной текст
     падал до контраста 3,7:1, а мелкий — до 1,6:1. Серый вместо белого и
     выцветшие оценки читаются как «не живые данные», но весь текст держит
     не меньше 4,9:1. */
  --text: #aab6c0;
  filter: saturate(0.35);
}

.card[data-state="stale"] .card__stale {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.card__stale {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--mid);
}

.btn--mini {
  margin-top: 0;
  padding: 4px 13px;
  font-size: 13px;
}

/* Крупные цифры */
.bignum {
  margin: 0;
  font-size: 76px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--tone, var(--text));
  text-shadow: 0 0 34px color-mix(in srgb, var(--tone, var(--aurora-teal)) 40%, transparent);
}

.card__caption {
  margin: 10px 0 0;
  font-size: 17px;
  color: var(--text);
}

.card__meta {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-faint);
}

/* Шкала Kp 0..9 */
.scale {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
  margin-top: 16px;
}

.scale__cell {
  height: 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
}

.scale__cell--on { background: var(--tone, var(--aurora-teal)); }

/* Полоса облачности */
.cloudbar {
  margin-top: 16px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.cloudbar__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--tone, var(--aurora-teal));
  transition: width 0.5s ease;
}

/* Разбивка облачности по ярусам */
.layers {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.layers[hidden] { display: none; }

.layer {
  display: grid;
  grid-template-columns: minmax(104px, auto) 1fr 42px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.layer__name { color: var(--text-dim); white-space: nowrap; }
.layer__alt  { color: var(--text-faint); font-size: 11px; }

.layer__bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.layer__fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--tone, var(--aurora-teal));
  transition: width 0.5s ease;
}

.layer__val {
  text-align: right;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Предупреждение о противоречивых данных */
.card__warn {
  margin: 16px 0 0;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--mid);
  background: rgba(255, 209, 102, 0.08);
  border: 1px solid rgba(255, 209, 102, 0.25);
  border-radius: 10px;
}

.card__warn[hidden] { display: none; }

.card__model {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

.layers__note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-faint);
}

/* ---------- Вердикт ---------- */
.card--verdict {
  margin-top: 22px;
  min-height: 0;
  border-color: color-mix(in srgb, var(--tone, var(--border)) 35%, transparent);
}

.verdict__value {
  margin: 0;
  font-size: 54px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--tone, var(--text));
  text-shadow: 0 0 40px color-mix(in srgb, var(--tone, var(--aurora-teal)) 45%, transparent);
}

.verdict__hint {
  margin: 10px 0 0;
  font-size: 17px;
  color: var(--text);
  max-width: 62ch;
}

.verdict__factors {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.verdict__factors li {
  font-size: 13px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 13px;
}

/* ---------- Уведомления ---------- */
.notify {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.notify .btn--mini { margin-top: 0; }

.notify .btn[aria-pressed="true"] {
  color: var(--aurora-green);
  border-color: rgba(77, 255, 184, 0.45);
  background: rgba(77, 255, 184, 0.08);
}

.notify__hint {
  flex: 1 1 240px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-faint);
}

/* ---------- Вкладка «Уведомления» ---------- */
.card--plain { min-height: 0; }
.card--plain:first-child { margin-top: 22px; }   /* как у вердикта на первой вкладке */

.ntest__lead {
  margin: 0;
  max-width: 64ch;
  color: var(--text);
}

.checks {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.check {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: start;
  gap: 4px 10px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.check__mark {
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  color: var(--tone, var(--text-dim));
}

.check__title  { color: var(--text); }
.check__detail { grid-column: 2 / -1; font-size: 13px; color: var(--text-dim); }
.check .btn--mini { margin-top: 0; }

.ntest__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.ntest__actions .btn--ghost { margin-top: 0; }

.ntest__tip {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--text-faint);
  max-width: 70ch;
}

.ntest__status {
  margin: 14px 0 0;
  min-height: 1.5em;          /* место под результат, чтобы текст ниже не прыгал */
  font-size: 14px;
  color: var(--tone, var(--text));
}

.help {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  color: var(--text-dim);
  font-size: 14px;
  max-width: 76ch;
}

.help b { color: var(--text); font-weight: 600; }

/* ---------- Окно наблюдения ---------- */
#window-card { margin-top: 18px; min-height: 0; }

.window__value {
  margin: 0;
  font-size: 44px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--tone, var(--text));
  text-shadow: 0 0 36px color-mix(in srgb, var(--tone, var(--aurora-teal)) 40%, transparent);
}

.window__hint {
  margin: 10px 0 0;
  font-size: 16px;
  color: var(--text);
}

.nighthours {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
  margin-top: 18px;
}

.hour {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 10px;
  font-variant-numeric: tabular-nums;
}

.hour--best {
  background: color-mix(in srgb, var(--tone, var(--aurora-teal)) 12%, transparent);
  border-color: color-mix(in srgb, var(--tone, var(--aurora-teal)) 55%, transparent);
}

.hour__time {
  font-size: 15px;
  font-weight: 650;
  color: var(--tone, var(--text));
}

.hour__cloud { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.hour__kp    { font-size: 12px; color: var(--text-faint); }

/* Ответ «куда ехать» длиннее слова «Низкий», поэтому на узком экране
   уменьшаем кегль, иначе строка занимает треть первого экрана */
@media (max-width: 480px) {
  #best-value { font-size: 34px; }
}

/* ---------- Список точек ---------- */
.places {
  display: grid;
  gap: 10px;
}

.place {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: baseline;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-left: 3px solid var(--tone, var(--border));
}

.place--best {
  background: color-mix(in srgb, var(--tone, var(--aurora-teal)) 10%, transparent);
  border-color: color-mix(in srgb, var(--tone, var(--aurora-teal)) 45%, transparent);
}

.place__name {
  font-size: 17px;
  font-weight: 650;
  color: var(--text);
}

.place__level {
  font-size: 14px;
  font-weight: 650;
  color: var(--tone, var(--text));
  white-space: nowrap;
}

.place__facts,
.place__travel {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.place__travel { color: var(--text-faint); }

@media (max-width: 480px) {
  .place { grid-template-columns: 1fr; }
  .place__level { grid-row: 1; justify-self: start; }
}

/* ---------- Прогноз ---------- */
.forecast {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}

.slot {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.slot--now { border-color: color-mix(in srgb, var(--aurora-teal) 55%, transparent); }

.slot__time {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}

.slot__kp {
  font-size: 27px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--tone, var(--text));
}

.slot__day {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: capitalize;
}

/* ---------- Подвал ---------- */
.foot {
  margin-top: 28px;
  font-size: 13px;
  color: var(--text-faint);
}

.foot p { margin: 4px 0; }
.foot__note { color: var(--text-faint); }
.foot a { color: var(--aurora-teal); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* Панель вкладки фокусируется с клавиатуры (Tab из вкладок ведёт в неё),
   но кольцо вокруг всей страницы было бы шумом — показываем тонкую линию. */
[role="tabpanel"]:focus-visible {
  outline: 1px solid rgba(53, 214, 232, 0.35);
  outline-offset: 4px;
  border-radius: 12px;
}
