* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", Arial, sans-serif;
  background: #f8fafc;
  color: #111827;
}

#appShell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.86);
  backdrop-filter: blur(2px);
}

.loading-overlay__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  padding: 0.95rem 1.15rem;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  color: #0f172a;
}

.loading-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid #cbd5e1;
  border-top-color: #2563eb;
  animation: loading-spin 0.8s linear infinite;
}

.loading-text {
  font-size: 0.92rem;
  font-weight: 600;
}

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

.timeline-bar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.93);
  color: #0f172a;
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(148, 163, 184, 0.55);
}

.timeline-actions {
  display: flex;
  gap: 0.4rem;
}

.timeline-slider-wrap {
  flex: 1;
  min-width: 180px;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
  opacity: 0.9;
}

#timeSlider {
  width: 100%;
  margin: 0;
}

.icon-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 6px;
  padding: 0.42rem 0.62rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.play-btn {
  font-weight: 700;
}

.datetime-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.region-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.datetime-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 6px;
  padding: 0.48rem 0.62rem;
  font-size: 0.98rem;
  min-width: 0;
  text-align: left;
  cursor: pointer;
}

.datetime-btn--warning {
  border-color: #f59e0b;
}

.region-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 6px;
  padding: 0.48rem 0.62rem;
  font-size: 0.98rem;
  min-width: 0;
  text-align: left;
  cursor: pointer;
}

.region-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 170px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  padding: 0.5rem;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
  z-index: 1100;
}

.region-menu label {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 0.3rem;
  color: #475569;
}

.region-menu select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.36rem 0.42rem;
  font-size: 0.92rem;
}

.hidden-date-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}

.floating-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  border: 1px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  border-radius: 8px;
  padding: 0.52rem 0.72rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.floating-btn--legend {
  left: auto;
  right: 12px;
}

.timeline-bar--dark {
  background: rgba(17, 24, 39, 0.92);
  color: #f9fafb;
  border-color: rgba(255, 255, 255, 0.2);
}

.timeline-bar--dark .icon-btn,
.timeline-bar--dark .datetime-btn,
.timeline-bar--dark .region-btn {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #f9fafb;
}

.timeline-bar--dark .datetime-btn--warning {
  border-color: #f59e0b;
}

.timeline-bar--dark .region-menu {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 10px 22px rgba(2, 6, 23, 0.45);
}

.timeline-bar--dark .region-menu label {
  color: #cbd5e1;
}

.timeline-bar--dark .region-menu select {
  background: rgba(30, 41, 59, 0.92);
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.35);
}

.timeline-bar--light {
  background: rgba(255, 255, 255, 0.93);
  color: #0f172a;
  border-color: rgba(148, 163, 184, 0.55);
}

#appShell.theme-dark .settings-popup {
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.28);
  box-shadow: 0 10px 25px rgba(2, 6, 23, 0.45);
}

#appShell.theme-dark .about-popup {
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.28);
  box-shadow: 0 10px 25px rgba(2, 6, 23, 0.45);
}

#appShell.theme-dark .warning-popup {
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border-color: rgba(245, 158, 11, 0.75);
  box-shadow: 0 10px 25px rgba(2, 6, 23, 0.45);
}

#appShell.theme-dark .warning-popup__header h2 {
  color: #fbbf24;
}

#appShell.theme-dark .settings-popup__header .icon-btn {
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

#appShell.theme-dark .about-popup__header .icon-btn {
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

#appShell.theme-dark .about-popup__note {
  color: #94a3b8;
}

#appShell.theme-dark .settings-group select {
  background: rgba(30, 41, 59, 0.92);
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.35);
}

#appShell.theme-dark .settings-mini-btn {
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

#appShell.theme-dark .map-legend {
  background: rgba(15, 23, 42, 0.94);
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.28);
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.45);
}

#appShell.theme-dark .loading-overlay {
  background: rgba(2, 6, 23, 0.65);
}

