:root {
  color-scheme: light dark;
  --background: #fff;
  --text: #171717;
  --secondary-text: #656565;
  --border: #c9c9c9;
  --soft-background: rgba(127, 127, 127, 0.1);
  --button-background: #262626;
  --button-text: #fff;
  --moon-light: #f4f1e8;
  --moon-dark: #393936;
  --focus: #075ec8;
  --error: #a51d1d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #1e1e1e;
    --text: #f0f0f0;
    --secondary-text: #aaa;
    --border: #555;
    --soft-background: rgba(255, 255, 255, 0.08);
    --button-background: #eee;
    --button-text: #181818;
    --moon-light: #f1eee4;
    --moon-dark: #333330;
    --focus: #83b9ff;
    --error: #ff9a9a;
  }
}

:root[data-theme="dark"] {
  --background: #1e1e1e;
  --text: #f0f0f0;
  --secondary-text: #aaa;
  --border: #555;
  --soft-background: rgba(255, 255, 255, 0.08);
  --button-background: #eee;
  --button-text: #181818;
  --moon-light: #f1eee4;
  --moon-dark: #333330;
  --focus: #83b9ff;
  --error: #ff9a9a;
}

* { box-sizing: border-box; }

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

main,
footer {
  width: min(100% - 40px, 600px);
  margin-inline: auto;
}

main { margin-top: 20px; }

h2 {
  margin: 0 0 32px;
  font-size: 1.25rem;
}

h2 a { color: inherit; text-decoration: none; }

.moon-summary {
  display: flex;
  align-items: center;
  gap: 32px;
  margin-bottom: 36px;
}

#moon {
  width: 184px;
  height: 184px;
  flex: 0 0 auto;
}

.moon-details { min-width: 0; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--secondary-text);
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 6vw, 2rem);
  line-height: 1.2;
}

.illumination {
  margin: 6px 0 0;
  color: var(--secondary-text);
  font-size: 1.05rem;
}

.illumination strong {
  color: var(--text);
  font-weight: 600;
}

.next-event {
  padding: 18px 0;
  border-block: 1px solid var(--border);
}

.next-event > p:last-child { margin: 0; font-size: 1.05rem; }

details { margin-top: 24px; }

summary {
  width: max-content;
  cursor: pointer;
  color: var(--secondary-text);
}

form { margin-top: 18px; }

label,
legend { font-size: 0.875rem; }

form > label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

input[type="datetime-local"] {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--background);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

.actions { display: flex; gap: 10px; margin-top: 12px; }

button {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--button-background);
  border-radius: 5px;
  background: var(--button-background);
  color: var(--button-text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.secondary {
  border-color: var(--border);
  background: transparent;
  color: var(--text);
  font-weight: 400;
}

button:hover { filter: brightness(1.08); }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 60%, transparent);
  outline-offset: 2px;
}

.utility-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-top: 28px;
}

.status { margin: 0; color: var(--secondary-text); font-size: 0.875rem; }
.error { margin-top: 10px; color: var(--error); }

.theme-picker {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 3px;
  border: 0;
  border-radius: 6px;
  background: var(--soft-background);
}

.theme-picker legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.theme-picker label {
  padding: 4px 7px;
  border-radius: 4px;
  color: var(--secondary-text);
  cursor: pointer;
}

.theme-picker label:has(input:checked) {
  background: var(--background);
  color: var(--text);
}

.theme-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-picker label:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--focus) 60%, transparent);
  outline-offset: 2px;
}

footer {
  margin-top: 40px;
  margin-bottom: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--secondary-text);
  font-size: 0.875rem;
}

@media (max-width: 440px) {
  .moon-summary { align-items: flex-start; gap: 18px; }
  #moon { width: 124px; height: 124px; }
  .utility-row { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
