/* =========================================================
   AI 강의자료 테마 (문서형 리뉴얼)
   - 헤더·목차·메뉴·푸터 등 인터페이스는 px, 본문은 rem으로 지정한다. 그래서 "글자 크기"
     설정(루트 font-size 변경)은 본문에만 반영되고 인터페이스는 !important 없이 고정된다.
   - DAY 페이지 본문은 기존 Tailwind 마크업을 그대로 두고, 이 파일에서 카드 중첩·그림자·
     어두운 배경 등을 문서형으로 덮어쓴다 (#mainContent 범위로 한정).
   ========================================================= */

:root {
  --brand: #4f46e5;
  --brand-strong: #4338ca;
  --brand-soft: #eef2ff;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --header-h: 56px;
  --sidebar-w: 264px;
  --radius: 12px;
  --focus: 0 0 0 3px rgba(79, 70, 229, 0.35);
}

/* 최소 초기화 (Tailwind를 쓰지 않는 메인 페이지용 — Tailwind preflight와 동일한 방향) */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, ol, ul, figure { margin: 0; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
a { color: inherit; text-decoration: none; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
}
body {
  background: var(--bg);
  color: var(--text-2);
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}

/* 키보드 사용자를 위한 포커스 표시 */
:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--text);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  transition: top 0.15s;
}
.skip-link:focus {
  top: 8px;
}

/* 본문 글자 크기 (html.font-sm / md / lg)
   본문(Tailwind 클래스)은 rem 단위라 루트 크기를 따라 커지고,
   헤더·목차·메뉴·푸터는 이 파일에서 px로 지정해 설정과 무관하게 고정된다 */
html.font-sm { font-size: 16px; }
html.font-md { font-size: 18px; }
html.font-lg { font-size: 20px; }

/* 스크롤바 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 10px;
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* =========================================================
   공통 버튼
   ========================================================= */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 15px;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
/* 터치 기기에서는 손가락으로 누르기 쉬운 크기(44px) 확보 */
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
  .day-select { padding: 10px 12px; }
}
.icon-btn[aria-expanded="true"] {
  background: var(--brand-soft);
  color: var(--brand);
}

/* =========================================================
   헤더
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 4px;
}
.site-header__spacer { flex: 1; }

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.site-brand__mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 8px;
}

.crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 14px;
}
.crumb__subject {
  color: var(--muted);
  white-space: nowrap;
}
.crumb__sep {
  color: var(--faint);
  font-size: 10px;
}
.crumb__title {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* DAY 선택 드롭다운 */
.dropdown {
  position: relative;
}
.day-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.15s;
}
.day-select:hover,
.day-select[aria-expanded="true"] {
  background: var(--bg-subtle);
}
.day-select__total {
  font-weight: 500;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}
.day-select i {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s;
}
.day-select[aria-expanded="true"] i {
  transform: rotate(180deg);
}

.menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  min-width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}
.menu[hidden] { display: none; }
.menu--right {
  left: auto;
  right: 0;
  min-width: 0;
}
.menu__label {
  padding: 8px 10px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
}
.menu__item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text-2);
  text-align: left;
  transition: background 0.12s;
}
.menu__item:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
.menu__item-day {
  flex-shrink: 0;
  width: 52px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.menu__item.is-current {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
}
.menu__item.is-current .menu__item-day { color: var(--brand); }
.menu__item.is-disabled {
  color: var(--faint);
  cursor: not-allowed;
}

/* 글자 크기 선택 */
.seg {
  display: flex;
  gap: 2px;
  padding: 4px;
}
.seg button {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.seg button:hover { background: var(--bg-subtle); color: var(--text); }
.seg button[aria-pressed="true"] {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
}

/* 읽기 진행바 */
.read-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  pointer-events: none;
}
.read-progress span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--brand);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* =========================================================
   목차 사이드바
   ========================================================= */
