/* WeatherMove — styles */
:root {
  --bg:           #f4f6fa;
  --panel:        #ffffff;
  --ink:          #1c2433;
  --ink-soft:     #4a5468;
  --ink-mute:     #8892a6;
  --line:         #e3e8f0;
  --line-soft:    #eef1f6;
  --brand:        #1d3fa5;
  --brand-dark:   #142b78;
  --brand-mid:    #2e5bd6;
  --brand-soft:   #eef3ff;
  --accent-blue:  #2f7ae0;
  --accent-green: #2bb35b;
  --accent-purple:#8455d6;
  --accent-orange:#ef8a2c;
  --accent-red:   #e2473a;
  --shadow-sm:    0 1px 2px rgba(20,33,78,.04), 0 1px 3px rgba(20,33,78,.06);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: var(--brand-mid); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }

/* ── App scaffold ────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-rows: 68px auto 1fr;
  min-height: 100vh;
}

/* Mobile nav bar — hidden on desktop, shown in mobile/narrow-mobile */
.mobile-nav { display: none; }

/* ── Header ──────────────────────────────────────────────────────── */
.header {
  background: linear-gradient(180deg, #1d3fa5 0%, #15327f 100%);
  color: white;
  display: grid;
  grid-template-columns: 280px 1fr auto;
  align-items: center;
  padding: 0 24px 0 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 24px;
}
.brand-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.brand-name  { font-size: 22px; font-weight: 800; letter-spacing: -.01em; line-height: 1; }
.brand-tag   { font-size: 11px; font-weight: 500; color: rgba(255,255,255,.72); margin-top: 4px; letter-spacing: .01em; }

.nav { display: flex; gap: 8px; align-items: center; height: 100%; }
.nav button {
  font-size: 15px; font-weight: 500;
  color: rgba(255,255,255,.78);
  padding: 0 16px; height: 100%;
  position: relative;
  transition: color .15s;
}
.nav button:hover { color: white; }
.nav button.active { color: white; font-weight: 600; }
.nav button.active::after {
  content: '';
  position: absolute;
  left: 16px; right: 16px; bottom: 14px;
  height: 3px;
  background: white;
  border-radius: 2px;
}

.header-right { display: flex; align-items: center; gap: 16px; }
.unit-toggle, .days-toggle {
  display: flex;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  overflow: hidden;
}
.unit-toggle button, .days-toggle button {
  padding: 6px 14px;
  font-size: 13px; font-weight: 600;
  color: rgba(255,255,255,.75);
}
.unit-toggle button.active, .days-toggle button.active { background: white; color: var(--brand); }

/* ── Body grid ────────────────────────────────────────────────────── */
.body {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 11px;
  padding: 11px 19px 19px;
  align-items: start;
}
@media (max-width: 1400px) {
  .body   { grid-template-columns: 264px minmax(0, 1fr); }
  .header { grid-template-columns: 264px 1fr auto; }
  .nav button { padding: 0 11px; }
  .nav button.active::after { left: 11px; right: 11px; }
}

@media (max-width: 950px) {
  .body   { grid-template-columns: 248px minmax(0, 1fr); }
  .header { grid-template-columns: 248px 1fr auto; }
  .nav button { padding: 0 8px; }
  .nav button.active::after { left: 8px; right: 8px; }
  .header-right { gap: 10px; }
  .sb-section { padding: 14px 12px 16px; }
  .btn-my-location { padding: 7px 8px; font-size: 10px; }
}

/* ── Panel base ───────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  min-width: 0; /* let grid/flex parents shrink past content size */
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar   { display: grid; gap: 11px; }
.sb-section { padding: 18px 18px 20px; }
.sb-title  { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--ink-soft); margin: 0; }
.sb-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.btn-my-location {
  font-size: 11px; font-weight: 600;
  color: var(--brand-mid);
  padding: 9px 10px;
  border: 1px solid var(--brand-mid);
  border-radius: 5px;
  background: white;
  white-space: nowrap;
  transition: all .12s;
}
.btn-my-location:hover { background: var(--brand-soft); }
.btn-my-location:disabled { opacity: .45; cursor: not-allowed; }
.sb-sub    { font-size: 12px; color: var(--ink-mute); margin: 0 0 14px; }
.sb-label  { display: block; font-size: 12px; font-weight: 500; color: var(--ink-soft); margin: 14px 0 6px; }
.sb-label:first-child { margin-top: 0; }

