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

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #0a0a12;
  color: #ccd;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
}

/* ── Top bar ─────────────────────────────────────────────── */
#topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 48px;
  background: #111120;
  border-bottom: 1px solid #2a2a44;
}

.brand {
  font-size: 15px;
  font-weight: 600;
  color: #aabbee;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.file-btn,
.back-btn {
  padding: 5px 14px;
  background: #1e2a4a;
  border: 1px solid #3a4a7a;
  border-radius: 4px;
  color: #99aadd;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.file-btn:hover,
.back-btn:hover {
  background: #253460;
  border-color: #5566aa;
  color: #bbccff;
}

.file-hint {
  font-size: 12px;
  color: #556;
  white-space: nowrap;
}

.status {
  flex: 1 1 auto;
  text-align: right;
  min-width: 0;
  font-size: 12px;
  color: #778;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-btn {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  background: none;
  border: 1px solid #2a2a44;
  border-radius: 4px;
  color: #667;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
}

.settings-btn:hover {
  background: #1a1a2e;
  border-color: #445;
  color: #99aacc;
}

/* ── Settings panel ──────────────────────────────────────────── */
#settingsPanel {
  position: fixed;
  top: 48px;
  right: 0;
  width: 300px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: #111120;
  border-left: 1px solid #2a2a44;
  border-bottom: 1px solid #2a2a44;
  padding: 16px;
  z-index: 1200;
  box-shadow: -4px 4px 16px rgba(0,0,0,0.6);
}

.sp-header {
  font-size: 13px;
  font-weight: 600;
  color: #aabbee;
  margin-bottom: 4px;
}

.sp-row {
  margin-bottom: 12px;
}

.sp-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #8899bb;
  margin-bottom: 5px;
}

.sp-val {
  color: #556677;
  font-variant-numeric: tabular-nums;
}

.sp-slider {
  width: 100%;
  accent-color: #4466aa;
  cursor: pointer;
}

.sp-label-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.sp-vis-switch {
  width: 28px;
  height: 15px;
}

.sp-vis-switch .sp-switch-track {
  border-radius: 8px;
}

.sp-vis-switch .sp-switch-track::after {
  width: 9px;
  height: 9px;
  top: 2px;
  left: 2px;
}

.sp-vis-switch input:checked + .sp-switch-track::after {
  transform: translateX(13px);
}

.sp-row-hidden .sp-slider {
  opacity: 0.25;
  pointer-events: none;
}

.sp-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #445566;
  margin: 14px 0 10px;
  border-top: 1px solid #1e1e36;
  padding-top: 10px;
}

.sp-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sp-label-inline {
  font-size: 12px;
  color: #8899bb;
}

.sp-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}

.sp-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.sp-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: #1e1e36;
  border: 1px solid #2a2a44;
  cursor: pointer;
  transition: background 0.2s;
}

.sp-switch-track::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #445566;
  top: 2px;
  left: 2px;
  transition: transform 0.2s, background 0.2s;
}

.sp-switch input:checked + .sp-switch-track {
  background: #1a2a4a;
  border-color: #4466aa;
}

.sp-switch input:checked + .sp-switch-track::after {
  transform: translateX(16px);
  background: #4488dd;
}

.sp-demo-row {
  border-top: 1px solid #1e1e36;
  padding-top: 10px;
  padding-bottom: 6px;
  margin-top: 4px;
  text-align: center;
}

.sp-demo-btn {
  background: none;
  border: 1px solid #2a2a44;
  border-radius: 3px;
  color: #445566;
  font-size: 11px;
  cursor: pointer;
  padding: 4px 10px;
  transition: color 0.15s, border-color 0.15s;
}

.sp-demo-btn:hover {
  color: #7788aa;
  border-color: #3a3a66;
}

.sp-donation-row {
  border-top: 1px solid #1e1e36;
  padding-top: 10px;
  margin-top: 4px;
  text-align: center;
}

.sp-donation-row .sp-section-title {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
  margin-bottom: 10px;
}

.sp-donation-label {
  font-size: 11px;
  color: #556677;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}

.sp-qr-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}

