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

body {
  font-family: system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  padding: 0.42rem 0.88rem 0.14rem;
  color: #151719;
  background:
    radial-gradient(circle at 20% 0%, rgba(52, 107, 170, 0.22), transparent 28rem),
    linear-gradient(135deg, #090b12 0%, #1d2530 42%, #e7e3d2 100%);
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.7rem;
  color: #f7f5ed;
  margin-bottom: 0.28rem;
}
h1 { font-size: 1.22rem; font-weight: 650; letter-spacing: 0; }
.meta { font-size: 0.73rem; color: rgba(247,245,237,0.72); margin-top: 0.04rem; }
.site-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  padding: 0.16rem;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  box-shadow: 0 10px 28px rgba(0,0,0,0.16);
}
.site-nav a {
  display: inline-grid;
  place-items: center;
  width: 1.72rem;
  height: 1.72rem;
  border-radius: 6px;
  color: rgba(247,245,237,0.84);
  text-decoration: none;
  font-size: 1rem;
  line-height: 1;
}
.site-nav a:hover { background: rgba(255,255,255,0.14); }
.site-nav a.active {
  background: rgba(255,255,255,0.88);
  color: #151719;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
}

.controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.34rem;
  margin-bottom: 0.24rem;
  padding: 0.3rem 0.5rem;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: rgba(255,255,255,0.88);
  box-shadow: 0 10px 28px rgba(0,0,0,0.18);
  font-size: 0.82rem;
}
.controls label { color: #4c535d; }
.controls select,
.controls input,
.controls button {
  height: 1.9rem;
  border: 1px solid #c7ccd2;
  border-radius: 6px;
  background: #fff;
  color: #22272f;
  font: inherit;
}
.controls select { padding: 0 0.48rem; }
.controls input { padding: 0 0.48rem; }
.controls input[type="datetime-local"] {
  position: absolute;
  right: 0;
  top: 0;
  width: 2rem;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}
.date-field { position: relative; display: inline-flex; align-items: center; }
.date-display {
  width: 10.7rem;
  padding-right: 2.6rem !important;
}
.picker-btn {
  position: absolute;
  right: 0.18rem;
  top: 50%;
  transform: translateY(-50%);
  height: 1.45rem !important;
  min-width: 2rem;
  padding: 0 0.32rem !important;
  font-size: 0.7rem;
  background: #f2f4f6 !important;
}
.picker-popover {
  position: absolute;
  z-index: 10;
  left: 0;
  top: calc(100% + 0.28rem);
  display: flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.38rem;
  border: 1px solid #c7ccd2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(0,0,0,0.18);
}
.picker-popover[hidden] { display: none; }
.picker-popover input,
.picker-popover select,
.picker-popover button {
  height: 1.78rem;
  font-size: 0.78rem;
}
.picker-popover input { width: 8.4rem; }
.picker-popover select { width: 3.1rem; padding: 0 0.28rem; }
.picker-popover button { padding: 0 0.5rem; }
.controls button { padding: 0 0.68rem; cursor: pointer; }
.controls .nav-btn {
  min-width: 2rem;
  padding: 0 0.52rem;
  font-size: 0.92rem;
  line-height: 1;
}
.controls button:hover { background: #eef2f5; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.28rem;
  margin-bottom: 0.24rem;
}
.stat-card,
.info-card,
.sky-panel,
.moon-panel {
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 10px 28px rgba(0,0,0,0.16);
}
.stat-card {
  min-width: 0;
  padding: 0.42rem 0.56rem;
}
.stat-label {
  display: block;
  margin-bottom: 0.18rem;
  color: #657080;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.stat-value {
  display: block;
  color: #1c222b;
  font-size: 0.94rem;
  font-weight: 750;
  line-height: 1.14;
}
.stat-note {
  display: block;
  margin-top: 0.16rem;
  color: #667085;
  font-size: 0.7rem;
  line-height: 1.25;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18rem;
  gap: 0.34rem;
  margin-bottom: 0.24rem;
}
.sky-panel,
.moon-panel,
.info-card { padding: 0.44rem 0.58rem; }
.sky-panel { position: relative; }
.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.3rem;
  color: #4d5664;
  font-size: 0.86rem;
  font-weight: 650;
}
#time-label { color: #75808e; font-weight: 500; }
#sky {
  display: block;
  width: 100%;
  aspect-ratio: 1100 / 315;
  border-radius: 7px;
  background: linear-gradient(180deg, #07111f 0%, #17283a 48%, #ebe0bd 100%);
}
.sky-tooltip {
  position: absolute;
  z-index: 30;
  max-width: min(19rem, 70vw);
  padding: 0.42rem 0.5rem;
  border: 1px solid rgba(20, 26, 34, 0.14);
  border-radius: 7px;
  background: rgba(18, 24, 33, 0.96);
  color: #f8fafc;
  box-shadow: 0 12px 28px rgba(0,0,0,0.22);
  font-size: 0.72rem;
  line-height: 1.32;
  white-space: pre-line;
  pointer-events: none;
}

