/* ================================
   Markdown 编辑器 - 自定义样式
   配色与 Leowh 主页统一
   ================================ */

:root {
  --bg: #FAFAF9;
  --bg-alt: #F5F5F4;
  --surface: #FFFFFF;
  --border: #E7E5E4;
  --border-strong: #D6D3D1;
  --text: #1E293B;
  --text-secondary: #52525B;
  --text-muted: #71717A;
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-light: rgba(79, 70, 229, 0.08);
  --secondary: #F97316;
  --accent: #EC4899;
  --success: #059669;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Toast ── */
.toast {
  position: fixed; top: 24px; right: 24px;
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 100px;
  font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  z-index: 1000;
  transform: translateX(calc(100% + 40px));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.toast.show { transform: translateX(0); }
.toast-dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; }

/* ── Page ── */
.page { max-width: 960px; margin: 0 auto; padding: 0 32px; }

/* ── Header scroll effect ── */
#header.scrolled {
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 2px 20px rgba(0,0,0,0.06);
}

/* ══════════════════════════════════════════
   Editor Section
   ══════════════════════════════════════════ */
.editor-section { padding: 24px 0 32px; }

/* ── Action buttons ── */
.editor-actions {
  display: flex; gap: 8px;
  margin-bottom: 12px;
}

.action-btn {
  padding: 8px 16px;
  background: rgba(79,70,229,0.06);
  border: 1px solid rgba(79,70,229,0.12);
  border-radius: 100px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--primary); cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.action-btn:hover { background: rgba(79,70,229,0.10); border-color: rgba(79,70,229,0.20); }

/* ── Toolbar ── */
.toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: none;
  flex-wrap: wrap;
}

.toolbar-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: transparent; border: 1px solid transparent;
  border-radius: 6px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  transition: all 0.15s ease;
}
.toolbar-btn:hover {
  background: var(--primary-light);
  border-color: rgba(79,70,229,0.15);
  color: var(--primary);
}

.toolbar-sep {
  width: 1px; height: 24px;
  background: var(--border);
  margin: 0 4px;
}

/* ── Editor Grid ── */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  background: var(--surface);
  min-height: 500px;
  box-shadow: var(--shadow);
}

.editor-pane {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
}

.preview-pane {
  display: flex; flex-direction: column;
}

.pane-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}

.pane-title {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}

.pane-badge {
  font-size: 11px; color: var(--text-muted);
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
}

.editor-textarea {
  flex: 1;
  width: 100%;
  padding: 20px;
  background: var(--surface);
  border: none;
  outline: none;
  resize: none;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 14px; line-height: 1.8;
  color: var(--text);
  min-height: 450px;
}
.editor-textarea::placeholder { color: #9CA3AF; }

.preview-content {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  min-height: 450px;
  line-height: 1.8;
  color: var(--text);
}

/* ══════════════════════════════════════════
   Preview Markdown Styles
   ══════════════════════════════════════════ */
.preview-content h1 {
  font-size: 28px; font-weight: 700;
  margin: 24px 0 16px; padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  color: var(--text);
  line-height: 1.3;
}
.preview-content h2 {
  font-size: 22px; font-weight: 700;
  margin: 22px 0 14px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  line-height: 1.3;
}
.preview-content h3 {
  font-size: 18px; font-weight: 700;
  margin: 18px 0 12px;
  color: var(--text);
}
.preview-content h4, .preview-content h5, .preview-content h6 {
  font-size: 16px; font-weight: 600;
  margin: 16px 0 10px;
  color: var(--text);
}

.preview-content p { margin: 0 0 14px; }
.preview-content p:last-child { margin-bottom: 0; }

.preview-content strong, .preview-content b { font-weight: 700; color: var(--text); }
.preview-content em, .preview-content i { font-style: italic; }
.preview-content del, .preview-content s { text-decoration: line-through; color: var(--text-muted); }

.preview-content a {
  color: var(--primary); text-decoration: underline;
  text-underline-offset: 2px;
}
.preview-content a:hover { color: var(--primary-hover); }

.preview-content img {
  max-width: 100%; height: auto;
  border-radius: var(--radius);
  margin: 8px 0;
}

.preview-content blockquote {
  margin: 14px 0; padding: 12px 18px;
  border-left: 4px solid var(--primary);
  background: var(--primary-light);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
}
.preview-content blockquote p { margin: 0; }

.preview-content ul, .preview-content ol {
  margin: 10px 0; padding-left: 28px;
}
.preview-content li { margin: 4px 0; }

.preview-content pre {
  margin: 14px 0; padding: 16px 18px;
  background: #1e1e1e; border-radius: var(--radius);
  overflow-x: auto;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 13px; line-height: 1.6;
  color: #d4d4d4;
}
.preview-content code {
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 13px;
}
.preview-content :not(pre) > code {
  background: var(--bg-alt);
  padding: 2px 6px; border-radius: 4px;
  color: #DB2777;
  font-size: 12px;
}

.preview-content table {
  width: 100%; margin: 14px 0;
  border-collapse: collapse;
  font-size: 14px;
}
.preview-content th, .preview-content td {
  padding: 10px 14px;
  border: 1px solid var(--border);
  text-align: left;
}
.preview-content th {
  background: var(--bg-alt);
  font-weight: 600;
  color: var(--text);
}
.preview-content tr:nth-child(even) { background: var(--bg-alt); }

.preview-content hr {
  margin: 20px 0;
  border: none;
  height: 1px;
  background: var(--border);
}

.preview-content input[type="checkbox"] {
  margin-right: 6px;
  accent-color: var(--primary);
}

/* ── Footer ── */
.footer {
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center; font-size: 13px; color: var(--text-muted);
}
.footer-sep { margin: 0 8px; color: var(--border-strong); }

/* ══════════════════════════════════════════
   Custom scrollbar
   ══════════════════════════════════════════ */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #A5B4FC; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4F46E5; }

::selection { background: rgba(79, 70, 229, 0.2); color: #1E293B; }

/* ══════════════════════════════════════════
   Guide Section (accordion)
   ══════════════════════════════════════════ */
.guide-section {
  margin-top: 16px;
  margin-bottom: 64px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.guide-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.guide-toggle:hover {
  background: var(--bg-alt);
}
.guide-toggle-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
}
.guide-toggle.open .toggle-arrow {
  transform: rotate(180deg);
}
.toggle-arrow {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}
.guide-list {
  padding: 0 20px 20px;
}
.guide-list.hidden {
  display: none;
}
.guide-item {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.guide-item:first-child {
  border-top: 1px solid var(--border);
}
.guide-item-title {
  font-size: 14px;
  font-weight: 600;
  color: #1E293B;
  margin-bottom: 6px;
}
.guide-item-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}
.guide-item-body kbd {
  padding: 1px 6px;
  background: var(--bg-alt);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

/* ══════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  .page { padding: 0 16px; }

  .editor-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .editor-pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: 300px;
  }

  .editor-textarea { min-height: 260px; }
  .preview-content { min-height: auto; }

  .toolbar { overflow-x: auto; }
}
