:root {
  --bg-1:#0a1a3d;
  --bg-2:#142a5e;
  --bg-3:#1e3a7a;
  --panel:rgba(255,255,255,0.04);
  --panel-strong:rgba(255,255,255,0.08);
  --panel-border:rgba(255,255,255,0.08);
  --text:#f5f8ff;
  --text-dim:rgba(245,248,255,0.7);
  --text-faint:rgba(245,248,255,0.5);
  --sun:#ffc857;
  --rain:#7cc7ff;
  --conf-high:#7ed957;
  --conf-med:#ffc857;
  --conf-low:#cfd8e8;
  --danger:#ff6b6b;
}
* { box-sizing: border-box; }
html, body {
  margin:0; padding:0;
  font-family: 'Inter Tight', system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse at top left, #1e3a7a 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, #0d2456 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--rain); text-decoration: none; }
a:hover { text-decoration: underline; }

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

/* HEADER */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 500;
  margin-bottom: 4px;
}
h1 {
  font-family: 'Fraunces', serif;
  font-weight: 300;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1; margin: 0;
  letter-spacing: -0.02em;
}
h1 em { font-style: italic; font-weight: 500; color: var(--sun); }
.unit-toggle {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 3px;
}
.unit-btn {
  border: 0; background: transparent; color: var(--text-dim);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: 999px;
  cursor: pointer; transition: all .2s ease;
}
.unit-btn.active { background: var(--sun); color: #0a1a3d; }

/* FORM */
.form-section {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 24px;
  backdrop-filter: blur(6px);
  margin-bottom: 24px;
}
.form-intro p {
  margin: 0 0 20px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
  max-width: 680px;
}
.legs { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.leg {
  display: grid;
  grid-template-columns: 32px 1fr 1fr 1fr 32px;
  gap: 10px;
  align-items: end;
}
.leg-num {
  font-family: 'Fraunces', serif;
  font-size: 22px; color: var(--text-faint);
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 6px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-faint); font-weight: 600;
}
.field input {
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit; font-size: 14px;
  padding: 10px 12px;
  transition: border-color .2s ease;
  width: 100%;
  color-scheme: dark;
}
.field input:focus {
  outline: none; border-color: var(--sun);
}
.city-field { position: relative; }
.suggestions {
  position: absolute; top: 100%; left: 0; right: 0;
  background: #1a2a55;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  margin-top: 4px;
  max-height: 240px; overflow-y: auto;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.suggestion {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover, .suggestion.active { background: rgba(255,200,87,0.15); }
.suggestion-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.remove-leg {
  background: transparent; border: 0; color: var(--text-faint);
  font-size: 22px; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  padding-bottom: 6px;
}
.remove-leg:hover { color: var(--danger); }
.form-actions {
  display: flex; gap: 10px; justify-content: space-between;
  flex-wrap: wrap;
}
.btn {
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent;
  transition: all .2s ease;
}
.btn-primary { background: var(--sun); color: #0a1a3d; border-color: var(--sun); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(255,200,87,0.3); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--panel-border); }
.btn-ghost:hover { background: var(--panel); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.form-error {
  background: rgba(255,107,107,0.1);
  border: 1px solid rgba(255,107,107,0.3);
  color: #ffb0b0;
  padding: 10px 14px; border-radius: 10px;
  font-size: 13px; margin-top: 14px;
}

/* LOADING */
.loading {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 60px 20px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,200,87,0.2);
  border-top-color: var(--sun);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-dim); font-size: 14px; }

/* RESULTS */
.results-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.results-title {
  font-family: 'Fraunces', serif; font-weight: 400;
  font-size: clamp(22px, 3vw, 30px);
  margin: 0; letter-spacing: -0.01em;
}
.results-actions { display: flex; gap: 8px; }

.scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -16px;
  padding: 0 16px 10px;
}
.scroll-wrap::-webkit-scrollbar { height: 6px; }
.scroll-wrap::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(120px, 1fr);
  gap: 8px;
  min-width: 100%;
}
.day {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 14px 8px 16px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  backdrop-filter: blur(6px);
  transition: transform .25s ease, background .25s ease;
  position: relative;
}
.day:hover { transform: translateY(-3px); background: var(--panel-strong); }
.conf-dot-day {
  position: absolute; top: 10px; right: 10px;
  width: 7px; height: 7px; border-radius: 50%;
}
.conf-dot-day.conf-high { background: var(--conf-high); }
.conf-dot-day.conf-med { background: var(--conf-med); }
.conf-dot-day.conf-low { background: var(--conf-low); opacity: 0.6; }

.dow { font-size: 11px; letter-spacing: 0.18em; font-weight: 600; color: var(--text-dim); }
.date { font-family: 'Fraunces', serif; font-size: 15px; font-weight: 500; margin-top: 2px; }
.city { font-size: 11px; color: var(--text-dim); margin-top: 6px; min-height: 28px; line-height: 1.25;
       overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 4px; }
.icon { margin: 10px 0 4px; height: 44px; display: flex; align-items: center; justify-content: center; }
.pop {
  font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums;
  display:flex; align-items:center; justify-content:center; gap:3px; margin-bottom: 8px;
}
.pop .drop { width:8px; height:10px; }
.pop .drop path { fill: var(--rain); }
.temps {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; margin: 4px 0 8px;
}
.hi { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 500; line-height: 1; }
.bar {
  width: 6px; height: 34px; border-radius: 10px;
  background: linear-gradient(180deg, #ffd58a 0%, #7cc7ff 100%);
  opacity: 0.85;
}
.lo { font-size: 14px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.spread {
  font-size: 10px; color: var(--text-faint);
  margin-top: 2px; font-variant-numeric: tabular-nums;
}

.footer {
  margin-top: 22px;
  display: flex; flex-wrap: wrap; gap: 12px 26px;
  font-size: 11.5px; color: var(--text-faint);
  padding: 0 4px;
}
.footer strong { color: var(--text-dim); font-weight: 600; }
.conf-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin: 0 4px; }
.conf-dot.conf-high { background: var(--conf-high); }
.conf-dot.conf-med { background: var(--conf-med); }
.conf-dot.conf-low { background: var(--conf-low); opacity: 0.6; }

.page-footer {
  margin-top: 40px; padding-top: 20px;
  border-top: 1px solid var(--panel-border);
  font-size: 12px; color: var(--text-faint);
  text-align: center;
}

@media (max-width: 720px) {
  .leg { grid-template-columns: 1fr; gap: 8px; }
  .leg-num { display: none; }
  .remove-leg { justify-self: end; padding: 0; }
  .results-header { flex-direction: column; align-items: stretch; }
  .results-actions { justify-content: flex-end; }
}
