:root {
  --ink: #172033;
  --paper: #fffdf6;
  --panel: rgba(255, 255, 255, 0.9);
  --muted: #687083;
  --line: rgba(23, 32, 51, 0.16);
  --sun: #f6b21a;
  --sun-dark: #b45b07;
  --shade: #111827;
  --focus: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% 6%, rgba(246, 178, 26, 0.34), transparent 24rem),
    radial-gradient(circle at 92% 18%, rgba(37, 99, 235, 0.14), transparent 22rem),
    linear-gradient(135deg, #fff8dc 0%, #eff6ff 52%, #eef8f1 100%);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 500;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 246, 0.86);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo,
.nav-link {
  color: inherit;
  text-decoration: none;
  font-weight: 850;
}

.logo {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(23, 32, 51, 0.08);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.nav-link {
  padding: 9px 12px;
  border-radius: 999px;
  color: var(--muted);
}

.nav-link.active,
.nav-link:hover {
  color: var(--ink);
  background: rgba(246, 178, 26, 0.2);
}

.page {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
  gap: 18px;
  margin-bottom: 18px;
}

.hero-copy,
.summary-card,
.control-panel,
.map-card,
.notes-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(23, 32, 51, 0.11);
}

.hero-copy {
  padding: clamp(24px, 5vw, 48px);
  overflow: hidden;
  position: relative;
}

.hero-copy::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -72px;
  width: 230px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #ffeaa3 0 34%, var(--sun) 35% 58%, transparent 59%);
  opacity: 0.72;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--sun-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow.small {
  margin-bottom: 5px;
  font-size: 11px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  position: relative;
  z-index: 1;
  max-width: 12ch;
  margin-bottom: 16px;
  font-size: clamp(42px, 8vw, 86px);
  line-height: 0.9;
  letter-spacing: -0.07em;
}

h2 {
  font-size: 22px;
  letter-spacing: -0.02em;
}

.lede {
  position: relative;
  z-index: 1;
  max-width: 68ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 19px);
  line-height: 1.55;
}

.summary-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.metric {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, #fff, var(--paper));
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.control-panel,
.map-card,
.notes-card {
  padding: 18px;
}

.control-panel {
  position: sticky;
  top: 86px;
}

.panel-title-row,
.map-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.map-status {
  max-width: 46ch;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}

.sun-timebar {
  position: relative;
  margin: 0 0 12px;
  padding: 9px 12px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: #f4f4f5;
  background: #303238;
  box-shadow: inset 0 -3px 0 rgba(246, 178, 26, 0.9);
}

.time-ticks {
  display: grid;
  grid-template-columns: repeat(17, minmax(54px, 1fr));
  gap: 0;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.time-ticks span {
  min-height: 22px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.62);
}

.daylight-band {
  position: absolute;
  left: 12%;
  right: 4%;
  bottom: 0;
  height: 16px;
  background: linear-gradient(90deg, #9fb4d5 0 5%, #c7e9ff 5% 9%, #ffe99a 9% 100%);
}

.time-thumb {
  position: absolute;
  bottom: -9px;
  width: 30px;
  height: 30px;
  border: 2px solid #ffd59b;
  border-radius: 999px;
  background: #ffad4d;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
  transform: translateX(-50%);
}

.field-grid,
.search-row {
  display: grid;
  gap: 12px;
}

.search-row {
  grid-template-columns: 1fr auto;
  margin-bottom: 14px;
}

.sr-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

input,
button,
textarea {
  font: inherit;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(23, 32, 51, 0.22);
  border-radius: 14px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  color: #16110a;
  font-weight: 900;
  background: linear-gradient(180deg, #ffd771, var(--sun));
  box-shadow: 0 12px 22px rgba(180, 91, 7, 0.2);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

button.secondary {
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line), 0 10px 22px rgba(23, 32, 51, 0.08);
}

button:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
}

.helper-card {
  margin-top: 16px;
  padding: 14px;
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 253, 246, 0.86);
  border: 1px solid var(--line);
  line-height: 1.45;
}

.helper-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.helper-card p {
  margin: 0;
}

.map-shell {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #dbe7df;
}

#shadeMap {
  width: 100%;
  height: min(68vh, 680px);
  min-height: 560px;
}

