:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #a855f7 100%);
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-md: 0 4px 16px -2px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px -8px rgba(79, 70, 229, .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(900px 480px at 8% -10%, rgba(99, 102, 241, .14), transparent 60%),
    radial-gradient(800px 420px at 100% 0%, rgba(168, 85, 247, .12), transparent 55%);
  background-repeat: no-repeat;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(226, 232, 240, .8);
  padding: 14px 0;
  margin-bottom: 28px;
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 1.2rem; letter-spacing: .02em; text-decoration: none;
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.logo svg { width: 24px; height: 24px; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a {
  margin-left: 4px; padding: 7px 14px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 500;
  transition: all .18s ease;
}
.nav-links a:hover { color: var(--primary); background: var(--primary-light); }

/* ---------- layout ---------- */
.main { min-height: 60vh; padding-bottom: 56px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  transition: box-shadow .2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
h1 { font-size: 1.5rem; font-weight: 800; margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 14px; }
.muted { color: var(--muted); font-size: .9rem; margin: 4px 0; }
code, .mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .84rem; word-break: break-all;
}

/* ---------- page head ---------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin: 4px 0 20px;
}
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted); font-size: .82rem; font-weight: 500;
}
.chip.accent { background: var(--primary-light); border-color: transparent; color: var(--primary-dark); }
.chip.warn { background: #fffbeb; border-color: transparent; color: #b45309; }

/* ---------- buttons ---------- */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border: none; border-radius: 12px;
  background: var(--gradient); background-size: 150% auto;
  color: #fff; font-size: .95rem; font-weight: 600; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  box-shadow: 0 2px 8px -2px rgba(79, 70, 229, .45);
  transition: all .18s ease;
}
button:hover, .btn:hover {
  background-position: right center;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}
button:active, .btn:active { transform: translateY(0); }
button:disabled { background: #cbd5e1; box-shadow: none; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: var(--card); color: var(--text);
  border: 1px solid var(--border); box-shadow: none;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { color: var(--primary); background: var(--primary-light); }
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff;
  box-shadow: 0 2px 8px -2px rgba(220, 38, 38, .4);
}
.btn-danger:hover { box-shadow: 0 8px 24px -6px rgba(220, 38, 38, .45); }
.btn-danger:disabled { background: #fca5a5; box-shadow: none; }
.btn-block { width: 100%; text-align: center; margin-top: 14px; }
.btn-lg { padding: 13px 28px; font-size: 1.02rem; border-radius: 14px; }
.btn-sm { padding: 6px 12px; font-size: .84rem; border-radius: 9px; }
.btn-link {
  background: none; border: none; padding: 0; color: var(--primary);
  font-size: .9rem; cursor: pointer; text-decoration: underline; box-shadow: none;
}
.btn-link:hover { color: var(--primary-dark); background: none; transform: none; }
.btn-link.danger { color: var(--danger); }

/* ---------- forms ---------- */
label { display: block; margin: 12px 0 5px; font-size: .88rem; font-weight: 600; color: #334155; }
input[type=text], input[type=password], input[type=email], input[type=number], select, textarea {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: 12px;
  font-size: 1rem; color: var(--text); background: #f8fafc;
  transition: all .18s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .1);
}
input[type=file] { font-size: .9rem; }

.alert {
  padding: 12px 16px; border-radius: 12px; margin-bottom: 14px;
  font-size: .92rem; font-weight: 500;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bbf7d0; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button, .tabs .tab, .tabs a {
  background: #eef2f7; color: var(--muted); box-shadow: none; padding: 8px 18px; border-radius: 999px;
  font-size: .9rem; text-decoration: none;
}
.tabs button.active, .tabs .tab.active, .tabs a.active {
  background: var(--gradient); color: #fff;
}
.tabs button:hover, .tabs .tab:hover, .tabs a:hover { color: var(--primary); transform: none; box-shadow: none; }
.tabs button.active:hover, .tabs .tab.active:hover, .tabs a.active:hover { color: #fff; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 11px 14px; text-align: left; vertical-align: top; }
thead th {
  background: #f8fafc; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .15s ease; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8faff; }
td a, .table-link { color: var(--primary); text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }

/* ---------- stats ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat-label { margin: 0; font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { margin: 6px 0 4px; font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.stat-value small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.progress { height: 8px; border-radius: 999px; background: #eef2f7; overflow: hidden; margin-top: 10px; }
.progress-bar {
  height: 100%; border-radius: 999px;
  background: var(--gradient);
  transition: width .4s ease; min-width: 2px;
}

/* ---------- dropzone ---------- */
.dropzone-form { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 36px 20px; cursor: pointer; text-align: center;
  border: 2px dashed #c7d2fe; border-radius: var(--radius);
  background: linear-gradient(180deg, #f8faff, #f4f6ff);
  transition: all .2s ease;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--primary); background: var(--primary-light); outline: none; }
.dropzone.dragover {
  border-color: var(--primary); background: var(--primary-light);
  transform: scale(1.01); box-shadow: var(--shadow-md);
}
.dropzone svg { width: 40px; height: 40px; opacity: .75; }
.dropzone .dz-title { font-weight: 700; font-size: 1rem; color: var(--text); }
.dropzone .dz-sub { font-size: .84rem; color: var(--muted); }

/* ---------- photo grid & management ---------- */
.photo-toolbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 16px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 12px;
}
.photo-toolbar label {
  display: inline-flex; align-items: center; gap: 8px; margin: 0;
  font-size: .9rem; font-weight: 600; color: #334155; cursor: pointer;
}
.photo-toolbar .spacer { flex: 1; }
#selected-count { color: var(--primary-dark); font-weight: 600; }

.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px;
}
.photo-item {
  position: relative; border-radius: 14px; overflow: hidden;
  background: var(--card); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: all .18s ease;
}
.photo-item:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.photo-item.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .18); }
.photo-thumb {
  display: block; width: 100%; height: 150px; object-fit: cover; background: #eef2f7;
  transition: transform .25s ease;
}
.photo-item:hover .photo-thumb { transform: scale(1.04); }
.photo-check {
  position: absolute; top: 10px; left: 10px; z-index: 3;
  width: 24px; height: 24px; accent-color: var(--primary);
  cursor: pointer;
}
.photo-item input[type=checkbox] { width: 24px; height: 24px; }
.photo-delete-btn {
  position: absolute; top: 8px; right: 8px; z-index: 3;
  width: 30px; height: 30px; padding: 0; border-radius: 9px;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px);
  color: #fff; font-size: .95rem; line-height: 1; box-shadow: none;
  opacity: 0; transition: all .18s ease; display: flex; align-items: center; justify-content: center;
}
.photo-item:hover .photo-delete-btn { opacity: 1; }
.photo-delete-btn:hover { background: var(--danger); transform: none; box-shadow: none; }
.photo-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px 10px; background: var(--card);
}
.photo-meta p { margin: 0; }
.photo-name {
  font-size: .8rem; font-weight: 600; color: #334155;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.photo-size { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .icon { font-size: 2.2rem; opacity: .5; margin-bottom: 8px; }
.meta-line { font-size: 0.8rem; color: var(--muted); margin: 16px 4px 0; line-height: 1.8; }
.meta-line.meta-top { margin: 0 4px 14px; }

#upload-progress { margin-top: 16px; }
.progress-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; margin-bottom: 8px; color: #374151; }
.progress-head #progress-pct { font-weight: 600; color: #6d5ef5; }
.progress-track { width: 100%; height: 10px; background: #eef0f6; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #6d5ef5, #8b5cf6); border-radius: 999px; transition: width 0.15s ease; }
.progress-sub { margin-top: 6px; font-size: 0.8rem; color: var(--muted); text-align: right; }

.fab {
  position: fixed;
  right: 20px;
  bottom: 20vh;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6d5ef5, #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(109, 94, 245, 0.45);
  z-index: 50;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(109, 94, 245, 0.55); }
.fab:active { transform: scale(0.94); }
.fab svg { width: 26px; height: 26px; }

/* ---------- gallery (guest) ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.gallery a {
  position: relative; display: block; border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  transition: all .2s ease;
  cursor: zoom-in;
}
.gallery a:hover { box-shadow: var(--shadow-md); transform: translateY(-3px); }
.gallery img {
  width: 100%; height: 180px; object-fit: cover; display: block; background: #eef2f7;
  transition: transform .25s ease;
}
.gallery a:hover img { transform: scale(1.05); }
.gallery a::after {
  content: "点击查看"; position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .45); color: #fff; font-size: .85rem; font-weight: 600;
  opacity: 0; transition: opacity .2s ease;
}
.gallery a:hover::after { opacity: 1; }

/* ---------- 灯箱 / Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 9999;
  display: none;
  align-items: center; justify-content: center;
}
.lightbox.open { display: flex; }

.lightbox-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 10, 18, .86);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: zoom-out;
}

.lightbox-close {
  position: absolute; top: 16px; right: 16px; z-index: 3;
  width: 44px; height: 44px; border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .5); color: #fff; font-size: 28px; line-height: 1;
  cursor: pointer; transition: background .18s ease;
}
.lightbox-close:hover { background: rgba(0, 0, 0, .75); }

.lightbox-prev, .lightbox-next {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 3;
  width: 52px; height: 72px; border: none;
  background: rgba(0, 0, 0, .45); color: #fff; font-size: 40px; line-height: 1;
  cursor: pointer; border-radius: 10px;
  transition: background .18s ease;
}
.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }
.lightbox-prev:hover, .lightbox-next:hover { background: rgba(0, 0, 0, .75); }

.lightbox-stage {
  position: relative; z-index: 2; margin: 0;
  display: flex; flex-direction: column; align-items: center;
  width: 100%;
}

.lightbox-viewport {
  position: relative;
  width: 100%;
  max-height: calc(100vh - 160px);
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.lightbox-track {
  display: flex;
  width: 100%;
  will-change: transform;
}
.lightbox-slide {
  flex: 0 0 100%;
  min-width: 0;
  display: flex; align-items: center; justify-content: center;
}
.lightbox-img {
  display: block;
  max-width: 96vw; max-height: calc(100vh - 160px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .55);
  background: #111;
  -webkit-user-drag: none;
  /* 不要设 pointer-events:none —— 微信长按保存依赖图片本身接收触摸事件 */
}
.lightbox-viewport.loading .lightbox-img { opacity: .5; }
.lightbox-spinner {
  position: absolute; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  pointer-events: none;
}
.lightbox-viewport.loading .lightbox-spinner { display: flex; }
.lightbox-spinner::after {
  content: ""; width: 36px; height: 36px;
  border: 3px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lb-spin .8s linear infinite;
}
@keyframes lb-spin { to { transform: rotate(360deg); } }

.lightbox-caption {
  margin-top: 10px;
  color: rgba(255, 255, 255, .85);
  font-size: .9rem;
  max-width: 80vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: center;
}
.lightbox-name { display: inline; }

.lightbox-toolbar {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 14px;
  padding: 8px 8px 8px 16px;
  background: rgba(0, 0, 0, .55);
  border-radius: 999px;
  color: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.lightbox-counter { font-size: .9rem; opacity: .9; font-variant-numeric: tabular-nums; }
.lightbox-download {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--gradient);
  color: #fff !important;
  text-decoration: none; font-size: .88rem; font-weight: 600;
  cursor: pointer; transition: opacity .18s ease;
}
.lightbox-download:hover { opacity: .9; }
.lightbox-download:active { transform: scale(.97); }

@media (max-width: 640px) {
  .lightbox-close { width: 38px; height: 38px; font-size: 22px; top: 10px; right: 10px; }
  .lightbox-prev, .lightbox-next { width: 40px; height: 56px; font-size: 30px; }
  .lightbox-prev { left: 6px; }
  .lightbox-next { right: 6px; }
  .lightbox-img, .lightbox-viewport {
    max-height: calc(100vh - 170px);
  }
}

/* ---------- QR ---------- */
.qr-card { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.qr-card .qr-side { flex: 1 1 260px; min-width: 240px; }
.qr-card .qr-main { flex: 1 1 300px; }
.qr-frame {
  display: inline-block; padding: 12px; border-radius: 18px;
  background: var(--gradient);
  box-shadow: var(--shadow-md);
}
.qr-frame img {
  display: block; max-width: 240px; width: 100%; border-radius: 10px; background: #fff;
}
.qr-box { text-align: center; padding: 16px; }
.qr-box img { max-width: 260px; width: 100%; }
.link-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; margin: 12px 0;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 12px;
}
.link-row .mono { flex: 1; color: var(--primary-dark); }

/* ---------- group rows (dashboard) ---------- */
.group-list { display: flex; flex-direction: column; gap: 12px; }
.group-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 18px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--card); text-decoration: none; color: var(--text);
  box-shadow: var(--shadow-sm); transition: all .18s ease;
}
.group-row:hover { border-color: #c7d2fe; box-shadow: var(--shadow-md); transform: translateY(-2px); }
.group-row .g-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.group-row .g-icon svg { width: 22px; height: 22px; }
.group-row .g-body { flex: 1; min-width: 180px; }
.group-row .g-title { font-weight: 700; font-size: .98rem; margin: 0; }
.group-row .g-meta { font-size: .8rem; color: var(--muted); margin: 2px 0 0; }
.group-row .g-arrow { color: var(--muted); font-size: 1.2rem; transition: all .18s ease; }
.group-row:hover .g-arrow { color: var(--primary); transform: translateX(3px); }
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .02em;
  background: var(--primary-light); color: var(--primary-dark);
}
.badge.outline { background: transparent; border: 1px solid var(--border); color: var(--muted); }

/* ---------- footer ---------- */
.site-footer {
  text-align: center; padding: 24px 0 32px; color: var(--muted);
  border-top: 1px solid var(--border);
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .site-header .wrap { flex-direction: column; align-items: flex-start; }
  .nav-links { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .nav-links a { margin-left: 0; }
  .page-head { flex-direction: column; }
  .card { padding: 18px; border-radius: 14px; }
  table { font-size: .82rem; }
  th, td { padding: 8px 10px; }
  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .photo-thumb { height: 120px; }
  .qr-card { flex-direction: column; align-items: stretch; }
  .qr-card .qr-side { text-align: center; }
}