.doc-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  z-index: 40;
  width: var(--sidebar-w);
  overflow-y: auto;
  padding: 24px 12px 32px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  transition: transform 0.25s ease;
}
.doc-sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--faint);
}
.toc {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.toc-link {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
  transition: background 0.12s, color 0.12s;
}
.toc-link:hover {
  background: var(--bg-subtle);
  color: var(--text);
}
/* 목차 PART 묶음 — theme.js가 p.toc-group을 접고 펴는 버튼으로 바꿈 */
.toc-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 10px 0 2px;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
  text-align: left;
  color: var(--brand);
  cursor: pointer;
}
p.toc-group { cursor: default; }
.toc > .toc-group:first-child,
.toc > .toc-part:first-child .toc-group { margin-top: 0; }
button.toc-group:hover { background: var(--bg-subtle); }
.toc-group__icon { flex-shrink: 0; font-size: 10px; color: var(--muted); transition: transform 0.15s; }
.toc-part.is-collapsed .toc-group__icon { transform: rotate(-90deg); }
.toc-part.is-collapsed .toc-part__links { display: none; }
.toc-part.is-collapsed.is-current .toc-group { background: var(--brand-soft); }
.toc-part__links { display: flex; flex-direction: column; gap: 1px; }
.toc-link.is-active {
  color: var(--brand);
  font-weight: 600;
  background: var(--brand-soft);
}

.doc-main {
  padding-left: var(--sidebar-w);
  transition: padding-left 0.25s ease;
}

/* 데스크톱: 목차 접기 */
body.toc-collapsed .doc-sidebar { transform: translateX(-100%); }
body.toc-collapsed .doc-main { padding-left: 0; }

/* 태블릿·모바일: 목차는 기본적으로 숨기고 버튼을 누르면 서랍처럼 열림 */
.toc-backdrop { display: none; }
@media (max-width: 1023px) {
  .doc-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .doc-main { padding-left: 0; }
  body.toc-open .doc-sidebar {
    transform: none;
    box-shadow: 0 0 40px rgba(15, 23, 42, 0.18);
  }
  body.toc-open .toc-backdrop {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    z-index: 39;
    background: rgba(15, 23, 42, 0.3);
  }
  .crumb__title,
  .crumb__sep:has(+ .crumb__title) { display: none; }
}
@media (max-width: 639px) {
  .crumb__subject,
  .crumb__subject + .crumb__sep,
  .header-divider { display: none; }
}

/* =========================================================
   본문 레이아웃
   ========================================================= */
.doc-content {
  max-width: 880px;
  margin: 0 auto;
  padding: 48px 24px 24px;
}
@media (max-width: 639px) {
  .doc-content { padding: 32px 16px 16px; }
}

/* 문서 제목 영역 (기존 그라데이션 배너를 대체) */
.doc-hero {
  padding-bottom: 8px;
}
.doc-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
}
.doc-eyebrow span + span::before {
  content: "·";
  margin-right: 8px;
  color: var(--faint);
}
.doc-hero h1 {
  margin-top: 12px;
  font-size: 2rem;
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
}
.doc-lead {
  margin-top: 16px;
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--muted);
}
@media (max-width: 639px) {
  .doc-hero h1 { font-size: 1.625rem; }
}

/* 본문 줄바꿈: 마지막 줄에 단어 하나만 남는 것을 줄임 */
#mainContent { text-wrap: pretty; }
#mainContent :is(h1, h2, h3, h4) { text-wrap: balance; }

/* 가운데 정렬 문단 보정 (theme.js의 fixCenteredText가 줄 수를 보고 클래스를 붙임)
   3줄 이상 → 왼쪽 정렬, 2줄 → 두 줄 길이를 비슷하게 맞춤 */
#mainContent .is-long-center { text-align: left; }
#mainContent .is-balanced-center { text-wrap: balance; }

/* 섹션 제목 (번호 + 제목 한 줄) */
.doc-h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 28px;
  font-size: 1.5rem;
  line-height: 1.35;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--text);
}
.doc-h2__num {
  flex-shrink: 0;
  font-size: 0.875em;
  font-weight: 700;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

/* 섹션: 카드 → 구분선으로 나뉜 문서 영역 */
#mainContent > section[id] {
  margin-top: 80px;
  padding: 72px 0 0;
  background: none;
  border: 0;
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  color: var(--text-2);
  scroll-margin-top: calc(var(--header-h) + 8px);
}
#mainContent > section[id]:hover { border-color: var(--border); }
@media (max-width: 639px) {
  #mainContent > section[id] {
    margin-top: 56px;
    padding-top: 48px;
  }
}

