/* ===============================
   THEME VARIABLES (PURE)
=============================== */
:root {
    --bg-main: #0D0A12;
    --bg-card: #1B1928;
    --bg-card-hover: #232033;
    --text-main: #EDEAFF;
    --text-sub: #9A96B8;
    --accent: #6C5CE7;
    --accent-hover: #7E6BFF;
    --action-btn-solid: #523369;
    --action-btn-solid-hover: #62407d;
    --action-btn-shadow: 0 10px 22px rgba(82, 51, 105, 0.34);
    --radius: 14px;
    --shadow: 0 3px 12px rgba(0,0,0,0.35);
    --page-transition-ms: 300ms;
    --page-transition-ease: cubic-bezier(0.32, 0.72, 0, 1);

    /* skeleton palette */
    --skeleton-surface-1: #1d1f24;
    --skeleton-surface-2: #15171b;
    --skeleton-fill-1: #2b2e35;
    --skeleton-fill-2: #3a3e46;
    --skeleton-fill-3: #25282f;
    --skeleton-border: rgba(255, 255, 255, 0.08);
    --skeleton-border-strong: rgba(255, 255, 255, 0.12);
    --skeleton-card-bg: linear-gradient(180deg, var(--skeleton-surface-1) 0%, var(--skeleton-surface-2) 100%);
    --skeleton-block-bg: linear-gradient(90deg, var(--skeleton-fill-1) 25%, var(--skeleton-fill-2) 50%, var(--skeleton-fill-1) 75%);
    --skeleton-soft-bg: rgba(255, 255, 255, 0.08);
    --skeleton-soft-bg-strong: rgba(255, 255, 255, 0.12);
    --skeleton-shimmer-bg: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.04) 44%,
        rgba(255, 255, 255, 0.10) 50%,
        rgba(255, 255, 255, 0.04) 56%,
        rgba(255, 255, 255, 0) 100%
    );
}

html {
    height: 100%;
    overscroll-behavior-y: none;
    overscroll-behavior-x: none;
}

body {
    font-family: "Pretendard", sans-serif;
    color: var(--text-main);
    overflow-x: hidden;
    overflow-y: hidden;
    overscroll-behavior: none;
    background: radial-gradient(circle at center, #151126 0%, #09070d 70%, #050408 100%);
}

/* ===============================
   RESET
=============================== */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

/* ===============================
   GLOBAL BACKGROUND
=============================== */
.bg-root {
    position: relative;
    width: 100%;
    min-height: 100dvh;
    overscroll-behavior: none;
}

.bg-frame {
    position: fixed;
    inset: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 420px;
    z-index: 0;
    background-image: url("/images/base/purple-frame.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    pointer-events: none;
}

/* ===============================
   APP CONTAINER
=============================== */
.app {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    height: 100dvh;
    overflow-x: hidden;
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
    background: transparent;
    overscroll-behavior: none;
}

    .app * {
        max-width: 100%;
        box-sizing: border-box;
    }

/* ===============================
   ROUTER ROOT (#pages-root)
=============================== */
#pages-root {
    position: relative;
    flex: 1;
    min-height: 0;
    display: block;
    overflow: hidden;
    overscroll-behavior: none;
}

    #pages-root > .page {
        min-height: 0;
    }

/* ===============================
   PAGE CROSS FADE (IOS-LIKE)
=============================== */
.page {
    position: absolute;
    inset: 0;
    opacity: 0;
    transform: scale(1);
    pointer-events: none;
    overflow: hidden;
    will-change: opacity, transform;
}

    .page.active {
        opacity: 1;
        pointer-events: auto;
        z-index: 1;
    }

    .page.page-transitioning {
        pointer-events: none;
    }

    .page.page-entering {
        opacity: 0;
        transform: scale(1.012);
        z-index: 3;
    }

        .page.page-entering.page-active-fade {
            opacity: 1;
            transform: scale(1);
            transition: opacity var(--page-transition-ms) var(--page-transition-ease), transform var(--page-transition-ms) var(--page-transition-ease);
        }

    .page.page-leaving {
        opacity: 0;
        transform: scale(0.992);
        z-index: 2;
        transition: opacity var(--page-transition-ms) var(--page-transition-ease), transform var(--page-transition-ms) var(--page-transition-ease);
    }

/* ===============================
   MAIN CONTENT STRUCTURE
=============================== */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: transparent;
}

.page-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ===============================
   SCROLL AREA
