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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
}

#app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

header h1 {
  font-size: 24px;
  color: #fff;
}

.icon-btn {
  background: none;
  border: 1px solid #444;
  color: #ccc;
  font-size: 20px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.icon-btn:hover {
  background: #333;
}

#upload-area {
  border: 2px dashed #555;
  border-radius: 12px;
  padding: 80px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}
#upload-area:hover, #upload-area.dragover {
  border-color: #a855f7;
}
#upload-area input {
  display: none;
}
.upload-prompt p {
  font-size: 18px;
  color: #888;
}

#editor {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

#image-container {
  position: relative;
  flex: 1;
  min-width: 0;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
}

#photo {
  display: block;
  width: 100%;
  height: auto;
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  /* width and height set by JS to match displayed image exactly */
  cursor: default;
  overflow: visible;
}

#controls {
  width: 260px;
  flex-shrink: 0;
  background: #16213e;
  border-radius: 8px;
  padding: 20px;
}

#controls h3 {
  margin-bottom: 16px;
  font-size: 16px;
  color: #fff;
}

#controls label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: #aaa;
}

#controls input[type="range"] {
  width: 100%;
  margin-top: 4px;
  accent-color: #a855f7;
}

#controls select {
  width: 100%;
  margin-top: 4px;
  padding: 6px;
  background: #1a1a2e;
  color: #e0e0e0;
  border: 1px solid #444;
  border-radius: 4px;
}

.control-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

button {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

#detectBtn {
  background: #a855f7;
  color: white;
}
#detectBtn:hover {
  background: #9333ea;
}
#detectBtn:disabled {
  background: #555;
  cursor: not-allowed;
}

.secondary {
  background: #2d2d4e;
  color: #ccc;
}
.secondary:hover {
  background: #3d3d5e;
}

.danger {
  background: #4a1a1a;
  color: #f87171;
}
.danger:hover {
  background: #5a2a2a;
}

.hidden {
  display: none !important;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: #16213e;
  border-radius: 12px;
  padding: 28px;
  width: 420px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-content h2 {
  margin-bottom: 12px;
  color: #fff;
}
.modal-content p {
  margin-bottom: 16px;
  font-size: 14px;
  color: #999;
}
.modal-content label {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: #aaa;
}
.modal-content input[type="text"],
.modal-content input[type="password"] {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 4px;
  color: #e0e0e0;
  font-size: 14px;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}
.figma-modal-wide {
  width: 520px;
}
.figma-instructions {
  background: #1a1a2e;
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.figma-instructions h4 {
  font-size: 13px;
  color: #ccc;
  margin-bottom: 8px;
}
.figma-instructions ol {
  padding-left: 20px;
  font-size: 13px;
  color: #999;
  line-height: 1.7;
}
.figma-instructions ol ol {
  margin-top: 4px;
}
.figma-instructions .hint {
  font-size: 11px;
  color: #666;
  display: block;
  margin-top: 2px;
  margin-bottom: 4px;
}

/* Loading */
#loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #333;
  border-top-color: #a855f7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* SVG dot styling */
.joint-dot {
  cursor: grab;
}
.joint-dot:active {
  cursor: grabbing;
}
.joint-dot.dragging {
  cursor: grabbing;
}
.joint-dot.selected {
  filter: brightness(1.3);
}
