body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  margin: 0;
  padding: 0 1.5rem;
  background: #f0f4f8;
  color: #2d3748;
  width: 100vw;
  box-sizing: border-box;
  transition: background 0.3s ease, color 0.3s ease;
}

body.dark-mode {
  background: #1a202c;
  color: #e2e8f0;
}

h1 {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.5rem;
  transition: color 0.3s ease;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  text-align: left;
  margin: 0;
  font-size: 1.5rem;
  flex-grow: 1;
}

body.dark-mode .page-header h1 {
  color: #fff;
}

#settings-toggle-btn {
  font-size: 1.6rem;
  cursor: pointer;
  border: none;
  background-color: transparent !important;
  color: inherit;
  padding: 0.5rem;
  border-radius: 8px;
  transition: transform 0.3s ease, background-color 0.2s ease;
}

#settings-toggle-btn:hover {
  background-color: rgba(128, 128, 128, 0.15) !important;
}

#settings-toggle-btn.spinning {
  animation: gear-spin 0.5s linear;
}

@keyframes gear-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================
   SETTINGS MENU - MODERN CARD-BASED DESIGN
   ============================================ */

#settings-menu {
  max-width: calc(100vw - 3rem);
  margin: 0 auto 2rem auto;
  border-radius: 16px;
  background: white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode #settings-menu {
  background: #2d3748;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Settings content container */
#settings-menu-content {
  padding: 1.5rem;
  display: block;
}

#settings-menu.closed #settings-menu-content {
  display: none;
}

/* Individual settings sections (cards) */
.settings-section {
  background: #f8fafc;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  transition: background 0.3s ease, transform 0.2s ease;
}

.settings-section:hover {
  transform: translateY(-1px);
}

body.dark-mode .settings-section {
  background: #364157;
}

.settings-section:last-child {
  margin-bottom: 0;
}

/* Section headers with icons */
.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #4a5568;
  margin: 0 0 1.25rem 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

body.dark-mode .section-title {
  color: #e2e8f0;
}

.section-title .icon {
  font-size: 1.35rem;
  line-height: 1;
}

/* Controls grid layout (desktop) */
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
}

.control-group-wide {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Control labels */
.control-label {
  font-weight: 600;
  font-size: 0.8rem;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body.dark-mode .control-label {
  color: #a0aec1;
}

/* Select inputs */
select, input[type="text"] {
  padding: 0.7rem 0.85rem;
  font-size: 0.95rem;
  border-radius: 10px;
  border: 2px solid #e2e8f0;
  background: white;
  color: #333;
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%236b7280' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") right 0.6rem center;
  background-size: 1.2em 1.2em;
  background-repeat: no-repeat;
}

select:hover, input[type="text"]:hover {
  border-color: #cbd5e1;
}

select:focus, input[type="text"]:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

body.dark-mode select, body.dark-mode input[type="text"] {
  background: #2d3748;
  color: #e0e0e0;
  border-color: #4a5568;
}

body.dark-mode select:hover, body.dark-mode input[type="text"]:hover {
  border-color: #6366f1;
}

/* Toggle row (iOS-style toggle switches) */
.toggle-row-wrapper {
  padding: 0.25rem 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 0;
  border-bottom: 1px solid #e2e8f0;
}

body.dark-mode .toggle-row {
  border-color: #4a5568;
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-label {
  font-size: 0.95rem;
  color: #374151;
  line-height: 1.4;
}

body.dark-mode .toggle-label {
  color: #d1d5db;
}

/* Custom toggle switch styling */
.toggle-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 52px;
  height: 28px;
  border-radius: 14px;
  background: #d1d5db;
  position: relative;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.toggle-row input[type="checkbox"]:hover {
  background: #9ca3af;
}

.toggle-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toggle-row input[type="checkbox"]:checked {
  background: #3b82f6;
}

.toggle-row input[type="checkbox"]:checked::after {
  left: 27px;
  background: white;
}

body.dark-mode .toggle-row input[type="checkbox"] {
  background: #4a5568;
}

body.dark-mode .toggle-row input[type="checkbox"]:hover {
  background: #6366f1;
}

body.dark-mode .toggle-row input[type="checkbox"]:checked {
  background: #60a5fa;
}

/* Notification time picker */
.notification-time-group {
  margin-top: 1.25rem;
}

.time-picker-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.75rem;
}

.time-picker-row select {
  width: auto;
  min-width: 85px;
  text-align: center;
  padding: 0.65rem 0.4rem;
}

.time-separator {
  font-size: 1.5rem;
  color: #9ca3af;
  font-weight: bold;
}

/* Notification hint */
.notification-hint {
  font-size: 0.82rem;
  color: #718096;
  margin-top: 0.85rem;
  line-height: 1.45;
}

body.dark-mode .notification-hint {
  color: #a0aec1;
}

/* Pollen select styling */
#pollen-select {
  max-height: 220px;
  overflow-y: auto;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 0.85rem;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

body.dark-mode #pollen-select {
  background: #2d3748;
  border-color: #4a5568;
}

#pollen-select label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  transition: background 0.15s ease;
}

