:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d2733;
  --text-soft: #5a6672;
  --muted: #8b97a3;
  --line: #e6e9ee;
  --brand: #d64545;      /* 日本红 */
  --brand-soft: #fdecec;
  --accent: #2b6cb0;
  --warn-bg: #fff7ed;
  --warn-line: #f6c177;
  --radius: 14px;
  --sidebar-w: 268px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a;
    --surface: #161c24;
    --text: #e8edf3;
    --text-soft: #aeb9c5;
    --muted: #7b8794;
    --line: #26303b;
    --brand: #ff6b6b;
    --brand-soft: #2a1a1c;
    --accent: #7fb2e6;
    --warn-bg: #2a2015;
    --warn-line: #6b5327;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- 布局 ---------- */
.layout { display: flex; }

/* ---------- 移动端顶栏 ---------- */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 40;
  align-items: center; gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-weight: 700; }
.menu-btn {
  display: inline-flex; flex-direction: column; gap: 4px;
  background: none; border: 0; padding: 6px; cursor: pointer;
}
.menu-btn span { width: 22px; height: 2px; background: var(--text); border-radius: 2px; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: sticky; top: 0;
  width: var(--sidebar-w); flex-shrink: 0;
  height: 100vh; overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px;
  background: var(--brand-soft);
}
.brand-text strong { display: block; font-size: 15px; }
.brand-text small { color: var(--muted); font-size: 11px; letter-spacing: .5px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group {
  margin: 16px 8px 6px; font-size: 11px; font-weight: 700;
  letter-spacing: 1px; color: var(--muted); text-transform: uppercase;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 9px;
  color: var(--text-soft); font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-num {
  font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--muted); min-width: 18px;
}
.nav-link.active .nav-num { color: var(--brand); }

.sidebar-foot { padding: 14px 10px 4px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 12px; }

.scrim {
  display: none; position: fixed; inset: 0; z-index: 30;
  background: rgba(10,15,20,.45); opacity: 0; pointer-events: none;
  transition: opacity .2s;
}

/* ---------- 主内容 ---------- */
.content {
  flex: 1; min-width: 0;
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 40px 80px;
}

/* Hero */
.hero { margin-bottom: 44px; }
.eyebrow {
  color: var(--brand); font-weight: 700; font-size: 13px;
  letter-spacing: 1px; margin: 0 0 10px;
}
.hero h1 { font-size: 42px; line-height: 1.15; margin: 0 0 16px; letter-spacing: -.5px; }
.lead { font-size: 18px; color: var(--text-soft); max-width: 640px; margin: 0 0 26px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 20px; border-radius: 10px; font-weight: 600; font-size: 15px;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow); }
.btn-primary:hover { background: #c23b3b; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

/* timeline */
.timeline {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-top: 34px;
}
.tl-item {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px;
}
.tl-dot {
  display: inline-block; font-size: 12px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); padding: 3px 10px; border-radius: 20px; margin-bottom: 8px;
}
.tl-item p { margin: 0; font-size: 14px; color: var(--text-soft); }

/* 卡片总览 */
.cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
  margin-bottom: 56px;
}
.card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 18px 18px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--brand); }
.card-num {
  font-size: 12px; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.card h3 { margin: 6px 0 6px; font-size: 17px; }
.card p { margin: 0; font-size: 13.5px; color: var(--text-soft); line-height: 1.6; }

/* 文档区块 */
.doc {
  padding: 40px 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 24px;
}
.doc-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; }
.doc-num {
  font-size: 14px; font-weight: 800; color: #fff; background: var(--brand);
  padding: 3px 10px; border-radius: 8px; font-variant-numeric: tabular-nums;
}
.doc h2 { font-size: 27px; margin: 0; letter-spacing: -.3px; }
.doc h3 { font-size: 17px; margin: 26px 0 10px; }
.doc h4 { font-size: 15px; margin: 18px 0 8px; color: var(--text-soft); }
.doc > p { color: var(--text-soft); font-size: 16px; }
.doc ul { padding-left: 4px; list-style: none; margin: 10px 0; }
.doc ul li {
  position: relative; padding-left: 22px; margin: 7px 0;
  color: var(--text-soft); font-size: 15.5px;
}
.doc ul li::before {
  content: "›"; position: absolute; left: 6px; top: -1px;
  color: var(--brand); font-weight: 700;
}
.doc ul.checklist li::before { content: "✓"; font-size: 13px; top: 1px; }
.doc strong { color: var(--text); font-weight: 600; }

/* callout */
.callout {
  margin: 18px 0; padding: 14px 16px 14px 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: 10px;
}
.callout strong { display: block; margin-bottom: 4px; color: var(--text); }
.callout p { margin: 0; font-size: 14.5px; color: var(--text-soft); }
.callout-warn { background: var(--warn-bg); border-left-color: var(--warn-line); border-color: var(--warn-line); }

