:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-muted: #f4f4f5;
  --text: #09090b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --primary: #18181b;
  --primary-hover: #27272a;
  --accent: #ff2442;
  --accent-soft: #fff1f2;
  --pro-gradient: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; }

.navbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1240px; margin: 0 auto; padding: 0 24px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand-icon {
  width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 16px;
}
.nav-links { display: flex; align-items: center; gap: 28px; font-size: 14px; color: var(--text-secondary); font-weight: 500; }
.nav-links a:hover { color: var(--text); }
.nav-actions { display: flex; align-items: center; gap: 12px; }
.status-pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--surface-muted); color: var(--text-secondary); }
.status-pill.is-pro { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%); color: #92400e; border: 1px solid #fcd34d; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: all 0.16s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-pro { background: var(--pro-gradient); color: #fff; box-shadow: 0 6px 18px -4px rgba(239, 68, 68, 0.35); }
.btn-pro:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-muted); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: 10px; }

.hero { max-width: 960px; margin: 0 auto; padding: 56px 24px 36px; text-align: center; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px; margin-bottom: 16px;
}
.hero h1 { font-size: clamp(28px, 4.5vw, 44px); font-weight: 800; line-height: 1.2; letter-spacing: -0.03em; margin-bottom: 14px; }
.hero p { font-size: 16px; color: var(--text-secondary); max-width: 620px; margin: 0 auto 24px; }
.hero-cta { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

.studio-section { max-width: 1240px; margin: 0 auto 72px; padding: 0 24px; }
.studio-grid { display: grid; grid-template-columns: 420px 1fr; gap: 24px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-md); }
.control-group { margin-bottom: 20px; }
.control-group:last-child { margin-bottom: 0; }
.control-label { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.control-hint { font-size: 12px; font-weight: 400; color: var(--text-muted); }

.ratio-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ratio-btn { padding: 8px 6px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); cursor: pointer; text-align: center; transition: all 0.15s; }
.ratio-btn span { display: block; font-size: 13px; font-weight: 700; }
.ratio-btn small { display: block; font-size: 11px; color: var(--text-muted); }
.ratio-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.ratio-btn.active small { color: rgba(255, 255, 255, 0.75); }

.template-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; max-height: 220px; overflow-y: auto; padding-right: 4px; }
.template-item {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; transition: all 0.15s; text-align: left;
}
.template-item:hover { border-color: #a1a1aa; }
.template-item.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); background: #fafafa; }
.template-swatch { width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0; border: 1px solid rgba(0, 0, 0, 0.08); }
.template-meta { min-width: 0; flex: 1; }
.template-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pro-tag { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 4px; background: var(--pro-gradient); color: #fff; margin-left: 4px; vertical-align: middle; }

.preset-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.preset-chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-muted); color: var(--text-secondary); cursor: pointer; transition: all 0.15s; }
.preset-chip:hover { background: #e4e4e7; color: var(--text); }
.input, .textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 14px; color: var(--text); background: var(--surface); transition: border-color 0.15s; margin-bottom: 8px;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--primary); }
.textarea { resize: vertical; min-height: 76px; }

