:root {
  --radius: 16px;
  --radius-sm: 10px;
  --font: "IBM Plex Sans JP", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2330;
  --surface-3: #21262d;
  --border: rgba(240, 246, 252, 0.08);
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-2: #39d4ff;
  --accent-soft: rgba(88, 166, 255, 0.12);
  --accent-border: rgba(88, 166, 255, 0.35);
  --accent-border-strong: rgba(88, 166, 255, 0.8);
  --success: #3fb950;
  --success-soft: rgba(63, 185, 80, 0.14);
  --warning: #d29922;
  --error: #f85149;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --sidebar-bg: linear-gradient(180deg, rgba(22, 27, 34, 0.96), rgba(13, 17, 23, 0.98));
  --card-bg: rgba(28, 35, 48, 0.72);
  --card-active-bg: linear-gradient(180deg, rgba(88, 166, 255, 0.12), rgba(28, 35, 48, 0.9));
  --panel-bg: rgba(22, 27, 34, 0.88);
  --item-bg: rgba(33, 38, 45, 0.85);
  --item-hover-bg: rgba(88, 166, 255, 0.08);
  --btn-ghost-bg: rgba(33, 38, 45, 0.9);
  --btn-primary-text: #0d1117;
  --brand-mark-text: #0d1117;
  --grid-color: rgba(88, 166, 255, 0.04);
  --map-bg: #0b1018;
  --popup-bg: rgba(22, 27, 34, 0.96);
}

html[data-theme="mid"] {
  color-scheme: dark;
  --bg: #1a2230;
  --surface: #232d3d;
  --surface-2: #2a3547;
  --surface-3: #313d52;
  --border: rgba(226, 232, 240, 0.1);
  --text: #e8edf5;
  --text-dim: #9aa8bc;
  --accent: #6ea8ff;
  --accent-2: #5fd4ff;
  --accent-soft: rgba(110, 168, 255, 0.14);
  --accent-border: rgba(110, 168, 255, 0.32);
  --accent-border-strong: rgba(110, 168, 255, 0.72);
  --success: #4cc76a;
  --success-soft: rgba(76, 199, 106, 0.14);
  --warning: #e0ad49;
  --error: #ff6b63;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
  --sidebar-bg: linear-gradient(180deg, rgba(35, 45, 61, 0.96), rgba(26, 34, 48, 0.98));
  --card-bg: rgba(42, 53, 71, 0.82);
  --card-active-bg: linear-gradient(180deg, rgba(110, 168, 255, 0.14), rgba(42, 53, 71, 0.95));
  --panel-bg: rgba(35, 45, 61, 0.92);
  --item-bg: rgba(49, 61, 82, 0.88);
  --item-hover-bg: rgba(110, 168, 255, 0.1);
  --btn-ghost-bg: rgba(49, 61, 82, 0.92);
  --btn-primary-text: #102033;
  --brand-mark-text: #102033;
  --grid-color: rgba(110, 168, 255, 0.05);
  --map-bg: #243041;
  --popup-bg: rgba(35, 45, 61, 0.96);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f9;
  --surface-3: #e3eaf3;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --text-dim: #64748b;
  --accent: #2563eb;
  --accent-2: #0ea5e9;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-border: rgba(37, 99, 235, 0.28);
  --accent-border-strong: rgba(37, 99, 235, 0.55);
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --warning: #d97706;
  --error: #dc2626;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
  --sidebar-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(244, 247, 251, 0.98));
  --card-bg: rgba(255, 255, 255, 0.92);
  --card-active-bg: linear-gradient(180deg, rgba(37, 99, 235, 0.08), rgba(255, 255, 255, 0.98));
  --panel-bg: rgba(255, 255, 255, 0.96);
  --item-bg: rgba(241, 245, 249, 0.95);
  --item-hover-bg: rgba(37, 99, 235, 0.08);
  --btn-ghost-bg: rgba(255, 255, 255, 0.95);
  --btn-primary-text: #ffffff;
  --brand-mark-text: #ffffff;
  --grid-color: rgba(37, 99, 235, 0.06);
  --map-bg: #dbe4ee;
  --popup-bg: rgba(255, 255, 255, 0.98);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  transition: background 0.25s ease, color 0.25s ease;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black 30%, transparent 100%);
  pointer-events: none;
}

.app {
  position: relative;
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  gap: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--brand-mark-text);
  box-shadow: 0 12px 32px rgba(88, 166, 255, 0.25);
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.brand p {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 0.82rem;
}

.sidebar-actions {
  display: flex;
  gap: 8px;
}

.theme-toggle {
  flex: 1;
}

.upload-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.upload-card {
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.upload-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent-border);
}

.upload-card.active {
  border-color: var(--accent-border-strong);
  background: var(--card-active-bg);
  box-shadow: inset 0 0 0 1px var(--accent-soft);
}

.upload-card h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  line-height: 1.35;
  word-break: break-all;
}

.upload-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.74rem;
}

.sidebar-footer {
  color: var(--text-dim);
  font-size: 0.72rem;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 24px 12px;
}

.topbar h2 {
  margin: 0;
  font-size: 1.35rem;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 0.86rem;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.map-style-switch {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 12px;
  background: var(--btn-ghost-bg);
  border: 1px solid var(--border);
}

.map-style-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.map-style-btn:hover {
  color: var(--text);
}

.map-style-btn.active {
  color: var(--text);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-border);
}

.map-labels-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--btn-ghost-bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.map-labels-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 0 24px 24px;
  flex: 1;
  min-height: 0;
}

.map {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-height: 420px;
}

.point-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.panel-header h3 {
  margin: 0;
  font-size: 0.95rem;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 0.75rem;
  font-family: var(--mono);
}

.point-list {
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.point-item {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px;
  background: var(--item-bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.point-item:hover,
.point-item.active {
  border-color: var(--accent-border);
  background: var(--item-hover-bg);
}

.point-item .name {
  font-weight: 600;
  margin-bottom: 6px;
}

.point-item .coords {
  color: var(--text-dim);
  font-size: 0.76rem;
  font-family: var(--mono);
  line-height: 1.5;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: var(--btn-primary-text);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(88, 166, 255, 0.25);
}

.btn.ghost {
  color: var(--text);
  background: var(--btn-ghost-bg);
  border: 1px solid var(--border);
}

.empty-state {
  color: var(--text-dim);
  padding: 24px 12px;
  text-align: center;
  font-size: 0.9rem;
}

.empty-state.small {
  padding: 16px 8px;
  font-size: 0.82rem;
}

.leaflet-container {
  background: var(--map-bg);
  font-family: var(--font);
}

.leaflet-popup-content-wrapper {
  background: var(--popup-bg);
  color: var(--text);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.leaflet-popup-tip {
  background: var(--popup-bg);
}

.popup-title {
  font-weight: 700;
  margin-bottom: 6px;
}

.popup-meta {
  color: var(--text-dim);
  font-size: 0.78rem;
  font-family: var(--mono);
  line-height: 1.45;
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    max-height: 34vh;
  }

  .content {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }

  .point-panel {
    max-height: 280px;
  }
}