/* footer */
.site-foot { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--muted); }
.site-foot p { margin: 4px 0; font-size: 13px; }
.foot-small { font-size: 12px; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .timeline { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .topbar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 35;
    transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.2);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim.show { display: block; opacity: 1; pointer-events: auto; }
  .content { padding: 28px 20px 64px; }
  .hero h1 { font-size: 32px; }
  .lead { font-size: 16px; }
  .cards { grid-template-columns: 1fr; }
}

/* ---------- 后台编辑入口 ---------- */
.edit-link {
  display: inline-block; margin-bottom: 8px;
  font-size: 13px; color: var(--muted);
}
.edit-link:hover { color: var(--brand); }

/* ---------- Markdown 渲染出的正文（被编辑板块 & 预览） ---------- */
.doc-body h3 { font-size: 17px; margin: 26px 0 10px; }
.doc-body h4 { font-size: 15px; margin: 18px 0 8px; color: var(--text-soft); }
.doc-body p { color: var(--text-soft); font-size: 16px; margin: 10px 0; }
.doc-body ul { padding-left: 4px; list-style: none; margin: 10px 0; }
.doc-body ul li {
  position: relative; padding-left: 22px; margin: 7px 0;
  color: var(--text-soft); font-size: 15.5px;
}
.doc-body ul li::before {
  content: "›"; position: absolute; left: 6px; top: -1px;
  color: var(--brand); font-weight: 700;
}
.doc-body strong { color: var(--text); font-weight: 600; }
.doc-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.doc-body .callout {
  margin: 18px 0; padding: 14px 16px 14px 18px;
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: 10px;
  font-size: 14.5px; color: var(--text-soft);
}
.doc-body .callout strong { display: block; margin-bottom: 4px; color: var(--text); }
.doc-body .callout-warn { background: var(--warn-bg); border-left-color: var(--warn-line); border-color: var(--warn-line); }

/* 注意 / 提示框正文：红色波浪下划线强调（前台静态框 + 后台 Markdown 框） */
.callout p,
.doc-body .callout {
  text-decoration: underline wavy var(--brand);
  text-decoration-thickness: 1.2px;
  text-underline-offset: 4px;
  text-decoration-skip-ink: none;
}
/* 标题不加波浪线，保持作为小标题的清晰 */
.callout > strong,
.doc-body .callout strong {
  text-decoration: none;
}

/* ---------- 后台编辑器 ---------- */
[hidden] { display: none !important; }
.admin { background: var(--bg); }
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 20px 24px 60px; }
.admin-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 24px;
}
.admin-brand { font-size: 15px; }
.admin-top-actions { display: flex; gap: 10px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

.admin-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow);
}
.login-card { max-width: 440px; margin: 60px auto; }
.login-card h2 { margin: 0 0 6px; font-size: 20px; }
.muted { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
.login-row { display: flex; gap: 10px; }
.login-row input { flex: 1; }
input, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 10px 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--brand); }

.form-msg { font-size: 13px; margin: 12px 0 0; min-height: 18px; }
.form-msg.err { color: var(--brand); }
.form-msg.ok { color: #2e9e6b; }

.admin-editor { display: grid; grid-template-columns: 220px 1fr; gap: 22px; }
.admin-side {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; height: fit-content;
  position: sticky; top: 20px;
}
.admin-side-title { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--muted); margin: 4px 8px 10px; text-transform: uppercase; }
.section-list { display: flex; flex-direction: column; gap: 2px; }
.section-item {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0; cursor: pointer; text-align: left;
  padding: 8px 10px; border-radius: 8px; color: var(--text-soft);
  font-family: inherit; font-size: 14px; transition: background .12s, color .12s;
}
.section-item:hover { background: var(--bg); color: var(--text); }
.section-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.si-num { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 16px; }
.section-item.active .si-num { color: var(--brand); }
.si-title { flex: 1; }
.si-dot { width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.section-item.edited .si-dot { background: var(--brand); }

.admin-main {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; min-width: 0;
}
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.editor-head strong { font-size: 18px; margin: 0 10px; }
.editor-actions { display: flex; gap: 8px; }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.badge-on { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.pane { display: flex; flex-direction: column; min-width: 0; }
.pane-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
#md { width: 100%; min-height: 460px; resize: vertical; line-height: 1.7; }
.preview-box {
  min-height: 460px; max-height: 620px; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 9px; padding: 6px 16px 16px;
}
.preview-box h3:first-child, .preview-box p:first-child { margin-top: 12px; }

.md-help { margin-top: 18px; font-size: 13px; color: var(--text-soft); }
.md-help summary { cursor: pointer; color: var(--muted); }
.md-help ul { margin: 10px 0 0; padding-left: 18px; }
.md-help li { margin: 4px 0; }
.md-help code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: 12.5px; }

@media (max-width: 860px) {
  .admin-editor { grid-template-columns: 1fr; }
  .admin-side { position: static; }
  .editor-grid { grid-template-columns: 1fr; }
  #md, .preview-box { min-height: 300px; }
}
