/* ============================================================
   NQSYS 门户样式（无框架、系统字体栈、暗色模式自适应）
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #1a2332;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-contrast: #ffffff;
  --code-bg: #f2f4f7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-hover: 0 6px 24px rgba(16, 24, 40, .08);
  --header-bg: rgba(247, 248, 250, .85);
}

html[data-theme="dark"] {
  --bg: #0e1217;
  --panel: #171c24;
  --ink: #e6edf3;
  --muted: #8b96a5;
  --line: #262d38;
  --accent: #818cf8;
  --accent-soft: rgba(99, 102, 241, .16);
  --accent-contrast: #0e1217;
  --code-bg: #1d232e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-hover: 0 6px 24px rgba(0, 0, 0, .4);
  --header-bg: rgba(14, 18, 23, .85);
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.empty { padding: 48px 0; text-align: center; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.main { flex: 1; width: 100%; padding: 32px 0 64px; }

/* ---------- 头部 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: .5px; color: var(--ink); }
.brand:hover { text-decoration: none; color: var(--accent); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; font-size: 15px; }
.nav a:hover { color: var(--ink); background: var(--accent-soft); text-decoration: none; }
.nav a.active { color: var(--accent); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 10px; }
.search-box input {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; width: 140px;
  transition: width .2s, border-color .2s; font-family: inherit;
}
.search-box input:focus { outline: none; border-color: var(--accent); width: 190px; }
.theme-toggle {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  width: 36px; height: 36px; cursor: pointer; font-size: 15px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); }

/* ---------- 通用块 ---------- */
.block { margin-top: 48px; }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.block h2, .page-head h1 { letter-spacing: -.02em; }
.more { font-size: 14px; }
.page-head { margin-bottom: 32px; }
.page-head h1 { font-size: 32px; margin-bottom: 8px; }
.page-head p { font-size: 15px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- 首页 Hero ---------- */
.hero { text-align: center; padding: 56px 0 24px; }
.hero h1 { font-size: clamp(36px, 6vw, 56px); font-weight: 800; letter-spacing: -.03em; }
.hero-sub { font-size: 20px; margin-top: 8px; color: var(--accent); font-weight: 500; }
.hero-desc { margin: 16px auto 0; max-width: 560px; }
.hero-actions { margin-top: 28px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: 9px 22px; font-size: 15px; cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s; font-family: inherit;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: #dc2626; border-color: #fecaca; }
html[data-theme="dark"] .btn-danger { border-color: #7f1d1d; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- 文章卡片 ---------- */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.post-card { padding: 20px 22px; display: flex; flex-direction: column; gap: 8px; transition: box-shadow .2s, transform .2s; }
.post-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); text-decoration: none; }
.post-card h3 a { color: var(--ink); font-size: 17px; }
.post-card h3 a:hover { color: var(--accent); text-decoration: none; }
.post-meta { font-size: 13px; }
.post-excerpt { font-size: 14px; color: var(--muted); }
.post-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 2px 10px; font-size: 13px;
}
.tag:hover { text-decoration: none; filter: brightness(1.05); }
.tag-count { font-size: 11px; opacity: .7; }
.tag-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.tag-active { background: var(--accent); color: var(--accent-contrast); }

/* ---------- 文章详情 ---------- */
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 40px; align-items: start; }
.article { max-width: 780px; }
.article-header { margin-bottom: 28px; }
.article-header h1 { font-size: clamp(26px, 4vw, 38px); letter-spacing: -.02em; line-height: 1.3; }
.article-meta { margin-top: 12px; font-size: 14px; }
.article-tags { display: inline-flex; gap: 6px; }

.markdown-body { font-size: 16px; line-height: 1.85; overflow-wrap: break-word; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 32px 0 16px; line-height: 1.35; }
.markdown-body h1 { font-size: 1.6em; }
.markdown-body h2 { font-size: 1.35em; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.markdown-body h3 { font-size: 1.15em; }
.markdown-body p { margin: 14px 0; }
.markdown-body ul, .markdown-body ol { margin: 14px 0; padding-left: 1.6em; }
.markdown-body li { margin: 6px 0; }
.markdown-body blockquote {
  margin: 16px 0; padding: 4px 18px;
  border-left: 4px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 8px 8px 0; color: var(--muted);
}
.markdown-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  background: var(--code-bg); border-radius: 5px; padding: 2px 6px; font-size: .88em;
}
.markdown-body pre { margin: 18px 0; }
.markdown-body pre.hljs { padding: 16px; border-radius: 10px; overflow-x: auto; font-size: 14px; line-height: 1.6; border: 1px solid var(--line); }
.markdown-body pre code { background: none; padding: 0; font-size: inherit; }
.markdown-body img { max-width: 100%; border-radius: 10px; }
.markdown-body table { border-collapse: collapse; margin: 18px 0; width: 100%; font-size: 15px; }
.markdown-body th, .markdown-body td { border: 1px solid var(--line); padding: 8px 14px; text-align: left; }
.markdown-body th { background: var(--code-bg); }
.markdown-body hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }
.markdown-body a { text-decoration: underline; text-underline-offset: 3px; }
.markdown-body input[type="checkbox"] { margin-right: 6px; }

