:root {
  --primary-color: #0A4737;
  --secondary-color: #A7DBA8;
  --background-color: #F8FAF5;
  --card-color: #D8FBF7;
  --accent-color: #FF6421;
  --text-main: #1f2937;
  --text-muted: #9ca3af;
  --border-light: #e5e7eb;
}

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

body {
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--background-color);
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#canvas {
  cursor: crosshair;
  touch-action: none;
  width: 100%;
  height: 100vh;
  display: block;
}

#canvas.select-mode {
  cursor: default;
}

#canvas.eraser-mode {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2"><circle cx="12" cy="12" r="10" fill="white" fill-opacity="0.5"/></svg>') 12 12, auto;
}

#canvas.grabbing {
  cursor: grabbing;
}

@keyframes selection-breathe {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

.selected-point {
  fill: var(--accent-color) !important;
  r: 8 !important;
  animation: selection-breathe 1.5s infinite ease-in-out;
}

.selected-line {
  stroke: var(--accent-color) !important;
  stroke-width: 6 !important;
  animation: selection-breathe 1.5s infinite ease-in-out;
}

.selected-shape {
  stroke: var(--accent-color) !important;
  stroke-width: 5 !important;
  animation: selection-breathe 1.5s infinite ease-in-out;
}

.selected-parallelogram {
  stroke: var(--accent-color) !important;
  stroke-width: 5 !important;
  fill: rgba(255, 100, 33, 0.3) !important;
  animation: selection-breathe 1.5s infinite ease-in-out;
}

.selected-parallelogram-point {
  fill: var(--accent-color) !important;
  animation: selection-breathe 1.5s infinite ease-in-out;
}

.selected-parallelogram-point-circle {
  r: 8 !important;
}

#toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translate(-50%, -20px);
  background: white;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  border-radius: 0.75rem;
  padding: 12px 24px;
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border-light);
  max-width: 90%;
  width: auto;
  transition: opacity 0.3s ease, transform 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

#toastMessage {
  color: var(--text-main);
  font-weight: 500;
  white-space: pre-line;
  line-height: 1.6;
  font-size: 1rem;
}

#toastClose {
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 4px;
  background: none;
  border: none;
  cursor: pointer;
}

#toastClose:hover {
  color: #4b5563;
}

.toolbar-container {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 1rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 8px;
  border: 1px solid var(--border-light);
  touch-action: none;
}

@media (min-width: 768px) {
  .toolbar-container {
    right: 24px;
  }
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 0.75rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-muted);
}

.tool-btn svg {
  color: inherit;
}

.tool-btn:hover {
  transform: translateX(-2px);
  background: #f3f4f6;
  color: var(--text-main);
}

@media (min-height: 700px) {
  .tool-btn {
    width: 50px;
    height: 50px;
  }

  .tool-btn svg {
    width: 24px;
    height: 24px;
  }
}

.tool-btn.active {
  background: var(--primary-color);
  color: white;
}

.tool-btn.active:hover {
  background: #0e5e49;
  color: white;
}

#eraserBtn.active {
  background: var(--primary-color);
  color: white;
}

#eraserBtn.active svg {
  fill: white;
}

.tool-btn.color-btn.active {
  transform: scale(2);
  z-index: 10;
  background: transparent;
}

.tool-btn.color-btn.active:hover {
  background: transparent;
}

.divider {
  height: 1px;
  background-color: #e5e7eb;
  margin: 4px 8px;
}

#deleteBtn {
  color: #dc2626;
}

#deleteBtn:hover {
  background-color: #fef2f2;
  color: #b91c1c;
}

.point-circle {
  transition: r 0.2s ease;
  pointer-events: none;
}

.point-hitarea {
  cursor: pointer;
  fill: transparent;
  pointer-events: all;
}

.line-path {
  transition: stroke-width 0.2s ease;
  pointer-events: none;
}

.line-hitarea {
  cursor: pointer;
  stroke: transparent;
  stroke-width: 20;
  fill: none;
  pointer-events: all;
}

.cloned-parallelogram {
  pointer-events: all;
  cursor: grab;
}

.cloned-parallelogram.dragging {
  cursor: grabbing;
}

.aux-line {
  stroke-dasharray: 6, 4;
  pointer-events: none;
}

.snap-marker {
  pointer-events: none;
  transition: all 0.1s;
}

.hidden {
  display: none !important;
}

#codeModal,
#successModal,
#authModal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}



#codeModal.show,
#successModal.show,
#authModal.show {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

.modal-content {
  background: white;
  padding: 24px;
  border-radius: 16px;
  width: 320px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
}

.code-display {
  background: #f3f4f6;
  border: 2px solid var(--border-light);
  border-radius: 8px;
  padding: 12px;
  font-size: 2rem;
  font-weight: bold;
  font-family: monospace;
  text-align: center;
  letter-spacing: 0.5em;
  min-height: 64px;
  color: var(--primary-color);
  display: flex;
  justify-content: center;
  align-items: center;
}

.code-display.error {
  border-color: #ef4444;
  color: #ef4444;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.keypad-btn {
  height: 60px;
  border-radius: 12px;
  border: 1px solid var(--border-light);
  background: white;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.1s;
  display: flex;
  justify-content: center;
  align-items: center;
}

.keypad-btn:active {
  background: #e5e7eb;
  transform: scale(0.98);
}

.keypad-btn.action {
  background: #f9fafb;
  font-size: 1rem;
}

.keypad-btn.primary {
  background: var(--primary-color);
  color: white;
  border: none;
}

.keypad-btn.primary:active {
  background: #0e5e49;
}