:root {
  --ink: #0f172a;
  --ink-soft: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --brand: #6366f1;
  --brand-dark: #4f46e5;
  --brand-soft: #eef2ff;
  --accent: #f97316;
  --danger: #e11d48;
  --success: #16a34a;
  --shadow-sm: 0 2px 10px rgba(15, 23, 42, .06);
  --shadow-md: 0 16px 44px rgba(15, 23, 42, .12);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface-soft);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { background: linear-gradient(135deg, var(--brand), #8b5cf6); }
.btn-primary:hover { box-shadow: 0 8px 22px rgba(99, 102, 241, .3); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn-danger { background: #fff1f2; color: var(--danger); border-color: #fecdd3; }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.btn-lg { min-height: 48px; padding: 0 24px; font-size: 15px; border-radius: 12px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink-soft);
}
.icon-btn:hover { background: var(--surface-soft); color: var(--ink); }
.icon-btn.danger { color: var(--danger); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field input, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 10px 12px; color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 88px; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}
.field-hint { font-size: 12px; color: var(--muted); }

.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--surface-soft); color: var(--ink-soft);
}
.badge-live { background: #fff1f2; color: #e11d48; }
.badge-live::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: #e11d48;
  box-shadow: 0 0 0 4px rgba(225, 29, 72, .14); animation: pulse 1.8s infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(225, 29, 72, 0); } }

.toast-stack { position: fixed; z-index: 9999; top: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  min-width: 220px; max-width: min(90vw, 520px); padding: 12px 16px; border-radius: 12px;
  background: rgba(15, 23, 42, .94); color: #fff; font-size: 14px; box-shadow: var(--shadow-md);
  animation: toastIn .2s ease both;
}
.toast.error { background: #9f1239; }
.toast.success { background: #15803d; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

.modal-mask {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(15, 23, 42, .56); backdrop-filter: blur(4px);
  animation: fadeIn .16s ease both;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(100%, 620px); max-height: min(90vh, 900px); overflow: auto; background: #fff;
  border-radius: 20px; box-shadow: 0 30px 80px rgba(15, 23, 42, .3);
}
.modal.modal-wide { width: min(100%, 1080px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); background: var(--surface-soft); border-radius: 0 0 20px 20px; }

.lightbox {
  position: fixed; inset: 0; z-index: 2000; display: flex; flex-direction: column;
  background: rgba(8, 11, 20, .96); color: #fff;
}
.lightbox-top, .lightbox-bottom {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 20px; flex: 0 0 auto;
}
.lightbox-stage { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 20px; }
.lightbox-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 46px; height: 46px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.1); color: #fff; font-size: 24px;
}
.lightbox-nav.prev { left: 18px; }
.lightbox-nav.next { right: 18px; }
.lightbox-nav:hover { background: rgba(255,255,255,.2); }
.lightbox-count { font-size: 14px; color: rgba(255,255,255,.7); }
.lightbox-name { font-size: 14px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox .icon-btn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: #fff; }
.lightbox .icon-btn:hover { background: rgba(255,255,255,.2); color: #fff; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 52px 20px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink-soft); font-size: 15px; }
.empty-state svg { opacity: .5; }

.qr-box { display: inline-flex; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); }
.qr-box img { width: 168px; height: 168px; image-rendering: pixelated; }

.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface-soft); color: var(--ink-soft); font-size: 13px; }

@media (max-width: 640px) {
  .modal-mask { padding: 10px; align-items: flex-end; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92vh; }
  .modal-body { padding: 18px; }
  .lightbox-nav { width: 38px; height: 38px; }
  .lightbox-nav.prev { left: 8px; }
  .lightbox-nav.next { right: 8px; }
}
