* { box-sizing: border-box; margin: 0; padding: 0; }

/* Lucide icons：統一外觀 */
[data-lucide],
svg.lucide {
  width: 1em;
  height: 1em;
  vertical-align: -2px;
  stroke-width: 2;
}
.icon-title {
  width: 1.1em;
  height: 1.1em;
  color: #58a6ff;
  vertical-align: -3px;
}
.icon-inline {
  width: 1em;
  height: 1em;
  vertical-align: -2px;
  margin-right: 2px;
}
.icon-xs {
  width: 0.85em;
  height: 0.85em;
  vertical-align: -1px;
}

/* EU/US 模型 badge */
.model-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.5px;
  margin-right: 4px;
  vertical-align: 1px;
}
.model-badge.eu { background: #1f3a8a; color: #93c5fd; border: 1px solid #3b82f6; }
.model-badge.us { background: #7f1d1d; color: #fca5a5; border: 1px solid #ef4444; }

body {
  font-family: -apple-system, "Segoe UI", "Microsoft JhengHei", sans-serif;
  background: #0f1419;
  color: #e6edf3;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  flex-wrap: wrap;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 { font-size: 20px; }

.menu-btn {
  display: none;
  background: transparent;
  border: 1px solid #30363d;
  color: #e6edf3;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  line-height: 0;
  min-width: 40px;
  min-height: 36px;
  align-items: center;
  justify-content: center;
}
.menu-btn svg { width: 20px; height: 20px; }
.menu-btn:hover { background: #21262d; }

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 99;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.overlay.active { display: block; }

.search-wrap {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 320px;
  max-width: 600px;
  align-items: center;
  background: #1c2230;
  border: 2px solid #4a5568;
  border-radius: 8px;
  padding: 4px 4px 4px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-wrap:focus-within {
  border-color: #58a6ff;
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}
.search-wrap::before {
  content: '🔍';
  font-size: 16px;
  flex-shrink: 0;
}

#searchInput {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border: none;
  color: #e6edf3;
  font-size: 15px;
  outline: none;
}
#searchInput::placeholder { color: #8b949e; }

#addBtn {
  padding: 8px 16px;
  background: #238636;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

#addBtn:hover:not(:disabled) { background: #2ea043; }
#addBtn:disabled { opacity: 0.6; cursor: wait; }

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 65px);
}

.sidebar {
  background: #161b22;
  border-right: 1px solid #30363d;
  padding: 16px;
}

.list-section { margin-bottom: 18px; }
.sidebar h2 { font-size: 12px; color: #8b949e; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }

.sidebar ul { list-style: none; }

.sidebar ul li {
  padding: 8px 10px;
  margin-bottom: 4px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}

.sidebar ul li:hover { background: #21262d; }
.sidebar ul li.active { background: #1f6feb33; border-left: 3px solid #1f6feb; padding-left: 7px; }

.sidebar ul li .m-name { flex: 1; }

.sidebar ul li .heart,
.sidebar ul li .cmp {
  background: transparent;
  border: none;
  color: #6e7681;
  cursor: pointer;
  padding: 4px;
  line-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 24px;
}
.sidebar ul li .heart svg { width: 16px; height: 16px; }
.sidebar ul li .heart:hover { color: #ff7b72; }
.sidebar ul li .heart.on { color: #ff5e5b; }
.sidebar ul li .heart.on svg { fill: #ff5e5b; }

.sidebar ul li .cmp svg { width: 16px; height: 16px; }
.sidebar ul li .cmp:hover { color: #58a6ff; }
.sidebar ul li .cmp.on { color: #58a6ff; }

.sidebar ul li .del {
  opacity: 0;
  background: transparent;
  border: none;
  color: #f85149;
  cursor: pointer;
  padding: 4px;
  line-height: 0;
  display: flex;
  align-items: center;
}
.sidebar ul li .del svg { width: 14px; height: 14px; }
.sidebar ul li:hover .del { opacity: 1; }

.hint { margin-top: 16px; font-size: 12px; color: #8b949e; line-height: 1.5; }
.hint-empty { margin: 4px 0 0 4px; font-size: 12px; font-style: italic; }

.content { padding: 20px; overflow-y: auto; }

/* 分頁 */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #30363d;
  margin-bottom: 20px;
}
.tab-btn {
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: #8b949e;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: #e6edf3; }
.tab-btn.active { color: #58a6ff; border-bottom-color: #58a6ff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* 多山頭分頁 */
.multi-header { margin-bottom: 14px; }
.multi-header h2 { font-size: 22px; }

.multi-pickbar {
  padding: 12px 14px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  margin-bottom: 18px;
}

.multi-section-title {
  font-size: 14px;
  color: #8b949e;
  margin: 18px 0 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.multi-windy-rows { display: flex; flex-direction: column; gap: 16px; }

.multi-row {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
}
.multi-row-head {
  padding: 12px 16px;
  background: #0d1117;
  border-bottom: 1px solid #30363d;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.multi-row-head h3 { font-size: 16px; }
.multi-row-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.multi-row-cards .card {
  background: transparent;
  border: none;
  border-radius: 0;
}
.multi-row-cards .card:first-child { border-right: 1px solid #30363d; }
.multi-row-cards .card-head h4 { font-size: 14px; }
.multi-iframe { height: 380px; }

@media (max-width: 900px) {
  .multi-row-cards { grid-template-columns: 1fr; }
  .multi-row-cards .card:first-child { border-right: none; border-bottom: 1px solid #30363d; }
  .multi-iframe { height: 280px; }
}
@media (max-width: 600px) {
  .multi-iframe { height: 240px; }
  .tab-btn { padding: 10px 12px; font-size: 13px; }
}

.mountain-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.mountain-header h2 { font-size: 24px; }

.coords { color: #8b949e; font-size: 13px; font-family: monospace; }

.range-switch { margin-left: auto; display: flex; gap: 4px; }

.range-btn {
  padding: 6px 14px;
  background: #21262d;
  border: 1px solid #30363d;
  color: #8b949e;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.range-btn.active { background: #1f6feb; color: white; border-color: #1f6feb; }

/* 比對 checkbox（pill 形式） */
.compare-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.compare-cb {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 16px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.compare-cb:hover { background: #21262d; }
.compare-cb.on { background: #1f6feb33; border-color: #1f6feb; color: #58a6ff; }
.compare-cb.disabled { opacity: 0.4; cursor: not-allowed; }
.compare-cb input { margin: 0; }

.compare-results {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 12px 16px;
  overflow-x: auto;
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.compare-table th,
.compare-table td {
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid #21262d;
}
.compare-table th {
  background: #0d1117;
  color: #8b949e;
  font-weight: 600;
  font-size: 13px;
}
.compare-table .m-cell {
  text-align: left;
  min-width: 110px;
}
.compare-table .row-note { display: block; color: #f85149; font-size: 11px; }
.compare-table .na { color: #6e7681; }

@media (max-width: 600px) {
  .compare-results { padding: 10px 8px; }
  .compare-table th,
  .compare-table td { padding: 8px 6px; font-size: 13px; }
}

.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.cwa-card { grid-column: span 2; }

.card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  overflow: hidden;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #30363d;
  background: #0d1117;
}

.card-head h3 { font-size: 15px; }
.card-head a { color: #58a6ff; font-size: 12px; text-decoration: none; }
.card-head a:hover { text-decoration: underline; }

.windy-frame { width: 100%; height: 380px; border: 0; display: block; }

.cwa-info { padding: 16px; }
.cwa-info .note { color: #d29922; font-size: 13px; margin: 8px 0 16px; }

.cwa-placeholder {
  padding: 12px;
  background: #0d1117;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cwa-msg { padding: 16px; text-align: center; color: #8b949e; }
.cwa-msg-sm { padding: 4px; text-align: center; color: #6e7681; font-size: 12px; margin-top: 4px; }

/* 鄉鎮對應設定表單 */
.cwa-setup { padding: 8px 4px; }
.cwa-setup-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 8px;
  align-items: center;
  justify-content: center;
}
.cwa-setup-form select,
.cwa-setup-form input {
  padding: 10px 12px;
  background: #0d1117;
  border: 1.5px solid #30363d;
  border-radius: 6px;
  color: #e6edf3;
  font-size: 14px;
  outline: none;
}
.cwa-setup-form select { min-width: 120px; }
.cwa-setup-form input { flex: 1; min-width: 180px; }
.cwa-setup-form select:focus,
.cwa-setup-form input:focus { border-color: #58a6ff; }

.cwa-setup-form button {
  padding: 10px 20px;
  background: #238636;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.cwa-setup-form button:hover { background: #2ea043; }

.cwa-setup-form .btn-secondary { background: #30363d; }
.cwa-setup-form .btn-secondary:hover { background: #484f58; }

.cwa-edit-btn {
  margin-left: 8px;
  background: transparent;
  border: 1px solid #30363d;
  color: #58a6ff;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cwa-edit-btn svg { width: 12px; height: 12px; }
.cwa-edit-btn:hover { background: #1f6feb22; border-color: #58a6ff; }

@media (max-width: 600px) {
  .cwa-setup-form { flex-direction: column; align-items: stretch; }
  .cwa-setup-form select,
  .cwa-setup-form input,
  .cwa-setup-form button { width: 100%; }
}

.day-group {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  overflow: hidden;
}

.day-group summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s;
}
.day-group summary::-webkit-details-marker { display: none; }
.day-group summary::before {
  content: '▶';
  font-size: 10px;
  color: #8b949e;
  margin-right: 8px;
  transition: transform 0.2s;
}
.day-group[open] summary::before { transform: rotate(90deg); }
.day-group summary:hover { background: #1c2230; }

.day-label { font-size: 15px; font-weight: 600; flex: 1; }
.day-pop { font-size: 18px; font-weight: 700; }

.time-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  padding: 8px 16px 16px;
  border-top: 1px solid #30363d;
}

.time-slot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #0d1117;
  border-radius: 4px;
  font-size: 13px;
}
.slot-time { color: #8b949e; font-family: monospace; }
.slot-pop { font-weight: 700; font-size: 15px; }

/* ========== 行動版 RWD ========== */
@media (max-width: 900px) {
  /* 顯示漢堡按鈕 */
  .menu-btn { display: inline-flex; order: -1; }

  /* 標題縮小 */
  .topbar { padding: 12px 14px; gap: 8px; }
  .topbar h1 { font-size: 16px; flex: 1; }

  /* 搜尋列換行佔滿 */
  .search-wrap { order: 3; flex: 1 1 100%; min-width: 0; }

  /* 側欄變抽屜 */
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
    overflow-y: auto;
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.4);
  }
  .sidebar.open { transform: translateX(0); }

  /* 主內容區 */
  .content { padding: 14px; }
  .cards { grid-template-columns: 1fr; gap: 12px; }
  .cwa-card { grid-column: auto; }

  /* Windy iframe 縮短 */
  .windy-frame { height: 280px; }

  /* 山頭標題 */
  .mountain-header h2 { font-size: 20px; }

  /* 行動版觸控加大 */
  .sidebar ul li { padding: 12px 10px; font-size: 16px; }
  .sidebar ul li .heart { font-size: 22px; padding: 6px 8px; }
  .sidebar ul li .del { opacity: 1; font-size: 16px; padding: 6px 8px; }
}

@media (max-width: 600px) {
  .topbar h1 { display: none; }
  .menu-btn { font-size: 24px; padding: 8px 14px; }

  .windy-frame { height: 240px; }
  .card-head { padding: 10px 14px; }
  .card-head h3 { font-size: 14px; }

  /* CWA 下拉行動版 */
  .day-group summary { padding: 14px; }
  .day-label { font-size: 14px; }
  .day-pop { font-size: 20px; }
  .time-slots { grid-template-columns: 1fr 1fr; padding: 8px 10px 12px; }
  .time-slot { padding: 10px 10px; }
  .slot-pop { font-size: 16px; }

  .mountain-header h2 { font-size: 18px; }
  .coords { font-size: 12px; }
}
