/* 地図の地図 — 見た目 */
:root {
  --bg: #070a10;
  --panel: rgba(12, 16, 25, 0.94);
  --panel-solid: #0c1019;
  --panel-2: rgba(255, 255, 255, 0.04);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e7edf6;
  --muted: #8e9ab0;
  --faint: #5d687c;
  --accent: #2ee6ff;

  /* 地域の光の色（level ごと） */
  --c-world: #5aa9ff;
  --c-country: #2ee6ff;
  --c-regional: #ffb547;
  --c-local: #ff5ad8;

  --radius: 12px;
  --sidebar-w: 360px;
  --font: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }

#app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ===== 一覧（左） ===== */
#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  border-right: 1px solid var(--line);
  z-index: 1100;
  transition: margin-left 0.25s ease;
}
#app.sidebar-closed #sidebar { margin-left: calc(-1 * var(--sidebar-w)); }

.sb-head { padding: 18px 18px 10px; }
.sb-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, var(--c-country), var(--c-regional) 55%, var(--c-local));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sb-title-en {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
  text-transform: uppercase;
}
.sb-lead { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }
.sb-stats { margin: 8px 0 0; font-size: 12px; color: var(--faint); }
.sb-stats b { color: var(--text); font-weight: 700; }

.sb-search { padding: 4px 18px 12px; border-bottom: 1px solid var(--line); }
#search {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
}
#search:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

.sb-list { flex: 1; overflow-y: auto; padding: 6px 10px 12px; scrollbar-width: thin; scrollbar-color: #2a3242 transparent; }
.grp { margin: 10px 0 2px; }
.grp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.grp-head .dot { flex: none; }
.grp-head .count { margin-left: auto; font-weight: 600; color: var(--faint); }

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rc);
  box-shadow: 0 0 6px var(--rc), 0 0 12px var(--rc);
}

