/* define global variables */
:root {
    --app_max_width: 1200px;
    --popup_max_width: 1150px;
    --list_app_max_width: 300px;

    --header_height: 50px;
    --bottom_bar_height: 75px;
    --input_beside_button_width: 17px;
    --app_list_width_padding: 10px;
    --app_list_height_padding: 325px;
    --app_rank_list_height_padding: 105px;
    --user_list_height_padding: 220px;
    --push_list_height_padding: 290px;
    --content_detail_height_padding: 40px;
    --mobile_screen_gap: 38px;
}

* { padding: 0; margin: 0; }

html, body {
    height: 100%;
    width: 100%;

    margin: 0px;
    padding: 0 !important;
    box-sizing: border-box;

    position: relative; /* 고정 제거 */
    overflow: hidden;
    overscroll-behavior-y: contain;

    /* user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none; */

    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

a { color: #222; text-decoration: none; }
a:active { color : #2698cb; }

#app {
    position: relative;
    height: 100%;
    width: 100%;

    overflow: hidden;
    margin: auto;
    padding: 0;
    box-sizing: border-box;
}

.mainComponent {
    position: relative;
    width: 100%;
    height: 100%;

    margin:0;
    padding:0;
    box-sizing: border-box;

    overflow: auto; /* 플로팅 메뉴 화면 넘어갈때 스크롤 보여지기 위해 */
    -webkit-overflow-scrolling: touch;

    text-align: center;
    font-size: 17px;
    background-color: #ededed;

    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
}

.mainWrapper {
    height: 100%;
    width: 100%;

    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding: 0;
    margin: 0;
    overflow: hidden;
    box-sizing: border-box;
    text-align: center;

    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch; /* 변경: 아이템 가로 전체 차지 */
    background-color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/**********
* contents(tab) area    *
***********/
.contentsArea {
    flex:1; /* 남은 공간 전체 차지. flexGrow, flexShrink, flexBasis 한번에 적용 */
    min-height: 0;         /* 내부 스크롤 가능하게 하는 핵심 */

    display: none;
    flex-direction: row;
    flex-wrap: wrap;    /* wrap: multi-line, nowrap: single-line */
    justify-content: space-around;
    align-items: stretch;   /* flex-wrap: nowrap 시 적용 */
    align-content: flex-start;  /* flex-wrap: wrap 시 적용 */


    width: 100%;
    max-height: 100%;
    height:100%;
    overflow: auto;

    box-sizing: border-box;
    margin: 0;
    padding: 0;

    scroll-behavior: smooth; /* 프로그래밍 스크롤 부드럽게 */
    overscroll-behavior-y: contain; /* Android/Chrome 바운스 느낌 */
    -ms-overflow-style: none;
    scrollbar-width: none;

    /* -webkit-overflow-scrolling: touch;  iOS용 바운스 그러나 사용시 z-index가 무력화됨. 사용금지  */

    /* border: 1px solid red; */
}
.contentsArea::-webkit-scrollbar {
    display: none;
}
.contentsAreaShow {
    display:flex;
}
.contentsAreaNoScroll {
    overflow-y: hidden;
}
.contentsArea > * {
    position: relative;
    z-index: auto; /* z-index: 1인 요소보다 아래 위치 for titlebar */
}

.eachContentArea {
    position: relative;
    margin: 10px;
    padding: 0px;
    box-sizing: border-box;
    overflow: hidden;
    scroll-behavior: smooth;
    flex-shrink: 1;
    width:100%;
    max-width: 100%;
    height:fit-content;
}



/* snsMoviePlayer style */
.eachContentSnsMoviePlayerArea {
    border: 1px solid #9c9c9d28;
    border-radius: 10px;
    background-color: white;

    overflow: hidden;

    width:100%;
    height: auto;
}

.eachContentYouTubePlayerContainer{
    position: relative; /* 자식 iframe의 absolute 기준점 */
    width: 100%;
    height: 0; /* aspect-ratio 트릭을 위한 높이 0 */
    padding-bottom: 56.25%; /* 16:9 비율 (9 / 16 = 0.5625 -> 56.25%) */
    aspect-ratio: 16 / 9; /* 또는 aspect-ratio: 16 / 9; 최신 브라우저 지원 시 */
}

.eachContentYouTubePlayer{
    position: absolute; /* 부모 기준 절대 위치 */
    top: 0;
    left: 0;
    width: 100%;   /* 부모 크기 꽉 채움 */
    height: 100%;  /* 부모 크기 꽉 채움 */

    border: none;
}

/* tiktokMoviePlayer style */
.eachContentTikTokMoviePlayerArea {
    border: 1px solid #9c9c9d28;
    border-radius: 10px;
    background-color: white;

    width:auto;
    height: auto;
}

.eachContentTiktokPlayerContainer{
    position: relative; /* 자식 iframe의 absolute 기준점 */
    padding:0;
    margin: 0 auto 0 auto;

    width:100%;
    height: auto;

    /* border: 1px solid blue; */
}
.eachContentTiktokPlayerContainer > blockquote,
.eachContentTiktokPlayerContainer > iframe {
    /* border:2px solid red; */

    /* 기본 마진/패딩 제거 */
    margin: 0 !important; /* 틱톡 인라인 스타일이나 다른 CSS보다 우선하도록 !important 사용 고려 */
    padding: 0 !important; /* 틱톡 인라인 스타일이나 다른 CSS보다 우선하도록 !important 사용 고려 */

    /* 너비 설정 (필요시) */
    display: block;
    width:100% !important;
    height: auto !important;
    /* aspect-ratio: 16 / 9 !important; */
    z-index: 0 !important;

    border:0px !important;
}

/* instagramMoviePlayer style */
.eachContentInstagramMoviePlayerArea {
    border: 1px solid #9c9c9d28;
    border-radius: 10px;
    background-color: white;

    width:auto;
    height: auto;
}

.eachContentInstagramPlayerContainer{
    position: relative; /* 자식 iframe의 absolute 기준점 */
    padding:0;
    margin: 0 auto 0 auto;

    width: fit-content;
    height: fit-content;

    /* border: 1px solid blue; */
}

.contentEditBlocker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0);
    cursor: pointer;
}

/* iframe style */
.eachContentIframe{
    width: 100%;
    height: 100%;

    border: none;
}

/**********
* tabbarWebSite     *
***********/
.tabbar-web-site-area{
    /* border: 1px solid red; */

    width: 100%;
    height: calc(100% - 5px);
    margin: 0px 0 0 0;
    padding: 0;
}

/**********
* bottom tab bar    *
***********/
.bottom-bar {
    height: var(--bottom_bar_height);
    width: 100%;
    margin: 0;
    padding: 0;

    background-color: #f9f8f8;

    flex-shrink: 0; /* 높이 유지 (중요) */

    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;

    /* border:1px solid red; */
}

.bottom-bar::-webkit-scrollbar {
    display: none; /* for Chrome, Safari, and Opera */
}
.bottom-bar-no-scroll {
    overflow-x: hidden;
}

.bottom-bar-element {
    display: inline-block;

    width: 25%;
    min-width:70px;
    height: 100%;

    font-weight: 500;
    font-size: 15px;
    text-align: center;

    /* border:1px solid blue; */
}
.bottom-bar:active .bottom-bar-element {
	/* color: #78909C; */
	transition: all 0.5s cubic-bezier(.25,.8,.25,1);
}

.bottom-bar-element-container{
    /* border:1px solid red; */

    display:flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    /* display:inline-block; */
    position:relative;

    margin: 7px auto auto auto;
    width: 100%;
    cursor: pointer;
}

.bottom-bar-element-container.check-mark::after {
    content: "";
    position: absolute;
    right: -20px;
    bottom: 0px;
    width: 15px;
    height: 15px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 15'%3E%3Ccircle cx='7.5' cy='7.5' r='7.5' fill='%23d9534f'/%3E%3Cpath d='M4 8l2.5 2.5L11 6' stroke='%23fff' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: contain; /* cover 대신 contain → 잘림 방지 */
    pointer-events: none;
    z-index: 2147483647;
}

.bottom-bar-element-image {
    /* border: 1px solid red; */

    border-radius: 5px;
    width: 30px;
    height: 30px;
    object-fit: contain;

    margin: 0;
    padding: 0;
}

.bottom-bar-element-title{
    width:100%;
    /* height: 16px; */
    /* overflow: hidden; */

    line-height: 1.5;

    mix-blend-mode: normal;
    color: black;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.helpButtonIcon {
    width: var(--input_beside_button_width);
    height: var(--input_beside_button_width);

    vertical-align: middle;

    margin:0 5px 0 5px;

    cursor: pointer;
}

/* Text Button Area */
.textButtonArea{
    display: inline-block;
    width: calc(100% - 35px);
    text-align: center;
    margin-top: 7px;
    padding:0px;
    line-height: 1px;

    /* border:1px solid red; */
}
.textButtonRightArea{
    text-align: right;
    margin-right: 35px;
}

.textButton {
    display: inline-block;

    margin: 0px;
    color: rgb(56, 54, 54);
    text-align: center;
    text-decoration: none;
    border: 0px solid rgb(56, 54, 54);
    background-color:transparent;
    font-size: 16px;
    font-weight: normal;
    word-wrap: none;
    cursor: pointer;

    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
.textButton:active, .textButton:hover {
    opacity: .7;
    outline: none;
    color: #2698cb;
}
.textButtonLeft {
    text-align: left;
}
.textButtonAutoWidth{
    width:auto;
}



/**********
* content context menu    *
***********/
.menuBackground{
    position: absolute; /* Stay in place */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(169, 169, 169, 0.665);
    background-color: transparent;
    z-index: 1;
}

.contentContextMenuArea{
    position: absolute;
    display: block;
    width:300px;
    height: fit-content;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(51, 65, 85, 0.95));
    backdrop-filter: blur(20px);
    border: 1px solid rgba(71, 85, 105, 0.3);
    border-radius: 16px;
    margin: 20px auto;
    padding: 20px;
    box-sizing: border-box;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: slideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2147483647;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 20px;

    width:100%;
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.quick-action:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.quick-action.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quick-action.disabled:hover {
    background: rgba(255, 255, 255, 0.05);
    transform: none;
}

.quick-action-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 8px;
    color: white;
}

.quick-action-text {
    font-size: 14px;
    color: #e4e6ea;
    text-align: center;
    font-weight: 500;
}

/* User Section */
.user-section {
    width:100%;

    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 20px;
    box-sizing: border-box;
    margin: 20px auto 0px auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    padding: 15px 10px;
    box-sizing: border-box;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 15px;
}

.user-info:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin-right: 15px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: bold;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
}

.user-name {
    color: white;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.user-status {
    color: #9ca3af;
    font-size: 14px;
}

/* Menu Items */
.menu-item {
    display: flex;
    padding: 15px 15px;
    margin: 5px 0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #e4e6ea;
    font-size: 14px;
    font-weight: 500;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: translateX(5px);
}

.menu-item-icon {
    width: 20px;
    height: 20px;
    margin-right: 15px;
    flex-shrink: 0;
    opacity: 0.8;
}

.menu-item:hover .menu-item-icon:not(.disabled) {
    opacity: 1;
}

.menu-item-text {
    flex: 1;
    text-align: left;
}

.close-button {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.977); /* 평상시엔 은은하게 */
    background: rgba(30, 29, 29, 0.705);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.close-button svg {
    width: 18px;
    height: 18px;
}

.close-button:hover {
    background: rgba(239, 68, 68, 0.8); /* 호버 시 살짝 붉은 빛 */

    transform: rotate(90deg); /* 회전 애니메이션 추가 */
}

/**********
* Progress Area    *
***********/
.progressArea {
    position: fixed;
    z-index: 2147483647;
    top: 0;
    left: 0;

    width: 100%;
    height: 100%;
    pointer-events: auto;

    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 0 0 20px 0;

    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;

    background: rgba(0, 0, 0, 0.0);

}

.progressArea.show {
    visibility: visible;
    opacity: 1;
}

.progress-toast {
    background: rgba(31, 41, 55, 0.95);
    backdrop-filter: blur(8px);
    margin-bottom:30px;
    padding: 12px 20px;

    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

    display: flex;
    align-items: center;
    gap: 12px;

    pointer-events: auto;
    max-width: 90%;

    transform: translateY(100px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.progressArea.show .progress-toast {
    transform: translateY(0);
}

.progress-spinner {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffa516;
    animation: progress-spin 0.8s linear infinite;
    flex-shrink: 0;
}

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

#progress-message {
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: -0.01em;
    margin: 0;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 600px;

    opacity: 1;
    transition: opacity 0.3s ease;

    user-select: none;
    -webkit-user-select: none;
    -webkit-app-region: none;
}

#progress-message.updating {
    opacity: 0.6;
}

/**********
* Snackbar Area *
***********/
/* 토스트 스택 컨테이너 (모든 토스트가 쌓일 곳) */
.toast-stack-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);

    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    z-index: 2147483647;
    pointer-events: none;

    /* --- 모바일 화면에서 최대 너비 조정 --- */
    /* 뷰포트 너비 (100vw)에서 좌우 각 10px(총 20px) 여백을 뺀 값으로 설정 */
    max-width: calc(100% - 20px); /* 화면 너비를 기준으로 계산 */
    width:100%;

    align-items: center;
}

