:root {
  --bg: #f1ece3; --panel: #ffffff; --panel2: #faf7f1;
  --line: #e2dace; --line2: #cfc3b2;
  --tx: #13293d; --tx2: #4a5a6b; --tx3: #5b6875;
  --navy: #13293d; --ivory: #f4efe6; --gold: #c9a24b; --gold-dk: #855a0b;
  --accent: #1b4f7a; --red: #b31212;
  --sun: #e9b949; --block: #3d4f63; --back: #b4bfca; --night: #f3f4f6;
  --top-h: 52px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx);
  font-family: -apple-system, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
body { overflow: hidden; }
button, input { font: inherit; }

.top { position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 20;
  background: var(--navy); color: var(--ivory); border-bottom: 3px solid var(--gold);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px; gap: 8px; }
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand .mark { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--ivory); display: grid; place-items: center; box-shadow: 0 0 0 2px var(--gold); }
.brand .mark img { display: block; }
.brand .sub { font-weight: 400; font-size: 12px; opacity: .85; }
@media (max-width: 420px) { .brand .sub { display: none; } }
.line-sm { display: inline-block; margin-top: 6px; color: #067a3a; font-weight: 700; font-size: 14.5px; text-decoration: none; border-bottom: 1px solid rgba(6,122,58,.35); }
.top-act { display: flex; align-items: center; gap: 8px; flex: none; }
.ghost { background: transparent; color: var(--ivory); border: 1px solid rgba(244,239,230,.5); border-radius: 999px; padding: 4px 12px; font-size: 14px; cursor: pointer; }

.search { position: fixed; top: calc(var(--top-h) + 10px); left: 16px; right: 16px; z-index: 15;
  display: flex; gap: 8px; max-width: 560px; margin: 0 auto; }
.search input { flex: 1; min-width: 0; height: 46px; border: 1px solid var(--line2); border-radius: 12px;
  padding: 0 14px; font-size: 16px; background: var(--panel); color: var(--tx); box-shadow: 0 4px 14px rgba(19,41,61,.12); }
.search button { height: 46px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--navy); color: var(--ivory);
  font-weight: 700; font-size: 16px; cursor: pointer; box-shadow: 0 4px 14px rgba(19,41,61,.18); }
.search button:disabled { background: #e8e2d6; color: #645d50; }
.search .loc { flex: none; width: 46px; padding: 0; background: var(--panel); color: var(--tx); border: 1px solid var(--line2); font-size: 20px; }
.search .loc.busy { animation: sp 1.2s linear infinite; }

.toast { position: fixed; top: calc(var(--top-h) + 64px); left: 16px; right: 16px; max-width: 560px; margin: 0 auto;
  z-index: 16; background: var(--navy); color: var(--ivory); border-radius: 10px; padding: 10px 14px; font-size: 15px;
  opacity: 0; transform: translateY(-6px); transition: .2s; pointer-events: none; }
.toast.on { opacity: 1; transform: none; }

#map { position: fixed; top: var(--top-h); left: 0; right: 0; bottom: 0; }
#map .cesium-viewer-bottom, #map .cesium-widget-credits { display: none !important; }
.nogl { padding: 120px 24px; text-align: center; font-size: 17px; }

.loading { position: fixed; top: 34%; left: 50%; transform: translateX(-50%); z-index: 14; background: var(--panel);
  border-radius: 14px; padding: 16px 22px; box-shadow: 0 6px 24px rgba(19,41,61,.15); font-size: 16px; color: var(--tx);
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; pointer-events: none; }
.loading small { color: var(--tx3); font-size: 13px; }
.cover { position: fixed; inset: var(--top-h) 0 0 0; z-index: 25; background: rgba(241,236,227,.94);
  display: flex; align-items: center; justify-content: center; }
.cover[hidden] { display: none; }
.cover-card { background: var(--panel); border-radius: 14px; padding: 22px 24px; font-size: 17px; text-align: center;
  box-shadow: 0 8px 30px rgba(19,41,61,.15); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cover-card b { font-size: 26px; color: var(--gold-dk); }
.spin { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--gold); animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 18; background: var(--panel);
  border-radius: 18px 18px 0 0; box-shadow: 0 -6px 24px rgba(19,41,61,.16);
  padding: 6px 16px calc(28px + env(safe-area-inset-bottom)); max-height: 52vh; overflow-y: auto;
  max-width: 720px; margin: 0 auto; }
.sheet.min .result { display: none; }
.grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line2); margin: 4px auto 8px; cursor: pointer; padding: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips > * { flex: none; }
.chip { border: 1px solid var(--line2); background: var(--panel2); color: var(--tx); border-radius: 999px;
  padding: 6px 13px; font-size: 15px; cursor: pointer; }
.chip.on { background: var(--navy); border-color: var(--navy); color: var(--ivory); font-weight: 700; }
#date { border: 1px solid var(--line2); border-radius: 10px; padding: 5px 8px; font-size: 15px; background: var(--panel2); color: var(--tx); min-width: 0; }
.timeRow { margin-top: 10px; align-items: center; }
.play { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--gold); color: var(--navy);
  font-size: 18px; font-weight: 700; cursor: pointer; }
