:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --ink: #1c1c1e;
  --sub: #8e8e93;
  --line: #e5e5ea;
  --accent: #0a84ff;
  --tabh: calc(54px + env(safe-area-inset-bottom));
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

/* 顶部 */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .title { font-size: 17px; font-weight: 600; color: var(--ink); margin-right: 12px; }
.topbar .title .name { color: var(--accent); font-weight: 700; }
.topbar .who { font-size: 13px; color: var(--accent); white-space: nowrap; }

/* 内容区 */
.view {
  padding: 16px;
  padding-bottom: calc(var(--tabh) + 16px);
  min-height: calc(100vh - 100px);
}
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card h3 { margin: 0 0 8px; font-size: 15px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card-head h3 { margin: 0; }
.muted { color: var(--sub); font-size: 14px; }
.prose { font-size: 15px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }

/* 编辑控件 */
.link-btn { border: 0; background: none; color: var(--accent); font-size: 14px; padding: 4px 0; }
.textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font: inherit; font-size: 15px; line-height: 1.6;
  resize: vertical; margin: 4px 0 12px; background: var(--bg);
}
.btn-row { display: flex; gap: 10px; }
.btn-primary, .btn-ghost {
  flex: 1; padding: 12px; border-radius: 10px; font-size: 16px; border: 1px solid var(--line);
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:disabled { opacity: .6; }
.btn-ghost { background: var(--card); color: var(--ink); }
.btn-danger { background: var(--card); color: #ff3b30; border-color: #ffd0cc; flex: 0 0 auto; padding-left: 18px; padding-right: 18px; }

.input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font: inherit; font-size: 15px; margin: 4px 0 12px; background: var(--bg);
}

/* 自定义块图片：竖屏单列，宽度自适应 */
.sec-imgs img { width: 100%; height: auto; border-radius: 10px; display: block; margin-top: 10px; }
.sec-imgs.edit { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.sec-imgs.edit img { margin-top: 0; aspect-ratio: 1/1; object-fit: cover; }
.img-item { position: relative; }
.img-rm {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 15px; line-height: 1;
}
.img-add-btn {
  display: inline-block; padding: 10px 16px; border: 1px dashed var(--line);
  border-radius: 10px; color: var(--accent); font-size: 14px; margin-bottom: 12px;
}
#sec-up-status { margin-left: 10px; }

/* 加内容按钮 */
.add-block {
  width: 100%; padding: 14px; border: 1px dashed var(--accent); background: var(--card);
  border-radius: 14px; color: var(--accent); font-size: 16px;
}
.img-add-btn.block { display: block; text-align: center; margin-bottom: 12px; }

/* 相册（花絮）网格 */
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.g-item { position: relative; aspect-ratio: 1/1; }
.g-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; }
.g-del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; font-size: 15px; line-height: 1;
}
.zoom { cursor: zoom-in; }

/* 时间轴日期分组 */
.tl-date { font-size: 14px; font-weight: 600; color: var(--ink); margin: 16px 2px 8px; }
.tl-date:first-of-type { margin-top: 4px; }
.tl-note { font-size: 12px; font-weight: 400; color: var(--sub); margin-left: 6px; }

/* 苹果相册式看图器 */
.viewer { position: fixed; inset: 0; z-index: 200; background: #000; display: flex; flex-direction: column; }
.viewer-close {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 16px; z-index: 20;
  width: 50px; height: 50px; border: 0; border-radius: 50%;
  background: #fff; color: #111; font-size: 24px; font-weight: 700;
  line-height: 50px; text-align: center;
  box-shadow: 0 3px 12px rgba(0,0,0,.5);
}
/* 顶部暗色渐变，让关闭按钮更跳出来 */
.viewer::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 96px; z-index: 5;
  background: linear-gradient(rgba(0,0,0,.45), rgba(0,0,0,0)); pointer-events: none;
}
.viewer-main { flex: 1 1 auto; width: 100%; min-height: 0; }
.viewer-main .swiper-slide { display: flex; align-items: center; justify-content: center; }
.viewer-main .swiper-zoom-container img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-info {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 14px; color: #fff;
}
.viewer-meta { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
#viewer-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-sub { font-size: 12px; color: rgba(255,255,255,.7); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.viewer-sub .cap {
  background: rgba(255,255,255,.18); color: #fff; font-size: 11px;
  padding: 1px 7px; border-radius: 10px;
}
.viewer-dl {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 20px; border: 0;
  background: var(--accent); color: #fff; font-size: 14px;
}
.viewer-dl:disabled { opacity: .55; }
.viewer-hint {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 15;
  bottom: 150px; background: rgba(0,0,0,.7); color: #fff;
  font-size: 13px; padding: 8px 16px; border-radius: 20px; white-space: nowrap;
}

/* 自写横滑缩略图条 */
.filmstrip {
  flex: 0 0 auto; display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 8px 12px; padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
  scrollbar-width: none;
}
.filmstrip::-webkit-scrollbar { display: none; }
.strip-thumb {
  flex: 0 0 auto; width: 54px; height: 54px; object-fit: cover; border-radius: 6px;
  opacity: .5; border: 2px solid transparent; transition: opacity .2s;
}
.strip-thumb.active { opacity: 1; border-color: #fff; }

/* 缩略图墙上的上传者角标 */
.g-by {
  position: absolute; left: 4px; bottom: 4px; max-width: calc(100% - 8px);
  background: rgba(0,0,0,.5); color: #fff; font-size: 10px; line-height: 1.4;
  padding: 1px 5px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 回收站 */
.trash-entry {
  text-align: center; color: var(--sub); font-size: 13px; padding: 18px 0 4px; margin-top: 8px;
}
.trash-item .trash-acts {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 6px;
  align-items: center; justify-content: center; background: rgba(0,0,0,.35);
}
.trash-acts button { border: 0; border-radius: 14px; font-size: 12px; padding: 5px 12px; }
.t-restore { background: var(--accent); color: #fff; }
.t-purge { background: #fff; color: #ff3b30; }

/* 上传进度小药丸 */
.uprog {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabh) + 14px); z-index: 150;
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.82); color: #fff; padding: 10px 16px; border-radius: 22px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 13px; max-width: 80vw;
}
.uprog-bar { width: 90px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.25); overflow: hidden; }
.uprog-bar i { display: block; height: 100%; width: 0; background: #fff; border-radius: 3px; transition: width .2s; }
.uprog-bar.indeterminate i { width: 40% !important; animation: indet 1s infinite ease-in-out; }
@keyframes indet { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.uprog-text { white-space: nowrap; }
.placeholder {
  display: flex; align-items: center; justify-content: center;
  min-height: 160px; color: var(--sub); font-size: 14px;
  border: 1px dashed var(--line); border-radius: 14px;
}

/* 底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  height: var(--tabh);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1; min-width: 0; border: 0; background: none;
  font-size: 10px; color: var(--sub); white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding-top: 8px;
}
.tabbar button .ico { font-size: 19px; line-height: 1; }
.tabbar button.active { color: var(--accent); }

/* 身份选择 */
.mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.4);
  display: flex; align-items: flex-end;
}
.sheet {
  width: 100%;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  padding: 24px 20px calc(env(safe-area-inset-bottom) + 24px);
  animation: rise .25s ease;
}
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet h2 { margin: 0 0 4px; font-size: 20px; }
.sheet .hint { margin: 0 0 18px; color: var(--sub); font-size: 14px; }
.identity-list { display: grid; gap: 10px; }
.identity-list button {
  width: 100%; padding: 16px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg);
  font-size: 17px; color: var(--ink); text-align: center;
}
.identity-list button:active { background: #e8e8ed; }
