/* 个人网站 —— App 风格样式（移动优先，深色主题） */
:root {
  --bg: #1b1c1e;
  --card: #2b2c2f;
  --text: #f1f2f4;
  --text-2: #9195a1;
  --line: rgba(255, 255, 255, .08);
  --accent: #3d8bfd;
  --accent-ink: #ffffff;
  --danger: #ff7b7f;
  --ok: #3ad07f;
  --radius: 16px;
  --tab-h: 56px;
  --bar-h: 52px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}

[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(env(safe-area-inset-bottom, 0px) + 96px);
  -webkit-font-smoothing: antialiased;
}

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

/* ---------------------------------------------------------------- 顶部栏 */
/* 对齐 app.dmscn.net：深色固定头部、大标题、圆形图标按钮 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 8px 10px 18px;
  background: #1b1c1e;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  color: #f1f2f4;
}
.brand {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; letter-spacing: .3px;
  color: #f1f2f4;
}
.brand-dot {
  flex: none;
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, #3d8bfd, #7bb0ff);
  box-shadow: 0 0 0 3px rgba(61, 139, 253, .18);
}
.brand-name {
  min-width: 0;
  font-size: 26px; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.actions { display: flex; align-items: center; gap: 2px; flex: none; }
.top-link {
  flex: none;
  padding: 5px 8px;
  border-radius: 9px;
  font-size: 13px;
  line-height: 1.3;
  color: #d9dbe2;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.top-link:active { background: rgba(255, 255, 255, .12); }
.top-user {
  max-width: 6.5em;
  overflow: hidden; text-overflow: ellipsis;
  color: var(--accent);
}
@media (max-width: 420px) {
  .top-user { display: none; }
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #f1f2f4;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.icon-btn svg { width: 23px; height: 23px; display: block; }
.icon-btn:active { background: rgba(255, 255, 255, .12); }
.icon-btn.is-on { color: var(--accent); background: rgba(61, 139, 253, .14); }
.ic { width: 22px; height: 22px; }

.dropdown {
  position: absolute;
  top: calc(100% - 6px);
  right: 10px;
  min-width: 186px;
  padding: 6px;
  background: #2b2c2f;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .55);
  color: #f1f2f4;
  overflow: hidden;
  animation: pop .14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.dropdown a {
  display: block;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14.5px;
}
.dropdown a:active { background: rgba(255, 255, 255, .08); }
.dd-sep { height: 1px; margin: 5px 6px; background: rgba(255, 255, 255, .08); }
.dd-danger { color: #ff7b7f; }

/* ------------------------------------------------------------ 顶部搜索栏 */
.search {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 66px);
  z-index: 39;
  max-height: 0;
  overflow: hidden;
  background: var(--bg);
  visibility: hidden;
  transition: max-height .26s ease, visibility 0s linear .26s;
}
.search.is-open { max-height: 108px; visibility: visible; transition: max-height .26s ease, visibility 0s; }
.search-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 12px 12px;
}
.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--card);
}
.search-field .ic { width: 18px; height: 18px; color: var(--text-2); flex: none; }
.search-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.search-field input::placeholder { color: #6f7480; }
.search-cancel {
  flex: none;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
}
.search-empty {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px 10px;
  color: var(--text-2);
  font-size: 13px;
}

/* ---------------------------------------------------------------- 内容区 */
.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; }

