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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

.app {
    display: grid;
    grid-template-rows: 42px 1fr;
    grid-template-columns: 220px 1fr 260px;
    height: 100vh;
}

/* Toolbar */
.toolbar {
    grid-column: 1 / -1;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
}

.toolbar button {
    background: #0f3460;
    color: #e0e0e0;
    border: 1px solid #1a4080;
    border-radius: 4px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 12px;
}

.toolbar button:hover { background: #1a4080; }
.toolbar .title { font-weight: 600; font-size: 14px; color: #00b4ff; margin-right: 16px; }
.toolbar .sep { width: 1px; height: 24px; background: #0f3460; margin: 0 4px; }

/* Left Panel - Tree */
.tree-panel {
    background: #16213e;
    border-right: 1px solid #0f3460;
    overflow-y: auto;
    padding: 8px;
}

.tree-panel h3 {
    font-size: 11px;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 8px;
    padding: 0 4px;
}

.tree-page { margin-bottom: 4px; }

.tree-page-header {
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tree-page-header:hover { background: #1a4080; }
.tree-page.selected > .tree-page-header { background: #0f3460; color: #00b4ff; }
.tree-icon { font-size: 10px; }

.tree-items { padding-left: 16px; }

.tree-item {
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-item:hover { background: #1a4080; color: #e0e0e0; }
.tree-item.selected { background: #0f3460; color: #00b4ff; }

/* Center Panel - Preview */
.preview-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: #0f0f23;
    padding: 16px;
}

.canvas-wrapper {
    border: 2px solid #333;
    border-radius: 8px;
    padding: 8px;
    background: #000;
    box-shadow: 0 0 20px rgba(0, 180, 255, 0.1);
}

#oled-canvas {
    display: block;
    image-rendering: pixelated;
}

.controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.controls button {
    width: 40px;
    height: 32px;
    background: #1a1a2e;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.controls button:hover { background: #2a2a4e; border-color: #00b4ff; }
.controls button:active { background: #0f3460; }

.controls .hint-text {
    font-size: 11px;
    color: #666;
    margin-left: 8px;
}

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

.props-panel h3 {
    font-size: 13px;
    color: #00b4ff;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid #0f3460;
}

.props-panel label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
    color: #aaa;
    gap: 8px;
}

.props-panel input[type="text"],
.props-panel input[type="number"],
.props-panel select {
    background: #0f0f23;
    border: 1px solid #333;
    border-radius: 3px;
    color: #e0e0e0;
    padding: 4px 6px;
    font-size: 12px;
    width: 120px;
}

.props-panel input[type="range"] { width: 80px; }
.props-panel input[type="checkbox"] { width: auto; }

.props-panel .prop-actions {
    margin-top: 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.props-panel .prop-actions button {
    background: #0f3460;
    border: 1px solid #1a4080;
    color: #e0e0e0;
    border-radius: 3px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
}

.props-panel .prop-actions button:hover { background: #1a4080; }
.props-panel .hint { color: #666; font-size: 12px; text-align: center; margin-top: 40px; }

/* Code Panel */
.code-panel {
    position: fixed;
    bottom: -50%;
    left: 0;
    right: 0;
    height: 45%;
    background: #0f0f23;
    border-top: 2px solid #0f3460;
    transition: bottom 0.3s;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.code-panel.open { bottom: 0; }

.code-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #16213e;
    border-bottom: 1px solid #0f3460;
}

.code-panel-header span { font-size: 13px; font-weight: 600; color: #00b4ff; }

.code-panel-header button {
    background: #0f3460;
    border: 1px solid #1a4080;
    color: #e0e0e0;
    border-radius: 3px;
    padding: 4px 10px;
    font-size: 11px;
    cursor: pointer;
}

#code-output {
    flex: 1;
    overflow: auto;
    padding: 12px 16px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    white-space: pre;
    color: #b0b0b0;
    line-height: 1.5;
}
