/* 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: none; /* Changed from flex to none */
    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: visible;
}

/* Controls Panel */
.controls-panel {
    width: 380px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    overflow-y: visible;
    flex-shrink: 0;
    position: relative;
    z-index: 10; /* Ensure it stays on top of sticky canvas */
}

/* ... 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; <-- Remove centering to allow top alignment for sticky */
    align-items: center;
    padding: 2rem;
    background: repeating-conic-gradient(var(--bg-color) 0% 25%, var(--surface-color) 0% 50%) 50% / 32px 32px;
    
    /* Sticky Magic */
    position: sticky;
    top: 0;
    align-self: flex-start; /* Important for flex child sticky */
    height: 100vh; /* Fill viewport height */
    overflow-y: auto; /* Allow scrolling inside canvas section if it gets too tall (e.g. on small screens) */
}

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

/* Mobile Optimization Enhancements */
@media (max-width: 900px) {
    body {
        height: auto;
        min-height: 100vh;
        display: block;
        overflow-y: visible;
    }

    .app-container {
        height: auto;
        min-height: auto;
        display: block;
        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;
        height: auto; /* Reset height for mobile */
        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: 100%; /* Full width to allow flex items to distribute */
    max-width: 300px; /* Keep max-width for larger screens */
    display: flex;
    gap: 10px; /* Space between buttons */
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
    justify-content: center; /* Center buttons horizontally */
}

/* Buttons */
.action-btn, .primary-btn {
    flex: 1; /* Allow buttons to grow and shrink */
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Pretendard', sans-serif;
    white-space: nowrap; /* Prevent text wrapping inside buttons */
}

.action-btn {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--primary-text-color);
    margin-top: 0; /* Remove top margin for flex consistency */
}
.action-btn:hover {
    background-color: var(--border-color);
}
.action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.primary-btn {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.3);
    margin-top: 0; /* Ensure consistent spacing in flex container */
}
.primary-btn:hover {
    background-color: #d00000;
    transform: translateY(-2px);
}

/* Info Section (Enhanced for Publisher Content) */
.info-section {
    background-color: var(--bg-color);
    padding: 80px 20px;
    border-top: 1px solid var(--border-color);
}

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

.content-header {
    text-align: center;
    margin-bottom: 60px;
}

.content-header h2 {
    font-size: 2.2rem;
    margin-bottom: 15px;
    color: var(--primary-text-color);
    border: none;
    padding: 0;
}

.content-header p {
    font-size: 1.2rem;
    color: var(--secondary-text-color);
}

.content-article {
    margin-bottom: 60px;
    line-height: 1.8;
}

.content-article h3 {
    font-size: 1.5rem;
    margin-top: 40px;
    margin-bottom: 20px;
    color: var(--primary-text-color);
    border-left: 4px solid var(--accent-color);
    padding-left: 15px;
}

.content-article h4 {
    font-size: 1.2rem;
    margin-top: 30px;
    margin-bottom: 10px;
    color: var(--primary-text-color);
}

.content-article p {
    margin-bottom: 20px;
    font-size: 1.05rem;
    color: var(--secondary-text-color);
}

.content-article ul {
    background: var(--surface-color);
    padding: 25px 40px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.content-article li {
    margin-bottom: 12px;
    color: var(--secondary-text-color);
}

.content-article strong {
    color: var(--primary-text-color);
    font-weight: 700;
}

.content-article dl {
    background: var(--surface-color);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.content-article dt {
    color: var(--accent-color);
    font-weight: 700;
    margin-top: 20px;
    font-size: 1.1rem;
}
.content-article dt:first-child {
    margin-top: 0;
}

.content-article dd {
    margin-left: 0;
    margin-top: 5px;
    margin-bottom: 10px;
    color: var(--secondary-text-color);
}

.content-footer {
    text-align: center;
    margin-top: 80px;
    padding-top: 40px;
    border-top: 1px solid var(--border-color);
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--primary-text-color);
}

/* 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;
    }
}

/* Collapsible Sample Section */
.sample-details {
    background-color: var(--highlight-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.sample-details summary {
    padding: 12px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--primary-text-color);
}

.sample-details summary::-webkit-details-marker {
    display: none;
}

.sample-details summary::after {
    content: '+';
    font-size: 1.2rem;
    font-weight: bold;
}

.sample-details[open] summary::after {
    content: '-';
}

.sample-details[open] summary {
    border-bottom: 1px solid var(--border-color);
}

/* Sample Image Preview Styles */
.sample-image-container {
    text-align: center;
    padding: 15px;
}

.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;
}

/* --- Global Navigation --- */
.global-nav {
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-text-color);
    text-decoration: none;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 30px;
    margin: 0;
    padding: 0;
}

.nav-links a {
    text-decoration: none;
    color: var(--secondary-text-color);
    font-weight: 500;
    font-size: 1rem;
    transition: color 0.2s;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--accent-color);
}

.nav-cta {
    background-color: var(--accent-color);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.nav-cta:hover {
    background-color: #d00000;
}

/* --- Hero Section (Landing) --- */
.hero-section {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: white;
    padding: 100px 20px;
    text-align: center;
}

.hero-content h1 {
    font-size: 3.5rem;
    margin-bottom: 20px;
    line-height: 1.2;
}

.hero-content p {
    font-size: 1.2rem;
    color: #ccc;
    margin-bottom: 40px;
    line-height: 1.6;
}

.hero-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.big-btn {
    display: inline-block;
    padding: 15px 30px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

.secondary-btn {
    background-color: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}
.secondary-btn:hover {
    background-color: rgba(255,255,255,0.2);
}

/* --- How It Works --- */
.how-it-works {
    padding: 80px 20px;
    background-color: var(--bg-color);
}

.section-title {
    text-align: center;
    font-size: 2.2rem;
    margin-bottom: 50px;
    color: var(--primary-text-color);
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px;
    max-width: 1000px;
    margin: 0 auto;
}

.step {
    text-align: center;
    position: relative;
}

.step-num {
    font-size: 4rem;
    font-weight: 900;
    color: var(--accent-color);
    opacity: 0.1;
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 0;
}

.step h4 {
    font-size: 1.4rem;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
}

.step p {
    color: var(--secondary-text-color);
    line-height: 1.6;
    position: relative;
    z-index: 1;
}

/* --- Card Grid (Landing & Trends) --- */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-top: 40px;
}

.card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: 12px;
    transition: transform 0.2s;
}

