/* ==========================================================================
   Style Rewinder - 3D Fashion Mixer 전역 스타일시트
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 웹 폰트 정의 (Pretendard Medium)
   -------------------------------------------------------------------------- */
@font-face {
    font-family: 'Pretendard';
    src: url('https://cdn.jsdelivr.net/gh/Project-Noonnu/noonfonts_2107@1.1/Pretendard-Medium.woff') format('woff');
    font-weight: 500;
    font-style: normal;
}

/* --------------------------------------------------------------------------
   2. 전역 CSS 변수 (테마 색상, 글꼴, 그림자 설정)
   -------------------------------------------------------------------------- */
:root {
    --primary-bg: #939393;
    /* 기본 어두운 배경색 */
    --accent-color: #3b82f6;
    /* 강조 포인트 컬러 (블루) */
    --glass-bg: rgba(15, 23, 42, 0.98);
    /* 최적화: 단순 반투명/불투명 배경 */
    --glass-border: transparent;
    /* 최적화: 글래스 테두리 제거 */
    --shadow-sm: 0 4px 20px -5px rgba(0, 0, 0, 0.05);
    /* 은은한 그림자 */
    --shadow-lg: 0 40px 60px -15px rgba(0, 0, 0, 0.12);
    /* 깊은 그림자 */
    --font-main: 'Ubuntu', 'Pretendard', sans-serif;
    /* 메인 본문 글꼴 */
    --font-display: 'Ubuntu', 'Pretendard', sans-serif;
    /* 제목/디스플레이 글꼴 */
    --sat: env(safe-area-inset-top, 0px);
    --sab: env(safe-area-inset-bottom, 0px);
    --sal: env(safe-area-inset-left, 0px);
    --sar: env(safe-area-inset-right, 0px);
}

/* --------------------------------------------------------------------------
   3. 기본 리셋 및 모바일 터치/선택 방지 설정
   -------------------------------------------------------------------------- */
html,
body,
*,
button,
input,
select,
textarea {
    font-family: var(--font-main);
    -webkit-tap-highlight-color: transparent;
    /* 모바일 터치 하이라이트 제거 */
    -webkit-touch-callout: none;
    /* 모바일 롱터치 팝업 방지 */
    outline: none !important;
}

*:focus,
*:focus-visible,
*:active,
button:focus,
button:active {
    outline: none !important;
    -webkit-tap-highlight-color: transparent !important;
}

button:active {
    transform: scale(0.95) !important;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    touch-action: manipulation;
    /* 기본 터치 제스처 조절 */
    user-select: none;
    /* 텍스트 드래그 및 선택 방지 */
    -webkit-user-select: none;
    overscroll-behavior: none;
    /* 바운스 바운더리 스크롤 방지 */
    overflow: hidden;
    position: fixed;
    /* iOS 가로 스크롤 완전 차단 */
}

body {
    overflow: hidden;
    /* 전역 스크롤바 숨김 */
    background-color: var(--primary-bg);
}

/* 전시 모드(mode-locked) 시 편집 관련 관리 버튼 및 삭제 요소 숨김 */
body.mode-locked #management-btn-wrapper,
body.mode-locked .delete-btn,
body.mode-locked .set-action-btns,
body.mode-locked .set-assigner {
    display: none !important;
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 900;
    letter-spacing: -0.02em;
}

/* --------------------------------------------------------------------------
   4. 3D Three.js 캔버스 컨테이너 및 비네팅 오버레이
   -------------------------------------------------------------------------- */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    cursor: default;
    background: #111111;
    touch-action: none;
    z-index: 1;
    /* 스탠바이미 GPU 하드웨어 레이어 가속 유도 */
    transform: translateZ(0);
    will-change: transform;
}

/* 화면 좌우 어두운 가장자리 비네팅(Vignette) 가림막 */

/* 아이패드 전체화면 시 Safari/Chrome 제스처(쓸어내림 등) 원천 차단 */
body.ipad-fullscreen {
    touch-action: none !important;
}
#vignette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* 터치 및 마우스 이벤트 통과 */
    z-index: 2;
    background: linear-gradient(to right,
            rgba(17, 17, 17, 1.0) 0%,
            rgba(17, 17, 17, 0.9) 20%,
            rgba(17, 17, 17, 0.65) 35%,
            transparent 47%,
            transparent 53%,
            rgba(17, 17, 17, 0.65) 65%,
            rgba(17, 17, 17, 0.9) 80%,
            rgba(17, 17, 17, 1.0) 100%);
    transform: translateZ(0);
    will-change: transform;
}

