﻿body.planthopper-page {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 245, 229, 0.85), transparent 28%),
    radial-gradient(circle at top right, rgba(225, 238, 247, 0.9), transparent 30%),
    linear-gradient(160deg, #eef4f8 0%, #f9fbfd 58%, #e6eef6 100%);
  color: #1d2a36;
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

.planthopper-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: 8px 12px 24px;
}

.ph-hidden {
  display: none;
}

.ph-loading-mask {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(91, 104, 117, 0.42);
  backdrop-filter: blur(2px);
  z-index: 1200;
}

.ph-loading-mask.show {
  display: flex;
}

.ph-loading-panel {
  width: min(360px, calc(100vw - 32px));
  padding: 18px 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(210, 221, 232, 0.96);
  box-shadow: 0 18px 40px rgba(26, 47, 69, 0.18);
}

.ph-loading-title {
  color: #17324d;
  font-size: 18px;
  font-weight: 700;
}

.ph-loading-text {
  margin-top: 8px;
  color: #526577;
  line-height: 1.6;
}

.ph-loading-bar {
  height: 10px;
  margin-top: 14px;
  border-radius: 999px;
  background: #dbe5ee;
  overflow: hidden;
}

.ph-loading-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #9eaab7, #4f677f);
  transition: width 0.25s ease;
}

.ph-loading-progress {
  margin-top: 8px;
  color: #17324d;
  font-weight: 700;
  text-align: right;
}

.ph-card {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(210, 221, 232, 0.9);
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(26, 47, 69, 0.08);
  backdrop-filter: blur(10px);
}

.ph-kicker,
.ph-detail-kicker {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.09);
  color: #0f766e;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.ph-stat-label,
.ph-summary-label,
.ph-detail-list dt {
  display: block;
  margin-bottom: 6px;
  color: #637689;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.ph-stat strong,
.ph-summary-value {
  color: #183149;
  font-size: 16px;
  font-weight: 700;
}

.ph-controls {
  padding: 8px 14px;
  margin-bottom: 12px;
}

.ph-mobile-info {
  display: none;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.ph-mobile-detail summary {
  cursor: pointer;
  color: #17324d;
  font-weight: 700;
}

.ph-mobile-info-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.ph-mobile-info-grid strong {
  color: #183149;
  font-size: 14px;
  line-height: 1.4;
}

.ph-control {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ph-control span {
  color: #5b6c7d;
  font-size: 13px;
  font-weight: 700;
}

.ph-control select {
  height: 44px;
  padding: 10px 12px;
  border: 1px solid #ccd8e3;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  color: #17324d;
  font-size: 15px;
}

.ph-slider-block {
  gap: 10px;
}

.ph-slider {
  margin: 6px 4px 2px;
}

.ph-slider .noUi-target {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #d7e3ee, #f0c4a3);
  box-shadow: inset 0 1px 3px rgba(24, 49, 73, 0.15);
  touch-action: none;
}

.ph-slider .noUi-connects {
  border-radius: 999px;
}

.ph-slider .noUi-connect {
  background: linear-gradient(90deg, #f2a65a, #d97706);
}

.ph-slider .noUi-handle {
  right: -11px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.18), 0 8px 16px rgba(23, 50, 77, 0.16);
  touch-action: none;
}

.ph-slider .noUi-handle:before,
.ph-slider .noUi-handle:after {
  display: none;
}

.ph-slider-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: #5a6f82;
  font-size: 12px;
}

.ph-link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: #0f5e8f;
  font-weight: 700;
}

.ph-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.95fr) 300px;
  gap: 10px;
  align-items: stretch;
  min-height: calc(100dvh - 142px);
  margin-bottom: 12px;
}

.ph-map-card {
  position: relative;
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-height: clamp(420px, calc(100dvh - 170px), 760px);
}

.ph-floating-panel {
  position: absolute;
  right: 18px;
  bottom: 56px;
  z-index: 500;
  width: min(320px, calc(100% - 36px));
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(210, 221, 232, 0.96);
  box-shadow: 0 14px 28px rgba(26, 47, 69, 0.14);
  backdrop-filter: blur(10px);
  cursor: grab;
}

.ph-floating-panel.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.ph-floating-panel button,
.ph-floating-panel select,
.ph-floating-panel .noUi-target,
.ph-floating-panel .noUi-handle {
  cursor: auto;
}

.ph-floating-control {
  gap: 6px;
}

.ph-floating-dates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0 8px;
}

.ph-floating-dates strong {
  color: #183149;
  font-size: 14px;
}

#planthopperMap {
  flex: 1 1 auto;
  height: clamp(420px, calc(100dvh - 190px), 740px);
  min-height: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(210, 221, 232, 0.95);
}

.ph-detail-card {
  padding: 14px 14px 12px;
  background: rgba(255, 255, 255, 0.72);
  height: 100%;
  overflow: auto;
}

