/* ── Variables ──────────────────────────────────────────────── */
:root {
  --bg:            #0d1117;
  --sidebar-bg:    #161b22;
  --panel-bg:      #1c2128;
  --surface:       #21262d;
  --surface-hover: #2d333b;
  --border:        #30363d;
  --border-light:  #21262d;

  --text:          #e6edf3;
  --text-muted:    #8b949e;
  --text-dim:      #484f58;
  --accent:        #58a6ff;
  --accent-hover:  #79b8ff;

  /* Source colours */
  --src-meshmap:    #2d81d6;
  --src-liamcottle: #f78166;
  --src-gaulix:     #3fb950;

  /* Status colours */
  --st-online:  #3fb950;
  --st-recent:  #d29922;
  --st-offline: #6e7681;
  --st-unknown: #3d444d;

  /* Role colours */
  --role-router:   #7d56c2;
  --role-repeater: #2d81d6;
  --role-client:   #484f58;
  --role-tracker:  #d29922;
  --role-sensor:   #39a3c7;

  --sidebar-w: 290px;
  --panel-w:   360px;
  --header-h:  60px;
  --radius:    8px;
  --radius-sm: 5px;
}

/* ── Reset / Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

/* ── Layout (map page inner flex) ────────────────────────── */
#page-map {
  /* .page-map-layout sets flex-direction: row */
}

/* ── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  max-height: 100%;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s ease, min-width 0.25s ease, width 0.25s ease;
  z-index: 1000;
  overflow: hidden;
}

#sidebar.collapsed {
  transform: translateX(calc(-1 * var(--sidebar-w)));
  min-width: 0;
  width: 0;
  border-right: none;
}

#sidebar-reopen {
  display: none;
  position: fixed;
  top: calc(var(--nav-h) + 10px);
  left: 14px;
  z-index: 2100;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 6px 8px;
  cursor: pointer;
  line-height: 0;
  transition: background 0.15s, color 0.15s;
}
#sidebar-reopen:hover { background: var(--surface); color: var(--text); }
#sidebar.collapsed ~ #sidebar-reopen,
body.sidebar-collapsed #sidebar-reopen { display: flex; }

/* Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

#sidebar-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
#sidebar-toggle:hover { background: var(--surface); color: var(--text); }

/* Scrollable area */
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Search ──────────────────────────────────────────────── */
.search-wrap {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px;
  gap: 6px;
  transition: border-color 0.15s;
}
.search-wrap:focus-within { border-color: var(--accent); }
.search-icon { color: var(--text-muted); flex-shrink: 0; }

#search {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13px;
  padding: 8px 0;
}
#search::placeholder { color: var(--text-dim); }

#clear-search {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 3px;
}
#clear-search:hover { color: var(--text); background: var(--surface-hover); }

/* ── Stats row ───────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 6px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.stat-val {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.stat-lbl {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.stat-card.online .stat-val { color: var(--st-online); }
.stat-card.recent .stat-val { color: var(--st-recent); }

/* ── Refresh bar ─────────────────────────────────────────── */
.refresh-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

#refresh-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 11px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#refresh-btn:hover { background: var(--surface); color: var(--accent); border-color: var(--accent); }
#refresh-btn.loading svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Filter groups ───────────────────────────────────────── */
.filter-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--surface);
  border: none;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 9px 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.group-header:hover { background: var(--surface-hover); }

.chevron {
  transition: transform 0.2s;
  flex-shrink: 0;
}
.group-header.collapsed .chevron { transform: rotate(-90deg); }

.group-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--sidebar-bg);
}
.group-body.hidden { display: none; }

/* Source rows */
.source-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
  user-select: none;
}
.source-row:hover { background: var(--surface); }
.source-row input[type="checkbox"] { display: none; }

.src-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.src-name { flex: 1; color: var(--text); font-size: 12px; }
.src-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 10px;
  color: var(--text-muted);
  padding: 1px 6px;
  min-width: 28px;
  text-align: center;
}

/* Checkbox rows (status, role) */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
  user-select: none;
  font-size: 12px;
  color: var(--text);
}
.check-row:hover { background: var(--surface); }
.check-row input[type="checkbox"] { accent-color: var(--accent); width: 13px; height: 13px; }

/* Status dots */
.dot-status {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-status.online  { background: var(--st-online); box-shadow: 0 0 5px var(--st-online); }
.dot-status.recent  { background: var(--st-recent); }
.dot-status.offline { background: var(--st-offline); }
.dot-status.unknown { background: var(--st-unknown); border: 1px solid var(--border); }

/* ── Legend ──────────────────────────────────────────────── */
.legend-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface);
}
.legend-block h4 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.legend-grid { display: flex; flex-direction: column; gap: 5px; }
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.legend-sep {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border-light);
}