#appShell.theme-dark .loading-overlay__content {
  background: rgba(15, 23, 42, 0.95);
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.35);
}

#appShell.theme-dark .loading-spinner {
  border-color: rgba(148, 163, 184, 0.55);
  border-top-color: #93c5fd;
}

#appShell.theme-dark .legend-dot {
  border-color: #e2e8f0;
}

#appShell.theme-dark .legend-subtitle {
  color: #94a3b8;
}

.settings-popup {
  position: absolute;
  top: 64px;
  left: 12px;
  width: 300px;
  max-height: calc(100vh - 80px);
  overflow: auto;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 0.75rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
}

.settings-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.settings-popup__header-actions {
  display: inline-flex;
  gap: 0.35rem;
}

.settings-popup__header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.settings-popup__header .icon-btn {
  color: #111827;
  border-color: #cbd5e1;
  background: #f8fafc;
}

.settings-group {
  margin-bottom: 0.85rem;
}

.settings-group h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
}

.settings-group__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.settings-group__header h3 {
  margin: 0;
}

.settings-group__actions {
  display: inline-flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.settings-mini-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 6px;
  padding: 0.22rem 0.45rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.settings-group label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.95rem;
}

.settings-group select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.38rem 0.42rem;
  font-size: 0.95rem;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
}

.about-popup {
  position: absolute;
  top: 64px;
  left: 324px;
  width: 390px;
  max-height: calc(100vh - 80px);
  overflow: auto;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 0.75rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
}

.warning-popup {
  position: absolute;
  top: 82px;
  right: 314px;
  width: 360px;
  max-height: calc(100vh - 80px);
  overflow: auto;
  z-index: 1200;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #f59e0b;
  border-radius: 10px;
  padding: 0.75rem;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
}

.warning-popup__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem;
  margin-bottom: 0.6rem;
}

.warning-popup__header h2 {
  margin: 0;
  font-size: 1.08rem;
  color: #92400e;
}

.warning-popup p {
  margin: 0;
  line-height: 1.4;
  font-size: 0.95rem;
}

.about-popup__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.55rem;
  margin-bottom: 0.6rem;
}

.about-popup__header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.about-popup p {
  margin: 0 0 0.65rem;
  line-height: 1.4;
  font-size: 0.95rem;
}

.about-popup__section {
  margin: 0.8rem 0 0.65rem;
}

.about-popup__section h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.about-popup__note {
  margin-top: 0.8rem;
  font-size: 0.82rem;
  color: #6b7280;
}

.map-legend {
  position: absolute;
  right: 12px;
  top: 82px;
  z-index: 950;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  min-width: 290px;
  max-width: 360px;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.map-legend h3 {
  margin: 0;
  font-size: 1.05rem;
}

.map-legend__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.legend-hide-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 6px;
  padding: 0.24rem 0.48rem;
  font-size: 0.78rem;
  cursor: pointer;
}

#appShell.theme-dark .legend-hide-btn {
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(255, 255, 255, 0.08);
}

.legend-subtitle {
  margin: 0.12rem 0 0.5rem;
  font-size: 0.84rem;
  color: #6b7280;
}

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 1rem;
}

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

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #111827;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .timeline-bar {
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .timeline-slider-wrap {
    order: 2;
    width: 100%;
  }

  .datetime-btn {
    min-width: 0;
    flex: 1;
    text-align: left;
  }

  .region-anchor {
    margin-left: auto;
  }

  .settings-popup {
    width: calc(100vw - 24px);
    max-width: 340px;
  }

  .about-popup {
    top: 108px;
    left: 12px;
    width: calc(100vw - 24px);
    max-width: 420px;
  }

  .warning-popup {
    top: 108px;
    left: 12px;
    width: calc(100vw - 24px);
    max-width: 420px;
  }

  .map-legend {
    top: 120px;
    min-width: 230px;
    max-width: calc(100vw - 24px);
  }
}
