
html, body { height: 100%; margin: 0; background:#0b0f12; color:#e8eef3; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji"; }
#app { position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr; }
header { display:flex; align-items:center; gap:12px; padding:10px 12px; background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0)); border-bottom:1px solid rgba(255,255,255,0.08); }
header h1 { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; margin: 0; opacity: .9; }
#panel { position: absolute; top: 50px; left: 12px; width: 400px; max-width: calc(100% - 24px); background: rgba(20,24,28,0.9); border:1px solid rgba(255,255,255,.08); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); backdrop-filter: blur(8px); padding: 12px; z-index: 10; }
#panel h2 { font-size: 13px; margin: 0 0 8px; font-weight: 700; letter-spacing: .03em; opacity: .9; }
#panel .row { display:flex; gap:4px; align-items:center; margin-bottom:8px; }
#panel label { flex: 0 0 110px; font-size: 12px; opacity: .8; }
#panel input[type="number"], #panel input[type="text"] { flex: 1 1 auto; background:#0f1419; color:#e8eef3; border:1px solid rgba(255,255,255,.08); border-radius: 10px; padding:8px 10px; outline:none; }
#panel input[type="file"] { width: 100%; font-size: 12px; }
#panel button, #panel .btn { appearance:none; border:none; border-radius: 12px; background:#2a323a; color:#e8eef3; padding:10px 12px; font-weight:600; cursor:pointer; border:1px solid rgba(255,255,255,.1); }
#panel button:hover { background:#34404b; }
#panel .btn-row { display:flex; gap:8px; flex-wrap: wrap; }
#hint { position: absolute; bottom: 12px; left: 12px; padding: 10px 12px; font-size: 12px; background: rgba(20,24,28,0.9); border:1px solid rgba(255,255,255,.08); border-radius: 10px; pointer-events:none; }
#stats { position:absolute; top:12px; right:12px; z-index:10; font-size: 12px; opacity: .8; }
canvas { display:block; width:100%; height:100%; }
a.link { color:#9fd1ff; }
.range {width: 50px;}
.top-controls { position:absolute; left:75%; transform:translateX(-50%); display:flex; align-items:center; gap:10px; z-index: 9999 }
.icon-btn { display:grid; place-items:center; width:36px; height:36px; border-radius:999px; background:#1b2127; border:1px solid rgba(255,255,255,.12); cursor:pointer; }
.icon-btn:hover { background:#24303b; }
.icon-btn svg { width:18px; height:18px; fill:#e8eef3; }
.icon-btn.active-run {
    background: #1b4; /* green */
    border-color: #1b4;
}
.icon-btn.active-pause {
    background: #b22; /* red */
    border-color: #b22;
}



#modelerModal { position: fixed; inset: 0; display:none; align-items: center; justify-content: center; z-index: 9999; }
#modelerModal.show { display:flex; }
#modelerModal .backdrop { position:absolute; inset:0; background: rgba(0,0,0,0.5); }
#modelerModal .panel { position: relative; width: min(1100px, calc(100% - 40px)); max-height: 86vh; overflow: hidden; border-radius: 16px; background: #14181c; border:1px solid rgba(255,255,255,.08); box-shadow: 0 10px 40px rgba(0,0,0,.5); }


/* Modal */
#rocksModal { position: fixed; inset: 0; display:none; align-items: center; justify-content: center; z-index: 30; }
#rocksModal.show { display:flex; }
#rocksModal .backdrop { position:absolute; inset:0; background: rgba(0,0,0,0.45); }
#rocksModal .panel { position: relative; width: min(900px, calc(100% - 40px)); max-height: 80vh; overflow: hidden; border-radius: 16px; background: #14181c; border:1px solid rgba(255,255,255,.08); box-shadow: 0 10px 40px rgba(0,0,0,.5); }
#rocksModal header { display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid rgba(255,255,255,.08); }
#rocksModal header h3 { margin:0; font-size:14px; letter-spacing:.05em; text-transform:uppercase; opacity:.9; }
#rocksModal .content { overflow:auto; max-height: calc(80vh - 52px); }
table { width:100%; border-collapse: collapse; font-size:12px; }
thead th { position: sticky; top: 0; background:#0f1419; text-align:left; padding:10px; border-bottom:1px solid rgba(255,255,255,.1); }
tbody td { padding:10px; border-bottom:1px solid rgba(255,255,255,.06); white-space:nowrap; }
tbody tr:hover { background:#1a2026; cursor:pointer; }
.btn-inline { font-size:12px; padding:6px 8px; border-radius: 10px; }
.x { cursor:pointer; border:none; background:#24303b; color:#e8eef3; padding:8px 10px; border-radius:10px; }
.x:hover { background:#31404e; }
.rock-controls {display: flex; align-items: center; flex-direction: row; width: 300px; justify-content: space-evenly};

#lineOffsetModal {
    display: none;   /* hidden by default */
    z-index: 40;
}

#lineOffsetModal .panel {
    position: fixed;       /* position the panel itself */
    bottom: 25%;
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    border-radius: 12px;
    background: #14181c;
    border: 1px solid rgba(255,255,255,.10);
    box-shadow: 0 10px 30px rgba(0,0,0,.45);
    padding: 10px 12px;
}





#lineOffsetModal h4 { margin: 0 0 8px; font-size: 13px; letter-spacing:.04em; opacity:.9; }
#lineOffsetModal .row { display:flex; align-items:center; gap:8px; margin:8px 0; }
#lineOffsetModal label { width: 18px; text-align:center; opacity:.8; font-size:12px; }
#lineOffsetModal input[type=range] { flex: 1 1 auto; }
#lineOffsetModal output { width: 46px; text-align:right; font-variant-numeric: tabular-nums; opacity:.9; }
#lineOffsetModal .btns { display:flex; gap:8px; justify-content:flex-end; margin-top:8px; }
#lineOffsetModal button { border-radius:10px; background:#2a323a; color:#e8eef3; border:1px solid rgba(255,255,255,.12); padding:8px 10px; cursor:pointer; }
#lineOffsetModal button:hover { background:#34404b; }

/* Hover label */
#hoverLabel { position: fixed; transform: translate(-50%, -120%); padding: 4px 8px; font-size: 12px; background: rgba(20,24,28,0.95); border:1px solid rgba(255,255,255,.15); border-radius: 8px; pointer-events:none; display:none; white-space:nowrap; }


/* ——— header tool bar ——— */
.tools { display:flex; align-items:center; gap:8px; margin-left:12px; }
.tool-btn { appearance:none; border:1px solid rgba(255,255,255,.12); background:#1b2127; color:#e8eef3; padding:8px 10px; border-radius:10px; cursor:pointer; }
.tool-btn[aria-pressed="true"] { background:#2e3a45; }

/* ——— context panel shell ——— */
#panel { position:absolute; top:75px; left:12px; width:340px; max-width:calc(100% - 24px); background:rgba(20,24,28,.92); border:1px solid rgba(255,255,255,.08); border-radius:14px; box-shadow:0 10px 30px rgba(0,0,0,.35); backdrop-filter:blur(8px); padding:12px; z-index:10; display:none; }
#panel header { display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
#panel header h2 { font-size:13px; margin:0; letter-spacing:.03em; opacity:.9; }
#panel .close { border:none; border-radius:10px; padding:6px 8px; background:#24303b; color:#e8eef3; cursor:pointer; }

/* ——— startup (terrain) modal ——— */
#terrainModal { position:fixed; inset:0; display:flex; align-items:center; justify-content:center; background:rgba(0,0,0,.5); z-index:50; }
#terrainModal .panel { width:min(520px, calc(100% - 40px)); background:#14181c; border:1px solid rgba(255,255,255,.1); border-radius:14px; box-shadow:0 10px 40px rgba(0,0,0,.5); padding:16px; }
.dropzone { margin-top:10px; border:1px dashed rgba(255,255,255,.22); border-radius:12px; padding:18px; text-align:center; opacity:.9; }
.dropzone.drag { background:#182028; }
.small { font-size:12px; opacity:.8; }
.hidden { display:none !important; }

#surveyModal.hidden { display: none; }
#surveyModal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 9999; display: flex; align-items: center; justify-content: center; }
#surveyModal .panel.survey { width: min(1150px, 96vw); max-height: 92vh; overflow: auto; background: #0f1419; border: 1px solid rgba(255,255,255,0.06); border-radius: 12px; padding: 14px; box-shadow: 0 8px 40px rgba(0,0,0,.45); }
#surveyModal .mapwrap { height: 420px; border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; overflow: hidden; background: #0b1116; margin: 10px 0; }
#surveyMap { width: 100%; height: 100%; }
#surveyModal .controls-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
#surveyModal .controls-row.end { justify-content: flex-end; }


/* Alternate dropzone styling for launcher */
.dropzone.alt { border-style: dashed; cursor: pointer; background: #0b1116; }
.dropzone.alt:hover { background: #0e151c; }
.tiny { font-size: 11px; opacity: .75; }

.mat-row { display:flex; gap:6px; align-items:center; }
.mat-row input[type="number"] { width: 76px; }
.mat-row input[type="text"] { flex: 1 1 auto; }


/* WebKit scrollbars */
.lines-list::-webkit-scrollbar{ width:8px; }
.lines-list::-webkit-scrollbar-track{ background:#0f1419; border-radius:8px; }
.lines-list::-webkit-scrollbar-thumb{ background:#2a323a; border-radius:8px; }
.lines-list::-webkit-scrollbar-thumb:hover{ background:#34404b; }

/* Cards fill the list width */
.lines-list {
  display: grid;
  gap: .3rem;
  margin: .35rem 0 .5rem;
  max-height: 140px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* One-column card: meta on top, controls below, full width */
.line-chip {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: auto;
  row-gap: .3rem;
  width: 100%;                 /* ← fill list width */
  padding: .45rem .55rem;
  background: #14191f;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 10px;
  box-sizing: border-box;      /* ← include padding in width */
}

/* Meta row */
.line-chip .meta {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: 12px;
  min-width: 0;
}

/* Controls occupy the whole card width */
.line-controls {
  width: 100%;                        /* ← stretch to card width */
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));  /* 3 equal columns */
  grid-template-rows: auto 28px 28px; /* header, + row, − row */
  gap: 6px 8px;
  align-items: center;
  justify-items: center;
  box-sizing: border-box;
}

/* Tiny header row for X Y Z */
.axis-head {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: inherit;     /* same 3 equal columns */
  justify-items: center;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .7;
}

/* Buttons: perfectly centered text */
.mini {
  height: 28px;                       /* consistent height */
  width: 100%;                        /* fill each column */
  display: flex;                      /* precise centering */
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 8px;
  background: #222a31;
  color: #e8eef3;
  border: 1px solid rgba(255,255,255,.12);
  cursor: pointer;
  line-height: 1;                     /* avoid vertical mis-centering */
  box-sizing: border-box;
}
.mini:hover { background: #2b3540; }
.mini:focus { outline: 2px solid #3a556e; outline-offset: 1px; }

/* Full-width Remove button, centered label */
.remove-btn {
  grid-column: 1 / -1;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 .75rem;
  border-radius: 8px;
  background: #2a323a;
  color: #e8eef3;
  border: 1px solid rgba(255,255,255,.14);
  cursor: pointer;
  box-sizing: border-box;
}
.remove-btn:hover { background: #34404b; }

/* (optional) small swatch tidy */
.swatch { width: 9px; height: 9px; border-radius: 3px; border: 1px solid rgba(255,255,255,.25); }

#rockPreviewModal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999; /* above panels */
}
#rockPreviewModal.show {
  display: flex;
}
#rockPreviewModal .backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
#rockPreviewModal .modal-content {
  position: relative;
  background: #14181c;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  padding: 10px;
}

#multiRockModal { position: fixed; inset: 0; display:none; align-items:center; justify-content:center; z-index:9999; }
#multiRockModal.show { display:flex; }
#multiRockModal .backdrop { position:absolute; inset:0; background:rgba(0,0,0,0.5); }
#multiRockModal .modal-content { position:relative; background:#14181c; border:1px solid rgba(255,255,255,.08); border-radius:12px; padding:12px; }
#multiRockList label { display:block; font-size:13px; margin:4px 0; cursor:pointer; }

/* optional: nicer inline radios */
#panelSeeding .row input[type="radio"] { margin: 0; }


#potree_render_area {
  position: absolute;
  inset: 0;
  pointer-events: none;   /* clicks pass through */
  z-index: 8888;             /* above Three.js canvas */
  background: transparent !important;
}

/* Holder anchors both legends */
#colourbarholder {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: row;
  gap: 2vw; /* 👈 space between the two legends */
  z-index: 20;
}

/* One legend column (title + bar + labels) */
.legendColumn {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
  color: #e8eef3;
}

/* Title above each legend */
.legendTitle {
  margin-bottom: 6px;
  font-weight: 600;
  opacity: 0.85;
}

/* Box around canvas + labels */
.legendBox {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(20,24,28,0.8);
  padding: 8px;
  border-radius: 8px;
}

/* Labels arranged vertically */
#legendLabels,
#velocityLabels {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 120px;
}

#legendLabels div,
#velocityLabels div {
  color: #e8eef3;
  white-space: nowrap;
}

#bakeScrubRow input[type=range] {
  flex: 1;
}

.modal.right {
  position: fixed;
  top: 50%;
  right: 50px;
  transform: translateY(-50%);
  width: 300px;
  background: #1c1f26;
  color: #fff;
  border-left: 2px solid #444;
  box-shadow: -2px 0 10px rgba(0,0,0,0.5);
  z-index: 2000;
  transition: transform 0.3s ease;
}
.modal.right.hidden {
  transform: translateY(-50%) translateX(100%);
}
.modal.right .modal-content {
  padding: 16px;
}
.modal.right .close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 22px;
  cursor: pointer;
  background: none;
  border: none;
  color: #ccc;
}
.modal.right table {
  width: 100%;
  border-collapse: collapse;
}
.modal.right th {
  text-align: left;
  font-weight: 600;
  padding: 4px;
  opacity: 0.7;
}
.modal.right td {
  text-align: right;
  padding: 4px;
}

#btnIsolateRock.active {
  background: #1b4; /* green highlight */
  border-color: #1b4;
}

.scrub-container {
  position: absolute;
  bottom: 5vh;
  left: 50%;
  transform: translateX(-50%);
  width: 70vw;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(20,20,20,0.75);
  padding: 6px 10px;
  border-radius: 8px;
}

.scrub-track {
  position: relative;
  flex: 1;
}

#bakeSlider {
  width: 100%;
  appearance: none;
  background: transparent;
  z-index: 2;
  position: relative;
}

#bakeTicks {
  position: absolute;
  top: 14px; /* adjust to sit just under slider */
  left: 0;
  right: 0;
  height: 6px;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
}

#bakeTicks span {
  width: 1px;
  background: rgba(255,255,255,0.5);
  height: 6px;
}
#btnScrubPlay {
  font-size: 14px;
  width: 36px;
}

#polyOpts.hidden { display: none; }