.timeBox { flex: 1; min-width: 0; }
.timeLabel { font-size: 21px; font-weight: 700; }
#time { width: 100%; accent-color: var(--gold-dk); height: 28px; margin: 2px 0; }
.sunInfo { font-size: 13px; color: var(--tx2); }

.result { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.hint { margin: 4px 0; font-size: 15px; color: var(--tx2); line-height: 1.6; }
.rhead { font-size: 16px; margin-bottom: 8px; }
.rhead b { color: var(--gold-dk); }
.drow { display: grid; grid-template-columns: 58px 1fr; gap: 2px 8px; margin: 10px 0; }
.dname { font-weight: 700; font-size: 15px; line-height: 1.2; }
.dname small { display: block; font-weight: 400; color: var(--tx3); font-size: 12px; }
.dbar { min-width: 0; }
.cells { display: grid; grid-template-columns: repeat(58, 1fr); height: 22px; border-radius: 5px; overflow: hidden; cursor: pointer; }
.c { display: block; height: 100%; }
.c.sun { background: var(--sun); } .c.block { background: var(--block); }
.c.back { background: var(--back); } .c.night { background: var(--night); box-shadow: inset 0 1px 0 #dde1e6, inset 0 -1px 0 #dde1e6; }
/* 刻度：05:00 起、每格 15 分，6/9/12/15/18 點分別在第 4/16/28/40/52 格 */
.ticks { position: relative; height: 15px; font-size: 11px; color: var(--tx3); }
.ticks span { position: absolute; transform: translateX(-50%); }
.ticks span:nth-child(1) { left: calc(4 / 58 * 100%); } .ticks span:nth-child(2) { left: calc(16 / 58 * 100%); }
.ticks span:nth-child(3) { left: calc(28 / 58 * 100%); } .ticks span:nth-child(4) { left: calc(40 / 58 * 100%); }
.ticks span:nth-child(5) { left: calc(52 / 58 * 100%); }
.dsay { grid-column: 2; font-size: 14px; line-height: 1.5; color: var(--tx); }
.dsay .w { color: var(--red); } .dsay .b { color: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--tx2); margin: 6px 0; }
.legend .c { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; border: 1px solid var(--line); }
.note { font-size: 12.5px; color: var(--tx3); line-height: 1.6; margin: 6px 0; }
.ract { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.ghost2 { border: 1px solid var(--line2); background: var(--panel2); color: var(--tx); border-radius: 10px; padding: 8px 14px; font-size: 15px; cursor: pointer; }
.btn-line { display: inline-block; background: #06c755; color: #fff; text-decoration: none; font-weight: 700;
  border-radius: 10px; padding: 11px 18px; font-size: 16px; }
.btn-line.sm { padding: 8px 14px; font-size: 15px; }

.attrib { font-size: 11.5px; color: var(--tx3); margin: 10px 0 0; line-height: 1.5; }
@media (max-width: 899px) {
  .sheet { max-height: 46vh; padding-top: 4px; }
  .chips { gap: 6px; }
  .chip { padding: 5px 10px; font-size: 14.5px; }
  #date { font-size: 13.5px; padding: 4px 6px; max-width: 128px; }
  .timeRow { margin-top: 6px; }
  .timeLabel { font-size: 19px; }
  .hint { font-size: 14px; }
}

.drawer { position: fixed; inset: 0; z-index: 40; background: rgba(19,41,61,.45); display: flex; justify-content: center; align-items: flex-end; }
.drawer[hidden] { display: none; }
.drawer-card { position: relative; background: var(--panel); width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 22px 18px calc(30px + env(safe-area-inset-bottom)); line-height: 1.7; font-size: 15.5px; }
.drawer-card h1 { font-size: 22px; margin: 0 36px 8px 0; }
.drawer-card h2 { font-size: 18px; margin: 18px 0 6px; border-left: 4px solid var(--gold); padding-left: 8px; }
.drawer-card h3 { font-size: 16px; margin: 12px 0 2px; }
.drawer-card p { margin: 4px 0; }
.close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--panel2); font-size: 18px; cursor: pointer; color: var(--tx); }
.cta { background: #fbf3df; border-left: 3px solid var(--gold); padding: 12px 14px; border-radius: 10px; margin: 16px 0; }
.cta p { margin: 0 0 10px; }
.tools { list-style: none; padding: 0; margin: 4px 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tools a { display: block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--accent); text-decoration: none; background: var(--panel2); }
.src { font-size: 12.5px; color: var(--tx3); margin-top: 14px !important; }

@media (min-width: 900px) {
  .sheet { left: 16px; right: auto; bottom: 16px; width: 440px; border-radius: 18px; max-height: calc(100vh - var(--top-h) - 110px); }
  .search { left: 16px; right: auto; width: 440px; margin: 0; }
  .toast { left: 16px; right: auto; width: 440px; margin: 0; }
}
