:root {
    --bg-color: #1e1e1e;
    --sidebar-bg: #252526;
    --header-bg: #323233;
    --accent-color: #007acc;
    --text-color: #cccccc;
    --border-color: #3f3f3f;
    --toolbar-width: 50px;
    --sidebar-width: 300px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
#header {
    height: 40px;
    background-color: var(--header-bg);
    display: flex;
    align-items: center;
    padding: 0 15px;
    border-bottom: 1px solid var(--border-color);
    justify-content: space-between;
}

.logo {
    font-weight: bold;
    color: var(--accent-color);
}

.toolbar-top button {
    background: transparent;
    border: none;
    color: var(--text-color);
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
}

.toolbar-top button:hover {
    background-color: var(--border-color);
}

.grid-settings {
    display: flex;
    gap: 10px;
    font-size: 12px;
}

.grid-settings label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

/* Main Layout */
#main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Sidebar */
#toolbar-left {
    width: var(--toolbar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 10px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    margin-bottom: 8px;
    background-color: transparent;
    border: 1px solid transparent;
    color: var(--text-color);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.tool-btn svg {
    pointer-events: none;
}

.tool-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

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

/* Canvas Area */
#canvas-area {
    flex: 1;
    background-color: #121212;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
    position: relative;
    overscroll-behavior: contain;
    user-select: none;
}

#canvas-container {
    background-color: #000;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    line-height: 0;
}

#svg-canvas {
    /* cursor set via js */
    touch-action: none;
}

.cursor-crosshair { cursor: crosshair; }
.cursor-default { cursor: default; }
.cursor-move { cursor: move; }

/* Resize Handles */
.resize-handle {
    fill: white;
    stroke: var(--accent-color);
    stroke-width: 1px;
}

.control-handle {
    fill: #ffcc00;
    stroke: white;
    stroke-width: 1px;
    cursor: ew-resize;
}

.cursor-nwse { cursor: nwse-resize; }
.cursor-nesw { cursor: nesw-resize; }
.cursor-ew { cursor: ew-resize; }
.cursor-ns { cursor: ns-resize; }

/* Right Sidebar */
#sidebar-right {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.properties-panel {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
}

h3 {
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 10px;
    color: #888;
}

.prop-group {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.prop-group label {
    flex: 1;
    font-size: 13px;
}

.prop-group input {
    width: 60px;
    background: #3c3c3c;
    border: 1px solid var(--border-color);
    color: white;
    padding: 2px;
}

/* Properties Panel Improved */
.panel-section {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #333;
}

.panel-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 11px;
    font-weight: bold;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 13px;
}

.control-row label {
    color: #ccc;
    min-width: 60px;
}

.color-picker {
    width: 100%;
    height: 24px;
    padding: 0;
    border: none;
    cursor: pointer;
    background: transparent;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.slider-group input[type="range"] {
    flex: 1;
    height: 4px;
    background: #444;
    border-radius: 2px;
    outline: none;
}

.num-input-sm {
    width: 45px !important;
    text-align: right;
    padding: 2px 4px;
}

.multi-col {
    gap: 10px;
}

.col {
    flex: 1;
}

.sub-label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.col select {
    width: 100%;
    background: #3c3c3c;
    border: 1px solid var(--border-color);
    color: white;
    padding: 4px;
    border-radius: 4px;
}


/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--sidebar-bg);
    padding: 20px;
    border-radius: 8px;
    width: 400px;
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 18px;
}

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

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
}

.input-group input, .input-group select {
    width: 100%;
    background: #3c3c3c;
    border: 1px solid var(--border-color);
    color: white;
    padding: 8px;
    border-radius: 4px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-footer button {
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
}

#btn-settings-save {
    background-color: var(--accent-color);
    color: white;
}

#btn-settings-close {
    background-color: var(--border-color);
    color: var(--text-color);
}

/* Footer */
#footer {
    height: 25px;
    background-color: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 11px;
    justify-content: space-between;
}

#privacy-link {
    color: white;
    text-decoration: none;
    opacity: 0.9;
}

#privacy-link:hover {
    text-decoration: underline;
    opacity: 1;
}

/* Responsive */
@media (max-width: 900px) {
    body {
        overflow: auto;
        height: auto;
    }

    #app {
        height: auto;
        min-height: 100vh;
    }

    #header {
        height: auto;
        padding: 8px 10px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .toolbar-top {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .grid-settings {
        flex-wrap: wrap;
        gap: 8px;
    }

    #main-container {
        flex-direction: column;
        min-height: 0;
        overflow: visible;
    }

    #toolbar-left {
        width: 100%;
        height: 56px;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 6px 8px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .tool-btn {
        width: 44px;
        height: 44px;
        margin-bottom: 0;
        margin-right: 8px;
        flex: 0 0 auto;
    }

    #sidebar-right {
        width: 100%;
        height: auto;
        max-height: none;
        min-height: 0;
        border-left: none;
        border-top: 1px solid var(--border-color);
        overflow: visible;
    }

    .modal-content {
        width: min(92vw, 400px);
        max-height: 80vh;
        overflow: auto;
    }

    #canvas-container {
        max-width: 100%;
    }

    #svg-canvas {
        width: 100%;
        height: auto;
    }
}

@media (max-width: 600px) {
    .logo {
        font-size: 12px;
    }

    .toolbar-top button {
        padding: 6px 8px;
        font-size: 12px;
    }

    .grid-settings {
        font-size: 11px;
    }

    #canvas-area {
        padding: 6px;
    }
}
