/* ==========================================================================
   库查的开发技术笔记 —— 样式表
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "Fira Code", Consolas,
    "Liberation Mono", Menlo, monospace;

  --container: 740px;
  --radius: 10px;
  --radius-sm: 7px;

  color-scheme: light dark;
}

/* 浅色主题（默认） */
:root,
[data-theme="light"] {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --text: #1f2328;
  --text-muted: #59636e;
  --border: #e4e7eb;
  --border-strong: #d3d8de;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef2ff;
  --code-bg: #f3f4f6;
  --code-border: #e4e7eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
  --header-bg: rgba(255, 255, 255, 0.82);
}

/* 深色主题 */
[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #161a21;
  --surface-2: #1b2029;
  --text: #e6e8eb;
  --text-muted: #9aa4ad;
  --border: #262b33;
  --border-strong: #333a45;
  --accent: #a5b4fc;
  --accent-hover: #c7d2fe;
  --accent-soft: #1e2130;
  --code-bg: #11151c;
  --code-border: #232934;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --header-bg: rgba(15, 17, 21, 0.82);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { color: var(--accent-hover); text-decoration: underline; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 650;
  font-size: 15px;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}
[data-theme="dark"] .brand-mark { color: #0f1115; }
.brand-text { letter-spacing: .2px; }

.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}
.theme-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  transition: all .15s ease;
}
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.link-btn {
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 7px;
}
.link-btn:hover { color: var(--accent); background: var(--surface-2); }
.inline { display: inline; }

/* ---------- 主体 ---------- */
.main {
  flex: 1;
  padding-top: 40px;
  padding-bottom: 64px;
}

/* ---------- 登录 ---------- */
.auth-wrap {
  display: flex;
  justify-content: center;
  padding-top: 8vh;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 30px;
}
.auth-title { margin: 0 0 6px; font-size: 22px; font-weight: 680; }
.auth-sub { margin: 0 0 22px; color: var(--text-muted); font-size: 14px; }

.field { display: block; margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.field-input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-error {
  margin: 0 0 16px;
  padding: 9px 12px;
  font-size: 13.5px;
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
}
[data-theme="dark"] .form-error { color: #fca5a5; background: rgba(185,28,28,.16); border-color: rgba(185,28,28,.4); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
[data-theme="dark"] .btn-primary { color: #0f1115; }
.btn-block { width: 100%; }

/* ---------- 列表 ---------- */
.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}
.list-title { margin: 0; font-size: 26px; font-weight: 680; letter-spacing: .3px; }
.list-count { margin: 0; color: var(--text-muted); font-size: 13.5px; }

.note-card {
  padding: 20px 22px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.note-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.note-card-title { margin: 0 0 6px; font-size: 18px; font-weight: 640; }
.note-card-title a { color: var(--text); }
.note-card-title a:hover { color: var(--accent); text-decoration: none; }
.note-card-excerpt { margin: 0 0 10px; color: var(--text-muted); font-size: 14.5px; line-height: 1.6; }
.note-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text-muted);
  font-size: 12.5px;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty code { font-family: var(--font-mono); font-size: 13px; }

/* ---------- 笔记正文 ---------- */
.note { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.back-link {
  display: inline-block;
  margin-bottom: 22px;
  font-size: 14px;
  color: var(--text-muted);
}
.back-link:hover { color: var(--accent); text-decoration: none; }
.note-title {
  margin: 0 0 10px;
  font-size: 30px;
  line-height: 1.3;
  font-weight: 720;
  letter-spacing: .2px;
}
.note-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 30px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.note-body { font-size: 16px; line-height: 1.78; }
.note-body > *:first-child { margin-top: 0; }
.note-body h1,
.note-body h2,
.note-body h3,
.note-body h4 {
  margin: 1.7em 0 .6em;
  font-weight: 660;
  line-height: 1.35;
}
.note-body h1 { font-size: 1.6em; }
.note-body h2 { font-size: 1.35em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.note-body h3 { font-size: 1.15em; }
.note-body h4 { font-size: 1em; }
.note-body p { margin: .9em 0; }
.note-body ul,
.note-body ol { margin: .9em 0; padding-left: 1.5em; }
.note-body li { margin: .35em 0; }
.note-body li::marker { color: var(--text-muted); }
.note-body a { text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.note-body img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.note-body hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

/* 行内代码 */
.note-body code {
  font-family: var(--font-mono);
  font-size: .88em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: .12em .4em;
  border-radius: 5px;
  word-break: break-word;
}
/* 代码块 */
.note-body pre {
  margin: 1.2em 0;
  padding: 16px 18px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  line-height: 1.6;
}
.note-body pre code {
  font-size: .86em;
  background: none;
  border: 0;
  padding: 0;
  border-radius: 0;
  word-break: normal;
}

/* 引用 */
.note-body blockquote {
  margin: 1.2em 0;
  padding: .4em 1.1em;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.note-body blockquote > :first-child { margin-top: .5em; }
.note-body blockquote > :last-child { margin-bottom: .5em; }

/* 表格 */
.note-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 14.5px;
  display: block;
  overflow-x: auto;
}
.note-body th,
.note-body td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}
.note-body th { background: var(--surface-2); font-weight: 620; }
.note-body tr:nth-child(2n) td { background: var(--surface-2); }

/* ---------- 404 ---------- */
.not-found { text-align: center; padding: 80px 20px; }
.not-found h1 { font-size: 64px; margin: 0 0 8px; color: var(--text-muted); letter-spacing: 2px; }
.not-found p { color: var(--text-muted); margin: 0 0 24px; }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer-inner {
  padding: 22px 20px;
  text-align: center;
}
.footer-inner p { margin: 4px 0; }
.footer-copy { color: var(--text-muted); font-size: 13px; }
.footer-beian {
  font-size: 12.5px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
  justify-content: center;
  align-items: center;
}
.footer-beian a { color: var(--text-muted); }
.footer-beian a:hover { color: var(--accent); }
.footer-sep { margin: 0 6px; opacity: .6; }
.gongan { display: inline-flex; align-items: center; gap: 4px; }
.gongan-badge { font-size: 13px; line-height: 1; }

/* ---------- 响应式 ---------- */
@media (max-width: 600px) {
  body { font-size: 15px; }
  .main { padding-top: 28px; }
  .note-title { font-size: 25px; }
  .list-title { font-size: 23px; }
  .auth-card { padding: 26px 22px; }
  .note-card { padding: 17px 16px; }
}

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