/* -------------------------------------------------------------- 全站搜索页 */
.sr-form { display: flex; gap: 8px; margin: 0 0 12px; }
.sr-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
}
.sr-field .ic { width: 18px; height: 18px; color: var(--text-2); flex: none; }
.sr-field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.sr-field input::placeholder { color: #6f7480; }
.sr-submit { flex: none; height: 44px; padding: 0 18px; }
.sr-tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
  padding-bottom: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.sr-tabs::-webkit-scrollbar { display: none; }
.sr-tab {
  flex: none;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.5;
  white-space: nowrap;
}
.sr-tab b { font-weight: 500; opacity: .75; margin-left: 2px; }
.sr-tab.on { background: rgba(61, 139, 253, .14); border-color: rgba(61, 139, 253, .4); color: var(--accent); }
.sr-count { color: var(--text-2); font-size: 13px; margin: 0 2px 10px; }
.sr-about { margin: 0 0 12px; }
.sr-badge {
  display: inline-block;
  margin-right: 6px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .07);
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 18px;
}
.sr-item .card-title:active { color: var(--accent); }
.sr-hint { margin-bottom: 10px; }
mark.hl { background: rgba(61, 139, 253, .3); color: #fff; border-radius: 3px; padding: 0 1px; }

/* ------------------------------------------- 相册（瀑布流：按原始比例分列） */
.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; }
.about-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.ab-item { display: flex; flex-direction: column; gap: 6px; }
.ab-item img { width: 100%; border-radius: 10px; background: var(--bg); }
.ab-item .btn { width: 100%; }