#pollen-select label:hover {
  background: #eef2f7;
}

body.dark-mode #pollen-select label:hover {
  background: #3a465c;
}

body.dark-mode #pollen-select label {
  color: #e0e0e0;
}

/* Settings actions (buttons) */
.settings-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

#location-btn, #dark-mode-toggle {
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
}

#location-btn {
  background-color: #3b82f6;
  border: none;
  color: white;
}

body.dark-mode #location-btn {
  background-color: #4da6ff;
}

#location-btn:hover:not(:disabled) {
  background-color: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

body.dark-mode #location-btn:hover:not(:disabled) {
  background-color: #3d86cc;
}

#location-btn:disabled {
  background-color: #9ca3af;
  cursor: default;
}

#dark-mode-toggle {
  background-color: #4b5563;
  border: none;
  color: white;
}

body.dark-mode #dark-mode-toggle {
  background-color: #6b7280;
}

#dark-mode-toggle:hover {
  background-color: #374151;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

body.dark-mode #dark-mode-toggle:hover {
  background-color: #9ca3af;
}

/* ============================================
   FORECAST SUMMARY STYLES
   ============================================ */

#forecast-summary {
  margin-top: 1rem;
  width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 5px;
}

.summary-container {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  gap: 8px;
  min-width: max-content;
  width: fit-content;
  margin: 0 auto;
  padding: 10px 5px;
  background: #e9ecef;
  border-radius: 8px;
}

body.dark-mode .summary-container {
  background: #333;
}

.day-card {
  flex: 0 0 auto;
  width: 70px;
  height: 120px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 5px;
  transition: transform 0.2s ease;
}

body.dark-mode .day-card {
  background: #444;
  box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
}

.day-card:hover {
  transform: translateY(-3px);
}

.day-card.selected {
  box-shadow: 0 0 0 2px #3b82f6, 0 4px 12px rgba(59, 130, 246, 0.3);
  transform: translateY(-3px);
}

body.dark-mode .day-card.selected {
  box-shadow: 0 0 0 2px #60a5fa, 0 4px 12px rgba(96, 165, 250, 0.4);
}

.day-card.selected .day-name {
  color: #3b82f6;
}

body.dark-mode .day-card.selected .day-name {
  color: #60a5fa;
}

.day-name {
  font-weight: bold;
  font-size: 0.9rem;
  margin-top: 4px;
  text-align: center;
}

.weather-icon {
  font-size: 2rem;
  line-height: 1;
  margin: 5px 0;
}

.temp-range {
  font-size: 0.85rem;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wind-display {
  font-size: 0.75rem;
  color: #666;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.dark-mode .wind-display {
  color: #aaa;
}

.day-card.today {
  background-color: rgba(255, 255, 180, 0.3) !important;
  border: 3px solid rgba(255, 215, 0, 0.6) !important;
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3) !important;
  transform: translateY(-4px);
}

body.dark-mode .day-card.today {
  background-color: rgba(255, 255, 180, 0.2) !important;
  border-color: rgba(255, 215, 0, 0.6) !important;
  box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3) !important;
}

body.dark-mode .day-card.today .day-name, 
body.dark-mode .day-card.today .temp-range {
  color: #212121 !important;
}

.day-card.today .temp-range {
  font-size: 1.1rem !important;
  color: #333 !important;
  font-weight: bold;
}

body.dark-mode .day-card.today .temp-range {
  color: #f7fafc !important;
}

@media (max-width: 500px) {
    .summary-container { gap: 5px; padding: 8px 2px; }
    .day-card { width: 60px; height: 110px; }
    .weather-icon { font-size: 1.5rem; }
    .temp-range { font-size: 0.75rem; }
}

/* ============================================
   OTHER STYLES (existing)
   ============================================ */

#current-temp-container {
  background: #e9ecef;
  border-radius: 8px;
  padding: 10px 5px;
  margin-top: 0.25rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

body.dark-mode #current-temp-container {
  background: #333;
  box-shadow: 0 2px 4px rgba(255, 255, 255, 0.1);
}

#current-temp-title {
  text-align: center;
  font-weight: bold;
  font-size: 1.2rem;
  color: #333;
  margin-bottom: 0.5rem;
}

body.dark-mode #current-temp-title {
  color: #f7fafc;
}

#current-temp {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.current-item {
  font-weight: bold;
  font-size: 1.1rem;
  color: #333;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

body.dark-mode #current-temp .current-item {
  color: #f7fafc;
}

#last-updated-weather, #last-updated-pollen, #info {
  margin-top: 0.5rem;
  font-style: italic;
  color: #555;
  text-align: center;
  font-size: 0.9rem;
  transition: color 0.3s ease;
}

body.dark-mode #last-updated-weather, body.dark-mode #last-updated-pollen, body.dark-mode #info {
  color: #aaa;
}

#error-msg {
  color: #cc0000;
  font-weight: bold;
  margin-top: 0.5rem;
  text-align: center;
  min-height: 1.2em;
  font-size: 0.95rem;
  transition: color 0.3s ease;
}