/* --------------------------------------------------------------------------
   5. 상단 우측 오디오(BGM) 제어 버튼
   -------------------------------------------------------------------------- */
#audio-control-btn {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    outline: none;
    color: #fafaf8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: none;
    pointer-events: auto;
    /* filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4)); - 최적화 위해 제거됨 */
}

#audio-control-btn:hover {
    background: transparent;
    transform: scale(1.15);
    opacity: 0.8;
}

#audio-control-btn img,
#audio-control-btn svg {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
}

/* --------------------------------------------------------------------------
   6. 좌측 수직 스타일 선택 휠 (Vertical Style Selector Wheel)
   -------------------------------------------------------------------------- */
#side-style-wrapper {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    z-index: 500;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    user-select: none;
    max-width: calc(100vw - 40px);
}

.side-style-header {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 900;
    color: #fafaf8;
    letter-spacing: 0.05em;
    margin: 0 0 12px 0;
    text-transform: uppercase;
}

/* 수직 스크롤 리스트 (원형 휠 효과 제거) */
.side-style-container {
    max-height: none;
    overflow-y: visible;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 10px 20px 10px 60px;
    touch-action: auto;
    max-width: 100%;
    pointer-events: auto; /* Ensure container receives clicks and scrolls */
}

.side-style-container::-webkit-scrollbar {
    display: none;
}

.side-style-list {
    display: flex;
    flex-direction: column;
    gap: 4px; /* Reduced from 12px */
    position: relative;
    width: max-content;
    /* margin-left removed, moved to padding on container to prevent landscape clipping */
}

.side-style-item {
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    transform-origin: left center;
    position: relative;
    pointer-events: auto;
    padding: 2px 8px 2px 0; /* Reduced vertical padding */
    width: max-content;
    overflow: visible;
}

@media (hover: hover) {
    .side-style-item:hover {
        color: rgba(255, 255, 255, 0.7);
    }
}

/* 선택된 활성 스타일 항목 강조 */
.side-style-item.active {
    color: #fafaf8 !important;
    font-weight: 900 !important;
    font-size: 1.1rem !important;
}

/* Timeline Layout (Years on the left) */
.timeline-container {
    position: absolute;
    right: calc(100% + 15px); /* Distance between text and year */
    top: 0;
    bottom: 0;
    width: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}
.timeline-year {
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 700;
    color: #fafaf8;
}
.timeline-arrow-line {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: calc(50% + 24px); /* Moved further down */
    width: 2px;
    background-color: #fafaf8;
    pointer-events: none;
}
.timeline-arrow-line::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 5px 0;
    border-style: solid;
    border-color: #fafaf8 transparent transparent transparent;
}

.timeline-arrow-line.horizontal-arrow::after {
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    border-width: 5px 0 5px 6px;
    border-color: transparent transparent transparent #fafaf8;
}

.ui-overlay {
    position: absolute;
    top: 24px;
    left: 24px;
    pointer-events: auto;
    z-index: 10;
}

/* 상단 메인 브랜드 타이틀 */
.title-svg-interactive {
    overflow: visible;
}

.title-char {
    cursor: default;
}

/* 텍스트 타이틀 개별 글자 호버 효과 */
.title-hover-letter {
    display: inline-block;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.25s ease;
    cursor: pointer;
    white-space: pre;
}

.title-hover-letter:hover {
    transform: scale(1.3) translateY(-3px);
    color: #fafaf8;
}

/* --------------------------------------------------------------------------
   7. 관리 / 갤러리 모달 패널 (#management-panel) - ARCHIVE STUDIO
   -------------------------------------------------------------------------- */
#management-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 92vw;
    height: 88vh;
    max-width: 1400px;
    max-height: 90vh;
    background: #e8e8e8 !important;
    border-radius: 24px;
    padding: 32px 36px 28px 40px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    border: none;
    overflow: hidden; /* 스크롤바가 큰 네모 밖으로 튀어나가지 않도록 완전 차단 */
    z-index: 20000;
    display: none;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #000000;
    box-sizing: border-box;
}

#management-panel[style*="display: block"],
#management-panel[style*="display: flex"] {
    display: flex !important;
}

/* 상단 헤더 (ARCHIVE STUDIO & 액션 버튼) */
.archive-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 8px;
    flex-shrink: 0;
    position: relative;
}

