/* ─── 퍼널 오퍼레이팅 강의록 뷰어 ─── */
:root {
  --bg: #f7f6f3;
  --bg-card: #ffffff;
  --bg-sidebar: #fbfaf8;
  --bg-hover: #f0efec;
  --text: #1a1a1a;
  --text-2: #57534e;
  --text-3: #a8a29e;
  --border: #e7e5e4;
  --accent: #c2410c;
  --accent-soft: #fff1e8;
  --gold: #f59e0b;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.08), 0 16px 48px rgba(0,0,0,.12);
  --radius: 14px;
  --sidebar-w: 300px;
  --toc-w: 220px;
  --font-serif: 'Pretendard Variable', Pretendard, -apple-system, sans-serif;
}
html[data-theme="dark"] {
  --bg: #161412;
  --bg-card: #201d1a;
  --bg-sidebar: #1b1917;
  --bg-hover: #2a2622;
  --text: #ece9e4;
  --text-2: #b8b2aa;
  --text-3: #6e6862;
  --border: #322e29;
  --accent: #fb923c;
  --accent-soft: #33231a;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.4), 0 16px 48px rgba(0,0,0,.5);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ─── 부트 스피너 ─── */
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--text-3); font-size: 14px; }
.boot-spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 상단 진행바 ─── */
#read-progress { position: fixed; top: 0; left: 0; height: 3px; background: linear-gradient(90deg, var(--accent), var(--gold)); width: 0%; z-index: 100; transition: width .1s linear; }

