/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(156, 163, 175, 0.3);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(156, 163, 175, 0.5);
}

/* Markdown typography and GFM styling */
.markdown-content {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: inherit;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1.8em;
  margin-bottom: 0.6em;
  scroll-margin-top: 5rem;
}

.markdown-content h1 { font-size: 1.85rem; border-bottom: 1px solid var(--border-color, #e5e7eb); padding-bottom: 0.4em; }
.markdown-content h2 { font-size: 1.45rem; border-bottom: 1px solid var(--border-color, #e5e7eb); padding-bottom: 0.3em; }
.markdown-content h3 { font-size: 1.2rem; }
.markdown-content h4 { font-size: 1.05rem; }

.dark .markdown-content h1,
.dark .markdown-content h2 {
  border-bottom-color: #1e2230;
}

.markdown-content p {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
  line-height: 1.7;
}

.markdown-content a {
  color: #0284c7;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}
.markdown-content a:hover {
  color: #38bdf8;
}

.markdown-content ul,
.markdown-content ol {
  padding-left: 1.6em;
  margin-top: 0.5em;
  margin-bottom: 0.8em;
}

.markdown-content ul { list-style-type: disc; }
.markdown-content ol { list-style-type: decimal; }

.markdown-content li {
  margin-top: 0.3em;
  margin-bottom: 0.3em;
  line-height: 1.6;
}

.markdown-content li > p {
  margin: 0;
}

.markdown-content blockquote {
  margin: 1em 0;
  padding: 0.6em 1.2em;
  border-left: 4px solid #0284c7;
  background-color: rgba(2, 132, 199, 0.05);
  border-radius: 0 0.375rem 0.375rem 0;
  color: inherit;
  opacity: 0.9;
}

.markdown-content hr {
  margin: 2em 0;
  border: 0;
  border-top: 1px solid #e5e7eb;
}
.dark .markdown-content hr {
  border-top-color: #1e2230;
}

/* Tables */
.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 0.9em;
}

.markdown-content th,
.markdown-content td {
  padding: 0.6em 1em;
  border: 1px solid #e5e7eb;
  text-align: left;
}
.dark .markdown-content th,
.dark .markdown-content td {
  border-color: #1e2230;
}

.markdown-content th {
  background-color: rgba(243, 244, 246, 0.8);
  font-weight: 600;
}
.dark .markdown-content th {
  background-color: #141721;
}

.markdown-content tr:nth-child(even) {
  background-color: rgba(249, 250, 251, 0.5);
}
.dark .markdown-content tr:nth-child(even) {
  background-color: rgba(20, 23, 33, 0.3);
}

/* Code & Pre */
.markdown-content code:not(pre code) {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.875em;
  padding: 0.2em 0.4em;
  border-radius: 0.25rem;
  background-color: rgba(156, 163, 175, 0.15);
  color: #0284c7;
}
.dark .markdown-content code:not(pre code) {
  background-color: rgba(255, 255, 255, 0.08);
  color: #38bdf8;
}

.markdown-content pre {
  margin: 1.2em 0;
  padding: 1em;
  border-radius: 0.5rem;
  background-color: #0d1117 !important;
  color: #c9d1d9 !important;
  overflow-x: auto;
  position: relative;
  border: 1px solid #30363d;
}

.markdown-content pre code {
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.85em;
  line-height: 1.5;
  background: transparent !important;
  padding: 0 !important;
}

/* Code Copy Button */
.code-block-wrapper {
  position: relative;
}
.copy-code-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: #8b949e;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 0.25rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background-color 0.2s;
}
.code-block-wrapper:hover .copy-code-btn {
  opacity: 1;
}
.copy-code-btn:hover {
  background: #30363d;
  color: #c9d1d9;
}

/* KaTeX formula centering */
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5em 0;
}

/* Images in Markdown */
.markdown-content img {
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
  margin: 1em auto;
  display: block;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