.archive-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 900;
    color: #000000;
    letter-spacing: -0.01em;
    text-transform: uppercase;
    margin: 0;
}

/* 상단 탭 네비게이션 (CATEGORY / STYLE SET) */
.archive-tabs-container {
    display: flex;
    background: #d4d4d4;
    padding: 3px;
    border-radius: 10px;
    gap: 3px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.archive-tab-btn {
    padding: 6px 18px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #555555;
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.archive-tab-btn:hover {
    color: #000000;
}

.archive-tab-btn.active {
    background: #111111;
    color: #fafaf8;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.archive-tab-content {
    animation: fadeIn 0.25s ease;
}

.archive-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.archive-icon-btn {
    width: 36px;
    height: 36px;
    background: #111111;
    color: #fafaf8;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.archive-icon-btn:hover {
    opacity: 0.85;
    transform: scale(1.06);
}

.archive-icon-btn:active {
    transform: scale(0.96);
}

/* 내부 스크롤 영역 (큰 네모 안쪽에 항상 선명하게 표시되는 세로 스크롤바) */
.archive-scroll-area {
    touch-action: pan-y;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 14px;
    margin-right: -4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #222222 #d4d4d4;
}

.archive-scroll-area::-webkit-scrollbar {
    width: 7px;
    display: block !important;
}

.archive-scroll-area::-webkit-scrollbar-track {
    background: #d4d4d4;
    border-radius: 10px;
    margin: 6px 0;
}

.archive-scroll-area::-webkit-scrollbar-thumb {
    background: #222222;
    border-radius: 10px;
    min-height: 40px;
}

.archive-scroll-area::-webkit-scrollbar-thumb:hover {
    background: #111111;
}

/* 카테고리 섹션 및 헤더 */
.category-section {
    margin-bottom: 26px;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-top: 4px;
}

.category-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 900;
    color: #000000;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.category-add-btn {
    width: 24px;
    height: 24px;
    background: #111111;
    color: #fafaf8;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.category-add-btn:hover {
    opacity: 0.85;
    transform: scale(1.12);
}

.category-add-btn:active {
    transform: scale(0.95);
}

/* 카테고리별 썸네일 가로 스크롤 그리드 (가로 스크롤바 숨김 처리로 깔끔한 카드 뷰 유지) */
.thumbnail-grid {
    display: flex;
    gap: 14px;
    overflow-x: auto !important;
    overflow-y: hidden;
    padding: 6px 2px 14px 2px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    width: 100%;
    align-items: flex-start;
}

.thumbnail-grid::-webkit-scrollbar {
    height: 8px;
}

.thumbnail-grid::-webkit-scrollbar-track {
    background: transparent;
}

.thumbnail-grid::-webkit-scrollbar-thumb {
    background: #cccccc;
    border-radius: 4px;
}

.thumbnail-grid::-webkit-scrollbar-thumb:hover {
    background: #aaaaaa;
}

/* 썸네일 항목 아이템 컨테이너 */
.thumb-container {
    flex: 0 0 112px;
    min-width: 112px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.thumb-container.dragging {
    opacity: 0.35;
    transform: scale(0.95);
}

.thumb-container.drag-over {
    box-shadow: 0 0 0 2px #0084ff;
    border-radius: 8px;
    transform: scale(1.03);
}

.thumb {
    width: 100%;
    height: 112px;
    aspect-ratio: 1;
    border-radius: 4px;
    overflow: hidden;
    background: #d4d4d4;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease;
    cursor: pointer;
}

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

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* 인풋 스택 (세트 지정, 이름, 설명, 링크 4단 바) */
.item-inputs-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
}

.item-inputs-stack input,
.item-inputs-stack select,
.item-inputs-stack textarea {
    width: 100%;
    height: 19px;
    line-height: 19px;
    padding: 0 6px;
    border-radius: 3px;
    background: #d8d8d8;
    border: 1.5px solid transparent;
    font-size: 9px;
    font-weight: 700;
    color: #111111;
    outline: none;
    transition: all 0.15s ease;
    box-sizing: border-box;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    resize: none;
    margin: 0;
}

.item-inputs-stack textarea.item-memo {
    white-space: pre-wrap;
    overflow-y: auto;
    height: 48px;
    line-height: 1.4;
    padding-top: 4px;
    padding-bottom: 4px;
    word-break: break-all;
}

.item-inputs-stack input::placeholder,
.item-inputs-stack textarea::placeholder {
    color: #888888;
    font-weight: 600;
    opacity: 0.7;
}

.item-inputs-stack input:focus,
.item-inputs-stack select:focus,
.item-inputs-stack textarea:focus {
    border-color: #0084ff !important;
    background: #fafaf8 !important;
    color: #000000 !important;
    box-shadow: 0 0 0 2px rgba(0, 132, 255, 0.2) !important;
}

/* 커스텀 세트 지정 드롭다운 (체크박스) */
.set-assigner-wrapper {
    position: relative;
    width: 100%;
    height: 19px;
}

.set-assigner-btn {
    width: 100%;
    height: 19px;
    line-height: 19px;
    padding: 0 6px;
    border-radius: 3px;
    background: #d8d8d8;
    border: 1.5px solid transparent;
    font-size: 9px;
    font-weight: 700;
    color: #333333;
    cursor: pointer;
    text-align: center;
    box-sizing: border-box;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.set-assigner-btn.has-set {
    background: #cecece;
    font-weight: 800;
}

.set-assigner-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 100px;
    overflow-y: auto;
    background: #fafaf8;
    border: 1px solid #ddd;
    border-radius: 3px;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    padding: 4px;
}

.set-assigner-menu.show {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.set-assigner-menu label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    font-weight: 700;
    color: #333;
    cursor: pointer;
    white-space: nowrap;
}

.set-assigner-menu input[type="checkbox"] {
    width: 12px !important;
    height: 12px !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* 순서 변경 좌우 이동 버튼 그룹 */
.order-btn-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
    padding: 0 2px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.thumb-container:hover .order-btn-group {
    opacity: 1;
}

.order-btn {
    background: #d2d2d2;
    border: none;
    color: #333333;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
}

.order-btn:hover:not(:disabled) {
    background: #111111;
    color: #fafaf8;
}

.order-idx {
    font-size: 8px;
    font-weight: 800;
    color: #666666;
}



/* 이미지 삭제 버튼 (Hover 시 표시) */
.delete-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #111111;
    color: #fafaf8;
    border-radius: 50%;
    scale: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 900;
    transition: transform 0.15s ease, scale 0.15s ease;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
    cursor: pointer;
}

.thumb-container:hover .delete-btn,
.set-thumb-preview:hover .delete-btn {
    scale: 1;
}

.delete-btn:hover {
    background: #ef4444;
    transform: scale(1.1);
}

/* --------------------------------------------------------------------------
   8. 하단 바닥 고정 조작 컨트롤 버튼 그룹 (2D, 셔플, 리셋, 갤러리)
   -------------------------------------------------------------------------- */
.controls {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    z-index: 150;
}

.controls button, .controls a {
    outline: none !important;
    -webkit-tap-highlight-color: transparent !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
}

.controls button:focus, .controls button:active,
.controls a:focus, .controls a:active {
    outline: none !important;
    background: transparent !important;
    box-shadow: none !important;
}

.btn {
    background: #fafaf8;
    padding: 14px 18px;
    border-radius: 20px;
    border: 1px solid #f1f5f9;
    cursor: pointer;
    font-weight: 800;
    color: #1e293b;
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    white-space: nowrap;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    min-width: 110px;
    text-align: center;
    /* 버튼 가로폭 슬림하게 축소 */
}

#management-btn-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    width: 44px;
    height: 44px;
}

