/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Скрытие через класс (не через атрибут hidden, чтобы display не перебивался) ── */
.is-hidden { display: none !important; }

/* ── Body ── */
body {
  font-family: 'Rubik', sans-serif;
  background: #f2f2f0;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(12px, 3vw, 40px);
}

/* ══════════════════════════════
   Card
══════════════════════════════ */
.wx-card {
  background: #fff;
  border-radius: 16px;
  border: 0.5px solid rgba(0, 0, 0, 0.1);
  padding: clamp(14px, 3vw, 24px);
  width: 100%;
  max-width: 900px;
}

/* ══════════════════════════════
   Search
══════════════════════════════ */
.wx-search {
  position: relative;
  margin-bottom: 4px;
}

.wx-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.wx-search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.wx-search-icon {
  position: absolute;
  left: 11px;
  font-size: 18px;
  color: #bbb;
  pointer-events: none;
  line-height: 1;
  top: 50%;
  transform: translateY(-50%);
}

.wx-search-input {
  font-family: 'Rubik', sans-serif;
  font-size: clamp(13px, 2vw, 15px);
  width: 100%;
  padding: 10px 36px 10px 36px;
  border-radius: 10px;
  border: 0.5px solid rgba(0, 0, 0, 0.18);
  background: #fafaf8;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.15s;
}
.wx-search-input::placeholder { color: #bbb; }
.wx-search-input:focus        { border-color: #80b4f0; background: #fff; }

.wx-clear-btn {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: #bbb;
  padding: 4px;
  line-height: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wx-clear-btn:hover { color: #888; }

.wx-search-btn {
  font-family: 'Rubik', sans-serif;
  font-size: clamp(12px, 1.8vw, 14px);
  font-weight: 500;
  padding: 10px clamp(14px, 2.5vw, 22px);
  border-radius: 10px;
  border: none;
  background: #1a1a1a;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
  flex-shrink: 0;
}
.wx-search-btn:hover    { background: #333; }
.wx-search-btn:active   { transform: scale(0.97); }
.wx-search-btn:disabled { background: #ccc; cursor: default; }

/* ── Suggestions dropdown ── */
.wx-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 0.5px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  list-style: none;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.wx-suggestions li {
  padding: 10px 14px;
  font-size: clamp(12px, 1.8vw, 14px);
  color: #1a1a1a;
  cursor: pointer;
  border-bottom: 0.5px solid rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.wx-suggestions li:last-child { border-bottom: none; }
.wx-suggestions li:hover      { background: #f5f5f3; }

.wx-suggestions li .sug-sub {
  font-size: clamp(10px, 1.4vw, 11px);
  color: #aaa;
}

/* ══════════════════════════════
   Header (after load)
══════════════════════════════ */
.wx-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: clamp(14px, 2.5vw, 20px) 0 clamp(10px, 2vw, 16px);
}

.wx-title-wrap { flex: 1; min-width: 0; }

.wx-title {
  font-size: clamp(14px, 2.5vw, 18px);
  font-weight: 500;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wx-subtitle {
  font-size: clamp(10px, 1.5vw, 12px);
  color: #aaa;
  margin-top: 2px;
}

.breakpoint-tag {
  font-size: 10px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  background: #ddeeff;
  color: #1a4a8a;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ══════════════════════════════
   Loader
══════════════════════════════ */
.wx-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 0;
  color: #aaa;
  font-size: 13px;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid #e8e8e8;
  border-top-color: #80b4f0;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════
   Error
══════════════════════════════ */
.wx-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px 0;
  color: #c04040;
  font-size: clamp(12px, 1.8vw, 14px);
  text-align: center;
}

/* ══════════════════════════════
   Scroll + Grid
══════════════════════════════ */
.wx-scroll {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.wx-scroll::-webkit-scrollbar       { height: 3px; }
.wx-scroll::-webkit-scrollbar-track { background: transparent; }
.wx-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 2px; }

.wx-grid {
  display: grid;
  gap: clamp(2px, 0.5vw, 4px);
  min-width: 320px;
}

/* ── Time ── */
.wx-time {
  font-size: clamp(10px, 1.5vw, 13px);
  color: #888;
  text-align: center;
  padding: 3px 0 clamp(6px, 1.5vw, 12px);
  white-space: nowrap;
}

/* ── Icons ── */
.wx-icon {
  text-align: center;
  font-size: clamp(16px, 3.5vw, 26px);
  height: clamp(28px, 5vw, 42px);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Section labels ── */
.wx-section-label {
  font-size: clamp(10px, 1.5vw, 12px);
  color: #888;
  padding: clamp(8px, 1.5vw, 14px) 0 clamp(3px, 0.8vw, 5px);
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 5px;
}

.info-dot {
  width: clamp(12px, 2vw, 15px);
  height: clamp(12px, 2vw, 15px);
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(8px, 1.2vw, 10px);
  color: #bbb;
  flex-shrink: 0;
}

/* ── Tiles ── */
.tile {
  border-radius: clamp(4px, 1vw, 8px);
  text-align: center;
  padding: clamp(5px, 1.2vw, 10px) 2px;
  font-size: clamp(11px, 1.8vw, 15px);
  font-weight: 500;
  line-height: 1.2;
}

.tile-temp-pos  { background: #c8f0d8; color: #1a6b3a; }
.tile-temp-high { background: #a0e0b0; color: #155230; }
.tile-temp-neg  { background: #d0e4ff; color: #1a3060; }
.tile-feels-neg { background: #b8d4f0; color: #1a3d6b; }
.tile-feels-pos { background: #b0f0d0; color: #1a6b3a; }
.tile-wind-hi   { background: #f5e8a0; color: #6b4e0a; }
.tile-wind-lo   { background: #f0f0ee; color: #4a4a48; }
.tile-gust-hi   { background: #f0d890; color: #6b4e0a; font-style: italic; }
.tile-gust-lo   { background: #eeeeec; color: #4a4a48; font-style: italic; }
.tile-press     { background: #f0d8f0; color: #6b1a6b; }
.tile-humid     { background: #d0e8ff; color: #1a3d6b; }

/* ── Precipitation ── */
.precip-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: clamp(40px, 8vw, 60px);
  position: relative;
}

.precip-val {
  font-size: clamp(9px, 1.3vw, 11px);
  color: #bbb;
  position: absolute;
  top: 0;
  width: 100%;
  text-align: center;
  white-space: nowrap;
}
.precip-val.has-rain { color: #4a80b0; }

.precip-bar {
  background: #a8d0f0;
  border-radius: 3px 3px 0 0;
  width: 65%;
  margin-top: auto;
  min-height: 0;
}

/* ── Kp circles ── */
.tile-kp-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2px 0;
}

.tile-kp {
  border-radius: 50%;
  width: clamp(30px, 5vw, 44px);
  height: clamp(30px, 5vw, 44px);
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(11px, 1.8vw, 14px);
  font-weight: 500;
  color: #333;
}

/* Уровни Kp */
.tile-kp.kp-quiet    { border-color: #6db87a; color: #1a5c28; background: #eaf7ed; }
.tile-kp.kp-moderate { border-color: #d4a017; color: #6b4e0a; background: #fdf3d0; }
.tile-kp.kp-storm    { border-color: #d45050; color: #7a1a1a; background: #fde8e8; }

/* ══════════════════════════════
   Dark mode
══════════════════════════════ */
@media (prefers-color-scheme: dark) {
  body     { background: #1c1c1e; }
  .wx-card { background: #2c2c2e; border-color: rgba(255,255,255,0.08); }

  .wx-search-input {
    background: #3a3a3c;
    border-color: rgba(255,255,255,0.1);
    color: #f0f0f0;
  }
  .wx-search-input:focus      { border-color: #4a80c0; background: #404042; }
  .wx-search-input::placeholder { color: #666; }
  .wx-search-icon             { color: #666; }
  .wx-clear-btn               { color: #666; }
  .wx-clear-btn:hover         { color: #aaa; }
  .wx-search-btn              { background: #f0f0f0; color: #1a1a1a; }
  .wx-search-btn:hover        { background: #ddd; }

  .wx-suggestions {
    background: #3a3a3c;
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  }
  .wx-suggestions li          { color: #f0f0f0; border-bottom-color: rgba(255,255,255,0.06); }
  .wx-suggestions li:hover    { background: #48484a; }
  .wx-suggestions li .sug-sub { color: #666; }

  .wx-title         { color: #f0f0f0; }
  .wx-subtitle      { color: #666; }
  .wx-section-label { color: #666; }
  .breakpoint-tag   { background: #1a2e4a; color: #80b4f0; }
  .info-dot         { border-color: rgba(255,255,255,0.15); color: #555; }
  .wx-loader        { color: #555; }
  .spinner          { border-color: #3a3a3a; border-top-color: #4a80c0; }

  .tile-temp-pos  { background: #1a4a2e; color: #80e8a8; }
  .tile-temp-high { background: #1a5e38; color: #6de8a0; }
  .tile-temp-neg  { background: #1a2040; color: #80a0e0; }
  .tile-feels-neg { background: #1a2e4a; color: #80b4e8; }
  .tile-feels-pos { background: #1a4a34; color: #80e8b0; }
  .tile-wind-hi   { background: #4a3a0a; color: #f0d070; }
  .tile-wind-lo   { background: #2a2a28; color: #c0c0be; }
  .tile-gust-hi   { background: #4a380a; color: #e8c860; }
  .tile-gust-lo   { background: #2c2c2a; color: #b8b8b6; }
  .tile-press     { background: #3a1a3a; color: #e080e0; }
  .tile-humid     { background: #1a2c4a; color: #80b8f8; }
  .precip-bar     { background: #305880; }
  .tile-kp        { border-color: rgba(255,255,255,0.15); color: #ddd; }
  .tile-kp.kp-quiet    { border-color: #3a8a4a; color: #80e8a0; background: #1a3a22; }
  .tile-kp.kp-moderate { border-color: #a07010; color: #f0d070; background: #3a2e08; }
  .tile-kp.kp-storm    { border-color: #a03030; color: #f08080; background: #3a1a1a; }
}

/* ══════════════════════════════
   Responsive
══════════════════════════════ */
@media (max-width: 480px) {
  .wx-card { border-radius: 12px; }
  .wx-search-btn { padding: 10px 14px; }
}

@media (min-width: 901px) and (max-width: 1280px) {
  .tile { padding: 9px 4px; }
}

@media (min-width: 1281px) {
  .tile { padding: 10px 6px; font-size: 15px; }
}
