/* Zeleor - night sky theme (constitution V: plain CSS with custom properties). */
:root {
  color-scheme: dark;
  --bg: #05070f;
  --bg-top: #0b1230;
  --panel: rgba(18, 24, 48, 0.62);
  --panel-solid: #121830;
  --border: rgba(160, 180, 255, 0.18);
  --text: #e8ecff;
  --muted: #a7b2da;
  --accent: #f5c86b;
  --focus: #9fd3ff;
  --physical: #ff6b70;
  --emotional: #4cc3ff;
  --intellectual: #4ade80;
  --mastery: #e879f9;
  --passion: #facc15;
  --wisdom: #a5b4fc;
  --good: #4ade80;
  --bad: #ff6b70;
  --radius: 14px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* The sky gradient lives on <html>; <body> stays transparent so the star canvas shows through. */
/* Dawn: a pale blue glow rising from the bottom edge of the window. */
html {
  background:
    radial-gradient(ellipse 120% 45% at 50% 100%, rgba(120, 180, 255, 0.28) 0%, rgba(70, 120, 220, 0.12) 45%, transparent 75%) fixed,
    linear-gradient(to top, rgba(90, 150, 240, 0.16) 0%, transparent 40%) fixed,
    radial-gradient(ellipse at 50% -10%, var(--bg-top) 0%, var(--bg) 65%) fixed var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 16px/1.5 var(--font);
  background: transparent;
  overflow-x: hidden;
}

#sky { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1; pointer-events: none; }

h1, h2, h3, p { margin: 0; }

button, input { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

[hidden] { display: none !important; }

body[data-mode="single"] .compat-only,
body[data-mode="compat"] .single-only { display: none !important; }

/* ---------- header ---------- */

.top {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
}

.site-bar {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}
.site-brand { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 600; letter-spacing: 0.04em; color: var(--text); text-decoration: none; }
.site-bar nav a { color: var(--muted); text-decoration: none; padding: 10px 4px; display: inline-block; }
.site-bar nav a:hover, .site-brand:hover { color: var(--accent); }

.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 40px; height: 40px; }
.brand h1 { font-size: 1.6rem; letter-spacing: 0.08em; font-weight: 600; }
.tagline { color: var(--muted); font-size: 0.9rem; }

.mode {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  backdrop-filter: blur(8px);
}
.mode label { position: relative; cursor: pointer; }
.mode input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.mode span { display: inline-block; padding: 8px 16px; border-radius: 999px; min-height: 44px; line-height: 28px; }
.mode input:checked + span { background: rgba(245, 200, 107, 0.18); color: var(--accent); }
.mode input:focus-visible + span { outline: 2px solid var(--focus); }

/* ---------- grid ---------- */

.grid {
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 16px 24px;
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

@media (min-width: 960px) {
  .grid { grid-template-columns: 300px minmax(0, 1fr) 300px; }
  .chart-panel { grid-column: 1 / -1; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-width: 0;
}

.panel-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

main[aria-busy="true"] .panel { opacity: 0.75; transition: opacity 0.2s; }
body.stale #rhythms, body.stale #chart-area { opacity: 0.4; }

/* Fixed minimum heights keep the layout from shifting while data arrives (CLS 0). */
#profile { min-height: 420px; }
#center { min-height: 420px; }
#today { min-height: 420px; }
.chart-panel { min-height: 300px; }

/* ---------- form ---------- */

.field { display: grid; gap: 4px; margin-bottom: 12px; border: 0; padding: 0; }
.field label, .field legend { font-size: 0.85rem; color: var(--muted); }
input[type="date"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(5, 7, 15, 0.6);
  color: var(--accent);
  font-size: 1.05rem;
}
input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.85); }

.sex { display: flex; gap: 16px; flex-wrap: wrap; }
.sex legend { width: 100%; margin-bottom: 4px; }
.sex label { display: inline-flex; gap: 6px; align-items: center; min-height: 44px; cursor: pointer; }

button { cursor: pointer; }
button:disabled { cursor: default; }

.primary, .ghost {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.primary {
  width: 100%;
  margin-bottom: 16px;
  background: linear-gradient(180deg, rgba(245, 200, 107, 0.95), rgba(214, 160, 70, 0.95));
  border-color: transparent;
  color: #1a1408;
  font-weight: 600;
}
.primary:hover { filter: brightness(1.08); }
.ghost { background: rgba(255, 255, 255, 0.04); }
.ghost:hover { background: rgba(255, 255, 255, 0.09); }

/* ---------- profile ---------- */

.profile-info { display: flex; gap: 16px; align-items: center; margin-bottom: 12px; }
.moon-box { display: grid; justify-items: center; gap: 4px; }
.moon-caption { font-size: 0.7rem; color: var(--muted); text-align: center; max-width: 90px; }
.moon-button {
  position: relative;
  width: 84px; height: 84px; padding: 0;
  border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
}
.moon-pic {
  position: absolute; inset: 9px;
  background-size: 1000% 300%; background-repeat: no-repeat;
}
.moon-n { background-image: url("../img/moon-n.png?v=1"); }
.moon-s { background-image: url("../img/moon-s.png?v=1"); }
.moon-badge { position: absolute; left: 4px; top: 0; color: var(--accent); font-size: 0.85rem; font-weight: 700; }

.age { display: grid; grid-template-columns: auto auto; gap: 2px 12px; margin: 0; }
.age dt { color: var(--muted); font-size: 0.85rem; }
.age dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

.rhythms { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rhythm { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; min-height: 40px; }
.rhythm input { width: 18px; height: 18px; accent-color: var(--accent); }
.rhythm-name {
  justify-self: start;
  background: none; border: 0; padding: 4px 0;
  font-weight: 600; text-decoration: underline dotted rgba(255, 255, 255, 0.35); text-underline-offset: 3px;
}
.rhythm.secondary .rhythm-name { font-weight: 500; }
.rhythm-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.rhythm-physical .rhythm-name, .rhythm-physical .rhythm-value { color: var(--physical); }
.rhythm-emotional .rhythm-name, .rhythm-emotional .rhythm-value { color: var(--emotional); }
.rhythm-intellectual .rhythm-name, .rhythm-intellectual .rhythm-value { color: var(--intellectual); }
.rhythm-mastery .rhythm-name, .rhythm-mastery .rhythm-value { color: var(--mastery); }
.rhythm-passion .rhythm-name, .rhythm-passion .rhythm-value { color: var(--passion); }
.rhythm-wisdom .rhythm-name, .rhythm-wisdom .rhythm-value { color: var(--wisdom); }
.rhythm.critical .rhythm-value::after { content: " ●"; color: var(--accent); }

/* ---------- calendar ---------- */

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-weight: 600; color: var(--accent); }
.cal-step { min-width: 44px; padding: 0; font-size: 1.3rem; }
.cal-grid { display: grid; gap: 4px; }
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-weekdays span { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 4px 0; }
.cal-row [role="gridcell"] { display: grid; }
.cal-row button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  font-variant-numeric: tabular-nums;
}
.cal-row button:hover { background: rgba(255, 255, 255, 0.1); }
.cal-row button.today { border-color: rgba(245, 200, 107, 0.5); }
.cal-row button.selected { background: var(--accent); color: #1a1408; font-weight: 700; }
.cal-row button.crit { box-shadow: inset 0 -3px 0 rgba(255, 107, 112, 0.7); }

/* ---------- signs strip ---------- */

.signs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.sign {
  flex: 1 1 90px;
  display: grid; justify-items: center; gap: 4px;
  min-height: 96px; padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.85rem;
}
.sign:hover { background: rgba(255, 255, 255, 0.1); }
.sign-icon { width: 52px; height: 52px; fill: currentColor; }
.sign-zodiac .sign-icon { color: var(--accent); }
.sign-animal .sign-icon { color: #ff8f7a; }
.sign-element .sign-icon { color: #9fd3ff; }
.person-signs { flex-wrap: nowrap; }
.person-signs .sign { flex: 1 1 0; min-width: 0; font-size: 0.8rem; }

/* ---------- today ---------- */

#set-today { width: 100%; margin-bottom: 16px; }
.today-row { display: flex; gap: 16px; align-items: center; justify-content: center; margin-bottom: 12px; }
.hexagram {
  width: 84px; height: 92px; padding: 8px;
  border-radius: 10px; border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
}
.hexagram svg { width: 100%; height: 100%; fill: #4cc3ff; }
.sun { font-size: 0.85rem; color: var(--muted); text-align: center; }

/* ---------- chart ---------- */

.chart-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.chart-title { font-size: 0.85rem; color: var(--muted); }
.color-day { display: inline-flex; gap: 8px; align-items: center; font-size: 0.85rem; }
.swatch { width: 36px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: #222; }
.chart-area { min-height: 220px; width: 100%; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; } /* dots on the first/last day line */
.grid-day { stroke: rgba(160, 180, 255, 0.1); }
.grid-today { stroke: var(--accent); stroke-opacity: 0.6; }
.grid-label { fill: var(--muted); font-size: 11px; }
.midline { stroke: rgba(255, 255, 255, 0.35); stroke-dasharray: 3 3; }
.curve { fill: none; stroke-width: 2.2; stroke-linejoin: round; }
.curve.secondary { stroke-width: 1.3; stroke-dasharray: 5 4; opacity: 0.9; }
.curve-physical { stroke: var(--physical); }
.curve-emotional { stroke: var(--emotional); }
.curve-intellectual { stroke: var(--intellectual); }
.curve-mastery { stroke: var(--mastery); }
.curve-passion { stroke: var(--passion); }
.curve-wisdom { stroke: var(--wisdom); }
.crit-physical { fill: var(--physical); }
.crit-emotional { fill: var(--emotional); }
.crit-intellectual { fill: var(--intellectual); }
.crit-ring { fill: none; stroke: var(--bg); stroke-width: 1.2; }
.bars-bg { fill: rgba(0, 0, 0, 0.35); stroke: var(--border); }
.bar-label { font-size: 11px; font-weight: 700; text-anchor: middle; }
.bar-label-physical { fill: var(--physical); }
.bar-label-emotional { fill: var(--emotional); }
.bar-label-intellectual { fill: var(--intellectual); }
.chart-nav { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
.chart-nav button {
  min-width: 64px; min-height: 44px;
  border-radius: 10px; border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}
.chart-nav button:hover { background: rgba(255, 255, 255, 0.1); }

/* ---------- compatibility ---------- */

.compat { display: grid; }
/* A grid does not collapse margins, so drop the last field margin to line the signs up with person 1. */
.compat > .field:last-child { margin-bottom: 0; }
.compat-center #compare { width: 100%; margin-bottom: 8px; }
/* One column: both people first, then the result. */
@media (max-width: 959px) {
  body[data-mode="compat"] #today { order: 1; }
  body[data-mode="compat"] #center { order: 2; }
  body[data-mode="compat"] .chart-panel { order: 3; }
}
.cgroup { font-size: 0.85rem; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.cbar { display: grid; grid-template-columns: 7.5em 1fr 4.5em; gap: 8px; align-items: center; min-height: 28px; font-size: 0.9rem; }
.cbar-track { position: relative; height: 10px; border-radius: 5px; background: rgba(255, 255, 255, 0.08); }
.cbar-track::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: rgba(255, 255, 255, 0.4); }
.cbar-fill { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.cbar-fill.pos { left: 50%; background: var(--good); }
.cbar-fill.neg { right: 50%; background: var(--bad); }
.cbar-value { text-align: right; font-variant-numeric: tabular-nums; }
.cbar-total { margin-top: 12px; font-weight: 700; }
.cbar-total .cbar-fill.pos { background: var(--accent); }
.band-text { margin-top: 8px; font-size: 1.1rem; color: var(--accent); font-weight: 600; text-align: center; }
.distance { margin-top: 4px; color: var(--muted); font-size: 0.85rem; text-align: center; }

/* ---------- human check, status, dialog ---------- */

.check {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(5, 7, 15, 0.55);
  padding: 16px;
}
.check-box { max-width: 360px; display: grid; gap: 12px; background: var(--panel-solid); }
#check-widget { min-height: 65px; }

.status {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 15;
  max-width: calc(100vw - 32px);
  display: flex; gap: 12px; align-items: center;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--panel-solid);
  border: 1px solid rgba(255, 107, 112, 0.5);
}

.reading {
  width: min(68ch, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-solid);
  color: var(--text);
}
.reading::backdrop { background: rgba(5, 7, 15, 0.7); backdrop-filter: blur(3px); }
.reading-head {
  position: sticky; top: 0;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--panel-solid);
  border-bottom: 1px solid var(--border);
}
.reading-head h2 { font-size: 1.1rem; color: var(--accent); text-transform: capitalize; }
.close { min-width: 44px; min-height: 44px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, 0.06); font-size: 1.4rem; }
.reading-body { padding: 16px 20px 24px; line-height: 1.65; overflow-wrap: anywhere; }
.reading-body h3 { color: var(--accent); font-size: 1rem; margin: 8px 0; }
.reading-body > h3:first-child { display: none; } /* already shown as the dialog title */
.reading-body p { margin: 0 0 12px; }
.reading-body b { color: #fff; }

.foot { max-width: 1280px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 0.8rem; text-align: center; }
.noscript { padding: 24px; text-align: center; }

/* ---------- small screens ---------- */

@media (max-width: 959px) {
  #profile, #center, #today { min-height: 0; }
  .chart-area { min-height: 180px; }
}

@media (max-width: 420px) {
  .brand h1 { font-size: 1.3rem; }
  .mode span { padding: 8px 12px; }
  .chart-nav button { min-width: 0; flex: 1 1 30%; }
  .cbar { grid-template-columns: 6.5em 1fr 4em; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
