:root {
  --ink: #24352c;
  --ink-soft: #5a6f63;
  --paper: #ffffff;
  --mint-0: #f4fbf7;
  --mint-1: #e3f4ea;
  --mint-2: #bfe5cd;
  --mint-3: #6fbf93;
  --mint-4: #3d9a6c;
  --safe: #5fbf86;
  --safe-soft: #dff6e8;
  --caution: #e0b44a;
  --caution-soft: #fff4d6;
  --alert: #e07a72;
  --alert-soft: #ffe4e1;
  --line: rgba(61, 154, 108, 0.16);
  --shadow: 0 18px 48px rgba(45, 110, 78, 0.1);
  --radius: 22px;
  --font-display: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", sans-serif;
  --font-ui: "Outfit", "M PLUS Rounded 1c", sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: var(--font-ui);
  background:
    radial-gradient(1200px 600px at 12% -10%, #ffffff 0%, transparent 55%),
    radial-gradient(900px 500px at 90% 0%, #d9f3e5 0%, transparent 50%),
    linear-gradient(165deg, #f8fcfa 0%, #eaf6ef 48%, #dff1e7 100%);
  overflow-x: hidden;
}

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite;
}

.orb-a {
  width: 220px;
  height: 220px;
  top: -40px;
  right: 12%;
  background: radial-gradient(circle at 35% 35%, #fff8d6, #ffe8a3 55%, transparent 70%);
}

.orb-b {
  width: 160px;
  height: 160px;
  bottom: 8%;
  left: -30px;
  background: radial-gradient(circle at 40% 40%, #d7f3e6, #a8dfc2 60%, transparent 72%);
  animation-delay: -6s;
}

.cloud {
  position: absolute;
  height: 42px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  filter: blur(0.5px);
  animation: floaty 22s linear infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}

.cloud::before {
  width: 48px;
  height: 48px;
  top: -22px;
  left: 18px;
}

.cloud::after {
  width: 36px;
  height: 36px;
  top: -14px;
  left: 52px;
}

.cloud-a {
  width: 110px;
  top: 14%;
  left: -140px;
}

.cloud-b {
  width: 90px;
  top: 28%;
  left: -180px;
  opacity: 0.4;
  animation-duration: 28s;
  animation-delay: -10s;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2.5rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.topbar .top-mini-nav {
  margin-left: auto;
  align-self: center;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--mint-4);
  line-height: 1.05;
}

.tagline {
  margin: 0.2rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 500;
}

.leg {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.leg i {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  display: inline-block;
}

.leg.safe i {
  background: var(--safe);
}
.leg.caution i {
  background: var(--caution);
}
.leg.alert i {
  background: var(--alert);
}

.map-legend {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1100; /* Leaflet コントロール(1000)より前面 */
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem 0.7rem;
  max-width: min(70%, 22rem);
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 22px rgba(45, 110, 78, 0.12);
  border: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--ink-soft);
  pointer-events: none;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.85rem 1.25rem;
  margin-bottom: 0.95rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 88%, var(--mint-1));
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(45, 110, 78, 0.06);
}

.filter-group {
  display: grid;
  gap: 0.4rem;
}

.filter-label {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--mint-4);
  letter-spacing: 0.04em;
}

.filter-selects {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.field.compact {
  margin: 0;
}

.field.compact select {
  min-width: 9.5rem;
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  font-size: 0.85rem;
}

.btn.compact {
  padding: 0.55rem 0.8rem;
  font-size: 0.8rem;
  white-space: nowrap;
}

.filter-status {
  margin: 0 0 0.15rem auto;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.period-chips .chip {
  min-width: 3.2rem;
  justify-content: center;
}

.stage {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
  gap: 1rem;
  align-items: start;
}

.map-shell {
  position: relative;
  border-radius: calc(var(--radius) + 4px);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: var(--mint-1);
  min-height: 62vh;
}

#map {
  width: 100%;
  height: min(70vh, 720px);
  min-height: 420px;
  background: #dcefe4;
}

.map-hint {
  position: absolute;
  left: 50%;
  bottom: 0.85rem;
  transform: translateX(-50%);
  z-index: 500;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  color: var(--ink-soft);
  font-size: 0.78rem;
  pointer-events: none;
  box-shadow: 0 6px 18px rgba(45, 110, 78, 0.08);
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 700;
  display: grid;
  place-items: center;
  background: rgba(220, 239, 228, 0.72);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.map-loading[hidden] {
  display: none !important;
}

.map-loading-card {
  width: min(92%, 320px);
  padding: 1.1rem 1.2rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(95, 191, 134, 0.28);
  box-shadow: 0 12px 32px rgba(45, 110, 78, 0.12);
  text-align: center;
}

.map-loading-spinner {
  width: 1.7rem;
  height: 1.7rem;
  margin: 0 auto 0.7rem;
  border-radius: 50%;
  border: 3px solid #d7eee1;
  border-top-color: var(--mint-4);
  animation: map-spin 0.8s linear infinite;
}

.map-loading-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--ink);
}

.map-loading-sub {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.map-loading-bar {
  margin: 0.85rem 0 0.45rem;
  height: 6px;
  border-radius: 999px;
  background: #e5f4ec;
  overflow: hidden;
}

.map-loading-bar span {
  display: block;
  height: 100%;
  width: 28%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7ed0a2, #5fbf86);
  animation: map-bar 1.4s ease-in-out infinite;
}

.map-loading-eta {
  margin: 0;
  font-size: 0.74rem;
  color: #8aa394;
}

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

@keyframes map-bar {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(420%);
  }
}

.panel {
  display: grid;
  gap: 0.85rem;
}

.card {
  background: color-mix(in srgb, var(--paper) 92%, var(--mint-1));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem 1.25rem;
  backdrop-filter: blur(10px);
}

.card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.card-sub {
  margin: 0.25rem 0 0.9rem;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.5;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.stat {
  text-align: center;
  padding: 0.7rem 0.35rem;
  border-radius: 16px;
}

.stat.safe {
  background: var(--safe-soft);
}
.stat.caution {
  background: var(--caution-soft);
}
.stat.alert {
  background: var(--alert-soft);
}

.stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
}

.stat.safe .stat-num {
  color: var(--mint-4);
}
.stat.caution .stat-num {
  color: #b88912;
}
.stat.alert .stat-num {
  color: #c44e45;
}

.stat-label {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.detail-kicker {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--mint-4);
  font-weight: 600;
}

.detail-place {
  margin: 0.25rem 0 0.7rem;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.3;
}

.risk-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
  font-family: var(--font-display);
}

.risk-pill[data-level="safe"] {
  background: var(--safe-soft);
  color: var(--mint-4);
}
.risk-pill[data-level="caution"] {
  background: var(--caution-soft);
  color: #9a740f;
}
.risk-pill[data-level="alert"] {
  background: var(--alert-soft);
  color: #c44e45;
}

.risk-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
}

