:root {
  --bg: #ffffff;
  --card: #f6f8fb;
  --border: #dde6f2;
  --text: #1f2937;
  --muted: #64748b;
  --accent: #2f6feb;
  --wind: #0f5ed7;
  --danger: #c83535;
  --warn: #9a6b16;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --card-radius: 18px;
  --card-shadow: 0 6px 16px rgba(15, 23, 42, 0.07);
  --card-border: none;
  --headline-weight: 650;
  --metric-weight: 800;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
  transition: background-color 180ms ease, color 180ms ease;
}

a {
  color: var(--accent);
}

.top {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1rem 0.5rem;
  text-align: left;
}

.top h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.8vw, 2.2rem);
  font-weight: var(--headline-weight);
  letter-spacing: -0.02em;
}

.sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.sub-spots,
.sub-sources {
  margin: 0;
}

.sub-spots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.45rem;
  margin-bottom: 0.28rem;
}

.spot-jump {
  display: inline-block;
  text-decoration: none;
  font-size: 0.76rem;
  padding: 0.2rem 0.48rem;
  border-radius: 999px;
  border: 1px solid #cfdcf0;
  background: #f3f8ff;
  color: #355276;
  text-transform: uppercase;
  -webkit-tap-highlight-color: rgba(47, 111, 235, 0.18);
}

.spot-jump:hover {
  background: #e6f0ff;
}

