/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f2f5f9;
  color: #1e293b;
  font-size: 14px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; outline: none; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

:root {
  --primary: #4f6ef7;
  --primary-dark: #3b5bdb;
  --primary-soft: rgba(79, 110, 247, .12);
  --accent: #7048e8;
  --accent-2: #9c36b5;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --bg: #f2f5f9;
  --card: #ffffff;
  --line: #eef2f7;
  --border: #e2e8f0;
  --danger: #e03131;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .04);
  --shadow: 0 4px 12px rgba(15, 23, 42, .06), 0 12px 32px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .10), 0 24px 64px rgba(15, 23, 42, .12);
  --gradient: linear-gradient(135deg, #4f6ef7 0%, #7048e8 50%, #9c36b5 100%);
  --gradient-soft: linear-gradient(135deg, rgba(79,110,247,.08), rgba(112,72,232,.08), rgba(156,54,181,.08));
}

/* ============ 通用视图 ============ */
.view { display: none; min-height: 100vh; }
.view.active { display: block; }

/* ============ 登录页 ============ */
#view-login {
  background: linear-gradient(160deg, #3b5bdb 0%, #5f3dc4 55%, #9c36b5 100%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 22px 20px;
  position: relative;
  overflow: hidden;
}
/* 装饰光斑 */
#view-login::before,
#view-login::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .35;
  pointer-events: none;
}
#view-login::before {
  width: 280px; height: 280px;
  background: #fff;
  top: -80px; left: -60px;
}
#view-login::after {
  width: 360px; height: 360px;
  background: #f0abfc;
  bottom: -120px; right: -100px;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 36px 26px 28px;
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .28);
  text-align: center;
  z-index: 1;
}
.login-logo {
  width: 72px; height: 72px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px;
  box-shadow: 0 10px 24px rgba(112, 72, 232, .4);
  color: #fff;
}
.login-title { font-size: 22px; font-weight: 800; letter-spacing: 1px; }
.login-sub { font-size: 13px; color: var(--text-2); margin: 8px 0 26px; }

.divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-3); font-size: 12px;
  margin: 20px 0 14px;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.dev-tip { font-size: 12px; color: var(--text-3); margin-bottom: 10px; }
.dev-users { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.dev-user {
  padding: 8px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 13px; color: var(--text);
  transition: all .15s;
}
.dev-user:active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); transform: scale(.97); }
.dev-add {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px dashed var(--border);
  background: transparent;
  font-size: 13px; color: var(--text-2);
}

