/* ========================================
   Design System & CSS Variables
   ======================================== */
:root {
    /* Color Palette - 洗練された水色系デザイン */
    --color-primary: hsl(200, 75%, 50%);
    --color-primary-dark: hsl(200, 75%, 42%);
    --color-primary-light: hsl(200, 75%, 58%);
    --color-secondary: hsl(190, 65%, 48%);
    --color-accent: hsl(210, 70%, 55%);
    
    /* Gradients - 洗練されたグラデーション */
    --gradient-primary: linear-gradient(135deg, #00bcd4 0%, #0097a7 100%);
    --gradient-secondary: linear-gradient(135deg, #26c6da 0%, #00acc1 100%);
    --gradient-success: linear-gradient(135deg, #4dd0e1 0%, #00bcd4 100%);
    
    /* Neutral Colors - 指定された色 */
    --color-bg: #3dcaf8;
    --color-bg-secondary: #36b8e0;
    --color-bg-tertiary: #2fa6c8;
    --color-surface: #4dd0f9;
    --color-surface-hover: #5dd6fa;
    
    /* Text Colors - 読みやすいテキスト */
    --color-text-primary: hsl(200, 30%, 20%);
    --color-text-secondary: hsl(200, 20%, 40%);
    --color-text-tertiary: hsl(200, 15%, 60%);
    
    /* Border & Divider */
    --color-border: hsl(195, 30%, 80%);
    --color-border-light: hsl(195, 25%, 88%);
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    --spacing-2xl: 4rem;
    
    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 24px rgba(0, 188, 212, 0.25);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Reset & Base Styles
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(0, 188, 212, 0.06) 0%, transparent 60%),
        radial-gradient(circle at 80% 80%, rgba(0, 151, 167, 0.06) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* ========================================
   Header
   ======================================== */
.header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    animation: fadeInDown 0.6s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.logo h1 {
    font-size: 2.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #ffffff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

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

/* ========================================
   Sections
   ======================================== */
.section {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

.section.active {
    display: block;
}

/* ========================================
   Cards
   ======================================== */
.upload-card,
.editor-card {
    background: #d9f4fd;
    border: 1px solid #c4e8f9;
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    box-shadow: 0 4px 20px rgba(0, 188, 212, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
    transition: all var(--transition-base);
}

.upload-card:hover,
.editor-card:hover {
    box-shadow: 0 8px 30px rgba(0, 188, 212, 0.18), 0 2px 6px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-header {
    margin-bottom: var(--spacing-lg);
}

.step-badge {
    display: inline-block;
    background: var(--gradient-primary);
    color: white;
    padding: 0.25rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    box-shadow: var(--shadow-glow);
}

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

/* ========================================
   Upload Area
   ======================================== */
.upload-area {
    border: 2px dashed var(--color-border-light);
    border-radius: var(--radius-md);
    padding: var(--spacing-2xl);
    text-align: center;
    background: #ffffff;
    transition: all var(--transition-base);
    cursor: pointer;
    margin-bottom: var(--spacing-lg);
}

.upload-area:hover {
    border-color: var(--color-primary);
    background: #ffffff;
    transform: translateY(-2px);
}

.upload-area.drag-over {
    border-color: var(--color-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(0, 188, 212, 0.15), 0 4px 12px rgba(0, 188, 212, 0.1);
}

.upload-icon {
    color: var(--color-primary);
    margin-bottom: var(--spacing-sm);
    animation: bounce 2s ease-in-out infinite;
}

.upload-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: var(--spacing-xs);
}

.upload-subtext {
    color: var(--color-text-tertiary);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-md);
}

/* ========================================
   Size Inputs
   ======================================== */
.size-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.input-group input {
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    color: var(--color-text-primary);
    transition: all var(--transition-fast);
    font-family: inherit;
}

.input-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 188, 212, 0.12), 0 2px 8px rgba(0, 188, 212, 0.08);
}

.input-group input:hover {
    border-color: var(--color-border-light);
}

/* ========================================
   Preset Sizes
   ======================================== */
.preset-sizes {
    margin-bottom: var(--spacing-lg);
}

.preset-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-sm);
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-sm);
}

.btn-preset {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    font-weight: 500;
}

.btn-preset:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-primary);
    transform: translateY(-1px);
}

.btn-preset:active {
    transform: translateY(0);
}

/* ========================================
   Buttons
   ======================================== */
.btn-primary {
    background: #0522fb;
    border: none;
    border-radius: var(--radius-sm);
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
    width: 100%;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.btn-secondary:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-light);
    transform: translateY(-1px);
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    padding: var(--spacing-sm);
    transition: color var(--transition-fast);
    font-family: inherit;
    margin-top: var(--spacing-md);
}

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

/* ========================================
   Editor
   ======================================== */
.editor-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-md);
    background: #ffffff;
    border-radius: var(--radius-sm);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

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

.size-display {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.size-label {
    color: var(--color-text-tertiary);
    font-size: 0.875rem;
}

.size-value {
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.875rem;
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 600px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--spacing-lg);
    border: 1px solid var(--color-border);
}

#editor-canvas {
    position: absolute;
    cursor: move;
    user-select: none;
}

.crop-frame {
    position: absolute;
    border: 3px solid var(--color-primary);
    box-shadow: 
        0 0 0 9999px rgba(0, 0, 0, 0.6),
        0 0 20px rgba(102, 126, 234, 0.5),
        inset 0 0 20px rgba(102, 126, 234, 0.2);
    pointer-events: none;
    z-index: 10;
}

.crop-frame::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.resize-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--color-primary);
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: all;
    cursor: nwse-resize;
    z-index: 11;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease;
}

.resize-handle:hover {
    transform: scale(1.2);
    background: var(--color-primary-light);
}

.resize-handle-nw {
    top: -8px;
    left: -8px;
    cursor: nwse-resize;
}

.resize-handle-ne {
    top: -8px;
    right: -8px;
    cursor: nesw-resize;
}

.resize-handle-sw {
    bottom: -8px;
    left: -8px;
    cursor: nesw-resize;
}

.resize-handle-se {
    bottom: -8px;
    right: -8px;
    cursor: nwse-resize;
}

.editor-controls {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.editor-controls .btn-secondary {
    flex-shrink: 0;
}

.editor-controls .btn-primary {
    flex: 1;
}

/* ========================================
   Footer
   ======================================== */
.footer {
    text-align: center;
    margin-top: var(--spacing-2xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
    color: var(--color-text-tertiary);
    font-size: 0.875rem;
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-md);
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .upload-card,
    .editor-card {
        padding: var(--spacing-lg);
    }
    
    .size-inputs {
        grid-template-columns: 1fr;
    }
    
    .preset-buttons {
        grid-template-columns: 1fr;
    }
    
    .canvas-container {
        height: 400px;
    }
    
    .editor-controls {
        flex-direction: column;
    }
    
    .editor-controls .btn-secondary,
    .editor-controls .btn-primary {
        width: 100%;
    }
    
    .editor-info {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.875rem;
    }
    
    .canvas-container {
        height: 300px;
    }
}
