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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: rgba(255,255,255,0.08);
  --accent: #3b7fff;
  --accent2: #22c55e;
  --text: #e8eaf0;
  --text-sub: #8b90a7;
  --sidebar-w: 300px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

/* ── Layout ───────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}

#map {
  
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
}

#coords-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  height: 26px;
  background: rgba(15,17,23,0.85);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  z-index: 50;
}

#coords-text {
  font-size: 11px;
  color: var(--text-sub);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

/* ── Sidebar header ───────────────────────── */
#sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

#logo-mark {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
#logo-mark::after {
  content: '';
  position: absolute;
  bottom: 4px; left: 4px;
  width: 26px; height: 14px;
  border: 2px solid rgba(255,255,255,0.7);
  border-radius: 2px;
}
#logo-mark::before {
  content: '';
  position: absolute;
  top: 5px; right: 5px;
  width: 8px; height: 8px;
  background: rgba(255,255,255,0.6);
  border-radius: 50%;
}

#sidebar-header h1 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
#sidebar-header p {
  font-size: 11px;
  color: var(--text-sub);
  margin-top: 2px;
}

/* ── Section labels ───────────────────────── */
.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-sub);
  padding: 14px 16px 6px;
}

/* ── Basemap switcher ─────────────────────── */
#basemap-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 16px 4px;
}

.basemap-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-sub);
  border-radius: 6px;
  padding: 6px 0;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.basemap-btn:hover { border-color: var(--accent); color: var(--text); }
.basemap-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

/* ── Layer items ──────────────────────────── */
.layer-item {
  margin: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  transition: border-color 0.15s;
}
.layer-item:hover { border-color: rgba(255,255,255,0.15); }

.layer-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.layer-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.layer-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.layer-sub {
  font-size: 10px;
  color: var(--text-sub);
}

.layer-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Toggle switch ────────────────────────── */
.switch { position: relative; width: 34px; height: 18px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: #333;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform 0.2s;
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }

/* ── Opacity row ──────────────────────────── */
.opacity-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-sub);
}
.opacity-slider {
  flex: 1;
  height: 3px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}
.op-val { min-width: 32px; text-align: right; font-variant-numeric: tabular-nums; }

/* ── Upload area ──────────────────────────── */
#upload-area {
  margin: 2px 10px 6px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-sub);
  font-size: 12px;
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
}
#upload-area:hover { border-color: var(--accent); color: var(--text); }
#upload-area svg { opacity: 0.6; }

#upload-status {
  font-size: 11px;
  color: var(--accent2);
  padding: 0 14px 6px;
  min-height: 18px;
}

.sample-file-hint {
  margin: 0;
  padding: 0 14px 10px;
  font-size: 11px;
  color: var(--text-sub);
}
.sample-file-hint a { color: var(--accent); }

.wms-debug-panel {
  margin: 8px 10px 12px;
  padding: 10px 12px;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-sub);
}
.wms-debug-hint { margin: 0 0 8px; line-height: 1.45; }
.wms-debug-hint strong { color: var(--text); }
.wms-debug-links { margin: 0 0 8px; }
.wms-debug-links a { color: var(--accent); }
.wms-debug-pre {
  margin: 0;
  padding: 8px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 10px;
  font-family: ui-monospace, monospace;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  color: #c8cdd8;
}

/* ── Footer ───────────────────────────────── */
#sidebar-footer {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-sub);
}

/* ── Scrollbar ────────────────────────────── */
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
