:root {
  color-scheme: light dark;
}

.viz-root {
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --series-sun:      #eda100;
  --series-moon:     #2a78d6;
  --series-moonset:  #184f95;
  --series-besttime: #256abf;
  --pred-highly-likely:    #0ca30c;
  --pred-likely-perfect:   #a4a800;
  --pred-possibly-perfect: #fab219;
  --pred-not-expected:     #ec835a;
  --pred-not-possible:     #d03b3b;
  --pred-neutral:          #898781;
}

@media (prefers-color-scheme: dark) {
  .viz-root {
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
    --series-sun:      #c98500;
    --series-moon:     #3987e5;
    --series-moonset:  #256abf;
    --series-besttime: #2a78d6;
    --pred-highly-likely:    #0ca30c;
    --pred-likely-perfect:   #a4a800;
    --pred-possibly-perfect: #fab219;
    --pred-not-expected:     #ec835a;
    --pred-not-possible:     #d03b3b;
    --pred-neutral:          #898781;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.viz-root {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.page-header h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
}
.subtitle {
  color: var(--text-secondary);
  margin: 0 0 8px;
  font-size: 0.95rem;
}
.disclaimer {
  color: var(--text-muted);
  margin: 0 0 20px;
  font-size: 0.82rem;
  font-style: italic;
}

.page-footer { margin-top: 24px; }
.tips-list {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
}
.tips-list li { margin-bottom: 6px; }
.tips-list li:last-child { margin-bottom: 0; }
.regional-disclaimer {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: 16px 4px 0;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--series-moon);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
}

.settings-body { margin-top: 12px; }
.settings-body.hidden { display: none; }
.settings-body input {
  width: 100%;
  margin: 6px 0;
}
.hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 4px 0 0;
}
.hint.error { color: #d03b3b; }

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

.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
input[type="text"], input[type="date"], input[type="number"], select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--baseline);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.field-conjunction { width: 305px; justify-self: start; }
.field-conjunction select { width: 100%; }

@media (max-width: 480px) {
  .field-conjunction { width: 100%; }
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.field-location { grid-column: 1 / -1; }

.location-input-row {
  display: flex;
  gap: 8px;
}

.autocomplete {
  position: relative;
  flex: 1 1 auto;
}
.autocomplete input { width: 100%; }

.location-results {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  max-height: 240px;
  overflow-y: auto;
}
.location-results.hidden { display: none; }
.location-results li {
  padding: 8px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.85rem;
}
.location-results li:hover,
.location-results li.active {
  background: var(--gridline);
}

button#gps-btn {
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--baseline);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
button#gps-btn:disabled { opacity: 0.6; cursor: default; }

.location-summary {
  color: var(--text-primary) !important;
  font-weight: 600;
  font-size: 0.85rem !important;
}
.location-summary.hidden { display: none; }

button#submit-btn {
  background: var(--series-moon);
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-size: 0.9rem;
  cursor: pointer;
}
button#submit-btn:disabled { opacity: 0.6; cursor: default; }

.status-msg {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.status-msg.error { color: #d03b3b; }

.results.hidden { display: none; }

.conjunction-panel .muted { color: var(--text-secondary); }
.conjunction-panel .value { font-weight: 600; margin-left: 6px; }

.legend {
  display: flex;
  gap: 20px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block;
}
.swatch-sun { background: var(--series-sun); }
.swatch-moon { background: var(--series-moon); }
.swatch-moonset { background: var(--series-moonset); }
.swatch-besttime {
  background: var(--series-besttime);
  border-radius: 0;
  transform: rotate(45deg);
  width: 8px; height: 8px;
}

.prediction-banner {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-1));
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-primary);
}
.prediction-highly_likely    { --accent: var(--pred-highly-likely); }
.prediction-likely_perfect   { --accent: var(--pred-likely-perfect); }
.prediction-possibly_perfect { --accent: var(--pred-possibly-perfect); }
.prediction-not_expected     { --accent: var(--pred-not-expected); }
.prediction-not_possible     { --accent: var(--pred-not-possible); }
.prediction-not_new          { --accent: var(--pred-neutral); }
.prediction-sets_before_sun  { --accent: var(--pred-neutral); }

.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.day-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}
.day-card h3 {
  margin: 0 0 2px;
  font-size: 0.95rem;
}
.day-card-location {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.day-card svg { width: 100%; height: auto; display: block; }

text.axis {
  fill: var(--text-secondary);
  font-size: 9px;
}
.gridline { stroke: var(--gridline); stroke-width: 1; }
.baseline { stroke: var(--baseline); stroke-width: 1.5; }

.mark-label {
  fill: var(--text-secondary);
  font-size: 10px;
}

.stat-list {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}
.stat-section { margin-bottom: 14px; }
.stat-section:last-child { margin-bottom: 0; }
.stat-section-title {
  margin: 0 0 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--gridline);
}
.stat-section .stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--text-secondary); }
.stat-value { color: var(--text-primary); font-weight: 600; text-align: right; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.78rem;
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: none;
  white-space: nowrap;
  z-index: 10;
}