=============================== */
.scroll-area {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
    touch-action: pan-y;
    transform: translateZ(0);
    will-change: scroll-position, transform;
}

    .scroll-area::-webkit-scrollbar {
        width: 6px;
    }

    .scroll-area::-webkit-scrollbar-track {
        background: transparent;
    }

    .scroll-area::-webkit-scrollbar-thumb {
        background: var(--accent);
        border-radius: 999px;
    }

        .scroll-area::-webkit-scrollbar-thumb:hover {
            background: var(--accent-hover);
        }

/* ===============================
   UTIL / BLOCK
=============================== */
.bar {
    height: 12px;
}

.plain-dialog {
    position: fixed;
    inset: 0;
}

/* ===============================
   TEXT FLOW (KOREAN SAFE)
=============================== */
.text-flow {
    word-break: keep-all;
    overflow-wrap: break-word;
    white-space: normal;
}

/* ===============================
   PTR BASE SCROLL EXTENSION
=============================== */
.scroll-area::before {
    content: "";
    display: block;
    flex-shrink: 0;
    height: 20px;
}

.scroll-area::after {
    content: "";
    display: block;
    flex-shrink: 0;
    height: 30px;
}

.page,
.content,
.page-body {
    min-height: 0;
}

.content,
.page-body {
    overflow: hidden;
    overscroll-behavior: none;
}

.story-em {
    color: var(--accent);
    font-weight: 600;
}

.story-talk {
    color: #ffd6f5;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255, 120, 220, 0.25);
}

.story-skill {
    color: #caa7ff;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    border: 1px solid rgba(143, 75, 255, 0.55);
    background: rgba(20, 18, 33, 0.55);
    box-shadow: 0 2px 8px rgba(120, 60, 255, 0.18);
    white-space: nowrap;
}

body.ptr-pulling,
body.ptr-refreshing {
    overflow: hidden;
}

.ptr-indicator {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translate(-50%, -72px);
    width: min(90vw, 320px);
    z-index: 10001;
    display: flex;
    justify-content: center;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
    opacity: 0;
}

.ptr-indicator.is-visible {
    opacity: 1;
}

.ptr-indicator__pill {
    min-width: 180px;
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(8, 8, 12, 0.86);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.ptr-indicator__spinner {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-top-color: var(--accent);
    animation: global-loading-spin 0.85s linear infinite;
    flex: 0 0 auto;
}

.ptr-indicator__text {
    color: rgba(237, 234, 255, 0.92);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}

/* ===============================
   GLOBAL LOADING OVERLAY
=============================== */
.loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(4, 4, 8, 0.62);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.loading-box {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-width: 216px;
    max-width: 286px;
    padding: 22px 22px 18px;
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(180deg, rgba(10, 10, 14, 0.78) 0%, rgba(6, 6, 10, 0.68) 100%);
    box-shadow:
        0 22px 48px rgba(0, 0, 0, 0.38),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.loading-box::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.24) 0%,
        rgba(255, 255, 255, 0.10) 24%,
        rgba(255, 255, 255, 0.03) 58%,
        rgba(255, 255, 255, 0.18) 100%
    );
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0.72;
    filter: blur(0.5px);
}

.loading-box::after {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 28px;
    pointer-events: none;
    background:
        radial-gradient(72% 58% at 50% 0%, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0) 68%),
        radial-gradient(70% 64% at 50% 100%, rgba(108, 92, 231, 0.10) 0%, rgba(108, 92, 231, 0) 72%);
    filter: blur(14px);
    opacity: 0.6;
    z-index: -1;
}

.loading-title {
    margin: 0;
    color: var(--text-main);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.45;
    text-align: center;
    letter-spacing: -0.01em;
}

.loading-tip-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.loading-tip-label {
    margin: 0;
    color: rgba(237, 234, 255, 0.42);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-align: center;
}

.loading-tip {
    margin: 0;
    min-height: 3.3em;
    color: rgba(237, 234, 255, 0.72);
    font-size: 12px;
    line-height: 1.55;
    text-align: center;
    word-break: keep-all;
    overflow-wrap: break-word;
    opacity: 0;
    transform: translateY(5px);
    transition:
        opacity 180ms ease,
        transform 180ms ease;
}

.loading-tip.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.16);
    border-top-color: var(--accent);
    animation: global-loading-spin 0.85s linear infinite;
    flex: 0 0 auto;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.03);
}

@keyframes global-loading-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
