/* ============================================================
   common.css — 全局样式 + 主题系统
   ============================================================ */

/* ---------- 主题变量（浅色为默认） ---------- */
:root {
  --bg: #f7f8fa;
  --bg-soft: #ffffff;
  --bg-mute: #eef0f4;
  --text: #1f2329;
  --text-soft: #4a505a;
  --text-mute: #8b9099;
  --border: #e4e7ec;
  --accent: #4f6ef7;
  --accent-soft: rgba(79, 110, 247, 0.10);
  --accent-text: #3a55d6;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.05);
  --code-bg: #1e1e2e;
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 1180px;
}

[data-theme="dark"] {
  --bg: #0f1115;
  --bg-soft: #171a21;
  --bg-mute: #1f232c;
  --text: #e6e8ec;
  --text-soft: #b7bcc5;
  --text-mute: #7b818c;
  --border: #2a2f3a;
  --accent: #7c93ff;
  --accent-soft: rgba(124, 147, 255, 0.14);
  --accent-text: #a9b8ff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.4);
  --code-bg: #0b0c10;
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0 0 0.6em; color: var(--text); }
p { margin: 0 0 1em; }
button, input, textarea, select { font: inherit; color: inherit; }
code, pre, kbd { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }

/* ---------- Layout ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 1rem; }
main { min-height: 65vh; padding: 1.5rem 0 3rem; }
.section-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 1rem; }

/* ---------- Navbar ---------- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg-soft) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.navbar-inner { display: flex; align-items: center; gap: 1.2rem; height: 60px; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.navlinks { display: flex; gap: 0.15rem; margin-left: 1rem; flex: 1; flex-wrap: wrap; }
.navlinks a {
  padding: 0.4rem 0.7rem; border-radius: var(--radius-sm);
  color: var(--text-soft); font-size: 0.95rem;
}
.navlinks a:hover { background: var(--bg-mute); text-decoration: none; color: var(--text); }
.navlinks a.active { color: var(--accent-text); background: var(--accent-soft); font-weight: 600; }
.nav-right { display: flex; align-items: center; gap: 0.6rem; }

/* theme toggle */
.theme-toggle {
  border: 1px solid var(--border); background: var(--bg-soft);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center; font-size: 1.05rem; transition: 0.2s;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ---------- Buttons / badges ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-soft);
  cursor: pointer; font-weight: 600; font-size: 0.9rem; transition: 0.2s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-text); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); color: #fff; }
.badge {
  display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; background: var(--accent-soft); color: var(--accent-text);
}
.tag {
  display: inline-block; padding: 0.12rem 0.55rem; margin: 0.15rem 0.2rem 0.15rem 0;
  border-radius: 999px; font-size: 0.78rem; border: 1px solid var(--border);
  color: var(--text-soft); cursor: pointer; transition: 0.15s;
}
.tag:hover { border-color: var(--accent); color: var(--accent-text); }
.tag.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem;
}
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
@media (max-width: 800px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.35rem; }
.field input, .field textarea {
  width: 100%; padding: 0.6rem 0.8rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-soft);
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 2rem 0; margin-top: 2rem; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; color: var(--text-mute); font-size: 0.9rem; }
.footer a { color: var(--text-soft); }

/* ---------- Misc ---------- */
.muted { color: var(--text-mute); }
.mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 1rem; }
.empty { text-align: center; color: var(--text-mute); padding: 2rem 0; }
.notice { padding: 0.7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.9rem; }
.notice-info { background: var(--accent-soft); color: var(--accent-text); }
.notice-error { background: rgba(231, 76, 60, 0.12); color: #c0392b; }
[data-theme="dark"] .notice-error { color: #ff8b80; }

/* markdown body inside rendered content */
.md-body h1, .md-body h2, .md-body h3 { margin-top: 1.4em; }
.md-body h1 { border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.md-body code { background: var(--bg-mute); padding: 0.12rem 0.4rem; border-radius: 5px; font-size: 0.9em; }
.md-body pre { background: var(--code-bg); color: #e6edf3; padding: 1rem; border-radius: var(--radius-sm); overflow-x: auto; margin: 1rem 0; }
.md-body pre code { background: transparent; padding: 0; color: inherit; }
.md-body blockquote { border-left: 4px solid var(--accent); margin: 1rem 0; padding: 0.2rem 1rem; color: var(--text-soft); background: var(--accent-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.md-body table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.md-body th, .md-body td { border: 1px solid var(--border); padding: 0.5rem 0.75rem; text-align: left; }
.md-body a { word-break: break-word; }

@media (max-width: 600px) {
  .navbar-inner { height: auto; padding: 0.6rem 0; flex-wrap: wrap; }
  .navlinks { order: 3; width: 100%; margin-left: 0; }
}