.sp-qr-wrap canvas {
  border-radius: 4px;
}

.sp-donation-addr {
  font-size: 10px;
  color: #445566;
  font-family: monospace;
  letter-spacing: 0.04em;
  user-select: all;
}

.sp-donation-coin-sep {
  margin-top: 14px;
}

.sp-donation-memo {
  font-size: 10px;
  color: #445566;
  letter-spacing: 0.03em;
  margin-top: 3px;
  margin-bottom: 24px;
  user-select: all;
}

/* ── Attribution + icon key container ────────────────────── */
#bottomLeft {
  position: fixed;
  bottom: 8px;
  left: 10px;
  z-index: 1200;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

#iconKey {
  position: relative;
  flex-shrink: 0;
}

#attribution {
  font-size: 10px;
  line-height: 1.5;
  color: #2a3a4a;
  letter-spacing: 0.03em;
  user-select: none;
}

#attribution a {
  color: inherit;
  text-decoration: none;
}

#attribution a:hover {
  color: #445566;
  text-decoration: underline;
}

/* ── Icon key ─────────────────────────────────────────────── */

.ik-toggle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #111120;
  border: 1px solid #2a2a44;
  color: #7788aa;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  transition: background 0.15s, color 0.15s;
}

.ik-toggle:hover {
  background: #1a1a30;
  color: #aabbdd;
}

#iconKeyPanel {
  position: absolute;
  bottom: 36px;
  left: 0;
  width: 230px;
  max-height: 70vh;
  overflow-y: auto;
  background: #111120;
  border: 1px solid #2a2a44;
  border-radius: 6px;
  padding: 10px 12px 12px;
  box-shadow: 2px -4px 20px rgba(0,0,0,0.7);
}

.ik-header {
  font-size: 12px;
  font-weight: 600;
  color: #aabbee;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #1e1e38;
}

.ik-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #445566;
  margin: 8px 0 4px;
}

.ik-rows {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ik-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #7788aa;
}

.ik-glyph {
  width: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.ik-label {
  flex: 1;
}
.ik-sublabel {
  display: block;
  font-size: 10px;
  color: #667788;
  font-style: italic;
}

/* ── Layer bar ────────────────────────────────────────────── */
#layerbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  height: 34px;
  background: #0d0d1c;
  border-bottom: 1px solid #1e1e38;
  min-height: 0;
}

#lbSearch {
  padding: 3px 8px;
  background: #0a0a18;
  border: 1px solid #2a2a44;
  border-radius: 3px;
  color: #aabbdd;
  font-size: 12px;
  font-family: inherit;
  width: 230px;
  outline: none;
}

#lbSearch::placeholder { color: #334455; }
#lbSearch:focus { border-color: #445588; }

.lb-sep {
  width: 1px;
  height: 18px;
  background: #2a2a44;
  flex-shrink: 0;
  margin: 0 3px;
}

.lb-filter,
.lb-layer {
  padding: 3px 8px;
  background: none;
  border: 1px solid #1e1e38;
  border-radius: 3px;
  color: #445566;
  font-size: 11px;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.04em;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lb-filter svg,
.lb-filter img,
.lb-layer svg,
.lb-layer img {
  flex-shrink: 0;
}

.lb-filter:hover,
.lb-layer:hover {
  color: #99aacc;
  background: #14142a;
  border-color: #334466;
}

.lb-filter.active {
  background: #182d50;
  border-color: #4466aa;
  color: #88bbff;
  box-shadow: inset 0 0 6px rgba(80, 130, 220, 0.15);
}

.lb-layer.active {
  background: #141e30;
  border-color: #2a3d60;
  color: #7799bb;
}

.lb-layer:not(.active) {
  color: #334455;
  border-color: #161626;
  background: none;
}

/* ── Hazard range slider ──────────────────────────────────── */
.lb-hz-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.lb-hz-label {
  font-size: 11px;
  line-height: 1;
  color: #5577aa;
  white-space: nowrap;
  letter-spacing: 0.04em;
  user-select: none;
}

.lb-hz-slider {
  position: relative;
  width: 110px;
  height: 18px;
  flex-shrink: 0;
}

.lb-hz-track {
  position: absolute;
  top: 50%;
  left: 7px;
  right: 7px;
  height: 4px;
  background: #12122a;
  border-radius: 2px;
  transform: translateY(-50%);
  pointer-events: none;
}

.lb-hz-fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: #1a1a38;
  border-radius: 2px;
}