.top-actions {
  margin-top: 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.install-app-btn {
  margin-top: 0;
  margin-left: 0;
  border: 1px solid #b8cff6;
  background: #eaf2ff;
  color: #1e40af;
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(47, 111, 235, 0.18);
}

.install-app-btn:hover {
  background: #dbe8ff;
}

.meta {
  margin: 0.55rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.meta-warn {
  margin-top: 0.4rem;
  color: var(--danger);
  display: none;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  max-width: 760px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border: var(--card-border);
  border-radius: var(--card-radius);
  padding: 1rem 1rem 0.85rem;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(5px);
  scroll-margin-top: 14px;
  transition: background-color 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-head h2 {
  margin: 0;
  font-size: 1.2rem;
  text-transform: uppercase;
}

.badge {
  font-size: 0.78rem;
  color: var(--muted);
}

.card-head-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.spot-order-controls {
  display: inline-flex;
  gap: 0.25rem;
}

.spot-order-btn {
  border: 1px solid #d5dfec;
  background: #f7fbff;
  color: #475569;
  border-radius: 6px;
  width: 24px;
  height: 24px;
  line-height: 1;
  padding: 0;
  font-size: 0.8rem;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(47, 111, 235, 0.18);
}

.spot-order-btn:hover:not(:disabled) {
  background: #ebf3ff;
  color: #1f2937;
}

.spot-order-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Круг: карта OSM + ветер по мотивам neduet.ru */
.wind-map {
  position: relative;
  width: 100%;
  max-width: 255px;
  margin: 0.1rem auto 0.45rem;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid #d3dfef;
  box-shadow: 0 8px 24px rgba(30, 41, 59, 0.12);
}

.wind-map__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(160deg, #c8d8ea, #d9e7f5);
}

.wind-map__img {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.wind-map__img.wind-map__img--missing {
  display: none;
}

.wind-map__shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(
    ellipse 85% 85% at 50% 48%,
    rgba(255, 255, 255, 0.06) 0%,
    rgba(15, 23, 42, 0.2) 100%
  );
  pointer-events: none;
}

.wind-map__hud {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

.wind-map__corner {
  position: absolute;
  font-size: 0.85rem;
  font-weight: 700;
  color: #f8fbff;
  text-shadow: 0 1px 4px rgba(15, 23, 42, 0.55);
  z-index: 4;
}

.wind-map__corner--tr {
  top: 10px;
  right: 12px;
}

.wind-map__nums {
  text-align: center;
  padding: 0 0.5rem;
  z-index: 3;
  color: var(--wind);
}

.wind-map__minmax {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: #334155;
  text-shadow: 0 1px 4px rgba(15, 23, 42, 0.35);
  line-height: 1.3;
}

.wind-map__minmax--na {
  color: #475569;
  font-size: 0.62rem;
}

.wind-map__minmax--temp {
  color: #f8fbff;
  text-shadow: 0 1px 6px rgba(15, 23, 42, 0.55);
}

.wind-map__avg {
  display: block;
  font-size: clamp(1.6rem, 7.5vw, 2.15rem);
  font-weight: var(--metric-weight);
  letter-spacing: -0.03em;
  color: var(--wind);
  line-height: 1.15;
  text-shadow: 0 1px 6px rgba(15, 23, 42, 0.32);
  margin: 0.1rem 0;
}

.wind-map__avg-unit {
  font-size: 0.45em;
  font-weight: 600;
  color: inherit;
  margin-left: 0.1em;
}

.wind-map__arrow-layer {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  z-index: 1;
}

.wind-map__arrow {
  position: absolute;
  top: 1%;
  left: 50%;
  width: 0;
  height: 0;
  margin-left: -12px;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 40px solid #ef4444;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.35));
}

.wind-map__attr {
  margin: 0.2rem 0 0.35rem;
  font-size: 0.62rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
}

.wind-map__attr a {
  color: var(--muted);
}

.dir-summary {
  margin: 0 0 0.7rem;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
}

.temp-summary {
  margin: -0.35rem 0 0.7rem;
  font-size: 0.84rem;
  font-weight: 600;
  text-align: center;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
}

.stat-big {
  grid-column: 1 / -1;
  text-align: center;
  padding: 0.35rem 0;
}

.wind-line {
  font-size: clamp(2rem, 9vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--wind);
  line-height: 1.1;
}

.wind-line small {
  font-size: 0.45em;
  font-weight: 600;
  color: var(--muted);
  margin-left: 0.15em;
}

.stat {
  font-size: 0.9rem;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.dir-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.25rem 0 0.75rem;
}

.rose {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  background: #12161d;
}

.rose-arrow {
  font-size: 1.75rem;
  line-height: 1;
  transform: rotate(calc(var(--from-deg, 0) * 1deg + 180deg));
  display: inline-block;
  transition: transform 0.35s ease;
}

.dir-text {
  font-size: 1rem;
  font-weight: 600;
}

.chart-wrap {
  height: 140px;
  margin: 0 -0.15rem 0.55rem;
}

.chart-timezone {
  margin: -0.2rem 0 0.35rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.68rem;
}

.link-row {
  text-align: center;
  padding: 0.35rem 0 0.15rem;
  border-top: 1px solid #e7edf5;
  margin-top: 0.35rem;
}

.link-row a {
  font-size: 0.78rem;
}

.err {
  color: var(--danger);
  padding: 1rem;
  text-align: center;
}

.load {
  color: var(--muted);
  padding: 1rem 0.5rem;
  text-align: center;
  font-size: 0.95rem;
}

.spot-err {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0 0 0.55rem;
  line-height: 1.35;
  background: #fff1f1;
  border: 1px solid #ffd7d7;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
}

.spot-warn {
  color: var(--warn);
  font-size: 0.85rem;
  margin: 0 0 0.55rem;
  line-height: 1.35;
  background: #fff8e8;
  border: 1px solid #f4e4b6;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
}

.foot {
  padding: 1.25rem 1rem 2rem;
  max-width: 760px;
  margin: 0 auto;
  font-size: 0.75rem;
  color: var(--muted);
}

.foot .sub-sources {
  margin: 0 0 0.5rem;
  font-size: 0.74rem;
}

.foot > p:not(.sub-sources) {
  font-size: 0.7rem;
}

/* Active UI mode */
body[data-ui-mode='premium-v2'] {
  --bg: linear-gradient(180deg, #eef4ff 0%, #f9fbff 100%);
  --card: #ffffff;
  --text: #0f1f36;
  --muted: #536b8c;
  --accent: #1d4ed8;
  --wind: #124fc4;
  --card-radius: 14px;
  --card-shadow: 0 16px 34px rgba(31, 73, 140, 0.16);
  --card-border: 1px solid #cfdcf2;
  --headline-weight: 760;
  --metric-weight: 900;
}

body[data-ui-mode='premium-v2'] {
  background: var(--bg);
}

body[data-ui-mode='premium-v2'] .top {
  padding-top: 1.55rem;
}

body[data-ui-mode='premium-v2'] .top h1 {
  font-size: clamp(1.95rem, 4.5vw, 2.45rem);
  letter-spacing: -0.03em;
}

body[data-ui-mode='premium-v2'] .meta {
  font-size: 0.8rem;
  letter-spacing: 0.01em;
}

body[data-ui-mode='premium-v2'] .card-head h2 {
  font-size: 1.34rem;
  letter-spacing: -0.02em;
}

body[data-ui-mode='premium-v2'] .spot-jump,
body[data-ui-mode='premium-v2'] .spot-order-btn,
body[data-ui-mode='premium-v2'] .install-app-btn {
  background: linear-gradient(180deg, #fafdff, #e8f1ff);
  border-color: #b4c9eb;
  color: #1f4778;
}

body[data-ui-mode='premium-v2'] .wind-map {
  border-color: #b8cde9;
  box-shadow: 0 12px 28px rgba(51, 84, 134, 0.2);
}

body[data-ui-mode='premium-v2'] .wind-map__avg {
  text-shadow: 0 0 10px rgba(29, 78, 216, 0.22);
}

body[data-ui-mode='premium-v2'] .link-row {
  border-top-color: #cedcf0;
}

.foot .local {
  margin-top: 0.75rem;
  color: var(--text);
}

/* =======================
  Mobile audit improvements
  ======================= */
@media (max-width: 640px) {
  .top {
    padding: calc(0.75rem + env(safe-area-inset-top)) 0.8rem 0.45rem;
  }

  .top h1 {
    font-size: clamp(1.45rem, 6.2vw, 1.9rem);
    line-height: 1.18;
  }

  .sub {
    font-size: 0.74rem;
  }

  .spot-jump {
    min-height: 36px;
    padding: 0.38rem 0.62rem;
    font-size: 0.74rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .grid {
    padding: 0.7rem 0.7rem 1rem;
    gap: 0.75rem;
  }

  .card {
    padding: 0.8rem 0.8rem 0.7rem;
    border-radius: 12px;
  }

  .card-head {
    align-items: flex-start;
    gap: 0.55rem;
    margin-bottom: 0.6rem;
  }

  .card-head h2 {
    font-size: 1.05rem;
    line-height: 1.2;
  }

  .card-head-actions {
    gap: 0.35rem;
  }

  .spot-order-btn {
    width: 36px;
    height: 36px;
    font-size: 0.92rem;
  }

  .wind-map {
    max-width: 225px;
    margin-bottom: 0.35rem;
  }

  .wind-map__arrow {
    top: 2%;
    border-left-width: 11px;
    border-right-width: 11px;
    border-top-width: 34px;
  }

  .dir-summary,
  .temp-summary {
    margin-bottom: 0.55rem;
  }

  .chart-wrap {
    height: 130px;
    margin: 0 -0.25rem 0.45rem;
  }

  .link-row a {
    font-size: 0.82rem;
  }

  .foot {
    padding: 1rem 0.8rem calc(1.2rem + env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .top {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
  }

  .top h1 {
    font-size: clamp(1.3rem, 7.1vw, 1.65rem);
  }

  .sub-spots {
    gap: 0.3rem 0.35rem;
  }

  .spot-jump {
    min-height: 34px;
    padding: 0.34rem 0.54rem;
    font-size: 0.7rem;
  }

  .grid {
    padding-left: 0.6rem;
    padding-right: 0.6rem;
  }

  .card {
    padding: 0.72rem 0.72rem 0.65rem;
  }

  .card-head h2 {
    font-size: 0.97rem;
  }

  .wind-map {
    max-width: 205px;
  }

  .wind-map__avg {
    font-size: clamp(1.4rem, 8.8vw, 1.9rem);
  }

  .wind-map__minmax {
    font-size: 0.64rem;
  }

  .stats {
    gap: 0.5rem 0.55rem;
    margin-bottom: 0.6rem;
  }

  .dir-summary,
  .temp-summary {
    font-size: 0.8rem;
  }

  .chart-wrap {
    height: 122px;
  }
}

@media (max-width: 360px) {
  .card-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
  }

  .card-head-actions {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .wind-map {
    max-width: 194px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .spot-jump:hover,
  .spot-order-btn:hover:not(:disabled),
  .install-app-btn:hover {
    background: inherit;
    color: inherit;
  }

  .spot-jump:active,
  .spot-order-btn:active:not(:disabled),
  .install-app-btn:active {
    transform: translateY(0.5px);
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .top {
    padding-top: calc(0.5rem + env(safe-area-inset-top));
    padding-bottom: 0.35rem;
  }

  .grid {
    gap: 0.6rem;
    padding-top: 0.55rem;
  }

  .card {
    padding-top: 0.65rem;
    padding-bottom: 0.6rem;
  }

  .wind-map {
    max-width: 176px;
    margin-bottom: 0.25rem;
  }

  .chart-wrap {
    height: 110px;
    margin-bottom: 0.3rem;
  }
}

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