/* ------------------------------------------------------------------ 表单 */
.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: #24262a;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.input:focus, .textarea:focus { border-color: var(--accent); background: #2b2c2f; box-shadow: 0 0 0 3px rgba(61, 139, 253, .18); }
.textarea { resize: vertical; line-height: 1.6; }
.input.file { padding: 9px; background: #24262a; }
.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: #35363a;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
.btn:active { background: rgba(255, 255, 255, .1); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:active { background: #2f74e0; }
.btn-danger { color: var(--danger); border-color: rgba(255, 123, 127, .35); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }
.inline { display: inline-block; margin: 0; }

/* 图文详情：上一篇 / 返回 / 下一篇 */
.post-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0 4px;
}
.post-nav .btn.disabled { color: #6b7280; cursor: default; pointer-events: none; }

.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: #2b2c2f; }
.pager .disabled { color: #6b7280; }
.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; }
.form-alert {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 123, 127, .35);
  border-radius: 10px;
  background: rgba(255, 123, 127, .12);
  color: #ffb9bc;
  font-size: 13px;
  line-height: 1.55;
}
.link { color: var(--accent); font-size: 14px; }

/* -------------------------------------------------------------- 底部菜单 */
/* 对齐 app.dmscn.net：玻璃拟态悬浮胶囊导航 */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  transform: translateX(-50%);
  z-index: 50;
  width: calc(100% - 24px);
  max-width: 456px;
  display: flex;
  gap: 2px;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(92, 96, 108, .42), rgba(38, 40, 46, .58));
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  backdrop-filter: blur(26px) saturate(180%);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, .45),
    inset 0 1px 0 rgba(255, 255, 255, .22),
    inset 0 -1px 0 rgba(0, 0, 0, .25);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
  .tabbar { background: rgba(40, 42, 47, .97); }
}
/* 滑动指示器：胶囊高亮 + 速度驱动的拉伸与拖尾（水滴回弹） */
.tab-indicator {
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 0;
  width: 0;
  border-radius: 23px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 255, 255, .30), rgba(255, 255, 255, 0) 62%),
    linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .07));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .4),
    inset 0 -1px 0 rgba(0, 0, 0, .18),
    0 4px 14px rgba(0, 0, 0, .28);
  pointer-events: none;
  z-index: 0;
  --tx: 0px;
  --stretch: 0;
  --tail-w: 0px;
  --tail-x: 0px;
  --tail-o: 0;
  transform: translateX(var(--tx)) scaleX(calc(1 + var(--stretch))) scaleY(calc(1 - var(--stretch) * .22));
  transform-origin: 50% 50%;
  transition: transform .55s cubic-bezier(.16, 1.4, .3, 1), width .45s cubic-bezier(.22, 1.2, .36, 1);
  will-change: transform;
}
.tab-indicator::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--tail-w);
  height: 72%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .34) 52%, rgba(255, 255, 255, 0));
  filter: blur(2.5px);
  opacity: var(--tail-o);
  transform: translate(-50%, -50%) translateX(var(--tail-x));
  transition: width .4s cubic-bezier(.22, 1.2, .36, 1), transform .4s cubic-bezier(.22, 1.2, .36, 1), opacity .3s ease;
  pointer-events: none;
  will-change: transform, width, opacity;
}
.tab-indicator.is-dragging { transition: width .28s cubic-bezier(.32, .72, 0, 1); }
.tab-indicator.is-dragging::after { transition: none; }
.tab {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  padding: 7px 0 6px;
  border-radius: 24px;
  font-size: 11.5px;
  color: #9aa0ac;
  transition: color .22s ease;
  -webkit-tap-highlight-color: transparent;
}
.tab .ic { width: 24px; height: 24px; transition: transform .22s ease; }
.tab.active { color: #e9f1ff; }
.tab.active .ic {
  color: #3d8bfd;
  filter: drop-shadow(0 0 7px rgba(61, 139, 253, .6));
  transform: translateY(-1px) scale(1.04);
}
.tab.is-drop-target { color: #dbe7ff; }
.tab.is-drop-target .ic {
  color: #7fb0ff;
  transform: translateY(-1px) scale(1.06);
  animation: jelly .58s cubic-bezier(.22, 1.28, .36, 1);
}
@keyframes jelly {
  0% { transform: translateY(0) scale(1); }
  30% { transform: translateY(-6px) scale(1.2, .82); }
  55% { transform: translateY(0) scale(.92, 1.1); }
  75% { transform: translateY(-2px) scale(1.05, .96); }
  100% { transform: translateY(-1px) scale(1.06); }
}
.tab:active { background: rgba(255, 255, 255, .06); }

/* ------------------------------------------------------------------ 提示 */
.toast {
  position: fixed;
  left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 104px);
  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-info { background: rgba(61, 139, 253, .96); }
.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: 120;   /* 高于 AI 助手面板(110)，从回复缩略图打开时可见 */
  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;
}

/* -------------------------------------------------------------- AI 助手 */
body.ai-open { overflow: hidden; }
.ai-mask {
  position: fixed; inset: 0;
  z-index: 110;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .5);
  opacity: 0; visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.ai-mask.is-open { opacity: 1; visibility: visible; }
.ai-sheet {
  display: flex; flex-direction: column;
  width: 100%; max-height: 84vh; min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  transition: transform .22s ease;
  overflow: hidden;
}
.ai-mask.is-open .ai-sheet { transform: translateY(0); }
.ai-head {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
}
.ai-head strong { font-size: 15px; }
.ai-sub {
  flex: 1; min-width: 0;
  color: var(--text-2); font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-head .btn { flex: none; }
.ai-close {
  flex: none;
  width: 34px; height: 34px;
  padding: 0 0 2px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text-2);
  font-size: 24px; line-height: 1;
  cursor: pointer;
}
.ai-close:active { background: rgba(255, 255, 255, .08); }
.ai-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 14px 14px 6px;
  -webkit-overflow-scrolling: touch;
}
.ai-msg {
  width: fit-content; max-width: 86%;
  margin: 0 0 10px;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.ai-msg.bot { background: #24262a; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.ai-msg.user { margin-left: auto; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; }
.ai-msg.sys { margin-left: auto; margin-right: auto; max-width: 100%; background: transparent; color: var(--text-2); font-size: 12.5px; text-align: center; }
.ai-msg.err { background: rgba(255, 123, 127, .12); border: 1px solid rgba(255, 123, 127, .3); color: var(--danger); border-bottom-left-radius: 5px; }
.ai-msg.pending { color: var(--text-2); font-size: 13px; }
.ai-msg a { color: var(--accent); text-decoration: underline; }
.ai-confirm {
  width: 100%;
  margin: 0 0 10px;
  padding: 12px;
  border: 1px solid rgba(61, 139, 253, .4);
  border-radius: 12px;
  background: rgba(61, 139, 253, .08);
}
.ai-confirm-text { font-size: 13.5px; line-height: 1.55; word-break: break-word; }
.ai-confirm-ops { display: flex; gap: 8px; margin-top: 10px; }
.ai-confirm-ops .btn { flex: 1; }
.ai-compose {
  flex: none;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  border-top: 1px solid var(--line);
  background: var(--card);
}
.ai-input {
  flex: 1; min-width: 0;
  min-height: 40px; max-height: 120px;
  padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #24262a; color: var(--text);
  font: inherit; font-size: 14px; line-height: 1.45;
  resize: none;
}
.ai-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(61, 139, 253, .16); }
.ai-send { flex: none; height: 40px; }
.ai-attach {
  flex: none;
  width: 40px; height: 40px;
  padding: 0;
  font-size: 17px; line-height: 1;
}
.ai-attach[hidden] { display: none; }
.ai-file-input { display: none; }

/* 工具结果里的图片缩略图 */
.ai-msg.has-gallery { max-width: 92%; }
.ai-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin-top: 8px;
}
.ai-gallery a {
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
}
.ai-gallery img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* 用户气泡里的附件 */
.ai-msg-atts { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px; margin-top: 8px; }
.ai-msg-atts img { display: block; width: 74px; height: 74px; object-fit: cover; border-radius: 8px; }
.ai-msg-atts .ai-file-link { font-size: 12.5px; text-decoration: underline; word-break: break-all; }
.ai-msg.user .ai-file-link { color: var(--accent-ink); }

