/* =========================================================
   企业微信二维码主页 · 设计系统
   纸白 / 墨黑 / 墨绿，极简高级
   ========================================================= */

:root {
  --paper: #faf9f6;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --ink: #141412;
  --ink-2: #5a5852;
  --ink-3: #8e8b83;
  --line: #e7e3da;
  --line-2: #f0ede6;
  --accent: #123d2c;
  --accent-2: #1b5540;
  --accent-soft: #edf2ee;
  --danger: #9b2c1f;
  --ok: #1f6b4a;
  --radius: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 20, 18, 0.04);
  --shadow-lg: 0 28px 64px -34px rgba(20, 20, 18, 0.28), 0 2px 8px rgba(20, 20, 18, 0.04);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --serif: ui-serif, "Songti SC", "Noto Serif SC", Georgia, serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(880px 520px at 80% -10%, #f4f2ea 0%, rgba(244, 242, 234, 0) 62%),
    radial-gradient(680px 420px at 4% 104%, #f5f3ed 0%, rgba(245, 243, 237, 0) 66%);
}

button { font: inherit; color: inherit; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 通用容器 ---------- */

.page {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.shell {
  width: 100%;
  max-width: 1016px;
  margin: 0 auto;
  padding: 56px 28px 80px;
  flex: 1;
  display: flex;
  align-items: center;
}

/* ---------- 前台：主卡片 ---------- */

.hero {
  width: 100%;
  display: grid;
  grid-template-columns: 1.02fr 0.98fr;
  grid-template-areas:
    "copy qr"
    "foot qr";
  column-gap: 60px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 64px 60px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.6s var(--ease) both;
}

.hero-copy { grid-area: copy; align-self: center; }
.hero-qr { grid-area: qr; align-self: center; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 22px;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  text-transform: none;
}

.eyebrow .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.title {
  margin: 0;
  font-size: 40px;
  line-height: 1.18;
  letter-spacing: -0.022em;
  font-weight: 600;
}

.subtitle {
  margin: 18px 0 0;
  font-size: 15px;
  line-height: 1.85;
  color: var(--ink-2);
  max-width: 40em;
}

.subtitle:empty { display: none; }

.id-block {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--line-2);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.id-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.id-value {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.id-value.is-empty { color: var(--ink-3); font-weight: 400; }

.actions {
  margin-top: 34px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.footnote {
  grid-area: foot;
  margin: 30px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}

/* ---------- 按钮 ---------- */

.btn {
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 20px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease),
    border-color 0.18s var(--ease), opacity 0.18s var(--ease), box-shadow 0.18s var(--ease);
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: translateY(1px); }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(18, 61, 44, 0.24);
}
.btn-primary:not([disabled]):hover { background: var(--accent-2); }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:not([disabled]):hover { border-color: #d6d1c6; background: var(--surface-2); }

.btn-quiet {
  background: transparent;
  color: var(--ink-2);
  padding: 0 12px;
  height: 38px;
  font-size: 13px;
}
.btn-quiet:hover { color: var(--ink); }

.btn-sm { height: 34px; padding: 0 13px; font-size: 12.5px; border-radius: 8px; }

.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.6px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}
.btn-ghost.is-busy::after { border-color: rgba(20, 20, 18, 0.2); border-top-color: var(--ink); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 前台：二维码 ---------- */

.hero-qr { display: flex; flex-direction: column; align-items: center; }

.qr-frame {
  position: relative;
  width: 100%;
  max-width: 288px;
  aspect-ratio: 1;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.qr-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 4px;
  background: #fff;
}

.qr-frame.is-empty { background: var(--surface-2); }

.qr-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}

.qr-skeleton {
  position: absolute;
  inset: 12px;
  border-radius: 4px;
  background: linear-gradient(100deg, #f3f1ea 20%, #faf9f5 40%, #f3f1ea 60%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer {
  from { background-position: 140% 0; }
  to { background-position: -40% 0; }
}

.qr-hint {
  margin: 18px 0 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  text-align: center;
}

/* ---------- 移动端吸底操作条 ---------- */

.mobile-bar { display: none; }

/* ---------- Toast ---------- */

.toast-root {
  position: fixed;
  z-index: 90;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  background: rgba(20, 20, 18, 0.94);
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.01em;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.24s var(--ease) both;
  backdrop-filter: blur(6px);
}

.toast.is-out { animation: toast-out 0.22s var(--ease) both; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px) scale(0.98); }
}

/* ---------- 图片预览层（微信内保存） ---------- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(14, 14, 12, 0.62);
  backdrop-filter: blur(3px);
  animation: fade 0.2s var(--ease) both;
}

.sheet[hidden] { display: none; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-inner {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: 18px;
  padding: 20px 20px 22px;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, 0.55);
  animation: rise 0.3s var(--ease) both;
  text-align: center;
  max-height: 92dvh;
  overflow: auto;
}

.sheet-inner img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  display: block;
}

.sheet-title {
  margin: 14px 0 4px;
  font-size: 14px;
  font-weight: 600;
}

.sheet-desc { margin: 0 0 16px; font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }

.sheet-actions { display: flex; justify-content: center; gap: 10px; }

/* ---------- 后台：顶栏 ---------- */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line-2);
  background: rgba(250, 249, 246, 0.86);
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--ink-3); letter-spacing: 0.1em; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }

/* ---------- 后台：登录 ---------- */

.auth-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px 72px;
  position: relative;
  z-index: 1;
}

