/* Reset and Base Styles */
body, html {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Hiragino Sans', 'Noto Sans CJK JP', 'Yu Gothic', sans-serif;
    background-color: #f0f2f5;
    color: #333;
}

.main-container {
    display: flex;
    align-items: flex-start;
}

/* Left Column: Editor (Scrollable) */
.left-pane {
    flex-grow: 1;
    padding: 20px;
}

.editor-container {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.editor-container h2 {
    margin-top: 0;
}

.editor-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

/* Right Column: Preview (Sticky) */
.right-pane {
    width: 320px;
    flex-shrink: 0;
    padding: 20px;
}

.preview-container {
    position: sticky;
    top: 20px;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.preview-container h2, .preview-container h3 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

#preview-canvas {
    width: 100%;
    height: auto;
    border: 1px solid #ddd;
    image-rendering: pixelated; /* Keep pixels sharp */
}

.direction-controls, .export-controls {
    margin-top: 15px;
}

.direction-controls button, .export-controls button {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
}

.direction-controls button:hover, .export-controls button:hover {
    background-color: #e9e9e9;
}

.control-group, .control-group-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

#color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.color-box {
    width: 28px;
    height: 28px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.color-box.selected {
    border-color: #007aff;
    box-shadow: 0 0 5px #007aff;
}

.canvas-grid-container {
    overflow-x: auto;
}

.canvas-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
    min-width: 1100px;
}

.canvas-slot {
    position: relative;
    width: 256px;
    height: 320px; /* Increased height for buttons */
    text-align: center;
}

.canvas-slot span {
    display: block;
    margin-top: 260px;
    font-size: 14px;
    color: #555;
    margin-bottom: 8px;
}

.canvas-slot canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 256px;
    height: 256px;
    image-rendering: pixelated; /* Keep pixels sharp */
    background-color: transparent;
    border-radius: 4px;
}

.drawing-canvas {
    z-index: 10;
    border: 1px solid #ccc;
    /* Grid background */
    background-image: 
        linear-gradient(45deg, #eee 25%, transparent 25%), 
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 20px 20px; /* Controls grid density */
    background-position: -10px 0, -10px 0, 0 -10px, 0 -10px;
    cursor: crosshair;
}

.guide-canvas {
    z-index: 5;
    opacity: 0.35;
    pointer-events: none;
}

.drawing-canvas.active {
    border: 3px solid #007aff;
    box-shadow: 0 0 10px rgba(0, 122, 255, 0.5);
}

/* Frame-specific import/export buttons */
.frame-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.frame-button {
    padding: 6px 12px;
    border: 1px solid #ccc;
    background-color: #f9f9f9;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.frame-button:hover {
    background-color: #e9e9e9;
}