.ph-detail-header h2 {
  margin: 8px 0 4px;
  color: #17324d;
  font-size: 20px;
}

.ph-detail-list {
  margin: 10px 0;
}

.ph-detail-list div {
  padding: 8px 0;
  border-top: 1px solid rgba(224, 232, 239, 0.95);
}

.ph-detail-list div:first-child {
  border-top: 0;
}

.ph-detail-list dd {
  margin: 0;
  color: #183149;
  font-weight: 700;
  line-height: 1.45;
  font-size: 14px;
}

.ph-selection-range {
  margin: 0;
  color: #4f6274;
  line-height: 1.45;
  font-size: 13px;
}

.ph-recent-block {
  margin-top: 10px;
}

.ph-recent-list {
  margin: 10px 0 0;
  padding-left: 16px;
  color: #28445f;
  font-size: 13px;
}

.ph-recent-list li {
  margin-bottom: 6px;
  line-height: 1.4;
}

.ph-notes-card {
  padding: 12px 16px;
}

.ph-note-detail summary {
  cursor: pointer;
  color: #17324d;
  font-weight: 700;
}

.ph-note {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 247, 237, 0.92), rgba(255, 251, 245, 0.96));
  border: 1px solid rgba(253, 230, 200, 0.95);
  color: #7c4a19;
  line-height: 1.7;
}

.ph-legend {
  min-width: 118px;
  padding: 7px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(210, 221, 232, 0.95);
  box-shadow: 0 12px 28px rgba(26, 47, 69, 0.14);
  color: #17324d;
}

.ph-legend-title {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
}

.ph-legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 10px;
}

.ph-legend-swatch {
  width: 12px;
  height: 8px;
  border-radius: 3px;
  border: 1px solid rgba(15, 23, 42, 0.16);
}

.leaflet-control-layers {
  border-radius: 12px;
  border: 1px solid rgba(210, 221, 232, 0.95);
  box-shadow: 0 10px 28px rgba(26, 47, 69, 0.16);
}

.leaflet-tooltip.ph-grid-tooltip {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(203, 216, 227, 0.95);
  background: rgba(255, 255, 255, 0.96);
  color: #16324d;
  box-shadow: 0 10px 22px rgba(20, 40, 61, 0.12);
  font-size: 12px;
  line-height: 1.55;
}

.leaflet-bottom.leaflet-right {
  bottom: 4px;
}

.ph-latlon-label {
  color: #5f7387;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(179, 192, 204, 0.75);
  border-radius: 6px;
  padding: 2px 4px;
}

@media (max-width: 1080px) {
  .ph-top-grid {
    grid-template-columns: 1fr;
    min-height: calc(100dvh - 142px);
  }

  .ph-map-card {
    min-height: clamp(400px, calc(100dvh - 180px), 720px);
  }

  #planthopperMap {
    height: clamp(400px, calc(100dvh - 200px), 700px);
  }
}

@media (max-width: 680px) {
  .planthopper-shell {
    padding: 8px 8px 20px;
  }

  .ph-detail-card,
  .ph-notes-card {
    padding: 12px;
  }

  .ph-detail-card,
  .ph-controls {
    display: none;
  }

  .ph-mobile-info {
    display: block;
  }

  .ph-floating-panel {
    right: 10px;
    bottom: 42px;
    width: calc(100% - 20px);
    padding: 8px 10px;
    border-radius: 12px;
  }

  .ph-floating-dates {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 6px 0;
  }

  .ph-floating-dates strong {
    font-size: 12px;
  }

  .ph-floating-panel .ph-summary-label,
  .ph-floating-panel .ph-control span,
  .ph-floating-panel .ph-slider-meta {
    font-size: 11px;
  }

  .ph-floating-panel .ph-control select {
    height: 38px;
    padding: 8px 10px;
    font-size: 14px;
  }

  .ph-slider .noUi-handle {
    right: -14px;
    width: 28px;
    height: 28px;
    box-shadow: 0 0 0 5px rgba(217, 119, 6, 0.2), 0 10px 18px rgba(23, 50, 77, 0.18);
  }

  #planthopperMap {
    height: clamp(320px, calc(100dvh - 190px), 560px);
    min-height: 0;
  }

  .ph-top-grid {
    min-height: calc(100dvh - 88px);
  }

  .ph-map-card {
    min-height: clamp(320px, calc(100dvh - 170px), 580px);
  }

  .ph-slider-meta {
    gap: 6px;
  }

  .ph-legend {
    min-width: 102px;
    padding: 6px 7px;
  }

  .ph-legend.is-collapsed {
    min-width: 34px;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .ph-legend.is-collapsed .ph-legend-title,
  .ph-legend.is-collapsed .ph-legend-row {
    display: none;
  }

  .ph-legend.is-collapsed::before {
    content: "";
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff8db 0%, #fd8d3c 55%, #880808 100%);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
  }
}