/* Location list */
.loc-list  { display: grid; gap: 6px; margin-bottom: 12px; }
.loc-row   {
  display: grid;
  grid-template-columns: 18px 1fr auto 18px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background .12s;
}
.loc-row:hover { background: var(--line-soft); }
.loc-heart {
  width: 18px; height: 18px;
  display: grid; place-items: center;
  padding: 0;
  transition: transform .15s;
}
.loc-heart:hover { transform: scale(1.25); }
.loc-name  { font-size: 13.5px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loc-temp  { font-size: 13px; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.loc-remove {
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--ink-mute); font-size: 12px;
  transition: background .12s, color .12s;
}
.loc-remove:hover { background: #fbe2df; color: var(--accent-red); }

/* Buttons */
.btn-secondary {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: white; color: var(--ink-soft);
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all .12s;
}
.btn-secondary:hover { background: var(--brand-soft); border-color: var(--brand-mid); color: var(--brand); }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  width: 100%; padding: 12px;
  border-radius: 8px; background: var(--brand-mid);
  color: white; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .12s;
}
.btn-primary:hover { background: var(--brand); }

/* Search UI */
.search-ui { margin-top: 0; }
.search-input {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--brand-mid); border-radius: 8px;
  background: white; color: var(--ink);
  font-size: 13px; font-family: inherit;
  outline: none;
  transition: border-color .12s;
}
.search-input:focus { border-color: var(--brand); }
.search-dropdown {
  position: absolute;
  top: calc(100% + 4px); left: 0; right: 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(20,33,78,.12);
  z-index: 40;
  overflow: hidden;
  max-height: 280px;
  overflow-y: auto;
}
.search-result-item {
  display: block; width: 100%;
  padding: 9px 12px;
  text-align: left;
  font-size: 13px; color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
  transition: background .1s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--brand-soft); }
.search-result-item strong { font-weight: 600; }
.search-loading {
  padding: 10px 12px;
  font-size: 13px; color: var(--ink-mute);
  text-align: center;
}

/* View mode cards */
.vm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.vm-card {
  padding: 14px 12px 12px;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: white; cursor: pointer;
  position: relative; transition: all .15s; text-align: left;
}
.vm-card.active { border-color: var(--brand-mid); background: var(--brand-soft); }
.vm-card:disabled { opacity: .45; cursor: not-allowed; }
.vm-check {
  position: absolute; top: 8px; right: 8px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--brand-mid); color: white;
  display: none; place-items: center; font-size: 11px;
}
.vm-card.active .vm-check { display: grid; }
.vm-icon { height: 40px; display: grid; place-items: center; color: var(--ink-soft); margin-bottom: 8px; }
.vm-card.active .vm-icon { color: var(--brand-mid); }
.vm-name { font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.2; margin-bottom: 4px; }
.vm-desc { font-size: 11px; color: var(--ink-mute); line-height: 1.35; }

