/* [style.css] FINAL INTEGRATED VERSION v7 */

/* ... (기존 상단 코드 및 PC 스타일 유지) ... */
@import url('https://fonts.googleapis.com/css2?family=Cutive+Mono&display=swap');
@import url('https://use.typekit.net/koy2ghk.css');

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0; padding: 0; background-color: #ffffff; color: #000000;
    font-family: 'Courier New', Courier, monospace; font-size: 16px; line-height: 1;
    overflow-x: hidden; overflow-y: auto; min-height: 100vh;
}

a { text-decoration: none; color: inherit; transition: opacity 0.2s; }
a:hover { opacity: 0.7; }
button { font-family: 'Courier New', Courier, monospace; cursor: pointer; }

/* ... [PC용 스타일들] ... */
.typo-logo { font-family: "etna-x-condensed", sans-serif; font-weight: 400; color: #000; line-height: 0.8; letter-spacing: -0.8vw; font-size: 35vw; width: max-content; white-space: nowrap; margin: -3vw 0 15vh 0; position: relative; left: -0.5vw; z-index: 1; pointer-events: none; }
.typo-block { font-family: 'Courier New', Courier, monospace; font-size: 16px; line-height: 1; word-spacing: -1px; color: #000; }
.btn-rect { background: #fff; color: #000; border: 1px solid #000; font-family: 'Courier New', Courier, monospace; font-size: 16px; padding: 15px 30px; display: inline-block; transition: 0.2s; text-decoration: none; }
.btn-rect:hover { background: #000; color: #fff; transform: translateY(-2px); }
.hero-wrapper { width: 100%; min-height: 100vh; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; text-align: center; padding: 0 50px 200px 50px; position: relative; z-index: 10; }
#floating-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 500; overflow: hidden; }
.floating-obj { position: absolute; opacity: 0; animation: appearSlow 3s ease-out forwards; pointer-events: auto; }
.floating-obj.vanish { animation: fadeOutSlow 3s ease-out forwards !important; }
@keyframes appearSlow { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOutSlow { from { opacity: 1; } to { opacity: 0; } }
.unified-text { font-family: 'Courier New', Courier, monospace; font-size: 16px; line-height: 1.4; color: #000; text-align: center; margin: 0 auto; word-break: keep-all; max-width: 100%; width: fit-content; }

/* Generate (PC) */
.gen-layout { display: flex; flex-direction: column; justify-content: space-between; align-items: center; width: 100%; height: 100vh; overflow: hidden; background: #fff; padding-top: 0; padding-bottom: 2vh; }
.gen-header { flex: 0 0 auto; text-align: center; padding-top: 0; margin-bottom: -30px; width: 100%; z-index: 10; }
.gen-title { font-family: "etna-x-condensed", sans-serif; font-weight: 400; color: #000; margin: 0; font-size: min(160px, 18vh); line-height: 0.85; letter-spacing: -4px; }
.gen-subtitle { font-family: "Courier New", Courier, monospace; color: #000; font-size: min(16px, 2vh); line-height: 1.2; letter-spacing: -0.5px; margin-top: 2vh; }
.gen-workspace { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; padding: 0 0 0 0; margin-top: 20px; overflow: hidden; }
.grid-standard { max-width: 100%; transition: width 0.3s cubic-bezier(0.25, 1, 0.5, 1); }
#canvas-container { display: flex; justify-content: center; align-items: center; margin: 0 auto; border: none; background: transparent; box-sizing: border-box; overflow: hidden; font-size: 0; line-height: 0; }
#canvas { display: block; width: 100%; height: 100%; background-color: #fff; border: 1px solid #000; box-sizing: border-box; }

/* [PC용 컨트롤 버튼 스타일] */
.gen-controls { flex: 0 0 auto; display: flex; flex-direction: column; gap: 30px; z-index: 100; margin-bottom: 14vh; width: 100%; }
.ctrl-row { display: flex; justify-content: space-between; align-items: center; width: 100%; position: relative; }
.ctrl-group-left, .ctrl-group-right { display: flex; gap: 8px; align-items: center; }

.btn-sm { background: #fff; color: #000; border: 1px solid #000; font-family: 'Courier New', Courier, monospace; font-size: 14px !important; font-weight: 400; padding: 4px 7px; height: 33px; display: inline-flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; white-space: nowrap; position: relative; }
.btn-sm:hover, .btn-sm.active { background: #000; color: #fff; }
.btn-black { background: #000; color: #fff; border: 1px solid #000; }
.btn-nav { font-size: 14px !important; padding: 6px 0; height: auto; width: 160px; justify-content: center; }
.btn-color { width: 33px; height: 33px; padding: 0 !important; background: #fff; border: 1px solid #000; cursor: pointer; display: inline-block; position: relative; overflow: hidden; }
.popup-wrapper { position: relative; display: inline-block; }
.popup-list { display: none; position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 10px; width: 100%; background: #fff; border: 1px solid #000; z-index: 2000; flex-direction: column; text-align: center; pointer-events: auto !important; }
.popup-item { padding: 8px 0; border-bottom: 1px solid #000; font-family: 'Courier New', Courier, monospace; font-size: 14px !important; cursor: pointer; background: #fff; color: #000; width: 100%; }
.popup-item:last-child { border-bottom: none; }
.popup-item:hover { background: #000; color: #fff; }
.popup-list.show { display: flex; }
@media (max-width: 400px) { .btn-sm { font-size: 13px !important; padding: 4px 5px; } }

/* [Ingredient, Mypage 등 PC 스타일] */
.ing-layout-fix { position: relative; width: 100%; height: 100vh; background: #fff; overflow: hidden; }
.ing-header-fix { position: absolute; top: 0; left: 0; width: 100%; background: transparent; z-index: 50; padding-bottom: 20px; pointer-events: none; }
.ing-subtitle { font-family: "Courier New", Courier, monospace; color: #000; font-size: min(16px, 2vh); line-height: 1.2; letter-spacing: -0.5px; margin-top: 5vh; }
.ing-workspace-fix { width: 100%; height: 100%; overflow-y: auto; padding-top: 18vh; }
.ing-grid { width: 100%; padding: 50px 50px 120px 50px; display: grid; grid-template-columns: repeat(10, 1fr); gap: 10px; }
.ing-thumb { width: 100%; aspect-ratio: 1 / 1.414; object-fit: cover; background: transparent; border: 1px solid #000; display: block; transition: opacity 0.2s; }
.ing-thumb:hover { opacity: 0.8; }

/* [수정됨: PC에서 네비게이션이 버튼 위로 올라오도록 z-index 300 유지] */
.overlay-controls { position: absolute; bottom: 7vh; left: 0; width: 100%; background: transparent; pointer-events: none; padding-bottom: 2vh; z-index: 300; display: flex; justify-content: center; }
.overlay-controls button, .overlay-controls .popup-wrapper { pointer-events: auto; background: #fff; }

.mypage-info { width: 100%; text-align: center; padding: 4vh 0 4vh 0; font-family: 'Courier New', Courier, monospace; }
.credit-row { font-size: 14px; margin-bottom: 12px; color: #000; word-spacing: -1px; }
.mypage-grid { display: flex !important; align-items: flex-start; gap: 15px; width: 100%; padding: 0px 50px 120px 50px; }
.brag-grid { display: flex !important; align-items: flex-start; gap: 15px; width: 100%; padding: 80px 50px 120px 50px; }
.gallery-col { flex: 1; display: flex; flex-direction: column; gap: 15px; min-width: 0; }
.gallery-item { width: 100%; margin-bottom: 0; display: block; break-inside: avoid; }
.gallery-img-box { width: 100%; height: auto !important; aspect-ratio: auto !important; border: 1px solid #000; background: #fff; position: relative; cursor: pointer; display: block; }
.gallery-img-box img { width: 100%; height: auto !important; display: block; object-fit: cover; }
.gallery-meta { display: flex; justify-content: space-between; font-size: 12px; font-family: 'Courier New', Courier, monospace; padding-top: 4px; margin-top: 3px; }
.auth-overlay, .charge-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.95); z-index: 9999; display: none; justify-content: center; align-items: center; }
.charge-overlay { background: rgba(0, 0, 0, 0.5); }
.auth-box, .charge-box { background: #fff; border: 1px solid #000; padding: 40px; width: 320px; text-align: center; }
.charge-box { width: 340px; position: relative; }
.auth-title, .charge-title { font-family: "etna-x-condensed", sans-serif; font-weight: 400; font-size: 60px; letter-spacing: -1.26px; margin: -10px 0 40px 0; }
.auth-input, .charge-input { width: 100%; padding: 12px; margin-bottom: 8px; border: 1px solid #000; font-family: 'Courier New', Courier, monospace; font-size: 14px; outline: none; text-align: center; }
.auth-input { text-align: left; }
.auth-btn, .btn-charge-action, .btn-lemon { width: 100%; padding: 12px; margin-top: 0px; background: #000; color: #fff; border: 1px solid #000; font-family: 'Courier New', Courier, monospace; font-size: 16px; cursor: pointer; }
.btn-charge-action { font-size: 14px; }
.btn-lemon { background: #fff; color: #000; font-weight: bold; }
.btn-lemon:hover { background: #000; color: #fff; }
.auth-link { display: block; margin-top: 30px; font-size: 12px; text-decoration: underline; cursor: pointer; color: #000; }
.auth-close, .charge-close { margin-top: 25px; font-size: 12px; cursor: pointer; opacity: 0.5; font-family: 'Courier New'; }
.charge-close { position: absolute; top: 10px; right: 15px; margin-top: 0; }
.charge-desc { font-family: 'Courier New'; font-size: 12px; margin-bottom: 15px; line-height: 1.4; }
.charge-divider { margin: 20px 0; border-bottom: 1px dashed #000; }
.filter-wrapper { position: relative; display: inline-block; pointer-events: auto !important; }
.popup-list.popup-down { bottom: auto !important; top: 100%; margin-bottom: 0; margin-top: 10px; }
.btn-filter { background: transparent; border: 1px solid #000; font-family: 'Courier New'; font-size: 14px; padding: 5px 15px; cursor: pointer; width: 140px; text-align: center; display: flex; justify-content: center; align-items: center; background: #fff; margin-top: 60px; pointer-events: auto !important; }
.btn-filter:hover { background: #000; color: #fff; }
.brag-filter-box { pointer-events: auto !important; }


/* ==========================================================================
   [PART 7] MOBILE OPTIMIZATION (ONLY for width <= 768px)
   * FINAL DUAL-TRACK v3: 
   * - 네비게이션/버튼/필터 위치 최적화
   * - Bragging 갤러리 위치 상향 조정
   ========================================================================== */

@media (max-width: 768px) {

    /* [1. 상단 타이틀] */
    .gen-title, .typo-logo {
        font-size: 35vw !important;
        line-height: 0.8;
        letter-spacing: -1.2vw;
        margin-top: 1vh !important;
        margin-bottom: 0.15em !important;
        text-align: center;
        width: 100%;
    }

    /* [2. 캔버스 영역] */
    .gen-workspace {
        position: absolute; top: 0; left: 0; width: 100%; height: 100%;
        display: flex !important; justify-content: center !important; align-items: center !important;
        padding: 0 !important; pointer-events: none; z-index: 10; margin-top: 12px;
    }
    #canvas-container { pointer-events: auto; }

    /* [3. 하단 네비게이션] */
    .overlay-controls {
        position: absolute !important;
        bottom: 30px !important;
        left: 0; width: 100%;
        display: flex !important; justify-content: center !important;
        z-index: 300 !important;
        pointer-events: none;
    }

    .overlay-controls .popup-wrapper {
        pointer-events: auto;
        width: 50vw !important; 
        background: transparent !important;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        position: relative;
    }

    .overlay-controls .btn-nav {
        width: 100% !important; 
        height: auto !important;
        padding: 15px 0 !important;
        font-size: 14px !important;
        color: #000 !important;
        border: 1px solid #000 !important;
        background: #fff !important;
        display: flex;
        justify-content: center;
        align-items: center;
        box-shadow: none !important;
    }

    .overlay-controls .btn-nav:active,
    .overlay-controls .btn-nav:focus {
        color: #000 !important;
        background: #fff !important;
    }

    .overlay-controls .popup-list {
        width: 100% !important;
        left: 0 !important;
        bottom: 100% !important;
        margin-bottom: 10px !important;
        transform: none !important;
    }

    /* [4. 컨트롤 버튼 (5개)] */
    .gen-controls {
        position: absolute !important;
        bottom: 105px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 100;
        margin: 0 !important;
        padding: 0 !important;
        width: 75.3% !important;
        max-width: 500px !important;
    }

    .gen-controls .ctrl-row {
        display: grid !important;
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 4px !important;
        width: 100% !important;
    }
    .gen-controls .ctrl-group-left,
    .gen-controls .ctrl-group-right { display: contents !important; }

    .gen-controls button, .gen-controls .popup-wrapper, .gen-controls .btn-color {
        width: 100% !important; height: 40px !important; font-size: 14px !important;
        border: 1px solid #000 !important; 
        background: #fff;
        display: flex; justify-content: center; align-items: center;
    }
    
    .gen-controls .btn-black,
    .gen-controls button.btn-black {
        background: #000 !important;
        color: #fff !important;
    }

    .gen-controls .popup-wrapper button { border: none !important; width: 100% !important; height: 100% !important; }

    /* [5. Bragging 페이지 수정 (모바일 전용)] */
    
    /* 필터 버튼: 텍스트와 겹치지 않게 아래로 내림 (기존보다 margin-top 늘림) */
    .brag-filter-box { 
        margin-top: 60px !important; 
        margin-bottom: 30px !important; 
        pointer-events: auto !important;
        display: flex !important;
        justify-content: center !important;
    }
    .btn-filter { 
        margin-top: 0 !important; 
        width: 120px; 
    }

    /* 갤러리 그리드: 위쪽 여백을 줄여서 위로 끌어올림 */
    /* 기존 padding-top이 80px(웹)이거나 120px이었던 것을 20px로 강제 조정 */
    .brag-grid { 
        padding-top: 80px !important; 
    }
    
    /* (참고) 다른 그리드 설정 유지 */
    .mypage-grid, .brag-grid { 
        padding-left: 15px !important;
        padding-right: 15px !important;
        padding-bottom: 120px !important;
        gap: 10px !important; 
    }

    /* [6. 기타 설정 유지] */
    .hero-wrapper { height: 100vh !important; padding: 0 20px 40px 20px !important; display: flex !important; flex-direction: column !important; justify-content: flex-start !important; }
    .hero-wrapper .unified-text { font-size: 14px !important; line-height: 1.5; margin: 0 auto; max-width: 90%; }
    .btn-rect { margin-top: auto !important; margin-bottom: 10px !important; width: 60%; text-align: center; }
    .btn-rect + div { margin-top: 0 !important; }
    .ing-grid { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 5px !important; padding: 20px 10px 120px 10px !important; }
    .gen-workspace .unified-text { padding: 0 20px !important; font-size: 13px !important; }
    .btn-sm { font-size: 12px !important; padding: 6px 10px; }
}