    :root{
      --bg:#0b1020;
      --panel:#101a33;
      --text:#e8eeff;
      --muted:#9fb0da;
      --border:rgba(255,255,255,.12);

      --ok:#34d399;
      --bad:#fb7185;
      --work:#fbbf24;

      --aqua:#7dd3fc;
      --violet:#a78bfa;
      --amber:#fbbf24;
    }

    *{box-sizing:border-box}
    html, body { height: 100%; }
    :root{
    --ui-font: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Noto Sans", Arial;
    }
body{
  margin:0;
  font-family: var(--ui-font);
  background: radial-gradient(900px 500px at 20% 15%, rgba(125,211,252,.15), transparent 60%),
              radial-gradient(900px 500px at 80% 40%, rgba(52,211,153,.10), transparent 60%),
              var(--bg);
  color:var(--text);

  min-height: 100vh;   /* fallback for older/mobile quirks */
  height: 100vh;       /* solid baseline */
  height: 100dvh;      /* modern correct value (overrides when supported) */

  display:flex;
  flex-direction:column;
  overflow:hidden;
}

    @font-face{
  font-family: "NavFontA";
  src: url("../fonts/micross.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face{
  font-family: "NavFontB";
  src: url("../fonts/kokila.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face{
  font-family: "NavFontC";
  src: url("../fonts/kalinga.ttf") format("truetype");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

    header{
      display:flex; gap:12px; align-items:center;
      padding:12px 14px;
      border-bottom:1px solid var(--border);
      background: rgba(16,26,51,.85);
      backdrop-filter: blur(10px);
    }
    header h1{margin:0;font-size:16px;letter-spacing:.3px}
    header .tag{
      font-size:12px;color:var(--muted);
      border:1px solid var(--border);
      padding:2px 8px;border-radius:999px;
      white-space:nowrap;
    }

.layout{
  display:grid;
  grid-template-columns: 420px 1fr;

  /* NEW: fill remaining space below header (no magic 50px) */
  flex: 1 1 auto;
  min-height: 0;

  gap:12px;
  padding:12px;
  height: 100%;
}

    .panel{
      background: rgba(16,26,51,.72);
      border:1px solid var(--border);
      border-radius:16px;
      overflow:hidden;
      box-shadow: 0 10px 35px rgba(0,0,0,.35);
      display:flex;
      flex-direction:column;
      min-height:0;
    }

    /* Tabs header */
    .tabsBar{
      display:flex;
      gap:8px;
      padding:10px;
      border-bottom:1px solid var(--border);
      background: rgba(16,26,51,.55);
    }
    .tabBtn{
      border:1px solid var(--border);
      background: rgba(15,23,48,.55);
      color: var(--muted);
      border-radius:999px;
      padding:8px 10px;
      font-weight:900;
      font-size:12px;
      cursor:pointer;
      user-select:none;
      display:flex;
      align-items:center;
      gap:8px;
      line-height:1;
    }
    .tabDot{
      width:8px;height:8px;border-radius:999px;
      background: rgba(232,238,255,.25);
      border:1px solid rgba(255,255,255,.15);
    }
    .tabBtn[data-active="1"]{
      color: var(--text);
      border-color: rgba(125,211,252,.35);
      background: linear-gradient(90deg, rgba(125,211,252,.16), rgba(52,211,153,.10));
    }
    .tabBtn[data-active="1"] .tabDot{
      background: rgba(125,211,252,.95);
      border-color: rgba(125,211,252,.35);
    }
    .tabsHints{
      padding:8px 12px;
      border-bottom:1px solid var(--border);
      font-size:12px;
      color: var(--muted);
      display:flex;
      gap:10px;
      flex-wrap:wrap;
    }
    .hintPill{
      border:1px solid var(--border);
      border-radius:999px;
      padding:3px 8px;
      white-space:nowrap;
      max-width:100%;
      overflow:hidden;
      text-overflow:ellipsis;
    }
    .hintPill strong{color:var(--text)}

    .tabPages{
      flex:1;
      min-height:0;
      overflow:hidden;
    }

    .tabPage{
      height:100%;
      overflow:auto;
      padding:12px;
      display:none;
    }
    .tabPage[data-active="1"]{ display:block; }

    /* Common form styles */
    h2{
      margin:0 0 8px 0;
      font-size:13px;
      color:var(--muted);
      letter-spacing:.3px;
      text-transform:uppercase;
    }
    .divider{height:1px;background:var(--border);margin:12px 0;}
    .row{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:8px;}
    .row3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin-bottom:8px;}
    .row1{display:grid;grid-template-columns:1fr;gap:8px;margin-bottom:8px;}
    label{font-size:12px;color:var(--muted);display:block;margin-bottom:4px;}
    input,select,button,textarea{
      width:100%;
      padding:9px 10px;
      border-radius:12px;
      border:1px solid var(--border);
      background: rgba(15,23,48,.9);
      color:var(--text);
      outline:none;
    }
    textarea{min-height:60px; resize:vertical}
    button{cursor:pointer;font-weight:900}
    button.primary{
      background: linear-gradient(90deg, rgba(125,211,252,.25), rgba(52,211,153,.18));
      border-color: rgba(125,211,252,.35);
    }
    button.secondary{
      background: linear-gradient(90deg, rgba(167,139,250,.18), rgba(125,211,252,.12));
      border-color: rgba(167,139,250,.35);
    }
    button.ghost{background:transparent;}
    .btnrow{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:8px;}
    .small{font-size:12px;color:var(--muted);line-height:1.35;margin:8px 2px 0 2px;}

    /* List styles */
    .list{
      margin-top:10px;
      border-top:1px solid var(--border);
      max-height: 360px;
      overflow:auto;
      border-radius:14px;
    }
    .item{
      padding:10px 10px;border-bottom:1px solid var(--border);
      cursor:pointer;
      background: rgba(15,23,48,.25);
    }
    .item:hover{background: rgba(125,211,252,.07)}
    .item.static{cursor:default}
    .item .title{font-weight:900;font-size:13px;}
    .item .sub{font-size:12px;color:var(--muted);margin-top:2px;display:flex;gap:8px;flex-wrap:wrap;}
    .pill{font-size:11px;padding:2px 7px;border-radius:999px;border:1px solid var(--border);color:var(--muted);}
    .pill.star{border-color: rgba(125,211,252,.35); color: rgba(125,211,252,.95)}
    .pill.unknown{border-color: rgba(251,191,36,.4); color: rgba(251,191,36,.95)}
    .pill.beacon{border-color: rgba(52,211,153,.35); color: rgba(52,211,153,.95)}
    .pill.waypoint{border-color: rgba(167,139,250,.35); color: rgba(167,139,250,.95)}
    .pill.course{border-color: rgba(251,191,36,.45); color: rgba(251,191,36,.95)}

    /* Canvas */
    .canvasWrap{position:relative; min-height:0;}
    canvas#c{
      width:100%;height:100%;display:block;
      background: radial-gradient(800px 500px at 25% 20%, rgba(125,211,252,.08), transparent 60%),
                  radial-gradient(900px 700px at 80% 60%, rgba(167,139,250,.07), transparent 65%),
                  rgba(10,15,33,.85);
      border:1px solid var(--border);
      border-radius:16px;
      box-shadow: 0 10px 35px rgba(0,0,0,.35);
      touch-action: none;          /* allow JS pan/pinch */
      overscroll-behavior: none;   /* prevent scroll chaining */
    }
    .hud{
      position:absolute;top:12px;left:12px;right:12px;
      display:flex;justify-content:space-between;gap:12px;pointer-events:none;
    }
    .hud .box{
      background: rgba(16,26,51,.65);
      border:1px solid var(--border);
      border-radius:14px;
      padding:8px 10px;
      font-size:12px;
      color:var(--muted);
      backdrop-filter: blur(8px);
      max-width:48%;
      white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
    }
    .hud .box strong{color:var(--text)}
    .toast{
      position:absolute;bottom:12px;left:12px;
      background: rgba(16,26,51,.75);
      border:1px solid var(--border);
      border-radius:14px;
      padding:8px 10px;
      font-size:12px;
      color:var(--muted);
      backdrop-filter: blur(8px);
      display:none;
    }

    .searchRow:hover { background: rgba(255,255,255,0.08); }
    .searchRow:active { background: rgba(255,255,255,0.12); }

    /* Mini system canvas */
    canvas#sys{
      touch-action: none;
  overscroll-behavior: none;
      width:100%;
      height:260px;
      border:1px solid var(--border);
      border-radius:14px;
      background: radial-gradient(500px 260px at 50% 40%, rgba(125,211,252,.08), transparent 60%),
                  rgba(10,15,33,.65);
      display:block;
    }

