/* ==========================================================================
   1. PC 기본 글로벌 레이아웃 (본문 너비 고정 및 팽창 방어)
   ========================================================================== */
.rx-thesis-container {
    display: flex !important;
    flex-direction: row !important;
    gap: 40px;
    align-items: flex-start !important;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
    font-family: 'Noto Sans KR', 'Malgun Gothic', '맑은 고딕', sans-serif;
    color: #333;
    line-height: 1.9;
    position: relative !important;
}

/* [메인 본문 영역] 목차 고정 시 덜컹거림 및 본문 팽창 방지 방화벽 마진 */
.rx-thesis-main {
    flex: 1 !important;
    min-width: 0 !important;
    margin-right: 320px !important; /* 우측에 320px 크기의 가상 공간 상시 확보 */
    background: #ffffff;
    box-sizing: border-box;
}

/* [TOC 사이드바] 초기 대기 상태 여백 (대장님 완벽 고증 데이터 반영) */
.rx-thesis-sidebar {
    width: 280px !important;
    flex: 0 0 280px !important;
    
    position: absolute !important; 
    top: 45px !important; /* 평소 네비바 아래 안착 여백 */
    right: 20px !important;
    
    background: #fdfdfd;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
    box-sizing: border-box;
    z-index: 9999 !important;
}

/* ★ 402px 스크롤 돌파 시 자석 추적 모드 (대장님 완벽 고증 데이터 반영) */
.rx-thesis-sidebar.is-sticky {
    position: fixed !important;
    top: 150px !important; /* 고정 스크롤 시 퀵 메뉴바 회피 오버헤드 */
    max-height: calc(100vh - 180px) !important; 
    overflow-y: auto !important;
}

/* ==========================================================================
   TOC 내부 정련 및 스크립트 기능 원천 복원 (★간섭 완전 제거)
   ========================================================================== */
.rx-thesis-sidebar ul, 
.rx-thesis-sidebar li,
.rx-thesis-sidebar .toc-depth1,
.rx-thesis-sidebar .toc-depth2,
.rx-thesis-sidebar .toc-depth3 {
    list-style: none !important;
    list-style-type: none !important; /* 라이믹스 검은 점(Dot) 완벽 처단 */
    padding: 0 !important;
    margin: 0 !important;
    display: block; /* 스크립트의 토글 명령을 정상 수용할 수 있도록 복원 */
}

