:root {
  --color-bg: #0ea5e9;
  --color-bg-dark: #0369a1;
  --color-card: #ffffff;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-accent: #38bdf8;
  --color-chart: #0ea5e9;
  --radius: 16px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, var(--color-bg), var(--color-bg-dark));
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

h1 {
  font-size: 1.75rem;
  margin: 0;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.city {
  font-size: 1.25rem;
  font-weight: 600;
  color: #ffffff;
}

.updated {
  font-size: 0.875rem;
  color: #bae6fd;
}

/* Przełącznik jednostek */
.unit-toggle {
  margin-top: 10px;
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.15);
  padding: 4px;
  border-radius: 8px;
}

.unit-btn {
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.unit-btn:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.2);
}

.unit-btn.active {
  color: #ffffff;
  background: rgba(255,255,255,0.25);
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Ładowanie */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 16px;
  color: #ffffff;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Błąd i fallback */
.error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #ffffff;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.search-fallback {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 20px;
  border-radius: var(--radius);
  color: #ffffff;
}

.search-fallback label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 8px;
  opacity: 0.9;
}

.search-input {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.search-input input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: none;
  outline: none;
  font-size: 1rem;
}

.search-input button {
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  background: #ffffff;
  color: var(--color-bg-dark);
  font-weight: 600;
  cursor: pointer;
}

.search-input button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Karta bieżącej pogody */
.current-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.temp-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.temp-big {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
}

.weather-icon {
  font-size: 3rem;
}

.description {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--color-muted);
}

.details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  border-top: 1px solid #e2e8f0;
  padding-top: 20px;
}

.detail {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
}

.value {
  font-size: 1.1rem;
  font-weight: 600;
}

/* Prognoza 3 dni */
.forecast h2 {
  font-size: 1.1rem;
  margin: 0 0 12px 0;
  color: var(--color-text);
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.forecast-card {
  background: var(--color-card);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: 0 4px 12px -4px rgba(0,0,0,0.1);
}

.forecast-day {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-muted);
  margin-bottom: 8px;
}

.forecast-icon {
  font-size: 1.75rem;
  margin-bottom: 6px;
}

.forecast-temp {
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.forecast-temp .max {
  color: var(--color-text);
}

.forecast-temp .min {
  color: var(--color-muted);
}

.forecast-precip {
  font-size: 0.8rem;
  color: var(--color-accent);
  font-weight: 600;
}

/* Wykres temperatury */
.chart-section {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
  margin-top: 16px;
}

.chart-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.chart-header h2 {
  font-size: 1.1rem;
  margin: 0;
  color: var(--color-text);
}

.chart-day-selector {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.chart-day-selector::-webkit-scrollbar {
  height: 6px;
}

.chart-day-selector::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.chart-day-selector::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.chart-day-btn {
  flex: 0 0 auto;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.chart-day-btn:hover {
  background: #f1f5f9;
  color: var(--color-text);
}

.chart-day-btn.active {
  background: var(--color-bg);
  color: #ffffff;
  border-color: var(--color-bg);
}

.chart-container {
  position: relative;
  width: 100%;
  height: 240px;
}

.chart-container canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 8px;
}

.chart-now {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--color-muted);
  text-align: center;
}

/* Prognoza godzinowa */
.hourly-section {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow);
  margin-top: 16px;
}

.hourly-section h2 {
  font-size: 1.1rem;
  margin: 0 0 14px 0;
  color: var(--color-text);
}

.hourly-days {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.hourly-day {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.hourly-day-header {
  font-weight: 700;
  text-align: center;
  margin-bottom: 10px;
  font-size: 0.95rem;
  color: var(--color-text);
  border-bottom: 2px solid var(--color-bg);
  padding-bottom: 6px;
}

.hour-grid {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 0 8px 0;
  scrollbar-width: thin;
}

.hour-grid::-webkit-scrollbar {
  height: 6px;
}

.hour-grid::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.hour-grid::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.hour-card {
  flex: 0 0 auto;
  width: 52px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 4px;
  text-align: center;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hour-time {
  font-weight: 700;
  color: var(--color-muted);
  font-size: 0.8rem;
}

.hour-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.hour-temp {
  font-weight: 700;
  color: var(--color-text);
}

.hour-precip {
  color: var(--color-accent);
  font-weight: 600;
  font-size: 0.7rem;
}

/* Footer */
footer {
  margin-top: auto;
  padding: 16px;
  font-size: 0.75rem;
  color: #bae6fd;
  text-align: center;
}

footer a {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* Ukrywanie elementów */
.hidden {
  display: none !important;
}

/* Responsywność – mniejsze ekrany */
@media (max-width: 480px) {
  .temp-big { font-size: 3.25rem; }
  .forecast-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .forecast-card { padding: 10px 6px; }
  .hourly-days { grid-template-columns: 1fr; }
  .chart-container { height: 200px; }
}