body {
    overflow-y: auto !important;
}

.sub-container {
    max-width: 1200px;
    margin: 50px auto;
    padding: 0 20px;
    display: flex;
    gap: 50px;

    /* align-items: flex-start; 💡 중요: 자식 요소들이 부모 높이를 강제 상속받지 않도록 설정 */
    /* height: auto; 고정 높이 해제 */

    align-items: stretch !important;
    height: auto !important;
}

.content-area {
    flex: 3;
    height: auto !important; /* 고정 세로축 해제 */
    overflow-y: visible !important; /* 내부 세로 스크롤바를 흔적도 없이 삭제 */
}

.structure-tarot {
    text-align: center;
}

/* S : 사이드 위젯 바 */
.sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;

    /* 💡 [따라다니기 핵심] 고정 좌표 대신 브라우저 스크롤 흐름에 맞춘 스티키 배치 */
    position: -webkit-sticky; /* 사파리 브라우저 호환 */
    position: sticky;
    top: 100px; /* 상단 헤더 메뉴바와 겹치지 않도록 헤더 높이만큼 여백을 두고 고정 */

    height: auto;
}
/* E : 사이드 위젯 바 */

/* ❌ 세로 스크롤 방지 핵심: 고정형 메인 레이아웃 (뷰포트 맞춤) */
.dictionary-container {
    max-width: 1200px;
    margin: 0px auto;
    padding: 0 20px;
    display: flex;
    gap: 40px;

    /* 💡 [동기화 핵심 1] 양쪽 자식 요소들의 높이를 무조건 동일하게 연장시킵니다 */
    align-items: stretch !important;
    height: auto !important;
}

/* 1. 좌측 영역: 카테고리 필터 및 카드 리스트 */
.sidebar-panel {
    width: 280px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* 폭 찌그러짐 방지 */

    /* 💡 [동기화 핵심 2] 우측 콘텐츠 길이에 맞춰 세로축이 유연하게 동적 확장됨 */
    height: auto !important;
}

/* 상단 대분류 탭 (메이저 / 마이너 원소) */
.category-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    border-bottom: 1px solid var(--border-color);
}

.cat-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 12px 0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.cat-tab:hover {
    color: var(--gold-bright);
}

.cat-tab.active {
    color: var(--gold-bright);
    background-color: rgba(197, 160, 89, 0.08);
    font-weight: bold;
    border-bottom: 2px solid var(--gold-bright);
}

/* 💡 리스트 내부에서만 개별 스크롤 작동 */
.card-list-wrapper {
    flex: 1;
    overflow-y: auto; /* 전체 스크롤을 막고 이 구역만 세로 스크롤 허용 */
    padding: 10px 0;
}

/* ⚜️ 서재 전용 명품 다크 골드 슬림 스크롤바 장착 */
/* 스크롤바 디자인 커스텀 (다크테마 매칭) */
.card-list-wrapper::-webkit-scrollbar {
    width: 4px;
}
.card-list-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
}
.card-list-wrapper::-webkit-scrollbar-thumb {
    background-color: rgba(197, 160, 89, 0.3);
    border-radius: 2px;
}
.card-list-wrapper::-webkit-scrollbar-thumb:hover {
    background-color: var(--gold-bright);
    box-shadow: 0 0 8px var(--gold-bright);
}

