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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1e1e1e;
    color: #fff;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Toolbar */
.toolbar {
    width: 60px;
    background: #2d2d2d;
    display: flex;
    flex-direction: column;
    padding: 20px 10px;
    gap: 10px;
    border-right: 1px solid #3d3d3d;
    z-index: 10;
}

.tool-btn {
    width: 40px;
    height: 40px;
    background: #3d3d3d;
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    position: relative;
}

.tool-btn:hover {
    background: #4d4d4d;
    transform: scale(1.05);
}

.tool-btn.active {
    background: #0d99ff;
}

.tool-btn:hover::after {
    content: attr(title);
    position: absolute;
    left: 50px;
    top: 50%;
    transform: translateY(-50%);
    background: #000;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 100;
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: 50px;
    background: #2d2d2d;
    border-bottom: 1px solid #3d3d3d;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 10px;
}

.top-bar button {
    padding: 8px 16px;
    background: #0d99ff;
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.top-bar button:hover {
    background: #0b7fd9;
}

.top-bar button.secondary {
    background: #3d3d3d;
}

.top-bar button.secondary:hover {
    background: #4d4d4d;
}

.canvas-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: #1e1e1e;
}

#canvas {
    width: 900px;
    height: 600px;
    background: #fff;
    position: relative;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border-radius: 4px;
}

/* Elements */
.element {
    position: absolute;
    border: 1px solid transparent;
    cursor: move;
}

.element.text {
    background: transparent;
    border: 1px dashed #ccc;
    padding: 8px;
    font-size: 16px;
    color: #000;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
}

.element.selected {
    border: 2px solid #0d99ff;
    outline: none;
    z-index: 9999 !important;
}

/* Resize Handles */
.resize-handle {
    width: 10px;
    height: 10px;
    background: #0d99ff;
    border: 2px solid #fff;
    position: absolute;
    border-radius: 50%;
    z-index: 10000;
}

.resize-handle.top-left { top: -6px; left: -6px; cursor: nwse-resize; }
.resize-handle.top-right { top: -6px; right: -6px; cursor: nesw-resize; }
.resize-handle.bottom-left { bottom: -6px; left: -6px; cursor: nesw-resize; }
.resize-handle.bottom-right { bottom: -6px; right: -6px; cursor: nwse-resize; }

/* Rotation Handle */
.rotation-handle {
    width: 12px;
    height: 12px;
    background: #9b59b6;
    border: 2px solid #fff;
    position: absolute;
    border-radius: 50%;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    cursor: grab;
    z-index: 10000;
}

.rotation-line {
    position: absolute;
    width: 1px;
    height: 25px;
    background: #0d99ff;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.rotation-handle:active {
    cursor: grabbing;
}

/* Right Panel */
.right-panel {
    width: 280px;
    background: #2d2d2d;
    border-left: 1px solid #3d3d3d;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.panel-section {
    padding: 20px;
    border-bottom: 1px solid #3d3d3d;
}

.panel-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: #999;
    margin-bottom: 15px;
    letter-spacing: 1px;
    font-weight: 600;
}

.property-group {
    margin-bottom: 15px;
}

.property-group label {
    display: block;
    font-size: 12px;
    color: #aaa;
    margin-bottom: 5px;
}

.property-group input,
.property-group textarea {
    width: 100%;
    padding: 8px;
    background: #3d3d3d;
    border: 1px solid #4d4d4d;
    border-radius: 4px;
    color: #fff;
    font-size: 13px;
}

.property-group input:focus,
.property-group textarea:focus {
    border-color: #0d99ff;
    outline: none;
}

.property-group textarea {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

input[type="color"] {
    height: 36px;
    cursor: pointer;
    padding: 2px;
}

/* Layers Panel */
.layers-list {
    max-height: 300px;
    overflow-y: auto;
}

.layer-item {
    padding: 10px;
    background: #3d3d3d;
    margin-bottom: 5px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.layer-item:hover {
    background: #4d4d4d;
}

.layer-item.selected {
    background: #0d99ff;
    border-color: #0b7fd9;
}

.layer-item span {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.layer-controls {
    display: flex;
    gap: 5px;
}

.layer-controls button {
    width: 24px;
    height: 24px;
    background: #2d2d2d;
    border: none;
    border-radius: 3px;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layer-controls button:hover {
    background: #1d1d1d;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #2d2d2d; }
::-webkit-scrollbar-thumb { background: #4d4d4d; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #5d5d5d; }