/* Select */
.select-wrap { position: relative; }
.select-wrap::after {
  content: '';
  position: absolute; right: 12px; top: 50%;
  width: 8px; height: 8px;
  border-right: 1.5px solid var(--ink-mute);
  border-bottom: 1.5px solid var(--ink-mute);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select {
  width: 100%; padding: 9px 30px 9px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: white; color: var(--ink);
  font-size: 13px; font-family: inherit;
  appearance: none; cursor: pointer;
}
.select-wrap select:focus { outline: none; border-color: var(--brand-mid); }

/* ── Main area ────────────────────────────────────────────────────── */
.main { display: grid; gap: 11px; min-width: 0; }

.chart-card { padding: 18px 22px 18px; overflow: hidden; }
.chart-head {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 10px;
}
.chart-title { font-size: 14px; font-weight: 700; letter-spacing: .08em; color: var(--ink); margin: 0; }

/* ── 10-day overview table ──────────────────────────────────────── */
.ov-panel  { padding: 14px 16px 14px; }
.ov-scroll { overflow-x: auto; }
.ov-table  { width: 100%; border-collapse: collapse; }
.ov-loc-th { width: 130px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.ov-day-th {
  text-align: center; padding: 0 4px 8px;
  border-bottom: 1px solid var(--line);
  min-width: 74px;
}
.ov-dow  { font-size: 12px; font-weight: 700; color: var(--ink); }
.ov-date { font-size: 11px; color: var(--ink-mute); margin-top: 2px; }
.ov-loc-td { padding: 7px 8px 7px 0; border-top: 1px solid var(--line-soft); vertical-align: middle; }
.ov-loc-inner { display: flex; align-items: center; gap: 8px; max-width: 130px; }
.ov-loc-name  { font-size: 12px; font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ov-cell {
  text-align: center; vertical-align: middle;
  padding: 6px 4px;
  border-top: 1px solid var(--line-soft);
  border-left: 1px solid var(--line-soft);
}
.ov-icon  { display: flex; justify-content: center; align-items: center; margin-bottom: 3px; }
.ov-temps { font-size: 12px; font-weight: 600; white-space: nowrap; }
.ov-hi    { color: #e2473a; }
.ov-sep   { color: var(--ink-mute); font-weight: 400; }
.ov-lo    { color: #2f7ae0; }
.ov-rain  { font-size: 11px; color: var(--ink-mute); margin-top: 2px; white-space: nowrap; }
.chart-toolbar { display: flex; gap: 6px; align-items: center; }
.tool-btn {
  width: 32px; height: 28px; border-radius: 6px;
  border: 1px solid var(--line); background: white;
  display: grid; place-items: center;
  color: var(--ink-mute); transition: all .12s; cursor: pointer;
}
.tool-btn:hover { color: var(--ink); border-color: var(--ink-mute); }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.legend-item .legend-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-mute); }
.legend-item.muted { color: var(--ink-mute); }
.legend-item.muted .legend-dot { background: #c8d0dd; }

.chart-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
@media (max-width: 849px) { .chart-grid-2 { grid-template-columns: 1fr; } }

/* Dedicated location panel */
.loc-panel { padding: 16px 18px 18px; }
.loc-panel-head {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 14px;
}
.loc-panel-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 15px; font-weight: 600; color: var(--ink);
}
.loc-panel-charts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}
@media (max-width: 1599px) { .loc-panel-charts { grid-template-columns: minmax(0, 1fr); } }

.mini-chart-title { font-size: 12.5px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.mini-legend      { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; font-size: 11px; }

/* ── Advertisement ────────────────────────────────────────────────── */
.ad-label { font-size: 10px; font-weight: 600; letter-spacing: .12em; color: var(--ink-mute); text-align: center; }
.ad-card  {
  padding: 28px 20px;
  text-align: center;
  background: linear-gradient(180deg, #cfe1f4 0%, #aac6e5 100%);
  border-radius: 10px; color: #142b78;
  min-height: 460px;
  display: flex; flex-direction: column; align-items: center;
  position: relative; overflow: hidden;
}
.ad-headline { font-size: 22px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.ad-cta      { font-size: 18px; font-weight: 700; color: var(--brand-mid); margin: 18px 0 10px; line-height: 1.25; }
.ad-bullets  { font-size: 13px; line-height: 1.85; color: #2a3a6e; }
.ad-button   {
  margin-top: 18px; padding: 12px 22px;
  background: var(--brand-mid); color: white;
  font-size: 14px; font-weight: 600;
  border-radius: 6px; cursor: pointer;
  transition: background .12s;
}
.ad-button:hover { background: var(--brand); }
.ad-photo {
  margin-top: auto; align-self: stretch;
  height: 180px; border-radius: 6px;
  background: linear-gradient(180deg, rgba(20,43,120,0) 30%, rgba(20,43,120,.15) 100%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 200'><defs><linearGradient id='sky' x1='0' x2='0' y1='0' y2='1'><stop offset='0' stop-color='%2384a8c8'/><stop offset='1' stop-color='%23c5dceb'/></linearGradient><linearGradient id='mtn' x1='0' x2='0' y1='0' y2='1'><stop offset='0' stop-color='%23495b6f'/><stop offset='1' stop-color='%23394d65'/></linearGradient><linearGradient id='water' x1='0' x2='0' y1='0' y2='1'><stop offset='0' stop-color='%23647ea0'/><stop offset='1' stop-color='%23304e72'/></linearGradient></defs><rect width='400' height='110' fill='url(%23sky)'/><polygon points='0,110 80,40 150,70 220,30 290,80 360,50 400,90 400,120 0,120' fill='url(%23mtn)'/><polygon points='40,110 110,60 180,90 260,55 330,95 400,75 400,130 0,130' fill='%23586c87' opacity='.85'/><rect y='110' width='400' height='90' fill='url(%23water)'/><polygon points='0,110 80,180 150,150 220,190 290,140 360,170 400,130 400,200 0,200' fill='%23304e72' opacity='.5'/></svg>");
  background-size: cover; background-position: center;
}

/* ── Site footer banner ───────────────────────────────────────────── */
.site-footer {
  background: var(--brand);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: rgba(255,255,255,.8);
  flex-wrap: wrap;
}
.footer-credit {
  display: flex; align-items: center; gap: 8px;
}
.footer-credit a {
  color: white; font-weight: 600;
  text-decoration: underline;
}
.footer-contact {
  color: white; font-weight: 600; font-size: 12px;
  padding: 5px 16px;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 6px;
  white-space: nowrap;
  transition: background .12s;
}
.footer-contact:hover { background: rgba(255,255,255,.12); }

/* ── Loading / empty states ───────────────────────────────────────── */
.loading-spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--brand-mid);
  animation: spin .8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loc-loading-dot {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--brand-mid);
  animation: spin .8s linear infinite;
  vertical-align: middle;
}

/* ── Mobile layout (529px – 849px) ───────────────────────────────── */
@media (min-width: 529px) and (max-width: 849px) {

  /* Single-column body: sidebar stacks above main */
  .body {
    grid-template-columns: 1fr;
    padding: 8px 10px 14px;
  }

  /* Sidebar: Locations + View Mode side by side, ad full-width below */
  .sidebar {
    grid-template-columns: 1fr 1fr;
  }
  .sb-ad {
    grid-column: 1 / -1;
    padding: 10px 12px !important;
  }

  /* Ad card: horizontal layout — photo left, text right */
  .sb-ad .ad-card {
    display: grid;
    grid-template-columns: 110px 1fr;
    grid-template-rows: auto auto auto 1fr;
    min-height: 0;
    height: 120px;
    padding: 12px 14px;
    text-align: left;
    column-gap: 14px;
    align-items: start;
  }
  .sb-ad .ad-photo {
    grid-column: 1; grid-row: 1 / -1;
    height: auto; width: 100%; margin: 0;
    align-self: stretch; border-radius: 6px;
  }
  .sb-ad .ad-headline { grid-column: 2; grid-row: 1; font-size: 14px; }
  .sb-ad .ad-cta      { grid-column: 2; grid-row: 2; font-size: 12px; margin: 4px 0 2px; line-height: 1.2; }
  .sb-ad .ad-bullets  { grid-column: 2; grid-row: 3; font-size: 10px; line-height: 1.5; }
  .sb-ad .ad-button   { grid-column: 2; grid-row: 4; align-self: start; margin-top: 5px; padding: 5px 12px; font-size: 11px; }

  /* Sidebar panel padding reduction */
  .sb-section { padding: 14px 14px 16px; }

  /* Keep view mode cards side by side within their panel */
  .vm-grid { grid-template-columns: 1fr 1fr; }

  /* Dedicated charts: always single column on mobile */
  .loc-panel-charts { grid-template-columns: minmax(0, 1fr); }

  /* Header: two-column (brand | header-right), hide the inline nav */
  .header { padding: 0 12px; grid-template-columns: 1fr auto; }
  .brand-tag { display: none; }
  .nav { display: none; }

  /* Mobile nav bar — identical button style to desktop nav */
  .mobile-nav {
    display: flex;
    gap: 8px;
    align-items: center;
    height: 44px;
    padding: 0 16px;
    background: linear-gradient(180deg, #15327f 0%, #112970 100%);
    border-bottom: 1px solid rgba(255,255,255,.12);
  }
  .mobile-nav button {
    font-size: 15px; font-weight: 500;
    color: rgba(255,255,255,.78);
    padding: 0 10px; height: 100%;
    position: relative;
    transition: color .15s;
  }
  .mobile-nav button:hover { color: white; }
  .mobile-nav button.active { color: white; font-weight: 600; }
  .mobile-nav button.active::after {
    content: '';
    position: absolute;
    left: 10px; right: 10px; bottom: 7px;
    height: 3px;
    background: white;
    border-radius: 2px;
  }
}

/* ── Narrow mobile (< 528px): no horizontal scroll down to 350px ────── */
@media (max-width: 528px) {

  /* Single-column body */
  .body { grid-template-columns: 1fr; padding: 6px 8px 10px; }

  /* Stack sidebar panels into a single column so vm-cards have room */
  .sidebar { grid-template-columns: 1fr; }

  /* Header: two-column, hide inline nav */
  .header { padding: 0 12px; grid-template-columns: 1fr auto; }
  .brand-tag { display: none; }
  .nav { display: none; }
  .brand             { padding-left: 4px; }
  .brand-name        { font-size: 17px; }
  .unit-toggle button, .days-toggle button { padding: 5px 8px; font-size: 12px; }

  /* Mobile nav bar */
  .mobile-nav {
    display: flex;
    gap: 8px;
    align-items: center;
    height: 44px;
    padding: 0 16px;
    background: linear-gradient(180deg, #15327f 0%, #112970 100%);
    border-bottom: 1px solid rgba(255,255,255,.12);
  }
  .mobile-nav button {
    font-size: 15px; font-weight: 500;
    color: rgba(255,255,255,.78);
    padding: 0 10px; height: 100%;
    position: relative;
    transition: color .15s;
  }
  .mobile-nav button:hover { color: white; }
  .mobile-nav button.active { color: white; font-weight: 600; }
  .mobile-nav button.active::after {
    content: '';
    position: absolute;
    left: 10px; right: 10px; bottom: 7px;
    height: 3px;
    background: white;
    border-radius: 2px;
  }

  /* Panel padding: a touch tighter */
  .sb-section { padding: 12px 12px 14px; }

  /* Ad: reduce photo column so text has room on narrow screens */
  .sb-ad .ad-card { grid-template-columns: 90px 1fr; min-height: 0; height: 75px; }
}