/* 본문 안 그림자 제거, 테두리 톤 통일 */
#mainContent [class*="shadow"] { box-shadow: none; }
#mainContent .border-slate-200,
#mainContent .border-slate-200\/80 { border-color: var(--border); }

/* 섹션 안의 큰 회색 박스(STEP 블록 등) → 왼쪽 선만 있는 들여쓰기 블록 */
#mainContent > section > div.bg-slate-50.rounded-2xl {
  padding: 4px 0 4px 24px;
  background: none;
  border: 0;
  border-left: 2px solid var(--border);
  border-radius: 0;
}
@media (max-width: 639px) {
  #mainContent > section > div.bg-slate-50.rounded-2xl { padding-left: 16px; }
}

/* 작은 정보 박스: 테두리 없이 옅은 배경만 */
#mainContent .bg-slate-50.border-slate-200,
#mainContent .bg-slate-50.border-slate-200\/80 {
  border-color: transparent;
  background: var(--bg-subtle);
}

/* 어두운 강조 박스(bg-slate-900, 본문 속 어두운 그라데이션 div) → 밝은 강조 박스
   (코드 블록 pre는 어두운 배경 유지) */
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"]) {
  background: var(--brand-soft);
  color: var(--text);
  border-left: 3px solid var(--brand);
}
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"]) :is(.text-slate-200, .text-slate-300) { color: var(--text-2); }
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"]) :is(.text-indigo-200, .text-indigo-300, .text-indigo-400) { color: var(--brand); }
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"]) .text-amber-300 { color: #b45309; }
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"]) :is(.text-white, [class*="text-indigo-100"]) { color: var(--text); }
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"]) :is(.bg-white\/10, .bg-white\/5) { background: #fff; }
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"])[class*="text-white"] { color: var(--text); }
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"]) .bg-indigo-600,
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"]) .bg-indigo-600 * { color: #fff; }
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"]) .bg-indigo-600 .text-indigo-200 { color: #c7d2fe; }

/* 어두운 배경용 연한 강조 글씨 → 밝은 배경에서 읽히는 진한 톤
   (밝게 바뀐 강조 박스·정리 섹션 안에서만 적용, 코드 블록 pre는 제외) */
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"], section[class*="bg-gradient"]) :is(.text-sky-200, .text-sky-300, .text-sky-400) { color: #0369a1; }
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"], section[class*="bg-gradient"]) :is(.text-rose-200, .text-rose-300, .text-rose-400) { color: #be123c; }
#mainContent :is(.bg-slate-900:not(pre), div[class*="from-slate-900"], section[class*="bg-gradient"]) :is(.text-emerald-200, .text-emerald-300, .text-emerald-400) { color: #047857; }
/* 마지막 정리 섹션(그라데이션 배경) → 일반 섹션 */
#mainContent > section[id][class*="bg-gradient"] {
  background: none;
  color: var(--text-2);
}
#mainContent > section[class*="bg-gradient"] .text-white { color: var(--text); }
#mainContent > section[class*="bg-gradient"] .text-indigo-300,
#mainContent > section[class*="bg-gradient"] .text-indigo-200 { color: var(--brand); }
#mainContent > section[class*="bg-gradient"] [class*="text-indigo-100"],
#mainContent > section[class*="bg-gradient"] [class*="text-slate-300"] { color: var(--text-2); }
#mainContent > section[class*="bg-gradient"] .bg-white\/10,
#mainContent > section[class*="bg-gradient"] .bg-white\/5 { background: var(--bg-subtle); }
#mainContent > section[class*="bg-gradient"] [class*="border-white"] { border-color: var(--border); }
#mainContent > section[class*="bg-gradient"] .bg-white\/80 {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand);
}