/* 목차 내부 전체 링크 텍스트의 파란색 오염 완전 차단 */
.rx-thesis-sidebar a {
    color: #2d3748 !important; 
    text-decoration: none !important;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

/* 1수준 대메뉴(I. 서론 / II. 생애) 줄 간격 */
.rx-thesis-sidebar .toc-depth1 > li {
    margin-bottom: 16px !important;
    width: 100% !important;
}

/* 1수준 줄바꿈 방지 및 마스터 정렬 */
.rx-thesis-sidebar .rx-folder-trigger-bar {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    cursor: pointer;
    user-select: none;
    width: 100% !important;
}

/* --------------------------------------------------------------------------
   ★ 개요 3 횡대 탈출 방지 및 1열 수평 분할 격리 정렬 인프라
   -------------------------------------------------------------------------- */

/* 2수준 중단원(1. 연구의 필요성) 전체 박스 */
.rx-thesis-sidebar .toc-depth2 {
    padding-left: 14px !important; /* 들여쓰기 라인 */
    margin-top: 8px !important;
    margin-bottom: 4px !important;
    border-left: 2px solid #e2e8f0 !important;
    /* 스크립트의 제어 신호(display: none/flex)를 강제로 방해하지 않음 */
    box-sizing: border-box !important;
}

/* 3수준 소단원(1) 구술사) 전체 박스 - 개요2 옆구리로 붙는 현상 결사 방지 */
.rx-thesis-sidebar .toc-depth3 {
    padding-left: 14px !important; /* 한 단계 더 깊은 들여쓰기 */
    margin-top: 6px !important;
    margin-bottom: 6px !important;
    width: 100% !important;
    clear: both !important; /* 주방향 플로팅 완전 해제 */
    display: none; /* 초기 상태 숨김 */
}

/* ★ 핵심 정밀 저격: 모든 개요 줄 단위(div 또는 내부 가로 정렬용 전용 클래스 대응) */
.rx-thesis-sidebar .toc-depth1 li,
.rx-thesis-sidebar .toc-depth2 li,
.rx-thesis-sidebar .toc-depth3 li {
    width: 100% !important;
    clear: both !important;
    margin-bottom: 6px !important;
}

/* 실제 제목과 페이지 번호가 만나는 정렬 라인 (안전한 좌우 분할 보장) */
.rx-thesis-sidebar .toc-depth1 li > div,
.rx-thesis-sidebar .toc-depth2 li,
.rx-thesis-sidebar .toc-depth3 li { 
    justify-content: space-between !important; /* 좌측 글자 ↔ 우측 p.번호 */
    align-items: center !important;
    white-space: nowrap !important;        /* 비좁아도 아래로 부러지는 현상 방지 */
}

/* 만약 3수준 상자가 li의 자식으로 섞여서 flex 가로 배열을 방해할 경우를 대비한 복원 */
.rx-thesis-sidebar .toc-depth2 li .toc-depth3,
.rx-thesis-sidebar li .toc-depth3 {
    display: flex !important;
    flex-direction: column !important; /* 하위 3수준 목록 상자는 무조건 세로 아래로만 배출 */
    width: 100% !important;
}

.rx-thesis-sidebar .toc-depth2 a { color: #4a5568 !important; font-size: 0.9rem !important; }
.rx-thesis-sidebar .toc-depth3 a { color: #718096 !important; font-size: 0.85rem !important; }

/* 페이지 번호(p.1, p.10 등) 텍스트 전용 자석 정렬 인프라 */
.rx-thesis-sidebar a[href*="page"],
.rx-thesis-sidebar a:last-child {
    text-align: right !important;
    margin-left: auto !important; /* 모든 가로 공백을 밀어내고 무조건 우측 벽면에 밀착 */
    padding-left: 15px !important;
    font-weight: bold !important;
    color: #718096 !important;
}

/* 마우스 호버 및 하이라이트 인터랙션 */
.rx-thesis-sidebar a:hover,
.rx-thesis-sidebar .rx-folder-trigger-bar:hover span {
    color: #0056b3 !important;
}

/* 이하 컴포넌트 생략 없이 무손실 유지 */
.rx-thesis-cover-box { text-align: center; margin-bottom: 60px; padding: 50px 30px; background: #fafafa; border: 1px solid #edf2f7; border-radius: 8px; width: 100% !important; max-width: 100% !important; box-sizing: border-box !important; display: block !important; overflow: hidden !important; }
.rx-thesis-cover-box .degree-type { color: #718096; font-size: 1.05rem; font-weight: bold; margin-bottom: 25px; letter-spacing: 2px; }
.rx-thesis-cover-box h1 { font-size: 2.1rem; color: #1a202c; line-height: 1.4; margin-bottom: 15px; font-weight: bold; letter-spacing: -0.5px; }
.rx-thesis-cover-box .subtitle { color: #4a5568; font-size: 1.1rem; margin-bottom: 40px; font-style: italic; line-height: 1.5; white-space: normal !important; }
.rx-thesis-cover-box .author-info { font-size: 1.1rem; color: #2d3748; line-height: 2; margin-top: 30px; }
.rx-thesis-section { margin-bottom: 80px; }
.rx-thesis-main h2 { font-size: 1.85rem; color: #111; margin-top: 0; margin-bottom: 25px; padding-bottom: 12px; border-bottom: 2px solid #2d3748; font-weight: bold; }
.rx-thesis-main h3 { font-size: 1.4rem; color: #2d3748; margin-top: 45px; margin-bottom: 18px; font-weight: bold; }
.rx-thesis-main p { text-align: justify; margin-bottom: 22px; font-size: 1.05rem; color: #2d3748; text-indent: 12px; }
.rx-thesis-blockquote { background-color: #f8fafc; padding: 22px; border-left: 4px solid #4a5568; border-radius: 0 6px 6px 0; margin: 25px 0; font-size: 0.98rem; color: #334155; text-align: justify; }
.rx-table-scroll-container, .rx-table-container { overflow-x: auto; margin: 30px 0; border: 1px solid #e2e8f0; border-radius: 6px; }
.rx-thesis-table { width: 100%; border-collapse: collapse; }
.rx-footnote-trigger { color: #0056b3 !important; font-weight: bold !important; font-size: 0.85rem !important; vertical-align: super !important; cursor: pointer !important; position: relative !important; display: inline-block !important; margin-left: 2px !important; padding: 0 2px !important; user-select: none !important; }
.rx-footnote-tooltip { display: none; position: absolute !important; bottom: 140% !important; left: 50% !important; transform: translateX(-30%) !important; background: #1a202c !important; color: #fff !important; padding: 14px 18px !important; border-radius: 6px !important; width: 320px !important; font-size: 0.88rem !important; font-weight: normal !important; line-height: 1.6 !important; text-align: justify !important; box-shadow: 0 10px 25px rgba(0,0,0,0.25) !important; z-index: 99999 !important; word-break: break-all !important; white-space: normal !important; }
.rx-footnote-tooltip::after { content: "" !important; position: absolute !important; top: 100% !important; left: 30% !important; margin-left: -6px !important; border-width: 6px !important; border-style: solid !important; border-color: #1a202c transparent transparent transparent !important; }
.rx-footnote-trigger:hover .rx-footnote-tooltip { display: block !important; }

/* ==========================================================================
   2. 모바일 반응형 완벽 보장 (768px 이하)
   ========================================================================= */
@media screen and (max-width: 768px) {
    .rx-thesis-container { flex-direction: column !important; gap: 25px; padding: 12px; }
    .rx-thesis-sidebar, .rx-thesis-sidebar.is-sticky {
        position: relative !important; left: 0 !important; top: 0 !important; width: 100% !important; margin-bottom: 10px; padding: 20px;
        z-index: 0 !important; /* 모바일에서는 고정 레이어 제거 */
    }
    .rx-thesis-main { width: 100% !important; margin-right: 0 !important; padding: 0; }
}

.rx-footnote-tooltip {
  display: none;
  position: absolute !important;
  bottom: 140% !important;
  left: 50% !important;
  
  /* 기본은 -50% 중앙 정렬이되, JS에서 계산한 --shift-x 값만큼 좌우로 이동 */
  transform: translateX(calc(-50% + var(--shift-x, 0px))) !important;
  
  background: #1a202c !important;
  color: #fff !important;
  padding: 14px 18px !important;
  border-radius: 6px !important;
  
  width: 320px !important;
  max-width: 85vw !important; /* ★모바일 화면이 320px보다 작을 때를 대비한 안전장치 */
  
  font-size: 0.88rem !important;
  font-weight: normal !important;
  line-height: 1.6 !important;
  text-align: justify !important;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25) !important;
  z-index: 99999 !important;
  word-break: break-all !important;
  white-space: normal !important;
}

/* 말풍선 꼬리표(삼각형) 위치 보정 */
.rx-footnote-tooltip::after {
  content: "" !important;
  position: absolute !important;
  top: 100% !important;
  
  /* 말풍선 본체가 이동한 만큼 꼬리표는 반대 방향으로 이동해야 원래 각주 번호를 가리킵니다 */
  left: calc(50% - var(--shift-x, 0px)) !important;
  
  margin-left: -6px !important;
  border-width: 6px !important;
  border-style: solid !important;
  border-color: #1a202c transparent transparent transparent !important;
}