.toc { position: sticky; top: 88px; font-size: 14px; max-height: calc(100vh - 120px); overflow-y: auto; }
.toc-title { font-weight: 700; margin-bottom: 10px; }
.toc ul { list-style: none; }
.toc li { margin: 6px 0; padding-left: 0; }
.toc li.toc-3 { padding-left: 14px; }
.toc a { color: var(--muted); }
.toc a:hover { color: var(--accent); text-decoration: none; }

.adjacent { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 48px; }
.adjacent-item { padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; }
.adjacent-item:hover { box-shadow: var(--shadow-hover); text-decoration: none; }
.adjacent-item span:last-child { color: var(--ink); }
.adjacent-next { text-align: right; }

.comments { margin-top: 56px; }
.comments h2 { margin-bottom: 16px; }

/* ---------- 工具 / 友链 ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tool-card { padding: 18px 20px; display: flex; gap: 14px; align-items: flex-start; transition: box-shadow .2s, transform .2s; }
.tool-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); text-decoration: none; }
.tool-icon { font-size: 26px; line-height: 1; }
.tool-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tool-name { color: var(--ink); font-weight: 600; }
.tool-desc { font-size: 13px; }

/* ---------- 关于 ---------- */
.about-body { max-width: 780px; }
.about-socials { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }

/* ---------- 归档 ---------- */
.archive-list { list-style: none; }
.archive-list li { display: flex; gap: 20px; padding: 9px 0; border-bottom: 1px dashed var(--line); align-items: baseline; }
.archive-list li span { font-size: 13px; flex-shrink: 0; width: 92px; }

/* ---------- 搜索 ---------- */
.search-big { display: flex; gap: 10px; max-width: 560px; }
.search-big input { flex: 1; width: auto; }

/* ---------- 错误页 ---------- */
.error-page { text-align: center; padding: 80px 0; }
.error-page h1 { font-size: 64px; letter-spacing: -.03em; }
.error-page .hero-actions { justify-content: center; }

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; gap: 16px; justify-content: center; margin-top: 36px; }
.page-btn {
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 18px;
  background: var(--panel); color: var(--ink); font-size: 14px;
}
.page-btn:hover { border-color: var(--accent); text-decoration: none; }

/* ---------- 页脚 ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 48px; padding: 28px 0; }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--muted); }
.footer-inner a { color: var(--muted); }
.footer-inner a:hover { color: var(--accent); }

/* ---------- 管理后台 ---------- */
.admin-page .main { padding-top: 0; }
.admin-login { max-width: 380px; margin: 10vh auto 0; }
.login-card { padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.login-card h1 { font-size: 22px; }
.admin-header {
  position: sticky; top: 0; z-index: 40; background: var(--header-bg);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 56px;
}
.admin-brand { font-weight: 800; white-space: nowrap; }
.admin-tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  border: 0; background: none; color: var(--muted); padding: 6px 12px;
  border-radius: 8px; cursor: pointer; font-size: 14px; font-family: inherit;
}
.tab.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.admin-actions { display: flex; gap: 8px; }
.admin-main { padding: 24px 20px 60px; max-width: 1080px; margin: 0 auto; }
.admin-grid { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
.admin-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; }
.admin-list { list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 65vh; overflow-y: auto; }
.admin-list-item {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.admin-list-title { font-size: 14px; }
.admin-list-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.admin-list-actions { display: flex; gap: 6px; flex-shrink: 0; }
.editor-card { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.editor-card h3 { font-size: 17px; }
.editor-card label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > label { flex: 1 1 200px; }
.form-inline { align-items: center; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox-label input { width: auto; }
.form-actions { display: flex; gap: 10px; }
.preview-box { border: 1px dashed var(--line); border-radius: 10px; padding: 20px; margin-top: 4px; }
.admin-stack { display: flex; flex-direction: column; gap: 20px; }
.admin-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.admin-row:last-child { border-bottom: 0; }
.admin-row .admin-list-main { flex-direction: row; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.admin-row .admin-list-main .muted { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; flex-shrink: 0; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
html[data-theme="dark"] .badge-warn { background: rgba(245, 158, 11, .15); color: #fbbf24; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 20px;
  border-radius: 999px; font-size: 14px; z-index: 100; box-shadow: var(--shadow-hover);
}
.toast-error { background: #dc2626; color: #fff; }
.error-msg { color: #dc2626; font-size: 13px; }

input[type="text"], input[type="password"], input[type="search"], input[type="number"],
input[type="datetime-local"], select, textarea {
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 12px; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
textarea.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .article-layout { grid-template-columns: 1fr; }
  .toc { display: none; }
  .admin-grid { grid-template-columns: 1fr; }
  .admin-side { position: static; }
  .admin-list { max-height: 240px; }
}
@media (max-width: 640px) {
  .header-inner { gap: 10px; }
  .nav a { padding: 6px 8px; font-size: 14px; }
  .search-box input { width: 90px; }
  .search-box input:focus { width: 130px; }
  .post-grid, .tool-grid { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; }
  .adjacent { grid-template-columns: 1fr; }
}