.detail-hint {
  margin: 0.7rem 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.55;
}

.place-detail-field {
  margin-top: 0.65rem;
}

.place-detail-field[hidden] {
  display: none !important;
}

.source-list {
  margin: 0.85rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.35rem;
}

.source-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  padding: 0.4rem 0.55rem;
  border-radius: 10px;
  background: var(--mint-0);
}

.source-list .source-heading {
  justify-content: flex-start;
  background: transparent;
  padding: 0.55rem 0.15rem 0.1rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #8aa394;
}

.source-list .source-link {
  display: grid;
  gap: 0.15rem;
  justify-content: stretch;
}

.source-list .source-kind {
  font-size: 0.7rem;
  color: #8aa394;
}

.source-list .source-link a {
  color: var(--mint-4);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.source-list .source-link a:hover {
  text-decoration: underline;
}

.source-list .report-item {
  display: grid;
  gap: 0.25rem;
  justify-content: stretch;
  background: #f7fbf8;
  border: 1px solid rgba(95, 191, 134, 0.18);
}

.source-list .report-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 0.7rem;
  color: var(--ink);
  font-weight: 600;
}

.source-list .report-place {
  color: var(--mint-4);
}

.source-list .report-count {
  color: var(--ink-soft);
  font-weight: 500;
}

.source-list .report-meta time {
  margin-left: auto;
  font-size: 0.72rem;
  font-weight: 500;
  color: #8aa394;
}

.source-list .report-comment {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.45;
}

.leaflet-popup-content .popup-report {
  margin-top: 0.25rem;
  font-size: 0.82rem;
  color: #4a6356;
}

.leaflet-popup-content .popup-sources {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.25rem;
}

.leaflet-popup-content .popup-link a {
  color: var(--mint-4);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}

.leaflet-popup-content .popup-link a:hover {
  text-decoration: underline;
}

.field {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.field select {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236fbf93' d='M1 1l5 5 5-5'/%3E%3C/svg%3E")
    no-repeat right 0.85rem center;
  border-radius: 14px;
  padding: 0.7rem 2rem 0.7rem 0.85rem;
  font: inherit;
  color: var(--ink);
}

.field select:focus,
.field textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--mint-3) 55%, white);
  outline-offset: 1px;
}