/* ── Map wrap ────────────────────────────────────────────── */
#map-wrap {
  flex: 1;
  position: relative;
  height: 100%;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* ── Floating controls ───────────────────────────────────── */
.map-controls {
  position: absolute;
  bottom: 24px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 900;
}

.map-controls-sep {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.map-controls button {
  width: 36px;
  height: 36px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.map-controls button:hover { background: var(--surface-hover); color: var(--accent); }

/* ── Loading overlay ─────────────────────────────────────── */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13,17,23,0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 2000;
  color: var(--text-muted);
  font-size: 13px;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

/* ── Error toast ─────────────────────────────────────────── */
#error-toast {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #3d1515;
  border: 1px solid #f8514980;
  color: #f85149;
  padding: 8px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  z-index: 2000;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: opacity 0.3s;
}
#error-toast.hidden { display: none; }

/* ── Detail panel ────────────────────────────────────────── */
#detail-panel {
  width: var(--panel-w);
  min-width: var(--panel-w);
  height: 100%;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease, min-width 0.25s ease, width 0.25s ease;
  z-index: 900;
}
#detail-panel.hidden {
  transform: translateX(var(--panel-w));
  min-width: 0;
  width: 0;
  border-left: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--sidebar-bg);
}

.node-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.short-name-badge {
  background: var(--accent);
  color: #0d1117;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  flex-shrink: 0;
  font-family: monospace;
}

.node-long-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.node-hex-id {
  font-size: 11px;
  font-family: monospace;
  color: var(--text-muted);
  margin-top: 2px;
}

