:root {
  --night: #12162a;
  --night-2: #1b2140;
  --glass: rgba(16, 20, 40, 0.82);
  --glass-edge: rgba(255, 197, 61, 0.22);
  --gold: #ffc53d;
  --coral: #ff7846;
  --cream: #fff3d6;
  --ink: #f3ecdd;
  --muted: #a8a795;
  --sea: #4a5f8a;
  --radius: 18px;
  --font-display: "Fraunces", serif;
  --font-body: "Figtree", sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--night);
  color: var(--ink);
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
  background: #0d1122;
}

/* soft vignette over the satellite imagery */
#map::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 400;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(10, 12, 28, 0.55) 100%);
}

/* ---------------------------------------------------------------- panel */
.panel {
  position: fixed;
  z-index: 1000;
  top: 18px;
  left: 18px;
  width: 348px;
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  scrollbar-width: thin;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  padding: 20px 20px 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.brand { display: flex; gap: 14px; align-items: flex-start; }

.brand-sun {
  flex: 0 0 42px;
  height: 42px;
  margin-top: 3px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #fff0b3, var(--gold) 55%, var(--coral));
  box-shadow: 0 0 22px rgba(255, 197, 61, 0.55), 0 0 60px rgba(255, 120, 70, 0.25);
  position: relative;
  overflow: hidden;
}

.brand-sun::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 38%;
  background: linear-gradient(rgba(28, 38, 70, 0.2), #1c2646 60%);
}

h1 {
  font-family: var(--font-display);
  font-weight: 560;
  font-size: 1.62rem;
  letter-spacing: 0.01em;
  line-height: 1.1;
}

h1 em {
  font-style: italic;
  font-weight: 380;
  color: var(--gold);
}

.tagline {
  margin-top: 5px;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.35;
}

.controls { margin-top: 16px; display: grid; gap: 10px; }

.lbl {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.date-row, .opacity-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

input[type="date"] {
  flex: 1;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--cream);
  background: var(--night-2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 12px;
  color-scheme: dark;
}

input[type="date"]:focus-visible,
.seg-btn:focus-visible,
input[type="range"]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--night-2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.seg-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 8px 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.seg-btn.active {
  color: #221a06;
  background: linear-gradient(135deg, var(--cream), var(--gold));
  box-shadow: 0 2px 10px rgba(255, 197, 61, 0.35);
}

input[type="range"] {
  flex: 1;
  accent-color: var(--gold);
}

/* ---------------------------------------------------------------- day stats */
.daycard {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.daystat {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.daystat .k {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  line-height: 1.25;
}

.daystat .v {
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 500;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- legends */
.legend { margin-top: 14px; }

.grad {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    #241242 0%, #6a1b6a 25%, #c43c4e 50%, #f47930 72%, #ffb73d 88%, #ffec9e 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.grad-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 4px;
  padding: 0 2px;
}

.tick-sunset { color: var(--gold); font-weight: 700; }

.legend-note, .hint {
  margin-top: 8px;
  font-size: 0.73rem;
  line-height: 1.45;
  color: var(--muted);
}

.chips { display: grid; gap: 6px; }

.chip {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.78rem;
}

.chip i {
  flex: 0 0 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.hint {
  border-top: 1px dashed rgba(255, 255, 255, 0.14);
  padding-top: 10px;
  margin-top: 14px;
}

/* ---------------------------------------------------------------- point card */
.pointcard {
  position: fixed;
  z-index: 1001;
  top: 18px;
  right: 18px;
  width: 380px;
  max-width: calc(100vw - 36px);
  max-height: calc(100dvh - 36px);
  overflow-y: auto;
  scrollbar-width: thin;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.pointcard .close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.2s;
}

.pointcard .close:hover { background: rgba(255, 255, 255, 0.18); }

.pc-cat {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 197, 61, 0.15);
  color: var(--gold);
  border: 1px solid rgba(255, 197, 61, 0.4);
}

.pc-cat.cat-2 { background: rgba(255, 120, 70, 0.15); color: var(--coral); border-color: rgba(255, 120, 70, 0.4); }
.pc-cat.cat-1 { background: rgba(122, 140, 178, 0.15); color: #aebcd8; border-color: rgba(122, 140, 178, 0.4); }
.pc-cat.cat-0 { background: rgba(90, 98, 120, 0.2); color: #97a0b4; border-color: rgba(120, 130, 150, 0.4); }

.pc-head h2 {
  font-family: var(--font-display);
  font-weight: 540;
  font-size: 1.3rem;
  margin-top: 9px;
}

.pc-sub { font-size: 0.75rem; color: var(--muted); margin-top: 3px; }

.pc-times {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 8px;
}

.pc-time {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pc-time.main {
  background: linear-gradient(135deg, rgba(255, 197, 61, 0.16), rgba(255, 120, 70, 0.1));
  border-color: rgba(255, 197, 61, 0.35);
}

.pc-time .k {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.pc-time .v {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 550;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}

.pc-time.main .v { color: var(--gold); }

.pc-block {
  margin-top: 12px;
  font-size: 0.82rem;
  line-height: 1.5;
}

.chart-wrap { margin-top: 16px; }

.chart-wrap h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

#chart {
  width: 100%;
  background: linear-gradient(180deg, #232a4d 0%, #3d3358 45%, #7c3b55 78%, #b0563f 100%);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chart-note { font-size: 0.7rem; color: var(--muted); margin-top: 7px; line-height: 1.45; }

.chart-note .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--cream);
  box-shadow: 0 0 6px var(--gold);
  vertical-align: -1px;
}

/* ---------------------------------------------------------------- misc */
.loader {
  position: fixed;
  z-index: 1200;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 0.85rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.loader-sun {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: conic-gradient(var(--gold), var(--coral), var(--gold));
  animation: spin 1.1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.credits {
  position: fixed;
  z-index: 900;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: rgba(240, 235, 215, 0.55);
  background: rgba(10, 12, 28, 0.5);
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 96vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaflet-control-attribution { display: none; }

.leaflet-control-zoom {
  border: 1px solid var(--glass-edge) !important;
  border-radius: 10px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: var(--glass) !important;
  color: var(--cream) !important;
  backdrop-filter: blur(8px);
}

.sun-marker {
  filter: drop-shadow(0 0 6px rgba(255, 197, 61, 0.8));
}

/* ---------------------------------------------------------------- mobile */
.controls > *, .daycard > *, .pc-times > *, .chips > * { min-width: 0; }
input[type="date"] { min-width: 0; max-width: 100%; }
.seg-btn { min-width: 0; }

@media (max-width: 720px) {
  .panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-width: 100vw;
    max-height: 46dvh;
    border-radius: 20px 20px 0 0;
    padding: 14px 16px calc(12px + env(safe-area-inset-bottom));
  }

  h1 { font-size: 1.3rem; }
  .tagline { display: none; }
  .hint { display: none; }
  .daycard { grid-template-columns: 1fr 1fr; }

  .pointcard {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: 52dvh;
  }

  .credits { display: none; }
}
