:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --brand: #2f6fed;
  --brand-soft: #e8effc;
  --text: #1c2333;
  --muted: #6b7384;
  --border: #e3e7ee;
  --chip: #eef1f7;
  --chip-active: #2f6fed;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 12px rgba(16,24,40,.06);
  --radius: 14px;
  --sidebar-w: 300px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(16,24,40,.04);
}
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.logo { font-size: 24px; background: var(--brand-soft); color: var(--brand); padding: 8px 12px; border-radius: 12px; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 700; line-height: 1.2; }
.sub { margin: 0; color: var(--muted); font-size: 12.5px; }

.search-wrap { position: relative; flex: 1 1 340px; max-width: 520px; margin-left: auto; }
.search-ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
#search {
  width: 100%;
  padding: 11px 76px 11px 40px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  outline: none;
  transition: border .15s, box-shadow .15s, background .15s;
}
#search:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: #fff; }
.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--muted);
  font-size: 15px; line-height: 1; padding: 6px; border-radius: 8px;
}
.icon-btn:hover { background: var(--chip); color: var(--text); }
.clear-btn { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }
#searchCount { position: absolute; right: 40px; top: 50%; transform: translateY(-50%); font-size: 12px; color: var(--muted); white-space: nowrap; }

.filter-toggle {
  display: none;
  align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: 9px 14px; border-radius: 10px; font-size: 14px; cursor: pointer;
}