.admin-login-link {
  margin-top: 18px;
  font-size: 13px; color: var(--text-3);
  text-decoration: underline;
  cursor: pointer;
}
.admin-login { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.admin-login input {
  height: 46px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0 14px;
  font-size: 14px;
  background: #fff;
  transition: border-color .15s;
}
.admin-login input:focus { border-color: var(--primary); }

.btn {
  height: 46px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  transition: transform .12s, box-shadow .15s, opacity .2s;
  padding: 0 20px;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 8px 20px rgba(112, 72, 232, .32);
}
.btn-primary:active { opacity: .9; }
.btn-ghost {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-ghost:active { background: var(--line); }
.btn-danger {
  background: #fff;
  color: var(--danger);
  border: 1.5px solid #fecaca;
}
.login-foot { color: rgba(255, 255, 255, .85); font-size: 12px; margin-top: 22px; letter-spacing: 1px; z-index: 1; position: relative; }

/* ============ 配置后台（活动列表/编辑） ============ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--line);
}
.app-header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.app-title { font-size: 17px; font-weight: 800; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.app-title .badge {
  font-size: 11px; font-weight: 600; padding: 3px 8px;
  background: var(--gradient);
  color: #fff; border-radius: 6px;
  letter-spacing: .5px;
}
.app-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); }
.app-user .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.logout-btn {
  font-size: 13px; color: var(--text-2);
  padding: 6px 10px;
  border-radius: 8px;
}
.logout-btn:active { background: var(--line); }

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 20px 18px 100px;
}

.section-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 14px;
}
.section-title { font-size: 15px; font-weight: 700; }
.section-hint { font-size: 12px; color: var(--text-3); }

/* 活动列表 */
.activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.activity-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .2s;
  display: flex; flex-direction: column;
}
.activity-card:active { transform: scale(.99); box-shadow: var(--shadow); }
.activity-thumb {
  aspect-ratio: 9 / 16;
  background: var(--gradient-soft);
  position: relative;
  overflow: hidden;
}
.activity-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.activity-thumb .empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 13px;
}
.status-tag {
  position: absolute; top: 10px; left: 10px;
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  font-weight: 600;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.status-tag.on  { background: rgba(16, 185, 129, .85); color: #fff; }
.status-tag.off { background: rgba(100, 116, 139, .85); color: #fff; }

.activity-body { padding: 12px 14px 14px; }
.activity-title { font-size: 15px; font-weight: 700; line-height: 1.3; }
.activity-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.activity-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.activity-actions .mini-btn {
  flex: 1;
  font-size: 12px; padding: 7px 8px;
  border-radius: 8px;
  background: var(--line);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}
.activity-actions .mini-btn:active { background: #d9e1ee; }
.activity-actions .mini-btn.primary { background: var(--primary-soft); color: var(--primary); }
.activity-actions .mini-btn.danger { background: #fee2e2; color: var(--danger); }

.fab {
  position: fixed;
  right: 20px; bottom: 24px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  font-size: 28px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 28px rgba(112, 72, 232, .45);
  z-index: 40;
}
.fab:active { transform: scale(.95); }

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-state .emoji { font-size: 48px; margin-bottom: 12px; }
.empty-state .tip { font-size: 13px; margin-top: 6px; }

/* ============ 活动编辑页 ============ */
.editor-page {
  padding-bottom: 120px;
}
.editor-section {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.editor-section h3 {
  font-size: 14px; font-weight: 700;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.editor-section h3 .num {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--gradient);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 12px; color: var(--text-2);
  margin-bottom: 6px; font-weight: 600;
}
.field input[type=text],
.field input[type=date],
.field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  background: #fafbfd;
  transition: border-color .15s, background .15s;
}
.field input:focus, .field textarea:focus { border-color: var(--primary); background: #fff; }
.field textarea { min-height: 80px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 上传区 */
.uploader {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 26px 16px;
  text-align: center;
  background: #fafbfd;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.uploader:active { border-color: var(--primary); background: var(--primary-soft); }
.uploader .icon { font-size: 36px; margin-bottom: 6px; }
.uploader .label { font-size: 13px; color: var(--text); font-weight: 600; }
.uploader .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.uploader-preview {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--line);
}
.uploader-preview img { width: 100%; max-height: 360px; object-fit: contain; background: #fafbfd; }
.uploader-preview .remove {
  position: absolute; top: 8px; right: 8px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  backdrop-filter: blur(6px);
}

/* 样式选择 */
.style-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.style-item {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  text-align: center;
  background: #fff;
  transition: all .15s;
}
.style-item .preview {
  width: 100%; aspect-ratio: 1;
  border-radius: 6px;
  background: var(--line);
  margin-bottom: 6px;
}
.style-item .preview.s1 { background: linear-gradient(135deg, #1f2937, #4f6ef7); }
.style-item .preview.s2 { background: linear-gradient(135deg, #fbbf24, #f43f5e); }
.style-item .preview.s3 { background: linear-gradient(135deg, #10b981, #4f6ef7); }
.style-item .preview.s4 { background: linear-gradient(135deg, #8b5cf6, #ec4899); }
.style-item .preview.s5 { background: linear-gradient(135deg, #0ea5e9, #6366f1); }
.style-item .preview.s6 { background: linear-gradient(135deg, #f43f5e, #fb923c); }
.style-item .name { font-size: 12px; color: var(--text); }
.style-item.active { border-color: var(--primary); background: var(--primary-soft); }
.style-item.active .name { color: var(--primary); font-weight: 600; }

/* 海报预览 */
.poster-preview {
  background: var(--gradient-soft);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.poster-preview img {
  max-width: 240px;
  margin: 0 auto;
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.poster-preview .label { font-size: 12px; color: var(--text-2); margin-bottom: 10px; font-weight: 600; }

.bottom-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 12px 18px;
  z-index: 30;
  display: flex; gap: 10px;
}
.bottom-bar .btn { flex: 1; }
.safe-bottom { height: env(safe-area-inset-bottom, 0px); }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%; bottom: 100px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, .92);
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  max-width: 80vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ============ Modal ============ */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-mask.show { display: flex; }
.modal {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  max-height: 86vh;
  overflow-y: auto;
}
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 14px; }
.modal .modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal .modal-actions .btn { flex: 1; }

/* ============ 分享页 ============ */
.share-page {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, #f5f3ff 0%, #fdf2f8 100%);
  padding: 24px 18px 80px;
}
.share-hero {
  text-align: center;
  padding: 20px 12px 24px;
}
.share-hero .pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(79, 110, 247, .12);
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.share-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.3;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 6px;
}
.share-time {
  font-size: 12px; color: var(--text-2);
}

.share-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  margin: 0 auto 18px;
  max-width: 420px;
}
.share-poster-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--gradient-soft);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: default;
}
.share-poster-wrap img {
  width: 100%;
  display: block;
  /* 微信长按图片识别的关键：不要阻止默认长按行为 */
  pointer-events: auto;
}
.longpress-hint {
  position: absolute;
  top: 12px; left: 12px;
  background: rgba(15, 23, 42, .65);
  color: #fff;
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 4px;
  pointer-events: none;
  animation: float 2.4s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.copy-block {
  background: #fafbfd;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  position: relative;
}

.share-actions {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: flex; gap: 10px;
  z-index: 30;
}
.share-actions .btn { flex: 1; }

.share-loading, .share-error {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px;
  text-align: center;
}
.share-loading .spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.share-error .emoji { font-size: 56px; margin-bottom: 12px; }
.share-error .tip { font-size: 14px; color: var(--text-2); }