.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 14px;
  padding: 0.7rem 0.85rem;
  font: inherit;
  color: var(--ink);
  resize: vertical;
  min-height: 4.2rem;
}

.step {
  margin-bottom: 0.95rem;
}

.step-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}

.step-label span {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--mint-1);
  color: var(--mint-4);
  font-size: 0.75rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.chip:hover {
  border-color: color-mix(in srgb, var(--mint-3) 70%, white);
}

.chip.is-active {
  background: var(--mint-1);
  color: var(--mint-4);
  border-color: color-mix(in srgb, var(--mint-3) 65%, white);
}

.pin-status {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

#btn-watch-selected {
  width: 100%;
  margin-top: 0.85rem;
}

.alert-form {
  margin-bottom: 0.65rem;
}

.alert-actions {
  margin-top: 0.7rem;
}

.watch-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}

.watch-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  background: var(--mint-0);
  border: 1px solid var(--line);
}

.watch-list .watch-meta {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.watch-list .watch-area {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
}

.watch-list .watch-sub {
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.watch-list .btn-remove {
  border: 0;
  background: transparent;
  color: #c44e45;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.watch-list .empty {
  justify-content: center;
  color: var(--ink-soft);
  font-size: 0.82rem;
  border-style: dashed;
}

.inapp-alerts {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.4rem;
}

.inapp-alerts .flash {
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: var(--caution-soft);
  color: #9a740f;
  font-size: 0.84rem;
  font-family: var(--font-display);
  font-weight: 700;
  animation: rise 0.35s ease;
}

.inapp-alerts .flash.alert {
  background: var(--alert-soft);
  color: #c44e45;
}

.btn.soft {
  width: 100%;
  background: linear-gradient(180deg, #f7fcf9 0%, #e7f5ec 100%);
  color: var(--mint-4);
  border: 1px solid var(--line);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 0.8rem 0.7rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, #62b888 0%, var(--mint-4) 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(61, 154, 108, 0.28);
}

.btn.ghost {
  background: var(--mint-0);
  color: var(--mint-4);
  border: 1px solid var(--line);
}

.form-msg {
  min-height: 1.25rem;
  margin: 0.65rem 0 0;
  font-size: 0.82rem;
  color: var(--mint-4);
}

.form-msg.error {
  color: #c44e45;
}

/* Leaflet tweaks */
.leaflet-container {
  font-family: var(--font-ui);
}

.risk-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 12px rgba(36, 53, 44, 0.22);
  transition: transform 0.2s ease;
}

.risk-marker.is-selected {
  transform: scale(1.35);
  animation: pulse 1.6s ease-in-out infinite;
}

.risk-marker.safe {
  background: var(--safe);
}
.risk-marker.caution {
  background: var(--caution);
}
.risk-marker.alert {
  background: var(--alert);
}

.report-pin {
  width: 22px;
  height: 22px;
  margin: 0 auto;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: linear-gradient(135deg, #7ec8a2, #3d9a6c);
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(45, 110, 78, 0.35);
}

.report-pin::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: #fff;
}

.leaflet-popup-content-wrapper {
  border-radius: 14px;
  box-shadow: var(--shadow);
  font-family: var(--font-display);
}

.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.7s ease forwards;
}

.delay-1 {
  animation-delay: 0.08s;
}
.delay-2 {
  animation-delay: 0.16s;
}
.delay-3 {
  animation-delay: 0.24s;
}
.delay-4 {
  animation-delay: 0.32s;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(61, 154, 108, 0.35);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(61, 154, 108, 0);
  }
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(-18px, 12px);
  }
}

@keyframes floaty {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(calc(100vw + 220px));
  }
}

@media (max-width: 900px) {
  .app {
    width: min(100% - 1.25rem, 1200px);
  }

  .map-legend {
    top: 0.6rem;
    right: 0.6rem;
    left: auto;
    bottom: auto;
    transform: none;
    max-width: calc(100% - 3.5rem);
    font-size: 0.7rem;
  }

  .filter-bar {
    align-items: stretch;
  }

  .filter-status {
    margin: 0;
    width: 100%;
  }

  .filter-selects {
    width: 100%;
  }

  .field.compact {
    flex: 1;
    min-width: 0;
  }

  .field.compact select {
    width: 100%;
    min-width: 0;
  }

  .stage {
    grid-template-columns: 1fr;
  }

  #map {
    height: 48vh;
    min-height: 300px;
  }

  .btn-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal,
  .orb,
  .cloud,
  .risk-marker.is-selected,
  .btn {
    animation: none !important;
    transition: none !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}
