:root {
  --moon-gold: #efd486;
  --moon-night: #171323;
  --moon-night-soft: #24203c;
  --moon-lilac: #bcb3dc;
  --moon-mint: #9ed8cd;
}

body.moon-sheet-open {
  overflow: hidden;
}

.moon-context-line,
.desktop-moon-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.moon-location-trigger {
  display: inline-flex;
  min-width: 0;
  min-height: 36px;
  align-items: center;
  gap: 5px;
  padding: 0;
  color: rgba(244, 239, 250, 0.72);
  font: inherit;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.moon-location-trigger svg {
  width: 13px;
  height: 13px;
  stroke-width: 1.7;
}

.moon-location-trigger svg:last-child {
  width: 11px;
  opacity: 0.55;
}

.moon-privacy-cue {
  color: rgba(226, 219, 238, 0.42);
  font-size: 9px;
  line-height: 1.4;
  text-align: right;
}

.moon-phase-rail {
  display: grid;
  grid-template-columns: repeat(7, minmax(38px, 1fr));
  align-items: start;
  gap: 2px;
  width: 100%;
  overflow: visible;
}

.moon-day {
  display: flex;
  min-width: 0;
  min-height: 82px;
  align-items: center;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0 4px;
  color: inherit;
  font: inherit;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.moon-day-label,
.moon-day-date {
  color: rgba(232, 225, 241, 0.43);
  font-size: 9px;
  font-weight: 440;
  line-height: 1.2;
  white-space: nowrap;
}

.moon-day-visual {
  position: relative;
  display: grid;
  width: 46px;
  height: 48px;
  place-items: center;
}

.moon-day-visual canvas {
  position: relative;
  z-index: 2;
  display: block;
  filter: drop-shadow(0 7px 9px rgba(4, 2, 11, 0.38));
}

.moon-day-halo {
  position: absolute;
  z-index: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(245, 202, 108, 0.26);
  filter: blur(10px);
  opacity: 0;
}

.moon-day.is-today {
  background: linear-gradient(180deg, rgba(245, 211, 132, 0.08), transparent);
}

.moon-day.is-today .moon-day-label {
  color: var(--moon-gold);
  font-weight: 580;
}

.moon-day.is-today .moon-day-date {
  color: rgba(239, 212, 134, 0.66);
}

.moon-day.is-today .moon-day-halo,
.moon-day.is-selected .moon-day-halo {
  opacity: 0.8;
  animation: moonHaloBreathe 5.6s ease-in-out infinite;
}

.moon-day:focus-visible,
.moon-location-trigger:focus-visible,
.tonight-moon-link:focus-visible,
.desktop-tonight-moon:focus-visible {
  outline: 2px solid rgba(239, 212, 134, 0.58);
  outline-offset: 2px;
}

.tonight-moon-link,
.desktop-tonight-moon {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0;
  color: rgba(236, 228, 244, 0.66);
  font: inherit;
  font-size: 10px;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.tonight-moon-link strong,
.desktop-tonight-moon strong {
  color: var(--moon-gold);
  font-weight: 560;
}

.tonight-moon-link svg,
.desktop-tonight-moon svg {
  width: 12px;
  height: 12px;
}

.moon-sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 220;
}

.moon-sheet-layer[hidden] {
  display: none !important;
}

.moon-sheet-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0;
  background: rgba(10, 7, 17, 0.62);
  border: 0;
  backdrop-filter: blur(8px);
}

.moon-sheet {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: min(100%, 460px);
  max-height: min(88vh, 720px);
  max-height: min(88dvh, 720px);
  padding: 10px 22px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  color: #f7f2fa;
  background:
    radial-gradient(circle at 50% 16%, rgba(111, 93, 157, 0.2), transparent 38%),
    linear-gradient(180deg, #211a31, #17121f 72%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -30px 80px rgba(5, 2, 10, 0.42);
  transform: translateX(-50%);
  animation: moonSheetReveal 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  overscroll-behavior: contain;
}

.moon-sheet-grabber {
  display: block;
  width: 38px;
  height: 4px;
  margin: 0 auto 18px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.moon-sheet-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.moon-sheet-heading p,
.moon-sheet-heading h2 {
  margin: 0;
}

.moon-sheet-heading p {
  margin-bottom: 6px;
  color: rgba(239, 212, 134, 0.66);
  font-size: 10px;
}

.moon-sheet-heading h2 {
  color: #fff9e9;
  font-family: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  font-size: 25px;
  font-weight: 560;
  line-height: 1.35;
}

.moon-sheet-close {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  color: rgba(255, 255, 255, 0.58);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
}

.moon-sheet-close svg {
  width: 18px;
  height: 18px;
}

.moon-detail-visual {
  position: relative;
  display: grid;
  min-height: 128px;
  place-items: center;
}

.moon-detail-visual::before {
  position: absolute;
  width: 92px;
  height: 92px;
  content: "";
  background: rgba(239, 197, 103, 0.22);
  border-radius: 50%;
  filter: blur(26px);
}

.moon-detail-visual canvas {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.38));
}

.moon-detail-support {
  max-width: 30em;
  margin: 2px auto 17px;
  color: rgba(244, 239, 249, 0.73);
  font-family: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  font-size: 16px;
  line-height: 1.75;
  text-align: center;
}

.moon-start-talk {
  display: flex;
  width: 100%;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #2a2237;
  font: inherit;
  font-size: 14px;
  font-weight: 580;
  background: linear-gradient(135deg, #e8def2, #a9d7ce);
  border: 0;
  border-radius: 8px;
}

.moon-start-talk svg {
  width: 16px;
  height: 16px;
}

.moon-science-details {
  margin-top: 12px;
  padding-top: 2px;
}

.moon-science-details summary {
  padding: 14px 2px;
  color: rgba(239, 232, 246, 0.54);
  font-size: 12px;
  cursor: pointer;
}

.moon-science-details > p {
  margin: 0;
  color: rgba(239, 233, 244, 0.55);
  font-size: 12px;
  line-height: 1.75;
}

.moon-detail-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 15px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}

.moon-detail-metrics > span {
  display: flex;
  min-width: 0;
  min-height: 68px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  padding: 10px 5px;
  background: rgba(23, 18, 31, 0.82);
  text-align: center;
}

.moon-detail-metrics small {
  color: rgba(255, 255, 255, 0.35);
  font-size: 9px;
}

.moon-detail-metrics strong {
  overflow: hidden;
  max-width: 100%;
  color: rgba(255, 249, 235, 0.86);
  font-size: 14px;
  font-weight: 540;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moon-boundary {
  margin-top: 14px !important;
  color: rgba(216, 208, 222, 0.38) !important;
  font-size: 10px !important;
  text-align: center;
}

.moon-location-copy {
  max-width: 34em;
  margin: 10px 0 18px;
  color: rgba(238, 231, 243, 0.5);
  font-size: 12px;
  line-height: 1.7;
}

.moon-location-search {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  min-height: 50px;
  align-items: center;
  gap: 9px;
  padding: 5px 6px 5px 15px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.moon-location-search svg {
  width: 16px;
  height: 16px;
  color: rgba(255, 255, 255, 0.42);
}

.moon-location-search input {
  min-width: 0;
  color: #fff;
  font: inherit;
  font-size: 14px;
  outline: 0;
  background: transparent;
  border: 0;
}

.moon-location-search input::placeholder {
  color: rgba(255, 255, 255, 0.28);
}

.moon-location-search button {
  min-height: 38px;
  padding: 0 14px;
  color: #2c2339;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  background: var(--moon-gold);
  border: 0;
  border-radius: 6px;
}

.moon-use-location,
.moon-location-results button {
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  gap: 12px;
  color: inherit;
  font: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.moon-use-location {
  min-height: 62px;
  padding: 10px 5px;
}

.moon-use-location > svg:first-child {
  width: 20px;
  color: var(--moon-gold);
}

.moon-use-location > span,
.moon-location-results button > span {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 3px;
}

.moon-use-location strong,
.moon-location-results strong {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 560;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moon-use-location small,
.moon-location-results small {
  overflow: hidden;
  color: rgba(255, 255, 255, 0.36);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.moon-use-location > svg:last-child,
.moon-location-results button > svg {
  width: 14px;
  color: rgba(255, 255, 255, 0.3);
}

.moon-location-results {
  max-height: 250px;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.moon-location-results button {
  min-height: 56px;
  padding: 9px 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

.moon-location-results button:focus-visible,
.moon-location-results button:hover {
  outline: 0;
  background: rgba(239, 212, 134, 0.06);
}

.moon-location-status {
  min-height: 18px;
  margin: 9px 2px 0;
  color: rgba(239, 212, 134, 0.62);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

.moon-response-anchor {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 0 0 18px;
  padding: 0 0 17px;
  border-bottom: 1px solid rgba(82, 73, 91, 0.1);
}

.moon-response-visual {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
}

.moon-response-visual::before {
  position: absolute;
  width: 34px;
  height: 34px;
  content: "";
  background: rgba(231, 192, 104, 0.2);
  border-radius: 50%;
  filter: blur(8px);
}

.moon-response-visual canvas {
  position: relative;
  z-index: 1;
}

.moon-response-anchor > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.moon-response-anchor small {
  color: #82769e;
  font-size: 10px;
}

.moon-response-anchor strong {
  color: #514a58;
  font-family: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
  font-size: 14px;
  font-weight: 520;
  line-height: 1.65;
}

.v6-web .moon-response-anchor {
  max-width: 720px;
  grid-template-columns: 50px minmax(0, 1fr);
  margin-bottom: 22px;
  padding-bottom: 20px;
}

.v6-web .moon-response-anchor strong {
  font-size: 15px;
}

/* Mobile: the lunar rhythm stays compact enough to leave the listening path visible. */
.v6 .app-intro {
  min-height: 348px;
  background:
    radial-gradient(ellipse at 50% 33%, rgba(116, 99, 166, 0.22), transparent 45%),
    linear-gradient(180deg, #15111f 0%, #201a34 70%, #293256 100%);
}

.v6 .app-intro::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  opacity: 0.26;
  background-image:
    radial-gradient(circle at 14% 28%, rgba(255, 255, 255, 0.42) 0 1px, transparent 1.2px),
    radial-gradient(circle at 82% 22%, rgba(255, 228, 176, 0.34) 0 1px, transparent 1.2px),
    radial-gradient(circle at 68% 54%, rgba(255, 255, 255, 0.25) 0 1px, transparent 1.2px);
}

.v6 .mobile-top,
.v6 .moon-hero {
  position: relative;
  z-index: 1;
}

.v6 .moon-hero {
  padding-top: 1px;
}

.v6 .moon-context-line {
  margin-top: 4px;
}

.v6 .moon-phase-rail {
  margin-top: 4px;
}

.v6 .tonight-moon-link {
  width: 100%;
  margin-top: -2px;
}

.v6 .moon-hero-copy {
  margin-top: 7px;
}

.v6 .moon-hero-copy h1 {
  font-size: 29px;
  font-weight: 540;
  line-height: 1.34;
}

.v6 .moon-hero-copy p {
  margin-top: 4px;
  font-size: 14px;
}

.v6 .moon-hero-copy small {
  margin-top: 3px;
  font-size: 11px;
}

body.v6[data-dictation-visual="listening"] .moon-day.is-today .moon-day-visual {
  animation: moonListeningBreathe 10s ease-in-out infinite;
}

body.v6[data-dictation-visual="listening"] .moon-day.is-today .moon-day-halo {
  background: rgba(142, 212, 201, 0.34);
  animation: moonListeningHalo 10s ease-in-out infinite;
}

/* Desktop: same lunar source, expressed as one calm header instead of a separate data widget. */
.v6-web .lunar-panel {
  min-height: 302px;
  padding: 26px 42px 30px;
  background:
    radial-gradient(circle at 50% 11%, rgba(123, 102, 174, 0.21), transparent 38%),
    linear-gradient(145deg, #21182f, #292443 62%, #293554);
}

.v6-web .desktop-moon-context {
  width: min(100%, 760px);
  margin: 0 auto 2px;
}

.v6-web .desktop-moon-phases {
  width: min(100%, 760px);
  margin: 0 auto 5px;
}

.v6-web .moon-day {
  min-height: 92px;
}

.v6-web .moon-day-visual {
  width: 62px;
  height: 58px;
}

.v6-web .desktop-tonight-moon {
  margin: 0 auto 5px;
}

.v6-web .hero-copy h1 {
  max-width: 780px;
  margin-inline: auto;
  font-size: 30px;
  font-weight: 580;
}

.v6-web .hero-copy > p:last-child {
  max-width: 680px;
  margin-inline: auto;
  color: rgba(224, 217, 234, 0.68);
}

body.v6-web[data-dictation-visual="listening"] .moon-day.is-today .moon-day-visual {
  animation: moonListeningBreathe 10s ease-in-out infinite;
}

@keyframes moonHaloBreathe {
  0%, 100% { opacity: 0.45; transform: scale(0.86); }
  50% { opacity: 0.9; transform: scale(1.18); }
}

@keyframes moonListeningBreathe {
  0%, 100% { transform: scale(0.94); }
  40% { transform: scale(1.09); }
}

@keyframes moonListeningHalo {
  0%, 100% { opacity: 0.38; transform: scale(0.82); }
  40% { opacity: 0.92; transform: scale(1.42); }
}

@keyframes moonSheetReveal {
  from { opacity: 0.55; transform: translateX(-50%) translateY(28px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@media (min-width: 720px) {
  .moon-sheet {
    bottom: 50%;
    width: min(520px, calc(100% - 48px));
    max-height: min(760px, calc(100vh - 72px));
    padding: 14px 28px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 12px;
    transform: translate(-50%, 50%);
    animation-name: moonDialogReveal;
  }

  .moon-sheet-grabber {
    display: none;
  }
}

@media (max-width: 350px) {
  .moon-phase-rail {
    grid-template-columns: repeat(7, minmax(34px, 1fr));
  }

  .moon-day-visual {
    width: 39px;
  }

  .moon-privacy-cue {
    max-width: 92px;
  }

  .v6 .app-intro {
    min-height: 340px;
  }

  .v6 .moon-hero-copy h1 {
    font-size: 26px;
  }
}

@media (max-height: 650px) {
  .v6 .app-intro {
    min-height: 306px;
  }

  .v6 .moon-day {
    min-height: 70px;
  }

  .v6 .moon-day-visual {
    height: 39px;
    transform: scale(0.86);
  }

  .v6 .moon-hero-copy {
    margin-top: 2px;
  }

  .v6 .moon-hero-copy h1 {
    font-size: 25px;
  }
}

@keyframes moonDialogReveal {
  from { opacity: 0.55; transform: translate(-50%, calc(50% + 18px)); }
  to { opacity: 1; transform: translate(-50%, 50%); }
}

@media (prefers-reduced-motion: reduce) {
  .moon-day-halo,
  body[data-dictation-visual="listening"] .moon-day.is-today .moon-day-visual {
    animation: none !important;
  }
}