#management-btn-wrapper button {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#management-btn-wrapper button:hover {
    transform: scale(1.15);
    opacity: 0.8;
}

.btn:hover {
}

.btn-black {
    background: #0f172a;
    color: #fafaf8;
    border: none;
    box-shadow: 0 10px 30px -5px rgba(15, 23, 42, 0.3);
}

.btn-black:hover {
}

#flat-view-btn, #mode-2d-btn {
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

#mode-2d-btn.active {
    background: #64748b !important;
    color: #fafaf8 !important;
    border-color: #94a3b8 !important;
    box-shadow: 0 10px 25px -5px rgba(100, 116, 139, 0.4) !important;
}

/* --------------------------------------------------------------------------
   9. 로딩 스플래시 화면 (#loading-screen)
   -------------------------------------------------------------------------- */
#loading-screen {
    position: fixed;
    inset: 0;
    background: #111111;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.8s ease;
    user-select: none;
}

.splash-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: splashZoomIn 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.splash-logo {
    max-width: 280px;
    max-height: 280px;
    width: 80vw;
    height: auto;
    object-fit: contain;
    /* filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.12)); - 최적화 위해 제거됨 */
}

.splash-debug-log {
    position: absolute;
    bottom: 24px;
    font-size: 10px;
    font-family: monospace;
    color: #475569;
    text-align: center;
    max-width: 80%;
    pointer-events: none;
}

