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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    font-size: 2rem;
    font-weight: 300;
}

.tab-nav {
    display: flex;
    background: #fff;
    border-bottom: 2px solid #e0e0e0;
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    background: #f8f9fa;
    color: #333;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: #f8f9ff;
}

.main-content {
    padding: 30px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 画像読み込みタブ */
.upload-area {
    margin-bottom: 30px;
}

.upload-box {
    border: 3px dashed #ddd;
    border-radius: 10px;
    padding: 50px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.upload-box:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.upload-box p {
    font-size: 18px;
    margin-bottom: 10px;
}

.upload-box small {
    color: #888;
}

.image-preview {
    text-align: center;
    margin-top: 20px;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* 塗りつぶし編集タブ */
#paint-edit {
    display: flex;
    gap: 20px;
}

.tools-panel {
    width: 300px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    height: fit-content;
}

.tools-panel h3 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.tool-group {
    margin-bottom: 20px;
}

.tool-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.tool-group input[type="range"] {
    width: 100%;
    margin-bottom: 5px;
}

.tool-group input[type="color"] {
    width: 60px;
    height: 40px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.tool-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

#auto-color-btn {
    margin-left: 10px;
    padding: 8px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

#auto-color-btn:hover {
    background: #5a6fd8;
}

.canvas-container {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    position: relative;
}

.canvas-controls {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-radius: 8px 8px 0 0;
}

.canvas-controls button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.canvas-controls button:hover {
    background: #f0f0f0;
}

#paint-canvas {
    display: block;
    cursor: crosshair;
    flex: 1;
    overflow: auto;
}

.canvas-viewport {
    flex: 1;
    overflow: auto;
    padding: 20px;
    background: #f9f9f9;
    background-image: 
        linear-gradient(45deg, #e0e0e0 25%, transparent 25%), 
        linear-gradient(-45deg, #e0e0e0 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #e0e0e0 75%), 
        linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* テキスト追加タブ */
#text-add {
    display: flex;
    gap: 20px;
}

.text-panel {
    width: 350px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    height: fit-content;
}

.text-panel h3 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.text-input-group {
    margin-bottom: 20px;
}

#text-input {
    width: 100%;
    height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    resize: vertical;
}

.text-style-group {
    margin-bottom: 20px;
}

.style-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.style-row label {
    font-weight: 500;
    color: #555;
    min-width: 60px;
}

.style-row select,
.style-row input[type="range"] {
    flex: 1;
}

.style-row input[type="color"] {
    width: 40px;
    height: 30px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.style-row input[type="checkbox"] {
    margin-right: 5px;
}

#add-text-btn {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

#add-text-btn:hover {
    background: #5a6fd8;
}

.text-canvas-container {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

#text-canvas {
    display: block;
    cursor: pointer;
    flex: 1;
    overflow: auto;
}

/* 保存タブ */
.save-panel {
    max-width: 600px;
    margin: 0 auto;
}

.save-panel h3 {
    margin-bottom: 20px;
    color: #333;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.save-options {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.save-options label {
    display: inline-block;
    margin-right: 10px;
    font-weight: 500;
    color: #555;
}

.save-options select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.preview-area {
    margin-bottom: 30px;
    text-align: center;
}

.preview-area h4 {
    margin-bottom: 15px;
    color: #555;
}

#final-canvas {
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

#download-btn {
    width: 100%;
    padding: 15px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 500;
}

#download-btn:hover {
    background: #218838;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .main-content {
        padding: 15px;
    }
    
    #paint-edit,
    #text-add {
        flex-direction: column;
    }
    
    .tools-panel,
    .text-panel {
        width: 100%;
        margin-bottom: 20px;
    }
    
    .tab-nav {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        flex: 1 1 50%;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    .tab-btn {
        flex: 1 1 100%;
        font-size: 14px;
        padding: 12px 15px;
    }
}

/* ツール選択ボタン */
.tool-btn {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    padding: 8px 16px;
    margin-right: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.tool-btn:hover {
    background-color: #e0e0e0;
}

.tool-btn.active {
    background-color: #667eea;
    color: white;
    border-color: #5a67d8;
}