#close-panel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
#close-panel:hover { background: var(--surface); color: var(--text); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Badges */
.badges-row { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.status-badge.online  { background: #1a3d2a; color: var(--st-online); border: 1px solid #2ea043; }
.status-badge.recent  { background: #3d2a00; color: var(--st-recent); border: 1px solid #9e6a03; }
.status-badge.offline { background: var(--surface); color: var(--st-offline); border: 1px solid var(--border); }
.status-badge.unknown { background: var(--surface); color: var(--text-dim); border: 1px solid var(--border); }
.source-badge { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }
.role-badge   { background: #1a1a3d; color: #8b5cf6; border: 1px solid #3730a3; }

/* Detail row */
.detail-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
}
.detail-label { color: var(--text-muted); }
.detail-val   { color: var(--text); font-weight: 500; }

/* Detail section */
.detail-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.count-badge {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  font-size: 10px;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
  margin-left: auto;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.info-cell {
  padding: 9px 12px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.info-cell:nth-child(2n)  { border-right: none; }
.info-cell:last-child,
.info-cell:nth-last-child(2):nth-child(odd) { border-bottom: none; }
.info-cell span  { display: block; font-size: 10px; color: var(--text-muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.3px; }
.info-cell strong { font-size: 12px; color: var(--text); font-weight: 500; }

/* Battery */
.battery-widget {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.battery-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.battery-label strong { color: var(--text); }
.battery-track {
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.battery-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease, background-color 0.3s;
  background: var(--st-online);
}

/* Maps link */
.maps-link {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--accent);
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  transition: background 0.12s;
}
.maps-link:hover { background: var(--surface); text-decoration: none; }

/* Neighbors */
#dp-neighbors { padding: 6px 10px 8px; }
.neighbor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 4px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
  cursor: default;
}
.neighbor-item:hover { background: var(--surface); }
.neighbor-id {
  font-family: monospace;
  font-size: 11px;
  color: var(--accent);
}
.neighbor-snr {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.snr-good  { color: var(--st-online); }
.snr-ok    { color: var(--st-recent); }
.snr-bad   { color: #f85149; }

/* ── Utility classes ─────────────────────────────────────── */
.hidden { display: none !important; }
.muted  { color: var(--text-muted); }
.small  { font-size: 11px; }

/* ── Leaflet overrides ───────────────────────────────────── */
.leaflet-control-layers {
  background: var(--panel-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  color: var(--text) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
}
.leaflet-control-layers-toggle {
  background-color: var(--panel-bg) !important;
  width: 36px !important;
  height: 36px !important;
}
.leaflet-control-layers label { color: var(--text) !important; font-size: 12px !important; }
.leaflet-control-layers-separator { border-color: var(--border) !important; }
.leaflet-container .leaflet-control-attribution {
  background: rgba(13,17,23,0.75) !important;
  color: var(--text-dim) !important;
  font-size: 10px !important;
}
.leaflet-container .leaflet-control-attribution a { color: var(--text-muted) !important; }

/* Cluster icons */
.cluster-icon {
  border-radius: 50%;
  border: 2px solid;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: transform 0.15s;
}
.cluster-icon:hover { transform: scale(1.1); }

/* Custom marker */
.mesh-marker { background: transparent; border: none; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 260px; --panel-w: 100vw; --nav-h: 50px; }

  #detail-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 75vh;
    border-left: none;
    border-top: 1px solid var(--border);
    transform: translateY(100%);
  }
  #detail-panel.hidden { transform: translateY(100%); width: 100%; }
  #detail-panel:not(.hidden) { transform: translateY(0); }

  #top-nav { padding: 0 12px; gap: 0; }
  .brand-name { display: none; }
  .nav-link span:last-child { display: none; }
  .nav-link { padding: 0 10px; gap: 0; font-size: 0; }
  .nav-link svg { width: 18px; height: 18px; }

  .hero { flex-direction: column; padding: 32px 20px; gap: 24px; text-align: center; }
  .hero-visual { display: none; }
  .hero-cta { justify-content: center; }
  .hero-title { font-size: 26px; }

  .home-stats { grid-template-columns: 1fr 1fr; gap: 12px; }
  .hstat-sep { display: none; }

  .feature-grid { grid-template-columns: 1fr; }
  .community-grid { grid-template-columns: 1fr; }
  .apps-grid { grid-template-columns: 1fr 1fr; }
  .steps { gap: 16px; }
  .step { flex-direction: column; gap: 10px; }
  .step-arrow { display: none; }

  .page-scroll { padding: 24px 16px 80px; }
}

/* ═══════════════════════════ TOP NAV ═══════════════════════════ */
:root { --nav-h: 52px; }

html, body { height: 100%; overflow: hidden; }

#top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 2000;
  gap: 20px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.nav-brand:hover { text-decoration: none; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  height: 36px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--surface-hover); color: var(--accent); }

/* ═══════════════════════════ PAGES ═══════════════════════════ */
#pages {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  bottom: 0;
}

.page {
  display: none;
  width: 100%;
  height: 100%;
}
.page.active { display: flex; }

/* Map page inherits old layout */
.page-map-layout {
  flex-direction: row;
  overflow: hidden;
}

/* Scrollable content pages */
.page-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 40px 24px 80px;
}
.page-scroll::-webkit-scrollbar { width: 6px; }
.page-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Page headers ─────────────────────────────────────────── */
.page-header { margin-bottom: 36px; }
.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}
.page-sub {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 680px;
  line-height: 1.7;
}

/* ═══════════════════════════ HOME ═══════════════════════════ */
.home-section {
  padding: 0 0 56px;
  max-width: 780px;
  margin: 0 auto;
  width: 100%;
}
.section-heading {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 32px;
  letter-spacing: -0.5px;
  text-align: center;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

/* Hero */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 0 60px;
  gap: 0;
  max-width: 780px;
  margin: 0 auto;
}

.hero-inner { width: 100%; }

.hero-badge {
  display: inline-block;
  background: #1a3a5c;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid #2d5a8c;
  margin-bottom: 20px;
}

.hero-title {
  font-size: 48px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -1.2px;
  line-height: 1.1;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #e6edf3 40%, #58a6ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.75;
  max-width: 560px;
  margin: 0 auto 32px;
}
.hero-sub strong { color: var(--text); }

.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--accent);
  color: #0d1117;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--text-muted); text-decoration: none; }

.hero-visual { display: none; }

/* Stats bar */
.home-stats {
  display: flex;
  align-items: center;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 32px;
  margin: 0 auto 56px;
  max-width: 900px;
  gap: 0;
}
.hstat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}
.hstat-val {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1;
}
.hstat-plus { font-size: 18px; color: var(--text-muted); }
.hstat-lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.hstat-sep { width: 1px; background: var(--border); height: 40px; flex-shrink: 0; }

/* Feature cards */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}

.feature-card {
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}
.feature-card:hover { border-color: var(--text-muted); }

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.feature-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.feature-card p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.65;
}
.feature-card p strong { color: var(--text); }

/* How it works steps */
.steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 720px;
  margin: 0 auto;
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #0d1117;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-content h3 { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.step-content p  { font-size: 12px; color: var(--text-muted); line-height: 1.65; }
.step-content p a { color: var(--accent); }
.step-content p strong { color: var(--text); }

