/* ============================================
   Contour Tool — Icon Strip + Floating Panels
   ============================================ */

/* Prevent page scroll — lock everything to viewport */
html.ct-no-scroll, html.ct-no-scroll body,
html.ct-no-scroll .main-content,
html.ct-no-scroll .container-fluid,
html.ct-no-scroll .container-fluid > * {
  overflow: hidden !important;
  min-height: 0 !important;
  max-height: 100vh !important;
}
html.ct-no-scroll .container-fluid { padding-bottom: 0 !important; }

/* ---- Dropzone ---- */
.ct-dz { border: 1.5px dashed #d0d0d0; border-radius: 10px; padding: 14px 8px; cursor: pointer; transition: all .2s; display: flex; align-items: center; justify-content: center; }
.ct-dz:hover, .ct-dz.dz-drag-hover { border-color: #744c54; background: rgba(116,76,84,.04); }
.dark-version .ct-dz { border-color: #444; }
.dark-version .ct-dz:hover { border-color: #9b6b73; background: rgba(155,107,115,.06); }
.ct-dz .dz-preview { display: flex; align-items: center; gap: 5px; width: 100%; }
.ct-dz .dz-preview .dz-filename { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contour-dz-msg { pointer-events: none; width: 100%; }

/* ---- Icon Strip (left edge) ---- */
.ct-strip {
  width: 44px;
  min-width: 44px;
  border-right: 1px solid #eee;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  gap: 4px;
  z-index: 20;
  flex-shrink: 0;
  overflow-y: none;
}
.dark-version .ct-strip { border-color: #333; }

.ct-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  color: #777;
  transition: all .15s;
  position: relative;
  flex-shrink: 0;
}
.ct-icon:hover { background: rgba(116,76,84,.08); color: #744c54; }
.ct-icon.active { background: rgba(116,76,84,.12); color: #744c54; }
.ct-icon.active::after {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  background: #744c54;
  border-radius: 0 3px 3px 0;
}
.ct-icon i { font-size: 20px; }
.dark-version .ct-icon { color: #888; }
.dark-version .ct-icon:hover, .dark-version .ct-icon.active { color: #d4a0a8; background: rgba(155,107,115,.12); }
.dark-version .ct-icon.active::after { background: #d4a0a8; }

/* ---- Dock Panel ---- */
.ct-panels {
  width: 0;
  min-width: 0;
  overflow: hidden;
  border-right: 0 solid #eee;
  transition: width .2s ease, min-width .2s ease, border-width .2s ease;
  position: relative;
}
.ct-panels.open {
  width: 220px;
  min-width: 220px;
  border-right-width: 1px;
  overflow-y: auto;
}
.dark-version .ct-panels { border-color: #333; }
.ct-panel {
  width: 220px;
  padding: 14px;
  font-size: 12px;
  display: none;
  animation: ctPanelIn .15s ease;
  box-sizing: border-box;
}
.ct-panel.active { display: block; }
@keyframes ctPanelIn { from { opacity: 0; } to { opacity: 1; } }

.ct-panel-head {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: #888; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;
}
.ct-panel-close { cursor: pointer; font-size: 16px; line-height: 1; color: #aaa; }
.ct-panel-close:hover { color: #744c54; }

.ct-label { font-size: 11px; font-weight: 600; color: #888; display: block; margin-bottom: 3px; }
.ct-select {
  width: 100%; padding: 5px 8px; border: 1px solid #ddd; border-radius: 6px;
  font-size: 11.5px; background: #fff; color: #333;
}
.dark-version .ct-select { background: rgba(255,255,255,.06); border-color: #444; color: #ddd; }
.ct-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px; border-radius: 3px; background: #ddd; outline: none; margin: 6px 0;
}
.dark-version .ct-slider { background: #444; }
.ct-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #744c54; cursor: pointer; }
.ct-slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #744c54; cursor: pointer; border: none; }

.ct-check { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; margin: 4px 0; }
.ct-check input { accent-color: #744c54; }

/* 2D/3D toggle */
.contour-dim-btn {
  flex: 1; padding: 5px 0; border: 1px solid #ccc; background: #f5f5f5;
  font-size: 11px; font-weight: 700; color: #666; cursor: pointer; transition: all .15s; text-align: center;
}
.contour-dim-btn:first-child { border-radius: 6px 0 0 6px; }
.contour-dim-btn:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
.dark-version .contour-dim-btn { border-color: #444; color: #999; background: #2a2a3a; }
.contour-dim-btn.active { background: #744c54; color: #fff; border-color: #744c54; }

/* ---- Main viz area ---- */
.contour-main { flex: 1; position: relative; min-width: 0; overflow: hidden; }
#contour-viz { width: 100%; height: 100%; position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column; }

/* ---- Toolbar (hidden — using sidebar panels now) ---- */
.contour-toolbar { display: none; }

/* ---- Plot wrapper ---- */
.contour-plot-wrapper { border-radius: 4px; overflow: hidden; background: #fff; position: relative; }
.dark-version .contour-plot-wrapper { background: #1a1a2e; }

/* ---- Zoom + North controls ---- */
.contour-viz-controls {
  position: absolute; bottom: 10px; right: 10px; z-index: 20;
  display: flex; flex-direction: column; gap: 4px;
}
.contour-viz-btn {
  width: 30px; height: 30px; border: 1px solid #ddd; border-radius: 6px;
  background: rgba(255,255,255,.92); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 18px; color: #555; transition: all .15s;
}
.dark-version .contour-viz-btn { background: rgba(30,30,45,.9); border-color: #444; color: #aaa; }
.contour-viz-btn:hover { background: #744c54; color: #fff; border-color: #744c54; }
.contour-north-arrow {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #744c54;
  border: 1px solid #ddd; border-radius: 6px; background: rgba(255,255,255,.92);
}
.dark-version .contour-north-arrow { background: rgba(30,30,45,.9); border-color: #444; }

/* ---- Tooltip ---- */
.contour-tooltip {
  position: absolute; padding: 5px 8px; background: rgba(0,0,0,.8); color: #fff;
  border-radius: 5px; font-size: 11px; pointer-events: none; z-index: 100; white-space: nowrap;
}

/* ---- Note ---- */
.contour-note {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  padding: 6px 12px; border-radius: 6px; font-size: 11px; z-index: 10;
  background: #fef3c7; border: 1px solid #fbbf24; color: #92400e; white-space: nowrap;
}
.dark-version .contour-note { background: rgba(251,191,36,.1); border-color: rgba(251,191,36,.3); color: #fbbf24; }

/* ---- Dimension Toggle ---- */
.ct-toggle-group { display: flex; gap: 0; border-radius: 8px; overflow: hidden; border: 1px solid #ddd; }
.dark-version .ct-toggle-group { border-color: #444; }
.ct-toggle {
  flex: 1; padding: 6px 0; border: none; background: #f5f5f5; color: #888;
  font-size: 11px; font-weight: 600; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.dark-version .ct-toggle { background: #2a2a3a; color: #777; }
.ct-toggle.active { background: #744c54; color: #fff; }

/* ---- Switch List ---- */
.ct-switch-list { display: flex; flex-direction: column; gap: 6px; }
.ct-switch-row { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: #555; }
.dark-version .ct-switch-row { color: #aaa; }

.ct-mini-switch { position: relative; width: 30px; height: 16px; display: inline-block; flex-shrink: 0; }
.ct-mini-switch input { opacity: 0; width: 0; height: 0; }
.ct-mini-switch span {
  position: absolute; inset: 0; background: #ccc; border-radius: 16px; cursor: pointer; transition: .2s;
}
.ct-mini-switch span::before {
  content: ''; position: absolute; width: 12px; height: 12px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.ct-mini-switch input:checked + span { background: #744c54; }
.ct-mini-switch input:checked + span::before { transform: translateX(14px); }
.dark-version .ct-mini-switch span { background: #555; }

/* ---- Fullpage overlay (Theory / References) ---- */
.ct-fullpage {
  position: absolute;
  inset: 0;
  background: #fff;
  z-index: 30;
  overflow-y: auto;
  animation: ctFpIn .2s ease;
}
@keyframes ctFpIn { from { opacity: 0; } to { opacity: 1; } }
.dark-version .ct-fullpage { background: #1e1e2e; color: #d0d0d0; }
.ct-fullpage-inner { padding: 32px 40px; max-width: 720px; position: relative; }
.ct-fp-close {
  position: absolute; top: 20px; right: 20px;
  font-size: 24px; color: #aaa; cursor: pointer; line-height: 1; transition: color .15s;
}
.ct-fp-close:hover { color: #744c54; }
.ct-fp-content { font-size: 13.5px; line-height: 1.7; color: #555; }
.dark-version .ct-fp-content { color: #bbb; }
.ct-fp-content h6 { color: #333; font-size: 14px; }
.dark-version .ct-fp-content h6 { color: #ddd; }
.ct-fp-content ul { padding-left: 20px; margin: 8px 0; }
.ct-fp-content li { margin-bottom: 4px; }
.ct-fp-note {
  padding: 12px 16px; border-radius: 8px; font-size: 12.5px;
  background: #f8f5f0; border-left: 3px solid #744c54; color: #666;
}
.dark-version .ct-fp-note { background: rgba(116,76,84,.1); color: #aaa; }

/* ---- Categorized Layer Panel ---- */
.ct-layer-cat { margin-bottom: 6px; }
.ct-layer-cat-head {
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; padding: 4px 0; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .3px; color: #888; user-select: none;
}
.ct-layer-cat-head span { display: flex; align-items: center; gap: 3px; }
.ct-cat-chevron { transition: transform .2s; }
.ct-layer-cat.collapsed .ct-cat-chevron { transform: rotate(-90deg); }
.ct-layer-cat.collapsed .ct-layer-cat-body { display: none; }
.ct-layer-cat-body { padding-left: 4px; }
.ct-layer-radio {
  display: flex; align-items: center; gap: 6px; padding: 3px 4px; margin: 1px 0;
  border-radius: 5px; cursor: pointer; font-size: 11.5px; transition: background .1s;
}
.ct-layer-radio:hover { background: rgba(116,76,84,.06); }
.ct-layer-radio input { accent-color: #744c54; margin: 0; flex-shrink: 0; }
.ct-layer-radio span { line-height: 1.3; }

/* ---- Axes ---- */
.x-axis path, .x-axis line, .y-axis path, .y-axis line { stroke: #ccc; }
.dark-version .x-axis path, .dark-version .x-axis line, .dark-version .y-axis path, .dark-version .y-axis line { stroke: #444; }
