:root {
  --bg: #f5f7f6;
  --card-bg: #ffffff;
  --text: #1b2521;
  --text-muted: #5c6b64;
  --accent: #2f8f5b;
  --good: #2f8f5b;
  --good-bg: #e6f4ec;
  --fair: #b8860b;
  --fair-bg: #fbf1dd;
  --poor: #c0392b;
  --poor-bg: #fbe8e6;
  --dark: #3d5a80;
  --dark-bg: #e7edf5;
  --border: #e2e8e4;
}
 
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181a;
    --card-bg: #1e2427;
    --text: #e8ede9;
    --text-muted: #93a39b;
    --accent: #4caf7d;
    --good: #4caf7d;
    --good-bg: #1e3a2c;
    --fair: #e0b84f;
    --fair-bg: #3a3220;
    --poor: #e57368;
    --poor-bg: #3a2320;
    --dark: #7ea0c9;
    --dark-bg: #223247;
    --border: #33393c;
  }
}

:root[data-theme="dark"] {
  --bg: #14181a;
  --card-bg: #1e2427;
  --text: #e8ede9;
  --text-muted: #93a39b;
  --accent: #4caf7d;
  --good: #4caf7d;
  --good-bg: #1e3a2c;
  --fair: #e0b84f;
  --fair-bg: #3a3220;
  --poor: #e57368;
  --poor-bg: #3a2320;
  --dark: #7ea0c9;
  --dark-bg: #223247;
  --border: #33393c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.header {
  text-align: center;
  margin-bottom: 28px;
}

.header-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.theme-toggle-btn,
.unit-toggle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.unit-toggle-btn {
  font-size: 0.75rem;
  font-weight: 600;
}

.theme-toggle-btn:hover,
.unit-toggle-btn:hover {
  border-color: var(--accent);
}

.header h1 {
  font-size: 1.6rem;
  margin: 0 0 6px;
}

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

.location-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.location-badge .pin {
  font-size: 1rem;
}

.daylight-info {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  margin-left: 4px;
}

.link-btn:hover {
  opacity: 0.8;
}

/* Status / loading */
.status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 48px 0;
  color: var(--text-muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* Location choice */
.location-choice {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 20px;
  text-align: center;
}

.location-message {
  color: var(--poor);
  margin: 0 0 16px;
  font-size: 0.9rem;
}

.primary-btn {
  width: 100%;
  padding: 12px 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn:hover {
  opacity: 0.9;
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 16px 0;
}

.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.manual-form {
  display: flex;
  gap: 8px;
}

.manual-form input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: var(--card-bg);
  color: var(--text);
}

.manual-form button {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  cursor: pointer;
}

.manual-form button:hover {
  opacity: 0.9;
}

/* Results */
.results {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.day-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.day-quote {
  margin: 0;
  padding: 0 8px;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.quote-author {
  font-style: normal;
  opacity: 0.85;
}

.day-pill {
  flex: 0 0 auto;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.day-pill:hover {
  border-color: var(--accent);
}

.day-pill-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

.best-time-card {
  background: linear-gradient(135deg, #2f8f5b, #1f6f45);
  color: white;
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
}

.best-time-card .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.75rem;
  opacity: 0.85;
  margin: 0 0 8px;
}

.best-time-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 8px;
}

.best-time-main h2 {
  margin: 0;
  font-size: 2.2rem;
  line-height: 1.1;
}

.weather-icon {
  font-size: 2.6rem;
  line-height: 1;
}

.window-card .weather-icon {
  font-size: 1.8rem;
}

.sky-label {
  margin: 2px 0 0;
  font-size: 0.85rem;
  opacity: 0.85;
}

.best-time-card .reason {
  margin: 0 0 12px;
  opacity: 0.95;
  font-size: 1rem;
}

.factor-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.window-card .factor-row {
  justify-content: flex-start;
  margin-top: 10px;
}

.window-card .chip {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.windows-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.windows-header-label {
  font-weight: 600;
  font-size: 0.95rem;
}

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

.windows-editor {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-top: 14px;
}

.window-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.window-edit-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--card-bg);
  color: var(--text);
}

.window-edit-row select {
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: var(--card-bg);
  color: var(--text);
}

.window-edit-row .to-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.windows-editor-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
}

.windows-editor-actions .primary-btn {
  width: auto;
  padding: 10px 20px;
}

.window-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.window-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.window-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.window-card .window-time {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 2px 0 0;
}

.window-card .sky-label {
  color: var(--text-muted);
}

.rating-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.rating-good {
  background: var(--good-bg);
  color: var(--good);
}

.rating-fair {
  background: var(--fair-bg);
  color: var(--fair);
}

.rating-poor {
  background: var(--poor-bg);
  color: var(--poor);
}

.rating-dark {
  background: var(--dark-bg);
  color: var(--dark);
}

.window-card p.reason {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.daylight-note {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--dark);
}

.wear-line,
.sun-line {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.best-time-card .wear-line,
.best-time-card .sun-line {
  color: white;
  opacity: 0.95;
}

.attribution {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.attribution a {
  color: var(--text-muted);
}

.error-banner {
  background: var(--poor-bg);
  color: var(--poor);
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
  margin-bottom: 20px;
}
