:root {
  --bg: #ffffff;
  --panel: #f7f8fa;
  --border: #e3e6ea;
  --text: #1c2430;
  --muted: #6b7684;
  --accent: #2563eb;
  --sidebar-w: 320px;
  --viewer-w: 420px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

/* ---------- sidebar ---------- */
#sidebar {
  width: var(--sidebar-w);
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--panel);
  overflow-y: auto;
}
.brand { padding: 14px 16px 6px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand h1 { margin: 0; font-size: 20px; }
#lang {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 12px;
  padding: 4px 6px;
  max-width: 130px;
}
.tagline { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
#stat-count { color: var(--accent); font-weight: 600; }

.search-box { padding: 8px 16px; }
.search-box input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: var(--bg);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 16px 8px; }
.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip .cnt { color: var(--muted); font-size: 11px; }
.chip.active { border-color: var(--accent); background: #e8efff; }

.toggles { padding: 2px 16px 10px; display: flex; flex-direction: column; gap: 4px; }
.toggle { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.submit-btn {
  margin: 2px 16px 10px;
  padding: 8px 10px;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  background: #f0f5ff;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}
.submit-btn:hover { background: #e3edff; }

.report-target { font-size: 13px; font-weight: 600; margin: 0 0 10px; }
.pick-btn {
  width: 100%;
  margin-bottom: 8px;
  padding: 9px;
  border: 1px dashed var(--accent);
  border-radius: 8px;
  background: #f0f5ff;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}
.picked-point { font-size: 12px; color: #16a34a; margin: 0 0 8px; font-weight: 600; }
#pick-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  background: #1c2430;
  color: #fff;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
  pointer-events: none;
  max-width: 90%;
}

#report-modal,
#submit-modal {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 22, .55);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.submit-card {
  background: var(--bg);
  border-radius: 14px;
  width: min(460px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.submit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.submit-head h2 { margin: 0; font-size: 16px; }
.submit-head button { border: none; background: none; font-size: 16px; cursor: pointer; }
#submit-form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
#submit-form input, #submit-form textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}
#submit-form .hp { position: absolute; left: -9999px; height: 0; width: 0; padding: 0; border: 0; }
#submit-form button[type="submit"] {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
#submit-result { font-size: 12px; margin: 8px 0 0; }
#submit-result.ok { color: #16a34a; }
#submit-result.err { color: #dc2626; }

.list-section { padding: 0 8px 8px; }
.list-section h2 { font-size: 12px; color: var(--muted); margin: 8px 8px 4px; }
.wander-section { padding: 0 16px 4px; }
#wander-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#wander-btn:hover { filter: brightness(1.1); }
.cam-list { list-style: none; margin: 0; padding: 0; }
.cam-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}
.cam-item:hover { background: #edf1f6; }
.cam-item.active { background: #e8efff; }
.cam-thumb {
  width: 64px; height: 36px;
  flex: none;
  border-radius: 6px;
  object-fit: cover;
  background: #d6dbe1;
}
.cam-thumb.placeholder { display: flex; align-items: center; justify-content: center; font-size: 16px; }
.cam-meta { min-width: 0; }
.cam-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cam-sun { margin-left: auto; font-size: 13px; flex: none; }

.credits { margin-top: auto; padding: 12px 16px; font-size: 10px; color: var(--muted); }

/* ---------- map ---------- */
#map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }

#menu-btn {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 25;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
  cursor: pointer;
}

#multiview-bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 5;
}
#multiview-bar button {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
}
#multiview-bar #multiview-clear { background: #8b94a1; }

.maplibregl-popup-content { padding: 8px; border-radius: 10px; }
.map-popup { font-size: 12px; width: 180px; cursor: pointer; }
.map-popup img { width: 100%; border-radius: 6px; display: block; margin-bottom: 4px; }
.map-popup .t { font-weight: 600; }

/* ---------- viewer modal ---------- */
#viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(12, 16, 22, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.viewer-card {
  background: var(--bg);
  border-radius: 16px;
  width: min(960px, 96vw);
  max-height: 94vh;
  overflow-y: auto;
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
}
.viewer-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 14px 8px; gap: 8px; }
.viewer-head h2 { margin: 0; font-size: 16px; }
.viewer-head p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.viewer-actions { display: flex; gap: 6px; flex: none; }
.viewer-actions button {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  width: 32px; height: 32px;
  font-size: 15px;
  cursor: pointer;
}
#viewer-fav.on { color: #f59e0b; border-color: #f59e0b; }
.viewer-frame { aspect-ratio: 16 / 9; background: #000; }
.viewer-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.viewer-note { font-size: 11px; color: var(--muted); padding: 8px 14px; }
.viewer-history { padding: 0 14px 12px; }
.viewer-history h3 { font-size: 12px; color: var(--muted); margin: 4px 0 6px; }
.viewer-history ul { list-style: none; margin: 0; padding: 0; }
.viewer-history li { font-size: 11px; color: var(--muted); padding: 3px 0; border-top: 1px dashed var(--border); }
.viewer-history li b { color: var(--text); }

/* ---------- multiview ---------- */
#multiview {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 22, .96);
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.multiview-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 18px; color: #fff; }
.multiview-head h2 { margin: 0; font-size: 16px; }
#multiview-close { border: 1px solid #444; background: transparent; color: #fff; border-radius: 8px; padding: 6px 12px; cursor: pointer; }
#multiview-grid {
  flex: 1;
  display: grid;
  gap: 6px;
  padding: 0 18px 18px;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
}
#multiview-grid.single { grid-template-columns: 1fr; }
.mv-cell { position: relative; background: #000; border-radius: 8px; overflow: hidden; }
.mv-cell iframe { width: 100%; height: 100%; border: 0; }
.mv-cell .mv-label {
  position: absolute; left: 8px; top: 8px;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: 12px; padding: 3px 8px; border-radius: 6px;
}

@media (max-width: 760px) {
  #menu-btn { display: block; }
  #sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 85vw);
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,.25);
  }
  #sidebar.open { transform: none; }
  #viewer { padding: 0; }
  .viewer-card { width: 100vw; max-height: 100vh; border-radius: 0; }
  #multiview-grid { grid-template-columns: 1fr; padding: 0 8px 8px; }
  .multiview-head { padding: 8px 10px; }
}
