/**
 * 文件：public/assets/css/main.css
 * 用途：定义全站主题变量、基础排版、首页归档和共享页脚样式。
 * 作者：Shan
 * 创建日期：2026-07-20
 * 最后修改：2026-07-29
 * 关键依赖：HTML data-theme 属性
 * 职责边界：提供全站共享样式，详情、后台和登录页差异由各自 CSS 负责。
 * 修改记录：2026-07-29 Shan - 补充样式文件档案。
 * 注意事项：主题变量名称是其他样式表的稳定接口。
 */

:root {
  color-scheme: light;
  --bg: #fafbfc;
  --fg: #1a1a2e;
  --muted: #777f8f;
  --link: #2563eb;
  --border: #e8ecf0;
  --card: #ffffff;
  --card-soft: #f7f9fb;
  --field: #f3f5f8;
  --header-bg: rgba(255, 255, 255, .92);
  --result-hover: #f7f9fb;
  --shadow: rgba(0, 0, 0, .08);
  --focus-ring: rgba(37, 99, 235, .14);
  --button-bg: #1d4ed8;
  --button-bg-hover: #1e40af;
  --button-fg: #ffffff;
  --code-bg: #edf0f4;
  --pre-bg: #101828;
  --danger: #c2410c;
  --wrapper: 1124px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101418;
  --fg: #edf2f7;
  --muted: #9aa6b2;
  --link: #7db2ff;
  --border: #27313b;
  --card: #171d24;
  --card-soft: #1d2530;
  --field: #202a35;
  --header-bg: rgba(16, 20, 24, .9);
  --result-hover: #202a35;
  --shadow: rgba(0, 0, 0, .28);
  --focus-ring: rgba(125, 178, 255, .18);
  --button-bg: #2563eb;
  --button-bg-hover: #1d4ed8;
  --button-fg: #ffffff;
  --code-bg: #263241;
  --pre-bg: #111827;
  --danger: #f97316;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea { font: inherit; }
button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--button-fg);
  padding: 8px 14px;
  cursor: pointer;
}
button:hover { background: var(--button-bg-hover); }
button.danger { background: var(--danger); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.wrapper { max-width: var(--wrapper); margin: 0 auto; padding: 14px 30px; }
.header-wrapper { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.site-title { color: var(--fg); font-size: 17px; font-weight: 800; }
.header-actions { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  padding: 2px;
}
.theme-toggle button {
  min-width: 36px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0 7px;
  font-size: 12px;
  line-height: 1;
  text-orientation: mixed;
  white-space: nowrap;
  writing-mode: horizontal-tb;
}
.theme-toggle button[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
}
.page-content { flex: 1 0 auto; padding: 30px 0; }
.page-heading { margin: 0 0 20px; font-size: 32px; line-height: 1.2; font-weight: 800; }
.intro p { margin: 4px 0; }
.tools-section { margin-top: 42px; }
.tools-note { border-left: 3px solid var(--link); color: var(--muted); padding-left: 14px; }
.tools-note p { margin: 3px 0; }

.search-container { position: relative; width: min(360px, 100%); }
.search-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--field);
  color: var(--fg);
  padding: 8px 62px 8px 18px;
  outline: none;
}
.search-input:focus { border-color: var(--link); box-shadow: 0 0 0 3px var(--focus-ring); }
.search-char-count {
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--muted);
  font-size: 12px;
  transform: translateY(-50%);
  pointer-events: none;
}
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: none;
  width: min(420px, calc(100vw - 36px));
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 8px 24px var(--shadow);
}
.search-results.active { display: block; }
.result-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--fg); }
.result-item:hover { background: var(--result-hover); text-decoration: none; }
.result-title { font-weight: 600; }
.result-meta, .empty { color: var(--muted); font-size: 13px; }
.empty { padding: 16px; text-align: center; }

.categories { margin-top: 40px; }
#archive { display: flex; flex-direction: column; gap: 12px; }
.archive-loading { color: var(--muted); }
.archive-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.archive-group[open] { box-shadow: 0 8px 22px var(--shadow); }
.archive-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 11px 16px;
  background: var(--field);
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  list-style: none;
  user-select: none;
}
.archive-title::-webkit-details-marker { display: none; }
.archive-title:focus-visible { outline: 2px solid var(--link); outline-offset: -2px; }
.archive-group[open] .archive-title { border-bottom: 1px solid var(--border); }
.archive-category { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.archive-category-mark { width: 4px; height: 22px; border-radius: 2px; background: var(--link); }
.archive-summary-meta { display: inline-flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.archive-count {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 600;
}
.archive-chevron {
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .18s ease;
}
.archive-group:not([open]) .archive-chevron { transform: rotate(-45deg); }
.archive-list { list-style: none; margin: 0; padding: 4px 16px; }
.archive-post {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  border-bottom: 1px solid var(--border);
  padding: 13px 8px;
}
.archive-post:last-child { border-bottom: 0; }
.archive-post:hover { background: var(--result-hover); }
.archive-date { color: var(--muted); padding-top: 2px; font-size: 12px; font-variant-numeric: tabular-nums; }
.archive-post-link { display: flex; min-width: 0; flex-direction: column; gap: 2px; color: var(--fg); }
.archive-post-link:hover { text-decoration: none; }
.archive-post-title { color: var(--link); font-size: 16px; font-weight: 650; line-height: 1.45; }
.archive-post-excerpt {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.site-footer { margin-top: auto; border-top: 1px solid var(--border); background: var(--card); padding: 22px 0; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.footer-signature { display: flex; min-width: 0; align-items: center; gap: 12px; }
.footer-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--field);
  color: var(--link);
  font-size: 15px;
  font-weight: 800;
}
.footer-copy { display: flex; min-width: 0; flex-direction: column; line-height: 1.4; }
.footer-copy strong { font-size: 14px; }
.footer-thought-line { display: flex; min-width: 0; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.footer-thought-line > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer-refresh {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-size: 15px;
  line-height: 1;
}
.footer-refresh:hover { background: var(--field); color: var(--link); }
.footer-meta { display: flex; flex: 0 0 auto; align-items: center; gap: 16px; }
.footer-stat { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.footer-link { color: var(--fg); font-size: 13px; }
.not-found h1 { font-size: 34px; line-height: 1.2; }

:not(pre) > code {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: .88em;
}

@media (max-width: 768px) {
  .wrapper { padding: 14px 18px; }
  .header-wrapper { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; flex-wrap: wrap; margin-left: 0; }
  .page-heading { font-size: 26px; }
  .archive-title { padding: 10px 12px; }
  .archive-list { padding: 3px 10px; }
  .archive-post { grid-template-columns: 46px minmax(0, 1fr); gap: 8px; padding: 12px 4px; }
  .footer-inner { align-items: flex-start; flex-direction: column; gap: 16px; }
  .footer-signature { width: 100%; }
  .footer-meta { width: 100%; justify-content: flex-start; }
}
