:root {
  --ink: #1c2430;
  --muted: #5d6b7c;
  --line: #e6ebf1;
  --bg: #f6f8fb;
  --panel: 348px;
  --blue: #2563eb;
  --blue-deep: #1d4ed8;
  --rose: #e25b78;
  --header: 60px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: "Noto Sans TC", "PingFang HK", "PingFang TC", "Microsoft JhengHei", "WenQuanYi Micro Hei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

button, input, select { font-family: inherit; }

header {
  height: var(--header);
  flex: 0 0 var(--header);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px 0 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
  border: 2px solid #fff;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.22);
  flex: 0 0 auto;
}

h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0.01em;
}

#subtitle {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.header-side {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

#header-stats {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

#header-stats strong {
  color: var(--ink);
  font-weight: 700;
}

#panel-toggle {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

#panel-toggle:hover { background: #f3f6fb; }

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

aside {
  width: var(--panel);
  flex: 0 0 var(--panel);
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

aside.collapsed { display: none; }

.controls {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

input[type="search"], select {
  width: 100%;
  border: 1px solid #d7dee8;
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  color: var(--ink);
}

input[type="search"]:focus, select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  border-color: var(--blue);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.regions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid #e3e8ef;
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 3px 8px 3px 6px;
  font-size: 12px;
  line-height: 1.3;
  cursor: pointer;
}

.chip i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.chip .n { color: #8b98a8; font-variant-numeric: tabular-nums; }

.chip.active {
  background: #eff5ff;
  border-color: #b9d0fb;
  color: #1e3a8a;
}

.chip:focus-visible, button:focus-visible, .item:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.list-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px 4px;
  font-size: 12px;
  color: var(--muted);
}

#reset {
  border: 0;
  background: transparent;
  color: var(--blue-deep);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 0;
}

#reset[hidden] { display: none; }

#list {
  list-style: none;
  margin: 0;
  padding: 0 8px 8px;
  overflow: auto;
  flex: 1;
}

.item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 12px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 8px;
  row-gap: 1px;
  align-items: center;
}

.item:hover, .item.active { background: #f3f7fd; }

.item .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  grid-row: 1 / span 2;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(15, 23, 42, 0.06);
}

.item .name {
  font-size: 14px;
  font-weight: 600;
}

.item .code {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-deep);
  letter-spacing: 0.03em;
}

.item .sub {
  grid-column: 2 / span 2;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  margin: 12px;
  color: var(--muted);
  font-size: 13px;
}

.about {
  border-top: 1px solid var(--line);
  padding: 8px 12px 10px;
  color: #6b7786;
  font-size: 11px;
  line-height: 1.45;
}

.about a { color: #1d4f91; }

#map {
  flex: 1;
  min-width: 0;
  background: #e7eef3;
}

.hub {
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.hub-dot, .hub-label { pointer-events: auto; }

.hub-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2563eb;
  border: 2.5px solid #fff;
  box-shadow:
    0 0 0 6px rgba(37, 99, 235, 0.28),
    0 0 0 12px rgba(37, 99, 235, 0.12);
}

.hub-label {
  position: absolute;
  left: 24px;
  top: -7px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  padding: 6px 6px 6px 10px;
  border-radius: 5px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.22);
  white-space: nowrap;
}

.hub-label button {
  pointer-events: auto;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.view-control {
  display: flex;
  overflow: hidden;
  border-radius: 6px;
}

.view-control button {
  border: 0;
  background: #fff;
  color: var(--ink);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

.view-control button + button { border-left: 1px solid #e6ebf1; }
.view-control button:hover { background: #f3f6fb; }

.route-popup .maplibregl-popup-content {
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  padding: 0;
  line-height: 1.4;
}

.route-popup .maplibregl-popup-close-button {
  color: #64748b;
  font-size: 18px;
  width: 24px;
  height: 24px;
  padding: 4px 4px 0 0;
}

.popup { padding: 12px 14px 12px; min-width: 230px; max-width: 300px; }
.popup-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.popup-kicker i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.popup h3 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.3;
}
.popup .iata {
  display: inline-block;
  margin-left: 4px;
  color: var(--blue-deep);
  font-size: 13px;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}
.popup .en { margin: 0; font-size: 13px; color: #334155; }
.popup .apt { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tag {
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  padding: 1px 7px;
}
.tag-suspend { background: #fee2e2; color: #991b1b; }
.tag-new { background: #dcfce7; color: #166534; }
.tag-resume { background: #e0f2fe; color: #075985; }
.tag-season { background: #fef3c7; color: #92400e; }
.popup h4 {
  margin: 10px 0 4px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.airlines {
  margin: 0;
  padding: 0 0 0 16px;
  max-height: 168px;
  overflow: auto;
  font-size: 13px;
}
.airlines li { margin: 0 0 3px; }
.airline-note {
  display: inline-block;
  margin-left: 6px;
  color: #9a3412;
  font-size: 12px;
}

.maplibregl-map { font-family: inherit; }
.maplibregl-ctrl-attrib {
  font-size: 10px;
  line-height: 1.35;
  max-width: min(640px, 72vw);
  background: rgba(255, 255, 255, 0.9);
}
.maplibregl-ctrl-attrib a { color: #1d4f91; }

@media (max-width: 800px) {
  header { height: auto; min-height: var(--header); padding: 8px 12px; align-items: flex-start; }
  .header-side { flex-direction: column; align-items: flex-end; gap: 4px; }
  .layout { flex-direction: column; }
  aside {
    width: 100%;
    flex: 0 0 46vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  #map { min-height: 54vh; }
}
