:root {
  --bg: #f6f4ef;
  --panel: #ffffff;
  --ink: #1d2430;
  --muted: #687385;
  --line: #d9dedf;
  --good: #13966b;
  --good-soft: #e0f3ec;
  --risk: #e07b39;
  --risk-soft: #fff0e6;
  --route: #e44893;
  --sky: #2c6fb7;
  --sun: #f5b642;
  --shadow: 0 18px 50px rgba(38, 48, 62, 0.14);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", sans-serif;
}

/* Leaflet positioning fallback. Kept local so the map still renders if CDN CSS is slow. */
.leaflet-container {
  overflow: hidden;
  outline-offset: 1px;
  touch-action: none;
}

.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;
  top: 0;
  left: 0;
}

.leaflet-tile {
  width: 256px;
  height: 256px;
  border: 0;
  user-select: none;
}

.leaflet-tile-loaded {
  visibility: inherit;
}

.leaflet-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  clear: both;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-left .leaflet-control {
  float: left;
  margin-left: 10px;
}

.leaflet-right .leaflet-control {
  float: right;
  margin-right: 10px;
}

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

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

.leaflet-control-zoom a {
  display: block;
  width: 30px;
  height: 30px;
  background: #fff;
  border-bottom: 1px solid #ccd4d8;
  color: #1d2430;
  line-height: 30px;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
}

.leaflet-control-zoom a:first-child {
  border-radius: 6px 6px 0 0;
}

.leaflet-control-zoom a:last-child {
  border-bottom: 0;
  border-radius: 0 0 6px 6px;
}

.leaflet-control-attribution {
  padding: 3px 6px;
  background: rgba(255, 255, 255, 0.84);
  color: #536170;
  font-size: 11px;
}

.leaflet-control-attribution a {
  color: #2c6fb7;
}

.leaflet-popup {
  position: absolute;
  margin-bottom: 20px;
  text-align: center;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(29, 36, 48, 0.2);
}

.leaflet-popup-tip-container {
  position: absolute;
  left: 50%;
  width: 40px;
  height: 20px;
  margin-left: -20px;
  overflow: hidden;
  pointer-events: none;
}

.leaflet-popup-tip {
  width: 16px;
  height: 16px;
  margin: -8px auto 0;
  background: #fff;
  transform: rotate(45deg);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  min-height: 100vh;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 5;
}

.title-block {
  display: grid;
  gap: 7px;
}

.eyebrow {
  margin: 0;
  color: var(--sky);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.65rem, 4vw, 2.35rem);
  line-height: 1.12;
}

.lead {
  color: var(--muted);
  line-height: 1.7;
}

.controls {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.field span {
  font-size: 0.88rem;
}

.field input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
}

.field input:focus-visible,
.quick-times button:focus-visible {
  outline: 3px solid rgba(44, 111, 183, 0.25);
  outline-offset: 2px;
}

.quick-times {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.quick-times button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

.quick-times button:hover {
  background: #eef5f7;
  border-color: #b9ccd3;
}

.sun-card {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 18px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdfa, #f9fbfb);
}

.compass-ring {
  position: relative;
  width: 96px;
  height: 96px;
  border: 2px solid #c7d0d5;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 0 46%, transparent 47%),
    conic-gradient(from 0deg, #edf5f7, #fff7e3, #edf5f7, #eef4ef);
}

.compass-ring span {
  position: absolute;
  color: #536170;
  font-size: 0.68rem;
  font-weight: 800;
}

.north {
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
}

.east {
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
}

.south {
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
}

.west {
  top: 50%;
  left: 7px;
  transform: translateY(-50%);
}

.sun-needle {
  position: absolute;
  inset: 12px;
  transform: rotate(180deg);
  transform-origin: center;
  transition: transform 220ms ease;
}

.sun-needle::before {
  content: "";
  position: absolute;
  top: 1px;
  left: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 5px rgba(245, 182, 66, 0.2);
  transform: translateX(-50%);
}

.sun-needle::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 50%;
  width: 3px;
  height: 30px;
  border-radius: 999px;
  background: rgba(29, 36, 48, 0.55);
  transform: translateX(-50%);
}

.sun-detail {
  display: grid;
  gap: 12px;
}

.status {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.45;
}

dl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
}

dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

dd {
  margin: 3px 0 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

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

.legend i {
  width: 24px;
  height: 5px;
  border-radius: 999px;
}

.legend-good {
  background: var(--good);
}

.legend-risk {
  background: var(--risk);
}

.legend-route {
  background: var(--route);
}

.recommendations {
  display: grid;
  gap: 10px;
}

h2 {
  font-size: 1rem;
}

.recommendation-list {
  display: grid;
  gap: 8px;
}

.recommendation-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--good);
  border-radius: 8px;
  background: #fbfcfb;
}

.recommendation-card.risk {
  border-left-color: var(--risk);
  background: var(--risk-soft);
}

.recommendation-card.night {
  border-left-color: var(--sky);
  background: #eef6ff;
}

.recommendation-card strong {
  font-size: 0.95rem;
}

.recommendation-card span {
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.55;
}

.notice {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.65;
}

.notice a {
  color: var(--sky);
  font-weight: 800;
}

.map-panel {
  position: relative;
  min-height: 100vh;
}

#map {
  position: absolute;
  inset: 0;
  background: #dfe9e6;
}

.area-label {
  padding: 4px 8px;
  border: 1px solid rgba(19, 150, 107, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(20, 35, 45, 0.16);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.leaflet-popup-content {
  margin: 12px 14px;
  color: var(--ink);
  line-height: 1.55;
}

.leaflet-popup-content strong {
  display: block;
  margin-bottom: 3px;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    min-height: auto;
    padding: 20px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .map-panel {
    min-height: 62vh;
  }

  #map {
    position: relative;
    height: 62vh;
  }

  .sun-card {
    grid-template-columns: 88px 1fr;
    gap: 14px;
  }

  .compass-ring {
    width: 82px;
    height: 82px;
  }
}

@media (max-width: 430px) {
  .control-panel {
    padding: 16px;
  }

  .quick-times {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sun-card {
    grid-template-columns: 1fr;
  }
}
