/* =========================================================
   Human Atlas — Interactive 3D Anatomy
   Clean professional UI · Light theme
   ========================================================= */

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
  background: #f4f5f7;
  color: #1a1d23;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  display: grid;
  grid-template-columns: 280px 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  width: 100vw;
}

/* ---------- TOP BAR ---------- */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: #ffffff;
  border-bottom: 1px solid #e6e8ec;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.brand-mark {
  color: #d9384a;
  font-size: 18px;
  position: relative;
  top: 2px;
}
.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #1a1d23;
}
.brand-sub {
  font-size: 12px;
  color: #8a8f99;
  margin-left: 4px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  background: #f4f5f7;
  border: 1px solid #e6e8ec;
  border-radius: 8px;
  padding: 6px 10px 6px 32px;
  width: 240px;
  transition: border-color .15s, background .15s;
}
.search:focus-within {
  border-color: #d9384a;
  background: #fff;
}
.search-icon {
  position: absolute;
  left: 10px;
  color: #8a8f99;
  font-size: 14px;
}
.search input {
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: #1a1d23;
  width: 100%;
}
.search input::placeholder { color: #aab0bb; }

.btn-ghost {
  background: #fff;
  border: 1px solid #e6e8ec;
  color: #1a1d23;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
}
.btn-ghost:hover {
  background: #f4f5f7;
  border-color: #d2d6de;
}
.btn-ghost:active { transform: translateY(1px); }

/* ---------- SIDE PANEL ---------- */
.sidepanel {
  background: #ffffff;
  border-right: 1px solid #e6e8ec;
  padding: 18px 16px 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-title {
  font-size: 11px;
  font-weight: 600;
  color: #1a1d23;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.panel-sub {
  font-size: 11.5px;
  color: #8a8f99;
  margin-top: -4px;
  margin-bottom: 4px;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: background .12s;
  position: relative;
}
.check-item:hover { background: #f4f5f7; }
.check-box {
  width: 16px;
  height: 16px;
  border: 1.5px solid #c4c9d2;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .12s;
  background: #fff;
}
.check-item.on .check-box {
  background: #d9384a;
  border-color: #d9384a;
}
.check-item.on .check-box::after {
  content: "";
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.check-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.check-label {
  font-size: 13px;
  color: #1a1d23;
  flex: 1;
}
.check-item.dim { opacity: 0.35; }
.check-item.dim .check-label { color: #8a8f99; }

/* ---------- controls ---------- */
.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 2px;
  font-size: 12.5px;
  color: #1a1d23;
}

.switch-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
  user-select: none;
}

.switch {
  position: relative;
  width: 34px;
  height: 20px;
  display: inline-block;
  flex-shrink: 0;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}
.slider {
  position: absolute;
  inset: 0;
  background: #d2d6de;
  border-radius: 20px;
  transition: background .15s;
  cursor: pointer;
}
.slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s;
}
.switch.on .slider { background: #d9384a; }
.switch.on .slider::before { transform: translateX(14px); }

.slider-row {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}
.slider-row > span {
  font-size: 12.5px;
  color: #1a1d23;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #e6e8ec;
  border-radius: 4px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #d9384a;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #d9384a;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #fff;
}

/* ---------- credits ---------- */
.credits {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid #e6e8ec;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}
.version {
  font-size: 11px;
  font-weight: 600;
  color: #8a8f99;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border: 1px solid #e6e8ec;
  border-radius: 4px;
  background: #f4f5f7;
}
.credit {
  font-size: 11px;
  color: #8a8f99;
}

/* ---------- VIEWPORT ---------- */
.viewport {
  position: relative;
  background:
    radial-gradient(circle at 50% 40%, #ffffff 0%, #eef0f4 70%, #e3e6ed 100%);
  overflow: hidden;
}

#canvasHost {
  position: absolute;
  inset: 0;
}
#canvasHost canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.viewport-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.legend {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border: 1px solid #e6e8ec;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  color: #1a1d23;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border: 1px solid #e6e8ec;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 12px;
  color: #5a6070;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.hint strong { color: #1a1d23; font-weight: 600; }

/* scrollbar */
.sidepanel::-webkit-scrollbar { width: 6px; }
.sidepanel::-webkit-scrollbar-track { background: transparent; }
.sidepanel::-webkit-scrollbar-thumb { background: #d2d6de; border-radius: 6px; }
.sidepanel::-webkit-scrollbar-thumb:hover { background: #b4b9c4; }

/* responsive: collapse panel on small screens */
@media (max-width: 760px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 56px 220px 1fr;
  }
  .sidepanel { border-right: none; border-bottom: 1px solid #e6e8ec; }
  .search { width: 140px; }
  .brand-sub { display: none; }
}
