/* Document content styles */
.doc {
  flex: 1;
  min-width: 0;
  order: 1;
  padding: 40px 48px 100px 56px;
  background: transparent;
  min-height: calc(100vh - var(--header-height));
}

/* ===== Doc header ===== */
.doc-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
}

.doc-header .breadcrumb {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-bottom: 12px;
}
.doc-header .breadcrumb a {
  color: var(--text-tertiary);
  text-decoration: none;
}
.doc-header .breadcrumb a:hover { color: var(--accent); }

.doc-header h1 {
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -.02em;
  margin-bottom: 8px;
}

.doc-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: 12px;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.difficulty {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 3px;
}
.difficulty.easy   { color: var(--easy);   background: var(--success-bg); }
.difficulty.medium { color: var(--medium); background: var(--warning-bg); }
.difficulty.hard   { color: var(--hard);   background: var(--danger-bg); }

.doc-tag {
  font-size: var(--text-xs);
  padding: 2px 8px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border-radius: 3px;
}

/* ===== Sections ===== */
.doc-section {
  margin-bottom: 40px;
  scroll-margin-top: calc(var(--header-height) + 16px);
}

.doc-section > h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  letter-spacing: -.01em;
}

.doc-section h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 28px 0 10px;
  color: var(--text-primary);
}

.doc-section h4 {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--text-primary);
}

.doc-section p { margin: 10px 0; }
.doc-section ul,
.doc-section ol {
  padding-left: 24px;
  margin: 10px 0;
}
.doc-section li { margin: 4px 0; }
.doc-section li::marker { color: var(--text-tertiary); }

.doc-section strong {
  font-weight: 600;
  color: var(--text-primary);
}

.doc-section code.inline {
  font-family: var(--font-mono);
  font-size: .9em;
  padding: 1px 5px;
  background: var(--bg-subtle);
  color: var(--text-code);
  border-radius: 3px;
}

/* ===== Formula block ===== */
.formula {
  margin: 16px 0;
  padding: 14px 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--text-primary);
  letter-spacing: .02em;
}

/* ===== Doc footer nav ===== */
.doc-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-light);
}
.doc-nav a {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color .15s;
}
.doc-nav a:hover { border-color: var(--accent); }
.doc-nav .label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-bottom: 4px;
}
.doc-nav .title {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 500;
}
.doc-nav .next { text-align: right; }

.doc-footer {
  margin-top: 32px;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* ---- LeetCode 原题链接 ---- */
.lc-link-row { margin: 4px 0 8px; }
.lc-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent-bg);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.lc-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.lc-link-icon { flex-shrink: 0; }

/* ---- 阅读更多 · 公众号解锁门 ---- */
.rm-body.rm-clip {
  position: relative;
  overflow: hidden;
}
.rm-body.rm-clip::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 220px;
  background: linear-gradient(to bottom, rgba(255,255,255,0), var(--bg-doc) 88%);
  pointer-events: none;
}
.rm-gate {
  margin: 8px 0 40px;
  text-align: center;
}
.rm-gate-tip {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-bottom: 10px;
}
.rm-btn {
  display: inline-block;
  padding: 10px 32px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
  box-shadow: 0 2px 8px rgba(51,112,255,.18);
}
.rm-btn:hover { background: var(--accent-hover); }
.rm-gate-sub {
  margin-top: 10px;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
/* 弹窗 */
.rm-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 24, 31, .55);
  padding: 20px;
}
.rm-modal.show { display: flex; }
body.rm-locked { overflow: hidden; }
.rm-modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 92vh;
  overflow: auto;
  background: var(--bg-doc);
  border-radius: 14px;
  padding: 26px 26px 22px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.rm-modal-close {
  position: absolute;
  top: 10px; right: 14px;
  border: 0; background: none;
  font-size: 24px; line-height: 1;
  color: var(--text-tertiary);
  cursor: pointer;
}
.rm-modal-title { font-size: 19px; margin: 0 0 4px; color: var(--text-primary); }
.rm-modal-sub { font-size: var(--text-xs); color: var(--text-tertiary); margin: 0 0 18px; }
.rm-modal-body { display: flex; gap: 18px; align-items: center; text-align: left; }
.rm-qr {
  flex: 0 0 128px;
  width: 128px; height: 128px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.rm-qr img { width: 100%; height: 100%; object-fit: contain; display: block; }
.rm-steps { margin: 0; padding-left: 18px; font-size: var(--text-sm); color: var(--text-secondary); line-height: 1.9; }
.rm-input-row { display: flex; gap: 8px; margin-top: 18px; }
.rm-input {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--text-sm);
  outline: none;
  background: #fff;
  color: var(--text-primary);
}
.rm-input:focus { border-color: var(--accent); }
.rm-submit {
  padding: 9px 20px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.rm-submit:disabled { opacity: .6; cursor: default; }
.rm-err { min-height: 18px; margin: 8px 0 0; font-size: var(--text-xs); color: #e54545; }
.rm-tip { margin: 10px 0 0; font-size: 11px; color: var(--text-tertiary); }
@media (max-width: 520px) {
  .rm-modal-body { flex-direction: column; text-align: center; }
  .rm-steps { padding-left: 0; }
}
