/* 梗史 gengshi —— 深色主题（--bg #0c1020 / --accent #6366f1 渐变） */
:root {
  --bg: #0c1020;
  --panel: #121831;
  --panel2: #0f1428;
  --line: #232b4d;
  --text: #e8ebf7;
  --muted: #a3abcd;
  --accent: #6366f1;
  --accent2: #8b5cf6;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 50% -100px, rgba(99, 102, 241, 0.16), transparent 70%);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: #a5b4fc; }
a:hover { color: #c7d2fe; }

:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; border-radius: 4px; }

/* ---- 顶栏 ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(12, 16, 32, 0.92);
  border-bottom: 1px solid var(--line);
}
.logo {
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.tagline { color: var(--muted); font-size: 13px; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.search {
  width: 200px;
  max-width: 40vw;
  padding: 9px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.search::placeholder { color: var(--muted); }

/* ---- 按钮 / 输入 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 18px;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.12); }
.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn.ghost:hover { border-color: var(--accent); filter: none; }
.btn.danger-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--danger);
  min-height: 34px;
  padding: 4px 10px;
  font-size: 13px;
}
.btn.danger-ghost:hover { border-color: var(--danger); filter: none; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.input, textarea.input {
  width: 100%;
  padding: 10px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* ---- Hero ---- */
main { max-width: 860px; margin: 0 auto; padding: 20px 16px calc(60px + env(safe-area-inset-bottom)); }
.hero { text-align: center; padding: 26px 8px 18px; }
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(24px, 5vw, 34px);
  background: linear-gradient(135deg, #e8ebf7, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-sub { color: var(--muted); font-size: 14px; max-width: 640px; margin: 0 auto; }
.stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 26px; margin-top: 18px; }
.stat { color: var(--muted); font-size: 13px; }
.stat b { display: block; font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- 时间线 ---- */
#timeline { margin-top: 14px; }
.date-node {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 26px 0 12px;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  font-weight: 600;
}
.date-node .cnt { color: var(--muted); font-weight: 400; font-size: 13px; }
.cards { display: flex; flex-direction: column; gap: 12px; padding-left: 14px; border-left: 3px solid var(--line); margin-left: 1px; }

.card {
  display: flex;
  gap: 14px;
  padding: 16px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card-main { min-width: 0; flex: 1; }
.card-title { margin: 0 0 4px; font-size: 18px; line-height: 1.35; }
.card-sum {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; color: var(--muted); }
.badge {
  padding: 2px 9px;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 999px;
  color: #c7d2fe;
  white-space: nowrap;
}
.badge.archive { background: rgba(148, 163, 184, 0.12); border-color: rgba(148, 163, 184, 0.3); color: #cbd5e1; }
.hot { color: #fca5a5; }
.card-thumb {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(135deg, #312e81, #6d28d9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.search-note { margin: 16px 0 4px; color: var(--muted); font-size: 14px; }
.load-wrap { text-align: center; margin: 22px 0 8px; }
.empty { text-align: center; color: var(--muted); padding: 50px 0; }

/* ---- 弹层 ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 8, 20, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.sheet {
  position: relative;
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
}
.sheet h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.4; }
.sheet h3 { margin: 22px 0 10px; font-size: 16px; }
.sheet h4 { margin: 18px 0 10px; font-size: 15px; color: #c7d2fe; }
.sheet .close, .lightbox .close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  font-size: 16px;
  color: var(--muted);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}
.sheet .close:hover, .lightbox .close:hover { color: var(--text); }
.muted { color: var(--muted); font-size: 13px; }

.detail-meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.track { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.track-chip {
  font-size: 12px;
  padding: 3px 10px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}
.text-item { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.text-item p { margin: 0 0 4px; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.text-item .src { font-size: 12px; color: var(--muted); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; display: block; }

/* ---- 评论 ---- */
.cmt-item { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.cmt-head { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.cmt-head .nick { color: #c7d2fe; }
.cmt-del { margin-left: auto; }
.cmt-item p { margin: 4px 0 0; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.cmt-form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.cmt-form .row { display: flex; gap: 10px; }
.cmt-form textarea { min-height: 84px; resize: vertical; }
.cmt-form .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cmt-form .foot .muted { font-size: 12px; }

/* ---- 我的身份 ---- */
.keybox {
  padding: 12px 14px;
  background: var(--panel2);
  border: 1px dashed var(--line);
  border-radius: 10px;
  overflow-x: auto;
  margin: 12px 0;
}
.keybox code { font-size: 14px; word-break: break-all; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.import-row { display: flex; gap: 10px; margin: 12px 0 4px; }
.import-row .input { flex: 1; min-width: 0; }
.my-comments { display: flex; flex-direction: column; gap: 8px; }
.my-cmt { padding: 10px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.my-cmt .meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.my-cmt .meta a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- 看大图 / toast ---- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox img { max-width: 94vw; max-height: 88vh; border-radius: 8px; }
.lightbox .close { z-index: 2; background: rgba(30, 36, 60, 0.8); }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(30px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: 86vw;
  padding: 10px 18px;
  background: #1c2340;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 16px 40px; }

/* ---- 移动端 ---- */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 10px 14px; row-gap: 8px; }
  .top-actions { width: 100%; margin-left: 0; }
  .search { flex: 1; width: auto; max-width: none; }
  .tagline { display: none; }
  main { padding: 12px 12px calc(50px + env(safe-area-inset-bottom)); }
  .cards { padding-left: 10px; }
  .date-node { padding-left: 10px; }
  .card { padding: 13px; gap: 10px; }
  .card-thumb { flex-basis: 72px; width: 72px; height: 72px; font-size: 24px; }
  .card-title { font-size: 16px; }
  .sheet { padding: 22px 16px calc(22px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; }
  .import-row { flex-direction: column; }
  .import-row .btn { width: 100%; }
}