body.dark-mode #error-msg {
  color: #ff5555;
}

canvas {
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  width: 100%;
  margin: 0 auto;
  display: block;
  object-fit: contain;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode canvas {
  background: #2d2d2d;
  border-color: #555;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

#chart-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 auto;
  max-width: 100vw;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  background: white;
  border: 1px solid #ddd;
}

#chart-container canvas {
    min-width: 900px;
    height: 400px !important;
    display: block;
    object-fit: contain;
}

body.dark-mode #chart-container {
    background: #2d2d2d;
    border-color: #555;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

@media (max-width: 500px) {
    #chart-container canvas {
        min-width: 700px;
    }
}

/* Fancy Loading Spinner */
#loading-indicator {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 24px 0;
}

.fancy-spinner-container {
  position: relative;
  width: 64px;
  height: 64px;
}

.spinner-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid transparent;
}

.spinner-ring-outer {
  animation: spinner-spin 2.4s cubic-bezier(0.4, 0, 0.2, 1) infinite;
  border-top-color: #3b82f6;
  border-right-color: #3b82f6;
}

.spinner-ring-inner {
  position: absolute;
  top: 8px;
  left: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  animation: spinner-spin 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite reverse;
  border-bottom-color: #60a5fa;
  border-left-color: #60a5fa;
}

.spinner-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  background: #3b82f6;
  border-radius: 50%;
  animation: spinner-pulse 1.2s ease-in-out infinite;
}

@keyframes spinner-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes spinner-pulse {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(0.8); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
}

.loading-text {
  font-size: 0.95rem;
  color: #6b7280;
  font-weight: 500;
  letter-spacing: 0.02em;
}

body.dark-mode .loading-text {
  color: #a7a7a7;
}

#day-filter-reset {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  font-size: 0.9rem;
  color: #6b7280;
}

#day-filter-reset button {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

#day-filter-reset button:hover {
  background: #2563eb;
}

body.dark-mode #day-filter-reset {
  color: #a7a7a7;
}

body.dark-mode #day-filter-reset button {
  background: #60a5fa;
}

body.dark-mode #day-filter-reset button:hover {
  background: #3b82f6;
}

body.dark-mode .spinner-ring-outer {
  border-top-color: #60a5fa;
  border-right-color: #60a5fa;
}

body.dark-mode .spinner-ring-inner {
  border-bottom-color: #93b8f5;
  border-left-color: #93b8f5;
}

body.dark-mode .spinner-center {
  background: #60a5fa;
}

/* ============================================
   MOBILE RESPONSIVE - SMALL DEVICES
   ============================================ */

@media (max-width: 768px) {
  body {
    padding: 0 1rem;
  }

  /* Settings menu full width on mobile */
  #settings-menu {
    max-width: calc(100vw - 2rem);
    border-radius: 14px;
  }

  #settings-menu-content {
    padding: 1.25rem;
  }

  /* Stack sections vertically, full width */
  .settings-section {
    padding: 1.25rem;
    margin-bottom: 0.85rem;
  }

  /* Controls grid - single column on small screens */
  .controls-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  .control-group-wide {
    width: 100%;
  }

  /* Larger tap targets for selects */
  select, input[type="text"] {
    padding: 0.85rem 0.75rem;
    font-size: 1rem;
    min-height: 46px;
  }

  /* Toggle switches - larger on mobile */
  .toggle-row input[type="checkbox"] {
    width: 56px;
    height: 30px;
  }

  .toggle-row input[type="checkbox"]::after {
    width: 24px;
    height: 24px;
  }

  .toggle-row input[type="checkbox"]:checked::after {
    left: 31px;
  }

  /* Time picker - side by side on mobile */
  .time-picker-row select {
    min-width: 80px;
    font-size: 1rem;
  }

  /* Buttons full width on very small screens */
  .settings-actions {
    grid-template-columns: 1fr !important;
  }

  #location-btn, #dark-mode-toggle {
    padding: 0.95rem 1.25rem;
    min-height: 48px;
    font-size: 1rem;
  }

  /* Pollen checkboxes - easier to tap */
  #pollen-select {
    max-height: 250px;
    padding: 0.75rem;
  }

  #pollen-select label {
    padding: 0.6rem 0.5rem;
    margin-bottom: 0.4rem;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  h1 {
    font-size: 1.35rem;
    margin-bottom: 0.85rem;
  }

  .page-header {
    padding: 0 0.5rem;
  }

  #last-updated-weather, #last-updated-pollen {
    font-size: 0.8rem;
  }

  #error-msg {
    font-size: 0.85rem;
  }
}

/* Extra small screens (iPhone SE, etc.) */
@media (max-width: 360px) {
  #settings-menu-content {
    padding: 1rem;
  }

  .settings-section {
    padding: 1rem;
  }

  .section-title {
    font-size: 0.95rem;
  }

  .time-picker-row select {
    min-width: 70px;
    font-size: 0.9rem;
  }

  #pollen-select {
    max-height: 200px;
  }
}
