/* ===== 基礎 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel2: #273449;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent2: #f59e0b;
  --topbar-h: 60px;
}
html, body { height: 100%; }
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  overflow: hidden;
}

/* ===== 頂列 ===== */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  background: linear-gradient(90deg, #11203c, #1e293b);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 28px; }
.topbar h1 { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
.topbar p { font-size: 12px; color: var(--muted); }
.topnav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: .15s;
}
.nav-btn:hover { background: var(--accent); color: #04263a; border-color: var(--accent); }
.nav-btn.play { background: linear-gradient(90deg,#f59e0b,#ef4444); color:#fff; border:none; font-weight:700; }
.nav-btn.play:hover { filter: brightness(1.1); }

/* ===== 主布局 ===== */
.layout { display: flex; height: calc(100% - var(--topbar-h)); position: relative; }

/* ===== 側邊欄 ===== */
.sidebar {
  width: 340px; flex-shrink: 0; background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto; padding: 16px;
}
.side-section { margin-bottom: 18px; }
.side-label {
  display: block; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px;
}
.day-dropdown {
  width: 100%; padding: 10px; border-radius: 8px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  font-size: 14px; cursor: pointer;
}
.day-head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.day-theme { font-size: 26px; }
.day-title { font-size: 16px; font-weight: 700; }
.day-meta { font-size: 12px; color: var(--muted); }
.day-note {
  font-size: 13px; line-height: 1.6; color: #cbd5e1;
  background: var(--panel2); padding: 10px; border-radius: 8px;
  border-left: 3px solid var(--accent);
}

/* ===== 餐廳安排 ===== */
.day-meals { margin-top: 10px; }
.meals-title { font-size: 12px; color: var(--accent2); font-weight: 700; margin-bottom: 6px; }
.meal-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; margin-bottom: 5px; cursor: pointer; font-size: 13px; }
.meal-row:hover { border-color: var(--accent); }
.meal-row.plain { cursor: default; }
.meal-label { font-size: 11px; color: var(--muted); background: var(--bg); padding: 2px 7px; border-radius: 6px; flex: 0 0 auto; }
.meal-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.meal-name { font-weight: 600; }
.meal-special { width: 100%; font-size: 11px; color: var(--muted); padding-left: 2px; line-height: 1.4; }
.d-block.special h4 { color: var(--accent2); }
.d-block.special { background: rgba(245,158,11,.08); border-left: 3px solid var(--accent2); padding: 8px 10px; border-radius: 6px; }

/* ===== 景點列表 ===== */
.poi-list { list-style: none; display: flex; flex-direction: column; gap: 6px; min-height: 10px; }
.poi-list.flex { opacity: .95; }
.poi-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; cursor: grab; font-size: 14px;
  transition: .12s;
}
.poi-item:hover { border-color: var(--accent); transform: translateX(2px); }
.poi-item .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.poi-item .pname { flex: 1; }
.poi-item .pcat { font-size: 11px; color: var(--muted); }
.poi-item.ghost { opacity: .4; }
.poi-item .grip { color: var(--muted); cursor: grab; }
.hint { font-size: 11px; color: var(--muted); margin-top: 6px; }
.flex-head { list-style:none; font-size:12px; color:var(--accent2); font-weight:700; margin:8px 0 2px; padding-top:4px; border-top:1px dashed var(--line); }
.flex-head:first-child { border-top:none; padding-top:0; }
.flex-item { cursor: grab; }
.sched-badge { display:inline-block; background:#065f46; color:#6ee7b7; font-size:10px; padding:1px 5px; border-radius:6px; margin-left:4px; }
.d-en .sched { display:inline-block; background:#065f46; color:#6ee7b7; font-size:11px; padding:1px 7px; border-radius:8px; margin-left:6px; }

/* 景點分類顏色點（與 app.js 對應） */

/* ===== 地圖 ===== */
.map-wrap { flex: 1; position: relative; }
#map { width: 100%; height: 100%; background: #0b1220; }
.route-legend {
  position: absolute; bottom: 14px; left: 14px; z-index: 500;
  background: rgba(15,23,42,.9); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 12px; max-width: 280px;
  color: var(--text); backdrop-filter: blur(4px);
}
.route-legend b { color: var(--accent); }
.route-legend .seg { color: var(--muted); margin-top: 3px; }

/* Leaflet 數字標記 */
.num-marker {
  background: var(--accent); color: #04263a; font-weight: 700;
  border-radius: 50%; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); font-size: 13px;
}
.leaflet-popup-content { font-family: inherit; }
.popup-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.popup-cat { font-size: 11px; color: #2563eb; margin-bottom: 6px; }
.popup-more { color: #2563eb; cursor: pointer; font-size: 12px; text-decoration: underline; }

/* ===== 詳情面板 ===== */
.detail {
  position: absolute; top: 0; right: 0; height: 100%; width: 420px; max-width: 90vw;
  background: var(--panel); border-left: 1px solid var(--line);
  z-index: 1000; overflow-y: auto; padding: 20px;
  transition: transform .25s ease; box-shadow: -8px 0 30px rgba(0,0,0,.4);
}
.detail.closed { transform: translateX(105%); }
/* 詳情面板背景遮罩（手機點擊左側空白可關閉） */
.detail-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 999; transition: opacity .25s; }
.detail-backdrop.closed { opacity: 0; pointer-events: none; }
@media (min-width: 861px) { .detail-backdrop { display: none; } }  /* 桌機不需遮罩 */
.detail-close {
  position: absolute; top: 12px; right: 12px;
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  width: 36px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 16px; z-index: 2;
}
.detail-close:hover { background: #ef4444; border-color: #ef4444; }
.d-cat { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 20px; color: #fff; margin-bottom: 8px; }
.d-name { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
.d-en { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.d-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; margin-bottom: 16px; }
.d-facts dt { color: var(--accent2); white-space: nowrap; }
.d-facts dd { color: #cbd5e1; }
.d-block { margin-bottom: 14px; }
.d-block h4 { font-size: 14px; margin-bottom: 5px; color: var(--accent); display: flex; gap: 6px; align-items: center; }
.d-block p { font-size: 13px; line-height: 1.7; color: #cbd5e1; }

/* ===== 彈窗 ===== */
.modal {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal.closed { display: none; }
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  max-width: 720px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 26px; position: relative;
}
.modal-card h2 { font-size: 22px; margin-bottom: 14px; }
.modal-card h3 { font-size: 16px; margin: 18px 0 8px; color: var(--accent); }
.modal-card p { font-size: 14px; line-height: 1.7; color: #cbd5e1; margin-bottom: 8px; }
.modal-card table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.modal-card th, .modal-card td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.modal-card th { background: var(--panel2); color: var(--accent2); }
.flight-card {
  background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 14px; margin: 10px 0;
}
.flight-card .fno { font-weight: 800; color: var(--accent); font-size: 16px; }
.tip-row { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tip-row .ti { font-size: 24px; }
.tip-row .tt { font-weight: 700; margin-bottom: 2px; }
.tip-row .td { font-size: 13px; color: #cbd5e1; line-height: 1.6; }
.warn {
  background: #422006; border: 1px solid #a16207; border-radius: 8px;
  padding: 10px 12px; font-size: 13px; color: #fde68a; margin: 10px 0;
}

/* ===== 登入/分享 ===== */
.share-status {
  display: inline-flex; align-items: center; font-size: 12px; color: var(--muted);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px;
}
.share-now { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 10px 0; font-size: 14px; }
.share-link { margin-top: 8px; font-size: 13px; color: var(--muted); }
.share-link input { width: 100%; margin-top: 4px; padding: 7px; border-radius: 6px; background: var(--bg); color: var(--accent); border: 1px solid var(--line); font-size: 12px; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.share-row input { flex: 1; min-width: 160px; padding: 9px 11px; border-radius: 8px; background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-size: 14px; }
.sbtn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); padding: 9px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.sbtn:hover { border-color: var(--accent); }
.sbtn.primary { background: var(--accent); color: #04263a; border: none; font-weight: 700; }
.share-msg { margin-top: 12px; font-size: 13px; color: #cbd5e1; line-height: 1.6; min-height: 18px; }
#btn-cloud-save { background: #065f46; color: #6ee7b7; border-color: #065f46; }

/* ===== 播放模式 ===== */
.play-card {
  position: absolute; top: 18px; right: 18px; z-index: 600; width: 360px; max-width: 80vw;
  background: rgba(15,23,42,.92); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; backdrop-filter: blur(8px); box-shadow: 0 10px 40px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .4s ease; pointer-events: none; display: none;
}
body.playing .play-card { display: block; }
.pc-step { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.pc-cat { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.pc-name { font-size: 22px; font-weight: 800; margin-bottom: 2px; }
.pc-en { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.pc-intro { font-size: 13px; line-height: 1.7; color: #cbd5e1; }
.pc-fact { font-size: 12px; color: var(--accent2); margin-top: 8px; }

.play-bar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 700;
  background: rgba(2,6,23,.95); border-top: 1px solid var(--line); padding: 10px 14px;
}
.play-bar.closed { display: none; }
.pb-controls { display: flex; align-items: center; gap: 8px; }
.pb-controls button {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  width: 40px; height: 36px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.pb-controls button:hover { background: var(--accent); color: #04263a; }
#pp-toggle { background: var(--accent2); color: #1a1205; border: none; }
.pb-title { font-weight: 700; margin-left: 6px; flex: 0 0 auto; }
#pp-exit { width: auto; padding: 0 12px; margin-left: auto; }
.play-list { display: flex; gap: 6px; overflow-x: auto; margin-top: 10px; padding-bottom: 4px; }
.pl-item {
  flex: 0 0 auto; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; white-space: nowrap; color: var(--muted);
}
.pl-item.active { background: var(--accent); color: #04263a; font-weight: 700; border-color: var(--accent); }
.pl-item:hover { border-color: var(--accent); }
body.playing .sidebar, body.playing .detail { filter: brightness(.6); }
.flight-dot { font-size: 20px; filter: drop-shadow(0 0 6px rgba(251,191,36,.9)); transition: transform .2s; }
#pp-music { background: var(--panel2); }

/* ===== 捲軸 ===== */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== RWD ===== */
@media (max-width: 860px) {
  body { overflow: auto; }
  .layout { flex-direction: column; height: auto; }
  .sidebar { width: 100%; max-height: none; border-right: none; border-bottom: 1px solid var(--line); }
  .map-wrap { height: 60vh; }
  /* 手機：詳情面板固定於畫面（不隨頁面捲動跑掉），左側留空白可點擊關閉 */
  .detail { position: fixed; top: 0; right: 0; height: 100vh; height: 100dvh; width: 86vw; max-width: 86vw; z-index: 1000; }
  .topbar { flex-direction: column; height: auto; gap: 8px; padding: 10px; }
  .topbar h1 { font-size: 15px; }
}
