:root { --pad: 12px; --radius: 14px; }
html, body { height: 100%; margin: 0; }
#map { position: absolute; inset: 0; }
/* Desktop toolbar (shown only when 3D is enabled on desktop) */
.toolbar {
  position: absolute; left: var(--pad); right: var(--pad); top: var(--pad);
  display: none; /* default hidden; show programmatically when 3D is on (desktop) */
  align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; background: rgba(255,255,255,.95);
  border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.15);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Noto Sans TC, sans-serif;
  z-index: 999;
}
.toolbar label { font-size: 14px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.toolbar input[type="range"] { width: 260px; }
.toolbar .spacer { flex: 1; }
/* Mobile: FAB + bottom sheet */
.fab { position: absolute; right: 16px; bottom: 16px; z-index: 1100; display: none; }
.fab button {
  width: 56px; height: 56px; border: none; border-radius: 50%;
  background: #111; color: #fff; font-size: 24px; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200;
  transform: translateY(100%);
  background: #fff; border-top-left-radius: 18px; border-top-right-radius: 18px;
  box-shadow: 0 -12px 30px rgba(0,0,0,.25); padding: 14px 12px 16px; transition: transform .25s ease;
}
.sheet.open { transform: translateY(0); }
.sheet .grip { width: 56px; height: 5px; border-radius: 999px; background: #ddd; margin: 4px auto 12px; }
.sheet .row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.sheet .row label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.sheet .row input[type="range"] { flex: 1; }
.sheet .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.sheet .actions button { padding: 8px 12px; border-radius: 10px; border: 1px solid #ddd; background: #f7f7f7; }
/* Mobile rules */
@media (max-width: 640px) {
  .toolbar { display: none !important; } /* force-hide desktop toolbar on mobile */
  .fab { display: block; }
}

/* 日照分析 Modal 專用樣式 */
.sun-modal-card {
  max-width: 640px;
  width: min(96vw, 640px);
  /* 讓整體視窗不要太高，維持在視窗高度內 */
  max-height: 60vh;
  /* 調整內邊距，讓上、下邊界視覺上對稱，不再有一大片上方空白 */
  padding: 16px 18px 16px;
  box-sizing: border-box;
}

/* 移除預設 h2 的上邊距，只保留與下方內容的間距 */
.sun-modal-card h2 {
  margin: 0 0 8px;
  padding: 0;
}

/* 只針對日照分析視窗，讓右上角關閉按鈕「懸浮在外面」 */
#sunModal .modal-card {
  position: relative;
  overflow: visible; /* 允許關閉按鈕跑出卡片外框 */
}

#sunModal .modal-close {
  position: absolute;
  /* 再往外、往上拉一點，懸浮感更明顯 */
  top: -18px;
  right: -18px;
  border-radius: 999px;
  padding: 4px 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  /* 關閉按鈕底色改為黑色，字改為白色 */
  background: #000;
  color: #fff;
  border: 2px solid #fff; /* 與卡片拉開一點層次感 */
}

/* 手機版：縮小日照分析視窗寬度，接近底部抽屜內容區的視覺寬度 */
@media (max-width: 640px) {
  .sun-modal-card {
    max-width: 360px;
    width: min(96vw, 360px);
    max-height: 55vh; /* 手機再矮一點，避免佔滿整個畫面 */
    /* 手機也沿用相同的上下邊界設定，維持一致感 */
    padding: 16px 18px 16px;
  }
}

.sun-building-title {
  font-size: 14px;
  color: #555;
  margin-bottom: 8px;
}

.sun-tabs {
  display: flex;
  gap: 8px;
  margin: 8px 0 4px;
  /* 覆寫共用 .tabs 的膠囊背景，避免吃掉左右圓角 */
  background: transparent;
  border-radius: 0;
  padding: 0;
  overflow: visible;
}

.sun-tabs .tab {
  flex: 1 1 0;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 999px; /* 確保每顆按鈕自己是完整圓角 */
}

.sun-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  margin-bottom: 8px;
}

.sun-chip {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #ddd;
  background: #f7f7f7;
  display: inline-flex;
  align-items: center;
}

.sun-chip.high {
  background: #fff6d5;
  border-color: #f2c94c;
}

.sun-chip.medium {
  background: #e8f4ff;
  border-color: #7fb4ff;
}

.sun-chip.low {
  background: #f3f3f3;
  border-color: #ccc;
}

.sun-detail-pane {
  margin-top: 4px;
  /* 降低內容區高度，整體視窗看起來更矮 */
  max-height: 180px;
  overflow: auto;
}

.sun-detail-pane table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.sun-detail-pane th,
.sun-detail-pane td {
  padding: 4px 6px;
  border-bottom: 1px solid #eee;
  text-align: center;
  white-space: nowrap;
}

.sun-detail-pane th:first-child,
.sun-detail-pane td:first-child {
  text-align: left;
}

.sun-detail-hours {
  font-variant-numeric: tabular-nums;
}

.sun-detail-hours.sun-level-high {
  font-weight: 600;
}

.sun-detail-hours.sun-level-low {
  color: #888;
}

.sun-summary {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #eee;
  font-size: 13px;
}

.sun-summary-line {
  margin-bottom: 4px;
}

.sun-summary .btn {
  font-size: 12px;
  padding: 4px 8px;
}
