:root {
  --bg-deep:      #07090f;
  --bg-mid:       #0d1526;
  --bg-card:      rgba(255,255,255,0.05);
  --border-glass: rgba(255,255,255,0.10);
  --accent:       #38bdf8;
  --accent-warm:  #fb923c;
  --accent-green: #4ade80;
  --text-primary: #e2e8f0;
  --text-muted:   #64748b;
  --text-dim:     #94a3b8;
  --danger:       #f87171;
  --radius-card:  18px;
  --radius-sm:    10px;
  --blur:         blur(16px);
  --transition:   0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Starfield canvas */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Gradient overlays */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 10%, rgba(14,165,233,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(99,102,241,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 50% 60% at 50% 50%, rgba(7,9,15,1) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

header {
  text-align: center;
  margin-bottom: 40px;
  animation: fadeDown 0.7s ease both;
}

header .logo-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 6px;
}

header .logo-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 0 12px var(--accent));
}

header h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #e2e8f0 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p.subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.search-section {
  animation: fadeDown 0.7s 0.1s ease both;
  margin-bottom: 20px;
}

.search-bar {
  display: flex;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 50px;
  padding: 8px 8px 8px 20px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.15);
}

#city-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  color: var(--text-primary);
  min-width: 0;
}

#city-input::placeholder { color: var(--text-muted); }

#search-btn {
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #07090f;
  border: none;
  border-radius: 40px;
  padding: 10px 24px;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

#search-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(56,189,248,0.35);
}

#search-btn:active { transform: translateY(0); }

#error-msg {
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(248,113,113,0.12);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: var(--danger);
  font-size: 0.9rem;
  margin-bottom: 16px;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%,100% { transform: translateX(0);  }
  25%     { transform: translateX(-6px); }
  75%     { transform: translateX( 6px); }
}

.history-section {
  margin-bottom: 30px;
  animation: fadeDown 0.7s 0.15s ease both;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.history-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

#clear-history-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
  transition: color var(--transition);
  padding: 4px;
}

#clear-history-btn:hover { color: var(--danger); }

#history-list {
  list-style: none;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition);
}

.history-chip:hover {
  background: rgba(56,189,248,0.1);
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Loading spinner */
#loader {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 20px;
  animation: fadeUp 0.3s ease both;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(56,189,248,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { 
  to { transform: rotate(360deg); } 
}

#loader p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Current weather */
#current-weather {
  display: none;
  margin-bottom: 30px;
  animation: fadeUp 0.5s ease both;
}

.current-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-card);
  padding: 28px 32px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  position: relative;
  overflow: hidden;
}

.current-card::before {
  content: '';
  position: absolute;
  top: -40px; 
  right: -40px;
  width: 200px; 
  height: 200px;
  background: radial-gradient(circle, rgba(56,189,248,0.12), transparent 70%);
  pointer-events: none;
}

.current-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.current-left .city-name {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.current-left .weather-date {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

.current-left .weather-desc {
  color: var(--text-dim);
  font-size: 1rem;
  margin-top: 8px;
  text-transform: capitalize;
}

.current-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.current-right img {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 0 12px rgba(56,189,248,0.4));
}

.current-right .temp-big {
  font-family: 'Syne', sans-serif;
  font-size: clamp(2.8rem, 6vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: #fff;
}

.current-right .temp-unit {
  font-size: 1.5rem;
  color: var(--text-muted);
  align-self: flex-start;
  padding-top: 8px;
}

/* Stats grid */
.current-stats {
  display: flex;
  gap: 16px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.stat-chip {
  flex: 1;
  min-width: 120px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-icon { font-size: 1.3rem; }

.stat-info .stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.stat-info .stat-value {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* Forecast */
#forecast-section {
  display: none;
  animation: fadeUp 0.5s 0.1s ease both;
}

.section-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

#forecast-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.forecast-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-card);
  padding: 18px 14px;
  text-align: center;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: transform var(--transition), border-color var(--transition),
              box-shadow var(--transition);
  animation: fadeUp 0.4s ease both;
  cursor: default;
}

.forecast-card:nth-child(1) { animation-delay: 0.05s; }
.forecast-card:nth-child(2) { animation-delay: 0.10s; }
.forecast-card:nth-child(3) { animation-delay: 0.15s; }
.forecast-card:nth-child(4) { animation-delay: 0.20s; }
.forecast-card:nth-child(5) { animation-delay: 0.25s; }

.forecast-card:hover {
  transform: translateY(-4px);
  border-color: rgba(56,189,248,0.35);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.forecast-card .fc-day {
  font-family: 'Syne', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.forecast-card img {
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 0 6px rgba(56,189,248,0.3));
}

.forecast-card .fc-temp {
  font-family: 'Syne', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  margin: 6px 0 2px;
}

.forecast-card .fc-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: capitalize;
  margin-bottom: 10px;
}

.forecast-card .fc-humidity {
  font-size: 0.8rem;
  color: var(--accent-warm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Animations */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0);     }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0);    }
}

/* Responsive */
@media (max-width: 540px) {
  .current-top    { flex-direction: column; }
  .current-right  { justify-content: flex-start; }
  .current-stats  { gap: 10px; }
  #forecast-cards { grid-template-columns: repeat(2, 1fr); }
}

/* Scrollbar */
::-webkit-scrollbar            { width: 6px; }
::-webkit-scrollbar-track      { background: var(--bg-deep); }
::-webkit-scrollbar-thumb      { background: #1e293b; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover{ background: #334155; }
