/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
}

#loading-overlay p {
    margin-top: 20px;
    font-size: 1.1rem;
    line-height: 1.5;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ... existing styles ... */
:root {
    /* Light Mode (Default) */
    --bg-color: #ffffff;
    --surface-color: #f9f9f9;
    --border-color: #e5e5e5;
    --primary-text-color: #111111;
    --secondary-text-color: #666666;
    --accent-color: #ff0000;
    --highlight-bg: #f1f1f1;
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --border-color: #333;
    --primary-text-color: #e0e0e0;
    --secondary-text-color: #aaaaaa;
    --accent-color: #ff0000;
    --highlight-bg: #2a2a2a;
}

body {
    font-family: 'Pretendard', sans-serif;
    background-color: var(--bg-color);
    color: var(--primary-text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    transition: background-color 0.3s, color 0.3s;
}

/* ... existing scrollbar styles ... */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.app-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 100vh;
}

.app-header {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Space between title and toggle */
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Theme Toggle Button */
.icon-btn {
    background: none;
    border: none;
    color: var(--primary-text-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: var(--border-color);
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Controls Panel */
.controls-panel {
    width: 380px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: auto;
    flex-shrink: 0;
}

/* ... existing control styles ... */
.control-group {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}
/* ... */

.canvas-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: repeating-conic-gradient(var(--bg-color) 0% 25%, var(--surface-color) 0% 50%) 50% / 32px 32px;
}

/* ... existing styles ... */

/* Mobile Optimization Enhancements */
@media (max-width: 900px) {
    body {
        overflow-y: auto; /* Ensure body scrolls */
    }

    .app-container {
        height: auto; /* Remove fixed height constraint */
        min-height: 100vh;
        overflow: visible;
    }

    .main-content {
        flex-direction: column-reverse; /* Canvas top (visually), Controls bottom (in DOM flow? No, column-reverse puts bottom element on top. 
                                           Wait, HTML structure is Controls then Canvas. 
                                           column-reverse puts Canvas (2nd child) on TOP, Controls (1st child) on BOTTOM.
                                           So Canvas is visually first. Correct. */
        overflow: visible; /* Remove internal scroll */
        height: auto;
    }

    /* Sticky Canvas Section */
    .canvas-section {
        position: sticky;
        top: 0;
        z-index: 100; /* Stay on top of controls */
        padding: 0.5rem;
        min-height: auto;
        background: var(--bg-color); /* Match bg to hide content behind */
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); /* Shadow for separation */
    }

    .canvas-wrapper {
        width: 100%;
        max-width: 100%;
        /* Limit height to leave room for controls (e.g., 40% of viewport) */
        max-height: 40vh; 
        aspect-ratio: 16 / 9;
        margin: 0 auto;
    }
    
    /* Controls Panel */
    .controls-panel {
        width: 100%;
        border-right: none;
        border-top: none; /* Separated by canvas border */
        padding: 1.5rem 1rem;
        overflow: visible; /* Scroll with page */
        background-color: var(--surface-color);
        /* Add enough bottom padding for scrolling past content */
        padding-bottom: 50px;
    }

    .app-header {
        padding: 0.8rem 1rem;
        /* Let header scroll away naturally */
    }
    
    .app-header h1 {
        font-size: 1.1rem;
    }

    .multi-file-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.multi-file-input input[type="file"] {
    font-size: 0.9rem;
    padding: 0.5rem;
}

.control-group h2 {
        font-size: 1.1rem;
    }

    input[type="range"] {
        height: 24px;
    }
    
    input[type="text"], input[type="file"], select, button {
        padding: 10px;
        font-size: 16px;
    }

    .info-section {
        padding: 40px 15px;
    }
    
    .info-section h2 {
        font-size: 1.3rem;
    }
}

.canvas-wrapper {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    max-width: 100%; /* 반응형 대비 */
}

#thumbnailCanvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.download-wrapper {
    margin-top: 2rem;
    width: 300px;
}

/* Info Section (SEO & Content) */
.info-section {
    background-color: #f9f9f9;
    padding: 60px 20px;
    border-top: 1px solid #e5e5e5;
    color: #333;
}

.info-container {
    max-width: 1000px;
    margin: 0 auto;
}

.info-section article {
    margin-bottom: 40px;
}

.info-section h2 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #111;
    border-left: 5px solid #065fd4; /* YouTube Blue accent */
    padding-left: 15px;
}

.info-section p, .info-section li, .info-section dd {
    font-size: 1rem;
    line-height: 1.7;
    color: #555;
}

.info-section ul, .info-section ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.info-section li {
    margin-bottom: 8px;
}

.info-section dt {
    font-weight: 700;
    margin-top: 15px;
    color: #333;
}

.info-section dd {
    margin-left: 0;
    margin-bottom: 10px;
}

/* Footer */
.site-footer {
    background-color: #1f1f1f;
    color: #aaa;
    padding: 30px 20px;
    text-align: center;
    font-size: 0.9rem;
}

.footer-content nav {
    margin-top: 10px;
}

.footer-content a {
    color: #fff;
    text-decoration: none;
    margin: 0 10px;
    transition: color 0.3s;
}

.footer-content a:hover {
    color: #3ea6ff;
    text-decoration: underline;
}

/* Dark Mode Support for new sections (if global dark theme is on) */
/* Assuming the root variables set dark mode, we just ensure readability */
/* However, info-section forces light bg by default for readability contrast, 
   but if we want full dark mode consistency: */

@media (prefers-color-scheme: dark) {
    .info-section {
        background-color: #121212;
        color: #e0e0e0;
        border-top: 1px solid #333;
    }
    .info-section h2 {
        color: #fff;
    }
    .info-section p, .info-section li, .info-section dd {
        color: #bbb;
    }
    .info-section dt {
        color: #e0e0e0;
    }
}

/* Sample Image Preview Styles */
.sample-image-container {
    margin-bottom: 1.5rem;
    text-align: center;
    background-color: var(--highlight-bg);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.sample-thumb {
    width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    display: block;
    margin-bottom: 8px;
}

.sample-label {
    font-size: 0.85rem;
    color: var(--secondary-text-color);
    margin: 0;
    font-weight: 500;
}