.step-arrow {
  display: flex;
  justify-content: center;
  color: var(--text-dim);
  padding: 0 0 0 40px;
}

/* Apps grid */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 900px;
  margin: 0 auto;
}

.app-card {
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text-muted);
}
.app-card:hover { border-color: var(--accent); background: var(--surface); text-decoration: none; color: var(--text); }
.app-card div { display: flex; flex-direction: column; gap: 2px; }
.app-card strong { font-size: 12px; font-weight: 700; color: var(--text); }
.app-card span  { font-size: 10px; color: var(--text-muted); }

/* ═══════════════════════════ COMMUNITIES ═══════════════════════════ */
.community-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.community-card {
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color 0.2s;
}
.community-card:hover { border-color: var(--text-muted); }

.community-header { display: flex; align-items: center; gap: 14px; }

.community-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.community-name { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.community-region { font-size: 11px; color: var(--text-muted); }

.community-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
}

.community-config {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.config-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border-light);
}
.config-row:last-child { border-bottom: none; padding-bottom: 0; }
.config-key { color: var(--text-muted); }
.config-val {
  font-family: monospace;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.community-stats {
  display: flex;
  gap: 20px;
}
.cstat { display: flex; flex-direction: column; gap: 2px; }
.cstat strong { font-size: 16px; font-weight: 700; color: var(--text); }
.cstat span   { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }

.community-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.clink {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  transition: all 0.15s;
}
.clink:hover { background: var(--surface-hover); color: var(--text); border-color: var(--text-muted); text-decoration: none; }
.clink-primary { background: #1a3a5c; color: var(--accent); border-color: #2d5a8c; }
.clink-primary:hover { background: #1e4570; color: var(--accent-hover); }

.community-card-add {
  border-style: dashed;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 200px;
  color: var(--text-dim);
}
.community-card-add:hover { border-color: var(--text-muted); }
.community-icon-add {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px dashed var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.community-card-add h3 { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.community-card-add p  { font-size: 12px; color: var(--text-dim); max-width: 240px; line-height: 1.6; }

/* ═══════════════════════════ SETTINGS ═══════════════════════════ */
.settings-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.settings-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--surface);
  border: none;
  color: var(--text);
  padding: 14px 18px;
  cursor: pointer;
  transition: background 0.15s;
}
.settings-group-header:hover { background: var(--surface-hover); }

.sg-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
}
.sg-icon { font-size: 17px; }

.settings-group-body { background: var(--panel-bg); }
.settings-group-body.hidden { display: none; }

.settings-category {
  border-bottom: 1px solid var(--border);
}
.settings-category:last-child { border-bottom: none; }

.sc-header {
  padding: 10px 18px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
}

.param-table { display: flex; flex-direction: column; }

.param-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  gap: 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s;
}
.param-row:last-child { border-bottom: none; }
.param-row:hover { background: var(--surface); }

.param-info { flex: 1; min-width: 0; }
.param-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.param-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}
.param-desc code {
  font-family: monospace;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 11px;
}
.param-desc strong { color: var(--text); }

/* Value badges */
.param-rec, .param-warn, .param-neutral {
  font-family: monospace;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: default;
  transition: all 0.15s;
}

.param-rec {
  background: #1a3d2a;
  color: var(--st-online);
  border-color: #2ea04380;
}
.param-rec.copyable {
  cursor: pointer;
}
.param-rec.copyable:hover {
  background: #1e4d33;
  border-color: var(--st-online);
}

.param-warn {
  background: #3d1515;
  color: #f85149;
  border-color: #f8514940;
}

.param-neutral {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border);
}

/* Copyable elements (config values in communities) */
.copyable {
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}
.copyable:hover {
  filter: brightness(1.2);
  border-color: var(--accent) !important;
}
.copyable::after {
  content: '⧉';
  font-size: 10px;
  margin-left: 4px;
  opacity: 0.5;
}

/* Copy toast */
#copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a3d2a;
  border: 1px solid #2ea043;
  color: var(--st-online);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
#copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.settings-source {
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}
.settings-source a { color: var(--text-muted); }
.settings-source a:hover { color: var(--accent); }

/* ── Footer ─────────────────────────────────────────────────── */
#site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 900;
  padding: 0 16px;
}
#site-footer strong { color: var(--text); font-weight: 600; }
.footer-links {
  display: flex;
  align-items: center;
  gap: 12px;
}
.footer-links a {
  color: var(--text-dim);
  display: flex;
  align-items: center;
  transition: color 0.15s;
}
.footer-links a:hover {
  color: var(--accent);
  text-decoration: none;
}