/* ---- Site navigation ---- */
.site-nav {
  display: flex;
  gap: 4px;
  margin: 0 0 16px;
  flex-wrap: wrap;
}
.site-nav a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid transparent;
}
.site-nav a:hover { color: var(--text-primary); border-color: var(--border); }
.site-nav a[aria-current="page"] {
  color: var(--text-primary);
  font-weight: 600;
  background: var(--surface-1);
  border-color: var(--border);
}

.find-label {
  display: block;
  margin-top: 12px;
}

/* ---- Month tracker / history ---- */
.panel-heading {
  margin: 0 0 10px;
  font-size: 1rem;
}
.about-list {
  margin: 0;
  padding-left: 1.2em;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.6;
}
.about-list li { margin-bottom: 6px; }
.about-list a, .col-link a { color: var(--series-moon); }

.table-scroll { overflow-x: auto; }
.tracker-table {
  width: 100%;
  min-width: 640px;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.tracker-table th {
  text-align: left;
  padding: 6px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--baseline);
  white-space: nowrap;
}
.tracker-table td {
  padding: 9px 10px;
  vertical-align: top;
  border-bottom: 1px solid var(--gridline);
  color: var(--text-primary);
}
.tracker-table .sub {
  color: var(--text-muted);
  font-size: 0.78rem;
}
.tracker-table .col-month { white-space: nowrap; }
.tracker-table .month-name { font-weight: 600; }
.tracker-table .month-year { color: var(--text-muted); font-size: 0.78rem; }
.tracker-table .col-newmoon, .tracker-table .col-date { white-space: nowrap; }
.tracker-table .col-notes { min-width: 160px; }
.tracker-table .col-link { white-space: nowrap; }
.gap-row td {
  color: var(--text-muted);
  font-style: italic;
  background: transparent;
  text-align: center;
}

.sighted-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
}
.sighted-tag.yes { border-color: var(--pred-highly-likely); }
.sighted-tag.no { color: var(--text-secondary); }
.sighted-tag.pending, .sighted-tag.unknown {
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}

.history-year {
  border-top: 1px solid var(--gridline);
  padding: 4px 0;
}
.history-year:first-of-type { border-top: none; }
.history-year summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 2px;
  cursor: pointer;
  list-style: none;
}
.history-year summary::-webkit-details-marker { display: none; }
.history-year summary::before {
  content: "▸";
  color: var(--text-muted);
  width: 1em;
}
.history-year[open] summary::before { content: "▾"; }
.year-title { font-size: 1rem; font-weight: 600; }
.year-count { color: var(--text-muted); font-size: 0.8rem; }
.history-year .table-scroll { padding-bottom: 8px; }
#history-toggle { margin-bottom: 8px; }

/* ---- Planning Outlook ---- */
.beta-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border: 1px solid var(--baseline);
  border-radius: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  vertical-align: middle;
}
.beta-tag-lg { font-size: 0.7rem; padding: 1px 8px; }

.callout {
  border-left: 4px solid var(--series-moon);
}
.callout p { margin: 0; font-size: 0.92rem; line-height: 1.55; color: var(--text-secondary); }
.callout p strong { color: var(--text-primary); }
.callout .beta-note { margin-top: 8px; font-size: 0.8rem; color: var(--text-muted); font-style: italic; }

.stale-notice.hidden { display: none; }
.stale-notice {
  padding: 12px 14px;
  border: 1px solid var(--pred-possibly-perfect);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-primary);
}
.outlook-table .col-more { font-weight: 600; white-space: nowrap; }
.outlook-table .col-less { white-space: nowrap; color: var(--text-secondary); }
.outlook-table .col-depends { font-size: 0.8rem; color: var(--text-muted); }
.outlook-table .dep-row { display: none; }
.outlook-table .dep-row td { padding-top: 0; font-size: 0.78rem; color: var(--text-muted); }
@media (max-width: 640px) {
  .outlook-table { min-width: 0; }
  .outlook-table .dep-row { display: table-row; }
  .outlook-table tbody tr:not(.dep-row) td { border-bottom: none; }
  .outlook-table col:nth-child(1) { width: 27% !important; }
  .outlook-table col:nth-child(2), .outlook-table col:nth-child(3) { width: 36.5% !important; }
  .outlook-table col:nth-child(4), .outlook-table th:nth-child(4), .outlook-table td:nth-child(4) { display: none; }
  .outlook-table th, .outlook-table td { padding-left: 4px; padding-right: 4px; }
  .outlook-table .col-more, .outlook-table .col-less { font-size: 0.8rem; }
}