@keyframes splashZoomIn {
    0% {
        opacity: 0;
        transform: scale(0.88);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 토스트 메시지 박스 알림 */
#message-box {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #fafaf8;
    color: #000000;
    padding: 14px 28px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 3000;
    display: none;
}

/* --------------------------------------------------------------------------
   10. 스타일 세트 관리 항목 UI
   -------------------------------------------------------------------------- */
.set-settings-list {
    margin-top: 12px;
}

.set-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #dedede;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    overflow: hidden;
}

.set-item-row:hover {
    background: #d4d4d4;
}

.set-thumb-preview {
    max-width: 112px;
    max-height: 112px;
    min-width: 60px;
    min-height: 60px;
    border-radius: 4px;
    background: #d4d4d4;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: visible;
    position: relative;
    cursor: default;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease;
}

.set-thumb-preview.has-img {
    cursor: pointer;
    background: #fafaf8;
}

.set-thumb-preview.has-img:hover {
    transform: scale(1.02);
}

.set-thumb-preview img {
    max-width: 112px;
    max-height: 112px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.set-name-edit {
    flex: 1;
    min-width: 50px;
    font-size: 11px;
    font-weight: 900;
    color: #111111;
    background: transparent;
    outline: none;
    border: none;
    padding: 2px 4px;
}

.set-desc-edit {
    width: 100%;
    min-height: 40px;
    font-size: 10px;
    color: #444;
    background: transparent;
    outline: none;
    border: none;
    padding: 2px 4px;
    margin-top: 4px;
    resize: vertical;
    border-radius: 4px;
}
.set-desc-edit:focus {
    background: #f1f5f9;
}

.set-action-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.set-mini-btn {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 900;
    text-transform: uppercase;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-save {
    background: #0f172a;
    color: #fafaf8;
    border: none;
}

.btn-image-upload {
    background: #0f172a;
    color: #fafaf8;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
}

.btn-image-upload:hover {
    background: #333333;
    color: #fafaf8;
}

.btn-image-upload.has-img {
    background: #111111;
    color: #fafaf8;
}

.btn-image-upload.has-img:hover {
    background: #333333;
    color: #fafaf8;
}

.btn-delete {
    background: #f1f5f9;
    color: #94a3b8;
    border: none;
}

.btn-save:hover {
    background: #333333;
}

.btn-delete:hover {
    background: #666666;
    color: #fafaf8;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-50px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* --------------------------------------------------------------------------
   11. 다중 선택 드롭다운 UI (Multi-select Dropdown)
   -------------------------------------------------------------------------- */
.set-dropdown-container {
    position: relative;
    width: 100%;
    margin-top: 8px;
}

.set-dropdown-trigger {
    width: 100%;
    padding: 6px 10px;
    font-size: 9px;
    font-weight: 800;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.set-dropdown-trigger:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.set-trigger-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: left;
    margin-right: 4px;
}

.set-dropdown-trigger span {
    opacity: 0.5;
    font-size: 8px;
    flex-shrink: 0;
}

.set-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    min-width: 150px;
    max-width: 220px;
    background: #fafaf8 !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
    z-index: 99999 !important;
    max-height: 184px !important;
    overflow-y: auto !important;
    display: none;
    padding: 6px;
    animation: popUp 0.2s ease;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #94a3b8 #f1f5f9;
}

.set-dropdown-menu.active {
    display: block !important;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 700;
    color: #475569;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-item:hover {
    background: #f8fafc;
    color: #6366f1;
}

.dropdown-item input {
    accent-color: #6366f1;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.dropdown-item.selected {
    background: #f1f5f9;
    color: #0f172a;
}

/* --------------------------------------------------------------------------
   12. 아이템 클릭 모달 팝업 (#info-popup)
   -------------------------------------------------------------------------- */
#info-popup {
    position: fixed;
    inset: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: flex-end;
    padding-right: 60px;
    pointer-events: none;
    animation: fadeIn 0.15s ease;
}

.info-card {
    height: min(800px, 85vh);
    width: calc(min(800px, 85vh) * (500 / 800));
    max-width: 90vw;
    background: #ffffff;
    border: none;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: none;
    position: relative;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    animation: popUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-sizing: border-box;
}

.info-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2% 4%;
    border-bottom: 1px solid #000;
}