/* 개별 토스트 박스 스타일 */
.toast-box {
    background-color: rgba(51, 51, 51, 0.9);
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);

    max-width: auto;
    min-width: auto; /* 필요하다면 최소 너비를 고정 값으로 설정 (예: 200px) */

    text-align: center;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;

    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    pointer-events: auto;
    cursor: pointer;
}

/* 토스트 박스 등장/사라지는 애니메이션 및 중요도 색상 (변경 없음) */
.toast-box.show { opacity: 1; transform: translateY(0); }
.toast-box.hide { opacity: 0; transform: translateY(20px); }
.toast-box.info { background-color: rgba(33, 149, 243, 0.984); }
.toast-box.success { background-color: rgba(76, 175, 80, 0.9); }
.toast-box.warning { background-color: rgba(255, 152, 0, 0.9); }
.toast-box.error { background-color: rgba(244, 67, 54, 0.9); }

/**********
* installation button    *
***********/
.install-banner {
    position: fixed;
    max-width: 100vw;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%); /* X축은 중앙, Y축은 숨김 상태 */

    right: auto;
    z-index: 9999;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    box-sizing: border-box;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.install-banner.show {
    transform: translateX(-50%) translateY(0);
}

.install-banner.hide {
    transform: translateX(-50%) translateY(-100%);
}

.install-banner-content {
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.install-banner-text {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.install-banner-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 6px;
}

.install-banner-message {
    flex: 1;
    text-align: left;
}

.install-banner-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.install-banner-subtitle {
    font-size: 13px;
    opacity: 0.9;
}

.install-banner-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.install-btn {
    background: white;
    color: #667eea;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

.install-btn:active {
    transform: translateY(0);
}

.close-banner-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.close-banner-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* 펄스 효과 */
.install-banner.pulse .install-btn {
    animation: buttonPulse 2s ease-in-out;
}

@keyframes buttonPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .install-banner {
        padding: 12px 16px;
    }

    .install-banner-content {
        flex-wrap: wrap;
    }

    .install-banner-actions {
        width: 100%;
        margin-top: 8px;
    }

    .install-btn {
        flex: 1;
        padding: 10px 16px;
        font-size: 13px;
    }
}