.lb-hz-fill.active {
  background: #2a4d8e;
  box-shadow: 0 0 5px rgba(60, 110, 200, 0.45);
}

.lb-hz-slider input[type="range"] {
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  /* Height matches the transparent track — webkit anchors the thumb to the track top,
     so keeping input=track height lets margin-top on the thumb do precise centering. */
  height: 4px;
  transform: translateY(-50%);
  margin: 0;
  padding: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  pointer-events: none;
  outline: none;
  z-index: 3;
}

.lb-hz-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #4d7acc;
  border: 1.5px solid #2a55aa;
  cursor: pointer;
  pointer-events: all;
  transition: background 0.12s, transform 0.1s;
  box-shadow: 0 0 5px rgba(77, 122, 204, 0.55);
  /* Webkit places thumb top at track top; offset by (track_h - thumb_h)/2 to center it.
     (4 - 13) / 2 = -4.5px */
  margin-top: -4.5px;
}

.lb-hz-slider input[type="range"]::-webkit-slider-thumb:hover {
  background: #6699ee;
  transform: scale(1.2);
}

.lb-hz-slider input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #4d7acc;
  border: 1.5px solid #2a55aa;
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 0 5px rgba(77, 122, 204, 0.55);
}

.lb-hz-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
}

.lb-hz-slider input[type="range"]::-moz-range-track {
  height: 4px;
  background: transparent;
}

.lb-hz-val {
  font-size: 10px;
  line-height: 1;
  color: #445566;
  white-space: nowrap;
  min-width: 44px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  user-select: none;
}

.lb-hz-val.hz-active {
  color: #99bbee;
}

/* ── Main content area ────────────────────────────────────── */
main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

#map {
  flex: 1 1 auto;
  min-width: 0;
  background: #040409;
}

#sidebar {
  flex: 0 0 340px;
  overflow: hidden;
  background: #0c0c1a;
  border-left: 1px solid #1e1e38;
}

#sb-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 16px;
}

.sidebar-hint {
  font-size: 13px;
  color: #556;
  line-height: 1.6;
}

.sidebar-hint code {
  background: #1a1a2e;
  border: 1px solid #2a2a44;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: monospace;
  font-size: 12px;
  color: #99aacc;
}

/* ── Drop overlay ─────────────────────────────────────────── */
#dropOverlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 50, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  border: 3px dashed #4466aa;
  pointer-events: none;
}

/* display:flex above overrides the browser's built-in [hidden] rule — must re-suppress explicitly */
#dropOverlay[hidden] { display: none; }
#layerbar[hidden]    { display: none; }

.drop-label {
  font-size: 22px;
  font-weight: 600;
  color: #aabbee;
  letter-spacing: 0.04em;
  pointer-events: none;
}

/* ── Leaflet overrides ────────────────────────────────────── */
.leaflet-container {
  background: #07070f;
}

.leaflet-control-zoom a {
  background: #111120;
  color: #aabbee;
  border-color: #2a2a44;
}

.leaflet-control-zoom a:hover {
  background: #1e2a4a;
}

.leaflet-div-icon {
  background: none !important;
  border: none !important;
}

/* ── Star markers ─────────────────────────────────────────────── */
.star-marker {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.star-ring {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid transparent;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.5);
  transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.star-marker:hover .star-ring {
  border-color: rgba(140, 170, 255, 0.55);
  transform: scale(1.2);
  opacity: 1;
}

.star-group {
  display: flex;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

.star {
  display: inline-block;
  border-radius: 50%;
  flex-shrink: 0;
  pointer-events: none;
}

.star-marker.dim {
  opacity: 0.13;
}

/* ── In-system dot markers ────────────────────────────────────── */
.sys-dot-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  cursor: pointer;
}

.sys-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  border: 1px solid transparent;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.5);
  transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.sys-dot-wrap:hover .sys-ring,
