* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  transition: all 0.3s ease;
}

.dark-mode a {
  color: #2196f3;
}

.dark-mode {
  color: #eee;
  background-color: #222;
}

body {
  background-color: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px;
  background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
  color: white;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.subtitle {
  font-size: 1.1rem;
  opacity: 0.9;
}

.editor-preview-container {
  display: flex;
  gap: 20px;
  flex: 1;
  margin-bottom: 20px;
}

.editor-section,
.preview-section {
  flex: 1;
  display: flex;
  position: relative;
  flex-direction: column;
  border-radius: 10px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background-color: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.section-header h2 {
  font-size: 1.3rem;
  color: #495057;
}

.toolbar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.toolbar-btn {
  padding: 5px 10px;
  background-color: #e9ecef;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.dark-mode .toolbar-btn {
  color: #eee;
  background-color: #222;
}

.toolbar-btn:hover {
  background-color: #dee2e6;
}

.copy-btn {
  position: absolute;
  top: 70px;
  right: 6px;
  background: rgba(0, 0, 0, 0.05);
  color: grey;
  border: none;
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
  opacity: 0.9;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
}

.dark-mode .copy-btn {
  color: white;
}

.copy-btn:hover {
  opacity: 1;
  transform: scale(1.1);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.copy-btn:active {
  transform: scale(0.9);
}

.dark-mode .copy-btn {
  background: rgba(255, 255, 255, 0.2);
}

#markdown-input {
  flex: 1;
  padding: 20px;
  border: none;
  resize: none;
  font-family: "Courier New", Courier, monospace;
  font-size: 1rem;
  line-height: 1.5;
  outline: none;
}

.preview-content {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  font-size: 1rem;
}

textarea {
  background-color: #f8f8f8;
}

.dark-mode textarea,
.dark-mode .preview-section,
.dark-mode .section-header,
.dark-mode .preview-content {
  background: #333 !important;
  color: #eee;
}

.dark-mode .section-header {
  border-bottom: #444 1px solid;
}

.dark-mode .section-header h2 {
  color: #eee !important;
}

@media (max-width: 768px) {
  .editor-section {
    min-height: 600px;
  }


  .editor-preview-container {
    flex-direction: column;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .toolbar {
    width: 100%;
    justify-content: space-between;
  }

  header h1 {
    font-size: 2rem;
  }
}

/* =====================
   📝 Markdown 样式
===================== */
.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4,
.preview-content h5,
.preview-content h6 {
  margin-top: 0.3em;
  margin-bottom: 0.3em;
  color: inherit;
}

.preview-content p {
  margin-bottom: 0.8em;
}

.preview-content p:last-child {
  margin-bottom: 0;
}

.preview-content ul,
.preview-content ol {
  padding-left: 1.5em;
  margin-bottom: 0.8em;
}

.preview-content li {
  margin-bottom: 0.3em;
}

.preview-content blockquote {
  border-left: 4px solid #ddd;
  padding-left: 1em;
  margin: 0.8em 0;
  color: #666;
  font-style: italic;
}

.preview-content table {
  border-collapse: collapse;
  width: 100%;
}

.preview-content th {
  border: 1px solid rgba(0, 0, 0, 0.7);
}

.preview-content td {
  border: 1px solid rgba(0, 0, 0, 0.4);
}

/* 保证 highlight.js 渲染出来的 span 不会丢掉等宽字体 */
.hljs,
.hljs * {
  font-family: "JetBrains Mono", Consolas, Monaco, "Courier New", monospace !important;
  font-variant-ligatures: none !important;
  font-feature-settings: "liga" 0, "calt" 0 !important;
}

/* ========== 行内代码 ========== */
.preview-content code {
  background-color: rgba(27, 31, 35, 0.05);
  color: #e01e5a; /* inline 代码强调色 */
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 1rem;
}

/* ========== 代码块（整体背景） ========== */
.preview-content pre {
  background-color: rgba(200, 200, 200, 0.15);
  color: #24292e;
  padding: 1em;
  border-radius: 10px;
  overflow-x: auto;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 1rem;
  line-height: 1.5;
  margin: 0.8em 0;
}

/* ========== 代码块内部文字 ========== */
.preview-content pre code {
  background-color: transparent !important;
  padding: 0 !important;
  color: inherit;
}

/* ========== 暗色模式 ========== */
.dark-mode .preview-content code {
  background-color: rgba(255, 255, 255, 0.05);
  color: #c9d1d9;
}

.dark-mode .preview-content pre {
  background-color: rgba(255, 255, 255, 0.05);
  color: #c9d1d9;
  scrollbar-width: thin;
  scrollbar-color: #333 #161b22;
}

.dark-mode .preview-content pre code {
  color: inherit;
}

.dark-mode .preview-content th {
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.dark-mode .preview-content td {
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.dark-mode .preview-content blockquote {
  color: #ddd;
}

/* 深色模式切换按钮 */
.dark-mode-toggle {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: all 0.3s ease;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.dark-mode-toggle:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.1);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.7);
}

.dark-mode .dark-mode-toggle {
  color: white;
}