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

:root {
    --primary-color: #0066ff;
    --primary-hover: #0052cc;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --background: #f8f9fa;
    --surface: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
    --radius: 8px;
    --radius-large: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    flex: 1;
}

header {
    text-align: center;
    margin-bottom: 48px;
    padding-top: 20px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.mode-selector {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
}

.mode-btn {
    padding: 10px 24px;
    border: 2px solid var(--border-color);
    background: var(--surface);
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.mode-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.converter-section {
    background: var(--surface);
    border-radius: var(--radius-large);
    box-shadow: var(--shadow);
    padding: 32px;
    margin-bottom: 48px;
}

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

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.action-buttons {
    display: flex;
    gap: 12px;
}

.action-btn, .copy-btn, .download-btn {
    padding: 8px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn {
    background: var(--primary-color);
    color: white;
}

.action-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.copy-btn {
    background: var(--success-color);
    color: white;
}

.copy-btn:hover {
    background: #218838;
}

.download-btn {
    background: var(--secondary-color);
    color: white;
}

.download-btn:hover {
    background: #5a6268;
}

textarea {
    width: 100%;
    min-height: 200px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-family: 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    transition: border-color 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.file-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--background);
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(0, 102, 255, 0.05);
}

.file-upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(0, 102, 255, 0.1);
}

.upload-icon {
    fill: var(--text-secondary);
    margin-bottom: 16px;
}

.file-info {
    margin-top: 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.image-preview {
    margin-top: 16px;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.output-section {
    margin-top: 24px;
}

.output-actions {
    display: flex;
    gap: 8px;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
    margin-bottom: 48px;
}

.feature {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.feature svg {
    fill: var(--primary-color);
    margin-bottom: 16px;
}

.feature h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.feature p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

footer {
    background: var(--surface);
    padding: 24px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.language-selector {
    margin-bottom: 16px;
}

.language-selector select {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--surface);
    font-size: 0.875rem;
    cursor: pointer;
}

footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .mode-selector {
        flex-wrap: wrap;
    }
    
    .mode-btn {
        flex: 1;
        min-width: 100px;
    }
    
    .converter-section {
        padding: 20px;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .features {
        grid-template-columns: 1fr;
    }
    
    textarea {
        min-height: 150px;
    }
    
    .file-upload-area {
        padding: 32px 16px;
    }
}

/* ダークモード対応（システム設定に従う） */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #1a1a1a;
        --surface: #2d2d2d;
        --text-primary: #ffffff;
        --text-secondary: #a0a0a0;
        --border-color: #404040;
        --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
    }
    
    .mode-btn {
        background: var(--surface);
        color: var(--text-primary);
    }
    
    .mode-btn:hover {
        background: var(--surface);
    }
    
    textarea {
        background: var(--surface);
        color: var(--text-primary);
    }
    
    .file-upload-area {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .file-upload-area:hover {
        background: rgba(0, 102, 255, 0.1);
    }
    
    .language-selector select {
        background: var(--surface);
        color: var(--text-primary);
    }
}