.sun-path-overlay {
  position: absolute;
  inset: 0;
  z-index: 440;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.overlay-horizon {
  fill: rgba(31, 122, 91, 0.16);
  stroke: rgba(15, 23, 42, 0.45);
  stroke-width: 1.6;
}

.overlay-sector {
  fill: rgba(142, 211, 190, 0.34);
  stroke: none;
}

.overlay-axis {
  stroke: rgba(15, 23, 42, 0.46);
  stroke-width: 1.4;
  stroke-dasharray: 7 7;
}

.overlay-arc {
  fill: none;
  stroke: #facc15;
  stroke-width: 5;
  stroke-linecap: round;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.24));
}

.overlay-ray {
  stroke-linecap: round;
  opacity: 0.88;
}

.overlay-ray.sunrise {
  stroke: #ef7d61;
  stroke-width: 6;
}

.overlay-ray.sunset,
.overlay-ray.current {
  stroke: #f59e0b;
  stroke-width: 6;
}

.overlay-ray.shadow {
  stroke: #111827;
  stroke-width: 5;
  opacity: 0.7;
  stroke-dasharray: 12 9;
}

.overlay-origin {
  fill: rgba(255, 255, 255, 0.8);
  stroke: #ef3b1f;
  stroke-width: 4;
}

.overlay-sun {
  fill: rgba(255, 173, 77, 0.86);
  stroke: #fff1bf;
  stroke-width: 3;
}

.overlay-cardinal {
  dominant-baseline: middle;
  text-anchor: middle;
  fill: #4b5563;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.82);
  stroke-width: 5;
  font-size: 16px;
  font-weight: 900;
}

.map-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 450;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 28px rgba(23, 32, 51, 0.12);
  font-size: 13px;
  font-weight: 800;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--focus);
}

.legend-line {
  width: 22px;
  height: 4px;
  border-radius: 999px;
}

.legend-line.sun {
  background: var(--sun);
}

.legend-line.shade {
  background: var(--shade);
}

.legend-line.arc {
  height: 0;
  border-top: 4px dotted var(--sun);
  background: transparent;
}

.leaflet-container {
  font: inherit;
}

/* Keep the map usable even if the CDN Leaflet CSS is delayed or blocked. */
.leaflet-container {
  overflow: hidden;
  position: relative;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  max-width: none !important;
  max-height: none !important;
}

.leaflet-control-container .leaflet-top,
.leaflet-control-container .leaflet-bottom {
  position: absolute;
  z-index: 1000;
}

.leaflet-control-container .leaflet-top {
  top: 10px;
}

.leaflet-control-container .leaflet-bottom {
  bottom: 10px;
}

.leaflet-control-container .leaflet-left {
  left: 10px;
}

.leaflet-control-container .leaflet-right {
  right: 10px;
}

.leaflet-control {
  clear: both;
  float: left;
}

.leaflet-right .leaflet-control {
  float: right;
}

.leaflet-control-zoom a {
  display: block;
  width: 32px;
  height: 32px;
  color: var(--ink);
  line-height: 32px;
  text-align: center;
  text-decoration: none;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.map-caption {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.notes-card {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.notes-card textarea {
  min-height: 126px;
  resize: vertical;
}

.notes-actions {
  max-width: 520px;
}

.output {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  padding: 14px;
  border: 1px dashed rgba(23, 32, 51, 0.34);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 253, 246, 0.75);
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

  #shadeMap {
    height: 58vh;
    min-height: 440px;
  }
}

@media (max-width: 620px) {
  .header-inner,
  .map-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav,
  .map-status {
    justify-content: flex-start;
    text-align: left;
  }

  .inline-fields,
  .button-row,
  .search-row {
    grid-template-columns: 1fr;
  }

  .sun-timebar {
    padding-inline: 8px;
  }

  .time-ticks {
    grid-template-columns: repeat(17, 58px);
    overflow-x: auto;
  }

  #shadeMap {
    min-height: 380px;
  }
}