.close-info {
    width: 28px;
    height: 28px;
    background: #111111;
    color: #fafaf8;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-right: -2%;
}

.close-info:hover {
    background: #333;
}

.info-title-container {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    padding: 2% 4%;
    border-bottom: 1px solid #000;
}

.info-visual {
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-bottom: none;
}

.info-visual img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.info-visual:hover img {
    transform: scale(1.03);
}

.popup-image-container {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    border-bottom: 1px solid #000;
    background-color: #ffffff;
}

.buy-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.buy-overlay span {
    color: #fafaf8;
    font-weight: 900;
    font-size: 13px;
    letter-spacing: 0.1em;
    border: 2px solid #fafaf8;
    padding: 6px 16px;
    text-transform: uppercase;
}

.popup-image-container:hover .buy-overlay {
    opacity: 1;
}

.info-body {
    flex: 0 0 auto;
    padding: 4%;
    text-align: left;
    background: transparent;
    width: 100%;
    box-sizing: border-box;
}

.info-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #111111;
    padding: 0 16px;
    height: 45px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 900;
    color: #fafaf8;
    margin-left: -2%;
    letter-spacing: 0.05em;
    box-sizing: border-box;
}

#info-title {
    font-size: 18px;
    color: #000000;
    font-weight: 800;
    margin: 0;
    white-space: pre-wrap;
    word-break: keep-all;
}

#info-link {
    display: none !important;
}

/* 스크롤바 가시성 더 선명하게 보정 */
.item-memo::-webkit-scrollbar,
#info-desc::-webkit-scrollbar {
    width: 5px;
}

.item-memo::-webkit-scrollbar-thumb,
#info-desc::-webkit-scrollbar-thumb {
    background: #94a3b8;
    border-radius: 10px;
}

.item-memo::-webkit-scrollbar-track,
#info-desc::-webkit-scrollbar-track {
    background: transparent;
}

#info-desc {
    font-size: 13px;
    color: #000000;
    line-height: 1.6;
    letter-spacing: -0.02em;
    font-weight: 500;
    white-space: pre-wrap;
    max-height: 100%;
    overflow-y: auto;
    word-break: keep-all;
}


