:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-panel: #1c2128;
  --border: #30363d;
  --border-soft: #242a31;
  --text: #e6edf3;
  --text-dim: #9198a1;
  --text-faint: #6e7681;
  --accent: #4493f8;
  --accent-soft: rgba(68, 147, 248, 0.14);
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(1, 4, 9, 0.4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #1f6feb, #8957e5);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.5px;
}

.brand h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: 0.2px; }
.tagline { margin: 0; font-size: 12px; color: var(--text-faint); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; flex: 1 1 auto; min-width: 0; }

.field { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.field > span { flex: 0 0 auto; white-space: nowrap; }
.field.grow { flex: 1 1 200px; min-width: 150px; }

.field input,
.field select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input { width: 100%; min-width: 0; }
.field input:focus,
.field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn:hover { background: #21262d; border-color: #484f58; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #238636; border-color: #2ea043; white-space: nowrap; }
.btn-group { display: flex; gap: 8px; flex: 0 0 auto; }
.btn-primary:hover { background: #2ea043; }

/* ---------------- 状态条 ---------------- */

.status-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--border-soft);
  border-bottom: 1px solid var(--border);
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 28px;
  background: var(--bg-soft);
}

.status-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-faint); }
.status-value { font-size: 13px; font-variant-numeric: tabular-nums; }
.status-value.ok { color: var(--good); }
.status-value.fail { color: var(--bad); }

/* ---------------- 布局 ---------------- */

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 28px 56px;
  align-items: start;
}

.sidebar { position: sticky; top: 96px; display: flex; flex-direction: column; gap: 14px; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover { color: var(--text); border-color: #484f58; }
.chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: #a5c9ff; }

.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 320px; overflow-y: auto; }

.history button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background 0.12s, color 0.12s;
}

.history button:hover { background: var(--bg-soft); color: var(--text); }
.history button.is-active { background: var(--accent-soft); color: #a5c9ff; }

/* ---------------- 正文 ---------------- */

.content { min-width: 0; }

.message {
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  background: rgba(210, 153, 34, 0.08);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #e3b341;
}

.message.error { border-left-color: var(--bad); background: rgba(248, 81, 73, 0.08); color: #ff7b72; }

.daily-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 12px;
  color: var(--text-faint);
}

.daily-meta .pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--bg-panel);
}

.markdown-body {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 34px 36px;
  box-shadow: var(--shadow);
}

.markdown-body h1 {
  font-size: 26px;
  margin: 0 0 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.3px;
}

.markdown-body h2 {
  font-size: 18px;
  margin: 36px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.markdown-body h3 {
  font-size: 15px;
  margin: 26px 0 12px;
  color: #a5c9ff;
  letter-spacing: 0.5px;
}

.markdown-body blockquote {
  margin: 0 0 20px;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 0 8px 8px 0;
  color: var(--text-dim);
  font-size: 13.5px;
}

.markdown-body blockquote p { margin: 0; }

.markdown-body ol { margin: 0; padding-left: 0; list-style: none; counter-reset: item; }

.markdown-body ol > li {
  counter-increment: item;
  position: relative;
  padding: 14px 18px 14px 52px;
  margin-bottom: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  transition: border-color 0.15s, transform 0.15s;
}

.markdown-body ol > li:hover { border-color: #3d444d; }
.markdown-body ol > li::before {
  content: counter(item);
  position: absolute;
  left: 16px;
  top: 15px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #a5c9ff;
  font-size: 12px;
  font-weight: 600;
}

.markdown-body ol > li > strong { font-size: 15.5px; font-weight: 620; display: block; margin-bottom: 4px; }

.markdown-body ol > li small,
.markdown-body ol > li > small { display: block; color: var(--text-faint); font-size: 12px; font-style: italic; margin-bottom: 8px; }

.markdown-body ul { margin: 6px 0 0; padding-left: 18px; }
.markdown-body ol > li ul { list-style: none; padding-left: 0; }
.markdown-body ol > li ul > li { font-size: 13.5px; color: var(--text-dim); margin-bottom: 3px; }
.markdown-body ol > li ul > li strong { color: var(--text); font-weight: 550; }

.markdown-body a { color: var(--accent); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }

.markdown-body .score { color: var(--good); font-weight: 600; font-variant-numeric: tabular-nums; }
.markdown-body .score.high { color: #56d364; }
.markdown-body .score.mid { color: var(--warn); }
.markdown-body .score.low { color: var(--text-dim); }

.markdown-body p { margin: 0 0 12px; }

.markdown-body .placeholder { color: var(--text-faint); text-align: center; padding: 40px 0; }

/* 失败源提示 */
.markdown-body h2 + ul { font-size: 13.5px; color: var(--text-dim); }

.footer {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px 40px;
  color: var(--text-faint);
  font-size: 12px;
}

.hidden-item { display: none !important; }

mark.search-hit { background: rgba(210, 153, 34, 0.35); color: #ffd98a; border-radius: 3px; padding: 0 2px; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 18px 16px 40px; }
  .sidebar { position: static; }
  .topbar { padding: 12px 16px; }
  .status-item { padding: 10px 16px; }
  .markdown-body { padding: 20px 18px 26px; }
  .markdown-body ol > li { padding: 12px 14px 12px 46px; }
  .footer { padding: 0 16px 30px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}