html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
}

.app {
  display: flex;
  width: 100%;
  height: 100%;
  background: #e8ecf1;
  --left: 66.66%;
}

/* 左側地圖區域(可拖拽調寬) */
#mapPane {
  position: relative;
  flex: 0 0 var(--left);
  height: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-right: 1px solid #c9d0d8;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.03);
}

/* 中間拖拽分隔條 */
#divider {
  flex: 0 0 10px;
  width: 10px;
  cursor: col-resize;
  background: #f2f4f7;
  border-left: 1px solid #c9d0d8;
  border-right: 1px solid #c9d0d8;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  touch-action: none;
  user-select: none;
}
#divider::after {
  content: "";
  width: 3px;
  height: 48px;
  border-radius: 2px;
  background: #b7c1cc;
}

/* 右側查看區域 */
#rightPane {
  position: relative;
  flex: 1 1 auto;
  height: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-left: 1px solid #c9d0d8;
  background: #fff;
}

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

/* 左上角切換 tab */
.type-tab {
  position: absolute;
  top: 10px;
  left: 64px;
  z-index: 1000;
  display: flex;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
  border: 1px solid #e2e6ea;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.type-tab button {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-size: 13px;
  color: #555;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.type-tab button.active {
  background: #3d5a80;
  color: #fff;
  font-weight: 600;
}

/* 全景查看器容器 */
#viewer {
  width: 100%;
  height: 100%;
  position: relative;
}

/* 普通影像 + 屬性表面板 */
#imgPanel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  background: #fff;
}
#imgPanel[hidden] {
  display: none;
}
#imgHint {
  padding: 24px 16px;
  font-size: 13px;
  color: #888;
  text-align: center;
}
#imgContent {
  padding: 12px;
}
#imgContent[hidden] {
  display: none;
}
#imgPanelTitle {
  font-size: 14px;
  font-weight: 600;
  color: #3d5a80;
  margin-bottom: 8px;
  word-break: break-all;
}
#imgView {
  width: 100%;
  max-height: 58vh;
  object-fit: contain;
  border-radius: 8px;
  background: #f2f4f7;
  border: 1px solid #e5e9ee;
  margin-bottom: 10px;
  display: block;
}
#attrList {
  margin: 0;
  border: 1px solid #e5e9ee;
  border-radius: 8px;
  overflow: hidden;
}
#attrList .row {
  display: flex;
  font-size: 12px;
  line-height: 1.6;
}
#attrList .row:nth-child(even) {
  background: #fafbfc;
}
#attrList dt {
  flex: 0 0 110px;
  padding: 3px 8px;
  color: #777;
  background: #f4f6f8;
  border-right: 1px solid #e5e9ee;
  text-align: right;
}
#attrList dd {
  flex: 1;
  margin: 0;
  padding: 3px 8px;
  color: #333;
  word-break: break-all;
}

/* 移除 Leaflet 預設外框 */
.pin-marker-wrapper {
  background: transparent !important;
  border: none !important;
}

.pin-marker {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: 16px 16px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.pin-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: 
    drop-shadow( 1px  0px 0 #ffffff)
    drop-shadow(-1px  0px 0 #ffffff)
    drop-shadow( 0px  1px 0 #ffffff)
    drop-shadow( 0px -1px 0 #ffffff)
    drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

/* 選中點位高亮 */
.leaflet-marker-icon.selected .pin-svg line {
  stroke: #ff9800 !important;
  stroke-width: 2.4px !important;
}
.leaflet-marker-icon.selected .pin-svg path,
.leaflet-marker-icon.selected .pin-svg circle {
  fill: #ff9800 !important;
}
.leaflet-marker-icon.selected .pin-marker {
  transform-origin: 16px 16px;
  filter: drop-shadow(0 0 5px rgba(255, 152, 0, 0.9));
}

/* 普通影像前後切換導覽 */
.img-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 8px;
}
.img-nav button {
  flex: 0 0 auto;
  border: 1px solid #d5dbe2;
  background: #fff;
  color: #3d5a80;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
}
.img-nav button:hover {
  background: #eef2f7;
}
#imgCount {
  font-size: 13px;
  color: #666;
}

/* 全景標題 */
.psv-navbar .psv-caption {
  font-size: 15px;
}

/* ================= 擬真測量工具樣式 ================= */
.measuring-cursor {
  cursor: crosshair !important;
}

/* 測量切換按鈕 */
.pano-measure-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #c9d0d8;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #2c3e50;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}
.pano-measure-btn:hover {
  background: #f0f4f8;
  transform: translateY(-1px);
}
.pano-measure-btn.active {
  background: #d93025;
  color: #ffffff;
  border-color: #b3261e;
  box-shadow: 0 2px 10px rgba(217, 48, 37, 0.35);
}
.measure-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* 頂部操作提示列 */
.pano-measure-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: rgba(20, 24, 33, 0.82);
  color: #ffffff;
  padding: 6px 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3px;
  border-radius: 20px;
  pointer-events: none;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}

/* 測量點標記 */
.measure-marker {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #ffd400;
  border: 2px solid #ffffff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 90;
  box-shadow: 0 0 10px rgba(255, 212, 0, 0.8), 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* 測量連線層 */
.measure-line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 89;
}

/* 方案 A: 簡潔測量結果卡片 */
.measure-tooltip {
  position: absolute;
  transform: translate(-50%, -120%);
  background: rgba(26, 32, 44, 0.92);
  backdrop-filter: blur(6px);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 95;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.18);
  white-space: nowrap;
}
.measure-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: rgba(26, 32, 44, 0.92) transparent transparent transparent;
}
.measure-tooltip .title {
  color: #ffd400;
  font-weight: 600;
  font-size: 11px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  padding-bottom: 3px;
  margin-bottom: 4px;
  text-align: center;
}
.measure-tooltip .main-val {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 6px;
}
.measure-tooltip .main-val b {
  color: #4cd964;
  font-size: 15px;
  font-weight: 700;
}

/* ================= 測量放大鏡樣式 ================= */
.pano-magnifier {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  pointer-events: none; /* 確保點擊事件穿透至下方全景圖 */
  z-index: 120;
  background: #111;
  transition: opacity 0.15s ease;
}

.pano-magnifier canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}

/* 放大鏡紅色十字準星 */
.magnifier-crosshair {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.magnifier-crosshair::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1.5px;
  background: rgba(255, 77, 79, 0.9);
  transform: translateY(-50%);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}
.magnifier-crosshair::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1.5px;
  background: rgba(255, 77, 79, 0.9);
  transform: translateX(-50%);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

@media (max-width: 900px) {
  .app {
    flex-direction: column;
    --left: 55%;
  }
  #divider {
    display: none;
  }
  #mapPane {
    height: auto;
  }
  #rightPane {
    height: auto;
  }
}