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

:root {
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --heading: #0f172a;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --code-bg: #f8fafc;
  --accent: #3b82f6;
  --accent-light: #dbeafe;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.08);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ── */
.doc-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.doc-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}

.doc-header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.doc-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--heading);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s ease;
  cursor: pointer;
  border: none;
}

.btn-ghost {
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--border-light);
  color: var(--text);
}

/* ── Document Container ── */
.doc-container {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 32px auto;
  padding: 0 32px;
}

.doc-content {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 56px 64px;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* ── Typography ── */
.doc-content h1 {
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.25;
  margin-bottom: 8px;
  letter-spacing: -0.03em;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.doc-content h2 {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--heading);
  margin-top: 48px;
  margin-bottom: 16px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.doc-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--heading);
  margin-top: 36px;
  margin-bottom: 12px;
  line-height: 1.35;
}

.doc-content h4 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--heading);
  margin-top: 28px;
  margin-bottom: 8px;
}

.doc-content h5, .doc-content h6 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 24px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-content p {
  margin-bottom: 16px;
  color: var(--text);
}

.doc-content strong {
  font-weight: 600;
  color: var(--heading);
}

/* ── Links ── */
.doc-content a {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}
.doc-content a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Heading anchor links — headerLink wraps the entire heading text */
.doc-content h1 > .header-anchor,
.doc-content h2 > .header-anchor,
.doc-content h3 > .header-anchor,
.doc-content h4 > .header-anchor,
.doc-content h5 > .header-anchor,
.doc-content h6 > .header-anchor {
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
}
.doc-content h1 > .header-anchor:hover,
.doc-content h2 > .header-anchor:hover,
.doc-content h3 > .header-anchor:hover,
.doc-content h4 > .header-anchor:hover {
  text-decoration: none;
  color: inherit;
}

/* ── Lists ── */
.doc-content ul, .doc-content ol {
  margin-bottom: 16px;
  padding-left: 28px;
}

.doc-content li {
  margin-bottom: 6px;
  line-height: 1.7;
}

.doc-content li > ul, .doc-content li > ol {
  margin-top: 6px;
  margin-bottom: 6px;
}

/* Task lists */
.doc-content .task-list-item {
  list-style: none;
  margin-left: -28px;
  padding-left: 0;
}

.doc-content .task-list-item input[type="checkbox"] {
  margin-right: 8px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

/* ── Blockquotes ── */
.doc-content blockquote {
  margin: 20px 0;
  padding: 16px 24px;
  border-left: 4px solid var(--accent);
  background: var(--accent-light);
  border-radius: 0 8px 8px 0;
  color: var(--text);
}

.doc-content blockquote p:last-child {
  margin-bottom: 0;
}

/* ── Code ── */
.doc-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: #e11d48;
}

.doc-content pre {
  margin: 20px 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.doc-content pre.hljs {
  background: #0d1117;
  padding: 20px 24px;
  overflow-x: auto;
  line-height: 1.55;
}

.doc-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e6edf3;
  font-size: 0.85rem;
}

/* ── Tables ── */
.doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.92rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.doc-content thead {
  background: var(--border-light);
}

.doc-content th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--heading);
  border-bottom: 2px solid var(--border);
}

.doc-content td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
}

.doc-content tbody tr:last-child td {
  border-bottom: none;
}

.doc-content tbody tr:hover {
  background: var(--border-light);
}

/* ── Horizontal Rule ── */
.doc-content hr {
  border: none;
  height: 2px;
  background: var(--border);
  margin: 36px 0;
  border-radius: 1px;
}

/* ── Images ── */
.doc-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 16px 0;
  box-shadow: var(--shadow);
}

/* ── Table of Contents (generated by [[toc]]) ── */
.doc-content .table-of-contents {
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 32px;
  margin: 24px 0 36px;
}

.doc-content .table-of-contents h2 {
  font-size: 1.15rem;
  margin-top: 0;
  margin-bottom: 12px;
  padding-bottom: 0;
  border-bottom: none;
}

.doc-content .table-of-contents ul {
  margin-bottom: 0;
}

.doc-content .table-of-contents li {
  margin-bottom: 4px;
}

.doc-content .table-of-contents a {
  color: var(--link);
  font-weight: 400;
}

/* ── Footer ── */
.doc-footer {
  text-align: center;
  padding: 24px 32px 40px;
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .doc-content {
    padding: 32px 28px;
    border-radius: 0;
    box-shadow: none;
  }

  .doc-container {
    padding: 0;
    margin: 0 auto;
  }

  .doc-content h1 { font-size: 1.6rem; }
  .doc-content h2 { font-size: 1.3rem; }
  .doc-content h3 { font-size: 1.1rem; }

  .doc-header-inner {
    padding: 12px 20px;
  }

  .doc-footer {
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .doc-content {
    padding: 24px 20px;
  }
  .doc-content h1 { font-size: 1.4rem; }
}

/* ── Print ── */
@media print {
  .doc-header, .doc-footer, .doc-actions { display: none; }
  .doc-content { box-shadow: none; padding: 0; }
  body { background: white; }
}
