/* Markdown 样式表 - 包含完整的表格样式 */

:root {
  --sidebar-width: 220px;
  --topbar-height: 52px;
  --color-bg: #ffffff;
  --color-sidebar: #f7f7f8;
  --color-sidebar-hover: #ebebec;
  --color-sidebar-active: #e4e4e6;
  --color-border: #e5e5e5;
  --color-primary: #4f6ef7;
  --color-primary-light: #eef1fe;
  --color-text: #1a1a1a;
  --color-text-secondary: #666;
  --color-text-muted: #999;
  --color-tool-bg: #f5f5f5;
  --color-skill-bg: #e8f0fe;
  --color-skill-text: #1a56db;
  --color-user-bubble: #f0f0f0;
  --color-orange: #f97316;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.10);
}

.markdown-body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  color: #24292f;
  background-color: #ffffff;
  padding: 24px;
  word-wrap: break-word;
  width: 100%;
}

/* 标题样式 */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.25;
  color: #1f2328;
}

.stream-text h1,
.markdown-body h1 {
  font-size: 1.2em;
  padding-bottom: 0.3em;
}

.stream-text h2,
.markdown-body h2 {
  font-size: 1.1em;
  padding-bottom: 0.3em;
}

.stream-text h3,
.markdown-body h3 {
  font-size: 1em;
}

.stream-text h4,
.markdown-body h4 {
  font-size: 1em;
}

.stream-text h5,
.markdown-body h5 {
  font-size: 0.875em;
}

.stream-text h6,
.markdown-body h6 {
  font-size: 0.85em;
  color: #656d76;
}

/* 段落和文本 */
.markdown-body p {
  margin-top: 0;
  margin-bottom: 16px;
}

.markdown-body a {
  color: #667eea;
  text-decoration: none;
  transition: color 0.2s ease;
}

.markdown-body a:hover {
  color: #764ba2;
  text-decoration: underline;
}

.markdown-body strong {
  font-weight: 600;
  color: #1f2328;
}

.markdown-body em {
  font-style: italic;
}

.markdown-body del {
  text-decoration: line-through;
}

/* 列表样式 */
.markdown-body ul,
.markdown-body ol {
  margin-top: 0;
  margin-bottom: 16px;
  padding-left: 2em;
}

.markdown-body ul {
  list-style-type: disc;
}

.markdown-body ol {
  list-style-type: decimal;
}

.markdown-body li {
  margin-bottom: 8px;
}

.markdown-body li>ul,
.markdown-body li>ol {
  margin-top: 8px;
  margin-bottom: 0;
}

.markdown-body li>p {
  margin-bottom: 8px;
}

/* 任务列表 */
.markdown-body ul.contains-task-list {
  list-style-type: none;
  padding-left: 0;
}

