:root {
  --bg: #e8eef5;
  --card: #f7f4ef;
  --ink: #243246;
  --muted: #6b7c8f;
  --line: rgba(36, 50, 70, 0.1);
  --accent: #243849;
  --accent-soft: #3a5a70;
  --ok: #0f766e;
  --radius: 16px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --shadow: 0 4px 16px rgba(40, 60, 90, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(165deg, #dce8f4 0%, #b9cde3 45%, #8aa4c0 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 440px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

.site-back {
  display: inline-block;
  margin-bottom: 10px;
  color: #3d5570;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

.top h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.sub {
  margin: 4px 0 14px;
  font-size: 0.82rem;
  color: #3d5570;
  line-height: 1.45;
}

.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.panel-title {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  gap: 8px;
}

.panel-title-row .panel-title { margin: 0; }

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: #3d5570;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.custom-size {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.custom-size label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

.custom-size input {
  width: 100%;
  padding: 8px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font: inherit;
  background: #fff;
}

.hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.hint.center { text-align: center; }

.bg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.bg-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.bg-swatch.on {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  color: #3d5570;
  line-height: 1.4;
}

.check input { margin-top: 2px; }

.stage {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
  background: #d9e2ec;
  border-radius: 14px;
  min-height: 280px;
  overflow: hidden;
}

.frame {
  position: relative;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  touch-action: none;
}

.frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.guide {
  pointer-events: none;
  position: absolute;
  inset: 8%;
  border: 1px dashed rgba(255, 255, 255, 0.55);
  border-radius: 50% / 42%;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.12);
}

#video {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#zoom {
  width: 100%;
  margin: 12px 0 10px;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

button.primary, .file-btn.primary {
  appearance: none;
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

button.ghost, .file-btn {
  appearance: none;
  border: 1px solid #d7dde5;
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.file-btn {
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.wide { width: 100%; }

/* 底部状态条：普通提示也够醒目 */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  width: min(420px, calc(100% - 24px));
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #1f3344;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: 0 10px 28px rgba(20, 40, 60, 0.35);
}

.toast[hidden] { display: none !important; }

.toast-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: #f0d28a;
  flex-shrink: 0;
}

.toast.ok { background: #0f5c56; }
.toast.ok .toast-dot { background: #6ee7b7; }
.toast.err { background: #8b3a2a; }
.toast.err .toast-dot { background: #fdba74; }

/* 处理中全屏遮罩 */
.busy-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 35, 50, 0.55);
  display: grid;
  place-items: center;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.busy-mask[hidden] { display: none !important; }

.busy-card {
  width: min(320px, 100%);
  background: #fff;
  border-radius: 18px;
  padding: 28px 22px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 3px solid #d7e0ea;
  border-top-color: #243849;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.busy-title {
  margin: 0 0 8px;
  font-size: 1.1rem;
  font-weight: 800;
  color: #243246;
}

.busy-sub {
  margin: 0;
  font-size: 0.85rem;
  color: #6b7c8f;
  line-height: 1.45;
}

body.busy {
  overflow: hidden;
}
