/* ── Guide Layout ──────────────────────────────────────── */

:root {
  --guide-sidebar-w:    260px;
  --guide-toc-w:        220px;
  --guide-header-h:     48px;
  --guide-sidebar-bg:   #FAFAF8;
  --guide-accent:       oklch(0.52 0.14 258);
  --guide-accent-bg:    oklch(0.95 0.04 258);
  --guide-nav-active:   oklch(0.95 0.04 258);
  --guide-nav-hover:    #EEEDE9;
  --guide-border:       #E4E2DD;
  --guide-text:         #1A1917;
  --guide-text-muted:   #6B6965;
  --guide-code-bg:      #F6F5F1;
  --guide-panel-w:      380px;
  --guide-panel-h:      520px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

.guide-body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg, #F8F7F4);
  color: var(--guide-text);
  display: flex;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.65;
}

/* ── 모바일 오버레이 ──────────────────────────────────── */

.guide-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 90;
}
.guide-overlay.show { display: block; }

/* ── 모바일 헤더 ──────────────────────────────────────── */

.guide-mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--guide-header-h);
  background: #fff;
  border-bottom: 1px solid var(--guide-border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
}

.guide-hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.guide-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--guide-text);
  border-radius: 2px;
  transition: transform .2s;
}

.guide-mobile-logo {
  flex: 1;
  font-weight: 600;
  font-size: 15px;
  color: var(--guide-text);
  text-decoration: none;
}

.guide-search-fab-mobile {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--guide-text-muted);
  padding: 4px;
}

/* ── 사이드바 ──────────────────────────────────────────── */

.guide-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--guide-sidebar-w);
  background: var(--guide-sidebar-bg);
  border-right: 1px solid var(--guide-border);
  overflow-y: auto;
  z-index: 95;
  transition: transform .25s ease;
}

.guide-sidebar-inner {
  padding: 0 0 40px;
}

.guide-sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--guide-border);
  margin-bottom: 8px;
}

.guide-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--guide-text);
  text-decoration: none;
}
.guide-logo:hover { color: var(--guide-accent); }

/* ── 사이드바 네비게이션 ──────────────────────────────── */

.guide-nav { padding: 8px 0; }
.guide-nav-list { list-style: none; }

.guide-nav-section { margin-bottom: 2px; }

.guide-nav-section-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--guide-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  text-align: left;
  transition: color .15s;
}
.guide-nav-section-btn:hover { color: var(--guide-text); }
.guide-nav-section-btn.active { color: var(--guide-text); }

.guide-chevron {
  transition: transform .2s;
  flex-shrink: 0;
}
.guide-nav-section-btn.active .guide-chevron,
.guide-nav-section-btn[aria-expanded="true"] .guide-chevron {
  transform: rotate(180deg);
}

.guide-nav-items {
  list-style: none;
  display: none;
  padding-bottom: 4px;
}
.guide-nav-items.open { display: block; }

.guide-nav-link {
  display: block;
  padding: 6px 16px 6px 24px;
  font-size: 14px;
  color: var(--guide-text-muted);
  text-decoration: none;
  border-radius: 6px;
  margin: 1px 8px;
  transition: background .12s, color .12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.guide-nav-link:hover {
  background: var(--guide-nav-hover);
  color: var(--guide-text);
}
.guide-nav-link.active {
  background: var(--guide-nav-active);
  color: var(--guide-accent);
  font-weight: 500;
  border-left: 2px solid var(--guide-accent);
  padding-left: 22px;
}

/* ── 메인 영역 ────────────────────────────────────────── */

.guide-main {
  margin-left: var(--guide-sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Breadcrumb (topbar) ─────────────────────────────── */

.guide-breadcrumb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--guide-border);
  font-size: 13px;
  color: var(--guide-text-muted);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--guide-header-h);
}

.guide-breadcrumb-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.guide-breadcrumb-right {
  flex-shrink: 0;
}

.guide-breadcrumb-updated {
  font-size: 12px;
  color: #C4C2BD;
}

.guide-breadcrumb-home {
  color: var(--guide-accent);
  text-decoration: none;
}
.guide-breadcrumb-home:hover { text-decoration: underline; }

.guide-breadcrumb-sep { color: #C4C2BD; }

/* ── 콘텐츠 + TOC 레이아웃 ──────────────────────────── */

.guide-content-wrap {
  flex: 1;
}

.guide-page-wrap {
  display: flex;
  align-items: flex-start;
  gap: 40px;
  max-width: 1100px;
  padding: 40px 32px;
}

/* ── 문서 본문 ───────────────────────────────────────── */

.guide-article {
  flex: 1;
  min-width: 0;
}

.guide-article-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--guide-border);
}

.guide-article-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--guide-text);
  margin-bottom: 8px;
}

