:root {
  --bg: #f3f4f8;
  --ink: #111318;
  --muted: #6d7480;
  --line: rgba(20, 24, 31, 0.1);
  --card: #ffffff;
  --glass: rgba(255, 255, 255, 0.82);
  --blue: #007aff;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9f0a;
  --purple: #af52de;
  --shadow: 0 24px 70px rgba(22, 28, 38, 0.16);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 56px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 10%, rgba(0, 122, 255, 0.16), transparent 29%),
    radial-gradient(circle at 86% 18%, rgba(52, 199, 89, 0.13), transparent 27%),
    linear-gradient(135deg, #fbfcff 0%, #edf0f6 52%, #f8f4ef 100%);
  letter-spacing: 0;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button, input, textarea { font: inherit; }
button { border: 0; cursor: pointer; }

.stage {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

.phone-shell {
  width: min(430px, 100%);
  padding: 12px;
  background: #181b20;
  border-radius: 48px;
  box-shadow: 0 28px 90px rgba(18, 22, 29, 0.34);
}

.phone {
  position: relative;
  height: min(884px, calc(100vh - 56px));
  overflow: hidden;
  background: var(--bg);
  border-radius: 38px;
  isolation: isolate;
}

/* Fake iOS status bar + dynamic island are only meant for the desktop preview
   shell. They are hidden on real mobile (and any non-shell context) where
   the OS provides its own. */
.island {
  position: absolute;
  top: 11px;
  left: 50%;
  z-index: 60;
  width: 118px;
  height: 34px;
  transform: translateX(-50%);
  background: #090a0c;
  border-radius: 999px;
}

.status {
  position: absolute;
  top: 15px; left: 0; right: 0;
  z-index: 55;
  display: flex;
  justify-content: space-between;
  padding: 0 28px;
  font-size: 13px;
  font-weight: 760;
}

.app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.screen {
  display: none;
  flex: 1;
  min-height: 0;
  padding: 12px 16px calc(var(--safe-bottom) + 92px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: block; animation: enter 180ms ease; }
@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.top-title {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin: 8px 0 14px;
}
.top-title h2 { font-size: 34px; line-height: 1; margin: 0; }
.top-title .credits {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.1);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.round {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid rgba(255, 255, 255, 0.88);
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(30, 36, 44, 0.08);
  backdrop-filter: blur(18px);
}

.search {
  display: grid; grid-template-columns: 22px 1fr;
  gap: 8px; align-items: center;
  min-height: 48px;
  padding: 0 14px;
  color: #8b929e;
  background: rgba(118, 118, 128, 0.12);
  border-radius: 16px;
}
.search input {
  width: 100%; color: var(--ink);
  background: transparent; border: 0; outline: 0; font-size: 16px;
}

.h-scroll {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 14px 0 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
.h-scroll::-webkit-scrollbar { display: none; }

.category {
  flex: 0 0 calc((100% - 24px) / 4);
  min-width: 84px;
  min-height: 80px;
  padding: 10px 11px;
  color: #fff;
  border-radius: 18px;
  text-align: left;
  box-shadow: 0 12px 34px rgba(30, 36, 44, 0.12);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.category strong { display: block; font-size: 14px; line-height: 1.1; font-weight: 800; }
.category span { display: block; margin-top: 3px; color: rgba(255, 255, 255, 0.74); font-size: 11px; }

.cat-event { background: linear-gradient(135deg, #ff6a3d, #bf2f66); }
.cat-service { background: linear-gradient(135deg, #007aff, #15aabf); }
.cat-product { background: linear-gradient(135deg, #1c1f28, #6f5cff); }
.cat-invite { background: linear-gradient(135deg, #34c759, #11996c); }

.label {
  margin: 22px 0 10px;
  color: #7d8490;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.templates {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}

.template {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  text-align: left;
  box-shadow: 0 12px 30px rgba(30, 36, 44, 0.08);
  padding: 0;
}
.cover { height: 148px; background: #ddd center/cover; }
.cover.yoga { background-image: url("https://images.unsplash.com/photo-1531058020387-3be344556be6?auto=format&fit=crop&w=700&q=82"); }
.cover.clean { background-image: url("https://images.unsplash.com/photo-1600880292203-757bb62b4baf?auto=format&fit=crop&w=700&q=82"); }
.cover.launch { background-image: url("https://images.unsplash.com/photo-1516321318423-f06f85e504b3?auto=format&fit=crop&w=700&q=82"); }
.cover.wedding { background-image: url("https://images.unsplash.com/photo-1519741497674-611481863552?auto=format&fit=crop&w=700&q=82"); }

.template-body { padding: 10px; }
.template h3 { font-size: 15px; line-height: 1.16; margin: 0; }
.template p { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.tabbar {
  position: absolute; left: 14px; right: 14px;
  bottom: calc(var(--safe-bottom) + 12px);
  z-index: 42;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 4px; padding: 8px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  box-shadow: 0 14px 44px rgba(30, 36, 44, 0.16);
  backdrop-filter: blur(24px);
}

.tab {
  display: grid; place-items: center; gap: 3px;
  min-height: 58px;
  color: #8b929d;
  background: transparent;
  border-radius: 20px;
  font-size: 12px; font-weight: 760;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--blue); background: rgba(0, 122, 255, 0.1); }

.prompt {
  margin-top: 14px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 12px 30px rgba(30, 36, 44, 0.07);
}

.quick-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 12px;
}

.quick-card {
  min-height: 86px;
  padding: 12px;
  color: #252b35;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  text-align: left;
  box-shadow: 0 10px 26px rgba(30, 36, 44, 0.06);
}
.quick-card strong { display: block; font-size: 15px; line-height: 1.15; }
.quick-card span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.ai-chat-screen { padding-bottom: 92px; }
.ai-chat-screen.active { display: flex !important; flex-direction: column; }

.ai-recommend { flex: 0 0 auto; }
.ai-thread {
  display: grid; align-content: start; gap: 10px;
  flex: 1; min-height: 0; margin-top: 12px; padding: 4px 2px 14px;
  overflow: auto;
}
.bubble {
  max-width: 86%;
  padding: 11px 13px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.45;
}
.bubble.ai { justify-self: start; color: #252b35; background: rgba(118, 118, 128, 0.12); border-bottom-left-radius: 6px; }
.bubble.user { justify-self: end; color: #fff; background: var(--blue); border-bottom-right-radius: 6px; }
.bubble.hidden, .ai-result.hidden { display: none; }

.ai-result {
  display: grid; grid-template-columns: 76px 1fr;
  gap: 12px; align-items: center;
  padding: 10px;
  background: #fff;
  border: 1px solid rgba(0, 122, 255, 0.28);
  border-radius: 20px;
  box-shadow: 0 12px 30px rgba(30, 36, 44, 0.08);
  text-align: left;
}
.ai-result-thumb {
  height: 92px;
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(15, 18, 24, 0.04), rgba(15, 18, 24, 0.74)),
    url("https://images.unsplash.com/photo-1516321318423-f06f85e504b3?auto=format&fit=crop&w=500&q=82") center/cover;
}
.ai-result h3 { font-size: 16px; line-height: 1.15; margin: 0; }
.ai-result p { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.4; }

.ai-input-bar {
  position: absolute; left: 16px; right: 16px;
  bottom: calc(var(--safe-bottom) + 88px);
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  box-shadow: 0 14px 44px rgba(30, 36, 44, 0.12);
  backdrop-filter: blur(22px);
}
.ai-input-bar input {
  min-width: 0; padding: 0 13px;
  background: rgba(118, 118, 128, 0.12);
  border: 0; border-radius: 999px; outline: 0;
}

.primary, .secondary, .danger {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  font-weight: 790;
}
.primary { color: #fff; background: var(--blue); }
.secondary { color: var(--blue); background: rgba(0, 122, 255, 0.1); }
.danger { color: var(--red); background: rgba(255, 59, 48, 0.1); }
.primary:disabled, .secondary:disabled { opacity: 0.55; cursor: not-allowed; }

.full {
  position: absolute; inset: 0;
  z-index: 80; display: none;
  background: #f7f7f9;
}
.full.active { display: block; animation: enter 180ms ease; }

.social-bar, .editor-bar {
  position: absolute; left: 0; right: 0; top: 0;
  z-index: 10;
  display: grid; align-items: end;
  min-height: calc(var(--safe-top) + var(--header-h));
  padding: calc(var(--safe-top) + 10px) 12px 10px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(22px);
}
.social-row, .editor-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.editor-row { position: relative; }
.social-left, .social-actions, .editor-center, .editor-actions {
  display: flex; align-items: center; gap: 8px;
}
.preview-editor-actions { display: none; }
.editor-preview-mode .preview-market-actions { display: none; }
.editor-preview-mode .preview-editor-actions { display: flex; }
.editor-center { position: absolute; left: 50%; transform: translateX(-50%); }

.icon {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  color: var(--ink);
  background: rgba(118, 118, 128, 0.11);
  border-radius: 50%;
}

.preview-page, .edit-canvas {
  position: absolute;
  inset: calc(var(--safe-top) + var(--header-h)) 0 0;
  overflow: auto; background: #fff;
  -webkit-overflow-scrolling: touch;
}

.landing-hero {
  min-height: 430px;
  padding: 28px 22px;
  color: #fff;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: linear-gradient(180deg, rgba(12, 14, 19, 0.08), rgba(12, 14, 19, 0.82)),
    var(--cover, url("https://images.unsplash.com/photo-1531058020387-3be344556be6?auto=format&fit=crop&w=900&q=82")) center/cover;
}
.landing-hero h2 { font-size: 40px; line-height: 0.98; margin: 14px 0 8px; }
.landing-hero p { margin: 0; color: rgba(255, 255, 255, 0.82); font-size: 17px; line-height: 1.4; }
.landing-hero .chip {
  background: rgba(255, 255, 255, 0.2); color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  display: inline-flex; align-self: flex-start;
  padding: 0 12px; min-height: 30px; align-items: center;
  border-radius: 999px; font-size: 13px; font-weight: 700;
}

.landing-body { padding: 14px; background: #f7f7f9; }
.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini, .page-block { padding: 13px; background: #fff; border: 1px solid var(--line); border-radius: 18px; }
.mini strong { display: block; font-size: 20px; }
.mini span, .page-block p { color: var(--muted); font-size: 13px; line-height: 1.45; }
.page-block { margin-top: 10px; }
.page-block h3 { margin-bottom: 5px; font-size: 17px; }

.edit-canvas { padding: 0; background: #fff; }
.editable-text {
  position: relative; cursor: text;
  border-radius: 8px;
  outline: 1.5px dashed rgba(0, 122, 255, 0.55);
  outline-offset: 4px;
  transition: background 160ms ease, outline-color 160ms ease;
}
.editable-text:hover { background: rgba(0, 122, 255, 0.12); outline-color: var(--blue); }
.editable-text::after {
  content: "点击编辑";
  position: absolute; right: 0; top: -24px;
  padding: 3px 7px; color: #fff; background: var(--blue);
  border-radius: 999px; font-size: 11px; font-weight: 780;
  opacity: 0; pointer-events: none;
  transform: translateY(3px);
  transition: opacity 160ms ease, transform 160ms ease;
  white-space: nowrap;
}
.editable-text:hover::after { opacity: 1; transform: translateY(0); }

/* Editable cover image: clicking the hero in the editor opens a sheet that
   lets users change the cover by keyword or paste a URL. */
.editable-cover {
  position: relative;
  cursor: pointer;
}
.editable-cover::after {
  content: "点击更换封面";
  position: absolute;
  right: 14px; top: 14px;
  z-index: 4;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  font-size: 12px; font-weight: 800;
  box-shadow: 0 8px 24px rgba(18, 22, 29, 0.2);
  backdrop-filter: blur(12px);
}
.cover-preview {
  height: 160px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: #ddd center/cover;
}

.floating-ai {
  position: absolute;
  right: 18px;
  bottom: calc(var(--safe-bottom) + 24px);
  z-index: 30;
  display: grid; place-items: center;
  width: 52px; height: 52px;
  color: #fff; border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 18px 42px rgba(0, 122, 255, 0.34);
}
/* Make room for the floating AI button at the bottom of the canvas so it
   never sits on top of stats / sections content. */
.edit-canvas { padding-bottom: 120px; }

.sheet {
  position: absolute; inset: auto 10px 10px;
  z-index: 100;
  display: none;
  max-height: calc(100% - 116px);
  overflow: auto;
  padding: 10px;
  background: rgba(246, 247, 250, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 32px;
  box-shadow: 0 -18px 70px rgba(18, 22, 29, 0.24);
  backdrop-filter: blur(24px);
}
.sheet.open { display: block; animation: sheetUp 190ms ease; }
@keyframes sheetUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.grabber { width: 42px; height: 5px; margin: 4px auto 12px; background: rgba(20, 22, 26, 0.18); border-radius: 999px; }
.sheet h3 { margin: 0 8px 10px; font-size: 22px; }
.sheet textarea, .sheet input {
  width: 100%; padding: 14px;
  color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 18px;
  outline: 0; margin-bottom: 8px;
}
.sheet textarea { min-height: 130px; resize: vertical; font-family: inherit; font-size: 15px; line-height: 1.5; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }

.publish-hint {
  margin-top: 14px;
  padding: 13px;
  color: var(--muted);
  background: rgba(118, 118, 128, 0.11);
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.45;
}

.share-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
.share {
  display: grid; place-items: center; gap: 6px;
  min-height: 76px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: #424a56;
  font-size: 12px; font-weight: 700;
}
.share span:first-child {
  display: grid; place-items: center;
  width: 32px; height: 32px;
  color: #fff; background: var(--blue);
  border-radius: 11px; font-size: 14px;
}

.profile-card {
  margin-bottom: 10px;
  padding: 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 28px rgba(30, 36, 44, 0.06);
}
.profile-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.profile-head h3 { margin: 0; font-size: 17px; }
.profile-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.profile-actions {
  display: grid; grid-template-columns: 1fr 1fr 44px; gap: 8px;
  margin-top: 12px;
}
.small-action {
  min-height: 36px;
  color: var(--blue);
  background: rgba(0, 122, 255, 0.1);
  border-radius: 12px;
  font-size: 12px; font-weight: 760;
}
.small-action.icon-only { display: grid; place-items: center; padding: 0; font-size: 0; }
.small-action.danger { color: var(--red); background: rgba(255, 59, 48, 0.1); }

.chip {
  display: inline-flex; align-items: center;
  min-height: 26px;
  padding: 0 10px;
  color: #303743;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.toast {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 20px; right: 20px;
  z-index: 120;
  display: none;
  padding: 12px 14px;
  color: #fff;
  background: rgba(20, 22, 26, 0.9);
  border-radius: 18px;
  box-shadow: 0 18px 44px rgba(18, 22, 29, 0.25);
  backdrop-filter: blur(18px);
  font-size: 14px;
  font-weight: 720;
}
.toast.show { display: block; animation: enter 180ms ease; }

.field { display: grid; gap: 7px; margin-top: 12px; }
.field label { color: #525a66; font-size: 13px; font-weight: 760; }
.field input, .field textarea {
  width: 100%;
  padding: 13px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: 0;
}
.field textarea { height: 96px; resize: none; }

/* Auth modal */
.modal {
  position: absolute; inset: 0;
  z-index: 200;
  display: none;
  background: rgba(13, 16, 20, 0.5);
  align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}
.modal.open { display: flex; animation: enter 180ms ease; }
.modal-card {
  width: 100%;
  background: #fff;
  border-radius: 24px;
  padding: 22px 20px 18px;
  box-shadow: 0 28px 90px rgba(18, 22, 29, 0.4);
}
.modal-card h2 { margin: 0 0 4px; font-size: 22px; }
.modal-card p.lede { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.tab-switch {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px;
  background: rgba(118, 118, 128, 0.11);
  border-radius: 999px;
  margin-bottom: 14px;
}
.tab-switch button {
  min-height: 36px; border-radius: 999px;
  color: var(--muted); background: transparent;
  font-weight: 800; font-size: 13px;
}
.tab-switch button.active { color: var(--ink); background: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.06); }

.modal-actions {
  display: grid; gap: 10px; margin-top: 14px;
}
.modal-actions .text-link {
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 4px;
}
.modal-actions .text-link b { color: var(--blue); }
.modal-card .field:first-of-type { margin-top: 4px; }

.error-text { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 18px; }

.notice-card {
  text-align: center;
}
.notice-card .gift {
  display: grid; place-items: center;
  width: 70px; height: 70px;
  margin: 0 auto 14px;
  border-radius: 24px;
  background: linear-gradient(135deg, #007aff, #af52de);
  color: #fff;
}
.notice-card h2 { margin: 0 0 6px; font-size: 22px; }
.notice-card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.notice-card .bonus-amount {
  display: inline-block;
  margin: 12px 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.1);
  color: var(--blue);
  font-weight: 900; font-size: 18px;
}

/* Mobile: drop the desktop "phone-shell" chrome — the device already has its
   own. Use the full viewport. Top/bottom paddings use env(safe-area-inset-*)
   which we set as --safe-top / --safe-bottom universally above, so the same
   header/tabbar rules cover both desktop preview and real mobile. */
@media (max-width: 520px) {
  body { background: var(--bg); }
  .stage { padding: 0; min-height: 100dvh; }
  .phone-shell {
    width: 100%; padding: 0;
    background: var(--bg);
    border-radius: 0; box-shadow: none;
  }
  .phone {
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    background: var(--bg);
  }
  [data-full="share"] > .screen.active {
    padding: 12px 16px calc(var(--safe-bottom) + 24px) !important;
  }
  .sheet {
    inset: auto 8px calc(var(--safe-bottom) + 8px);
  }
  .modal { padding: 16px; }
}

/* Block iOS auto-zoom-on-focus (font-size ≥ 16px disables it) */
input, textarea, select { font-size: 16px; }
