:root {
  --bg-gradient-start: #4a90e2;
  --bg-gradient-end: #9013fe;
  --page-bg: #dfe7f0;
  --card-bg: #ffffff;
  --surface-bg: #eef2f7;
  --surface-border: rgba(15, 23, 42, 0.07);
  --text-primary: #1a202c;
  --text-muted: #718096;
  --accent: #4a90e2;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.1);
}

[data-theme="dark"] {
  --page-bg: #0a0e16;
  --card-bg: #141a24;
  --surface-bg: #1d2532;
  --surface-border: rgba(255, 255, 255, 0.08);
  --text-primary: #edf2f7;
  --text-muted: #8b98ab;
  --accent: #6ea8f5;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  height: -webkit-fill-available;
}

html {
  font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  touch-action: manipulation;
}

body {
  font-family: inherit;
  background: var(--page-bg);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.container {
  width: 100%;
  background: var(--card-bg);
  border-radius: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  padding-top: calc(1.25rem + env(safe-area-inset-top, 0));
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0));
  min-height: 100%;
  min-height: -webkit-fill-available;
  transition: background 0.2s ease;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes spinIn {
  from { transform: rotate(-45deg) scale(0.7); opacity: 0; }
  to { transform: rotate(0) scale(1); opacity: 1; }
}

header {
  position: relative;
  text-align: center;
  margin-bottom: 1.75rem;
  flex-shrink: 0;
  animation: cardIn 0.4s ease;
}

header h1 {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.theme-toggle {
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  border: 1px solid var(--surface-border);
  border-radius: 50%;
  background: var(--surface-bg);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}

.theme-toggle:active {
  transform: scale(0.88) rotate(-15deg);
}

.theme-toggle .icon-swap {
  display: inline-block;
  animation: spinIn 0.35s ease;
}

.status-card {
  background: var(--surface-bg);
  border-radius: 16px;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  border: 2px dashed var(--surface-border);
  box-shadow: var(--shadow-sm);
  animation: cardIn 0.4s ease;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.status-card.error {
  border-color: #fc8181;
  background: rgba(252, 129, 129, 0.1);
}

.status-icon {
  font-size: 3rem;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.status-text p:first-child {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  min-height: 48px;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--accent);
  color: white;
  align-self: center;
  width: 100%;
  max-width: 280px;
}

.btn.primary:hover {
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
}

.btn.secondary {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  font-size: 1.3rem;
  padding: 0.4rem;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}

.btn.secondary:active {
  transform: scale(0.9) rotate(45deg);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.weather-card {
  animation: cardIn 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.weather-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(150deg, var(--bg-gradient-start), var(--bg-gradient-end));
  background-size: 200% 200%;
  animation: gradientDrift 8s ease infinite;
  border-radius: 20px;
  padding: 1.25rem 1.25rem 1.75rem;
  color: #fff;
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
}

@keyframes gradientDrift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.weather-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.weather-header h2 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
  color: #fff;
}

.weather-header .muted {
  color: rgba(255, 255, 255, 0.75);
}

.weather-hero .btn.secondary {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.current-weather {
  text-align: center;
  padding-top: 0.5rem;
}

.temp-main {
  font-size: 4rem;
  font-weight: 200;
  line-height: 1;
}

.temp-main .unit {
  font-size: 1.5rem;
  vertical-align: super;
}

.weather-description {
  font-size: 1.1rem;
  margin-top: 0.35rem;
  color: rgba(255, 255, 255, 0.92);
}

.weather-icon {
  font-size: 3.25rem;
  margin-bottom: 0.25rem;
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.detail-item {
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.15s ease;
}

.detail-item:active {
  transform: scale(0.96);
}

.detail-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.daily-forecast h3 {
  font-size: 1rem;
  margin-bottom: 0.85rem;
}

.forecast-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.forecast-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  background: var(--surface-bg);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  font-size: 0.9rem;
  opacity: 0;
  animation: cardIn 0.35s ease forwards;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.15s ease;
}

.forecast-item:active {
  transform: scale(0.97);
}

.forecast-day {
  font-weight: 600;
  min-width: 80px;
}

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

.forecast-temps {
  display: flex;
  gap: 0.5rem;
  min-width: 80px;
  justify-content: flex-end;
}

.forecast-max {
  font-weight: 600;
}

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

.hidden {
  display: none;
}

footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

footer a {
  color: var(--accent);
}

.install-prompt {
  background: linear-gradient(135deg, #4a90e2, #9013fe);
  border-radius: 16px;
  padding: 1rem;
  margin-top: 1rem;
  box-shadow: 0 8px 24px rgba(74, 144, 226, 0.3);
  animation: slideUp 0.4s ease;
}

.install-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.install-icon {
  font-size: 2rem;
}

.install-text {
  flex: 1;
  color: white;
}

.install-title {
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.install-desc {
  font-size: 0.8rem;
  opacity: 0.9;
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  min-height: 44px;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.3);
}