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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    background: #1a1a2e;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
}

#app {
    display: grid;
    grid-template-columns: 220px 1fr 240px;
    height: 100vh;
}

/* Library Panel */
#library-panel {
    background: #16213e;
    border-right: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#library-panel h3 {
    padding: 10px 12px 6px;
    font-size: 14px;
    color: #e94560;
}

#library-tabs {
    display: flex;
    gap: 2px;
    padding: 0 8px 8px;
    flex-wrap: wrap;
}

#library-tabs button {
    flex: 1;
    padding: 4px 6px;
    font-size: 11px;
    background: #0f3460;
    color: #ccc;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    min-width: 50px;
}

#library-tabs button.active {
    background: #e94560;
    color: #fff;
}

#library-grid {
    flex: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px 8px;
    align-content: start;
}

.lib-thumb {
    aspect-ratio: 1;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: outline 0.15s;
}

.lib-thumb:hover {
    outline: 2px solid #e94560;
}

.lib-thumb svg {
    width: 100%;
    height: 100%;
}

/* Canvas Area */
#canvas-area {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0a0a1a;
}

#toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    flex-wrap: wrap;
}

#toolbar label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

#toolbar input[type="text"] {
    width: 140px;
    padding: 3px 6px;
    background: #0f3460;
    color: #fff;
    border: 1px solid #333;
    border-radius: 3px;
}

#toolbar input[type="number"] {
    width: 50px;
    padding: 3px 4px;
    background: #0f3460;
    color: #fff;
    border: 1px solid #333;
    border-radius: 3px;
    text-align: center;
}

#toolbar input[type="color"] {
    width: 28px;
    height: 24px;
    border: 1px solid #333;
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
    background: none;
}

#toolbar button {
    padding: 4px 10px;
    background: #0f3460;
    color: #ddd;
    border: 1px solid #1a4a8a;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

#toolbar button:hover {
    background: #1a4a8a;
}

.separator {
    width: 1px;
    height: 20px;
    background: #333;
}

#canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

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

/* Props Panel */
#props-panel {
    background: #16213e;
    border-left: 1px solid #0f3460;
    overflow-y: auto;
    padding: 10px 12px;
}

#props-panel h3 {
    font-size: 14px;
    color: #e94560;
    margin-bottom: 8px;
}

#props-panel hr {
    border: none;
    border-top: 1px solid #0f3460;
    margin: 12px 0;
}

#no-selection-msg {
    color: #666;
    font-style: italic;
    font-size: 12px;
}

#props-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 12px;
}

#props-controls input[type="range"] {
    flex: 1;
    accent-color: #e94560;
}

#props-controls span {
    min-width: 36px;
    text-align: right;
    font-size: 11px;
    color: #aaa;
}

.prop-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.prop-buttons button {
    flex: 1;
    min-width: 70px;
    padding: 4px 6px;
    font-size: 11px;
    background: #0f3460;
    color: #ddd;
    border: 1px solid #1a4a8a;
    border-radius: 3px;
    cursor: pointer;
}

.prop-buttons button:hover { background: #1a4a8a; }
.prop-buttons button#btn-delete-element { background: #7a1a1a; border-color: #a33; }
.prop-buttons button#btn-delete-element:hover { background: #a33; }

.hidden { display: none !important; }

/* Donut config */
#donut-config { }

#btn-add-ring {
    width: 100%;
    padding: 6px;
    margin-bottom: 8px;
    background: #0f3460;
    color: #ddd;
    border: 1px solid #1a4a8a;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

#btn-add-ring:hover { background: #1a4a8a; }

.ring-item {
    background: #0d1b3e;
    border: 1px solid #0f3460;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 6px;
}

.ring-item label {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    font-size: 11px;
}

.ring-item input[type="range"] {
    flex: 1;
    accent-color: #e94560;
}

.ring-item input[type="number"] {
    width: 48px;
    padding: 2px 3px;
    background: #0f3460;
    color: #fff;
    border: 1px solid #333;
    border-radius: 3px;
    text-align: center;
    font-size: 11px;
}

.ring-item input[type="color"] {
    width: 24px;
    height: 20px;
    border: 1px solid #333;
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.ring-item select {
    flex: 1;
    padding: 2px 4px;
    background: #0f3460;
    color: #fff;
    border: 1px solid #333;
    border-radius: 3px;
    font-size: 11px;
}

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

.ring-header span {
    font-weight: bold;
    font-size: 12px;
}

.ring-remove {
    background: #7a1a1a;
    color: #fff;
    border: none;
    border-radius: 3px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 11px;
}

.ring-remove:hover { background: #a33; }

/* Load dialog */
dialog {
    background: #16213e;
    color: #e0e0e0;
    border: 1px solid #0f3460;
    border-radius: 8px;
    padding: 20px;
    min-width: 300px;
    max-height: 60vh;
}

dialog::backdrop { background: rgba(0,0,0,0.6); }

#load-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.load-item {
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 2px;
}

.load-item:hover { background: #0f3460; }

/* PDF dialog */
#pdf-dialog { min-width: 380px; }

#pdf-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

#pdf-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

#pdf-options select, #pdf-options input[type="range"] {
    flex: 1;
    accent-color: #e94560;
}

#pdf-options select {
    padding: 4px;
    background: #0f3460;
    color: #fff;
    border: 1px solid #333;
    border-radius: 3px;
}

#pdf-options span {
    min-width: 40px;
    text-align: right;
    font-size: 11px;
    color: #aaa;
}

#pdf-preview-container {
    display: flex;
    justify-content: center;
    padding: 10px;
    background: #555;
    border-radius: 4px;
}

#pdf-preview-page {
    background: #fff;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    overflow: hidden;
}

#pdf-preview-mandala {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, #ddd 60%, #bbb);
    border: 1px dashed #999;
}

#pdf-export-go {
    padding: 8px 20px;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

#pdf-export-go:hover { background: #c73a52; }

#pdf-dialog-close {
    padding: 8px 20px;
    background: #0f3460;
    color: #ddd;
    border: 1px solid #1a4a8a;
    border-radius: 4px;
    cursor: pointer;
}

#load-dialog-close {
    padding: 6px 16px;
    background: #0f3460;
    color: #ddd;
    border: 1px solid #1a4a8a;
    border-radius: 4px;
    cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a1a; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* Selection handles */
.selection-handle {
    pointer-events: none;
}

.selection-rect {
    fill: none;
    stroke: #e94560;
    stroke-width: 1;
    stroke-dasharray: 4 2;
    pointer-events: none;
}