.sys-dot-wrap.highlighted .sys-ring {
  border-color: rgba(140, 170, 255, 0.55);
  transform: translate(-50%, -50%) scale(1.2);
  opacity: 1;
}

.sys-dot {
  position: relative;
  border-radius: 50%;
  pointer-events: none;
}

/* ── Name labels ──────────────────────────────────────────────── */
.label-anchor {
  position: absolute;
  top: 0;
  left: 0;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, 26px);
}

.starlabel {
  font-size: 12px;
  color: #525270;
  font-family: 'Segoe UI', system-ui, sans-serif;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0.55;
  text-shadow:
    -1px -1px 0 #000,
     0   -1px 0 #000,
     1px -1px 0 #000,
     1px  0   0 #000,
     1px  1px 0 #000,
     0    1px 0 #000,
    -1px  1px 0 #000,
    -1px  0   0 #000,
     0    0   8px rgba(0,0,0,0.7);
}

.starlabel.inhabited {
  color: #8899cc;
  opacity: 0.75;
}

/* ── Constellation labels ─────────────────────────────────────── */
.constellation-label-wrap {
  transform: translate(-50%, -50%);
  pointer-events: none;
  white-space: nowrap;
}

.constellation-label {
  font-size: 9px;
  color: #2a3d60;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-family: 'Segoe UI', system-ui, sans-serif;
  text-shadow: 0 0 6px #000, 0 0 12px #000;
  pointer-events: none;
}

/* ── POI badges ───────────────────────────────────────────────── */
.poi-anchor {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  transform: translate(-50%, -38px);
}

.poi-row {
  display: flex;
  gap: 2px;
  white-space: nowrap;
}

.poi-badge {
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
  display: flex;
  align-items: center;
}

.poi-badge svg,
.poi-badge img {
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.9));
  display: block;
}

