:root {
  --canvas-bg: #f8f9fa;
  --sidebar-bg: #2c3e50;
  --accent-color: #3498db;
  --cyan: #00ffff;
  --text-light: #ecf0f1;
  --text-dark: #2c3e50;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  display: grid;
  grid-template-columns: 400px 1fr;
  height: 100vh;
  color: var(--text-dark);
}

aside {
  padding: 20px;
  background: var(--sidebar-bg);
  color: var(--text-light);
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

aside h3 {
  margin-top: 0;
  font-size: 1.5rem;
  color: var(--cyan);
  border-bottom: 2px solid var(--text-light);
  padding-bottom: 10px;
}

aside a {
  position: absolute;
  right: 25px;
  -webkit-text-decoration: none;
  -moz-text-decoration: none;
  text-decoration: none;
  color: #ffffff;
  font-size: 16px;
  z-index: 10;
}

main {
  overflow: auto;
  background: var(--canvas-bg);
  position: relative;
  transition: var(--transition);
}

#canvas {
  display: grid;
  grid-template-columns: repeat(50, 120px);
  grid-template-rows: repeat(50, 90px);
  gap: 10px;
  min-width: max-content;
  min-height: max-content;
  padding: 30px;
  background-color: var(--text-dark);
  background-image: linear-gradient(#aff 1px, transparent 1px),
                    linear-gradient(90deg, #aff 1px, transparent 1px);
  background-size: 20px 20px;
  transition: var(--transition);
}

.shape {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: move;
  user-select: none;
  width: 120px;
  border: 2px solid var(--accent-color);
  border-radius: 6px;
  background: white;
  box-shadow: var(--shadow);
  transition: var(--transition);
  padding: 15px;
}

.shape:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.shape[contenteditable="true"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.5);
}

.diamond {
  transform: rotate(45deg);
  width: 90px;
  height: 90px;
}

.diamond span {
  transform: rotate(-45deg);
}

.parallelogram {
  transform: skewx(-20deg) !important;
}

.parallelogram span {
  transform: skew(20deg);
  height: 50px;
  padding-top: 15px;
}

.stadium {
  border-radius: 50px;
}

.line {
  background: var(--accent-color);
  transition: var(--transition);
}

.h-line { height: 3px; border-radius: 3px; }
.v-line { width: 3px; border-radius: 3px; }

.arrow {
  width: 0;
  height: 0;
  transition: var(--transition);
}

.arrow.right {
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-left: 24px solid var(--accent-color);
}

.arrow.left {
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  border-right: 24px solid var(--accent-color);
}

.arrow.up {
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 24px solid var(--accent-color);
}

.arrow.down {
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 24px solid var(--accent-color);
}

/* Controls */
label {
  display: block;
  margin: 15px 0 5px;
  font-weight: 500;
  font-size: 0.9rem;
}

input, select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-light);
  transition: var(--transition);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

button {
  background: var(--accent-color);
  color: white;
  border: none;
  padding: 10px 15px;
  margin: 10px 0;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  width: 100%;
}

button:hover {
  background: #2980b9;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

textarea {
  width: 100%;
  height: 150px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  resize: vertical;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-light);
  margin-top: 20px;
}

.property-panel {
  margin-top: 20px;
  padding: 15px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 6px;
}

.property-panel h4 {
  margin-top: 0;
  color: var(--text-light);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 8px;
}

.property-control {
  display: none;
  margin-top: 15px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-color);
  border-radius: 4px;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
  margin: 10px 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent-color);
}

input:checked + .slider:before {
  transform: translateX(26px);
}

/* Tooltip */
.tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 200px;
  background-color: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  margin-left: -100px;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
  }
  
  aside {
    padding: 15px;
  }
  
  #canvas {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    grid-template-rows: auto;
  }
}

/* Animation for new elements */
@keyframes popIn {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.new-element {
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}