:root {
  --bg: #0e1116;
  --panel: #171c24;
  --panel-2: #1f2630;
  --line: #2c3644;
  --text: #e8ecf2;
  --muted: #8a97a8;
  --accent: #fb7299; /* bilibili pink */
  --accent-2: #23ade5;
  --ok: #3fb78f;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 68px; padding: 0 22px;
  background: linear-gradient(90deg, #1a2029, #202833);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid; place-items: center; width: 44px; height: 44px;
  font-size: 17px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 12px; box-shadow: var(--shadow);
}
.brand-text h1 { font-size: 20px; letter-spacing: .5px; }
.brand-text p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.brand-stats { display: flex; gap: 22px; }
.stat { text-align: center; min-width: 56px; }
.stat span { display: block; font-size: 22px; font-weight: 700; color: #fff; }
.stat small { font-size: 11.5px; color: var(--muted); }

/* ---------- Layout ---------- */
.layout { display: flex; height: calc(100vh - 68px); }
.sidebar {
  width: 336px; flex: 0 0 336px; overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg); padding: 16px; display: flex; flex-direction: column; gap: 16px;
}
.map-wrap { position: relative; flex: 1 1 auto; }
#map { position: absolute; inset: 0; z-index: 1; }

/* ---------- Panels ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 14px; letter-spacing: 1px; color: #fff; margin-bottom: 12px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field select, .field input {
  width: 100%; padding: 9px 11px; font-size: 13.5px;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 9px; outline: none;
}
.field select:focus, .field input:focus { border-color: var(--accent-2); }

.filter-actions { display: flex; gap: 8px; margin-top: 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; font-size: 13px; color: #fff; text-decoration: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 0; border-radius: 9px; cursor: pointer; transition: transform .1s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
}
.btn.ghost:hover { color: var(--text); border-color: var(--accent-2); }

/* ---------- Results list ---------- */
.results-head { display: flex; align-items: center; justify-content: space-between; }
.results-head .count {
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
  padding: 2px 9px; border-radius: 20px;
}

/* ---------- UP dropdown (filter + legend combined) ---------- */
.up-dropdown { position: relative; }
.up-dropdown-btn {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 9px 11px; font-size: 13.5px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  cursor: pointer;
}
.up-dropdown-btn:hover, .up-dropdown-btn:focus { border-color: var(--accent-2); outline: none; }
.up-dropdown-btn .caret { margin-left: auto; color: var(--muted); font-size: 12px; }
.up-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px; background: #888; box-shadow: 0 0 0 1.5px rgba(255,255,255,.7); }
.up-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 400;
  background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: var(--shadow); padding: 6px; max-height: 320px; overflow-y: auto;
}
.up-menu.hidden { display: none; }
.up-option {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  font-size: 13px; color: var(--text); border-radius: 8px; cursor: pointer;
}
.up-option:hover { background: var(--panel-2); }
.up-option.active { background: #26303d; color: #fff; }

.popup .v-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 0 2px; }
.popup .v-tags i { font-style: normal; font-size: 10.5px; color: var(--accent-2); background: var(--panel-2); padding: 1px 6px; border-radius: 8px; }
.spot-list { list-style: none; margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.spot-list li button {
  width: 100%; text-align: left; padding: 9px 11px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); cursor: pointer; transition: background .15s ease, border-color .15s ease;
}
.spot-list li button:hover { background: #26303d; border-color: var(--accent-2); }
.spot-list .spot-name { font-size: 13.5px; font-weight: 600; }
.spot-list .spot-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Blur mask (outside Japan) ---------- */
.blur-overlay {
  position: absolute; inset: 0;
  z-index: 205; pointer-events: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.japan-clip-svg {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; z-index: -1;
}

/* ---------- Popup ---------- */
.leaflet-popup-content-wrapper {
  background: var(--panel); color: var(--text); border-radius: 12px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.leaflet-popup-content { margin: 14px; min-width: 240px; max-width: 300px; max-height: 60vh; overflow-y: auto; font-family: inherit; }
.leaflet-popup-content-wrapper { max-height: 70vh; }
.popup h4 { font-size: 15px; color: #fff; margin-bottom: 2px; }
.popup .pop-sub { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.popup ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }
.popup ul li button {
  width: 100%; text-align: left; padding: 9px 11px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
  color: var(--text); cursor: pointer; font-size: 12.5px; line-height: 1.4;
}
.popup ul li button:hover { border-color: var(--accent-2); background: #26303d; }
.popup .v-up { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.popup .v-avatar { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; background: var(--panel-2); }
.popup .v-bv { color: var(--muted); font-size: 11px; display: block; }
.popup .v-date { color: var(--accent-2); font-size: 11px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center; padding: 24px;
  background: rgba(6, 8, 12, .78); backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-card {
  width: min(960px, 95vw); background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 16px; color: #fff; }
.modal-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.player-box { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; }
#playerFrame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.modal-foot { display: flex; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); }

.map-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 500; background: rgba(14, 17, 22, .85); color: var(--muted);
  font-size: 12px; padding: 7px 14px; border-radius: 20px;
  border: 1px solid var(--line); pointer-events: none;
}

/* ---------- Hamburger / drawer (mobile) ---------- */
.hamburger {
  display: none;
  width: 42px; height: 42px; font-size: 20px; line-height: 1;
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  flex: 0 0 42px;
}
.backdrop { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .hamburger { display: grid; place-items: center; }

  .topbar {
    height: auto; min-height: 60px; flex-wrap: wrap;
    padding: 10px 14px; gap: 10px;
  }
  .brand { min-width: 0; }
  .brand-text h1 { font-size: 17px; }
  .brand-text p { font-size: 11px; }
  .brand-stats { gap: 14px; margin-left: auto; }
  .stat { min-width: 44px; }
  .stat span { font-size: 17px; }
  .stat small { font-size: 10px; }

  .layout { position: relative; flex-direction: column; }
  .map-wrap { position: absolute; inset: 0; }

  /* sidebar becomes slide-in drawer over the map */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 700;
    width: min(340px, 86vw); max-width: 100%;
    transform: translateX(-102%); transition: transform .25s ease;
    padding: 16px; overflow-y: auto; box-shadow: var(--shadow);
    background: var(--bg); border-right: 1px solid var(--line);
    max-height: none;
  }
  .sidebar.open { transform: translateX(0); }

  .backdrop { display: none; }
  .backdrop.show {
    display: block; position: fixed; inset: 0; z-index: 650;
    background: rgba(6, 8, 12, .5);
  }

  .map-hint { font-size: 11px; padding: 6px 11px; max-width: 90vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .modal-card { width: 100vw; height: 100vh; border-radius: 0; }
  .modal { padding: 0; }
  .modal-head { padding: 14px 16px; }
  .modal-foot { padding: 12px 16px; }
}

@media (max-width: 480px) {
  .brand-stats { display: none; }
}

