/* ============================================================
   AI 爆款文案大师 — 移动端 H5 样式
   适配：微信内置浏览器 / iOS Safari / Android Chrome
   ============================================================ */

:root {
  --primary: #ff2e63;
  --primary-light: #ff6b8d;
  --primary-dark: #e01e4f;
  --primary-soft: #fff0f4;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1a1a1c;
  --text-2: #666a73;
  --text-3: #9aa0a8;
  --line: #ebedf0;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(20, 22, 28, 0.05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --tabbar-h: 56px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; font-size: inherit; }
input, textarea { font-family: inherit; font-size: 16px; /* 防 iOS 聚焦缩放 */ }
img, video { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------------- 启动遮罩 ---------------- */
.boot {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #fff5f7 0%, #ffffff 60%);
}
.boot-logo { font-size: 54px; animation: pop .6s ease; }
.boot-title { margin-top: 10px; font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.boot-spin {
  margin-top: 22px; width: 26px; height: 26px;
  border: 2.5px solid var(--primary-soft); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.boot-tip { margin-top: 14px; font-size: 13px; color: var(--text-3); text-align: center; padding: 0 30px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------------- 布局 ---------------- */
.app { display: flex; flex-direction: column; min-height: 100%; }

.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; align-items: center; gap: 7px; min-width: 0; }
.brand-icon { font-size: 20px; }
.brand-text { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.credit-chip {
  display: flex; align-items: center; gap: 4px;
  padding: 5px 12px; border-radius: 20px;
  background: linear-gradient(135deg, #fff0f4, #ffe4ec);
  color: var(--primary-dark); font-size: 13px; font-weight: 700;
  border: 1px solid #ffd9e3; flex-shrink: 0;
}
.credit-icon { font-size: 12px; }

.main { flex: 1; padding: 12px 14px calc(var(--tabbar-h) + var(--safe-b) + 20px); }
.page-head { padding: 4px 2px 14px; }
.page-head h2 { margin: 0; font-size: 19px; font-weight: 700; }
.page-head p { margin: 4px 0 0; font-size: 13px; color: var(--text-3); }

/* ---------------- 分段控件 ---------------- */
.seg {
  display: flex; gap: 6px; padding: 4px;
  background: #fff; border-radius: 12px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.seg-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px; border-radius: 9px;
  color: var(--text-2); font-size: 12.5px; font-weight: 600;
  transition: background .18s, color .18s;
}
.seg-item i { font-style: normal; font-size: 19px; line-height: 1.1; }
.seg-item.active { background: var(--primary); color: #fff; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title { font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--text-3); }
.opt-tag {
  margin-left: 6px; padding: 1px 6px; border-radius: 4px;
  background: #f0f1f3; color: var(--text-3); font-size: 11px; font-weight: 500;
}
.hint { margin-top: 8px; font-size: 12px; color: var(--text-3); line-height: 1.5; }

.ta {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 11px 12px; resize: vertical; outline: none;
  background: #fafbfc; color: var(--text); line-height: 1.65;
  transition: border-color .18s, background .18s;
}
.ta:focus { border-color: var(--primary-light); background: #fff; }
.ta::placeholder { color: #b8bec6; }

.quick-row { display: flex; gap: 8px; margin-top: 10px; }
.quick-btn {
  flex: 1; padding: 8px; border-radius: 9px;
  background: #f5f6f8; color: var(--text-2); font-size: 13px; font-weight: 600;
}
.quick-btn:active { background: #ebedf0; }

.chip-row { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.chip {
  display: inline-block; padding: 4px 10px; border-radius: 14px;
  background: var(--primary-soft); color: var(--primary-dark);
  font-size: 12px; font-weight: 600;
}
.chip-x {
  width: 20px; height: 20px; border-radius: 50%;
  background: #f0f1f3; color: var(--text-3); font-size: 15px; line-height: 1;
}

/* ---------------- 参数选项 ---------------- */
.opt-block { margin-bottom: 12px; }
.opt-label { font-size: 13px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 5px; }
.opt-label small { font-weight: 400; color: var(--text-3); font-size: 11.5px; }
.opt-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.opt-chip {
  padding: 7px 13px; border-radius: 18px; font-size: 13px; font-weight: 600;
  background: #f5f6f8; color: var(--text-2); border: 1.5px solid transparent;
  transition: all .16s;
}
.opt-chip.active {
  background: var(--primary-soft); color: var(--primary-dark);
  border-color: var(--primary-light);
}
.opt-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; }
.opt-row + .opt-row { border-top: 1px solid var(--line); }
.opt-row-label { font-size: 14px; font-weight: 600; }
.opt-row-label small { display: block; font-weight: 400; font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.switch { position: relative; width: 46px; height: 27px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-slider {
  position: absolute; inset: 0; background: #d8dce2; border-radius: 27px;
  transition: background .2s;
}
.switch-slider::before {
  content: ''; position: absolute; width: 21px; height: 21px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(19px); }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 30px; height: 30px; border-radius: 8px; background: #f0f1f3;
  font-size: 17px; font-weight: 700; color: var(--text-2); line-height: 1;
}
.stepper button:active { background: #e2e5e9; }
.stepper span { min-width: 34px; text-align: center; font-weight: 700; font-size: 15px; }

/* ---------------- 按钮 ---------------- */
.btn-group { display: flex; flex-direction: column; gap: 9px; }
.btn-primary, .btn-ghost {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; border-radius: 12px;
  font-size: 16px; font-weight: 700; transition: opacity .16s, transform .1s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; box-shadow: 0 4px 14px rgba(255, 46, 99, .26);
}
.btn-primary:active { transform: scale(.985); opacity: .92; }
.btn-primary:disabled { opacity: .5; box-shadow: none; }
.btn-ghost {
  background: #fff; color: var(--primary-dark); border: 1.5px solid #ffd9e3;
}
.btn-ghost:active { background: var(--primary-soft); }
.btn-primary.sm, .btn-ghost.sm { padding: 11px; font-size: 14px; border-radius: 10px; }
.btn-cost {
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
  background: rgba(255,255,255,.24);
}
.btn-ghost .btn-cost { background: var(--primary-soft); }

/* ---------------- 上传组件 ---------------- */
.uploader-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.up-tile {
  aspect-ratio: 1/1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  border: 1.5px dashed #d8dce2; border-radius: 11px; background: #fafbfc;
  color: var(--text-3);
}
.up-tile:active { background: #f0f1f3; border-color: var(--primary-light); }
.up-ico { font-size: 23px; }
.up-txt { font-size: 11.5px; font-weight: 600; }

.img-thumb { position: relative; aspect-ratio: 1/1; border-radius: 11px; overflow: hidden; background: #f0f1f3; }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb .del {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border-radius: 50%; background: rgba(0,0,0,.55); color: #fff;
  font-size: 14px; line-height: 22px; text-align: center;
}
.img-thumb .sz {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 5px;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  color: #fff; font-size: 10px; text-align: right;
}

.video-preview { margin-top: 12px; }
.video-preview video { width: 100%; max-height: 240px; border-radius: 11px; background: #000; }
.video-meta { margin-top: 7px; font-size: 12px; color: var(--text-2); }
.video-remove {
  margin-top: 8px; width: 100%; padding: 9px; border-radius: 9px;
  background: #f5f6f8; color: var(--text-2); font-size: 13px; font-weight: 600;
}

/* ---------------- 模板库 ---------------- */
.tpl-list { display: flex; flex-direction: column; gap: 14px; }
.tpl-group-title {
  font-size: 14px; font-weight: 700; margin-bottom: 9px;
  display: flex; align-items: center; gap: 6px;
}
.tpl-group-title::before { content: ''; width: 3px; height: 13px; background: var(--primary); border-radius: 2px; }
.tpl-items { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.tpl-item {
  background: #fff; border-radius: 12px; padding: 12px 11px;
  box-shadow: var(--shadow); text-align: left; transition: transform .12s;
}
.tpl-item:active { transform: scale(.97); }
.tpl-ico { font-size: 21px; }
.tpl-name { font-size: 13.5px; font-weight: 700; margin-top: 5px; line-height: 1.35; }
.tpl-hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tpl-use { font-size: 11px; color: var(--primary); margin-top: 6px; font-weight: 600; }

/* ---------------- 历史 ---------------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.search-bar input {
  flex: 1; padding: 10px 13px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #fff; outline: none; font-size: 15px;
}
.search-bar input:focus { border-color: var(--primary-light); }
.search-bar button {
  padding: 0 17px; border-radius: 10px; background: var(--primary);
  color: #fff; font-weight: 700; font-size: 14px;
}
.filter-row { display: flex; gap: 7px; margin-bottom: 12px; overflow-x: auto; padding-bottom: 2px; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 6px 14px; border-radius: 16px; background: #fff;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  white-space: nowrap; flex-shrink: 0; box-shadow: var(--shadow);
}
.filter-chip.active { background: var(--primary); color: #fff; }

.his-list { display: flex; flex-direction: column; gap: 10px; }
.his-item {
  background: #fff; border-radius: 12px; padding: 12px;
  box-shadow: var(--shadow); display: flex; gap: 11px;
}
.his-cover {
  width: 58px; height: 58px; border-radius: 9px; object-fit: cover;
  background: #f0f1f3; flex-shrink: 0;
}
.his-cover-ph {
  width: 58px; height: 58px; border-radius: 9px; flex-shrink: 0;
  background: var(--primary-soft); display: flex; align-items: center;
  justify-content: center; font-size: 22px;
}
.his-main { flex: 1; min-width: 0; }
.his-title {
  font-size: 14px; font-weight: 700; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.his-excerpt {
  font-size: 12.5px; color: var(--text-2); margin-top: 3px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.his-foot { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.his-tag {
  padding: 2px 7px; border-radius: 5px; background: #f0f1f3;
  font-size: 10.5px; color: var(--text-2); font-weight: 600;
}
.his-time { font-size: 11px; color: var(--text-3); margin-left: auto; }
.his-acts { display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.his-act {
  width: 30px; height: 30px; border-radius: 8px; background: #f5f6f8;
  font-size: 14px; line-height: 30px; text-align: center;
}
.his-act:active { background: #e6e8eb; }

.load-more {
  width: 100%; margin-top: 12px; padding: 11px; border-radius: 10px;
  background: #fff; color: var(--text-2); font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
}
.empty { text-align: center; padding: 56px 20px; color: var(--text-3); }
.empty-ico { font-size: 44px; margin-bottom: 10px; }
.empty-txt { font-size: 14px; }
.empty-sub { font-size: 12.5px; margin-top: 6px; color: #b8bec6; }

/* ---------------- 我的 ---------------- */
.me-card {
  background: linear-gradient(150deg, #ff5e83 0%, #ff2e63 100%);
  border-radius: 16px; padding: 18px; margin-bottom: 12px; color: #fff;
  box-shadow: 0 6px 20px rgba(255,46,99,.24);
}
.me-top { display: flex; align-items: center; gap: 11px; }
.me-avatar {
  width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0;
}
.me-info { flex: 1; min-width: 0; }
.me-nick { font-size: 16px; font-weight: 700; }
.me-id { font-size: 11px; opacity: .78; margin-top: 1px; word-break: break-all; }
.me-edit {
  padding: 5px 11px; border-radius: 14px; background: rgba(255,255,255,.2);
  color: #fff; font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.me-credit { text-align: center; padding: 16px 0 12px; }
.mc-num { font-size: 38px; font-weight: 800; line-height: 1.1; letter-spacing: -1px; }
.mc-label { font-size: 11.5px; opacity: .82; margin-top: 3px; }
.btn-signin {
  width: 100%; padding: 12px; border-radius: 11px; background: #fff;
  color: var(--primary); font-size: 15px; font-weight: 700;
}
.btn-signin:disabled { opacity: .6; }
.me-stat { display: flex; margin-top: 14px; text-align: center; }
.me-stat > div { flex: 1; }
.me-stat b { display: block; font-size: 17px; font-weight: 700; }
.me-stat span { font-size: 11px; opacity: .82; }

.ledger-list { display: flex; flex-direction: column; }
.ledger-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.ledger-item:last-child { border-bottom: none; }
.ledger-note { color: var(--text-2); }
.ledger-time { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.ledger-amt { font-weight: 700; font-size: 15px; flex-shrink: 0; margin-left: 12px; }
.ledger-amt.plus { color: #e01e4f; }
.ledger-amt.minus { color: #0a9d5c; }
.about-txt { font-size: 12.5px; color: var(--text-2); line-height: 1.75; }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  display: flex; height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1px; color: var(--text-3); font-size: 10.5px; font-weight: 600;
}
.tab i { font-style: normal; font-size: 20px; line-height: 1.15; filter: grayscale(1); opacity: .55; }
.tab.active { color: var(--primary); }
.tab.active i { filter: none; opacity: 1; }

/* ---------------- 弹层 ---------------- */
.sheet { position: fixed; inset: 0; z-index: 500; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0,0,0,.45); animation: fade .2s; }
.sheet-body {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 92vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 18px 18px 0 0;
  animation: slideUp .26s cubic-bezier(.32,.72,.3,1);
  padding-bottom: var(--safe-b);
}
@keyframes fade { from { opacity: 0; } }
@keyframes slideUp { from { transform: translateY(100%); } }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px; border-bottom: 1px solid var(--line); background: #fff;
  border-radius: 18px 18px 0 0; flex-shrink: 0;
}
.sheet-title { font-size: 16px; font-weight: 700; }
.sheet-close { width: 28px; height: 28px; border-radius: 50%; background: #f0f1f3; font-size: 19px; line-height: 1; color: var(--text-2); }
.sheet-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px; }
.sheet-foot {
  display: flex; gap: 8px; padding: 10px 14px 12px;
  background: #fff; border-top: 1px solid var(--line); flex-shrink: 0;
}

/* 结果区块 */
.res-block { background: #fff; border-radius: 12px; padding: 13px; margin-bottom: 11px; }
.res-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.res-label { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.res-copy {
  padding: 4px 11px; border-radius: 13px; background: var(--primary-soft);
  color: var(--primary-dark); font-size: 12px; font-weight: 700;
}
.res-copy:active { background: #ffe0e9; }
.res-editor {
  width: 100%; border: 1.5px solid var(--line); border-radius: 9px;
  padding: 10px 11px; background: #fafbfc; outline: none;
  line-height: 1.75; resize: vertical; font-size: 15px; color: var(--text);
}
.res-editor:focus { border-color: var(--primary-light); background: #fff; }
.res-titles { display: flex; flex-direction: column; gap: 7px; }
.res-title-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px; background: #fafbfc; border-radius: 9px; border: 1px solid var(--line);
}
.res-title-num {
  width: 19px; height: 19px; border-radius: 5px; background: var(--primary-soft);
  color: var(--primary-dark); font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.res-title-txt { flex: 1; font-size: 14px; line-height: 1.5; border: none; background: none; outline: none; }
.res-title-copy { font-size: 15px; opacity: .5; flex-shrink: 0; }
.res-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.res-tag {
  padding: 5px 11px; border-radius: 14px; background: #eef4ff;
  color: #2b6cd4; font-size: 12.5px; font-weight: 600;
}
.res-frag {
  background: #fafbfc; border: 1px solid var(--line); border-radius: 9px;
  padding: 11px; margin-bottom: 8px;
}
.res-frag-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px; font-size: 12px; color: var(--text-3); font-weight: 600;
}
.res-frag textarea {
  width: 100%; border: none; background: none; outline: none;
  resize: vertical; line-height: 1.7; font-size: 14.5px; color: var(--text);
}
.res-warn {
  background: #fff8e6; border: 1px solid #ffe0a3; color: #8a6100;
  border-radius: 10px; padding: 10px 12px; font-size: 12.5px;
  line-height: 1.6; margin-bottom: 11px;
}
.res-notice {
  background: #eef4ff; border: 1px solid #cfe0ff; color: #2b5fa8;
  border-radius: 10px; padding: 10px 12px; font-size: 12.5px;
  line-height: 1.6; margin-bottom: 11px;
}
.res-assets { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 11px; }
.res-assets img { width: 66px; height: 66px; border-radius: 9px; object-fit: cover; }
.res-assets video { width: 100%; max-height: 210px; border-radius: 11px; background: #000; }

/* 模板选择列表 */
.tpl-sheet-item {
  display: flex; align-items: center; gap: 11px; padding: 12px;
  background: #fff; border-radius: 11px; margin-bottom: 8px;
}
.tpl-sheet-ico { font-size: 23px; flex-shrink: 0; }
.tpl-sheet-main { flex: 1; min-width: 0; }
.tpl-sheet-name { font-size: 14.5px; font-weight: 700; }
.tpl-sheet-hint { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.45; }
.tpl-sheet-ind {
  font-size: 11px; color: var(--primary); background: var(--primary-soft);
  padding: 2px 7px; border-radius: 5px; flex-shrink: 0; font-weight: 600;
}

/* 分享卡片 */
.card-sheet { max-height: 94vh; }
.card-preview { padding: 14px; overflow-y: auto; flex: 1; text-align: center; background: var(--bg); }
.card-preview img { width: 100%; max-width: 340px; margin: 0 auto; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.14); }
.card-tip { text-align: center; font-size: 12.5px; color: var(--text-3); padding: 0 14px 10px; background: var(--bg); }

/* ---------------- 加载遮罩 ---------------- */
.loading {
  position: fixed; inset: 0; z-index: 800;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.42);
}
.loading-box {
  background: rgba(255,255,255,.97); border-radius: 15px;
  padding: 26px 32px; text-align: center; min-width: 190px; max-width: 82vw;
}
.loading-spin {
  width: 32px; height: 32px; margin: 0 auto;
  border: 3px solid var(--primary-soft); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .75s linear infinite;
}
.loading-text { margin-top: 13px; font-size: 14.5px; font-weight: 600; }
.loading-sub { margin-top: 5px; font-size: 12px; color: var(--text-3); line-height: 1.5; }
.loading-bar {
  margin-top: 12px; height: 5px; background: #f0f1f3; border-radius: 3px; overflow: hidden;
}
.loading-bar i { display: block; height: 100%; width: 0; background: var(--primary); transition: width .25s; border-radius: 3px; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; top: 50%; z-index: 900;
  transform: translate(-50%, -50%);
  max-width: 78vw; padding: 12px 18px; border-radius: 11px;
  background: rgba(0, 0, 0, .82); color: #fff;
  font-size: 14px; line-height: 1.6; text-align: center;
  animation: toastIn .22s; word-break: break-word;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%,-46%); } }

/* ---------------- 对话框 ---------------- */
.dialog { position: fixed; inset: 0; z-index: 950; display: flex; align-items: center; justify-content: center; }
.dialog-mask { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.dialog-box {
  position: relative; width: 78vw; max-width: 320px;
  background: #fff; border-radius: 15px; padding: 22px 20px 0; text-align: center;
  animation: pop .22s;
}
.dialog-title { font-size: 16.5px; font-weight: 700; }
.dialog-text { font-size: 14px; color: var(--text-2); margin-top: 9px; line-height: 1.65; }
.dialog-input {
  width: 100%; margin-top: 13px; padding: 10px 12px;
  border: 1.5px solid var(--line); border-radius: 9px; outline: none;
}
.dialog-input:focus { border-color: var(--primary-light); }
.dialog-btns { display: flex; margin: 18px -20px 0; border-top: 1px solid var(--line); }
.dialog-btns button {
  flex: 1; padding: 14px; font-size: 15.5px; font-weight: 600; color: var(--text-2);
}
.dialog-btns button + button { border-left: 1px solid var(--line); }
.dialog-btns .primary { color: var(--primary); font-weight: 700; }

/* ---------------- 大屏适配（PC 打开 H5 时居中） ---------------- */
@media (min-width: 640px) {
  body { background: #e9ebef; }
  .app {
    max-width: 480px; margin: 0 auto; min-height: 100vh;
    background: var(--bg); box-shadow: 0 0 30px rgba(0,0,0,.07);
  }
  /* 用 margin 居中而非 transform，避免与弹层的 slideUp 动画 transform 冲突 */
  .tabbar { left: 50%; right: auto; width: 480px; margin-left: -240px; }
  .sheet-body { left: 50%; right: auto; width: 480px; margin-left: -240px; }
}

/* ---------------- 分享弹层 ---------------- */
.tab-share { color: var(--primary); }
.tab-share i { filter: none; opacity: 1; }

.share-sheet { max-height: 90vh; }
.share-body {
  display: flex; flex-direction: column; align-items: center;
  padding: 22px 22px calc(26px + var(--safe-b));
}
.share-qr {
  width: 210px; height: 210px; box-sizing: border-box;
  background: #fff; border-radius: 16px; padding: 12px;
  box-shadow: 0 6px 22px rgba(255, 46, 99, .12);
  display: flex; align-items: center; justify-content: center;
}
.share-qr svg { width: 100% !important; height: 100% !important; display: block; }
.share-url {
  margin-top: 18px; font-size: 13px; color: var(--text-2);
  word-break: break-all; text-align: center; max-width: 100%;
}
.share-tip { margin-top: 7px; font-size: 12px; color: #9aa0a8; text-align: center; }

/* 分享弹层：操作按钮组 */
.share-acts { margin-top: 20px; width: 100%; display: flex; gap: 10px; }
.share-acts .btn-ghost,
.share-acts .btn-primary { flex: 1; margin-top: 0; }
.share-body .sheet-scroll { width: 100%; }

/* 分享弹层：海报预览 */
.share-poster { margin-top: 18px; width: 100%; text-align: center; animation: fade .25s; }
.share-poster img {
  width: 62%; max-width: 240px; display: block; margin: 0 auto;
  border-radius: 12px; box-shadow: 0 8px 26px rgba(255, 46, 99, .18);
}
.share-poster-tip { margin-top: 9px; font-size: 12px; color: #9aa0a8; }

/* ---------------- 悬浮扫码分享按钮 ---------------- */
.fab-share {
  position: fixed; right: 16px; z-index: 120;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  width: 56px; height: 56px; padding: 0;
  border: 0; border-radius: 50%; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  box-shadow: 0 6px 20px rgba(255, 46, 99, .42);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
  -webkit-tap-highlight-color: transparent;
  transition: transform .16s ease, box-shadow .16s ease;
  animation: fabIn .38s cubic-bezier(.34, 1.56, .64, 1) both;
}
.fab-share:active { transform: scale(.9); box-shadow: 0 3px 12px rgba(255, 46, 99, .4); }
.fab-icon { width: 23px; height: 23px; fill: #fff; display: block; }
.fab-txt { font-size: 10px; color: #fff; font-weight: 600; line-height: 1; letter-spacing: .5px; }
.fab-halo {
  position: absolute; inset: 0; border-radius: 50%;
  background: var(--primary); opacity: .5;
  animation: fabHalo 2.4s ease-out infinite; z-index: -1;
}
@keyframes fabHalo {
  0%   { transform: scale(1);   opacity: .45; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}
@keyframes fabIn {
  from { transform: scale(0) rotate(-90deg); opacity: 0; }
  to   { transform: scale(1) rotate(0);      opacity: 1; }
}
/* 弹层打开时隐藏悬浮按钮，避免遮挡 */
body.sheet-open .fab-share { opacity: 0; pointer-events: none; transform: scale(.6); }
@media (prefers-reduced-motion: reduce) {
  .fab-halo { animation: none; opacity: 0; }
  .fab-share { animation: none; }
}
@media (min-width: 560px) {
  .fab-share { right: calc(50% - 240px + 16px); }
}