.poi-cryo      { color: #77eeff; }
.poi-tap       { color: #ffee44; }
.poi-gate      { color: #88ccff; }
.poi-rem-main  { color: #ff7777; }
.poi-rem       { color: #ff9955; }
.poi-rem-dorm  { color: #776655; }
.poi-derelict  { color: #9988bb; }
.poi-ruins-main{ color: #cc9944; }
.poi-ruins     { color: #997733; }
.poi-special   { color: #dd99ff; }


/* ── Sidebar content ──────────────────────────────────────────── */
.sb-title {
  font-size: 15px;
  font-weight: 600;
  color: #aabbee;
  margin-bottom: 8px;
  line-height: 1.3;
}

.sb-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.chip {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  background: #1a1a2e;
  border: 1px solid #2a2a44;
  color: #8899bb;
  white-space: nowrap;
}

.chip.good {
  background: #0a1a10;
  border-color: #1a4428;
  color: #55cc77;
}

.chip.bad {
  background: #1a0a0a;
  border-color: #441a1a;
  color: #cc5544;
}

.chip.type-chip {
  background: #12121f;
  border-color: #33334a;
  color: #8899bb;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
}

.chip.chip-internal {
  background: transparent;
  border-color: #222238;
  color: #445566;
  font-size: 10px;
  font-style: italic;
}

.chip.star-chip {
  background: #12121f;
  border-color: #33334a;
  color: #99aacc;
}

.sb-coords {
  font-size: 11px;
  color: #445566;
  margin-bottom: 10px;
  font-family: monospace;
  letter-spacing: 0.03em;
}

.sb-section {
  margin-top: 14px;
}

.sb-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #445566;
  margin-bottom: 6px;
}

.sb-meta {
  font-size: 12px;
  color: #667788;
  margin: 4px 0;
}

.sb-factions {
  color: #7788aa;
}

/* ── Notable POI chips ────────────────────────────────────────── */
.sb-notable {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.notable-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 10px;
  background: #0d0d1e;
  border: 1px solid #2a2a44;
  white-space: nowrap;
}

.notable-chip svg,
.notable-chip img {
  flex-shrink: 0;
}

.notable-cryosleeper     { color: #77eeff; border-color: #1f5060; }
.notable-coronal_tap     { color: #ffee44; border-color: #554400; }
.notable-gate            { color: #88ccff; border-color: #223355; }
.notable-remnant_main    { color: #ff7777; border-color: #551111; }
.notable-remnant         { color: #ff9955; border-color: #552211; }
.notable-remnant_dormant { color: #887766; border-color: #443322; }
.notable-mothership,
.notable-survey_ship,
.notable-probes          { color: #9988bb; border-color: #332255; }
.notable-ruins_main      { color: #cc9944; border-color: #553311; }
.notable-ruins           { color: #997733; border-color: #442200; }
.notable-special         { color: #dd99ff; border-color: #442255; }
.notable-core            { color: #99bbdd; border-color: #223355; }
.notable-hidden          { color: #778899; border-color: #334455; }
.notable-unsafe          { color: #ee7744; border-color: #552200; }
.notable-cut_off         { color: #887766; border-color: #443322; }

/* ── Generic content rows ─────────────────────────────────────── */
.sb-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 0;
  font-size: 13px;
  color: #8899bb;
  line-height: 1.4;
}

.sb-sub {
  font-size: 11px;
  color: #556677;
  font-weight: 400;
}

/* ── Glyph icons ──────────────────────────────────────────────── */
.sb-glyph {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sb-glyph svg,
.sb-glyph img {
  flex-shrink: 0;
}

.sb-planet-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kind-star            { color: #ffdd55; }
.kind-planet          { color: #4488cc; }
.kind-station         { color: #8877cc; }
.kind-gate            { color: #88ccff; }
.kind-cryosleeper     { color: #77eeff; }
.kind-coronal_tap     { color: #ffee44; }
.kind-jump_point      { color: #44ddaa; }
.kind-stable_location { color: #888899; }
.kind-debris_field    { color: #887755; }
.kind-derelict        { color: #9988bb; }
.kind-asteroids       { color: #665544; }
.kind-habitat         { color: #66aa88; }
.kind-supply_cache    { color: #aa8855; }
.kind-probe           { color: #99bbcc; }
.kind-survey_ship     { color: #aabb99; }
.kind-nav_buoy,
.kind-sensor_array,
.kind-comm_relay      { color: #778899; }
.kind-other           { color: #445566; }

/* ── Entity list ──────────────────────────────────────────────── */
.sb-entity-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sb-entity-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 14px;
  color: #8899bb;
}

.sb-entity-row:hover {
  background: #14142a;
  color: #aabbdd;
}

.sb-group-count {
  font-size: 12px;
  color: #556677;
  margin-left: auto;
  padding-left: 4px;
  white-space: nowrap;
  align-self: center;
}

.sb-entity-name {
  flex: 1;
  line-height: 1.4;
}

.sb-entity-sub {
  display: block;
  font-size: 12px;
  color: #445566;
  margin-top: 1px;
}

/* ── Planet / entity detail view ──────────────────────────────── */
.sb-back-row {
  margin-bottom: 10px;
}

.sb-back-btn {
  background: none;
  border: none;
  color: #667799;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  transition: color 0.1s;
}

.sb-back-btn:hover {
  color: #99aacc;
}

.sb-internal-id {
  font-size: 11px;
  color: #445566;
  font-family: monospace;
  margin-bottom: 6px;
  margin-top: -4px;
}

/* ── Planet strip summary line ───────────────────────────────── */
.sb-planet-strip {
  color: #8899bb;
  margin-top: 6px;
}

/* ── Hazard rating — inline badge in entity list ─────────────── */
.sb-hazard {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255,255,255,0.04);
  align-self: center;
  white-space: nowrap;
}

.hz-excellent { color: #55ee88; }
.hz-good      { color: #99cc55; }
.hz-high      { color: #ee9933; }
.hz-extreme   { color: #ee4433; }
.hz-unknown   { color: #445566; }

.sb-hazard-label {
  font-size: 9px;
  opacity: 0.65;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sb-min-hz {
  font-variant-numeric: tabular-nums;
}

/* ── Hazard chip (planet detail view) ────────────────────────── */
.chip.hz-chip.hz-excellent { background: #091a0d; border-color: #1a4428; color: #55ee88; }
.chip.hz-chip.hz-good      { background: #0d1a06; border-color: #2a3a10; color: #99cc55; }
.chip.hz-chip.hz-high      { background: #1a0e04; border-color: #4a2a08; color: #ee9933; }
.chip.hz-chip.hz-extreme   { background: #1a0606; border-color: #4a1010; color: #ee4433; }
.chip.hz-chip.hz-unknown   { background: #0d0d1a; border-color: #2a2a3a; color: #556677; }

/* ── Body-type count table ────────────────────────────────────── */
.sb-counts {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1px 8px;
}

.sb-count-row {
  display: contents;
}

.sb-count-label {
  font-size: 12px;
  color: #778899;
  padding: 2px 0;
}

.sb-count-n {
  font-size: 12px;
  color: #556677;
  text-align: right;
  padding: 2px 0;
  font-variant-numeric: tabular-nums;
}

/* ── Hidden / unplaced entity section ────────────────────────── */
.sb-hidden-section {
  margin-top: 4px;
}

.sb-hidden-summary {
  cursor: pointer;
  font-size: 12px;
  color: #445566;
  padding: 4px 6px;
  border-radius: 4px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  transition: color 0.1s;
}

.sb-hidden-summary::-webkit-details-marker { display: none; }

.sb-hidden-summary::before {
  content: '▶';
  font-size: 9px;
  transition: transform 0.15s;
  flex-shrink: 0;
}

details[open] > .sb-hidden-summary::before {
  transform: rotate(90deg);
}

.sb-hidden-summary:hover {
  color: #667788;
}

.sb-hidden-count {
  background: #141a24;
  border-radius: 10px;
  padding: 0 6px;
  font-size: 11px;
}

.sb-hidden-list .sb-entity-row {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* ── Mobile / responsive ─────────────────────────────────────── */

/* Sidebar close button — hidden on desktop, shown on mobile */
.sidebar-close-btn {
  display: none;
}

/* Sidebar backdrop — hidden on desktop, shown on mobile */
#sidebarBackdrop {
  display: none;
}

@media (max-width: 767px) {

  /* ── Top bar ─────────────────────────────────────────── */
  .file-hint { display: none; }

  /* ── Layer bar: horizontal scroll ───────────────────── */
  #layerbar {
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge */
    gap: 3px;
    padding: 0 8px;
  }
  #layerbar::-webkit-scrollbar { display: none; }
  #lbSearch { width: 120px; }

  /* ── Settings panel: full width ─────────────────────── */
  #settingsPanel {
    width: 100%;
    left: 0;
  }

  /* ── Sidebar: fixed overlay, slides in from right ───── */
  #sidebar {
    position: fixed;
    top: 48px;
    right: 0;
    bottom: 0;
    z-index: 1050;
    width: min(340px, 93vw);
    flex: none;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.75);
  }

  #sidebar.mob-open {
    transform: translateX(0);
  }

  /* Sidebar content: add right padding so text clears the close button */
  #sb-scroll {
    padding-right: 44px;
  }

  /* Sidebar close button */
  .sidebar-close-btn {
    display: flex;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 5;
    width: 26px;
    height: 26px;
    background: #181830;
    border: 1px solid #2a2a44;
    border-radius: 50%;
    color: #7788aa;
    font-size: 13px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
  }

  .sidebar-close-btn:hover {
    background: #222244;
    color: #aabbdd;
  }

  /* Sidebar backdrop */
  #sidebarBackdrop {
    display: block;
    position: fixed;
    inset: 0;
    top: 48px;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }

  #sidebarBackdrop.mob-open {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── Icon key: clamp panel to screen width ───────────── */
  #iconKeyPanel {
    max-width: calc(100vw - 24px);
  }

  /* ── Attribution + icon key: hide on mobile ─────────── */
  #attribution { display: none; }
  #iconKey     { display: none; }
}