.auth-card {
  width: 100%;
  max-width: 412px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 40px 36px 34px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.5s var(--ease) both;
}

.auth-title { margin: 0; font-size: 24px; letter-spacing: -0.02em; font-weight: 600; }
.auth-desc { margin: 8px 0 26px; font-size: 13px; color: var(--ink-3); line-height: 1.7; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  border-radius: 10px;
  margin-bottom: 26px;
}

.tab {
  flex: 1;
  height: 36px;
  border: 0;
  background: transparent;
  border-radius: 7px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.18s var(--ease);
}

.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.field { margin-bottom: 18px; }

.field-label {
  display: block;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  margin-bottom: 8px;
}

.input,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 0 14px;
  height: 46px;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
  font-family: inherit;
}

.textarea { height: auto; padding: 12px 14px; resize: vertical; min-height: 88px; line-height: 1.7; }

.input::placeholder,
.textarea::placeholder { color: #b6b2a9; }

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(18, 61, 44, 0.09);
}

.field-row { display: flex; gap: 10px; align-items: stretch; }
.field-row .input { flex: 1; }

.hint { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); line-height: 1.7; }

.alert {
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 12.5px;
  line-height: 1.7;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert[hidden] { display: none; }
.alert-error { background: #fbf1ef; border-color: #f0d9d4; color: var(--danger); }
.alert-ok { background: var(--accent-soft); border-color: #d9e7dd; color: var(--ok); }

.auth-foot {
  margin: 22px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.8;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
}
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 后台：工作台 ---------- */

.workspace {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 40px 28px 140px;
}

.page-head { margin-bottom: 30px; }
.page-title { margin: 0; font-size: 26px; letter-spacing: -0.02em; font-weight: 600; }
.page-desc { margin: 8px 0 0; font-size: 13px; color: var(--ink-3); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 20px; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-title { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.card-meta { font-size: 11.5px; color: var(--ink-3); }

/* 上传区 */
.dropzone {
  position: relative;
  border: 1px dashed #dcd7cb;
  border-radius: 12px;
  background: var(--surface-2);
  min-height: 288px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease);
  text-align: center;
  overflow: hidden;
}

.dropzone:hover,
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }

.dropzone input[type="file"] { display: none; }

.dz-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.dz-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--ink-2);
}
.dz-title { font-size: 13px; font-weight: 500; }
.dz-desc { font-size: 12px; color: var(--ink-3); line-height: 1.7; }

.dz-preview { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.dz-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.dz-tools {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.dz-note { font-size: 11.5px; color: var(--ink-3); }

/* 管理员列表 */
.member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
  font-size: 13px;
}
.member:last-child { border-bottom: 0; }
.member-mail { color: var(--ink); word-break: break-all; }
.member-role {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
}

.invite-box {
  margin-top: 14px;
  border: 1px dashed #d9d4c7;
  border-radius: 10px;
  padding: 14px 16px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.invite-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 19px;
  letter-spacing: 0.16em;
  font-weight: 600;
}

/* 底部保存条 */
.savebar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: rgba(250, 249, 246, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 14px 28px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.savebar-inner {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.save-state { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.save-state .pip { width: 6px; height: 6px; border-radius: 50%; background: #cdc8bc; }
.save-state.is-dirty { color: var(--ink-2); }
.save-state.is-dirty .pip { background: #c08a2e; }

/* 空/错误态 */
.state {
  text-align: center;
  padding: 76px 24px;
}
.state-title { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.state-desc { font-size: 13px; color: var(--ink-3); margin: 0 0 20px; line-height: 1.8; }

[hidden] { display: none !important; }

/* 本地预览角标（仅 ?preview=1 出现） */
.preview-badge {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 95;
  background: rgba(20, 20, 18, 0.86);
  color: #fff;
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 6px 12px;
  border-radius: 999px;
  pointer-events: none;
}

/* ---------- 响应式 ---------- */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    grid-template-areas: "copy" "qr" "foot";
    row-gap: 40px;
    column-gap: 0;
    padding: 48px 40px;
  }
  .hero-qr { order: 2; }
  .grid-2 { grid-template-columns: 1fr; }
  .shell { padding: 40px 20px 64px; align-items: flex-start; }
}

@media (max-width: 720px) {
  .shell { padding: 24px 16px 128px; }
  .hero {
    padding: 32px 22px 30px;
    border-radius: 20px;
    gap: 30px;
    box-shadow: 0 18px 44px -30px rgba(20, 20, 18, 0.3);
  }
  .title { font-size: 27px; letter-spacing: -0.02em; }
  .subtitle { font-size: 14px; margin-top: 14px; }
  .eyebrow { margin-bottom: 16px; }
  .id-block { margin-top: 26px; padding-top: 18px; }
  .actions { display: none; }
  .qr-frame { max-width: 262px; }
  .footnote { font-size: 11.5px; margin-top: 20px; }

  .mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: rgba(250, 249, 246, 0.9);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
  }
  .mobile-bar .btn { height: 48px; font-size: 14px; width: 100%; }

  .topbar { padding: 16px 18px; }
  .workspace { padding: 26px 16px 132px; }
  .auth-wrap { padding: 28px 16px 48px; }
  .auth-card { padding: 30px 22px 26px; border-radius: 18px; }
  .page-title { font-size: 22px; }
  .card { padding: 20px; }
  .savebar { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .savebar .btn { height: 44px; }
  .save-state {
    font-size: 11.5px;
    max-width: 46%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .save-state #saveStateText { overflow: hidden; text-overflow: ellipsis; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