.guide-article-desc {
  font-size: 16px;
  color: var(--guide-text-muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.guide-article-meta {
  font-size: 13px;
  color: #C4C2BD;
}

/* ── 문서 본문 타이포그래피 ──────────────────────────── */

.guide-article-body { max-width: 720px; }

.guide-article-body h1,
.guide-article-body h2,
.guide-article-body h3,
.guide-article-body h4 {
  color: var(--guide-text);
  line-height: 1.3;
  font-weight: 600;
}

.guide-article-body h1 { font-size: 24px; margin: 40px 0 16px; }
.guide-article-body h2 { font-size: 20px; margin: 36px 0 14px; padding-top: 8px; }
.guide-article-body h3 { font-size: 17px; margin: 28px 0 10px; }
.guide-article-body h4 { font-size: 15px; margin: 20px 0 8px; }

.guide-article-body h2::before {
  content: '';
  display: block;
  border-top: 1px solid var(--guide-border);
  margin-bottom: 28px;
}
.guide-article-body h2:first-child::before { display: none; }

.guide-article-body p { margin-bottom: 14px; color: #3D3B38; }

.guide-article-body a {
  color: var(--guide-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.guide-article-body ul,
.guide-article-body ol {
  margin: 12px 0 16px 20px;
  color: #3D3B38;
}

.guide-article-body li { margin-bottom: 6px; }

.guide-article-body blockquote {
  border-left: 3px solid var(--guide-accent);
  padding: 12px 16px;
  background: var(--guide-accent-bg, oklch(0.95 0.04 258));
  border-radius: 0 6px 6px 0;
  margin: 16px 0;
  color: var(--guide-text-muted);
  font-size: 14px;
}

/* ── 테이블 ──────────────────────────────────────────── */

.guide-article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 14px;
}

.guide-article-body th {
  background: #F0EFEB;
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--guide-border);
  color: var(--guide-text);
}

.guide-article-body td {
  padding: 9px 14px;
  border: 1px solid var(--guide-border);
  color: #3D3B38;
}

.guide-article-body tr:nth-child(even) td { background: #FAFAF8; }

/* ── 코드 블록 ───────────────────────────────────────── */

.guide-article-body pre {
  position: relative;
  background: var(--guide-code-bg);
  border: 1px solid var(--guide-border);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.guide-article-body code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

.guide-article-body :not(pre) > code {
  background: var(--guide-code-bg);
  border: 1px solid var(--guide-border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--guide-text);
}

/* 코드 복사 버튼 */
.guide-copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #fff;
  border: 1px solid var(--guide-border);
  border-radius: 5px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  color: var(--guide-text-muted);
  transition: background .15s, color .15s;
  font-family: inherit;
}
.guide-copy-btn:hover {
  background: var(--guide-nav-hover);
  color: var(--guide-text);
}
.guide-copy-btn.copied {
  background: var(--guide-accent-bg);
  color: var(--guide-accent);
  border-color: var(--guide-accent);
}

/* highlight.js 스타일 오버라이드 */
.guide-article-body .hljs {
  background: transparent;
  padding: 0;
}

/* ── 헤딩 앵커 링크 ──────────────────────────────────── */

.guide-article-body h2,
.guide-article-body h3 {
  position: relative;
}

.guide-anchor-link {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.85em;
  color: var(--guide-text-muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity .15s;
  font-weight: 400;
  vertical-align: middle;
}

.guide-article-body h2:hover .guide-anchor-link,
.guide-article-body h3:hover .guide-anchor-link {
  opacity: 1;
}

.guide-anchor-link:hover {
  color: var(--guide-accent);
}

/* ── 체크리스트 ──────────────────────────────────────── */

.guide-article-body input[type="checkbox"] {
  margin-right: 6px;
  accent-color: var(--guide-accent);
}

/* ── On This Page (TOC) ──────────────────────────────── */

.guide-toc {
  width: var(--guide-toc-w);
  flex-shrink: 0;
}

.guide-toc-inner {
  position: sticky;
  top: 80px;
}

.guide-toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--guide-text-muted);
  margin-bottom: 10px;
}

.guide-toc-list { list-style: none; }

.guide-toc-list li { margin-bottom: 2px; }

.guide-toc-link {
  display: block;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--guide-text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color .12s, border-color .12s;
  line-height: 1.4;
}

.guide-toc-link:hover {
  color: var(--guide-text);
  border-left-color: var(--guide-border);
}

.guide-toc-link.active {
  color: var(--guide-accent);
  border-left-color: var(--guide-accent);
}

.guide-toc-sub .guide-toc-link { padding-left: 18px; font-size: 12.5px; }

/* ── AI 검색 FAB ─────────────────────────────────────── */

.guide-search-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--guide-accent);
  color: #fff;
  border: none;
  border-radius: 28px;
  padding: 13px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  transition: transform .15s, box-shadow .15s;
  font-family: inherit;
  z-index: 80;
}
.guide-search-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.22);
}