.moon-wrap {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: start;
  gap: 0.42rem;
  min-height: 0;
}
.moon {
  width: 6.2rem;
  aspect-ratio: 1;
  border-radius: 50%;
  display: block;
  align-self: center;
  justify-self: center;
  filter: drop-shadow(0 0 1.4rem rgba(255,255,255,0.34));
}
.moon-copy {
  min-width: 0;
  width: 100%;
  text-align: center;
}
.moon-phase { font-size: 1.04rem; font-weight: 750; color: #1d222a; }
.moon-detail { margin-top: 0.28rem; font-size: 0.78rem; color: #657080; line-height: 1.42; }
.eclipse-detail {
  margin-top: 0.52rem;
  padding-top: 0.44rem;
  border-top: 1px solid #e7eaee;
  text-align: left;
}
.eclipse-title {
  margin-bottom: 0.12rem;
  color: #384150;
  font-size: 0.78rem;
  font-weight: 700;
}
.eclipse-detail .line {
  padding: 0.18rem 0;
  font-size: 0.74rem;
}
.eclipse-detail .line span:last-child {
  max-width: 11.2rem;
  line-height: 1.25;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.34rem;
  margin-bottom: 0.24rem;
}
.info-card h2 {
  margin-bottom: 0.28rem;
  color: #384150;
  font-size: 0.9rem;
  font-weight: 700;
}
.line {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.21rem 0;
  border-top: 1px solid #e7eaee;
  font-size: 0.8rem;
  position: relative;
}
.line:first-child { border-top: none; }
.line span:first-child { color: #647084; }
.line span:last-child { color: #202733; font-weight: 650; text-align: right; }
.line[data-tip] { cursor: help; }
.line[data-tip]::after,
.nerd-item[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 20;
  left: 0;
  bottom: calc(100% + 0.32rem);
  width: min(18rem, 78vw);
  padding: 0.42rem 0.5rem;
  border: 1px solid rgba(20, 26, 34, 0.14);
  border-radius: 7px;
  background: rgba(18, 24, 33, 0.96);
  color: #f8fafc;
  box-shadow: 0 12px 28px rgba(0,0,0,0.22);
  font-size: 0.72rem;
  line-height: 1.32;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.25rem);
  transition: opacity 0.12s ease 1s, transform 0.12s ease 1s;
}
.line[data-tip]:hover::after,
.line[data-tip]:focus-within::after,
.nerd-item[data-tip]:hover::after,
.nerd-item[data-tip]:focus-within::after {
  opacity: 1;
  transform: translateY(0);
}

.nerd-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.42rem;
  padding: 0.38rem 0.54rem;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 10px 28px rgba(0,0,0,0.14);
}
.nerd-item {
  min-width: 0;
  font-size: 0.75rem;
  position: relative;
}
.nerd-item[data-tip] { cursor: help; }
.nerd-label {
  display: block;
  color: #687386;
  font-size: 0.64rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.nerd-value {
  display: block;
  margin-top: 0.12rem;
  color: #1d242f;
  font-weight: 700;
}

@media (max-width: 1080px) {
  .info-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nerd-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nerd-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  body { padding: 0.62rem 0.62rem 0.2rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .nerd-strip { grid-template-columns: 1fr; }
  .moon-wrap { grid-template-columns: 1fr; }
  .moon { width: min(72vw, 8rem); }
}

/* ── Body modal (Sun / Moon viewer) ─────────────────────────────────── */
.body-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.body-modal[hidden] { display: none; }

.body-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 16, 0.84);
  backdrop-filter: blur(5px);
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(0.6rem); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
.body-modal-card {
  position: relative;
  z-index: 1;
  width: min(640px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px;
  background: #0c1420;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 32px 80px rgba(0,0,0,0.72), 0 0 0 1px rgba(255,255,255,0.04) inset;
  color: #eeeae0;
  animation: modal-in 0.2s cubic-bezier(0.22,1,0.36,1);
}
.body-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.1rem 0.72rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.body-modal-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #f7f4ec;
}
.body-modal-close {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: rgba(255,255,255,0.5);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.body-modal-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.body-modal-body { padding: 0.6rem 0.9rem 0.8rem; }

/* Lines inside the dark modal */
.body-modal-body .line {
  border-top-color: rgba(255,255,255,0.08);
}
.body-modal-body .line span:first-child { color: rgba(220,216,200,0.56); }
.body-modal-body .line span:last-child  { color: #eeeae0; }

/* ── Sun viewer ──────────────────────────────────────────────────────── */
.sun-tabs {
  display: flex;
  gap: 0.34rem;
  margin-bottom: 0.9rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.sun-tabs::-webkit-scrollbar { display: none; }
.sun-tab {
  padding: 0.26rem 0.6rem;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 20px;
  background: transparent;
  color: rgba(220,216,200,0.7);
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sun-tab:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sun-tab.active {
  background: rgba(246,196,60,0.18);
  border-color: rgba(246,196,60,0.52);
  color: #f6c84c;
}
.sun-img-wrap { text-align: center; }
.sun-img {
  display: block;
  width: min(100%, 460px);
  aspect-ratio: 1;
  margin: 0 auto 0.72rem;
  background: #000;
  transition: filter 0.3s ease;
}
.sun-img.round { border-radius: 50%; }
.sun-img.square { border-radius: 10px; }
.body-img {
  display: block;
  width: min(100%, 460px);
  height: 340px;
  object-fit: contain;
  margin: 0 auto 0.72rem;
  background: #000;
  border-radius: 10px;
  transition: filter 0.3s ease, opacity 0.18s ease;
}
.body-img.is-loading { opacity: 0.18; }
.image-loading {
  width: min(100%, 460px);
  height: 340px;
  margin: 0 auto -340px;
  display: grid;
  place-items: center;
  color: rgba(238,234,224,0.72);
  font-size: 0.78rem;
  background: #05070a;
  border-radius: 10px;
  position: relative;
  z-index: 1;
  pointer-events: none;
}
.image-loading[hidden] { display: none; }
.sun-desc {
  font-size: 0.78rem;
  color: rgba(220,216,200,0.68);
  line-height: 1.44;
  min-height: 3.4em;
  margin-bottom: 0.5rem;
  text-align: left;
}
.sun-meta {
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.67rem;
  color: rgba(220,216,200,0.38);
  text-align: center;
}

/* ── Moon viewer ─────────────────────────────────────────────────────── */
.moon-modal-wrap {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.moon-modal-disc-wrap {
  width: clamp(220px, 30vw, 310px);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  filter: drop-shadow(0 0 2rem rgba(255,255,255,0.22));
}
img.moon-modal-disc {
  width: 116%;
  height: 116%;
  margin: -8%;
  display: block;
  object-fit: cover;
}
canvas.moon-modal-disc {
  width: 100%;
  height: 100%;
  display: block;
}
.moon-modal-info {
  flex: 1;
  min-width: 0;
  padding-top: 0;
}
.moon-modal-phase {
  font-size: 1.04rem;
  font-weight: 700;
  color: #f7f4ec;
  margin-bottom: 0.22rem;
}
#moon { cursor: pointer; }

@media (max-width: 460px) {
  .moon-modal-wrap { flex-direction: column; align-items: center; }
  .moon-modal-disc-wrap { width: min(260px, 70vw); }
}