/* ══════════ 홈 ══════════ */
.home { max-width: 1080px; margin: 0 auto; padding: 0 24px 80px; }
.hero { padding: 72px 0 48px; text-align: center; position: relative; }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700; padding: 6px 14px; border-radius: 99px; margin-bottom: 20px; letter-spacing: .02em; }
.hero h1 { font-size: clamp(36px, 6vw, 56px); font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
.hero h1 .accent { color: var(--accent); }
.hero-sub { margin-top: 16px; font-size: clamp(15px, 2.5vw, 18px); color: var(--text-2); font-weight: 500; }
.hero-stats { display: flex; justify-content: center; gap: 40px; margin-top: 36px; flex-wrap: wrap; }
.hero-stat { text-align: center; }
.hero-stat .num { font-size: 32px; font-weight: 800; letter-spacing: -.02em; }
.hero-stat .num .unit { font-size: 16px; font-weight: 600; color: var(--text-3); margin-left: 2px; }
.hero-stat .lbl { font-size: 13px; color: var(--text-3); font-weight: 600; margin-top: 2px; }

/* 이어보기 배너 */
.continue-banner { display: flex; align-items: center; gap: 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; margin: 8px 0 32px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.continue-banner:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.continue-banner .icon { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.continue-banner .info { flex: 1; min-width: 0; }
.continue-banner .info .cap { font-size: 12px; color: var(--text-3); font-weight: 600; }
.continue-banner .info .tit { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue-banner .go { color: var(--accent); font-weight: 700; font-size: 14px; flex-shrink: 0; }

/* 전체 진도 */
.overall { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 40px; box-shadow: var(--shadow); }
.overall-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.overall-head .t { font-weight: 700; font-size: 15px; }
.overall-head .pct { font-weight: 800; font-size: 22px; color: var(--accent); }
.overall-bar { height: 10px; background: var(--bg-hover); border-radius: 99px; overflow: hidden; }
.overall-bar .fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 99px; transition: width .6s cubic-bezier(.22,1,.36,1); }
.overall-sub { margin-top: 10px; font-size: 13px; color: var(--text-3); }

/* 파트 섹션 */
.part-section { margin-bottom: 44px; }
.part-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.part-chip { font-size: 13px; font-weight: 800; padding: 4px 12px; border-radius: 8px; color: #fff; letter-spacing: .03em; flex-shrink: 0; }
.part-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.part-meta { font-size: 13px; color: var(--text-3); font-weight: 600; margin-left: auto; white-space: nowrap; }
.part-tools { margin: 2px 0 16px; font-size: 13px; color: var(--text-3); }
.part-tools .tool-tag { display: inline-block; background: var(--bg-hover); border-radius: 6px; padding: 2px 8px; margin-right: 6px; font-weight: 600; font-size: 12px; }

.ep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 12px; }
.ep-card { display: flex; align-items: center; gap: 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; transition: transform .15s, box-shadow .15s, border-color .15s; position: relative; overflow: hidden; }
.ep-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.ep-card .num { font-size: 13px; font-weight: 800; color: var(--text-3); width: 30px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.ep-card .body { flex: 1; min-width: 0; }
.ep-card .t { font-weight: 700; font-size: 14.5px; line-height: 1.4; display: flex; align-items: center; gap: 6px; }
.ep-card .t .star { color: var(--gold); font-size: 12px; }
.ep-card .m { font-size: 12px; color: var(--text-3); margin-top: 3px; font-weight: 500; }
.ep-card .done-mark { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 11px; color: transparent; flex-shrink: 0; transition: all .2s; }
.ep-card.done .done-mark { background: #10b981; border-color: #10b981; color: #fff; }
.ep-card.done .t { color: var(--text-2); }
.ep-card.reading::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }

/* ══════════ 리더 레이아웃 ══════════ */
.reader-layout { display: flex; min-height: 100vh; }

/* 사이드바 */
.sidebar { width: var(--sidebar-w); background: var(--bg-sidebar); border-right: 1px solid var(--border); position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto; z-index: 50; transition: transform .25s cubic-bezier(.22,1,.36,1); display: flex; flex-direction: column; }
.sidebar-head { padding: 20px 20px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg-sidebar); z-index: 2; }
.sidebar-head .logo { font-weight: 800; font-size: 16px; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.sidebar-head .logo .dot { color: var(--accent); }
.sidebar-head .prog { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.sidebar-head .prog .bar { flex: 1; height: 6px; background: var(--bg-hover); border-radius: 99px; overflow: hidden; }
.sidebar-head .prog .bar .fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 99px; transition: width .4s; }
.sidebar-head .prog .pct { font-size: 12px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.sidebar-nav { padding: 10px 12px 90px; flex: 1; }
.nav-part { margin-bottom: 4px; }
.nav-part-head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--text-2); transition: background .15s; text-align: left; }
.nav-part-head:hover { background: var(--bg-hover); }
.nav-part-head .chip { width: 26px; height: 18px; border-radius: 5px; color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-part-head .cnt { margin-left: auto; font-size: 11px; color: var(--text-3); font-weight: 600; }
.nav-part-head .car { font-size: 10px; color: var(--text-3); transition: transform .2s; }
.nav-part.open .nav-part-head .car { transform: rotate(90deg); }
.nav-eps { display: none; }
.nav-part.open .nav-eps { display: block; }
.nav-ep { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 14px; margin: 1px 0 1px 20px; border-radius: 8px; font-size: 13px; color: var(--text-2); transition: background .12s; border-left: 2px solid transparent; }
.nav-ep:hover { background: var(--bg-hover); }
.nav-ep.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; border-left-color: var(--accent); }
.nav-ep .n { font-size: 11px; font-weight: 700; color: var(--text-3); width: 20px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.nav-ep.active .n { color: var(--accent); }
.nav-ep .tt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-ep .chk { font-size: 11px; color: #10b981; flex-shrink: 0; opacity: 0; }
.nav-ep.done .chk { opacity: 1; }

/* 메인 */
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; padding: 10px 20px; }
.topbar .crumb { font-size: 13px; color: var(--text-3); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.topbar .crumb b { color: var(--text-2); }
.icon-btn { width: 36px; height: 36px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 15px; color: var(--text-2); transition: background .15s, color .15s; flex-shrink: 0; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
#menu-btn { display: none; }

/* 아티클 */
.article-wrap { display: flex; gap: 0; max-width: 1100px; margin: 0 auto; }
article.content { flex: 1; min-width: 0; padding: 40px 48px 60px; max-width: 780px; margin: 0 auto; }
.ep-header { margin-bottom: 36px; padding-bottom: 28px; border-bottom: 2px solid var(--border); }
.ep-header .part-line { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ep-header .part-line .chip { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 7px; color: #fff; }
.ep-header .part-line .pn { font-size: 13px; font-weight: 700; color: var(--text-3); }
.ep-header h1 { font-size: clamp(26px, 4vw, 36px); font-weight: 800; letter-spacing: -.03em; line-height: 1.25; }
.ep-header .stars { color: var(--gold); font-size: 15px; margin-top: 8px; letter-spacing: 2px; }
.ep-header .meta-line { display: flex; gap: 18px; margin-top: 14px; font-size: 13px; color: var(--text-3); font-weight: 600; flex-wrap: wrap; }
.ep-header .meta-line i { margin-right: 5px; }

/* 본문 타이포그래피 */
.content { font-size: var(--fs, 16.5px); }
.content h2 { font-size: 1.45em; font-weight: 800; letter-spacing: -.02em; margin: 2.2em 0 .7em; padding-top: .6em; line-height: 1.35; position: relative; }
.content h2::before { content: ''; display: block; width: 28px; height: 4px; background: var(--accent); border-radius: 2px; margin-bottom: 12px; }
.content h3 { font-size: 1.15em; font-weight: 700; margin: 1.8em 0 .5em; letter-spacing: -.01em; }
.content p { margin: .85em 0; color: var(--text); }
.content strong { font-weight: 700; background: linear-gradient(transparent 62%, var(--accent-soft) 62%); padding: 0 1px; }
.content ul, .content ol { margin: .8em 0; padding-left: 1.5em; }
.content li { margin: .35em 0; }
.content blockquote { margin: 1.3em 0; padding: 14px 20px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; font-weight: 500; }
.content blockquote p { margin: .3em 0; }
.content hr { border: none; border-top: 1px dashed var(--border); margin: 2.4em auto; width: 60%; }
.content table { width: 100%; border-collapse: collapse; margin: 1.4em 0; font-size: .92em; display: block; overflow-x: auto; }
.content table thead th { background: var(--bg-hover); font-weight: 700; text-align: left; }
.content th, .content td { border: 1px solid var(--border); padding: 9px 13px; min-width: 60px; }
.content tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-hover) 45%, transparent); }
.content code { background: var(--bg-hover); border-radius: 5px; padding: 2px 6px; font-size: .88em; font-family: 'SF Mono', Consolas, monospace; }
.content pre { background: var(--bg-hover); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; overflow-x: auto; margin: 1.2em 0; }
.content pre code { background: none; padding: 0; }
.content img { max-width: 100%; border-radius: 10px; }

/* 우측 TOC */
.toc-rail { width: var(--toc-w); flex-shrink: 0; padding: 40px 20px 40px 0; display: block; }
.toc-inner { position: sticky; top: 76px; max-height: calc(100vh - 110px); overflow-y: auto; }
.toc-inner .toc-title { font-size: 11px; font-weight: 800; color: var(--text-3); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 10px; }
.toc-link { display: block; font-size: 12.5px; color: var(--text-3); padding: 5px 0 5px 12px; border-left: 2px solid var(--border); line-height: 1.45; transition: color .15s, border-color .15s; }
.toc-link:hover { color: var(--text); }
.toc-link.active { color: var(--accent); border-left-color: var(--accent); font-weight: 700; }

/* 하단 네비 */
.ep-footer { max-width: 780px; margin: 0 auto; padding: 0 48px 80px; }
.complete-box { display: flex; align-items: center; justify-content: center; margin: 12px 0 32px; }
.complete-btn { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; padding: 13px 28px; border-radius: 99px; border: 2px solid var(--border); color: var(--text-2); transition: all .2s; background: var(--bg-card); }
.complete-btn:hover { border-color: #10b981; color: #10b981; }
.complete-btn.done { background: #10b981; border-color: #10b981; color: #fff; }
.prev-next { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pn-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; transition: transform .15s, box-shadow .15s, border-color .15s; }
.pn-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.pn-card.next { text-align: right; }
.pn-card .dir { font-size: 12px; color: var(--text-3); font-weight: 700; margin-bottom: 4px; }
.pn-card .tt { font-weight: 700; font-size: 14.5px; line-height: 1.4; }
.pn-card.empty { visibility: hidden; }

/* ─── 검색 모달 ─── */
.search-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding: 12vh 20px 20px; opacity: 0; pointer-events: none; transition: opacity .18s; backdrop-filter: blur(3px); }
.search-overlay.open { opacity: 1; pointer-events: auto; }
.search-box { width: 100%; max-width: 620px; background: var(--bg-card); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; transform: translateY(-8px) scale(.98); transition: transform .18s; }
.search-overlay.open .search-box { transform: none; }
.search-input-row { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.search-input-row i { color: var(--text-3); }
#search-input { flex: 1; border: none; outline: none; background: none; font-size: 16px; font-family: inherit; color: var(--text); }
.search-input-row kbd { font-size: 11px; background: var(--bg-hover); border: 1px solid var(--border); border-radius: 5px; padding: 2px 7px; color: var(--text-3); font-family: inherit; }
#search-results { max-height: 55vh; overflow-y: auto; padding: 8px; }
.sr-item { display: block; padding: 11px 14px; border-radius: 10px; transition: background .12s; }
.sr-item:hover, .sr-item.sel { background: var(--bg-hover); }
.sr-item .rt { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sr-item .rt .en { font-size: 11px; font-weight: 800; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 5px; }
.sr-item .rs { font-size: 12.5px; color: var(--text-3); margin-top: 3px; line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sr-item .rs mark { background: var(--accent-soft); color: var(--accent); font-weight: 700; border-radius: 3px; padding: 0 2px; }
.sr-empty { text-align: center; color: var(--text-3); padding: 32px; font-size: 14px; }

/* 사이드바 오버레이 (모바일) */
.sb-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 49; opacity: 0; pointer-events: none; transition: opacity .2s; }

/* 플로팅 홈버튼 (홈에서 검색) */
.fab-search { position: fixed; right: 24px; bottom: 24px; width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 19px; box-shadow: var(--shadow-lg); display: flex; align-items: center; justify-content: center; z-index: 60; transition: transform .15s; }
.fab-search:hover { transform: scale(1.08); }

/* ─── 반응형 ─── */
@media (max-width: 1080px) { .toc-rail { display: none; } }
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sb-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sb-open .sb-overlay { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  #menu-btn { display: flex; }
  article.content { padding: 28px 22px 40px; }
  .ep-footer { padding: 0 22px 60px; }
  .hero { padding: 48px 0 36px; }
  .hero-stats { gap: 24px; }
}

/* ─── 로그인 ─── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 20px; padding: 44px 36px 32px; box-shadow: var(--shadow-lg); text-align: center; }
.login-logo { font-size: 44px; margin-bottom: 14px; }
.login-card h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.login-sub { font-size: 13px; color: var(--text-3); margin-top: 8px; font-weight: 500; }
.login-divider { height: 1px; background: var(--border); margin: 24px 0; }
.login-guide { font-size: 14px; color: var(--text-2); line-height: 1.7; margin-bottom: 18px; }
#login-code { width: 100%; padding: 14px 16px; font-size: 17px; font-weight: 700; letter-spacing: .1em; text-align: center; border: 2px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); outline: none; font-family: inherit; transition: border-color .15s; }
#login-code:focus { border-color: var(--accent); }
#login-btn { width: 100%; margin-top: 12px; padding: 14px; font-size: 15px; font-weight: 700; border-radius: 12px; background: var(--accent); color: #fff; transition: opacity .15s, transform .1s; }
#login-btn:hover { opacity: .92; }
#login-btn:active { transform: scale(.98); }
#login-btn:disabled { opacity: .6; cursor: default; }
.login-err { color: #dc2626; font-size: 13px; font-weight: 600; margin-top: 12px; min-height: 18px; }
.login-foot { font-size: 12px; color: var(--text-3); margin-top: 20px; }

/* ─── 유저바 ─── */
.user-bar { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding-top: 18px; }
.user-chip { font-size: 13px; font-weight: 700; color: var(--text-2); background: var(--bg-card); border: 1px solid var(--border); border-radius: 99px; padding: 6px 14px; }
.user-chip i { color: #10b981; margin-right: 5px; }
.user-logout { font-size: 12.5px; font-weight: 600; color: var(--text-3); padding: 6px 10px; border-radius: 8px; transition: background .15s, color .15s; }
.user-logout:hover { background: var(--bg-hover); color: var(--text); }
