:root {
    color-scheme: dark !important;
}

html, body {
    color-scheme: dark !important;
    background: linear-gradient(135deg, #075985 0%, #0c4a6e 40%, #0f172a 100%);
    background-attachment: fixed;
    background-color: #0f172a;
    color: #f8fafc;
    margin: 0;
    padding: 0;
    font-family: 'Noto Serif KR', serif;
    -webkit-tap-highlight-color: transparent;
}

/* 메인 앱 모드: 풀스크린 고정 (스크롤 X) */
body.app-mode,
html:has(body.app-mode) {
    overflow: hidden;
    height: 100%;
    width: 100%;
}

#font-preload {
    position: absolute;
    top: -9999px;
    left: -9999px;
    font-family: 'Nanum Brush Script', cursive;
    visibility: hidden;
}

.unified-brush-font {
    font-family: 'Nanum Brush Script', cursive !important;
}

.app-container {
    width: 100%;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.step-content {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    scrollbar-width: none;
}

.step-content::-webkit-scrollbar {
    display: none;
}

.step-content.active {
    display: flex;
}

#step3 {
    display: none;
    flex-direction: column;
    height: 100%;
    background-color: #000;
    overflow: hidden;
}

#step3.active {
    display: flex;
}

.step-indicator {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    transition: all 0.3s;
    cursor: pointer;
}

.step-active {
    background-color: #ffffff;
    color: #0c4a6e;
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
}

.step-inactive {
    background-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.5);
}

#canvas-viewport {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #000;
    overflow: hidden;
    padding: 10px;
}

#tool-settings-area {
    height: 115px;
    background: rgba(51, 65, 85, 0.95);
    backdrop-filter: blur(30px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 10px 0;
}

#canvasMockup {
    touch-action: none;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    overflow: hidden;
    box-shadow: 0 0 80px rgba(0, 0, 0, 1);
    transform-origin: center;
}

#generatedImg {
    z-index: 5;
    mix-blend-mode: multiply;
    pointer-events: none;
    filter: contrast(1.1) brightness(1);
}

#fgCanvas {
    z-index: 10;
    pointer-events: none;
}

#watermarkCanvas {
    z-index: 20;
    pointer-events: none;
}

#generatedImg, #fgCanvas, #watermarkCanvas {
    transform-origin: center;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.floating-tool-bar {
    width: 100%;
    background: #ffffff;
    display: flex;
    align-items: stretch;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    z-index: 1200;
    height: 60px;
}

.tool-section-left {
    flex: 3;
    display: flex;
    justify-content: space-between;
    gap: 4px;
    padding: 6px;
    background: #f1f5f9;
    align-items: center;
}

.tool-section-right {
    flex: 4;
    display: flex;
    justify-content: space-between;
    gap: 4px;
    padding: 6px;
    background: #ffffff;
    align-items: center;
}

.tool-btn {
    flex: 1;
    height: 48px;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.tool-btn.active-target {
    background-color: #0f172a;
    color: #ffffff !important;
}

.tool-btn.active-func {
    background-color: #0284c7;
    color: #ffffff !important;
}

#toast {
    position: fixed;
    bottom: 190px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    color: white;
    padding: 12px 28px;
    border-radius: 40px;
    font-size: 11px;
    z-index: 3000;
    display: none;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    max-width: 85%;
}

.btn-exit-focus {
    position: absolute;
    top: 15px;
    left: 15px;
    background: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #0f172a;
    z-index: 1600;
    font-size: 20px;
    font-weight: 900;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border: none;
}

.glass-card {
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(16px);
    border-radius: 1.5rem;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.emotional-input {
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 1rem;
    color: #0f172a;
    font-weight: 600;
}

.emotional-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.texture-hwaseonji {
    background-color: #ffffff !important;
}

.texture-hanji {
    background-color: #f8f1e5 !important;
}

.texture-vintage {
    background-color: #e8dcc4 !important;
}

.loading-spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border-left-color: #ffffff;
    animation: spin 0.8s linear infinite;
}

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

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

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

#saveModal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    backdrop-filter: blur(15px);
}

#saveModal img {
    max-width: 90%;
    max-height: 55vh;
    border-radius: 8px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 1);
}

input[type=range] {
    -webkit-appearance: none;
    background: transparent;
    width: 100%;
    height: 24px;
}

input[type=range]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: #ffffff;
    margin-top: -7px;
    border: 2px solid #0284c7;
}

.section-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #f8fafc;
    margin-bottom: 0.4rem;
    margin-left: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ────────────────────────────────────────────────
   인증 (로그인 / 회원가입) 폼
   ──────────────────────────────────────────────── */
.auth-container {
    max-width: 420px;
    margin: 0 auto;
}

.auth-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 1rem;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: white;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

.auth-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.auth-input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.3);
}

.auth-tab {
    flex: 1;
    padding: 0.75rem;
    font-size: 0.875rem;
    font-weight: 700;
    border-radius: 0.75rem;
    transition: all 0.2s;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.auth-tab.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.auth-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.75rem;
    display: none;
}

.auth-error.show {
    display: block;
}

.premium-btn {
    background: linear-gradient(to right, #0284c7, #38bdf8);
    box-shadow: 0 4px 18px rgba(2, 132, 199, 0.35);
    border: none !important;
    color: white !important;
}

/* ────────────────────────────────────────────────
   헤더 / 네비게이션 / 유저 정보
   ──────────────────────────────────────────────── */
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    padding: 0.375rem 0.75rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.nav-link:hover {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link-active {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
}

.nav-link-active:hover {
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.15);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.5);
}

.guest-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #7dd3fc;
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(56, 189, 248, 0.3);
    background: rgba(56, 189, 248, 0.08);
    transition: all 0.2s;
}

.guest-login-btn:hover {
    background: rgba(56, 189, 248, 0.18);
}

/* 헤더 안 닉네임 표시 */
.auth-name {
    display: inline-block;
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.55);
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.1rem 0.5rem;
}

/* ────────────────────────────────────────────────
   작품 갤러리 (나의 작품 페이지)
   ──────────────────────────────────────────────── */
.gallery-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.gallery-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 1.25rem;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    min-height: 200px;
}

.gallery-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(56, 189, 248, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px -10px rgba(0, 0, 0, 0.3);
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.gallery-tags {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.gallery-tag {
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 0.375rem;
    letter-spacing: 0.025em;
}

.gallery-tag-style {
    background: rgba(56, 189, 248, 0.15);
    color: #7dd3fc;
}

.gallery-tag-paper {
    background: rgba(168, 85, 247, 0.15);
    color: #c4b5fd;
}

.gallery-delete-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.2);
    padding: 0.25rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.gallery-delete-btn:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.gallery-thumb {
    width: 100%;
    height: 140px;
    border-radius: 0.75rem;
    overflow: hidden;
    margin-bottom: 0.75rem;
    background: #faf9f5;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-body {
    flex: 1;
    margin-bottom: 0.75rem;
}

.gallery-subject {
    font-size: 0.8125rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.75);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.gallery-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.gallery-author {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #7dd3fc;
}

.gallery-date {
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.25);
}

/* 모바일에서는 다운로드 버튼 항상 표시 */
@media (hover: none) {
    #modal-download-btn {
        opacity: 1 !important;
    }
}

.loading-spin {
    animation: spin 1s linear infinite;
}

