:root {
  --bg: #08131b;
  --panel: rgba(12, 25, 36, 0.94);
  --panel-border: rgba(145, 192, 224, 0.18);
  --text: #e8f1f7;
  --muted: #93adbf;
  --accent: #2ec4b6;
  --btn-bg: #132c3d;
  --btn-hover: #1b3d54;
}

* { box-sizing: border-box; }
html, body, #app { margin: 0; padding: 0; width: 100%; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; font-size: 13px; overflow: hidden; }

#app { display: flex; position: relative; }

.panel {
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  z-index: 10;
  backdrop-filter: blur(8px);
}

#sidebar {
  width: 340px;
  min-width: 280px;
  max-width: 90vw;
  height: 100%;
}

#sidebar.collapsed { display: none; }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--panel-border);
}

.panel-header h1, .panel-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11.5px;
}

.subtitle a { color: var(--accent); text-decoration: none; }
.subtitle a:hover { text-decoration: underline; }

button {
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
}
button:hover { background: var(--btn-hover); }

.icon-btn {
  padding: 4px 8px;
  font-size: 14px;
  line-height: 1;
}

.frames-bar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--panel-border);
}

.toolbar {
  padding: 8px 14px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.search-box {
  position: relative;
  padding: 8px 14px;
  border-bottom: 1px solid var(--panel-border);
}

.search-box input {
  width: 100%;
  background: #091722;
  color: var(--text);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 12px;
}

.search-results {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 40px;
  max-height: 240px;
  overflow-y: auto;
  background: #0d202e;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}

.search-item {
  padding: 6px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.search-item:hover { background: var(--btn-hover); }
.search-item small { color: var(--muted); white-space: nowrap; }

.status-line {
  padding: 6px 14px;
  font-size: 11.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--panel-border);
  min-height: 28px;
}

.layer-groups {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 18px;
}

.group-block {
  margin-bottom: 10px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(9, 20, 30, 0.55);
}

.group-title {
  padding: 7px 10px;
  font-weight: 600;
  font-size: 12px;
  background: rgba(20, 44, 62, 0.55);
  border-bottom: 1px solid var(--panel-border);
  color: #cfe4f2;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
}
.layer-row:last-child { border-bottom: none; }
.layer-row:hover { background: rgba(255,255,255,0.04); }

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.3);
}

.layer-meta {
  flex: 1;
  min-width: 0;
}

.layer-name {
  display: block;
  font-size: 12.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-sub {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
}

.layer-badge {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}
.layer-badge.loaded { color: #7ae582; }
.layer-badge.loading { color: #f0b429; }
.layer-badge.error { color: #ff6b6b; }

#map-wrap {
  flex: 1;
  position: relative;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
  background: #081520;
}

.floating-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 15;
  padding: 7px 12px;
  font-weight: 600;
}

.coords-bar {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 12;
  background: rgba(8, 19, 27, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11.5px;
  color: #cfe4f2;
  font-variant-numeric: tabular-nums;
}

.inspector {
  width: 360px;
  max-width: 92vw;
  height: 100%;
  border-right: none;
  border-left: 1px solid var(--panel-border);
}

.insp-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 20px;
}

.insp-section {
  margin-bottom: 14px;
}

.insp-section h3 {
  margin: 0 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.kv-table {
  width: 100%;
  border-collapse: collapse;
}

.kv-table th, .kv-table td {
  text-align: left;
  vertical-align: top;
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 12px;
}

.kv-table th {
  color: var(--muted);
  width: 36%;
  font-weight: 500;
}

.fact-card {
  background: rgba(16, 36, 52, 0.65);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 7px 9px;
  margin-bottom: 7px;
}

.fact-label {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.fact-val {
  font-size: 12.2px;
  line-height: 1.35;
}

.fact-src {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--muted);
}
.fact-src a { color: var(--accent); }

.muted { color: var(--muted); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 10, 15, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-card {
  width: 720px;
  max-width: 100%;
  max-height: 85vh;
  background: #0d1f2d;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  line-height: 1.45;
}

.hidden { display: none !important; }

.maplibregl-popup-content {
  background: #0d1f2d;
  color: var(--text);
  border: 1px solid var(--panel-border);
  font-size: 12px;
}

@media (max-width: 820px) {
  #sidebar { position: absolute; left: 0; top: 0; bottom: 0; z-index: 25; }
  .inspector { position: absolute; right: 0; top: 0; bottom: 0; z-index: 26; }
}
