@font-face {
    font-family: 'Ownglyph';
    src: url('assets/Ownglyph.ttf') format('truetype');
}

@font-face {
    font-family: 'NanumSquareRound';
    font-weight: 700;
    src: url('../assets/fonts/NanumSquareRoundB.ttf') format('truetype');
}

@font-face {
    font-family: 'NanumSquareRound';
    font-weight: 800;
    src: url('../assets/fonts/NanumSquareRoundEB.ttf') format('truetype');
}

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

body {
    font-family: 'NanumSquareRound', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: #fff;
    color: #111;
    line-height: 1.7;
    font-weight: 700;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── Screen ── */

.screen { transition: opacity 0.3s; }
.screen--out { opacity: 0; }
.screen--in { animation: fadeIn 0.35s ease; }

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

/* ── Page ── */

.page {
    padding: 80px 24px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 40px;
}

.logo {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: #111;
    display: block;
    margin-bottom: 28px;
}

.text-block h1 {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.35;
    letter-spacing: -0.03em;
    margin-bottom: 16px;
}

.text-block p {
    color: #555;
    font-size: 1rem;
    line-height: 1.8;
    word-break: keep-all;
}

/* ── App wrapper ── */

.app-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* app-canvas-outer: 앱 이미지 + 툴바를 함께 담는 relative 컨테이너 */
.app-canvas-outer {
    position: relative;
    display: inline-block;
}

/* ── 캔버스 영역 ── */

.app-canvas-wrap {
    position: relative;
    width: 280px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    cursor: crosshair;
}

.app-bg {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 20px;
    pointer-events: none;
    user-select: none;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#overlayLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* 도구별 커서 */
.app-canvas-wrap.tool-underline { cursor: crosshair; }
.app-canvas-wrap.tool-sticker   { cursor: cell; }
.app-canvas-wrap.tool-comment   { cursor: text; }
.app-canvas-wrap.tool-eraser    { cursor: pointer; }

/* 캔버스는 항상 이벤트 받음 — wrap이 전체 처리 */
canvas { pointer-events: none; }
#overlayLayer { pointer-events: none; }

/* ── 배치된 스티커 ── */

.placed-sticker {
    position: absolute;
    width: 32px;
    height: 32px;
    object-fit: contain;
    pointer-events: auto;
    cursor: grab;
}

.placed-sticker:active { cursor: grabbing; }

.placed-sticker--anim {
    animation: popIn 0.2s ease;
}

@keyframes popIn {
    from { opacity: 0; transform: translate(-50%,-50%) scale(0.6); }
    to   { opacity: 1; transform: translate(-50%,-50%) scale(1); }
}

/* ── 배치된 밑줄 ── */

.placed-line {
    position: absolute;
    height: 18px;
    pointer-events: auto;
    cursor: grab;
    transform: translateY(-50%);
}

.placed-line::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1.5px;
    background: #2563eb;
    border-radius: 1px;
    transform: translateY(-50%);
}

.placed-line:active { cursor: grabbing; }

.placed-line--preview { opacity: 0.4; }

/* ── 배치된 코멘트 ── */

.placed-comment {
    position: absolute;
    font-family: 'Ownglyph', sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    color: #2563eb;
    max-width: 110px;
    line-height: 1.45;
    word-break: keep-all;
    pointer-events: auto;
    cursor: grab;
    transform: translate(-50%, 0);
    outline: none;
    user-select: none;
    -webkit-user-select: none;
}

.placed-comment:active { cursor: grabbing; }

.placed-comment--anim {
    animation: fadeUp 0.2s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translate(-50%, 6px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── 세로 툴바 ── */

.toolbar {
    position: absolute;
    top: 0;
    left: calc(100% + 10px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 16px;
}

.toolbar-divider {
    height: 1px;
    background: #e3e3e3;
    margin: 4px 0;
}

.tool-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border: 1.5px solid #e3e3e3;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    color: #999;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.tool-btn:hover { border-color: #111; color: #111; }
.tool-btn.active { border-color: #111; color: #111; background: #f7f7f7; }
.tool-btn--disabled { opacity: 0.3; pointer-events: none; }

/* ── 스티커 버튼 래퍼 ── */

.sticker-btn-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── 스티커 패널 (툴바 오른쪽으로 팝업) ── */

.sticker-panel {
    display: none;
    flex-direction: column;
    gap: 4px;
    position: absolute;
    top: 50%;
    left: 56px;
    transform: translateY(-50%);
    background: #fff;
    border: 1.5px solid #e3e3e3;
    border-radius: 10px;
    padding: 6px;
    z-index: 10;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.sticker-panel::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -5.5px;
    margin-top: -5px;
    width: 8px;
    height: 8px;
    background: #fff;
    border-left: 1.5px solid #e3e3e3;
    border-bottom: 1.5px solid #e3e3e3;
    transform: rotate(45deg);
}

.sticker-panel.panel--active { display: flex; }

.sticker-opt {
    width: 36px;
    height: 36px;
    border: 1.5px solid transparent;
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    transition: border-color 0.15s, background 0.15s;
}

.sticker-opt img { width: 24px; height: 24px; object-fit: contain; }
.sticker-opt:hover { border-color: #ddd; }
.sticker-opt.opt--active { border-color: #111; background: #f7f7f7; }

/* ── 코멘트 팝업 ── */

.comment-popup-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}

.comment-popup-overlay.popup--active {
    opacity: 1;
    pointer-events: auto;
}

.comment-popup {
    background: #fff;
    border-radius: 20px;
    padding: 0;
    max-width: 340px;
    width: 92%;
    text-align: left;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
    overflow: hidden;
    transform: translateY(16px) scale(0.97);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s;
}

.comment-popup-overlay.popup--active .comment-popup {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* 헤더 */
.comment-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 10px;
    border-bottom: 1px solid #f0f0f0;
}

.comment-popup-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: #111;
    letter-spacing: -0.02em;
}

.comment-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: #aaa;
    cursor: pointer;
    padding: 4px;
    transition: color 0.15s;
}
.comment-close-btn:hover { color: #111; }

.comment-confirm-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: #aaa;
    cursor: pointer;
    padding: 4px;
    transition: color 0.15s;
}
.comment-confirm-btn:hover { color: #111; }

/* 입력 영역 */
.comment-input-wrap {
    position: relative;
    padding: 12px 16px 16px;
}

.comment-input {
    width: 100%;
    border: none;
    padding: 4px 0;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    color: #111;
    resize: none;
    outline: none;
    line-height: 1.65;
    background: transparent;
}

.comment-input:focus {
    background: transparent;
}
.comment-input::placeholder { color: #c0c0c0; font-weight: 700; }

.comment-char-count {
    display: block;
    text-align: right;
    font-size: 0.75rem;
    color: #bbb;
    margin-top: 6px;
    font-weight: 700;
    padding-right: 2px;
}

/* ── 힌트 ── */

.hint-text {
    font-size: 0.82rem;
    color: #aaa;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-top: 24px;
}

/* ── 다음 버튼 ── */

.next-btn {
    width: 100%;
    padding: 15px;
    font-size: 1rem;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s, transform 0.3s, background 0.2s;
}
.next-btn--in { opacity: 1; transform: translateY(0); }

/* ── App wrapper spacing ── */
.app-wrapper {
    margin-top: 0px;
    margin-bottom: 24px;
}

/* ── Reserve ── */

.reserve { width: 100%; margin-top: 56px; }

.reserve-benefit {
    font-size: 0.95rem;
    font-weight: 800;
    color: #111;
    margin-bottom: 16px;
    letter-spacing: -0.02em;
}

.reserve-form { width: 100%; }
.input-row { display: flex; gap: 8px; }

.input-row input[type="email"] {
    flex: 1;
    padding: 13px 14px;
    border: 2px solid #E3E3E3;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    font-weight: 700;
    outline: none;
    background: #fff;
    transition: border-color 0.2s;
}
.input-row input[type="email"]:focus { border-color: #111; }
.input-row input[type="email"].input--error { border-color: #E05252; }
.input-row input[type="email"]::placeholder { color: #bbb; }

.btn {
    padding: 13px 22px;
    background: #000;
    color: #fff;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.2s;
}
.btn:hover { background: #333; }
.btn:disabled { background: #999; cursor: default; }

.form-error {
    display: block;
    margin-top: 8px;
    font-size: 0.82rem;
    color: #E05252;
    min-height: 1.2em;
}

/* ── Mockup ── */

.visual { width: 100%; display: flex; justify-content: center; }
.mockup { width: 280px; box-shadow: 0 16px 36px rgba(0,0,0,0.1); }

/* ── Modal ── */

.modal-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
.modal-overlay.modal--active { opacity: 1; pointer-events: auto; }

.modal {
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px 28px;
    max-width: 320px;
    width: 90%;
    text-align: center;
}
.modal-text { font-size: 0.95rem; line-height: 1.7; color: #222; margin-bottom: 24px; }
.modal-btn {
    padding: 10px 32px;
    background: #000; color: #fff;
    border: none; border-radius: 8px;
    font-size: 0.9rem; font-weight: 800;
    font-family: inherit; cursor: pointer;
}
.modal-btn:hover { background: #333; }

/* ── Footer ── */

footer { padding: 40px 0; border-top: 1px solid rgba(0,0,0,0.05); }
.footer-inner { display: flex; justify-content: center; align-items: center; gap: 20px; }
.copyright { color: #999; font-size: 12px; }
.footer-link { color: #999; font-size: 12px; }
.footer-link:hover { color: #555; }

/* ── Mobile ── */

@media (max-width: 600px) {
    .page { padding: 60px 20px 48px; gap: 32px; }
    .text-block h1 { font-size: 1.6rem; }
    .mockup { width: 240px; }
    .input-row { flex-direction: column; }
    .btn { width: 100%; padding: 13px; }
    .app-canvas-wrap { width: 240px; }

    /* 툴바를 캔버스 아래 가로 배치 */
    .app-canvas-outer {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .toolbar {
        position: static;
        flex-direction: row;
        padding: 12px 0 0;
        gap: 8px;
        justify-content: center;
    }

    .sticker-panel {
        position: absolute !important;
        flex-direction: row;
        justify-content: center;
        top: calc(100% + 12px);
        bottom: auto;
        left: 50%;
        transform: translateX(-50%);
        margin-top: 0;
    }

    .sticker-panel::before {
        top: -5.5px;
        bottom: auto;
        left: 50%;
        margin-left: -4px;
        margin-top: 0;
        border-left: 1.5px solid #e3e3e3;
        border-top: 1.5px solid #e3e3e3;
        border-bottom: none;
        border-right: none;
        transform: rotate(45deg);
    }

    /* 코멘트 팝업 모바일 최적화 (크기 축소) */
    .comment-popup {
        max-width: 280px;
        width: 85%;
        border-radius: 16px;
    }
    .comment-popup-header {
        padding: 10px 14px 8px;
    }
    .comment-input-wrap {
        padding: 10px 14px 12px;
    }
}
