:root {
  --bg: #f4efe6;
  --card: #fffcf7;
  --line: #e4d9c8;
  --text: #3b332c;
  --muted: #8a7d70;
  --accent: #c4784a;
  --accent2: #d9a066;
  --danger: #c45c4a;
  --shadow: 0 8px 24px rgba(90, 70, 50, .08);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  color: var(--text);
  font-family: "Nunito", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 88% 8%, #f3e4c8 0 90px, transparent 140px),
    linear-gradient(180deg, #f8f4ee 0%, #f3eee4 100%);
}
h1, h2 {
  font-family: "Nunito", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-weight: 800;
}
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(248, 244, 238, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
h1 {
  margin: 0;
  font-size: 20px;
  color: #3b332c;
}
.sub { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.upload-btn {
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 8px 16px rgba(196, 120, 74, .25);
}
.ghost-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fffcf7;
  color: var(--text);
  border-radius: 999px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 700;
}
.del-pin {
  width: 72px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffcf7;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 0 8px;
}
.del-pin:focus {
  outline: 2px solid rgba(196, 120, 74, .35);
}
.qr-mask {
  position: fixed;
  inset: 0;
  background: rgba(40, 32, 24, .45);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.qr-mask[hidden] { display: none; }
.qr-card {
  background: #fffcf7;
  color: var(--text);
  border-radius: 22px;
  padding: 20px;
  text-align: center;
  width: min(320px, 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.qr-card h2 { margin: 0 0 12px; font-size: 18px; }
.qr-card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 18px;
  background: transparent;
  padding: 0;
}
.qr-card p { margin: 10px 0 14px; color: var(--muted); font-size: 13px; word-break: break-all; }
.qr-card #qrUrl {
  margin: 0 0 14px;
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  user-select: all;
}
.qr-card button {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  width: 100%;
  cursor: pointer;
  font-weight: 800;
}
.qr-card #qrClose {
  margin-top: 8px;
  background: #fffcf7;
  color: var(--text);
  border: 1px solid var(--line);
}
.upload-btn input { display: none; }
.progress-wrap { padding: 10px 16px 0; }
.progress-bar {
  height: 8px;
  background: #e8dccb;
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}
.progress-text { color: var(--muted); font-size: 12px; margin-top: 6px; }
.drop {
  margin: 12px 16px;
  border: 1px dashed #d8cbb8;
  border-radius: 18px;
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  background: rgba(255, 252, 247, .7);
}
.drop.over {
  border-color: var(--accent);
  color: var(--text);
  background: #fffcf7;
}
.wx-tip {
  margin: 0 16px 10px;
  background: #fffcf7;
  color: var(--text);
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}
.wx-steps {
  background: #f4efe6;
  border-radius: 14px;
  padding: 12px;
  line-height: 1.7;
  font-size: 15px;
  color: var(--text);
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 10px 12px 48px;
}
@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 12px 16px 48px; }
}
@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(5, 1fr); }
}
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cell {
  position: relative;
  aspect-ratio: 1;
  background: var(--card);
  overflow: hidden;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--muted);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #f7f3ec;
  display: block;
}
.dl-btn {
  display: block;
  text-align: center;
  text-decoration: none;
  background: #fffcf7;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 8px;
  font-size: 14px;
  font-weight: 800;
}
.dl-btn.off {
  opacity: .4;
  pointer-events: none;
}
.cell.busy {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding: 8px;
  background: #f7f3ec;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  display: none;
  font-size: 15px;
}
.empty.show { display: block; }
.lightbox {
  position: fixed;
  inset: 0;
  background: #2a2622;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.lightbox[hidden] { display: none; }
.lb-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.lb-stage img, .lb-stage video {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  border-radius: 12px;
  transform-origin: center center;
  will-change: transform;
  cursor: grab;
}
.lb-stage img:active { cursor: grabbing; }
.lb-stage video { width: 100%; background: #1c1a18; cursor: default; }
.lb-close, .lb-nav {
  position: absolute;
  z-index: 2;
  border: 0;
  background: rgba(196, 120, 74, .92);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
}
.lb-close { top: calc(10px + env(safe-area-inset-top)); right: 10px; }
.lb-nav { top: 50%; transform: translateY(-50%); }
.lb-nav.prev { left: 8px; }
.lb-nav.next { right: 8px; }
.lb-tools {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px 4px;
  flex-wrap: wrap;
}
.lb-tools button, .lb-dl {
  appearance: none;
  border: 0;
  min-width: 44px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lb-meta {
  padding: 4px 16px calc(14px + env(safe-area-inset-bottom));
  color: #d9cbb8;
  font-size: 13px;
}
.lb-meta .hint { color: #b8aa98; font-size: 11px; margin-top: 2px; }
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: min(360px, 100%);
  background: #fffcf7;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin-bottom: 8px; }
.login-card p { color: var(--muted); font-size: 13px; }
.login-card input {
  width: 100%;
  margin: 16px 0;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 16px;
}
.login-card button, .upload-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
}
.login-card button {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 12px;
  font-weight: 800;
}
.error { color: var(--danger); min-height: 20px; margin-top: 10px; font-size: 13px; }
.cell .del {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 252, 247, .4);
  color: rgba(59, 51, 44, .45);
  font-size: 16px;
  box-shadow: none;
}
body.show-del .cell .del { display: block; }