/* 待发送附件 */
.ai-attach-list {
  flex: none;
  display: flex; gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: var(--card);
}
.ai-attach-list[hidden] { display: none; }
.ai-chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 210px;
  padding: 4px 4px 4px 9px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #24262a; color: var(--text-2);
  font-size: 12px;
}
.ai-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-chip.is-loading { opacity: .8; }
.ai-chip-x {
  flex: none;
  width: 20px; height: 20px;
  padding: 0;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--text-2);
  font-size: 15px; line-height: 1;
  cursor: pointer;
}
.ai-chip-x:hover { background: rgba(255, 255, 255, .08); color: var(--text); }

@media (min-width: 720px) {
  .ai-mask { align-items: center; padding: 24px; }
  .ai-sheet {
    width: min(480px, 92vw);
    height: min(620px, 82vh);
    max-height: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transform: translateY(10px) scale(.98);
  }
  .ai-mask.is-open .ai-sheet { transform: none; }
  .ai-compose { padding-bottom: 12px; }
}

/* ---------------------------------------------------------------- App 升级页 */
.upgrade-card {
  margin: 8px 0 24px;
  padding: 20px 18px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}
.upgrade-head { display: flex; align-items: center; gap: 14px; }
.upgrade-icon {
  flex: none;
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 15px;
  background: linear-gradient(135deg, #3d8bfd, #7bb0ff);
  color: var(--accent-ink);
  font-size: 26px; line-height: 1;
}
.upgrade-name { font-size: 17px; font-weight: 600; letter-spacing: .2px; }
.upgrade-sub { margin-top: 2px; color: var(--text-2); font-size: 12.5px; }
.upgrade-vers {
  margin: 18px 0 4px;
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
}
.upgrade-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  font-size: 14px;
}
.upgrade-row + .upgrade-row { border-top: 1px solid var(--line); }
.upgrade-row > span { color: var(--text-2); }
.upgrade-row strong { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.upgrade-badge {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(61, 139, 253, .18);
  color: #7bb0ff;
  font-size: 10.5px; font-weight: 700; letter-spacing: .5px;
}
.upgrade-log {
  margin-top: 16px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, .03);
}
.upgrade-log-title { margin-bottom: 6px; color: var(--text-2); font-size: 12.5px; }
.upgrade-log ul { margin: 0; padding-left: 18px; }
.upgrade-log li { margin: 4px 0; font-size: 13.5px; line-height: 1.65; }
.upgrade-btn { width: 100%; margin-top: 18px; padding: 12px; font-size: 15px; }
.upgrade-btn:disabled { opacity: .6; }
.upgrade-progress {
  height: 6px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
}
.upgrade-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #3d8bfd, #7bb0ff);
  transition: width .25s ease;
}
.upgrade-status { min-height: 18px; margin-top: 10px; color: var(--text-2); font-size: 12.5px; text-align: center; }
.upgrade-tip { margin: 12px 0 0; color: var(--text-2); font-size: 12.5px; text-align: center; }
.upgrade-tip a { color: #7bb0ff; text-decoration: underline; }
.upgrade-log-empty { margin: 0; color: var(--text-2); font-size: 13px; }
