:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.2);
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.7);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(226, 232, 240, 0.8);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius: 20px;
    --radius-sm: 12px;
}

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

body {
    font-family: 'Pretendard Variable', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(168, 85, 247, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(168, 85, 247, 0.1) 0px, transparent 50%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 4rem 1rem;
}

.glass {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
}

.container {
    max-width: 1000px;
    width: 100%;
}

.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
}

.site-brand {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #6366f1, #a855f7);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    white-space: nowrap;
}

.nav-tools {
    display: flex;
    gap: 0.25rem;
}

.nav-item {
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 700;
    border-radius: calc(var(--radius-sm) - 4px);
    transition: all 0.3s ease;
}

.nav-item:hover {
    color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.nav-item.active {
    color: white;
    background: var(--primary-color);
    box-shadow: 0 4px 12px var(--primary-glow);
}

header {
    text-align: center;
    margin-bottom: 4rem;
    animation: fadeInDown 0.8s ease-out;
}

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

header h1 {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #6366f1, #a855f7);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    font-size: 1.25rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

.upload-section {
    margin-bottom: 4rem;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 5rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.05);
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px var(--primary-glow);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    transition: transform 0.3s ease;
}

.drop-zone:hover .upload-icon {
    transform: scale(1.1) rotate(5deg);
}

.drop-zone p {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.file-info {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}

.result-section {
    margin-top: 3rem;
    animation: fadeInUp 0.6s ease-out;
}

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

.preview-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 3rem;
}

.preview-box {
    padding: 1.5rem;
    border-radius: var(--radius);
}

.preview-box h3 {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.image-wrapper:hover {
    transform: scale(1.02);
}

/* 투명 배경 격자무늬 - 현대적인 스타일 */
.processed-wrapper {
    background-image: 
        linear-gradient(45deg, #e2e8f0 25%, transparent 25%), 
        linear-gradient(-45deg, #e2e8f0 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, #e2e8f0 75%), 
        linear-gradient(-45deg, transparent 75%, #e2e8f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #ffffff;
}

.image-wrapper img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1));
}

.loader {
    text-align: center;
    width: 80%;
}

.spinner {
    width: 56px;
    height: 56px;
    border: 5px solid rgba(99, 102, 241, 0.1);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    margin: 0 auto 1.5rem;
}

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

.progress-bar-container {
    width: 100%;
    height: 10px;
    background-color: #f1f5f9;
    border-radius: 10px;
    margin-top: 1.5rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(to right, #6366f1, #a855f7);
    transition: width 0.3s ease;
}

.actions {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

button, .primary-btn, .secondary-btn {
    padding: 1rem 2.5rem;
    border-radius: var(--radius-sm);
    font-size: 1.125rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.primary-btn {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.5);
}

.secondary-btn {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.secondary-btn:hover {
    background-color: #f8fafc;
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

@media (max-width: 768px) {
    .preview-container {
        grid-template-columns: 1fr;
    }
}

.features-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 6rem;
    margin-bottom: 4rem;
}

.feature-card {
    padding: 2.5rem 2rem;
    border-radius: var(--radius);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1.5rem;
    display: block;
}

.feature-card h4 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.feature-card p {
    color: var(--text-muted);
    font-size: 1rem;
}

footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

/* Editor Styles */
.editor-wrapper {
    padding: 1.5rem;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tool-group label {
    font-weight: 700;
    font-size: 0.9rem;
}

.tool-group input[type="range"] {
    width: 150px;
    height: 6px;
    border-radius: 5px;
    background: #e2e8f0;
    outline: none;
    -webkit-appearance: none;
}

.tool-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn-sm {
    padding: 0.5rem;
    min-width: 40px;
    border-radius: var(--radius-sm);
}

.btn-sm:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

@media (max-width: 480px) {
    .site-brand { font-size: 0.9rem; }
    .nav-item { padding: 0.6rem 1rem; font-size: 0.9rem; }
}

.canvas-container {
    position: relative;
    width: 100%;
    min-height: 400px;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-container canvas {
    position: absolute;
    max-width: 100%;
    max-height: 100%;
    cursor: crosshair;
}

#mask-canvas {
    z-index: 10;
    opacity: 0.6;
}

.overlay-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

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

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.footer-nav, .footer-legal {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeInModal 0.3s ease-out;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideInModal 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}

.modal-body {
    overflow-y: auto;
    padding: 2rem;
    flex: 1;
}

.modal-body h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

.modal-body h3:first-child {
    margin-top: 0;
}

.modal-body p {
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.7;
}

.modal-body ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.modal-body li {
    margin-bottom: 0.5rem;
}

/* Scrollbar styling for modal */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}
