:root{
  --bg:#0b0f14;
  --panel:#0f1620;
  --panel2:#0c121a;
  --text:#e6edf3;
  --muted:#93a4b8;
  --border:#1c2a3a;
  --accent:#7c5cff;
  --accent2:#20c997;
  --danger:#ff5c7a;
  --shadow: 0 20px 60px rgba(0,0,0,0.42);
}
*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji"; background:var(--bg); color:var(--text); }
#app{ height:100%; display:flex; flex-direction:column; }

.topbar{ display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:10px; padding:12px 14px; border-bottom:1px solid var(--border); background:linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)); }
.brand{ font-weight:700; letter-spacing:0.2px; }
.top-actions{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

.file-btn input{ display:none; }
.file-btn span{ display:inline-flex; align-items:center; padding:9px 12px; border:1px solid var(--border); background:var(--panel); border-radius:10px; cursor:pointer; user-select:none; }
.file-btn span:hover{ border-color:#2b3d55; }

.btn{ padding:9px 12px; border:1px solid var(--border); background:var(--panel); color:var(--text); border-radius:10px; cursor:pointer; }
.btn:hover{ border-color:#2b3d55; }
.btn:disabled{ opacity:0.45; cursor:not-allowed; }
.btn.primary{ background:linear-gradient(180deg, rgba(124,92,255,0.25), rgba(124,92,255,0.10)); border-color:rgba(124,92,255,0.45); }
.btn-compact{ padding:7px 10px; border-radius:10px; }

.layout{ flex:1; min-height:0; display:flex; flex-direction:column; }
/* The viewport MUST have a real height (flex child), otherwise Three.js initializes at 0×0. */
.viewport{
  position:relative;
  flex:1;
  min-height:0;
  overflow:hidden;
  background:radial-gradient(1000px 600px at 20% 20%, rgba(124,92,255,0.08), transparent 60%), radial-gradient(800px 500px at 90% 0%, rgba(32,201,151,0.06), transparent 55%);
  /* Needed for touch orbit/pinch on mobile (prevents page scroll hijacking gestures). */
  touch-action:none;
}

/* Three.js WebGL canvas (injected by app.js) */
.three-canvas{ position:absolute; inset:0; width:100%; height:100%; display:block; }

#overlay2d{ position:absolute; inset:0; pointer-events:none; z-index:2; }

/* Floating dock */
.dock{
  position:absolute;
  left:14px;
  top:14px;
  width:min(520px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  overflow:auto;
  -webkit-overflow-scrolling: touch;
  background:rgba(12,18,26,0.78);
  border:1px solid rgba(255,255,255,0.10);
  border-radius:14px;
  padding:10px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index:4;
}
.dock-row{ display:flex; align-items:center; gap:10px; }
.dock-spacer{ flex:1; }

.tool-group{
  display:flex;
  gap:6px;
  padding:4px;
  border:1px solid rgba(255,255,255,0.10);
  border-radius:12px;
  background:rgba(255,255,255,0.02);
}
.icon-btn{
  width:38px;
  height:34px;
  border-radius:10px;
  border:1px solid transparent;
  background:transparent;
  color:var(--text);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
}
.icon-btn .ico{ font-size:16px; line-height:1; opacity:0.92; }
.icon-btn:hover{ border-color:rgba(255,255,255,0.16); background:rgba(255,255,255,0.04); }
.icon-btn.active{ border-color:rgba(124,92,255,0.55); background:rgba(124,92,255,0.20); }

.dock-section{ margin-top:8px; border-top:1px solid rgba(255,255,255,0.08); padding-top:8px; }
.dock-section > summary{
  cursor:pointer;
  user-select:none;
  color:#dbe7ff;
  font-weight:700;
  font-size:12px;
  letter-spacing:0.2px;
  list-style:none;
}
.dock-section > summary::-webkit-details-marker{ display:none; }
.dock-section > summary::after{ content:"▸"; float:right; opacity:0.65; transform: rotate(0deg); transition: transform 0.12s ease; }
.dock-section[open] > summary::after{ transform: rotate(90deg); }
.dock-section-body{ margin-top:10px; }
.dock-subtitle{ font-size:12px; color:var(--muted); margin-bottom:8px; }

.grid3{ display:grid; grid-template-columns: repeat(3, 1fr); gap:8px; }
.row{ margin-top:10px; }
.row-split{ display:flex; justify-content:space-between; align-items:center; gap:10px; }

.checks{ display:flex; flex-direction:column; gap:8px; }
.checks-row{ flex-direction:row; gap:12px; }
.check{ display:flex; gap:10px; align-items:center; font-size:13px; color:#dbe7ff; user-select:none; }
.check input{ accent-color: var(--accent); }

.slider-label{ display:block; font-size:12px; color:var(--muted); margin-bottom:6px; }
.slider{ width:100%; }

/* Points panel */
.points-panel{
  position:absolute;
  right:14px;
  top:14px;
  width: 320px;
  max-width: calc(100% - 28px);
  max-height: calc(100% - 28px);
  overflow:auto;
  -webkit-overflow-scrolling: touch;
  background:rgba(12,18,26,0.82);
  border:1px solid rgba(255,255,255,0.10);
  border-radius:14px;
  padding:10px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  display:none;
  z-index:5;
}
.points-panel.show{ display:block; }
.points-panel-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px; }
.points-title{ font-weight:700; }

.points{ margin:0; padding-left:20px; color:var(--text); }
.points li{ margin:6px 0; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; color:#cfe2ff; font-size:12px; }
.point-item{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.point-text{ flex:1; overflow:hidden; text-overflow:ellipsis; }
.point-del{ border:1px solid rgba(255,92,122,0.4); background:rgba(255,92,122,0.08); color:#ffb3c1; padding:2px 8px; border-radius:999px; cursor:pointer; }
.point-del:hover{ border-color:rgba(255,92,122,0.65); background:rgba(255,92,122,0.12); }

.muted{ margin-top:8px; color:var(--muted); font-size:12px; }

.footer{ display:flex; justify-content:space-between; align-items:center; padding:10px 14px; border-top:1px solid var(--border); color:var(--muted); font-size:12px; }
.status{ color:#cbd5e1; }
.footer-right{ color:var(--muted); }

.drop-hint{ position:absolute; inset:0; display:flex; flex-direction:column; align-items:center; justify-content:center; color:var(--muted); pointer-events:none; z-index:1; }
.drop-title{ font-size:18px; font-weight:700; color:#dbe7ff; margin-bottom:4px; }
.drop-sub{ font-size:13px; }

.hud{ position:absolute; left:10px; bottom:54px; display:flex; flex-direction:column; gap:6px; background:rgba(10,14,20,0.55); border:1px solid rgba(255,255,255,0.08); border-radius:12px; padding:8px 10px; backdrop-filter: blur(6px); z-index:4; }
.hud-row{ display:flex; gap:8px; align-items:center; font-size:12px; color:#dbe7ff; }
.dot{ width:10px; height:10px; border-radius:999px; background:#4b5563; display:inline-block; box-shadow:0 0 0 2px rgba(255,255,255,0.06) inset; }
.sm-status{ display:flex; align-items:center; gap:8px; color:#dbe7ff; font-size:12px; white-space:nowrap; }

@media (max-width: 820px){
  .dock{ width: calc(100% - 28px); }
  .points-panel{ width: calc(100% - 28px); right:14px; top:auto; bottom:54px; }
  .hud{ bottom:12px; }
}

@media (max-width: 560px){
  .topbar{ justify-content:flex-start; }
  .brand{ width:100%; }
  .top-actions{ width:100%; }
  .grid3{ grid-template-columns: 1fr; }
  .dock{ max-height: 60vh; }
}
