/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 240px;
  --chat-w: 320px;
  --accent: #2563eb;
  --accent-light: #eff6ff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --surface: #ffffff;
  --radius: 10px;
}

html, body {
  height: 100%;
  font-family: 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

/* ── 3-Column Layout ── */
#layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--chat-w);
  height: 100vh;
  overflow: hidden;
}

/* ── 왼쪽: 사이드바 ── */
#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  border-bottom: 1px solid var(--border);
}
#home-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 14px 12px;
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}
#home-link:hover { background: var(--bg); }
.sidebar-icon { font-size: 20px; }
#sidebar-header h1 { font-size: 13px; font-weight: 700; line-height: 1.3; }

#sidebar-search { padding: 8px 10px; }
#search-input {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
#search-input:focus { border-color: var(--accent); }

#nav-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 4px 6px 16px;
}
#nav-list li { margin: 1px 0; }
.nav-section {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 8px 3px;
}
#nav-list a {
  display: block;
  padding: 5px 8px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  transition: background .1s, color .1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#nav-list a:hover { background: var(--bg); color: var(--text); }
#nav-list a.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }

/* ── 가운데: 문서 본문 ── */
#main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

#content-header {
  padding: 10px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

#markdown-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px 60px;
}

/* ── 랜딩 페이지 ── */
#landing { padding-bottom: 32px; }

#hero {
  position: relative;
  width: 100%;
  height: 320px;
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 28px;
}
#hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
}
#hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right, rgba(0,0,0,.7) 0%, rgba(0,0,0,.3) 60%, transparent 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 36px;
  color: white;
}
#hero-overlay h1 {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 10px;
  text-shadow: 0 2px 8px rgba(0,0,0,.3);
}
#hero-overlay p {
  font-size: 14px;
  opacity: .88;
  line-height: 1.6;
  text-shadow: 0 1px 4px rgba(0,0,0,.3);
}

#quick-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.quick-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  text-decoration: none;
  display: block;
}
.quick-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); border-color: var(--accent); }
.quick-card .card-emoji { font-size: 22px; margin-bottom: 6px; }
.quick-card .card-title { font-size: 13px; font-weight: 600; color: var(--text); }
.quick-card .card-desc { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── 마크다운 스타일 ── */
#markdown-body h1 { font-size: 24px; font-weight: 800; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 2px solid var(--border); }
#markdown-body h2 { font-size: 18px; font-weight: 700; margin-top: 28px; margin-bottom: 10px; }
#markdown-body h3 { font-size: 15px; font-weight: 600; margin-top: 20px; margin-bottom: 8px; color: #334155; }
#markdown-body h4 { font-size: 14px; font-weight: 600; margin-top: 14px; margin-bottom: 6px; }
#markdown-body p { margin-bottom: 10px; }
#markdown-body ul, #markdown-body ol { margin: 6px 0 10px 18px; }
#markdown-body li { margin-bottom: 3px; }
#markdown-body blockquote { border-left: 3px solid var(--accent); padding: 10px 14px; background: var(--accent-light); border-radius: 0 6px 6px 0; margin: 14px 0; color: #1e40af; font-style: italic; }
#markdown-body code { background: #f1f5f9; padding: 2px 5px; border-radius: 4px; font-size: 13px; font-family: 'JetBrains Mono', monospace; }
#markdown-body pre { background: #1e293b; color: #e2e8f0; padding: 14px; border-radius: 8px; overflow-x: auto; margin: 12px 0; }
#markdown-body pre code { background: none; padding: 0; color: inherit; }
#markdown-body table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 13px; }
#markdown-body th { background: #f1f5f9; padding: 7px 10px; text-align: left; font-weight: 600; border: 1px solid var(--border); }
#markdown-body td { padding: 7px 10px; border: 1px solid var(--border); }
#markdown-body tr:nth-child(even) td { background: var(--bg); }
#markdown-body a { color: var(--accent); text-decoration: none; }
#markdown-body a:hover { text-decoration: underline; }
#markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── 오른쪽: AI 챗봇 ── */
#chat-panel {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat-header {
  padding: 14px 16px;
  background: var(--accent);
  color: white;
  flex-shrink: 0;
}
#chat-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

.msg { display: flex; }
.msg.ai { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }

.msg-bubble {
  max-width: 90%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.msg.ai .msg-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.msg.user .msg-bubble { background: var(--accent); color: white; border-bottom-right-radius: 3px; }

.msg-bubble p { margin: 0 0 5px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul { padding-left: 14px; margin: 3px 0; }
.msg-bubble strong { font-weight: 700; }
.msg-bubble h3 { font-size: 13px; font-weight: 700; margin: 6px 0 3px; }

.typing-indicator { display: flex; gap: 4px; align-items: center; padding: 2px 0; }
.typing-dot { width: 6px; height: 6px; background: var(--muted); border-radius: 50%; animation: bounce .9s infinite; }
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); } 40% { transform: translateY(-5px); } }

#chat-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
#chat-input-row { display: flex; gap: 6px; align-items: flex-end; }
#chat-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color .15s;
  max-height: 80px;
  overflow-y: auto;
}
#chat-input:focus { border-color: var(--accent); }
#chat-send {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: background .15s;
  flex-shrink: 0;
}
#chat-send:hover { background: #1d4ed8; }
#chat-send:disabled { background: var(--muted); cursor: not-allowed; }

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── 반응형 ── */
@media (max-width: 900px) {
  #layout { grid-template-columns: 1fr; grid-template-rows: 1fr; }
  #sidebar, #chat-panel { display: none; }
  #markdown-body { padding: 20px 16px 40px; }
}