@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes popUp {
    from {
        transform: scale(0.8) translateY(20px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* --------------------------------------------------------------------------
   13. 전시용 이용 안내 모달 오버레이 (#instruction-overlay)
   -------------------------------------------------------------------------- */
#instruction-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.9);
    /* backdrop-filter: blur(20px); - 스탠바이미 성능 저하 원인으로 제거됨 */
    display: none;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

.instruction-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 60px 50px;
    border-radius: 40px;
    max-width: 520px;
    width: 90%;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
    animation: popUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.instruction-card h1 {
    color: #fafaf8;
    line-height: 1.1;
    margin-bottom: 40px;
}

.step-icon {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    background: #fafaf8;
    color: #000;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

/* --------------------------------------------------------------------------
   14. 인터랙티브 요소 커서 통일 및 흰색 버튼 스타일
   -------------------------------------------------------------------------- */
button,
a,
input,
select,
textarea,
[onclick],
.btn,
.side-style-item {
    font-family: var(--font-main);
    cursor: pointer;
}

.btn-white {
    background: #fafaf8;
    color: #000;
    border-radius: 20px;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn-white:hover {
    transform: scale(1.05);
    filter: brightness(0.95);
}
canvas {
    touch-action: none !important;
}

.digital-date {
    position: fixed;
    bottom: 24px;
    left: 24px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fafaf8;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
    z-index: 9990;
    pointer-events: none;
}

/* ==========================================================================
   14. 스마트폰 및 모바일 태블릿 반응형 레이아웃 시스템 (Mobile Responsive)
   ========================================================================== */

@media (max-width: 768px) and (orientation: portrait) {
    /* 1. 상단 브랜드 헤더 (로고 및 인터랙티브 REWINDER 타이틀 축소 & Safe Area 적용) */
    .ui-overlay {
        top: max(14px, var(--sat));
        left: max(16px, var(--sal));
        max-width: calc(100vw - 80px);
    }

    .ui-overlay img {
        width: 160px !important;
        margin-bottom: 12px !important;
    }

    .title-svg-interactive {
        width: 190px !important;
        max-width: 100% !important;
        height: auto !important;
    }

    /* 2. 상단 우측 음향 버튼 */
    #audio-control-btn {
        top: max(12px, var(--sat));
        right: max(14px, var(--sar));
        width: 44px;
        height: 44px;
    }

    /* 3. 디지털 날짜 스탬프: 하단 겹침 방지 및 상단 서브 헤더로 깔끔하게 이동 */
    .digital-date {
        top: calc(max(14px, var(--sat)) + 52px);
        left: max(16px, var(--sal));
        bottom: auto;
        font-size: 0.72rem;
        letter-spacing: 0.05em;
        opacity: 0.8;
        text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    }

    /* 4. 스타일 휠 -> 하단 가로 스크롤 칩 탭 바(Horizontal Pill Tabs)로 전환 */
    #side-style-wrapper {
        position: fixed;
        top: auto;
        bottom: calc(max(16px, var(--sab)) + 60px);
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        transform: none;
        flex-direction: row;
        align-items: center;
        padding: 0;
        pointer-events: none;
        box-sizing: border-box;
        z-index: 200;
    }

    .side-style-header {
        display: none; /* 모바일에서는 직관적인 가로 칩 탭바로 깔끔하게 표시 */
    }

    .side-style-container {
        width: 100%;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 25px 0 6px 0;
        touch-action: pan-x;
        pointer-events: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* 좌우 부드러운 페이드아웃 그라데이션 마스크 */
        mask-image: linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent);
        -webkit-mask-image: linear-gradient(to right, transparent, black 16px, black calc(100% - 16px), transparent);
    }

    .side-style-container::-webkit-scrollbar {
        display: none;
    }

    .side-style-list {
        display: flex;
        flex-direction: row;
        gap: 8px;
        width: max-content;
        padding: 0 max(16px, var(--sal));
        margin-left: 0;
    }

    .timeline-container {
        display: flex;
        position: absolute;
        top: -20px;
        left: 0;
        right: 0;
        bottom: auto;
        width: 100%;
        height: 20px;
        justify-content: center;
        align-items: center;
    }

    .side-style-item {
        font-size: 0.85rem;
        font-weight: 700;
        padding: 7px 10px;
        background: transparent;
        border: none;
        color: rgba(255, 255, 255, 0.5);
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
        transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
        flex-shrink: 0;
    }

    .side-style-item.active {
        background: transparent !important;
        color: #fafaf8 !important;
        font-weight: 900 !important;
        font-size: 0.95rem !important;
        border: none !important;
        box-shadow: none;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
        transform: scale(1.1);
    }

    /* 5. 하단 셔플 & 2D 전환 컨트롤 버튼 그룹 */
    .controls {
        bottom: max(16px, var(--sab));
        left: 50%;
        transform: translateX(-50%);
        gap: 16px;
        z-index: 300;
    }

    .controls a img,
    .controls button img {
        width: 80px;
        height: 80px;
    }

    /* 6. 우측 하단 갤러리/관리 토글 버튼 */
    #management-btn-wrapper {
        bottom: max(16px, var(--sab));
        right: max(16px, var(--sar));
        width: 76px;
        height: 76px;
        z-index: 300;
    }

    #management-btn-wrapper button svg {
        width: 48px;
        height: 48px;
    }

    /* 7. 갤러리(ARCHIVE STUDIO) 관리 모달 패널 모바일 전체화면 */
    #management-panel {
        width: 100% !important;
        height: 100% !important;
        height: 100dvh !important;
        max-width: 100% !important;
        max-height: 100dvh !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        border-radius: 0 !important;
        padding: max(14px, var(--sat)) max(14px, var(--sal)) max(14px, var(--sab)) max(14px, var(--sar)) !important;
        box-shadow: none !important;
    }

    .archive-header {
        margin-bottom: 12px;
        padding-bottom: 6px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .archive-title {
        font-size: 16px;
    }

    .archive-tabs-container {
        position: static;
        transform: none;
    }

    .archive-tab-btn {
        padding: 5px 12px;
        font-size: 10px;
        border-radius: 6px;
    }

    .archive-icon-btn {
        width: 32px;
        height: 32px;
    }

    .archive-scroll-area {
        padding-right: 6px;
        margin-right: 0;
    }

    .thumbnail-grid {
        gap: 10px;
        padding-bottom: 10px;
    }

    .thumb-container {
        flex: 0 0 96px;
        min-width: 96px;
    }

    .thumb {
        height: 96px;
    }

    /* 8. 아이템 상세 정보 팝업 모달 */
    #info-popup {
        justify-content: center !important;
        align-items: center !important;
        padding: 16px !important;
        background: rgba(0, 0, 0, 0.7) !important;
        pointer-events: auto !important;
        z-index: 999999 !important;
    }

    .info-card {
        width: 92vw !important;
        max-width: 360px !important;
        height: 75vh !important;
        max-height: 75dvh !important;
        display: flex !important;
        flex-direction: column !important;
        border-radius: 16px !important;
        overflow: hidden !important;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6) !important;
    }

    .popup-image-container {
        flex: 1 1 0 !important;
        min-height: 0 !important;
    }

    #info-title { font-size: 14px !important; margin-bottom: 4px !important; }
    #info-desc { font-size: 11px !important; line-height: 1.4 !important; }
    .info-tag { font-size: 10px !important; height: 28px !important; padding: 0 10px !important; line-height: 28px !important; }
    .close-info, .close-info img { width: 28px !important; height: 28px !important; }
    .info-body { padding: 4% !important; }
    .info-header { padding: 4% !important; }
    .info-title-container { padding: 4% !important; }

    /* 9. 온보딩 이용 안내 모달 */
    .instruction-card {
        width: 90vw !important;
        max-width: 360px !important;
        padding: 28px 20px !important;
        border-radius: 24px !important;
    }

    .instruction-card h1 {
        font-size: 1.5rem !important;
        margin-bottom: 24px !important;
    }
}

