body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    background-color: #F5F5F7;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* 무대 */
.phone-stage {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 80px 20px 40px;
    box-sizing: border-box;
    gap: 28px;
}

.phone-caption {
    font-size: 1.05rem;
    color: #555;
    text-align: center;
    letter-spacing: 0.2px;
}

.dark-mode .phone-caption {
    color: #bbb;
}

/* 폰 본체 */
.phone {
    --phone-w: 320px;
    --phone-h: 660px;
    width: var(--phone-w);
    height: var(--phone-h);
    background: linear-gradient(160deg, #2a2a2c 0%, #0f0f10 100%);
    border-radius: 52px;
    padding: 14px;
    box-sizing: border-box;
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.28),
        0 0 0 2px #1a1a1c,
        inset 0 0 0 2px rgba(255, 255, 255, 0.04);
    position: relative;
    transition: transform 0.4s ease;
}

.phone:hover {
    transform: translateY(-4px);
}

.phone-island {
    position: absolute;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    width: 105px;
    height: 30px;
    background: #000;
    border-radius: 20px;
    z-index: 5;
}

.phone-home-indicator {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 5px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    z-index: 6;
    transition: background 0.2s ease, transform 0.2s ease;
}

.phone-home-indicator:hover {
    background: rgba(255, 255, 255, 0.85);
}

.phone-home-indicator:active {
    transform: translateX(-50%) scale(0.96);
}

/* 화면 */
.phone-screen {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 40px;
    overflow: hidden;
    background: linear-gradient(160deg, #6dc3ff 0%, #8a6dff 60%, #ff7eb6 100%);
}

.dark-mode .phone-screen {
    background: linear-gradient(160deg, #2a3a5c 0%, #3b2a6b 60%, #6b2a55 100%);
}

/* 홈 / 앱 화면 공통 */
.home-screen,
.app-view {
    position: absolute;
    inset: 0;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

/* 홈 화면 */
.home-screen {
    display: flex;
    flex-direction: column;
    padding: 8px 18px 36px;
    box-sizing: border-box;
    opacity: 1;
    transform: scale(1);
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 0 18px;
    height: 30px;
    flex-shrink: 0;
}

.status-icons {
    display: inline-flex;
    gap: 6px;
    font-size: 11px;
}

.app-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: min-content;
    gap: 18px 12px;
    align-content: start;
    padding-top: 28px;
}

.app-icon {
    appearance: none;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: #fff;
    font-family: inherit;
    transition: transform 0.18s ease;
}

.app-icon:hover {
    transform: translateY(-2px);
}

.app-icon:active {
    transform: scale(0.92);
}

.icon-symbol {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    object-fit: cover;
    display: block;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    background: #fff;
}

.icon-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    max-width: 72px;
    text-align: center;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 앱 실행 (영상) 화면 */
.app-view {
    opacity: 0;
    transform: scale(1.08);
    pointer-events: none;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-view video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* stage row: 폰 + 글 패널 가로 배치 (데스크톱) */
.stage-row {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* 글 패널 (iframe) — 클릭 시 슬라이드 인 */
.article-panel {
    position: relative;
    width: 0;
    height: 660px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translateX(30px);
    pointer-events: none;
    transition: width 0.45s cubic-bezier(0.65, 0, 0.35, 1),
                margin-left 0.45s cubic-bezier(0.65, 0, 0.35, 1),
                opacity 0.35s ease 0.1s,
                transform 0.45s cubic-bezier(0.65, 0, 0.35, 1);
}

.phone-stage.article-open .article-panel {
    width: 580px;
    margin-left: 36px;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.article-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    background: #F5F5F7;
}

.article-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 0.2s ease, transform 0.15s ease;
}

.article-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.article-close:active {
    transform: scale(0.92);
}

/* 모바일 닫기 버튼 — 데스크톱에선 숨김 */
.article-close-mobile {
    display: none;
}

.dark-mode .article-panel {
    background: #1c1c1e;
}

.dark-mode .article-frame {
    background: #1c1c1e;
}

/* 좁은 데스크톱/태블릿: 폰 옆에 패널을 못 두면 아래로 */
@media (max-width: 1100px) {
    .phone-stage.article-open {
        justify-content: flex-start;
    }

    .stage-row {
        flex-direction: column;
    }

    .article-panel {
        width: 92vw;
        max-width: 580px;
        height: 0;
        margin-left: 0;
        transform: translateY(-20px);
        transition: opacity 0.3s ease;
    }

    .article-frame {
        height: auto;
        min-height: 200px;
    }

    .phone-stage.article-open .article-panel {
        width: 92vw;
        max-width: 580px;
        /* 콘텐츠 전체 높이만큼 — JS가 iframe 높이를 scrollHeight로 설정 */
        height: auto;
        margin-left: 0;
        margin-top: 24px;
        transform: translateY(0);
    }

    /* 모바일 floating 닫기 버튼 — Pip-Boy phosphor 그린 CRT 톤 */
    .article-close-mobile {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        position: fixed;
        bottom: 22px;
        left: 50%;
        transform: translateX(-50%);
        padding: 13px 26px;
        background: rgba(0, 26, 0, 0.88);
        color: #4eff4e;
        border: 1px solid rgba(78, 255, 78, 0.55);
        border-radius: 999px;
        font-size: 0.95rem;
        font-weight: 600;
        font-family: 'JetBrains Mono', monospace;
        letter-spacing: 0.02em;
        cursor: pointer;
        z-index: 300;
        box-shadow:
            0 10px 30px rgba(0, 0, 0, 0.45),
            0 0 18px rgba(78, 255, 78, 0.25);
        text-shadow:
            0 0 6px rgba(78, 255, 78, 0.7),
            0 0 14px rgba(78, 255, 78, 0.3);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease, transform 0.18s ease, background 0.2s ease, border-color 0.2s ease;
    }

    .article-close-mobile i {
        font-size: 0.9rem;
    }

    .article-close-mobile:hover {
        background: rgba(0, 50, 0, 0.92);
        border-color: rgba(78, 255, 78, 0.85);
        color: #87ff87;
    }

    .article-close-mobile:active {
        transform: translateX(-50%) translateY(1px);
    }

    /* 글 패널 열려 있을 때만 표시 */
    .phone-stage.article-open .article-close-mobile {
        opacity: 1;
        pointer-events: auto;
    }

    /* 데스크톱 작은 × 버튼은 모바일에서 숨김 */
    .article-close {
        display: none;
    }
}

/* 앱 열림 상태 */
.phone.app-open .home-screen {
    opacity: 0;
    transform: scale(0.94);
    pointer-events: none;
}

.phone.app-open .app-view {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .phone-stage {
        padding: 70px 16px 30px;
        gap: 18px;
    }

    .phone-caption {
        font-size: 0.95rem;
    }

    .phone {
        --phone-w: 280px;
        --phone-h: 580px;
        border-radius: 46px;
        padding: 12px;
    }

    .phone-screen {
        border-radius: 36px;
    }

    .phone-island {
        top: 18px;
        width: 90px;
        height: 26px;
    }

    .home-screen {
        padding: 6px 14px 30px;
    }

    .status-bar {
        font-size: 12px;
        padding: 0 14px;
        height: 26px;
    }

    .app-grid {
        gap: 14px 8px;
        padding-top: 24px;
    }

    .icon-symbol {
        width: 48px;
        height: 48px;
        border-radius: 12px;
    }

    .icon-label {
        font-size: 0.65rem;
        max-width: 64px;
    }

    .phone-home-indicator {
        width: 100px;
        height: 4px;
        bottom: 8px;
    }
}