.sliders-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.slider-box label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.slider-box input[type="range"] { width: 100%; accent-color: var(--primary); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-muted); font-size: 13px; margin-bottom: 10px; }
.segmented { display: inline-flex; background: var(--surface-muted); padding: 3px; border-radius: 8px; gap: 3px; }
.segmented button { border: none; background: transparent; padding: 5px 10px; font-size: 12px; font-weight: 600; border-radius: 6px; cursor: pointer; color: var(--text-secondary); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.preview-panel {
  position: sticky; top: 84px; display: flex; flex-direction: column; align-items: center;
  background: #f1f5f9; background-image: radial-gradient(#cbd5e1 1px, transparent 1px); background-size: 18px 18px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px 24px; min-height: 620px;
}
.preview-header { width: 100%; display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; font-size: 13px; color: var(--text-secondary); }
.canvas-wrapper { width: 100%; display: flex; justify-content: center; align-items: center; flex: 1; }
#previewCanvas { max-width: 100%; max-height: 540px; width: auto; height: auto; border-radius: 14px; box-shadow: var(--shadow-lg); background: #fff; }
.preview-actions { width: 100%; display: flex; justify-content: center; gap: 12px; margin-top: 22px; flex-wrap: wrap; }

.pricing-section { max-width: 1080px; margin: 0 auto 88px; padding: 0 24px; }
.section-head { text-align: center; margin-bottom: 40px; }
.section-head h2 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 8px; }
.section-head p { color: var(--text-secondary); font-size: 15px; }
.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.price-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px 24px; display: flex; flex-direction: column; position: relative; }
.price-card.featured { border: 2px solid var(--primary); box-shadow: var(--shadow-lg); }
.popular-badge { position: absolute; top: -12px; right: 20px; background: var(--pro-gradient); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.price-tier { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.price-amount { font-size: 36px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 4px; }
.price-amount span { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.price-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 20px; }
.feature-list { list-style: none; margin-bottom: 24px; flex: 1; }
.feature-list li { font-size: 14px; color: var(--text-secondary); padding: 6px 0; display: flex; align-items: center; gap: 8px; }
.feature-list li::before { content: "✓"; color: #10b981; font-weight: 800; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(9, 9, 11, 0.55); backdrop-filter: blur(4px); display: none; place-items: center; z-index: 100; padding: 20px; }
.modal-backdrop.open { display: grid; }
.modal-box { background: var(--surface); width: 100%; max-width: 460px; border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow-lg); position: relative; }
.modal-close { position: absolute; top: 16px; right: 16px; border: none; background: var(--surface-muted); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 16px; color: var(--text-secondary); }
.modal-box h3 { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.modal-sub { font-size: 14px; color: var(--text-secondary); margin-bottom: 18px; }
.pay-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.divider { text-align: center; font-size: 12px; color: var(--text-muted); margin: 16px 0; position: relative; }
.divider::before, .divider::after { content: ""; position: absolute; top: 50%; width: 34%; height: 1px; background: var(--border); }
.divider::before { left: 0; }
.divider::after { right: 0; }
.redeem-row { display: flex; gap: 8px; }
.redeem-row .input { margin-bottom: 0; }
.demo-tip { margin-top: 12px; font-size: 12px; color: var(--text-muted); background: var(--surface-muted); padding: 8px 12px; border-radius: 8px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--primary); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 200; box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer { border-top: 1px solid var(--border); padding: 32px 24px; text-align: center; font-size: 13px; color: var(--text-muted); }
.page-nav { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.page-nav button { border: none; background: var(--surface-muted); color: var(--text); width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-weight: 700; display: grid; place-items: center; }
.page-nav button:disabled { opacity: 0.4; cursor: not-allowed; }
.avatar-controls { display: flex; align-items: center; gap: 8px; }
.avatar-thumb { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); display: none; }
.avatar-thumb.visible { display: block; }
.trust-strip { max-width: 1080px; margin: 0 auto 64px; padding: 0 24px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.trust-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px 20px; }
.trust-card h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.trust-card p { font-size: 13px; color: var(--text-secondary); }

.admin-container { max-width: 1040px; margin: 32px auto 72px; padding: 0 24px; }
.admin-card { margin-bottom: 20px; }
.admin-card h2 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.admin-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }
.admin-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 20px; align-items: start; }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 5px; }
.admin-actions { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.code-output { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; background: #fafafa; }
.query-box { background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; font-size: 13px; line-height: 1.8; white-space: pre-wrap; min-height: 150px; color: var(--text); }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.pro-status-box { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; display: none; }
.pro-status-box.visible { display: block; }

@media (max-width: 960px) {
  .studio-grid, .admin-grid, .trust-strip { grid-template-columns: 1fr; }
  .preview-panel { position: static; min-height: 460px; }
  .pricing-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}
