:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --ok: #15803d;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sidebar-w: 236px;
  --topbar-h: 55px;
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶部栏（在线检查页） ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 24px;
}

.topbar .brand {
  padding: 0;
  margin: 0;
  border-bottom: none;
}

.topnav {
  display: flex;
  gap: 4px;
}

.topnav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.topnav a:hover {
  background: #f3f4f6;
  color: var(--text);
}

.topnav a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.page {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 72px;
}

.page .online-checker {
  margin-bottom: 0;
}

/* ---------- 侧边栏（文档页） ---------- */
.container {
  display: flex;
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  align-self: flex-start;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 14px 20px;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.sidebar-title {
  padding: 0 10px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--text);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.brand-text span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar a {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar a:hover {
  background: #f3f4f6;
  color: var(--text);
}

.sidebar a.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.sidebar .sub-item {
  padding: 6px 10px 6px 24px;
  font-size: 12.5px;
  color: var(--muted);
}

.sidebar-foot {
  margin-top: auto;
  padding: 16px 10px 2px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.sidebar-foot span {
  display: block;
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
}

/* ---------- 内容区 ---------- */
.content {
  flex: 1;
  min-width: 0;
  padding: 32px 28px 88px;
}

.content > * {
  width: 100%;
  max-width: 920px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- 在线检查器 ---------- */
.online-checker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.checker-head {
  margin-bottom: 18px;
}

.checker-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.checker-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

.mode-switcher {
  display: flex;
  gap: 4px;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 20px;
  max-width: 460px;
}

.mode-btn {
  flex: 1;
  padding: 7px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08);
}

.checker-layout {
  display: flex;
  gap: 20px;
  align-items: stretch;
}

.input-section,
.result-section {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--surface);
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.check-mode-content label {
  display: block;
  margin: 14px 0 6px;
  font-size: 12.5px;
  color: var(--text-2);
}

.check-mode-content label:first-child {
  margin-top: 0;
}

.check-mode-content input,
.check-mode-content textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  resize: vertical;
}

.check-mode-content input::placeholder,
.check-mode-content textarea::placeholder {
  color: #9ca3af;
}

.check-mode-content input:focus,
.check-mode-content textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.check-btn {
  width: 100%;
  margin-top: 16px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.check-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

.check-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.check-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

.image-upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  background: #fafafa;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.image-upload-area:hover,
.image-upload-area.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-icon {
  color: var(--muted);
  margin-bottom: 2px;
}

.upload-text {
  font-size: 13px;
  color: var(--text-2);
}

.upload-hint {
  font-size: 12px;
  color: var(--muted);
}

.image-preview {
  max-width: 100%;
  max-height: 180px;
  border-radius: 6px;
  margin-top: 10px;
  border: 1px solid var(--border);
}

#image-file-input {
  display: none;
}

.check-mode-content {
  display: none;
}

.check-mode-content.active {
  display: block;
}

.result-content {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin: 0;
  min-height: 280px;
  max-height: 400px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-2);
  white-space: pre-wrap;
  word-wrap: break-word;
  text-align: center;
  box-shadow: none;
}

.form-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.empty-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 240px;
  color: var(--muted);
  font-family: var(--font-body);
}

.empty-text {
  font-size: 13px;
}

.loading {
  text-align: center;
  padding: 18px;
  font-size: 13px;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- 文档 ---------- */
.doc-head {
  margin: 4px 0 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

h1 {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.lede {
  margin-top: 8px;
  max-width: 65ch;
  font-size: 13.5px;
  color: var(--muted);
}

.content > h2 {
  margin-top: 44px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

.content > h3 {
  margin: 24px 0 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

p {
  margin: 10px 0;
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-2);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

table {
  width: 100%;
  margin: 14px 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  background: var(--surface);
  font-size: 13px;
}

th,
td {
  padding: 9px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: #f9fafb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: #fafbfc;
}

td {
  color: var(--text-2);
}

code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #f3f4f6;
  color: #1f2937;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

pre {
  margin: 10px 0 16px;
  padding: 14px 16px;
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: #24292f;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-x: auto;
  box-shadow: none;
}

.example {
  margin: 12px 0 20px;
  padding: 14px 16px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.example > code {
  background: transparent;
  padding: 0;
  font-weight: 500;
  color: var(--text-2);
}

.example pre {
  margin-bottom: 0;
  background: var(--surface);
}

.example pre + pre {
  margin-top: 10px;
}

.note {
  padding: 10px 12px;
  border-left: 3px solid var(--border-strong);
  background: #fafafa;
  color: var(--muted);
  font-size: 12.5px;
  border-radius: 0 6px 6px 0;
}

.note a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  :root { --sidebar-w: 204px; }
  .content { padding: 28px 20px 72px; }
}

@media (max-width: 820px) {
  .container { flex-direction: column; }

  .sidebar {
    position: sticky;
    top: var(--topbar-h);
    width: 100%;
    height: auto;
    padding: 10px 14px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    align-items: center;
    gap: 12px;
    overflow: visible;
  }

  .sidebar-title { display: none; }

  .brand-text span { display: none; }

  .nav {
    flex-direction: row;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    flex: 1;
  }

  .nav::-webkit-scrollbar { display: none; }

  .sidebar a {
    white-space: nowrap;
    padding: 6px 10px;
    font-size: 12.5px;
  }

  .sidebar .sub-item,
  .sidebar-foot { display: none; }

  .content {
    flex: none;
    width: 100%;
    padding: 22px 16px 64px;
  }

  .online-checker { padding: 20px; }
  .checker-layout { flex-direction: column; gap: 16px; }
  .result-content { min-height: 200px; max-height: 300px; }

  .page { padding: 20px 16px 56px; }
  .topbar-inner { padding: 10px 16px; }
}

@media (max-width: 560px) {
  .mode-switcher { max-width: none; }
  .mode-btn { padding: 7px 6px; font-size: 12.5px; }
  h1 { font-size: 22px; }
  .content > h2 { font-size: 17px; margin-top: 36px; }
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  pre { font-size: 12px; padding: 12px; }
  .topnav a { padding: 6px 8px; font-size: 12.5px; }
}