/* 초소형 스마트폰 (화면 폭 380px 이하: iPhone SE 등) */
@media (max-width: 380px) {
    .ui-overlay img {
        width: 100px !important;
    }
    .title-svg-interactive {
        width: 120px !important;
    }
    .controls a img,
    .controls button img {
        width: 38px;
        height: 38px;
    }
    .side-style-item {
        font-size: 0.72rem;
        padding: 5px 11px;
    }
}

/* 15. 모바일 가로 모드 (Landscape) - UI 요소 축소하여 원형 겹침 방지 */
@media (max-height: 500px) and (orientation: landscape) {
    .ui-overlay { top: max(20px, var(--sat)) !important; left: max(30px, var(--sal)) !important; }
    .ui-overlay img { width: 140px !important; margin-bottom: 6px !important; }
    .title-svg-interactive { width: 150px !important; }
    
    #side-style-wrapper { 
        top: max(85px, calc(var(--sat) + 75px)) !important;
        bottom: max(60px, calc(var(--sab) + 50px)) !important;
        transform: none !important; 
        left: max(30px, var(--sal)) !important; 
        pointer-events: auto !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    .side-style-header { display: block !important; margin-bottom: 12px !important; font-size: 1.2rem !important; }
    .side-style-container {
        max-height: none !important;
        flex: 1 !important;
        overflow-y: auto !important;
        padding-bottom: 20px !important;
    }
    
    .side-style-item { font-size: 0.65rem !important; padding: 4px 0 !important; }
    .side-style-item.active { font-size: 0.75rem !important; }
    
    .controls { 
        bottom: max(20px, var(--sab)) !important; 
        left: auto !important;
        right: max(30px, var(--sar)) !important;
        transform: none !important;
        gap: 16px !important; 
    }
    .controls a img, .controls button img { width: 56px !important; height: 56px !important; }
    
    #management-btn-wrapper { top: 50% !important; bottom: auto !important; right: max(24px, var(--sar)) !important; width: 52px !important; height: 52px !important; transform: translateY(-50%) !important; }
    #management-btn-wrapper button svg { width: 30px !important; height: 30px !important; }
    
    .digital-date { font-size: 0.7rem !important; bottom: max(20px, var(--sab)) !important; left: max(30px, var(--sal)) !important; top: auto !important; }
    #audio-control-btn { top: max(20px, var(--sat)) !important; right: max(30px, var(--sar)) !important; width: 36px !important; height: 36px !important; }

    #info-title { font-size: 12px !important; margin-bottom: 2px !important; }
    #info-desc { font-size: 9px !important; line-height: 1.3 !important; }
    .info-tag { font-size: 9px !important; height: 26px !important; padding: 0 8px !important; margin: 0 !important; line-height: 26px !important; }
    .close-info, .close-info img { width: 26px !important; height: 26px !important; }
    .info-body { padding: 4% !important; }
    .info-header { padding: 4% !important; }
    .info-title-container { padding: 4% !important; }
}