/* ── AI 검색 패널 ────────────────────────────────────── */

.guide-search-panel {
  position: fixed;
  bottom: 88px;
  right: 28px;
  width: var(--guide-panel-w);
  height: var(--guide-panel-h);
  background: #fff;
  border: 1px solid var(--guide-border);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 80;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

.guide-search-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.guide-search-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--guide-border);
  background: #FAFAF8;
}

.guide-search-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--guide-text);
}

.guide-search-panel-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--guide-text-muted);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background .12s;
}
.guide-search-panel-close:hover { background: var(--guide-nav-hover); }

.guide-search-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-search-welcome {
  color: var(--guide-text-muted);
  font-size: 13px;
  text-align: center;
  margin-top: 16px;
}

/* 채팅 메시지 */
.guide-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guide-msg-user {
  align-items: flex-end;
}

.guide-msg-ai {
  align-items: flex-start;
}

.guide-msg-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.55;
}

.guide-msg-user .guide-msg-bubble {
  background: var(--guide-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.guide-msg-ai .guide-msg-bubble {
  background: #F0EFEB;
  color: var(--guide-text);
  border-bottom-left-radius: 4px;
}

/* AI 응답 내 마크다운 렌더링 스타일 */
.guide-msg-ai .guide-msg-bubble p { margin-bottom: 8px; }
.guide-msg-ai .guide-msg-bubble p:last-child { margin-bottom: 0; }
.guide-msg-ai .guide-msg-bubble code {
  background: rgba(0,0,0,0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12.5px;
  font-family: 'JetBrains Mono', monospace;
}
.guide-msg-ai .guide-msg-bubble pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12px;
  margin: 6px 0;
}
.guide-msg-ai .guide-msg-bubble pre code {
  background: none;
  padding: 0;
  color: inherit;
}
.guide-msg-ai .guide-msg-bubble ul,
.guide-msg-ai .guide-msg-bubble ol {
  padding-left: 18px;
  margin: 6px 0;
}
.guide-msg-ai .guide-msg-bubble li { margin-bottom: 4px; }

/* 로딩 점 애니메이션 */
.guide-msg-loading .guide-msg-bubble {
  color: var(--guide-text-muted);
}

.guide-loading-dots {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 2px 0;
}

.guide-loading-dots span {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--guide-text-muted);
  animation: guide-bounce 1.2s ease-in-out infinite;
}

.guide-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.guide-loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes guide-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

.guide-search-panel-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--guide-border);
  background: #FAFAF8;
}

.guide-search-input-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.guide-search-input {
  flex: 1;
  border: 1px solid var(--guide-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  color: var(--guide-text);
  background: #fff;
  line-height: 1.5;
  transition: border-color .15s;
}
.guide-search-input:focus { border-color: var(--guide-accent); }

.guide-search-send {
  background: var(--guide-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity .15s;
}
.guide-search-send:disabled { opacity: .5; cursor: not-allowed; }
.guide-search-send:not(:disabled):hover { opacity: .85; }

/* ── 가이드 인덱스 페이지 ────────────────────────────────── */

.guide-index-sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}

.guide-index-section {
  border: 1px solid var(--guide-border);
  border-radius: 8px;
  padding: 20px 20px 16px;
  background: #fff;
}

.guide-index-section h2 {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--guide-text-muted);
  margin: 0 0 12px !important;
  padding: 0 !important;
  border: none !important;
}

.guide-index-section h2::before { display: none !important; }

.guide-index-section ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.guide-index-section li { margin-bottom: 6px; }

.guide-index-section a {
  font-size: 14px;
  color: var(--guide-accent);
  text-decoration: none;
}
.guide-index-section a:hover { text-decoration: underline; }

/* ── 반응형 ─────────────────────────────────────────────── */

@media (max-width: 1200px) {
  .guide-toc { display: none; }
}

@media (max-width: 768px) {
  .guide-body { display: block; }

  .guide-mobile-header { display: flex; }

  .guide-sidebar {
    transform: translateX(calc(-1 * var(--guide-sidebar-w)));
    top: 0;
    z-index: 95;
  }
  .guide-sidebar.open { transform: translateX(0); }

  .guide-main { margin-left: 0; padding-top: var(--guide-header-h); }

  .guide-breadcrumb { padding: 12px 16px; }

  .guide-page-wrap { padding: 24px 16px; }

  .guide-article-title { font-size: 22px; }

  .guide-search-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 80px;
  }

  .guide-breadcrumb-right { display: none; }

  .guide-search-fab span { display: none; }
  .guide-search-fab { border-radius: 50%; width: 52px; height: 52px; padding: 0; justify-content: center; }

  .guide-index-sections { grid-template-columns: 1fr; }
}
