:root {
  --bg: #f0f2f5;
  --header-bg: #1a1a2e;
  --header-text: #eee;
  --text: #222;
  --text-muted: #666;
  --border: #e0e0e0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

header h1 {
  font-size: 1.25rem;
  white-space: nowrap;
}

.search-container {
  position: relative;
  display: flex;
  gap: 0.5rem;
}

#search-input {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  width: 260px;
}

#search-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  background: #0d47a1;
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
}

#search-btn:hover { background: #1565c0; }
#search-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  color: var(--text);
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  max-height: 360px;
  overflow-y: auto;
}

.dropdown-item {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: #f5f7fa; }

.hidden { display: none; }

main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 1rem auto;
  padding: 0 1rem;
  overflow-x: auto;
}

.location-bar {
  background: #fff;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.location-bar .city-name {
  color: var(--text);
  font-weight: 600;
  font-size: 1.1rem;
}

.error-msg {
  background: #ffebee;
  color: #c62828;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

#forecast-container {
  position: relative;
  min-width: 800px;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  overflow: hidden;
}

.hover-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 140, 0, 0.8);
  pointer-events: none;
  z-index: 10;
}

.hover-tooltip {
  position: absolute;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.78rem;
  line-height: 1.6;
  pointer-events: none;
  z-index: 11;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  white-space: nowrap;
}

.tt-time {
  font-weight: 600;
  font-size: 0.82rem;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid #eee;
}

.tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
}

.tt-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.tt-val {
  margin-left: auto;
  font-weight: 600;
  padding-left: 12px;
}

.tt-sep {
  height: 1px;
  background: #eee;
  margin: 3px 0;
}

#day-strip {
  display: grid;
  border-bottom: 1px solid var(--border);
}

.day-col {
  text-align: center;
  padding: 10px 2px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.day-col:last-child { border-right: none; }
.day-col.alt { background: rgba(0,0,0,0.02); }

.day-date {
  font-size: 0.85rem;
  font-weight: 600;
}

.day-hilo {
  font-size: 0.8rem;
}

.day-hilo .hi { color: #e65100; font-weight: 600; }
.day-hilo .lo { color: #1565c0; }

.day-icon {
  font-size: 2.2rem;
  line-height: 1.1;
}

.day-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.2;
  max-width: 90px;
}

.day-precip {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chart-section {
  border-bottom: 1px solid var(--border);
}

.chart-section:last-child { border-bottom: none; }

.chart-section canvas {
  display: block;
  width: 100%;
}

.chart-legend {
  text-align: center;
  padding: 6px 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid #f0f0f0;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0 10px;
  white-space: nowrap;
}

.legend-swatch {
  display: inline-block;
  width: 14px;
  height: 10px;
  border-radius: 2px;
}

footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

footer a { color: #1565c0; }

@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: stretch;
  }
  #search-input {
    flex: 1;
    width: auto;
  }
}
