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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
}

#canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    cursor: crosshair;
}

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

#canvas.dragging {
    cursor: grabbing;
}

#canvas.panning {
    cursor: grab;
}

#canvas.panning:active {
    cursor: grabbing;
}

.github-link {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: #333;
    transition: all 0.3s ease;
    z-index: 999;
    text-decoration: none;
}

.github-link:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    color: #667eea;
}

.github-link:active {
    transform: translateY(0) scale(1);
}

.toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    padding: 10px 0;
}

.tool-btn {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    color: #333;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-1px);
}

.tool-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

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

.divider {
    width: 1px;
    height: 30px;
    background: #e0e0e0;
    margin: 0 3px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid #e0e0e0;
    margin-top: 8px;
}

.zoom-btn {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    color: #333;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
}

.zoom-btn:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: translateY(-1px);
}

.zoom-btn:active {
    transform: translateY(0);
}

.zoom-level {
    font-size: 13px;
    font-weight: 600;
    color: #667eea;
    min-width: 50px;
    text-align: center;
}

/* Modal Styles */
.modal {
    position: fixed;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 300px;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal.minimized .modal-content {
    display: none;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 12px 12px 0 0;
    cursor: move;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.modal-controls {
    display: flex;
    gap: 4px;
}

.modal-control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.modal-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.modal-content {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#toolbar-modal {
    top: 20px;
    left: 20px;
}

#help-modal {
    bottom: 20px;
    right: 20px;
}

.instructions {
    background: rgba(102, 126, 234, 0.1);
    border-left: 3px solid #667eea;
    color: #333;
    padding: 10px;
    font-size: 13px;
    border-radius: 4px;
    margin-top: 10px;
}

.instruction-text {
    text-align: left;
    font-weight: 500;
}

.context-menu {
    position: absolute;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    padding: 4px;
    z-index: 1000;
    min-width: 120px;
}

.context-menu.hidden {
    display: none;
}

.context-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: background 0.15s ease;
}

.context-menu-item:hover {
    background: #f0f0f0;
}

.info-section {
    margin-bottom: 16px;
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section h4 {
    color: #333;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
}

.info-section p {
    color: #666;
    font-size: 13px;
    line-height: 1.5;
}

/* Responsive design */
@media (max-width: 768px) {
    .tool-btn span {
        display: none;
    }

    .tool-btn {
        padding: 8px;
    }

    .modal {
        min-width: 250px;
        max-width: 90vw;
    }

    #toolbar-modal {
        top: 10px;
        left: 10px;
    }

    #help-modal {
        bottom: 10px;
        right: 10px;
    }

    .github-link {
        top: 10px;
        right: 10px;
        width: 36px;
        height: 36px;
    }

    .github-link svg {
        width: 20px;
        height: 20px;
    }
}

/* Keyboard focus styles */
.tool-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.modal-control-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* Animation for new elements */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.fade-in {
    animation: fadeIn 0.2s ease;
}

/* Scrollbar styling */
.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: #5568d3;
}

/* Load JSON Modal Styles */
.load-json-modal {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80vw;
    max-width: 900px;
    height: 90vh;
    max-height: none;
}

.load-json-modal.hidden {
    display: none;
}

.load-json-modal .modal-header {
    cursor: default;
}

.load-json-modal .modal-content {
    overflow-y: hidden;
}

.load-json-description {
    margin-bottom: 16px;
    color: #666;
    font-size: 14px;
}

.json-drop-zone {
    border: 2px dashed #667eea;
    border-radius: 8px;
    padding: 32px 24px;
    text-align: center;
    background: rgba(102, 126, 234, 0.05);
    margin-bottom: 16px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.json-drop-zone:hover {
    background: rgba(102, 126, 234, 0.1);
    border-color: #764ba2;
}

.json-drop-zone.drag-over {
    background: rgba(102, 126, 234, 0.15);
    border-color: #764ba2;
    border-style: solid;
}

.json-drop-zone svg {
    color: #667eea;
    margin-bottom: 12px;
}

.drop-zone-text {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.drop-zone-subtext {
    font-size: 13px;
    color: #999;
}

.json-input {
    width: 100%;
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 12px;
    resize: none;
    margin-bottom: 16px;
    transition: border-color 0.2s ease;
}

.json-input:focus {
    outline: none;
    border-color: #667eea;
}

.load-json-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.action-btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.action-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.action-btn.primary:active {
    transform: translateY(0);
}

.action-btn.secondary {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e0e0e0;
}

.action-btn.secondary:hover {
    background: #e9ecef;
}

.json-error {
    margin-top: 12px;
    padding: 12px;
    background: rgba(255, 107, 107, 0.1);
    border-left: 3px solid #ff6b6b;
    border-radius: 4px;
    color: #d63031;
    font-size: 13px;
    line-height: 1.5;
}

.json-error.hidden {
    display: none;
}

@media (max-width: 768px) {
    .load-json-modal {
        width: 95vw;
        height: 95vh;
    }
}
