/* ==========================================================================
   我全文件 — 照片在前的个人记录
   参考：Paul Stamatiou (stammy.com) 的暖白纸感 · 衬线标题 · 窄栏软卡片
   ========================================================================== */

/* ---------------- 字体 ---------------- */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/plex-400.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/plex-600.woff2') format('woff2');
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/plex-700.woff2') format('woff2');
}

/* ---------------- 变量 ---------------- */
:root {
  --bg: #f3f1ed;
  --card: #fbfaf9;
  --card-2: #eeebe5;
  --ink: #34312c;
  --ink-2: #57524a;
  --ink-3: #8f887d;
  --line: rgba(52, 49, 44, 0.1);
  --line-strong: rgba(52, 49, 44, 0.18);
  --accent: #6f8360;
  --media-bg: #e8e4dd;

  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --serif: Georgia, 'Iowan Old Style', 'Times New Roman', 'Songti SC', 'SimSun',
    'Source Han Serif SC', serif;

  --col: 700px;
  --pad: 22px;
  --r-card: 18px;
  --r-img: 12px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(40, 35, 28, 0.04);
  --shadow: 0 2px 4px rgba(40, 35, 28, 0.04), 0 14px 30px rgba(40, 35, 28, 0.05);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

html[data-theme='dark'] {
  --bg: #191b18;
  --card: #21241f;
  --card-2: #2a2d27;
  --ink: #e9e7e1;
  --ink-2: #b6b2a8;
  --ink-3: #8a857b;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.2);
  --accent: #a3bd91;
  --media-bg: #14160f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 14px 30px rgba(0, 0, 0, 0.24);
}

/* ---------------- 基础 ---------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.5s var(--ease), color 0.5s var(--ease);
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
::selection { background: var(--accent); color: #fff; }

.wrap {
  max-width: calc(var(--col) + var(--pad) * 2);
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* 只给读屏和搜索引擎看的文字 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.serif { font-family: var(--serif); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s var(--ease);
}
.topbar.scrolled { border-bottom-color: var(--line); }

.topbar-inner {
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  color: var(--ink-2);
  transition: color 0.2s var(--ease);
}
.brand:hover { color: var(--ink); }
.brand svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

.topbar-tools { display: flex; align-items: center; gap: 10px; }

.brand-sub {
  margin-left: 10px;
  margin-right: auto;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

/* 语言切换 / 分段控件 */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--card-2);
  border-radius: var(--r-pill);
}
.seg button {
  border: 0;
  background: none;
  padding: 6px 13px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.seg button:hover { color: var(--ink-2); }
.seg button.on {
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--card-2);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.icon-btn:hover { color: var(--ink); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
html[data-theme='dark'] .icon-sun,
html[data-theme='light'] .icon-moon { display: none; }

/* ---------------- 页头 ---------------- */
.hero { padding: 54px 0 38px; }
.hero-kicker {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.hero-title {
  font-family: var(--serif);
  font-size: clamp(32px, 5.4vw, 42px);
  /* 中文衬线（宋体）没有真正的粗体，600 会被浏览器合成、显得笨重；
     400 反而更像印刷品，也和参考站一致。 */
  font-weight: 400;
  line-height: 1.16;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  text-wrap: balance;
}
.hero-bio {
  margin: 0;
  max-width: 34em;
  font-size: 15.5px;
  line-height: 1.8;
  color: var(--ink-2);
}
.hero-stats {
  margin: 18px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* 搜索胶囊 */
.search-pill {
  margin-top: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  padding: 6px 6px 6px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  transition: border-color 0.2s var(--ease);
}
.search-pill:focus-within { border-color: var(--line-strong); }
.search-pill input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: none;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
.search-pill input::placeholder { color: var(--ink-3); }
.search-pill input::-webkit-search-cancel-button { display: none; }
.search-pill button {
  border: 0;
  background: var(--card-2);
  color: var(--ink-2);
  border-radius: var(--r-pill);
  padding: 8px 15px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s var(--ease);
}
.search-pill button:hover { color: var(--ink); }

/* ---------------- 文章流 ---------------- */
.stream {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding-bottom: 6px;
}

.post {
  background: var(--card);
  border-radius: var(--r-card);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid transparent;
  transition: box-shadow 0.3s var(--ease);
}
html[data-theme='dark'] .post { border-color: var(--line); }
.post:hover { box-shadow: var(--shadow); }

.post-media { background: var(--media-bg); line-height: 0; }
.post-media img { display: block; width: 100%; height: auto; }
.ph { margin: 0; cursor: zoom-in; }
.ph-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin-top: 2px;
}
.ph-strip .ph { aspect-ratio: 4 / 3; overflow: hidden; }
.ph-strip .ph img { width: 100%; height: 100%; object-fit: cover; }

.post-body { padding: 22px 26px 24px; }

.post-title {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: -0.005em;
  margin: 0 0 10px;
  text-wrap: balance;
}

.post-text {
  font-size: 15.5px;
  line-height: 1.78;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}

.post-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.post-meta { font-size: 12.5px; color: var(--ink-3); }
.post-tags { display: flex; gap: 11px; flex-wrap: wrap; }
.tag { font-size: 12.5px; color: var(--ink-3); transition: color 0.2s var(--ease); }
.tag:hover { color: var(--accent); }
.tag-inline {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
.tag-inline:hover { text-decoration-color: var(--accent); }

/* ---------------- 栏目索引 ---------------- */
.topic-list {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
  padding: 6px 24px;
}
.topic-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
  transition: color 0.2s var(--ease);
}
.topic-row:last-child { border-bottom: 0; }
.topic-row:hover .topic-name { color: var(--accent); }
.topic-name { font-family: var(--serif); font-size: 16.5px; }
.topic-count { font-size: 12.5px; color: var(--ink-3); }

/* ---------------- 加载更多 ---------------- */
.load-more { display: flex; justify-content: center; padding: 30px 0 0; }
.btn-soft {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-2);
  border-radius: var(--r-pill);
  padding: 11px 24px;
  font-size: 13.5px;
  cursor: pointer;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn-soft:hover { color: var(--ink); border-color: var(--line-strong); }

/* ---------------- 状态 ---------------- */
.empty { padding: 70px 0; text-align: center; color: var(--ink-3); }
.empty h3 {
  font-family: var(--serif);
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 400;
  color: var(--ink);
}
.empty p { margin: 0; font-size: 14px; line-height: 1.8; }

.loading { display: flex; justify-content: center; padding: 46px 0; }
.spinner {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--line-strong);
  border-top-color: var(--ink-3);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 页脚 ---------------- */
.footer {
  padding: 54px 0 60px;
  text-align: center;
  color: var(--ink-3);
  font-size: 12.5px;
  line-height: 2;
}
.footer a { text-decoration: underline; text-underline-offset: 3px; }
.footer a:hover { color: var(--ink-2); }

/* ---------------- 图片查看器 ---------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 56px 40px 40px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 116px);
  border-radius: var(--r-img);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.22);
}
.lightbox-close {
  position: absolute;
  top: 22px;
  right: 26px;
  border: 0;
  background: var(--card);
  color: var(--ink-2);
  border-radius: var(--r-pill);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  font-size: 17px;
  line-height: 1;
}

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 12px);
  z-index: 200;
  background: var(--ink);
  color: var(--bg);
  padding: 11px 20px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   后台
   ========================================================================== */

.admin-head { padding: 34px 0 22px; }
.admin-head h1 {
  font-family: var(--serif);
  font-size: 27px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.admin-head p { margin: 0; font-size: 13px; color: var(--ink-3); }

.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--card-2);
  border-radius: var(--r-pill);
  margin-bottom: 22px;
}
.tabs button {
  border: 0;
  background: none;
  padding: 9px 18px;
  border-radius: var(--r-pill);
  font-size: 13px;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.tabs button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 24px;
  align-items: start;
  padding-bottom: 70px;
}

.stage {
  background: var(--card-2);
  border-radius: var(--r-card);
  padding: 22px;
  min-height: 300px;
  max-height: calc(100vh - 150px);
  overflow: auto;
}
.stage-label { font-size: 12px; color: var(--ink-3); margin-bottom: 14px; }
.stage .post { box-shadow: var(--shadow); }
.stage .ph { cursor: default; }

.panel {
  background: var(--card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 18px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}
.panel-head .sub { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
.panel-body { padding: 20px; }

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  margin-bottom: 7px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.field input,
.field textarea,
.field select {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 13px;
  outline: none;
  transition: border-color 0.2s var(--ease);
}
.field textarea { min-height: 128px; resize: vertical; }
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: var(--line-strong); }
.field .hint { margin-top: 7px; font-size: 12px; line-height: 1.7; color: var(--ink-3); }

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  border-radius: var(--r-pill);
  padding: 10px 18px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn:hover { border-color: var(--line-strong); }
.btn-solid { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-solid:hover { opacity: 0.88; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-mini { padding: 6px 12px; font-size: 12.5px; }
.btn[data-danger] { color: #a8442a; border-color: rgba(168, 68, 42, 0.28); }
.btn[data-danger]:hover { background: #a8442a; border-color: #a8442a; color: #fff; }

.dropzone {
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--bg); }
.dropzone p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.dropzone p + p { margin-top: 6px; font-size: 12px; color: var(--ink-3); }

.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.thumb {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--media-bg);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 21px;
  height: 21px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}
.thumb-state {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  text-align: center;
  padding: 2px 0;
}

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
}
.table th.r, .table td.r { text-align: right; }
.table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: top;
}
.table tr:last-child td { border-bottom: 0; }
.table .t-title { font-family: var(--serif); font-size: 15px; }
.table .t-body {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 12.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.table img {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: var(--media-bg);
}
.table .acts { display: flex; gap: 6px; justify-content: flex-end; }

.stats { display: flex; gap: 12px; }
.stats > div {
  flex: 1;
  background: var(--bg);
  border-radius: 14px;
  padding: 16px 18px;
}
.stats .v { font-family: var(--serif); font-size: 25px; font-weight: 400; }
.stats .k { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }

.login-box { max-width: 380px; margin: 72px auto; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--card-2);
  color: var(--ink-3);
}
.badge.on { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

.preview-tabs { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1000px) {
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .stage { max-height: none; }
}

@media (max-width: 640px) {
  :root { --pad: 16px; --r-card: 16px; }

  .topbar-inner { height: 58px; }
  .brand { font-size: 15.5px; }
  .seg button { padding: 6px 11px; font-size: 12px; }
  .icon-btn { width: 33px; height: 33px; }

  .hero { padding: 34px 0 26px; }
  .hero-bio { font-size: 15px; }
  .search-pill { max-width: none; margin-top: 20px; }

  .stream { gap: 18px; }
  .post-body { padding: 18px 19px 20px; }
  .post-title { font-size: 18.5px; }
  .post-text { font-size: 15px; line-height: 1.75; }
  .post-foot { margin-top: 14px; }

  .lightbox { padding: 64px 14px 22px; }
  .topic-list { padding: 4px 18px; }
}
