:root {
  color-scheme: light;
  --page-bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --surface-3: #eef2f7;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --link: #0d6efd;
  --link-hover: #0b5ed7;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --code-inline-bg: rgba(15, 23, 42, 0.08);
  --code-inline-text: #0d6efd;
  --hero-start: #0d6efd;
  --hero-end: #6f42c1;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page-bg: #0b0f19;
    --surface: #111827;
    --surface-2: #151e2f;
    --surface-3: #0f172a;
    --text: #e5e7eb;
    --text-muted: #9aa4b2;
    --border: #263041;
    --border-strong: #334155;
    --link: #8ab4ff;
    --link-hover: #b3d1ff;
    --code-bg: #0b1220;
    --code-text: #e2e8f0;
    --code-inline-bg: rgba(148, 163, 184, 0.15);
    --code-inline-text: #c7d2fe;
    --hero-start: #1d4ed8;
    --hero-end: #0f172a;
  }
}

html[data-theme="light"] {
  color-scheme: light;
  --page-bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --surface-3: #eef2f7;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --link: #0d6efd;
  --link-hover: #0b5ed7;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --code-inline-bg: rgba(15, 23, 42, 0.08);
  --code-inline-text: #0d6efd;
  --hero-start: #0d6efd;
  --hero-end: #6f42c1;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0b0f19;
  --surface: #111827;
  --surface-2: #151e2f;
  --surface-3: #0f172a;
  --text: #e5e7eb;
  --text-muted: #9aa4b2;
  --border: #263041;
  --border-strong: #334155;
  --link: #8ab4ff;
  --link-hover: #b3d1ff;
  --code-bg: #0b1220;
  --code-text: #e2e8f0;
  --code-inline-bg: rgba(148, 163, 184, 0.15);
  --code-inline-text: #c7d2fe;
  --hero-start: #1d4ed8;
  --hero-end: #0f172a;
}

html,
body {
  height: 100%;
}

