/* ====== 基础变量 ====== */
:root {
  --bg: #f6f1e7;
  --paper: #fffdf7;
  --ink: #3a352c;
  --ink-soft: #6f685a;
  --line: #e6dcc6;
  --accent: #c0392b;       /* 封皮红 */
  --accent-soft: #f4e2df;
  --green: #5b7c5a;        /* 橄榄绿 */
  --amber: #d9a441;
  --shadow: 0 2px 14px rgba(80, 60, 20, .08);
  --shadow-lg: 0 12px 36px rgba(80, 60, 20, .14);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% 18%, rgba(192, 57, 43, .05), transparent 40%),
    radial-gradient(circle at 88% 8%, rgba(91, 124, 90, .06), transparent 45%),
    repeating-linear-gradient(45deg, rgba(120, 90, 40, .018) 0 2px, transparent 2px 12px);
  line-height: 1.6;
  min-height: 100vh;
}

.wrap { width: min(960px, 100% - 32px); margin-inline: auto; }

/* ====== 顶部导航 ====== */
.site-header {
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(8px);
  background: rgba(246, 241, 231, .85);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { font-size: 26px; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: .5px; }
.top-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.header-tagline { font-size: 13px; color: var(--ink-soft); }

/* 页脚备案信息 */
.site-footer .footer-inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.footer-beian { font-size: 12px; color: var(--ink-soft); max-width: 600px; text-align: center; line-height: 1.7; margin: 4px 0; }
.footer-icp { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.footer-icp a {
  font-size: 12px; color: var(--ink-soft); text-decoration: none;
  border-bottom: 1px dotted transparent; transition: all .15s ease;
}
.footer-icp a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.footer-icp .dot { color: var(--line); font-size: 12px; }
.footer-icp .beian-ga { display: inline-flex; align-items: center; gap: 4px; }
.footer-icp .beian-ga img { width: 14px; height: auto; display: block; }

/* ====== 按钮 ====== */
.btn {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(192,57,43,.3); }
.btn-primary:hover { background: #a93226; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: var(--paper); color: var(--ink); border-color: #d6cab0; }
.icon-btn {
  border: none; background: transparent; cursor: pointer;
  font-size: 18px; color: var(--ink-soft); padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* ====== 卡片 ====== */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ====== 概览区 ====== */
.hero { padding: 48px 0 28px; text-align: center; }
.hero-title { font-size: clamp(24px, 4vw, 34px); margin: 0 0 8px; font-weight: 800; }
.hero-title .accent { color: var(--accent); }
.hero-sub { color: var(--ink-soft); margin: 0 auto 28px; max-width: 540px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 20px;
}
.stat-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-num { font-size: 28px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

/* ====== 关于本站 ====== */
.about { margin-bottom: 28px; }
.about-card { padding: 28px; }
.about-title { font-size: 22px; margin: 0 0 14px; font-weight: 800; }
.about-title::before { content: "📖 "; }
.about-text { font-size: 15px; color: var(--ink); line-height: 1.85; margin: 0 0 24px; }
.about-text strong { color: var(--accent); }
.about-features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.feature {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 18px 16px; text-align: center;
}
.feature-icon { font-size: 28px; margin-bottom: 6px; }
.feature h3 { font-size: 15px; margin: 0 0 6px; color: var(--ink); }
.feature p { font-size: 13px; color: var(--ink-soft); margin: 0; line-height: 1.6; }

/* ====== 工具栏 ====== */
.toolbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px; margin-bottom: 24px; flex-wrap: wrap;
}
.search-box { position: relative; flex: 1; min-width: 220px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); opacity: .6; }
.search-box input {
  width: 100%; padding: 10px 14px 10px 36px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 14px; font-family: inherit; background: #fff;
  color: var(--ink);
}
.search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: all .15s ease;
}
.chip:hover { border-color: #d6cab0; color: var(--ink); }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ====== 时间线 / 日记列表 ====== */
.timeline { display: flex; flex-direction: column; gap: 28px; padding-bottom: 60px; }

.day-group { position: relative; }
.day-head {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 12px; padding-left: 4px;
}
.day-date { font-size: 18px; font-weight: 700; color: var(--ink); }
.day-weekday { font-size: 13px; color: var(--ink-soft); }
.day-count {
  margin-left: auto; font-size: 12px; color: var(--ink-soft);
  background: var(--paper); border: 1px solid var(--line);
  padding: 2px 10px; border-radius: 999px;
}

.entry-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

.entry {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
  display: flex; flex-direction: column;
}
.entry:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.entry.cat-技术资料 { border-left-color: #2c6fb0; }
.entry.cat-学习资料 { border-left-color: var(--green); }
.entry.cat-工具资源 { border-left-color: var(--amber); }
.entry.cat-生活笔记 { border-left-color: #b07a9e; }

.entry-cat {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--ink-soft);
  background: var(--bg); border: 1px solid var(--line);
  padding: 2px 9px; border-radius: 999px; align-self: flex-start;
  margin-bottom: 8px;
}
.entry-title { font-size: 16px; font-weight: 700; margin: 0 0 6px; color: var(--ink); }
.entry-content {
  font-size: 14px; color: var(--ink-soft); margin: 0 0 10px;
  white-space: pre-wrap; word-break: break-word;
}
.entry-link {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; color: #2c6fb0; text-decoration: none;
  word-break: break-all; margin-bottom: 10px;
}
.entry-link:hover { text-decoration: underline; }
.entry-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: auto; }
.tag {
  font-size: 11px; color: var(--ink-soft); background: var(--bg);
  border-radius: 4px; padding: 1px 7px;
}
.entry-tools {
  position: absolute; top: 10px; right: 10px;
  display: flex; gap: 2px; opacity: 0; transition: opacity .15s ease;
}
.entry:hover .entry-tools { opacity: 1; }

/* ====== 空状态 ====== */
.empty-state { text-align: center; padding: 80px 20px; color: var(--ink-soft); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 15px; }

/* ====== 页脚 ====== */
.site-footer {
  border-top: 1px solid var(--line); margin-top: 20px;
  padding: 20px 0; text-align: center; color: var(--ink-soft); font-size: 13px;
}

/* ====== 弹窗 ====== */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(58, 53, 44, .5); backdrop-filter: blur(2px); }
.modal-panel {
  position: relative; width: min(540px, 100%); max-height: 90vh; overflow-y: auto;
  padding: 0; animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--paper); border-radius: var(--radius) var(--radius) 0 0;
}
.modal-head h2 { margin: 0; font-size: 18px; }

.entry-form { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 14px; font-family: inherit;
  background: #fff; color: var(--ink); resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-actions { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.form-actions .spacer { flex: 1; }

/* ====== Toast ====== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 14px; box-shadow: var(--shadow-lg);
  z-index: 60; animation: toastIn .2s ease;
}
.toast[hidden] { display: none; }
@keyframes toastIn { from { transform: translate(-50%, 10px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }

/* ====== 响应式 ====== */
@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .about-features { grid-template-columns: 1fr; }
  .about-card { padding: 20px; }
  .hero { padding-top: 32px; }
  .brand-name { font-size: 18px; }
  .top-nav .btn { padding: 7px 11px; font-size: 13px; }
  .entry-list { grid-template-columns: 1fr; }
  .entry-tools { opacity: 1; } /* 触屏始终显示 */
  .header-tagline { display: none; }
}

/* ====== 登录门 ====== */
.login-gate {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  padding: 36px 28px 28px;
  text-align: center;
}
.login-mark { font-size: 40px; }
.login-title { margin: 8px 0 4px; font-size: 22px; }
.login-sub { margin: 0 0 22px; color: var(--ink-soft); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 14px; font-size: 15px; font-family: inherit;
  background: #fff; color: var(--ink); text-align: center;
}
.login-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error { color: var(--accent); font-size: 13px; margin: 0; }
.login-back { color: var(--ink-soft); font-size: 13px; text-decoration: none; margin-top: 6px; }
.login-back:hover { text-decoration: underline; }
.btn-block { width: 100%; }