.markdown-body .task-list-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.markdown-body .task-list-item input[type="checkbox"] {
  margin-top: 5px;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ============================================
   表格样式 - 核心部分
   ============================================ */

.markdown-body table {
  display: block;
  width: 100%;
  width: max-content;
  max-width: 100%;
  overflow: auto;
  margin-top: 0;
  margin-bottom: 24px;
  border-spacing: 0;
  border-collapse: collapse;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.markdown-body table thead {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.markdown-body table th {
  padding: 12px 16px;
  font-weight: 600;
  text-align: left;
  border: none;
  border-top: 1px solid #e1e4e8;
  border-bottom: 1px solid #e1e4e8;
  border-right: 1px solid #e1e4e8;
  font-size: 14px;
  white-space: nowrap;
}

.markdown-body table th:first-child {
  border-left: 1px solid #e1e4e8;
}

.markdown-body table th:last-child {}

.markdown-body table td {
  padding: 12px 16px;
  border-bottom: 1px solid #e1e4e8;
  border-right: 1px solid #e1e4e8;
  font-size: 14px;
  line-height: 1.5;
  color: #24292f;
}

.markdown-body table td:first-child {
  border-left: 1px solid #e1e4e8;
}

.markdown-body table tr {
  background-color: #ffffff;
  transition: background-color 0.2s ease;
}

.markdown-body table tbody tr:hover {
  background-color: #f6f8fa;
}

.markdown-body table tbody tr:nth-child(even) {
  background-color: #fafbfc;
}

.markdown-body table tbody tr:nth-child(even):hover {
  background-color: #f0f4f8;
}

.markdown-body table tbody tr:last-child td {
  border-bottom: none;
}

.markdown-body table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 8px;
}

.markdown-body table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 8px;
}

/* 表格中的代码样式 */
.markdown-body table code {
  background-color: rgba(175, 184, 193, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 85%;
}

/* 表格中的链接样式 */
.markdown-body table a {
  color: #667eea;
  font-weight: 500;
}

.markdown-body table a:hover {
  color: #764ba2;
}

/* 紧凑型表格 */
.markdown-body table.compact th,
.markdown-body table.compact td {
  padding: 8px 12px;
  font-size: 13px;
}

/* 无边框表格 */
.markdown-body table.borderless {
  box-shadow: none;
}

.markdown-body table.borderless th,
.markdown-body table.borderless td {
  border: none;
}

.markdown-body table.borderless thead {
  background: #f6f8fa;
}

.markdown-body table.borderless th {
  color: #24292f;
  border-bottom: 2px solid #d0d7de;
}

/* 条纹表格（斑马纹） */
.markdown-body table.stripe tbody tr:nth-child(odd) {
  background-color: #ffffff;
}

.markdown-body table.stripe tbody tr:nth-child(even) {
  background-color: #f6f8fa;
}

/* ============================================
   代码块样式
   ============================================ */

.markdown-body code {
  background-color: rgba(175, 184, 193, 0.2);
  padding: 0.2em 0.4em;
  margin: 0;
  font-size: 85%;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  border-radius: 6px;
  color: #24292f;
}

.markdown-body pre {
  margin-top: 0;
  margin-bottom: 24px;
  padding: 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.45;
  background-color: #1e1e1e;
  border-radius: 8px;
  color: #d4d4d4;
}

.markdown-body pre code {
  display: inline;
  max-width: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  line-height: inherit;
  word-wrap: normal;
  background-color: transparent;
  border: 0;
  color: inherit;
}

.markdown-body pre>code {
  padding: 0;
  margin: 0;
  word-break: normal;
  white-space: pre;
  background: transparent;
  border: 0;
}

/* 代码块头部 */
.markdown-body .code-block {
  margin-bottom: 24px;
  border-radius: 8px;
  overflow: hidden;
  background-color: #1e1e1e;
}

.markdown-body .code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background-color: #2d2d2d;
  border-bottom: 1px solid #3e3e3e;
}

.markdown-body .code-lang {
  font-size: 12px;
  color: #9cdcfe;
  font-weight: 500;
  text-transform: uppercase;
}

.markdown-body .code-copy-btn {
  padding: 4px 8px;
  font-size: 12px;
  color: #d4d4d4;
  background: transparent;
  border: 1px solid #5a5a5a;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.markdown-body .code-copy-btn:hover {
  background-color: #3e3e3e;
  border-color: #6e6e6e;
}

/* ============================================
   引用块样式
   ============================================ */

.markdown-body blockquote {
  margin: 0 0 24px 0;
  padding: 0 16px;
  color: #656d76;
  border-left: 4px solid #667eea;
  background-color: #f6f8fa;
  padding: 16px;
  border-radius: 0 8px 8px 0;
}

.markdown-body blockquote> :first-child {
  margin-top: 0;
}

.markdown-body blockquote> :last-child {
  margin-bottom: 0;
}

.markdown-body blockquote p {
  color: #57606a;
}

/* ============================================
   分割线样式
   ============================================ */

.markdown-body hr {
  height: 2px;
  padding: 0;
  margin: 32px 0;
  border: 0;
  overflow: hidden;
}

/* ============================================
   图片样式
   ============================================ */

.markdown-body img {
  max-width: 100%;
  box-sizing: content-box;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.markdown-body img[align="right"] {
  padding-left: 20px;
}

.markdown-body img[align="left"] {
  padding-right: 20px;
}

.markdown-body .emoji {
  max-width: none;
  vertical-align: text-top;
  background-color: transparent;
  box-shadow: none;
}

/* ============================================
   水平滚动容器
   ============================================ */

.markdown-body .highlight {
  margin-bottom: 24px;
}

.markdown-body .highlight pre {
  margin-bottom: 0;
  word-break: normal;
}

/* ============================================
   脚注样式
   ============================================ */

.markdown-body .footnotes {
  font-size: 12px;
  color: #656d76;
  border-top: 1px solid #d0d7de;
  margin-top: 32px;
  padding-top: 16px;
}

.markdown-body .footnotes ol {
  padding-left: 20px;
}

.markdown-body .footnotes li {
  margin-bottom: 4px;
}

.markdown-body .footnote-backref {
  font-size: 10px;
  margin-left: 4px;
}

/* ============================================
   定义列表
   ============================================ */

.markdown-body dl {
  margin-top: 0;
  margin-bottom: 24px;
  padding: 0;
}

.markdown-body dl dt {
  margin-top: 16px;
  padding: 0;
  font-weight: 600;
  font-style: italic;
}

.markdown-body dl dd {
  margin-bottom: 16px;
  margin-left: 0;
  padding: 0 16px;
}

/* ============================================
   键盘按键样式
   ============================================ */

.markdown-body kbd {
  display: inline-block;
  padding: 3px 5px;
  font: 11px 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  line-height: 10px;
  color: #24292f;
  vertical-align: middle;
  background-color: #f6f8fa;
  border: solid 1px rgba(175, 184, 193, 0.2);
  border-bottom-color: rgba(175, 184, 193, 0.2);
  border-radius: 6px;
  box-shadow: inset 0 -1px 0 rgba(175, 184, 193, 0.2);
}

/* ============================================
   响应式适配
   ============================================ */

@media (max-width: 768px) {
  .markdown-body {
    padding: 16px;
    font-size: 14px;
  }

  .markdown-body h1 {
    font-size: 1.75em;
  }

  .markdown-body h2 {
    font-size: 1.375em;
  }

  .markdown-body h3 {
    font-size: 1.125em;
  }

  /* 表格移动端适配 */
  .markdown-body table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .markdown-body table th,
  .markdown-body table td {
    padding: 8px 12px;
    font-size: 13px;
  }

  .markdown-body pre {
    padding: 12px;
    font-size: 13px;
  }
}

/* ============================================
   打印样式
   ============================================ */

@media print {
  .markdown-body {
    background: white;
    color: black;
    padding: 0;
  }

  .markdown-body table {
    box-shadow: none;
    border: 1px solid #d0d7de;
  }

  .markdown-body table thead {
    background: #f6f8fa !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .markdown-body table th {
    color: #24292f;
    border-bottom: 2px solid #d0d7de;
  }

  .markdown-body a {
    color: #667eea;
    text-decoration: underline;
  }

  .markdown-body pre {
    background-color: #f6f8fa;
    color: #24292f;
    border: 1px solid #d0d7de;
  }
}

html,
body,
#root {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  font-size: 14px;
  line-height: 1.6;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

/* scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 4px;
}

/* markdown prose */
.prose h1 {
  font-size: 1.5em;
  font-weight: 700;
  margin: 1em 0 .5em;
}

.prose h2 {
  font-size: 1.25em;
  font-weight: 700;
  margin: .9em 0 .4em;
}

.prose h3 {
  font-size: 1.1em;
  font-weight: 600;
  margin: .8em 0 .3em;
}

.prose p {
  margin: .5em 0;
}

.prose ul,
.prose ol {
  padding-left: 1.5em;
  margin: .5em 0;
}

.prose li {
  margin: .2em 0;
}

.prose strong {
  font-weight: 700;
}

.prose em {
  font-style: italic;
}

.prose code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  background: #f0f0f0;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .88em;
}

.prose pre {
  background: #1e1e1e;
  color: #d4d4d4;
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: .6em 0;
  font-size: .88em;
}

.prose pre code {
  background: none;
  padding: 0;
}

.prose blockquote {
  border-left: 3px solid var(--color-primary);
  padding-left: 12px;
  color: #555;
  margin: .5em 0;
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  margin: .5em 0;
}

.prose th,
.prose td {
  border: 1px solid var(--color-border);
  padding: 6px 12px;
  text-align: left;
}

.prose th {
  background: #f5f5f5;
  font-weight: 600;
}

.prose a {
  color: var(--color-primary);
}

/* paper-specific: citations in blue */
.prose .citation {
  color: var(--color-primary);
}

svg[aria-roledescription="error"] {
  display: none;
}