.item {
  position: relative;
  margin: 2px 0;
  padding: 10px 12px 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: default;
  transition: background 0.15s, border-color 0.15s;
}
.item::before {
  content: "";
  position: absolute;
  left: 4px; top: 12px; bottom: 12px;
  width: 3px;
  border-radius: 2px;
  background: var(--rc);
  opacity: 0.55;
}
.item:hover, .item:focus-within, .item.is-hot { background: var(--panel-2); border-color: var(--line); }
.item:hover::before, .item.is-hot::before { opacity: 1; box-shadow: 0 0 8px var(--rc); }
.item-top { display: flex; align-items: baseline; gap: 8px; }
.item-link {
  font-weight: 700;
  font-size: 14.5px;
  text-decoration: none;
}
.item-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.item-link .ext { font-size: 11px; color: var(--muted); margin-left: 3px; }
.item-host { margin-left: auto; font-size: 11px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.item-desc { margin: 4px 0 6px; font-size: 12.5px; color: #b8c2d3; }
.item-meta { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tag {
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}
.tag.lang { background: transparent; border: 1px solid var(--line); }
.item-actions { margin-left: auto; display: flex; gap: 4px; }
.btn-mini {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}
.btn-mini:hover { color: var(--text); border-color: color-mix(in srgb, var(--rc, var(--accent)) 70%, transparent); }
.empty { padding: 24px 12px; color: var(--muted); text-align: center; font-size: 13px; }

.sb-foot { border-top: 1px solid var(--line); padding: 10px 18px 14px; font-size: 11.5px; color: var(--faint); }
.discover h2 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 700; }
.discover ul { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.discover li { white-space: nowrap; }
.discover a { color: var(--muted); }
.discover a:hover { color: var(--text); }
.credit { margin: 0; line-height: 1.6; }
.credit a { color: var(--muted); }

/* ===== 地図 ===== */
#map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: #0a0d14; }
#map.is-over-region { cursor: pointer; }
.leaflet-container { font-family: var(--font); }
.leaflet-control-attribution { background: rgba(8, 11, 18, 0.75) !important; color: var(--faint) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bar a, .leaflet-control-layers { background: var(--panel) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-bar { border: 1px solid var(--line) !important; box-shadow: none !important; }
.leaflet-control-layers { border: 1px solid var(--line) !important; box-shadow: none !important; border-radius: 10px !important; }
.leaflet-control-layers-toggle { filter: invert(1) hue-rotate(180deg) brightness(1.4); }
.leaflet-control-layers-expanded { padding: 8px 12px 8px 8px; font-size: 12.5px; }

/* 光る地域（SVG の path） */
path.rg {
  stroke: var(--rc);
  fill: var(--rc);
  stroke-width: 1.4px;
  stroke-linejoin: round;
  fill-opacity: 0.12;
  stroke-opacity: 0.8;
  filter: drop-shadow(0 0 3px var(--rc)) drop-shadow(0 0 9px var(--rc));
  animation: rg-breathe 3.6s ease-in-out infinite;
  transition: fill-opacity 0.2s, stroke-width 0.2s;
}
path.rg--country { --rc: var(--c-country); }
path.rg--regional { --rc: var(--c-regional); animation-delay: -1.2s; }
path.rg--local { --rc: var(--c-local); animation-delay: -2.4s; stroke-width: 2px; }
path.rg--world {
  --rc: var(--c-world);
  animation: none;
  fill-opacity: 0;
  stroke-opacity: 0;
  filter: none;
  transition: fill-opacity 0.35s, stroke-opacity 0.35s;
}
.show-world path.rg--world { fill-opacity: 0.22; stroke-opacity: 0.9; filter: drop-shadow(0 0 4px var(--rc)); }

path.rg--dashed {
  stroke-dasharray: 6 5;
  stroke-width: 1.6px;
  fill-opacity: 0.04;
  filter: drop-shadow(0 0 3px var(--rc));
  animation-name: rg-breathe-soft;
}
@keyframes rg-breathe-soft {
  0%, 100% { fill-opacity: 0.02; stroke-opacity: 0.45; }
  50% { fill-opacity: 0.06; stroke-opacity: 0.95; }
}

path.rg.is-warm {
  animation: none;
  fill-opacity: 0.07;
  stroke-opacity: 0.95;
  filter: drop-shadow(0 0 3px var(--rc)) drop-shadow(0 0 7px var(--rc));
}
path.rg.is-hot {
  animation: none;
  fill-opacity: 0.24;
  stroke-opacity: 1;
  stroke-width: 2.4px;
  filter: drop-shadow(0 0 4px var(--rc)) drop-shadow(0 0 14px var(--rc));
}
path.rg--dashed.is-hot { fill-opacity: 0.12; }
path.rg.is-dim { animation: none; fill-opacity: 0.03; stroke-opacity: 0.18; filter: none; }

@keyframes rg-breathe {
  0%, 100% { fill-opacity: 0.08; stroke-opacity: 0.55; }
  50% { fill-opacity: 0.2; stroke-opacity: 1; }
}

/* 小さく見える地域の目印（ビーコン） */
.beacon { pointer-events: none; }
.beacon i {
  position: absolute;
  left: 50%; top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.beacon .core { width: 9px; height: 9px; background: var(--rc); box-shadow: 0 0 8px var(--rc), 0 0 16px var(--rc); }
.beacon .ring {
  width: 9px; height: 9px;
  border: 2px solid var(--rc);
  opacity: 0;
  animation: beacon-ring 2.4s ease-out infinite;
}
.beacon .ring + .ring { animation-delay: 1.2s; }
.beacon--country { --rc: var(--c-country); }
.beacon--regional { --rc: var(--c-regional); }
.beacon--local { --rc: var(--c-local); }
.beacon.is-hot .core { width: 13px; height: 13px; }
.beacon.is-dim { opacity: 0.25; }
.beacon.is-dim .ring { animation: none; }
@keyframes beacon-ring {
  0% { width: 9px; height: 9px; opacity: 0.9; }
  100% { width: 44px; height: 44px; opacity: 0; }
}

/* ===== カーソルを当てたときのカード ===== */
.card {
  position: absolute;
  z-index: 1200;
  width: 340px;
  max-width: calc(100% - 24px);
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 10px 10px 8px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  scrollbar-width: thin;
  scrollbar-color: #2a3242 transparent;
  animation: card-in 0.14s ease-out;
}
.card[hidden] { display: none; }
@keyframes card-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.card-head { display: flex; align-items: center; gap: 8px; padding: 0 4px 6px; }
.card-head .hint { font-size: 11px; color: var(--faint); }
.card-close {
  margin-left: auto;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  display: none;
}
.card.is-pinned .card-close { display: inline-block; }
.card-close:hover { color: var(--text); }
.card-grp + .card-grp { margin-top: 6px; border-top: 1px solid var(--line); padding-top: 6px; }
.card-grp h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 2px 4px 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.svc {
  display: block;
  padding: 8px 10px;
  border-radius: 9px;
  text-decoration: none;
  transition: background 0.12s;
}
.svc:hover, .svc:focus-visible { background: rgba(255, 255, 255, 0.06); outline: none; }
.svc-top { display: flex; align-items: baseline; gap: 8px; }
.svc-name { font-weight: 700; font-size: 14px; }
.svc:hover .svc-name { color: var(--rc); text-shadow: 0 0 12px color-mix(in srgb, var(--rc) 50%, transparent); }
.svc-host { margin-left: auto; font-size: 11px; color: var(--faint); white-space: nowrap; }
.svc-desc { display: block; margin-top: 2px; font-size: 12px; color: #aab5c7; }
.card-note { margin: 6px 4px 0; font-size: 11px; color: var(--faint); }

/* ===== 世界全体の地図（左下） ===== */
.dock {
  position: absolute;
  left: 12px;
  bottom: 22px;
  z-index: 1000;
  width: 300px;
  max-width: calc(100% - 24px);
  padding: 10px 10px 8px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--c-world) 35%, var(--line));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 24px color-mix(in srgb, var(--c-world) 18%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  --rc: var(--c-world);
}
.dock-head { display: flex; align-items: center; gap: 8px; margin: 0 4px 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.dock-head .toggle { margin-left: auto; }
.dock .svc { padding: 6px 8px; }
.dock .svc-desc { display: none; }
.dock .svc:hover .svc-desc, .dock .svc:focus-visible .svc-desc { display: block; }
.dock.is-collapsed .dock-body { display: none; }

/* ===== 凡例（右下） ===== */
.legend {
  position: absolute;
  right: 10px;
  bottom: 26px;
  z-index: 1000;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.legend div { display: flex; align-items: center; gap: 7px; }

/* ===== 一覧の表示ボタン ===== */
.fab {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  font-size: 13px;
}
.fab:hover { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }

.noscript { position: fixed; inset: auto 0 0 0; margin: 0; padding: 12px; background: #400; color: #fff; text-align: center; }

/* ===== 狭い画面（スマホ） ===== */
@media (max-width: 760px) {
  :root { --sidebar-w: min(88vw, 360px); }
  #sidebar {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  }
  .card {
    position: absolute;
    left: 8px !important;
    right: 8px;
    top: auto !important;
    bottom: 8px;
    width: auto;
    max-width: none;
    max-height: 55%;
  }
  .dock { bottom: 30px; width: auto; right: 12px; }
  .dock .dock-body { max-height: 30vh; overflow-y: auto; }
  .legend { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  path.rg, .beacon .ring, .card { animation: none !important; }
}