/* 프롬프트 박스: 코드 블록처럼 머리줄 + 본문 */
#mainContent div:has(> [onclick^="copyTextById"][id]) {
  padding: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
#mainContent div:has(> [onclick^="copyTextById"][id]) > div:first-child {
  margin: 0;
  padding: 8px 8px 8px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
#mainContent div:has(> [onclick^="copyTextById"][id]) > div:first-child > span {
  color: var(--text-2);
}
#mainContent div:has(> [onclick^="copyTextById"][id]) > div:first-child button {
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-2);
  transition: border-color 0.15s, color 0.15s;
}
#mainContent div:has(> [onclick^="copyTextById"][id]) > div:first-child button:hover {
  border-color: var(--brand);
  color: var(--brand);
}
#mainContent div:has(> [onclick^="copyTextById"][id]) > span {
  margin: 0;
  padding: 12px 16px 0;
  color: var(--faint);
}
#mainContent [onclick^="copyTextById"][id] {
  margin: 0;
  padding: 8px 16px 16px;
  background: #fff;
  border: 0;
  border-radius: 0;
  color: var(--text);
}
#mainContent [onclick^="copyTextById"][id]:hover {
  background: var(--bg-subtle);
}

/* =========================================================
   이전/다음 DAY
   ========================================================= */
.day-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 72px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.day-pager:empty { display: none; }
.pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}
.pager-link:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.pager-link--next {
  grid-column: 2;
  text-align: right;
}
.pager-link__dir {
  font-size: 13px;
  color: var(--muted);
}
.pager-link__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.pager-link:hover .pager-link__title { color: var(--brand); }
@media (max-width: 639px) {
  .day-pager { grid-template-columns: 1fr; }
  .pager-link--next { grid-column: auto; }
}

/* =========================================================
   푸터
   ========================================================= */
.site-footer {
  margin-top: 64px;
  padding: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  color: var(--faint);
}
.site-footer p + p { margin-top: 4px; }
.site-footer__biz { font-size: 12px; }
.site-footer__ask { white-space: nowrap; }
.site-footer__ask strong { color: var(--text-2); user-select: all; }

/* =========================================================
   맨 위로 버튼 / 토스트
   ========================================================= */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 45;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-2);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s, color 0.15s, border-color 0.15s;
}
.back-to-top.is-visible {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.back-to-top:hover {
  color: var(--brand);
  border-color: var(--brand);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--text);
  color: #fff;
  font-size: 14px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast i { color: #34d399; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* =========================================================
   수강생 접근 제어(로그인 게이트) — 기존 common.css에서 이전
   ========================================================= */
html.gate-locked,
html.gate-locked body {
  overflow: hidden !important;
}
#authGate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#authGate.gate-hidden { display: none; }
#authGate .gate-card {
  position: relative;
  background: #ffffff;
  border-radius: 20px;
  padding: 36px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
}
#authGate .gate-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  color: var(--faint);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
#authGate .gate-close:hover {
  background: #f1f5f9;
  color: #475569;
}
#authGate .gate-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 9999px;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
#authGate .gate-subject {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand);
  margin-bottom: 4px;
}
#authGate h2 {
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
#authGate .gate-desc {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.5;
}
#authGate #gateForm {
  display: flex;
  gap: 8px;
}
/* 한글 IME 조합 중 글자가 노출되지 않도록 입력창은 opacity:0으로 숨기고
   점(•) 표시는 별도 오버레이(gateNameMask)에 그린다 (auth.js 참고). */