body {
  background-color: var(--page-bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

.page-main {
  flex: 1;
}

.hero {
  background: linear-gradient(135deg, var(--hero-start), var(--hero-end));
  border-bottom-left-radius: 28px;
  border-bottom-right-radius: 28px;
}

.article-hero {
  background: linear-gradient(135deg, #343a40, #0d6efd);
  color: #fff;
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
}

.post-content {
  line-height: 1.8;
}

.post-content {
  line-height: 1.8;
  overflow-wrap: break-word;
}

/* =========================
   富文本图片（兼容 30 / 50 / 100）
   ========================= */
.post-content img,
.post-content picture,
.post-content figure img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 12px auto;
    object-fit: contain;
}

/* 👇 核心规则：尊重编辑器声明的 width */
.post-content img[style*="width"] {
    width: auto;
}

.post-content figure {
  max-width: 100%;
  margin: 0 auto 16px;
}

.img-lightbox {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
}
.img-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.img-lightbox img {
  position: relative;
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.qr {
  width: 120px;
  height: 120px;
  object-fit: contain;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 6px;
}

.hover-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

.bg-soft-primary {
  background-color: rgba(13, 110, 253, 0.12);
}

.btn-success-soft {
  background-color: rgba(25, 135, 84, 0.12);
  color: #198754;
  border: 1px solid rgba(25, 135, 84, 0.3);
}

.btn-danger-soft {
  background-color: rgba(220, 53, 69, 0.12);
  color: #dc3545;
  border: 1px solid rgba(220, 53, 69, 0.3);
}

.post-content pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 14px;
  border-radius: 10px;
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.95rem;
  border: 1px solid var(--border);
}

.post-content code {
  background: var(--code-inline-bg);
  color: var(--code-inline-text);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.95rem;
}

.post-content pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light {
  background-color: var(--surface) !important;
}

html[data-theme="dark"] .text-muted {
  color: var(--text-muted) !important;
}

html[data-theme="dark"] .text-secondary {
  color: var(--text-muted) !important;
}

html[data-theme="dark"] .text-dark {
  color: var(--text) !important;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .table-card,
html[data-theme="dark"] .kb-card,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .compare-card,
html[data-theme="dark"] .download-card {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .table {
  color: var(--text);
}

html[data-theme="dark"] .table th,
html[data-theme="dark"] .table td {
  color: var(--text) !important;
}

html[data-theme="dark"] .table > :not(caption) > * > * {
  background-color: var(--surface);
  border-color: var(--border);
}

html[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: var(--surface-2);
}

html[data-theme="dark"] .table-hover > tbody > tr:hover > * {
  background-color: #1f2a3b;
}

html[data-theme="dark"] .table-light,
html[data-theme="dark"] .table thead,
html[data-theme="dark"] thead.table-light {
  background-color: var(--surface-2) !important;
  color: var(--text);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select {
  background-color: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .form-control::placeholder {
  color: var(--text-muted);
}

html[data-theme="dark"] .form-control::-webkit-input-placeholder {
  color: var(--text-muted);
}

html[data-theme="dark"] .form-control::-moz-placeholder {
  color: var(--text-muted);
  opacity: 1;
}

html[data-theme="dark"] .form-control:-ms-input-placeholder {
  color: var(--text-muted);
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus {
  background-color: var(--surface-2);
  color: var(--text);
  border-color: #3b82f6;
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.2);
}

html[data-theme="dark"] .input-group-text {
  background-color: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .page-link {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .page-item.disabled .page-link {
  background-color: var(--surface-2);
  color: var(--text-muted);
}

html[data-theme="dark"] .page-item.active .page-link {
  background-color: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}

html[data-theme="dark"] .border,
html[data-theme="dark"] .border-top,
html[data-theme="dark"] .border-end,
html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-start {
  border-color: var(--border) !important;
}

html[data-theme="dark"] .badge.bg-light,
html[data-theme="dark"] .badge.text-bg-light {
  background-color: var(--surface-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

html[data-theme="dark"] .alert {
  background-color: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .alert-info {
  background-color: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: #d7f3ff;
}

html[data-theme="dark"] .alert-warning {
  background-color: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fde68a;
}

html[data-theme="dark"] .alert-secondary {
  background-color: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.35);
  color: #e2e8f0;
}

html[data-theme="dark"] .editor-content,
html[data-theme="dark"] .post-content,
html[data-theme="dark"] .kb-content,
html[data-theme="dark"] .sidebar-html {
  color: var(--text);
  background-color: transparent;
}

html[data-theme="light"] .editor-content [style*="color:#fff"],
html[data-theme="light"] .editor-content [style*="color: #fff"],
html[data-theme="light"] .editor-content [style*="color:#ffffff"],
html[data-theme="light"] .editor-content [style*="color: #ffffff"],
html[data-theme="light"] .editor-content [style*="color:white"],
html[data-theme="light"] .editor-content [style*="color: white"],
html[data-theme="light"] .editor-content [style*="color:rgb(255,255,255)"],
html[data-theme="light"] .editor-content [style*="color: rgb(255, 255, 255)"],
html[data-theme="light"] .sidebar-html [style*="color:#fff"],
html[data-theme="light"] .sidebar-html [style*="color: #fff"],
html[data-theme="light"] .sidebar-html [style*="color:#ffffff"],
html[data-theme="light"] .sidebar-html [style*="color: #ffffff"],
html[data-theme="light"] .sidebar-html [style*="color:white"],
html[data-theme="light"] .sidebar-html [style*="color: white"],
html[data-theme="light"] .sidebar-html [style*="color:rgb(255,255,255)"],
html[data-theme="light"] .sidebar-html [style*="color: rgb(255, 255, 255)"] {
  color: var(--text) !important;
}

html[data-theme="dark"] .editor-content [style*="color:#000"],
html[data-theme="dark"] .editor-content [style*="color: #000"],
html[data-theme="dark"] .editor-content [style*="color:#000000"],
html[data-theme="dark"] .editor-content [style*="color: #000000"],
html[data-theme="dark"] .editor-content [style*="color:black"],
html[data-theme="dark"] .editor-content [style*="color: black"],
html[data-theme="dark"] .editor-content [style*="color:rgb(0,0,0)"],
html[data-theme="dark"] .editor-content [style*="color: rgb(0, 0, 0)"],
html[data-theme="dark"] .sidebar-html [style*="color:#000"],
html[data-theme="dark"] .sidebar-html [style*="color: #000"],
html[data-theme="dark"] .sidebar-html [style*="color:#000000"],
html[data-theme="dark"] .sidebar-html [style*="color: #000000"],
html[data-theme="dark"] .sidebar-html [style*="color:black"],
html[data-theme="dark"] .sidebar-html [style*="color: black"],
html[data-theme="dark"] .sidebar-html [style*="color:rgb(0,0,0)"],
html[data-theme="dark"] .sidebar-html [style*="color: rgb(0, 0, 0)"] {
  color: var(--text) !important;
}

html[data-theme="dark"] .editor-content table,
html[data-theme="dark"] .editor-content th,
html[data-theme="dark"] .editor-content td,
html[data-theme="dark"] .kb-content table,
html[data-theme="dark"] .kb-content th,
html[data-theme="dark"] .kb-content td {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

html[data-theme="dark"] .editor-content [style*="background:#fff"],
html[data-theme="dark"] .editor-content [style*="background: #fff"],
html[data-theme="dark"] .editor-content [style*="background:#ffffff"],
html[data-theme="dark"] .editor-content [style*="background: #ffffff"],
html[data-theme="dark"] .editor-content [style*="background-color:#fff"],
html[data-theme="dark"] .editor-content [style*="background-color: #fff"],
html[data-theme="dark"] .editor-content [style*="background-color:#ffffff"],
html[data-theme="dark"] .editor-content [style*="background-color: #ffffff"],
html[data-theme="dark"] .kb-content [style*="background:#fff"],
html[data-theme="dark"] .kb-content [style*="background: #fff"],
html[data-theme="dark"] .kb-content [style*="background:#ffffff"],
html[data-theme="dark"] .kb-content [style*="background: #ffffff"],
html[data-theme="dark"] .kb-content [style*="background-color:#fff"],
html[data-theme="dark"] .kb-content [style*="background-color: #fff"],
html[data-theme="dark"] .kb-content [style*="background-color:#ffffff"],
html[data-theme="dark"] .kb-content [style*="background-color: #ffffff"],
html[data-theme="dark"] .editor-content [style*="background: white"],
html[data-theme="dark"] .editor-content [style*="background-color: white"],
html[data-theme="dark"] .editor-content [style*="background: rgb(255, 255, 255)"],
html[data-theme="dark"] .editor-content [style*="background-color: rgb(255, 255, 255)"],
html[data-theme="dark"] .kb-content [style*="background: white"],
html[data-theme="dark"] .kb-content [style*="background-color: white"],
html[data-theme="dark"] .kb-content [style*="background: rgb(255, 255, 255)"],
html[data-theme="dark"] .kb-content [style*="background-color: rgb(255, 255, 255)"],
html[data-theme="dark"] .sidebar-html [style*="background:#fff"],
html[data-theme="dark"] .sidebar-html [style*="background: #fff"],
html[data-theme="dark"] .sidebar-html [style*="background:#ffffff"],
html[data-theme="dark"] .sidebar-html [style*="background: #ffffff"],
html[data-theme="dark"] .sidebar-html [style*="background-color:#fff"],
html[data-theme="dark"] .sidebar-html [style*="background-color: #fff"],
html[data-theme="dark"] .sidebar-html [style*="background-color:#ffffff"],
html[data-theme="dark"] .sidebar-html [style*="background-color: #ffffff"],
html[data-theme="dark"] .sidebar-html [style*="background: white"],
html[data-theme="dark"] .sidebar-html [style*="background-color: white"],
html[data-theme="dark"] .sidebar-html [style*="background: rgb(255, 255, 255)"],
html[data-theme="dark"] .sidebar-html [style*="background-color: rgb(255, 255, 255)"] {
  background-color: transparent !important;
}