.card:hover {
    transform: translateY(-5px);
}

.card-icon {
    font-size: 3rem;
    margin-bottom: 20px;
}

.card h3 {
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.card p {
    color: var(--secondary-text-color);
    margin-bottom: 20px;
    line-height: 1.6;
}

.text-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

/* --- Page Layouts --- */
.content-page {
    padding: 60px 20px;
}

.page-header {
    text-align: center;
    margin-bottom: 60px;
}

.page-header h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.page-header p {
    color: var(--secondary-text-color);
    font-size: 1.2rem;
}

/* Trend Grid */
.trend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 60px;
}

.trend-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
}

/* Real Thumbnail Styles */
.thumb-link {
    display: block;
    width: 100%;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 15px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.thumb-link:hover {
    transform: scale(1.02);
}

.real-thumb {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    aspect-ratio: 16/9;
}

.views {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.analysis {
    font-size: 0.95rem;
    color: var(--secondary-text-color);
    margin-top: 5px;
}

/* Awards Rank List */
.rank-item {
    display: flex;
    align-items: center;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    gap: 20px;
}

.rank-badge {
    font-size: 2rem;
    font-weight: 900;
    width: 60px;
    text-align: center;
    font-style: italic;
}

.rank-item.gold .rank-badge { color: #ffd700; }
.rank-item.silver .rank-badge { color: #c0c0c0; }
.rank-item.bronze .rank-badge { color: #cd7f32; }

.rank-thumb {
    width: 200px;
    flex-shrink: 0;
}

.rank-thumb .placeholder-img {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: black;
    font-weight: bold;
}

.rank-info h3 { margin: 0 0 5px 0; }
.rank-info .channel { font-size: 0.9rem; color: var(--secondary-text-color); margin: 0; }
.rank-info .stats { color: var(--accent-color); font-weight: bold; margin: 10px 0; }
.rank-info .comment { background: var(--highlight-bg); padding: 10px; border-radius: 6px; font-size: 0.9rem; }

/* Job Board */
.job-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 50px;
}

.job-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 15px;
    position: relative;
    transition: border-color 0.2s;
    cursor: pointer;
}

.job-card:hover {
    border-color: var(--accent-color);
}

.job-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.job-status.recruiting { background: #e3f2fd; color: #1976d2; }
.job-status.closed { background: #f5f5f5; color: #616161; }

.job-desc {
    color: var(--secondary-text-color);
    margin: 10px 0;
}

.job-meta {
    font-size: 0.85rem;
    color: #999;
}

/* Blog Grid */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
}

.blog-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.blog-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.blog-thumb {
    height: 180px;
    background-size: cover;
    background-position: center;
    background-color: #333;
}

.blog-info {
    padding: 20px;
    flex: 1;
}

.blog-cat {
    font-size: 0.8rem;
    color: var(--accent-color);
    font-weight: 700;
    text-transform: uppercase;
}

.blog-info h3 {
    margin: 10px 0;
    font-size: 1.2rem;
    line-height: 1.4;
}

.blog-info p {
    color: var(--secondary-text-color);
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Article Viewer */
.blog-post-container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--surface-color);
    padding: 40px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

.category-badge {
    background-color: var(--highlight-bg);
    color: var(--accent-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 15px;
}

#article-title {
    font-size: 2.5rem;
    margin-bottom: 20px;
    line-height: 1.3;
}

.summary {
    font-size: 1.2rem;
    color: var(--secondary-text-color);
    font-style: italic;
    border-left: 4px solid var(--accent-color);
    padding-left: 20px;
    margin-bottom: 30px;
}

.article-body h3 {
    margin-top: 40px;
    margin-bottom: 20px;
    font-size: 1.8rem;
    color: var(--primary-text-color);
}

.article-body h4 {
    margin-top: 30px;
    margin-bottom: 15px;
    font-size: 1.4rem;
}

.article-body p, .article-body li {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--secondary-text-color);
    margin-bottom: 15px;
}

.article-body ul, .article-body ol {
    margin-bottom: 20px;
    padding-left: 20px;
}

.tip-box {
    background-color: rgba(255, 255, 0, 0.1);
    border: 1px solid #ffd700;
    padding: 20px;
    border-radius: 8px;
    margin: 30px 0;
    color: var(--primary-text-color);
}

.article-footer {
    margin-top: 60px;
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 40px;
}

@media (max-width: 768px) {
    .blog-post-container {
        padding: 20px;
    }
    #article-title {
        font-size: 1.8rem;
    }
}

/* Fine-tune Controls Styling */
.fine-tune-group {
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background-color: transparent !important;
}

.fine-tune-group h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: var(--primary-text-color);
}

.fine-tune-row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.fine-tune-row label {
    width: 60px;
    font-size: 12px;
    color: var(--secondary-text-color);
}

.fine-tune-row input[type="range"] {
    flex: 1;
}

.fine-tune-row .value-label {
    width: 45px;
    text-align: right;
    font-size: 12px;
    color: var(--primary-text-color);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}