/* Mobile layout: panel capped + map always visible */
@media (max-width: 980px){

  .layout{
    grid-template-columns: 1fr;

    /* Use vh fallback first, then dvh when supported */
    grid-template-rows: minmax(240px, 45vh) minmax(220px, 1fr);
    grid-template-rows: minmax(240px, 45dvh) minmax(220px, 1fr);

    gap:10px;
    padding:10px;

    height: 100%;
    min-height: 0;
  }

  /* Prevent panel/tab content from forcing the grid taller */
  .panel{ min-height: 0; }
  .tabPages{ min-height: 0; }

  /* Scroll inside the active tab instead of growing the panel */
  .tabPage{
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Remove fixed list cap on phones */
  .list{ max-height: none; }

  /* Make sure the canvas row can actually fill its track */
  .canvasWrap{ min-height: 0; }
  canvas#c{ height: 100%; }

  .hud .box{ max-width: 100%; }
}

  /* --- System / planet list --- */
  #planetList { margin-top: 10px; }
  .planet-item{
    display:flex; align-items:flex-start; justify-content:space-between;
    gap:10px; padding:10px 10px; border-radius:12px;
    border:1px solid rgba(232,238,255,0.12);
    background: rgba(10,14,26,0.35);
    cursor:pointer;
  }
  .planet-item:hover{ background: rgba(232,238,255,0.06); }
  .planet-item.active{
    border-color: rgba(251,191,36,0.55);
    box-shadow: 0 0 0 2px rgba(251,191,36,0.12) inset;
  }
  .planet-item .meta{ min-width:0; }
  .planet-item .title{ font-weight:700; line-height:1.1; }
  .planet-item .sub{ opacity:0.86; font-size:12px; margin-top:4px; }
  .planet-item .badges{ display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; }
  .badge{
    font-size:11px; padding:3px 8px; border-radius:999px;
    border:1px solid rgba(232,238,255,0.16);
    background: rgba(232,238,255,0.06);
    white-space:nowrap;
  }
  .badge.hot{ border-color: rgba(251,191,36,0.35); }
  .badge.hz{ border-color: rgba(34,197,94,0.35); } /* hab zone hint */
  .telemetry{
    margin-top:10px; padding:10px; border-radius:12px;
    border:1px solid rgba(232,238,255,0.12);
    background: rgba(10,14,26,0.30);
  }
  .telemetry .row{ display:flex; justify-content:space-between; gap:10px; font-size:12px; padding:2px 0; }
  .telemetry .k{ opacity:0.8; }
  .telemetry .v{ font-weight:600; }
