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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0a0a14;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
}

/* ===== Header ===== */
header {
  background: #111122;
  padding: 6px 16px;
  border-bottom: 1px solid #222244;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 40px;
}

header h1 {
  font-size: 14px;
  color: #e94560;
  white-space: nowrap;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
}

.header-controls label {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-controls input[type="range"] {
  width: 80px;
  accent-color: #e94560;
}

.header-controls input[type="checkbox"] {
  accent-color: #e94560;
}

.header-controls button {
  background: #e94560;
  color: #fff;
  border: none;
  padding: 3px 10px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}

.header-controls button:hover {
  background: #c73652;
}

.header-controls button:disabled {
  background: #555;
  cursor: not-allowed;
}

.loading-bar {
  flex: 1;
  height: 20px;
  background: #1a1a2e;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.loading-progress {
  height: 100%;
  width: 0%;
  background: #e94560;
  transition: width 0.3s;
  border-radius: 3px;
}

.loading-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: #fff;
}

/* ===== 4-Quad Grid ===== */
.quad-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  height: calc(100vh - 40px);
  background: #222;
}

.quad-cell {
  background: #0a0a14;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-label {
  position: absolute;
  top: 4px;
  left: 8px;
  font-size: 11px;
  color: #888;
  z-index: 10;
  pointer-events: none;
}

.seg-status {
  color: #e94560;
  margin-left: 8px;
  font-size: 10px;
}

/* ===== 2D Viewers ===== */
.viewer-2d {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  overflow: hidden;
}

.viewer-2d canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* axial scaleY(-1)는 JS applyTransform에서 통합 관리 */

.mask-overlay {
  position: absolute;
  pointer-events: none;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.slice-range {
  width: 100%;
  height: 14px;
  accent-color: #e94560;
  background: #111;
  border: none;
  display: block;
}

/* ===== Crosshair ===== */
.crosshair {
  position: absolute;
  pointer-events: none;
  z-index: 5;
}

.crosshair-h {
  left: 0;
  right: 0;
  height: 1px;
}

.crosshair-v {
  top: 0;
  bottom: 0;
  width: 1px;
}

/* 축별 색상: Axial(Z)=빨강, Coronal(Y)=초록, Sagittal(X)=파랑 */
/* Coronal 뷰: 가로=axial(빨강), 세로=sagittal(파랑) */
#coronal-ch-h { background: rgba(255, 60, 60, 0.7); }
#coronal-ch-v { background: rgba(60, 120, 255, 0.7); }

/* Sagittal 뷰: 가로=axial(빨강), 세로=coronal(초록) */
#sagittal-ch-h { background: rgba(255, 60, 60, 0.7); }
#sagittal-ch-v { background: rgba(60, 200, 60, 0.7); }

/* Axial 뷰: 가로=coronal(초록), 세로=sagittal(파랑) */
#axial-ch-h { background: rgba(60, 200, 60, 0.7); }
#axial-ch-v { background: rgba(60, 120, 255, 0.7); }

/* ===== 3D Viewer ===== */
.viewer-3d {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.viewer-3d canvas {
  width: 100% !important;
  height: 100% !important;
}

.three-controls {
  position: absolute;
  bottom: 4px;
  right: 4px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.three-control-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #ccc;
}

.three-control-label input[type="range"] {
  width: 80px;
  accent-color: #e94560;
}

.three-controls button {
  background: rgba(233, 69, 96, 0.8);
  color: #fff;
  border: none;
  padding: 3px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
}

.three-controls button:hover {
  background: #e94560;
}

/* ===== Bone List ===== */
.bone-list {
  position: absolute;
  top: 24px;
  left: 4px;
  max-height: calc(100% - 60px);
  overflow-y: auto;
  background: rgba(10, 10, 20, 0.9);
  border: 1px solid #333;
  border-radius: 4px;
  padding: 4px;
  font-size: 10px;
  z-index: 10;
}

.bone-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 2px;
  white-space: nowrap;
}

.bone-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.bone-color {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.bone-toggle {
  accent-color: #e94560;
}
