:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --chip: #f1f5f9;
  --accent: #0f172a;
  --l5: #b91c1c;
  --l4: #ea580c;
  --l3: #d97706;
  --l2: #65a30d;
  --l1: #15803d;
  --ok: #15803d;
  --shadow: 0 10px 30px rgba(15, 23, 42, .12);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --panel: #111827; --ink: #f1f5f9; --ink-2: #cbd5e1; --muted: #94a3b8;
    --line: #1f2937; --chip: #1f2937; --accent: #f1f5f9; --shadow: 0 10px 30px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --panel: #111827; --ink: #f1f5f9; --ink-2: #cbd5e1; --muted: #94a3b8;
  --line: #1f2937; --chip: #1f2937; --accent: #f1f5f9; --shadow: 0 10px 30px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "Noto Sans TC", system-ui, -apple-system, "Microsoft JhengHei", sans-serif;
  font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }

#app { display: grid; grid-template-columns: 380px 1fr; height: 100dvh; overflow: hidden; }
#side {
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; overflow-y: auto;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 20px 20px 12px; }
.logo svg { width: 40px; height: 40px; }
.logo rect { fill: var(--ink); }
.logo path, .logo circle { fill: none; stroke: var(--panel); stroke-width: 2.4; stroke-linecap: round; }
.logo circle { stroke: var(--l4); }
.brand h1 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: .02em; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; }

.search { padding: 4px 20px 10px; }
.search input {
  width: 100%; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  border-radius: 10px; padding: 10px 12px; font: inherit; outline: none;
}
.search input:focus { border-color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 12px; }
.chip {
  border: 1px solid var(--line); background: var(--chip); border-radius: 999px;
  padding: 3px 10px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.chip .n { opacity: .6; margin-left: 4px; font-variant-numeric: tabular-nums; }

.feature {
  margin: 0 20px 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  border: 0; border-radius: 12px; padding: 12px 14px; cursor: pointer; text-align: left;
  background: linear-gradient(135deg, #1e293b, #0f172a); color: #f8fafc;
}
.feature-k { font-size: 12px; background: var(--l4); color: #fff; padding: 1px 8px; border-radius: 6px; font-weight: 700; }
.feature-t { font-weight: 700; }
.feature-a { opacity: .7; }

.list-head { display: flex; justify-content: space-between; padding: 6px 20px; font-weight: 700; font-size: 14px; }
#list { list-style: none; margin: 0; padding: 0 12px 12px; }
#list li {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center;
  padding: 10px 8px; border-radius: 10px; cursor: pointer;
}
#list li:hover, #list li[aria-current="true"] { background: var(--chip); }
.rank { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; text-align: right; }
.li-name { font-weight: 500; line-height: 1.35; }
.li-sub { font-size: 12px; color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px;
  border-radius: 8px; color: #fff; font-weight: 900; font-size: 14px; padding: 0 6px;
}
.b5 { background: var(--l5); } .b4 { background: var(--l4); } .b3 { background: var(--l3); }
.b2 { background: var(--l2); } .b1 { background: var(--l1); }

.credits { margin-top: auto; padding: 16px 20px 22px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }
.credits p { margin: 0 0 6px; }

#mapwrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.legend {
  position: absolute; left: 14px; bottom: 28px; background: var(--panel); border-radius: 12px;
  padding: 10px 12px; box-shadow: var(--shadow); font-size: 12px;
}
.legend-t { font-weight: 700; margin-bottom: 4px; }
.legend-row { display: flex; gap: 10px; }
.legend-row span { display: inline-flex; align-items: center; gap: 4px; }
.legend-row i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

#detail {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); background: var(--panel);
  box-shadow: var(--shadow); transform: translateX(105%); transition: transform .28s ease; overflow-y: auto; z-index: 5;
}
#detail[aria-hidden="false"] { transform: none; }
.close {
  position: sticky; top: 10px; float: right; margin: 10px 12px 0 0; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel); font-size: 20px; cursor: pointer; z-index: 2;
}
.d-head { padding: 22px 22px 8px; }
.d-head h2 { margin: 0 0 4px; font-size: 22px; line-height: 1.3; font-weight: 900; }
.d-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.d-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 22px 6px; }
.kpi { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.kpi b { display: block; font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi span { font-size: 12px; color: var(--muted); }

.d-sec { padding: 14px 22px; border-top: 1px solid var(--line); }
.d-sec h3 { margin: 0 0 10px; font-size: 15px; font-weight: 700; }

.views { display: grid; grid-auto-flow: column; grid-auto-columns: 88%; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.views:has(.view:only-child) { grid-auto-columns: 100%; }
.view { scroll-snap-align: start; margin: 0; }
.view .frame { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; background: var(--chip); }
.view img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .2s; }
.view img.ann { opacity: 0; }
.view.on img.ann { opacity: 1; }
.view figcaption { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.view figcaption a { color: inherit; }
.toggle { margin-left: 10px; font-size: 12px; font-weight: 500; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 2px 10px; cursor: pointer; }
.toggle[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.ann-legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.ann-legend i { width: 10px; height: 10px; display: inline-block; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.finding { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.finding h4 { margin: 0 0 4px; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.sev { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; color: #fff; }
.sev3 { background: var(--l5); } .sev2 { background: var(--l4); } .sev1 { background: var(--l3); }
.finding p { margin: 0 0 6px; color: var(--ink-2); font-size: 14px; }
.finding ul { margin: 0; padding-left: 18px; font-size: 13.5px; }
.finding li { margin: 2px 0; }
.finding .fixes-t { font-size: 12px; color: var(--ok); font-weight: 700; margin-top: 4px; }

.bars { display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 92px 1fr 44px; gap: 8px; align-items: center; font-size: 13px; }
.bar .track { height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; position: relative; }
.bar .fill { height: 100%; background: var(--ink-2); border-radius: 99px; }
.bar .avg { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--l4); }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

.hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px; align-items: end; height: 64px; }
.hours i { background: var(--ink-2); border-radius: 2px 2px 0 0; min-height: 1px; }
.hours-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); }

.sightsvg { width: 100%; max-width: 320px; display: block; margin: 0 auto; }
.factor { display: grid; grid-template-columns: 1fr 90px; gap: 10px; font-size: 13.5px; padding: 4px 0; }
.factor .track { height: 8px; background: var(--chip); border-radius: 99px; overflow: hidden; align-self: center; }
.factor .fill { height: 100%; background: var(--l4); }

.maplibregl-popup-content { font-family: inherit; border-radius: 10px; padding: 8px 12px; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 46dvh 1fr; }
  #mapwrap { grid-row: 1; }
  #side { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); }
  .brand { padding: 14px 16px 8px; }
  .search, .chips, .list-head { padding-left: 16px; padding-right: 16px; }
  .feature { margin-left: 16px; margin-right: 16px; }
  .legend { bottom: 10px; left: 10px; }
  #detail { width: 100vw; }
  .d-head, .d-sec, .d-kpis { padding-left: 16px; padding-right: 16px; }
}
