/* 个人网站 —— App 风格样式（移动优先） */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1b1d21;
  --text-2: #6b7280;
  --line: #e6e8eb;
  --accent: #2b7cff;
  --accent-ink: #ffffff;
  --danger: #e5484d;
  --ok: #12a150;
  --radius: 14px;
  --tab-h: 56px;
  --bar-h: 52px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
}

[hidden] { display: none !important; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ---------------------------------------------------------------- 顶部栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .3px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7bb0ff);
  box-shadow: 0 0 0 3px rgba(43, 124, 255, .15);
}
.brand-name { font-size: 16px; }

.menu-btn {
  width: 40px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 10px;
  color: var(--text); cursor: pointer;
}
.menu-btn:active { background: rgba(0, 0, 0, .06); }
.ic { width: 22px; height: 22px; }

.dropdown {
  position: absolute;
  top: calc(var(--bar-h) - 6px);
  right: 10px;
  min-width: 168px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.dropdown a {
  display: block;
  padding: 12px 16px;
  font-size: 15px;
}
.dropdown a:active { background: var(--bg); }
.dropdown a + a { border-top: 1px solid var(--line); }
.dd-sep { height: 6px; background: var(--bg); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.dd-danger { color: var(--danger); }

/* ---------------------------------------------------------------- 内容区 */
.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 12px 24px;
}
.page-title { font-size: 22px; margin: 6px 2px 14px; }
.center { text-align: center; }
.muted { color: var(--text-2); font-size: 13px; }
.empty {
  text-align: center;
  color: var(--text-2);
  padding: 48px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------------ 卡片 */
.list { display: flex; flex-direction: column; gap: 12px; }
.card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.card:active { transform: scale(.995); }
.card-thumb { flex: 0 0 104px; background: var(--bg); }
.card-thumb img { width: 104px; height: 100%; min-height: 92px; object-fit: cover; }
.card-body { padding: 12px 14px 12px 0; min-width: 0; flex: 1; }
.card:not(.has-thumb) .card-body { padding-left: 14px; }
.card-title {
  font-size: 16px; font-weight: 600; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-excerpt {
  color: var(--text-2); font-size: 14px; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { color: var(--text-2); font-size: 12.5px; margin-top: 6px; }
.rec { display: block; }

/* ------------------------------------------- 相册（瀑布流：按原始比例分列） */
.grid {
  column-count: 2;
  column-gap: 8px;
}
@media (min-width: 480px) { .grid { column-count: 3; } }
.photo {
  margin: 0 0 8px;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.photo a { display: block; background: var(--bg); }
.photo img { width: 100%; height: auto; }
.photo-cap { font-size: 12px; color: var(--text-2); padding: 6px 8px 8px; word-break: break-all; }
.photo-admin { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 8px; }
.cap-edit { width: 100%; }
.cap-edit summary { font-size: 12px; color: var(--accent); cursor: pointer; }
.cap-edit .input { margin: 6px 0; font-size: 13px; padding: 6px 8px; }

/* ------------------------------------------------------------------ 详情 */
.post-detail { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.post-title { font-size: 21px; line-height: 1.4; margin: 0 0 6px; }
.post-imgs { display: flex; flex-direction: column; gap: 8px; margin: 14px 0; }
.post-imgs img { width: 100%; border-radius: 10px; }
.post-content { margin-top: 12px; white-space: pre-wrap; word-break: break-word; }

/* ------------------------------------------------------------------ 关于 */
.about { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.about-name { font-size: 20px; font-weight: 700; }

/* ------------------------------------------------------------------ 表单 */
.form { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin: 0 0 14px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.input, .textarea {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: #fbfbfc;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.input:focus, .textarea:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(43, 124, 255, .12); }
.textarea { resize: vertical; line-height: 1.6; }
.input.file { padding: 9px; background: #fff; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  font: inherit; font-weight: 600;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.btn:active { background: var(--bg); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:active { background: #1f6ae4; }
.btn-danger { color: var(--danger); border-color: rgba(229, 72, 77, .35); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.inline { display: inline-block; margin: 0; }

.admin-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0 0 14px;
}
.admin-bar form, .admin-bar details { margin: 0; }
.admin-bar .muted { margin-left: auto; }
.editor { width: 100%; }
.editor > summary { cursor: pointer; display: inline-block; list-style: none; }
.editor > summary::-webkit-details-marker { display: none; }
.editor[open] { margin-top: 8px; }
.editor[open] > summary { margin-bottom: 10px; }

.thumb-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb input { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; }

/* ------------------------------------------------------------------ 分页 */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0 4px; font-size: 14px; }
.pager a, .pager span { padding: 7px 14px; border-radius: 9px; border: 1px solid var(--line); background: #fff; }
.pager .disabled { color: #b9bec7; }
.pager-info { border: 0 !important; background: transparent !important; color: var(--text-2); }

/* ------------------------------------------------- 滚动加载（瀑布流）哨兵 */
.feed-sentinel { height: 44px; }
.feed-sentinel.loading::after {
  content: '加载中…';
  display: block;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
  line-height: 44px;
}
.feed-sentinel.failed::after {
  content: '加载失败，请下拉重试';
  display: block;
  text-align: center;
  color: var(--text-2);
  font-size: 13px;
  line-height: 44px;
}

/* ------------------------------------------------------- 管理页（面板 / 表格） */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
}
.panel > h3 { margin: 0 0 10px; font-size: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.stat { background: var(--bg); border-radius: 10px; padding: 10px 6px; text-align: center; }
.stat .k { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 2px; }
.stat b { font-size: 19px; }
.stat b i { font-size: 12px; font-style: normal; color: var(--text-2); margin-left: 1px; }

.month-picker { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.month-picker select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  white-space: nowrap;
}
.data-table th { background: var(--bg); color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.data-table tfoot td { background: var(--bg); font-weight: 700; }
.data-table .wrap-text { white-space: normal; word-break: break-word; min-width: 96px; }
.data-table .edit-row td { padding: 4px 8px; }
.data-table .edit-row .editor > summary { font-size: 12.5px; padding: 4px 10px; }
.tag {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 12.5px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.editor-form { display: flex; flex-direction: column; }
.editor-form .field { margin-bottom: 10px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; margin-bottom: 12px; }

.mini-list { display: flex; flex-direction: column; gap: 10px; }
.mini-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
}
.mini-thumb { flex: 0 0 64px; width: 64px; height: 64px; border-radius: 9px; overflow: hidden; background: var(--bg); }
.mini-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mini-body { flex: 1; min-width: 0; }
.mini-title { font-weight: 600; font-size: 15px; word-break: break-word; }
.mini-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cap-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.cap-row .input { flex: 1; min-width: 0; padding: 7px 10px; font-size: 13px; }
.cap-row .btn { flex: 0 0 auto; }

/* ------------------------------------------------------------------ 登录 */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 62vh; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 24px 20px; box-shadow: var(--shadow); }
.login-title { font-size: 22px; margin: 0 0 4px; text-align: center; }
.login-sub { color: var(--text-2); font-size: 13px; text-align: center; margin: 0 0 18px; }
.link { color: var(--accent); font-size: 14px; }

/* -------------------------------------------------------------- 底部菜单 */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-2);
}
.tab.active { color: var(--accent); }
.tab .ic { width: 23px; height: 23px; }
.tab:active { background: rgba(0, 0, 0, .03); }

/* ------------------------------------------------------------------ 提示 */
.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 80;
  max-width: 88vw;
  padding: 10px 18px;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .22);
  animation: toast-in .18s ease-out;
  transition: opacity .3s ease, transform .3s ease;
}
.toast-ok { background: rgba(18, 161, 80, .95); }
.toast-err { background: rgba(229, 72, 77, .95); }
.toast.hide { opacity: 0; transform: translateX(-50%) translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* ------------------------------------------------------------------ 灯箱 */
.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  padding: 0;                                /* 整页显示：图片铺满整个视口 */
  touch-action: none;                        /* 让横向滑动由脚本处理，不触发页面滚动 */
  -webkit-user-select: none; user-select: none;
}
.lightbox-stage {
  margin: 0;
  width: 100vw; height: 100vh;
  display: block;
  min-height: 0;
}
.lightbox-stage img {
  display: block;
  width: 100%; height: 100%;
  max-width: none; max-height: none;
  min-height: 0;
  object-fit: contain;                       /* 整张图完整可见，按比例留黑边 */
  border-radius: 0;
  transition: transform .18s ease;
}
.lightbox-stage img.dragging { transition: none; }
.lightbox-cap {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-width: none;
  padding: 28px 52px 42px;
  background: linear-gradient(to top, rgba(0, 0, 0, .72), rgba(0, 0, 0, 0));
  color: rgba(255, 255, 255, .92);
  font-size: 13px;
  text-align: center;
  word-break: break-word;
  pointer-events: none;
}
.lightbox-close {
  position: absolute; top: 14px; right: 16px;
  z-index: 2;
  color: #fff; font-size: 28px; line-height: 1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
  background: transparent; border: 0; cursor: pointer;
}
.lightbox-nav {
  position: absolute; top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 0 4px;
  color: #fff; font-size: 26px; line-height: 1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .5);
  background: rgba(255, 255, 255, .14);
  border: 0; border-radius: 50%;
  cursor: pointer;
}
.lightbox-nav:active { background: rgba(255, 255, 255, .26); }
.lightbox-nav.prev { left: 8px; }
.lightbox-nav.next { right: 8px; }
.lightbox-count {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  color: rgba(255, 255, 255, .75);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181c;
    --card: #1e2126;
    --text: #eceef1;
    --text-2: #9aa1ab;
    --line: #2c3037;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
  .topbar, .tabbar { background: rgba(30, 33, 38, .9); }
  .input, .textarea { background: #191c21; color: var(--text); }
  .input:focus, .textarea:focus { background: #1e2126; }
  .btn { background: #24272d; }
  .input.file { background: #24272d; }
  .pager a, .pager span { background: #24272d; }
}