.card-item {
    /* display: flex;
    align-items: center;
    padding: 12px 10px;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    font-size: 0.90rem; */
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 25px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.card-item:hover {
    color: var(--text-light);
    background-color: rgba(255, 255, 255, 0.02);
}

.card-item.active {
    color: var(--gold-bright);
    background-color: rgba(197, 160, 89, 0.04);
    border-left-color: var(--gold-bright);
    font-weight: 500;
}

.card-num {
    font-family: "Cinzel", serif;
    font-size: 0.8rem;
    width: 30px;
    color: var(--gold-dim);
}

/* 2. 우측 영역: 동적 키워드 콘텐츠 디스플레이 */
.display-panel {
    flex: 1;
    background-color: var(--bg-content);
    padding: 50px;
    overflow-y: auto; /* 내용이 너무 길어질 때를 대비한 안전 장치 */
    /* display: flex; */
    align-items: center;
    justify-content: center;
    /* 💡 이중 스크롤바 현상을 완벽히 파괴하고 바닥까지 부드럽게 전체 출력 */
    height: auto !important;
    overflow-y: visible !important;
}

.keyword-content {
    width: 100%;
    max-width: 750px;
    animation: fadeIn 0.4s ease-in-out;
}

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

.display-header {
    border-bottom: 1px solid rgba(197, 160, 89, 0.2);
    padding-bottom: 20px;
    margin-bottom: 35px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.display-title h3 {
    font-size: 2.2rem;
    color: var(--text-light);
    margin-bottom: 5px;
}

.display-title p {
    font-family: "Cinzel", serif;
    color: var(--gold-bright);
    font-size: 1rem;
    letter-spacing: 0.1em;
}

.display-index {
    font-family: "Cinzel", serif;
    font-size: 1.5rem;
    color: var(--gold-dim);
}

/* 정방향 / 역방향 키워드 그리드 배정 */
.keyword-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin-bottom: 35px;
}

.keyword-box {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    padding: 25px;
    border-top: 3px solid transparent;
}

.keyword-box.upright {
    border-top-color: #4e9f3d;
} /* 정방향: 은은한 그린 */
.keyword-box.reversed {
    border-top-color: #d94141;
} /* 역방향: 은은한 레드 */

.box-title {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.keyword-box.upright .box-title {
    color: #4e9f3d;
}
.keyword-box.reversed .box-title {
    color: #d94141;
}

.tag-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.keyword-tag {
    font-size: 0.85rem;
    background-color: rgba(255, 255, 255, 0.04);
    padding: 4px 12px;
    border-radius: 4px;
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* 상세 해설 문단 */
.meaning-section h4 {
    font-size: 1.1rem;
    color: var(--gold-bright);
    margin-bottom: 12px;
}

.meaning-section p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.8;
    text-align: justify;
    font-weight: 300;
}

/* ==========================================================================
🔮 .keyword-content 내부 종속형 타로 카드 프레임 CSS (B안 완치)
========================================================================== */
.tarot-card-mystic-frame {
    position: relative;
    width: 100%;
    max-width: 240px; /* 본문 내에서 과하게 크지 않고 정갈함을 유지하는 타로 카드 최적폭 */
    aspect-ratio: 1 / 1.6; /* 타로카드 고유의 정석 황금 비율(가로1 : 세로1.6) 강제 고정 */

    /* 💡 구조 변경 보완: 부모 상단 패딩이 있으므로 top 마진은 없애고, 아래 설명글과의 여백을 40px로 확장 */
    margin: 0 auto 40px;

    border: 1px solid rgba(197, 160, 89, 0.2);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.tarot-asset-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 이미지 비율이 깨지거나 밀리는 현상 원천 차단 */
    display: block;
    filter: brightness(0.88) contrast(1.04) saturate(0.92); /* 다크 테마 톤다운 */
    transition:
        transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.4s ease;
}

/* 이미지 경계선을 흔적도 없이 완전히 배경 속으로 녹여버리는 이중 안개 마스크 */
.tarot-fog-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 25px 12px #0b0c10; /* 사방 테두리를 배경색(#0B0C10)으로 서서히 페이딩 */
    pointer-events: none;
}

/* ✨ 마우스를 올렸을 때 안개 속 카드가 다가오는 인터랙션 연출 */
.tarot-card-mystic-frame:hover .tarot-asset-img {
    transform: scale(1.04);
    filter: brightness(0.98) contrast(1.08) saturate(1); /* 안개가 걷히며 본연의 색감 복원 */
}

/* ==========================================================================
   📱 [모바일 완전 반응형 개편] 가로 폭 950px 이하 스마트폰 해상도 구간
========================================================================== */
@media (max-width: 950px) {
    /* 1. 모바일 뷰포트에서 개별 락을 풀고 자연스러운 부모 터치 스크롤 허용 */
    body {
        overflow-y: auto;
    }

    /* 2. 가로 스플릿 컨테이너를 세로 1열 스택 정렬 구조로 변환 */
    .sub-container {
        flex-direction: column;
        gap: 40px;
        padding: 0 15px;
        margin: 30px auto;
    }

    /* 3. 모바일에서 우측 사이드바 위젯이 본문 방해 없이 맨 아래로 안정되게 정렬 */
    .sidebar {
        position: static;
        /* Sticky 플로팅 해제 */
        width: 100%;
        order: 2;
        /* 💡 본문 밑으로 배치 고정 */
    }

    .content-area {
        width: 100%;
        order: 1;
        /* 💡 본문이 무조건 상단에 먼저 노출 */
    }

    /* 4. 본문 내 2분할 그리드(메이저/마이너 및 4대 원소) 상자들을 전부 모바일 1열 구조로 유연화 */
    .arcana-split,
    .element-grid {
        grid-template-columns: 1fr;
        /* 가로 가로 분할 해제 */
        gap: 20px;
    }

    /* 모바일 가독성 향상을 위한 내부 패딩 미세 다운 에디팅 */
    .arcana-box,
    .element-card {
        padding: 25px 20px;
    }

    .image-placeholder {
        min-height: 180px;
        /* 모바일 액정 스케일에 맞춘 최소 높이 조정 */
    }

    .deck-image-box {
        padding: 10px;
        /* 모바일에서는 액정 폭 확보를 위해 액자 여백을 10px로 슬림화 */
        margin-bottom: 25px;
    }
}

/* 📱 모바일 디바이스 가변 대응 */
@media (max-width: 768px) {
    .tarot-card-mystic-frame {
        max-width: 180px; /* 모바일 폭에 맞춰 180px로 가변 축소 */
        margin: 0 auto 30px;
    }
}

/* 📱 모바일 터치 디바이스 반응형 스위칭 */
@media (max-width: 850px) {
    body {
        overflow-y: auto;
    } /* 모바일은 고정 풀고 스크롤 허용 */
    .sub-container {
        flex-direction: column;
        gap: 40px;
        margin: 30px auto;
    }
    .sidebar {
        position: static; /* 모바일 액정 폭에서는 따라다니기 기능을 끄고 아래로 순수 정렬 */
        width: 100%;
        order: 2; /* 본문 밑으로 수려하게 밀려남 */
    }
    .content-area {
        width: 100%;
        order: 1; /* 본문 정보 상자가 무조건 최상단 노출 */
    }
    .dictionary-container {
        flex-direction: column; /* 💡 가로 분할을 모바일용 상하 종적 배열로 전환 */
        gap: 30px;
        padding: 0 15px;
        margin: 30px auto;

        max-width: 1200px;
        margin: 50px auto;
        padding: 0 20px;
        display: flex;
        gap: 40px;

        /* 💡 [동기화 핵심 1] 양쪽 자식 요소들의 높이를 무조건 동일하게 연장시킵니다 */
        align-items: stretch !important;
        height: auto !important;
    }
    .sidebar-panel {
        width: 100%;
        /* height: 300px; 리스트 영역 공간 강제 한정 */
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .card-list-wrapper {
        display: flex; /* 💡 가로 한 줄 정렬 */
        overflow-x: auto; /* 💡 좌우로 스와이프하는 가로 스크롤 전격 개방 */
        overflow-y: hidden;
        padding: 15px;
        gap: 12px;
    }
    .card-list-wrapper::-webkit-scrollbar {
        height: 3px;
    }

    .card-item {
        flex: 0 0 auto;
        padding: 8px 16px;
        background-color: rgba(255, 255, 255, 0.02);
        border: 1px solid rgba(197, 160, 89, 0.1);
        border-left: none;
    }
    .card-item.active {
        border: 1px solid var(--gold-bright);
        border-left: none;
        background-color: rgba(197, 160, 89, 0.04);
    }
    .card-num {
        min-width: unset;
        gap: 4px;
    }

    .display-panel {
        width: 100%;
        padding: 30px 15px;
        background-color: transparent;
        border: none;
    }

    .keyword-grid {
        grid-template-columns: 1fr;
    }
}