#authGate .gate-mask-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  box-sizing: border-box;
}
#authGate .gate-mask-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: var(--focus);
}
#authGate #gateNameInput {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0 14px;
  margin: 0;
  border: none;
  background: transparent;
  opacity: 0;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
}
#authGate .gate-mask-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text);
  pointer-events: none;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
}
#authGate .gate-mask-overlay.is-empty {
  font-size: 14px;
  letter-spacing: normal;
  color: var(--faint);
}
/* 점 하나하나를 같은 폭의 칸으로 그려서, 선택한 부분(드래그)과 커서를 보여준다 (auth.js renderMask) */
#authGate .gate-mask-overlay .m-dot {
  display: inline-block;
  width: 12px;
  text-align: center;
  letter-spacing: 0;
  border-radius: 3px;
}
#authGate .gate-mask-overlay .m-dot.is-sel {
  background: var(--brand-soft, rgba(99, 102, 241, 0.2));
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.35);
}
#authGate .gate-mask-overlay .m-caret {
  display: inline-block;
  width: 0;
  height: 18px;
  margin: 0 -1px;
  border-left: 2px solid var(--brand, #6366f1);
  animation: gateCaretBlink 1s steps(1) infinite;
}
@keyframes gateCaretBlink { 50% { opacity: 0; } }
#authGate #gateNameInput { cursor: text; }
#authGate #gateForm button {
  padding: 10px 16px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 10px;
  white-space: nowrap;
  transition: background 0.15s;
}
#authGate #gateForm button:hover { background: var(--brand-strong); }
#authGate #gateForm button:disabled { opacity: 0.6; }
#authGate .gate-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 8px;
  text-align: left;
}
#authGate .gate-hint {
  margin-top: 16px;
  font-size: 12px;
  color: var(--faint);
}

/* =========================================================
   헤더·네비게이션 브랜드 요소 (메인 페이지의 AI 컨셉과 연결)
   ========================================================= */
:root {
  --grad: linear-gradient(100deg, #a78bfa 0%, #818cf8 35%, #22d3ee 70%, #f0abfc 100%);
}

/* 헤더 로고: 메인과 같은 그라데이션 마크, 누르면 메인으로 */
.brand-mark {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: 0 4px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  background: var(--grad);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.45);
  transition: transform 0.2s, box-shadow 0.2s;
}
.brand-mark:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 22px rgba(139, 92, 246, 0.7);
}

/* 읽기 진행바: 보라 → 청록 그라데이션 */
.read-progress { height: 3px; }
.read-progress span { background: var(--grad); }

/* DAY 배지 (헤더 드롭다운 버튼 · 드롭다운 목록) */
.day-select {
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  color: var(--badge-text);
}
.day-select:hover,
.day-select[aria-expanded="true"] { background: var(--badge-bg-hover); }
.menu__item-day {
  display: inline-flex;
  justify-content: center;
  padding: 3px 0;
  border-radius: 6px;
  background: var(--bg-subtle);
  font-size: 12px;
}
.menu__item.is-current .menu__item-day {
  background: var(--brand);
  color: #fff;
}
:root {
  --badge-bg: #f5f3ff;
  --badge-bg-hover: #ede9fe;
  --badge-border: #ddd6fe;
  --badge-text: #5b21b6;
}

/* 이전/다음 DAY: 마우스를 올리면 그라데이션 테두리 */
.pager-link:hover {
  border-color: transparent;
  background: linear-gradient(var(--pager-hover-bg), var(--pager-hover-bg)) padding-box, var(--grad) border-box;
}
:root { --pager-hover-bg: #faf5ff; }


/* =========================================================
   실습 주제 고르기 (.topic-picker) + 주제별 프롬프트 펼침 (.topic-prompt)
   - 주제 카드를 고르면 html[data-topic]이 바뀌고, 그 주제의 프롬프트가 모두 펼쳐짐 (theme.js)
   - .topic-text[data-topic]: 고른 주제에 해당하는 예시만 보이고 나머지는 숨김
   ========================================================= */
.topic-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (max-width: 639px) {
  .topic-picker { grid-template-columns: 1fr; }
}
.topic-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  text-align: left;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.topic-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.topic-card[aria-checked="true"] {
  border-color: transparent;
  background: linear-gradient(var(--pager-hover-bg), var(--pager-hover-bg)) padding-box, var(--grad) border-box;
  box-shadow: 0 10px 28px -14px rgba(139, 92, 246, 0.55);
}
.topic-card__icon {
  width: 38px;
  height: 38px;
  margin-bottom: 4px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background: var(--brand-soft);
  color: var(--brand);
}
.topic-card[aria-checked="true"] .topic-card__icon { background: var(--grad); color: #fff; }
.topic-card__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}
.topic-card[aria-checked="true"]::after {
  content: "선택됨";
  position: absolute;
  top: 14px;
  right: 14px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
}
.topic-card__desc {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--muted);
}
.topic-card__goal {
  margin-top: auto;
  padding-top: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand);
}

