:root {
  --accent: #ff8c42;
  --accent-dark: #e0701f;
  --bg: #f6f5f2;
  --card-bg: #ffffff;
  --text: #2b2b2b;
  --text-2: #7a7a7a;
  --line: #ececec;
  --danger: #e5484d;
  --ok: #2f9e44;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.page { max-width: 640px; margin: 0 auto; padding: 14px 14px 40px; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0 14px;
}
.topbar .title { font-size: 19px; font-weight: 700; flex: 1; }
.topbar .btn { flex-shrink: 0; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600;
  padding: 9px 16px; cursor: pointer;
  background: var(--accent); color: #fff;
}
.btn:active { opacity: .85; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #f3c9ca; }
.btn.sm { font-size: 13px; padding: 5px 10px; border-radius: 8px; }
.btn.block { width: 100%; }

/* ---------- 搜索框 ---------- */
.search {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.search input {
  flex: 1; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: 15px; background: #fff; outline: none;
}
.search input:focus { border-color: var(--accent); }

/* ---------- 卡片网格 ---------- */
.grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.cat-card {
  background: var(--card-bg); border-radius: var(--radius);
  overflow: hidden; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border: 1px solid var(--line);
}
.cat-card .cover {
  width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: #e8e6e1;
}
.cat-card .cover.ph { display: flex; align-items: center; justify-content: center; color: var(--text-2); font-size: 34px; }
.cat-card .info { padding: 9px 11px; }
.cat-card .name { font-size: 14.5px; font-weight: 600; word-break: break-all; }
.cat-card .meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; color: var(--text-2); padding: 60px 0; font-size: 14px; }
.empty .icon { font-size: 40px; margin-bottom: 8px; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: none; align-items: flex-end; justify-content: center; z-index: 50;
}
.mask.show { display: flex; }
.sheet {
  width: 100%; max-width: 640px; background: #fff;
  border-radius: 18px 18px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h3 { font-size: 16px; margin-bottom: 14px; }
.sheet .field { margin-bottom: 12px; }
.sheet .field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.sheet .field input[type=text] {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; outline: none;
}
.sheet .field input[type=file] { font-size: 14px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 16px; }
.sheet .actions .btn { flex: 1; }
.photo-preview { width: 100%; max-height: 180px; object-fit: cover; border-radius: 10px; display: none; margin-top: 8px; }

/* ---------- 详情页：媒体网格 ---------- */
.section-title {
  font-size: 15px; font-weight: 700; margin: 18px 0 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 560px) { .media-grid { grid-template-columns: repeat(4, 1fr); } }

.media-item { position: relative; border-radius: 10px; overflow: hidden; background: #000; aspect-ratio: 1/1; }
.media-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item video { width: 100%; height: 100%; object-fit: cover; }
.media-item .badge {
  position: absolute; left: 6px; top: 6px;
  background: rgba(0,0,0,.55); color: #fff;
  font-size: 10.5px; padding: 2px 7px; border-radius: 999px;
}
.media-item .play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.12);
}
.media-item .play::after {
  content: ""; width: 0; height: 0;
  border-top: 13px solid transparent; border-bottom: 13px solid transparent;
  border-left: 20px solid rgba(255,255,255,.92);
  margin-left: 5px;
}
.media-item .ops {
  position: absolute; right: 4px; bottom: 4px; display: flex; gap: 4px;
}
.media-item .ops .btn { padding: 4px 8px; font-size: 11px; border-radius: 6px; }

/* ---------- 播放弹层 ---------- */
.player {
  position: fixed; inset: 0; background: #000;
  display: none; align-items: center; justify-content: center; z-index: 60;
}
.player.show { display: flex; }
.player video { max-width: 100%; max-height: 100%; width: auto; height: auto; background: #000; }
.player .close { z-index: 10; }
.player .dl { z-index: 10; }
.player .close {
  position: absolute; top: 12px; right: 14px; color: #fff; font-size: 26px;
  background: rgba(0,0,0,.35); width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.player .dl {
  position: absolute; top: 16px; left: 16px;
  color: #fff; font-size: 13px; background: rgba(0,0,0,.35);
  padding: 7px 12px; border-radius: 999px; text-decoration: none;
}

/* ---------- 图片查看弹层 ---------- */
.viewer {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  display: none; align-items: center; justify-content: center; z-index: 60;
}
.viewer.show { display: flex; }
.viewer img { max-width: 100%; max-height: 100%; }
.viewer .close { position: absolute; top: 12px; right: 14px; color: #fff; font-size: 26px; }

/* ---------- 提示条 ---------- */
.notice {
  background: #fff8e6; border: 1px solid #f2d57e; color: #7a5b00;
  font-size: 12.5px; line-height: 1.6; border-radius: 10px;
  padding: 9px 12px; margin-bottom: 12px;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 12%; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; font-size: 13.5px;
  padding: 9px 16px; border-radius: 999px; z-index: 99;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 84%;
  text-align: center;
}
#toast.show { opacity: 1; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 20px; }
.login-wrap .logo { font-size: 44px; margin-bottom: 10px; }
.login-wrap h1 { font-size: 20px; margin-bottom: 6px; }
.login-wrap p { color: var(--text-2); font-size: 13.5px; margin-bottom: 22px; }
.login-wrap input {
  width: 100%; max-width: 300px; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; font-size: 16px; text-align: center; outline: none; margin-bottom: 12px;
}
.login-wrap .btn { max-width: 300px; width: 100%; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--text-2); text-align: center; }

/* 上传进度条 */
#progressBar {
  height: 4px; background: var(--line); border-radius: 2px; overflow: hidden;
  display: none; margin-top: 10px;
}
#progressBar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
