:root {
  --wine: #872f3d;
  --wine-dark: #6b2330;
  --paper: #f8eeeb;
  --surface: #fff8f5;
  --tint: #efd9d5;
  --rule: #d6aaa4;
  --ink: #43272b;
  --muted: #6c4b4d;
  --c-federation: #872f3d;
  --c-overseas: #2f5985;
  --c-domestic: #b06a12;
  --c-department: #2c6146;
  --panel-w: 380px;
  --top-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 15px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
a { color: var(--wine); }
button { font: inherit; color: inherit; }

.topbar {
  min-height: var(--top-h);
  background: var(--wine);
  color: #fff8f5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 18px;
  flex-wrap: wrap;
}
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: .04em; font-weight: 700; }
.stats { list-style: none; display: flex; gap: 6px 14px; margin: 0; padding: 0; flex-wrap: wrap; }
.stats li { font-size: 13px; opacity: .92; white-space: nowrap; }
.stats b { font-size: 17px; margin-right: 3px; font-variant-numeric: tabular-nums; }

.layout { flex: 1; display: flex; min-height: 0; position: relative; }
.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #ece4dc; }

.panel {
  width: var(--panel-w);
  background: var(--surface);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 2;
}
.sheet-handle { display: none; }

.tabs { display: flex; border-bottom: 1px solid var(--rule); flex: none; }
.tab {
  flex: 1; background: none; border: 0; padding: 11px 0; cursor: pointer;
  font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent;
}
.tab.is-active { color: var(--wine); border-bottom-color: var(--wine); }

.mode { flex: 1; overflow-y: auto; padding: 12px 14px 8px; min-height: 0; }
.mode[hidden] { display: none; }

.filters { display: grid; gap: 8px; margin-bottom: 10px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--rule); background: #fff; border-radius: 999px;
  padding: 3px 11px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.chip[aria-pressed="true"] { background: var(--tint); border-color: var(--wine); color: var(--wine-dark); font-weight: 600; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip[aria-pressed="false"] .dot { opacity: .35; }
.chip .n { color: var(--muted); font-weight: 400; font-size: 12px; }
.search {
  width: 100%; border: 1px solid var(--rule); border-radius: 8px; padding: 7px 10px;
  font: inherit; background: #fff; color: var(--ink);
}
.search:focus, .chip:focus-visible, .tab:focus-visible { outline: 2px solid var(--wine); outline-offset: 1px; }

.org-list, .annual-list { list-style: none; margin: 0; padding: 0; }
.org-list .group { font-size: 12px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; letter-spacing: .05em; }
.org-list button, .annual-list button {
  width: 100%; text-align: left; background: none; border: 0; padding: 6px 6px; border-radius: 6px;
  cursor: pointer; display: flex; gap: 8px; align-items: baseline;
}
.org-list button:hover, .annual-list button:hover { background: var(--paper); }
.org-list button.is-current, .annual-list button.is-current { background: var(--tint); }
.org-list .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.org-list .place, .annual-list .place { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 4px; }

.detail {
  background: #fff; border: 1px solid var(--rule); border-radius: 10px; padding: 12px 14px;
  margin-bottom: 12px; position: relative;
}
.detail .close {
  position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 20px; cursor: pointer;
  color: var(--muted); line-height: 1; padding: 4px;
}
.detail .photo { margin: -12px -14px 10px; }
.detail .photo img { width: 100%; height: 160px; object-fit: cover; border-radius: 10px 10px 0 0; display: block; }
.detail .photo figcaption { font-size: 11px; color: var(--muted); padding: 3px 14px 0; }
.detail h2 { font-size: 18px; margin: 0 26px 2px 0; color: var(--wine-dark); }
.detail .meta { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.detail .tag {
  display: inline-block; font-size: 11px; border-radius: 4px; padding: 0 6px; margin-left: 4px;
  background: var(--paper); border: 1px solid var(--rule); color: var(--muted);
}
.detail dl { margin: 0; display: grid; grid-template-columns: 5.2em 1fr; gap: 4px 8px; font-size: 14px; }
.detail dt { color: var(--muted); font-size: 13px; }
.detail dd { margin: 0; }
.detail .meetings { list-style: none; padding: 0; margin: 0; }
.detail .meetings li { margin-bottom: 3px; }
.detail .meetings .y { font-variant-numeric: tabular-nums; color: var(--muted); margin-right: 4px; }
.detail .more { border: 0; background: none; color: var(--wine); cursor: pointer; padding: 0; font-size: 13px; }
.detail .links { margin-top: 10px; font-size: 14px; }
.detail .sub-list { list-style: none; padding: 0; margin: 4px 0 0; columns: 2; column-gap: 12px; font-size: 13px; }
.detail .sub-list button { background: none; border: 0; padding: 1px 0; cursor: pointer; color: var(--wine); text-align: left; }
.detail .sub-list .college { break-after: avoid; color: var(--muted); font-weight: 600; margin-top: 6px; }

.annual-head { display: flex; align-items: center; justify-content: space-between; }
.year-label { font-size: 26px; font-weight: 700; color: var(--wine); font-variant-numeric: tabular-nums; }
.play {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--wine); background: #fff;
  color: var(--wine); cursor: pointer; font-size: 14px;
}
.play.is-playing { background: var(--wine); color: #fff; }
.slider { width: 100%; accent-color: var(--wine); margin: 8px 0 0; }
.slider-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.annual-list .y { font-variant-numeric: tabular-nums; font-weight: 600; width: 3em; flex: none; }

.panel-foot { font-size: 11.5px; color: var(--muted); padding: 8px 14px 10px; border-top: 1px solid var(--tint); flex: none; }

.legend {
  position: absolute; left: 10px; bottom: 26px; background: rgba(255, 248, 245, .94);
  border: 1px solid var(--rule); border-radius: 8px; padding: 6px 10px; font-size: 12px; display: grid; gap: 2px;
}
.legend[hidden] { display: none; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend i.ring { background: #fff !important; border: 3px solid var(--c-federation); width: 12px; height: 12px; }

.maplibregl-popup-content { font-family: inherit; padding: 6px 10px; border-radius: 8px; color: var(--ink); font-size: 13px; }

@media (max-width: 760px) {
  :root { --top-h: 0px; }
  .topbar { padding: 8px 12px; gap: 4px 10px; }
  .topbar h1 { font-size: 16px; }
  .stats li { font-size: 12px; }
  .stats b { font-size: 14px; }
  .layout { flex-direction: column; }
  .map-wrap { position: absolute; inset: 0; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 46%;
    border-right: 0; border-top: 1px solid var(--rule); border-radius: 14px 14px 0 0;
    box-shadow: 0 -4px 18px rgba(67, 39, 43, .18); transition: height .2s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel.is-collapsed { height: 104px; }
  .panel.is-expanded { height: 86%; }
  .sheet-handle {
    display: flex; justify-content: center; align-items: center; border: 0; background: none;
    height: 18px; cursor: pointer; flex: none; padding: 0;
  }
  .sheet-handle span { width: 42px; height: 5px; border-radius: 3px; background: var(--rule); }
  .tab { padding: 6px 0 8px; }
  .legend { top: 10px; bottom: auto; }
  .panel-foot { display: none; }
  .detail .photo img { height: 130px; }
}