.topic-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.topic-prompts__label {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-2);
}
.topic-prompts__label span { font-weight: 500; color: var(--faint); }
.topic-prompt {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s;
}
.topic-prompt[open] { border-color: var(--brand); }
.topic-prompt > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  list-style: none;
  cursor: pointer;
  border-radius: 12px;
}
.topic-prompt > summary::-webkit-details-marker { display: none; }
.topic-prompt > summary:hover { background: var(--bg-subtle); }
.topic-prompt__icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: var(--brand-soft);
  color: var(--brand);
}
.topic-prompt__name {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.topic-prompt.is-selected .topic-prompt__name::after {
  content: "내 주제";
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--badge-text);
  background: var(--badge-bg);
  border: 1px solid var(--badge-border);
  vertical-align: 1px;
}
.topic-prompt__chevron {
  font-size: 12px;
  color: var(--faint);
  transition: transform 0.2s;
}
.topic-prompt[open] .topic-prompt__chevron { transform: rotate(180deg); }
.topic-prompt__body { padding: 4px 16px 16px; }

/* 고른 주제의 예시만 보이기 (선택 전에는 첫 주제) */
html:not([data-topic]) #mainContent .topic-text:not([data-topic="run"]),
html[data-topic="run"] #mainContent .topic-text:not([data-topic="run"]),
html[data-topic="trip"] #mainContent .topic-text:not([data-topic="trip"]),
html[data-topic="cafe"] #mainContent .topic-text:not([data-topic="cafe"]),
html[data-topic="sleep"] #mainContent .topic-text:not([data-topic="sleep"]) { display: none; }

/* =========================================================
   본문 이미지 (.doc-figure) + 확대 보기 (.lightbox)
   <figure class="doc-figure"><a class="doc-figure__zoom" href="원본"><img src="웹용 사본"></a><figcaption>
   이미지를 누르면 theme.js가 원본을 화면 가득 띄움
   ========================================================= */
.doc-figure { margin: 0; }
.doc-figure__zoom {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  cursor: zoom-in;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.doc-figure__zoom:hover {
  border-color: var(--brand);
  box-shadow: 0 10px 30px -14px rgba(79, 70, 229, 0.45);
}
.doc-figure__zoom img {
  display: block;
  width: 100%;
  height: auto;
}
.doc-figure__hint {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(15, 23, 42, 0.75);
  pointer-events: none;
}
.doc-figure figcaption {
  margin-top: 10px;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--muted);
}
.doc-figure figcaption strong { color: var(--text); margin-right: 4px; }

.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.lightbox::backdrop {
  background: rgba(3, 5, 12, 0.88);
  backdrop-filter: blur(4px);
}
.lightbox__inner {
  width: 100%;
  height: 100%;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 16px 24px;
  cursor: zoom-out;
}
.lightbox__img {
  max-width: min(1600px, 100%);
  height: auto;
  margin: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.lightbox__close {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.22); }
html.lightbox-open { overflow: hidden; }


/* =========================================================
   프롬프트 "바꿔 쓸 곳" 표시 + 바꿔 보기 안내
   - 프롬프트 안: <mark class="edit-slot">바꿔도 되는 말</mark>
   - 프롬프트 상자 바로 아래: <div class="edit-hint">…</div>
   (그대로 복사해도 동작하고, 표시된 곳만 바꾸면 내 버전이 됨)
   ========================================================= */
