:root {
  --bg: linear-gradient(180deg, #3b82f6 0%, #1e3a8a 100%);
  --fg: #fff;
  --muted: rgba(255, 255, 255, 0.72);
  --card: rgba(255, 255, 255, 0.14);
  --card-border: rgba(255, 255, 255, 0.18);
  --input: rgba(255, 255, 255, 0.2);
  color-scheme: dark;
}

body.night {
  --bg: linear-gradient(180deg, #1e293b 0%, #020617 100%);
  --card: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

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

body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: #1e3a8a var(--bg) fixed;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header / search */
.top {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search {
  position: relative;
  flex: 1;
}

.search input {
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--input);
  color: var(--fg);
  font-size: 16px; /* prevents iOS zoom on focus */
  outline: none;
}
.search input::placeholder { color: var(--muted); }

.results {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.results li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.results li:hover, .results li:focus { background: rgba(255, 255, 255, 0.1); outline: none; }
.results small { color: var(--muted); }

.icon-btn {
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  background: var(--input);
  color: var(--fg);
  font-size: 18px;
  cursor: pointer;
}
.icon-btn:active { transform: scale(0.95); }

.status {
  text-align: center;
  color: var(--muted);
  margin: 48px 0;
}

/* Current conditions */
.current {
  text-align: center;
  padding: 28px 0 20px;
}
.current h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
}
.big-icon { font-size: 64px; line-height: 1.2; margin-top: 8px; }
.big-temp { font-size: 88px; font-weight: 200; line-height: 1; margin-left: 0.2em; }
.desc { font-size: 20px; margin-top: 6px; }
.range { color: var(--muted); margin-top: 4px; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 12px 14px;
  margin-top: 12px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.card h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Hourly */
.hourly {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.hourly::-webkit-scrollbar { display: none; }
.hour {
  flex: none;
  width: 56px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0;
}
.hour .t { font-size: 13px; color: var(--muted); }
.hour .i { font-size: 24px; }
.hour .p { font-size: 11px; color: #93c5fd; min-height: 1em; }

/* Daily */
.daily {
  list-style: none;
  margin: 0;
  padding: 0;
}
.day {
  display: grid;
  grid-template-columns: 3.5em 2em 2.5em 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid var(--card-border);
}
.day:first-child { border-top: 0; }
.day .i { font-size: 22px; text-align: center; }
.day .p { font-size: 12px; color: #93c5fd; }
.day .temps {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}
.day .lo { color: var(--muted); width: 2.2em; text-align: right; }
.day .hi { width: 2.2em; text-align: right; }
.bar {
  flex: 1;
  height: 4px;
  max-width: 120px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.15);
  position: relative;
}
.bar span {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 2px;
  background: linear-gradient(90deg, #60a5fa, #facc15, #f97316);
}

/* Details grid */
.details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.detail .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.detail .value { font-size: 22px; margin-top: 2px; }

.credit {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 20px;
}
.credit a { color: inherit; }
