/* ベースレイアウト */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* アプリケーション全体 */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

.app__header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 2px solid #e1e5e9;
}

.app__title {
    color: #2c3e50;
    font-size: 2.5rem;
    font-weight: 300;
    margin: 0;
}

.app__main {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* アップロードセクション */
.upload-section {
    margin-bottom: 2rem;
    text-align: center;
}

.upload-section__input {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 1rem;
    padding: 1rem;
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    background: #f8fafc;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.upload-section__input:hover {
    border-color: #4299e1;
    background: #ebf8ff;
}

.upload-section__input:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

/* ステータス表示 */
.status {
    font-size: 1.1rem;
    font-weight: 500;
    color: #4a5568;
    margin: 1rem 0;
}

.error {
    color: #e53e3e;
    background-color: #fed7d7;
    border: 1px solid #feb2b2;
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin: 1rem auto;
    max-width: 500px;
    font-weight: 500;
}

/* ツール選択セクション */
.tool-selection {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.tool-section h3 {
    margin: 0 0 1rem 0;
    color: #2d3748;
    font-size: 1.1rem;
    font-weight: 600;
}

.tool-selection__options {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background: white;
    border: 2px solid #e2e8f0;
    transition: all 0.2s ease;
}

.radio-option:hover {
    border-color: #cbd5e0;
}

.radio-option input[type="radio"] {
    margin-right: 0.5rem;
    accent-color: #4299e1;
}

.radio-option input[type="radio"]:checked+span {
    font-weight: 600;
    color: #2b6cb0;
}

/* モザイク設定 */
.mosaic-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.slider-control {
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    padding: 0.75rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    transition: border-color 0.2s ease;
}

.slider-control:hover {
    border-color: #cbd5e0;
}

.slider-control__label {
    font-weight: 500;
    color: #4a5568;
    min-width: 50px;
}

.slider-control__slider {
    flex: 1;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    appearance: none;
}

.slider-control__slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: #4299e1;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.slider-control__slider::-webkit-slider-thumb:hover {
    background: #3182ce;
}

.slider-control__slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #4299e1;
    border-radius: 50%;
    border: none;
    cursor: pointer;
}

.slider-control__value {
    font-weight: 600;
    color: #2d3748;
    min-width: 40px;
    text-align: right;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .tool-selection {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .tool-selection__options {
        flex-direction: column;
        gap: 0.5rem;
    }

    .slider-control {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
        text-align: center;
    }

    .slider-control__label,
    .slider-control__value {
        min-width: auto;
    }
}

/* キャンバスセクション */
.canvas-section {
    text-align: center;
    margin: 2rem 0;
    position: relative;
}

.canvas-section__canvas,
.canvas-section__overlay {
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: none;
    transition: all 0.3s ease;
    margin: 0 auto;
}

.canvas-section__canvas.visible,
.canvas-section__overlay.visible {
    display: block;
}

.canvas-section__overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    border: none;
    box-shadow: none;
    z-index: 10;
}

/* コントロールボタン */
.controls {
    text-align: center;
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.controls__group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn {
    padding: 0.875rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 140px;
    position: relative;
    overflow: hidden;
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn--primary {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
}

.btn--primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #3182ce 0%, #2c5aa0 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(49, 130, 206, 0.3);
}

.btn--secondary {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
}

.btn--secondary:hover:not(:disabled) {
    background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(56, 161, 105, 0.3);
}

.btn--neutral {
    background: linear-gradient(135deg, #718096 0%, #4a5568 100%);
    color: white;
}

.btn--neutral:hover:not(:disabled) {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(74, 85, 104, 0.3);
}

.btn--icon {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    min-width: 80px;
}

.btn--icon:disabled {
    opacity: 0.4;
}

/* プログレスバー */
.progress {
    width: 100%;
    height: 6px;
    background-color: #e2e8f0;
    border-radius: 3px;
    margin: 1rem 0;
    overflow: hidden;
    display: none;
}

.progress__bar {
    height: 100%;
    background: linear-gradient(90deg, #4299e1, #3182ce);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .app {
        padding: 10px;
    }

    .app__title {
        font-size: 2rem;
    }

    .app__main {
        padding: 1.5rem;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 300px;
    }
}

@media (max-width: 480px) {
    .app__title {
        font-size: 1.75rem;
    }

    .app__main {
        padding: 1rem;
    }
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* ローディング状態 */
.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}