#mainContent mark.edit-slot {
  background: #fef3c7;
  color: inherit;
  padding: 0 3px;
  border-radius: 4px;
  box-shadow: inset 0 -2px 0 #f59e0b;
}
#mainContent .edit-hint {
  margin: 10px 0 0;
  padding: 12px 14px;
  background: #fffbeb;
  border: 1px dashed #fcd34d;
  border-radius: 10px;
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--text-2);
}
#mainContent div:has(> [onclick^="copyTextById"][id]) > .edit-hint { margin: 4px 16px 16px; }
#mainContent .edit-hint__title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-weight: 700;
  color: #b45309;
}
#mainContent .edit-hint b { color: var(--text); font-weight: 700; margin-right: 4px; }

/* =========================================================
   직접 고쳐 쓰는 작성 틀 (.prompt-editor)
   - 머리줄: 제목 + "처음으로" / "복사하기" 버튼 (복사는 버튼으로만)
   - 본문: textarea.prompt-editor__input (theme.js가 높이 자동 조절·임시 저장)
   ========================================================= */
#mainContent .prompt-editor {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
#mainContent .prompt-editor__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}
#mainContent .prompt-editor__title { font-size: 0.9375rem; font-weight: 700; color: var(--text-2); }
#mainContent .prompt-editor__actions { display: inline-flex; gap: 6px; }
#mainContent .prompt-editor__actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 2.25rem;
  padding: 0 0.875rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 700;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#mainContent .prompt-editor__reset { background: #fff; border: 1px solid var(--border); color: var(--muted); }
#mainContent .prompt-editor__reset:hover { border-color: var(--text-2); color: var(--text); }
#mainContent .prompt-editor__copy { background: var(--brand); border: 1px solid var(--brand); color: #fff; }
#mainContent .prompt-editor__copy:hover { background: var(--brand-strong); }
#mainContent .prompt-editor__hint {
  margin: 0;
  padding: 10px 16px 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brand);
}
#mainContent .prompt-editor__hint i { margin-right: 4px; }
#mainContent .prompt-editor__input {
  display: block;
  width: calc(100% - 24px);
  margin: 8px 12px 12px;
  padding: 12px 14px;
  min-height: 7rem;
  resize: vertical;
  overflow: hidden;
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.75;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px dashed var(--brand);
  border-radius: 10px;
}
#mainContent .prompt-editor__input:focus {
  outline: none;
  background: #fff;
  border-style: solid;
  box-shadow: 0 0 0 3px var(--brand-soft);
}
/* 복사 안내("상자를 클릭하면 바로 복사돼요") 등 11px로 고정된 작은 글씨 → 본문 글자 크기에 맞춰 읽기 쉽게 */
#mainContent .text-\[11px\] { font-size: 0.8125rem; }

/* 작성 틀 아래 접어 둔 예시 (theme.js buildPromptExamples가 div.prompt-example → details로 변환) */
#mainContent .prompt-editor { margin-bottom: 1.5rem; }
#mainContent .prompt-example-box {
  margin: 0 0 2rem;
  background: var(--bg-subtle);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
#mainContent .prompt-example-box > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-2);
}
#mainContent .prompt-example-box > summary::-webkit-details-marker { display: none; }
#mainContent .prompt-example-box > summary > .fa-eye { color: #0284c7; }
#mainContent .prompt-example-box__btn {
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  background: #0284c7;
  color: #fff;
  font-size: 0.8125rem;
}
#mainContent .prompt-example-box__btn .fa-chevron-down { transition: transform 0.2s; }
#mainContent .prompt-example-box[open] .prompt-example-box__btn .fa-chevron-down { transform: rotate(180deg); }
#mainContent .prompt-example-box__open,
#mainContent .prompt-example-box[open] .prompt-example-box__closed { display: none; }
#mainContent .prompt-example-box[open] .prompt-example-box__open { display: inline; }
#mainContent .prompt-example-box__body {
  padding: 0 20px 20px;
  font-size: 0.875rem;
  line-height: 1.75;
  color: var(--text-2);
}
#mainContent .prompt-example-box__body.is-text,
#mainContent .prompt-example-box__body > .topic-text { white-space: pre-line; }


/* 수업 방식 경고 배너 (작성 틀 방식을 쓰는 DAY 맨 위) */
#mainContent .write-banner { margin-bottom: 3rem; }