/* ---------- Scope tabs ---------- */
.scope-tabs { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 24px 0; }
.scope-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 16px; border-radius: 999px; font-size: 14px; cursor: pointer; transition: all .15s;
}
.scope-btn .cnt { color: var(--muted); font-size: 12px; margin-left: 5px; }
.scope-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.scope-btn.active .cnt { color: rgba(255,255,255,.85); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 20px;
  align-items: start;
  padding: 20px 24px 40px;
  max-width: 1500px;
  margin: 0 auto;
}
.sidebar { position: sticky; top: 74px; display: flex; flex-direction: column; gap: 16px; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { margin: 0; font-size: 15px; }
.link-btn { border: none; background: none; color: var(--brand); font-size: 13px; cursor: pointer; padding: 2px 4px; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Region search + list ---------- */
.region-search { position: relative; display: flex; align-items: center; margin-bottom: 8px; }
.region-search svg { position: absolute; left: 10px; color: var(--muted); }
.region-search input {
  width: 100%; padding: 8px 10px 8px 30px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--bg); outline: none;
}
.region-search input:focus { border-color: var(--brand); background: #fff; }
.region-list {
  max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 2px;
  padding-right: 2px;
}
.region-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px; font-size: 13.5px; cursor: pointer; user-select: none;
}
.region-item:hover { background: var(--chip); }
.region-item .box {
  width: 17px; height: 17px; flex-shrink: 0; border-radius: 5px;
  border: 1.6px solid var(--border); display: grid; place-items: center; color: #fff; transition: all .12s;
}
.region-item.on .box { background: var(--brand); border-color: var(--brand); }
.region-item.on .box::after { content: "✓"; font-size: 11px; line-height: 1; }
.region-item .rname { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.region-item .rc { color: var(--muted); font-size: 12px; }
.region-item.on .rname { color: var(--brand); font-weight: 600; }
.region-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 12px 0; }

/* ---------- Chips (type + month) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips.months { gap: 6px; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 5px 11px; border-radius: 999px; font-size: 13px; cursor: pointer; transition: all .13s;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.chip .c { color: var(--muted); font-size: 11.5px; }
.chip:hover { border-color: var(--brand); }
.chip.active { background: var(--chip-active); color: #fff; border-color: var(--chip-active); }
.chip.active .c { color: rgba(255,255,255,.8); }
.more-btn {
  margin-top: 8px; width: 100%; border: 1px dashed var(--border); background: var(--surface);
  color: var(--brand); padding: 6px; border-radius: 9px; font-size: 13px; cursor: pointer;
}
.more-btn:hover { border-color: var(--brand); }

/* ---------- Season presets ---------- */
.season-presets { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.season-presets button {
  flex: 1 1 auto; border: 1px solid var(--border); background: var(--bg); color: var(--muted);
  padding: 6px 8px; border-radius: 9px; font-size: 12.5px; cursor: pointer; transition: all .13s;
}
.season-presets button.active { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); font-weight: 600; }

/* ---------- Clear all ---------- */
.clear-all {
  width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  padding: 10px; border-radius: 12px; font-size: 14px; cursor: pointer; transition: all .15s;
}
.clear-all:hover { color: var(--brand); border-color: var(--brand); }
.clear-all.has { color: #fff; background: var(--brand); border-color: var(--brand); }

/* ---------- Active filters ---------- */
.active-filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 14px; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.af-label { font-size: 12.5px; color: var(--muted); margin-right: 2px; }
.af-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--brand-soft); color: var(--brand);
  padding: 4px 7px 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.af-chip .rm { border: none; background: none; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0 2px; line-height: 1; }
.af-chip .rm:hover { color: #d93838; }
.af-clear { margin-left: auto; border: none; background: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.af-clear:hover { color: #d93838; }

/* ---------- Results ---------- */
.results { min-width: 0; }
.result-meta { display: flex; align-items: baseline; gap: 8px; margin: 4px 4px 16px; color: var(--muted); }
.big-count { font-size: 26px; font-weight: 700; color: var(--text); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(16,24,40,.10); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { margin: 0; font-size: 17px; font-weight: 700; }
.badge { flex-shrink: 0; background: #fff4e0; color: #a4651c; border: 1px solid #f2d8ac; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.card-loc { font-size: 13px; color: var(--brand); font-weight: 600; }
.kv { font-size: 13.5px; }
.kv b { color: var(--muted); font-weight: 600; margin-right: 4px; font-size: 12.5px; }
.card-desc { font-size: 13.5px; color: var(--text); margin: 0; }
.card-types { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-chip { background: var(--chip); color: var(--muted); padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { color: var(--brand); font-size: 12px; }

.detail { margin-top: 2px; border-top: 1px dashed var(--border); padding-top: 8px; }
.detail summary { cursor: pointer; font-size: 13px; color: var(--brand); font-weight: 600; user-select: none; list-style: none; }
.detail summary::before { content: "▾ "; }
.detail[open] summary::before { content: "▴ "; }
.detail-body { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.detail-block { font-size: 13.5px; }
.detail-block .db-label { display: inline-block; font-size: 12px; font-weight: 700; color: var(--brand); background: var(--brand-soft); padding: 1px 8px; border-radius: 999px; margin-bottom: 4px; }
.detail-block ul { margin: 4px 0 0; padding-left: 0; }
.detail-block li { list-style: none; margin: 2px 0; }
.detail-block li::before { content: "·"; color: var(--brand); margin-right: 6px; font-weight: 700; }

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 24px 0 8px; flex-wrap: wrap; }
.pager button {
  min-width: 38px; height: 38px; padding: 0 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); border-radius: 10px; font-size: 14px; cursor: pointer; transition: all .15s;
}
.pager button:hover:not(:disabled) { border-color: var(--brand); }
.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }
.pager .ellipsis { color: var(--muted); padding: 0 4px; }

.empty { text-align: center; padding: 60px 20px; color: var(--muted); font-size: 16px; }
.empty .link-btn { display: inline-block; margin-top: 8px; }

footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 24px 16px 40px; }

/* ---------- Mobile drawer ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 40; }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .filter-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(86vw, 320px);
    background: var(--bg); z-index: 50; padding: 16px; overflow-y: auto;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 24px rgba(16,24,40,.18);
  }
  body.drawer-open .sidebar { transform: translateX(0); }
  .brand h1 { font-size: 16px; }
  .sub { font-size: 11px; }
}
