/* ============================================================
   问卷工作台 · V2 主题（问卷星风格）
   · 蓝紫主色，取代原来的青绿
   · 白卡片 + 更克制的圆角与阴影，观感更接近专业问卷平台
   · 本文件在 style.css 之后加载，只做覆盖，不改结构与逻辑
   ============================================================ */

/* ---------- 1. 色板 ---------- */
:root{
  color-scheme:light;
  --text:#101828; --text-2:#475467; --muted:#5B667C; --placeholder:#98A2B3;
  --card:#FFFFFF; --border:#E6EBF4; --border-strong:#D3DBEA;
  --bg-start:#F5F7FC; --bg-end:#EDF1FA;
  --soft:#F4F7FD; --soft2:#EDF2FB;
  --line:#EDF1F8;
  --chip:#EEF2FB; --chip-text:#3D4A66;

  --primary:#3B5BFE; --primary2:#6D5EF8; --primary-deep:#2A44D9;
  --primary-soft:#EEF1FF; --primary-border:#C9D3FF;
  --grad:linear-gradient(135deg,#3B5BFE 0%,#5A5CFB 55%,#6D5EF8 100%);

  --radius-sm:9px; --radius-md:12px; --radius-lg:16px; --radius-xl:22px;
  --shadow-sm:0 1px 2px rgba(16,24,40,.05);
  --shadow-md:0 6px 18px -8px rgba(28,42,90,.16);
  --shadow-lg:0 18px 44px -20px rgba(42,68,217,.30);
  --shadow-xl:0 26px 64px -26px rgba(42,68,217,.34);
  --ring:0 0 0 3px rgba(59,91,254,.15);
  --glow:radial-gradient(900px 380px at 50% -130px,rgba(90,92,251,.10),transparent 70%);
  --tabbar-bg:#FFFFFF; --tabbar-hover:#F1F4FF;
}
:root.dark{
  color-scheme:dark;
  --text:#E8ECF7; --text-2:#B6C1D9; --muted:#9AA6BF; --placeholder:#6B7891;
  --card:#151B2B; --border:#242C42; --border-strong:#33405C;
  --bg-start:#0C1020; --bg-end:#111629;
  --soft:#1A2135; --soft2:#1E263C;
  --line:#212A40; --chip:#222B44; --chip-text:#B8C3DC;

  --primary:#7C8CFF; --primary2:#A78BFA; --primary-deep:#5B6BFF;
  --primary-soft:#1B2140; --primary-border:#2E3A66;
  --grad:linear-gradient(135deg,#5B6BFF 0%,#7C8CFF 55%,#A78BFA 100%);

  --shadow-sm:0 1px 2px rgba(0,0,0,.35);
  --shadow-md:0 6px 20px -8px rgba(0,0,0,.5);
  --shadow-lg:0 18px 44px -20px rgba(0,0,0,.6);
  --shadow-xl:0 26px 64px -26px rgba(0,0,0,.65);
  --ring:0 0 0 3px rgba(124,140,255,.22);
  --glow:radial-gradient(900px 380px at 50% -130px,rgba(124,140,255,.12),transparent 70%);
  --tabbar-bg:#141A29; --tabbar-hover:#1D2640;
}

/* ---------- 2. 底纹与顶栏 ---------- */
body{
  background:
    linear-gradient(180deg,var(--bg-start) 0%,var(--bg-end) 100%);
  -webkit-font-smoothing:antialiased;
}
body::before{
  background:
    radial-gradient(760px 320px at 12% -8%,rgba(90,92,251,.10),transparent 70%),
    radial-gradient(680px 300px at 92% -6%,rgba(109,94,248,.09),transparent 72%);
}
:root.dark body::before{
  background:
    radial-gradient(760px 320px at 12% -8%,rgba(124,140,255,.14),transparent 70%),
    radial-gradient(680px 300px at 92% -6%,rgba(167,139,250,.11),transparent 72%);
}

.app-header{
  background:color-mix(in srgb,var(--card) 84%,transparent);
  border-bottom:1px solid var(--border);
  box-shadow:0 1px 0 rgba(16,24,40,.02),0 6px 24px -20px rgba(16,24,40,.25);
}
.app-header::after{
  content:"";position:absolute;left:0;right:0;bottom:-1px;height:2px;
  background:linear-gradient(90deg,transparent,rgba(59,91,254,.55),rgba(109,94,248,.55),transparent);
  opacity:.7;
}
.header-inner{padding:13px 22px;padding-top:calc(13px + env(safe-area-inset-top,0px));padding-top:calc(13px + max(env(safe-area-inset-top,0px),var(--safe-top,0px)))}
.logo{font-size:16.5px;letter-spacing:.2px}
.logo-badge{
  width:36px;height:36px;border-radius:12px;
  background:var(--grad);
  box-shadow:0 8px 20px -6px rgba(59,91,254,.55);
  font-size:17px;
}
.btn-ghost{color:var(--muted)}
.btn-ghost:hover:not(:disabled){background:var(--soft2);color:var(--text)}

/* ---------- 3. 页面标题 ---------- */
.page-head{padding:26px 0 16px}
.page-head h1{font-size:26px;font-weight:800;letter-spacing:-.4px}
.page-head .sub{font-size:13px;color:var(--muted);margin-top:5px}

/* ---------- 4. 按钮 ---------- */
.btn{
  border-radius:10px;
  font-weight:600;
  transition:background .15s,color .15s,border-color .15s,box-shadow .15s,transform .12s;
}
/* 按钮内 loading 小圈（颜色跟随 currentColor，深浅底都可见） */
.btn-spin{
  width:14px;height:14px;flex:none;border-radius:50%;
  border:2px solid color-mix(in srgb,currentColor 32%,transparent);
  border-top-color:currentColor;
  animation:spin .7s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
.btn-primary{
  background:var(--grad);
  box-shadow:0 10px 22px -10px rgba(59,91,254,.6);
}
.btn-primary:hover:not(:disabled){filter:none;transform:translateY(-1px);box-shadow:0 14px 28px -12px rgba(59,91,254,.7)}
.btn-primary:active:not(:disabled){transform:translateY(0) scale(.99)}
.btn-soft{
  background:var(--primary-soft);color:var(--primary-deep);border:1px solid var(--primary-border);
}
:root.dark .btn-soft{color:var(--primary)}
.btn-soft:hover:not(:disabled){background:color-mix(in srgb,var(--primary-soft) 70%,var(--card))}
.btn-danger-soft{background:var(--danger-soft);color:var(--danger);border:1px solid var(--danger-border)}

/* ---------- 5. 统计卡 ---------- */
.stat-grid{gap:12px}
.stat-card{
  position:relative;overflow:hidden;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:17px 18px;
  box-shadow:var(--shadow-sm);
  transition:transform .18s,box-shadow .18s,border-color .18s;
}
.stat-card::before{
  content:"";position:absolute;left:0;top:0;bottom:0;width:3px;
  background:var(--grad);opacity:.85;
}
.stat-card:hover{transform:translateY(-2px);box-shadow:var(--shadow-md);border-color:var(--primary-border)}
.stat-card .ico{
  width:36px;height:36px;border-radius:11px;font-size:17px;margin-bottom:12px;
  background:var(--primary-soft);color:var(--primary);
}
.stat-card .num{font-size:30px;font-weight:800;letter-spacing:-.8px;line-height:1.1}
.stat-card .label{font-size:12px;color:var(--muted);margin-top:4px;letter-spacing:.2px}
/* 四张卡用同一色系的不同深浅，不再五颜六色 */
.stat-card .ico-green,.stat-card .ico-teal,.stat-card .ico-warn,.stat-card .ico-soft{
  background:var(--primary-soft);color:var(--primary);
}

/* ---------- 6. 问卷列表 ---------- */
#surveyList{display:flex;flex-direction:column;gap:11px;margin-top:14px}
.survey-row{
  position:relative;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:16px 18px;
  box-shadow:var(--shadow-sm);
  transition:transform .16s,box-shadow .18s,border-color .18s;
}
.survey-row::before{
  content:"";position:absolute;left:0;top:14px;bottom:14px;width:3px;border-radius:0 3px 3px 0;
  background:var(--border-strong);opacity:.9;
}
.survey-row:hover{transform:translateY(-2px);box-shadow:var(--shadow-md);border-color:var(--primary-border)}
.survey-row .s-title{font-size:15.5px;font-weight:700;letter-spacing:-.1px}
.survey-row .s-meta{font-size:12px;gap:9px;margin-top:6px}
.survey-row .s-count{
  background:var(--soft2);border-radius:12px;padding:9px 13px 10px;min-width:72px;
  display:flex;flex-direction:column;align-items:center;gap:1px;
}
.survey-row .answer-progress{width:100%;height:4px;margin-top:6px;border-radius:99px}
.survey-row .s-count b{font-size:20px;color:var(--primary-deep)}
:root.dark .survey-row .s-count b{color:var(--primary)}
.survey-row .answer-progress{background:var(--line);border-radius:99px;overflow:hidden}
.survey-row .answer-progress i{background:var(--grad);border-radius:99px}

/* 状态胶囊：统一色系 */
.chip{border-radius:99px;font-weight:600;letter-spacing:.2px}
.chip-draft{background:var(--soft2);color:var(--muted);border:1px solid var(--border)}
.chip-published{background:#E9F0FF;color:#2447D8;border:1px solid #C7D6FF}
:root.dark .chip-published{background:#1B2547;color:#9DB0FF;border-color:#2D3C6B}
.chip-closed{background:var(--soft2);color:var(--muted);border:1px solid var(--border)}

/* ---------- 7. 编辑器 ---------- */
.editor-grid{gap:16px}
.q-card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-sm);
  transition:border-color .16s,box-shadow .16s;
}
.q-card:hover{border-color:var(--border-strong);box-shadow:var(--shadow-md)}
.q-card.dragging{box-shadow:var(--shadow-lg);border-color:var(--primary);opacity:.92}
.q-head{gap:9px}
.q-type-badge{
  background:var(--primary-soft);color:var(--primary-deep);
  border-radius:8px;font-weight:700;letter-spacing:.2px;
}
:root.dark .q-type-badge{color:var(--primary)}
.q-title-input{
  border-radius:9px;font-size:14.5px;
}
.q-title-input:focus{border-color:var(--primary);box-shadow:var(--ring)}
.q-drag{color:var(--placeholder)}
.add-bar{gap:7px}
.add-bar button{
  border-radius:9px;border:1px dashed var(--border-strong);background:var(--card);color:var(--muted);
  transition:border-color .15s,color .15s,background .15s;
}
.add-bar button:hover{border-color:var(--primary);color:var(--primary);background:var(--primary-soft)}

/* 编辑器右侧预览：像一张真实问卷 */
.editor-preview,.preview-pane,#editorPreview{
  border-radius:var(--radius-xl);
}
#editorPreview{
  background:var(--card);
  border:1px solid var(--border);
  box-shadow:var(--shadow-md);
  overflow:hidden;
}
.fill-head{
  background:linear-gradient(135deg,#3B5BFE 0%,#5A5CFB 52%,#7A5AF8 100%);
  border-bottom:0;
  padding:26px 26px 22px;
  position:relative;
}
.fill-head::after{
  content:"";position:absolute;inset:0;pointer-events:none;
  background:radial-gradient(520px 200px at 85% -30%,rgba(255,255,255,.28),transparent 70%);
}
.fill-head h2{color:#fff;font-size:21px;letter-spacing:-.2px;position:relative;z-index:1}
.fill-head .fill-desc{color:rgba(255,255,255,.82);font-size:13.5px;position:relative;z-index:1}
.fill-body{padding:18px 22px 24px}

/* 填答题块 */
.fq{padding:15px 0;border-bottom:1px solid var(--line)}
.fq:last-child{border-bottom:0}
.fq-title{font-size:14.5px;font-weight:650;line-height:1.6}
.fq-no{color:var(--primary);font-weight:800;margin-right:5px}
.fq-opt{
  border:1px solid transparent;
  background:transparent;
  border-radius:10px;
  padding:9px 11px;
  margin-top:2px;
  transition:background .14s,border-color .14s;
}
.fq-opt:hover{background:var(--soft2)}
.fq-opt:has(input:checked){background:var(--primary-soft);border-color:var(--primary-border)}
.fq-opt input{accent-color:var(--primary)}
.fq-opt .txt-other input{border-radius:9px}

/* ---------- 8. 填答页（/s/:id） ---------- */
/* 原粉色渐变背景改成蓝紫，跟管理端统一 */
#bgLayer{
  background:linear-gradient(135deg,#DDE6FF,#E8E2FF,#D9F0FF,#E6E1FF,#DCE8FF,#DDE6FF);
  background-size:400% 400%;
}
:root.dark #bgLayer{
  background:linear-gradient(135deg,#101833,#221A3E,#0F2438,#241B45,#121B33,#101833);
  background-size:400% 400%;
}
#bgShade{background:rgba(255,255,255,.42)}
:root.dark #bgShade{background:rgba(10,14,26,.58)}

.container > #fillRoot > *{
  border-radius:var(--radius-xl);
}
#fillRoot .fill-wrap,#fillRoot .fill-card,#fillRoot .card{
  background:var(--card);
  border:1px solid var(--border);
  box-shadow:var(--shadow-lg);
  border-radius:var(--radius-xl);
  overflow:hidden;
}

/* ---------- 9. 空状态 / 弹窗 / Toast ---------- */
.empty{border-radius:var(--radius-lg);border:1px dashed var(--border-strong);background:color-mix(in srgb,var(--card) 70%,transparent)}
.modal{border-radius:var(--radius-xl);box-shadow:var(--shadow-xl);border:1px solid var(--border)}
.toast{border-radius:12px;box-shadow:var(--shadow-lg);font-weight:600}
input,textarea,select{border-radius:10px}
input:focus,textarea:focus,select:focus{border-color:var(--primary);box-shadow:var(--ring)}

/* ---------- 10. 移动端 ---------- */
@media (max-width:760px){
  .page-head{padding:16px 0 8px;flex-wrap:wrap;gap:8px}
  .page-head h1{font-size:21px}
  .page-head .sub{font-size:12px;margin-top:3px}
  .page-head .right{gap:7px}
  .page-head .right .btn{padding:8px 12px;font-size:12.5px}

  .header-inner{padding:10px 12px;gap:7px;padding-top:calc(10px + env(safe-area-inset-top,0px));padding-top:calc(10px + max(env(safe-area-inset-top,0px),var(--safe-top,0px)))}
  .logo{font-size:15px;gap:8px}
  .logo-badge{width:31px;height:31px;border-radius:10px;font-size:15px}
  .nav-label{display:none}
  #navSettingsBtn{padding:8px 9px}
  #navHomeBtn{display:none}
  #themeToggle{width:34px;height:34px}

  /* 统计卡：4 列紧凑条，不再占半屏 */
  .stat-grid{grid-template-columns:repeat(4,1fr);gap:8px}
  .stat-card{padding:11px 6px 10px;text-align:center;border-radius:13px}
  .stat-card::before{display:none}
  .stat-card .ico{width:27px;height:27px;font-size:13px;margin:0 auto 6px;border-radius:9px}
  .stat-card .num{font-size:19px;letter-spacing:-.4px}
  .stat-card .label{font-size:10px;margin-top:2px}

  .survey-row{padding:13px;border-radius:15px;flex-wrap:wrap;gap:9px}
  .survey-row .s-body{flex:1 1 auto;min-width:0}
  .survey-row .s-count{flex:0 0 auto;margin-left:auto;min-width:62px;padding:6px 10px 7px}
  .survey-row .s-title{white-space:normal;line-height:1.45}
  .survey-row .s-actions{gap:6px;width:100%;justify-content:flex-end}
  .survey-row .s-actions .btn{padding:7px 11px;font-size:12px}
  .survey-row .s-actions .icon-btn{width:30px;height:30px}

  .fill-head{padding:22px 18px 18px}
  .fill-head h2{font-size:18px}
  .fill-body{padding:14px 16px 20px}
  .q-card{border-radius:15px}
}


/* ---------- 11. 列表行「更多」菜单 ---------- */
.survey-row:has(.row-menu.open){z-index:10}
.row-menu-wrap{position:relative;display:flex;align-items:center}
.row-menu-wrap .icon-btn{width:32px;height:32px;border:1px solid var(--border);border-radius:9px;background:var(--card);color:var(--muted);font-size:16px;line-height:1}
.row-menu-wrap .icon-btn:hover{border-color:var(--primary-border);color:var(--primary);background:var(--primary-soft)}
.row-menu{
  position:absolute;right:0;top:calc(100% + 6px);z-index:40;
  min-width:148px;padding:6px;
  background:var(--card);border:1px solid var(--border);border-radius:12px;
  box-shadow:var(--shadow-lg);
  display:none;flex-direction:column;gap:2px;
}
.row-menu.open{display:flex}
.row-menu button{
  border:0;background:none;text-align:left;padding:9px 11px;border-radius:8px;
  font-size:13px;color:var(--text);cursor:pointer;font-family:inherit;
}
.row-menu button:hover{background:var(--soft2)}
.row-menu button.danger{color:var(--danger)}
.row-menu button.danger:hover{background:var(--danger-soft)}

/* ============================================================
   12. 问卷封面（图片 / 预设渐变 + 遮罩）
   ============================================================ */
.fill-head.has-cover{
  min-height:210px;
  background-size:cover;
  background-position:center;
  position:relative;
  min-height:190px;
  padding:46px 26px 34px;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
}
.fill-head.has-cover::before{
  content:"";
  position:absolute;
  inset:0;
  background:linear-gradient(180deg,
    rgba(0,0,0,calc(var(--cover-overlay, .42) * .26)) 0%,
    rgba(0,0,0,calc(var(--cover-overlay, .42) * .72)) 100%);
}
.fill-head.has-cover::after{
  display:block;content:"";position:absolute;inset:0;pointer-events:none;
  background:radial-gradient(520px 220px at 82% -20%,rgba(255,255,255,.30),transparent 70%);
}
.fill-head.has-cover h2,
.fill-head.has-cover .fill-desc,
.fill-head.has-cover .fill-end{
  position:relative;z-index:1;color:#fff;
  text-shadow:0 1px 12px rgba(0,0,0,.4);
}
.fill-head.has-cover .fill-desc{color:rgba(255,255,255,.9)}
.fill-head.cover-sm{min-height:150px;padding:34px 22px 26px}
.fill-head.cover-lg{min-height:300px;padding:64px 28px 48px}
.fill-end{font-size:12.5px;color:var(--muted);margin-top:8px}

/* ============================================================
   13. MBTI 结果页
   ============================================================ */
.mbti-card{
  max-width:600px;
  margin:26px auto;
  padding:38px 30px 26px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:26px;
  box-shadow:var(--shadow-xl);
  text-align:center;
}
.mbti-eyebrow{font-size:10.5px;letter-spacing:.28em;color:var(--muted);text-transform:uppercase}
.mbti-type{
  font-size:clamp(54px,15vw,78px);
  font-weight:800;line-height:1;letter-spacing:.02em;
  margin:16px 0 8px;
  background:var(--grad);
  -webkit-background-clip:text;background-clip:text;color:transparent;
}
.mbti-name{font-size:20px;font-weight:700;color:var(--text);letter-spacing:.02em}
.mbti-dims{display:flex;flex-direction:column;gap:14px;margin:28px 0 4px;text-align:left}
.mbti-dim{display:grid;gap:5px}
.md-head{display:flex;justify-content:space-between;font-size:12px;color:var(--muted);letter-spacing:.02em}
.md-head span.on{color:var(--primary);font-weight:700}
.md-bar{height:8px;border-radius:99px;background:var(--soft2);overflow:hidden}
.md-bar i{display:block;height:100%;border-radius:99px;background:var(--grad);transition:width .9s cubic-bezier(.2,.8,.2,1)}
.md-bar.rtl i{margin-left:auto;background:linear-gradient(270deg,#6D5EF8,#3B5BFE 70%,#7C8CFF)}
.md-num{font-size:10.5px;color:var(--placeholder);text-align:right;font-variant-numeric:tabular-nums}
.mbti-desc{font-size:14.5px;line-height:1.95;color:var(--text-2);text-align:left;margin:24px 0 0}
.mbti-tags{display:flex;gap:7px;flex-wrap:wrap;justify-content:center;margin-top:18px}
.mbti-tag{
  font-size:12px;padding:4px 11px;border-radius:99px;
  background:var(--primary-soft);color:var(--primary-deep);
  border:1px solid var(--primary-border);
}
:root.dark .mbti-tag{color:var(--primary)}
.mbti-ai{
  margin-top:18px;padding:15px 16px;border-radius:14px;
  background:var(--soft);border:1px solid var(--border);
  font-size:13.5px;line-height:1.9;color:var(--text-2);text-align:left;
}
.mbti-actions{display:flex;gap:9px;flex-wrap:wrap;justify-content:center;margin-top:24px}
.mbti-note{margin-top:18px;font-size:11px;color:var(--placeholder);line-height:1.7}
.submit-row{display:flex;justify-content:center;padding:26px 0 8px}
.fq-skipped{display:none!important}

/* ============================================================
   14. 完成彩带
   · confetti/ribbon/stars/bubbles：经典四预设
   · burst（默认）：大号礼花从屏幕左右两侧向中间汇聚喷射 + 中央完成徽章
   ============================================================ */
.confetti-layer{position:fixed;inset:0;pointer-events:none;z-index:9999;overflow:hidden}
.confetti-layer i{
  position:absolute;top:-14vh;left:var(--x);display:block;
  animation-duration:var(--t);animation-delay:var(--d);
  animation-timing-function:cubic-bezier(.2,.45,.5,1);
  animation-fill-mode:both;
}
.cf-confetti i{width:9px;height:14px;background:var(--c);border-radius:2px;animation-name:cfFall}
.cf-ribbon i{width:6px;height:44px;background:var(--c);border-radius:3px;opacity:.92;animation-name:cfRibbon}
.cf-stars i{
  width:13px;height:13px;background:var(--c);
  clip-path:polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%);
  animation-name:cfRise;
}
.cf-bubbles i{width:14px;height:14px;border-radius:50%;background:var(--c);opacity:.65;animation-name:cfRise}
@keyframes cfFall{
  0%{transform:translate3d(0,-10vh,0) rotate(var(--r)) scale(var(--s));opacity:0}
  10%{opacity:1}
  100%{transform:translate3d(6vw,112vh,0) rotate(calc(var(--r) + 540deg)) scale(var(--s));opacity:.9}
}
@keyframes cfRibbon{
  0%{transform:translate3d(0,-14vh,0) rotate(var(--r));opacity:0}
  12%{opacity:1}
  100%{transform:translate3d(-5vw,112vh,0) rotate(calc(var(--r) - 260deg));opacity:.85}
}
@keyframes cfRise{
  0%{transform:translate3d(0,105vh,0) scale(var(--s));opacity:0}
  15%{opacity:1}
  100%{transform:translate3d(3vw,-14vh,0) scale(calc(var(--s) * .7));opacity:0}
}

/* ===== 左右礼花喷射：粒子从两侧出发、向屏幕中间汇聚 ===== */
.cf-burst i{
  position:absolute;top:var(--y);display:block;
  width:var(--w);height:var(--h);
  background:var(--c);border-radius:var(--br,2px);
  animation-name:cfBurst;
  animation-duration:var(--t);animation-delay:var(--d);
  animation-timing-function:cubic-bezier(.12,.72,.3,1);
  animation-fill-mode:both;
  will-change:transform,opacity;
}
.cf-burst i.from-l{left:-7vw}
.cf-burst i.from-r{right:-7vw}
.cf-burst i.sh-star{
  border-radius:0;
  clip-path:polygon(50% 0,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%);
}
@keyframes cfBurst{
  /* 左右礼花 → 向中间喷射 → 越过中线 → 受重力落下 → 淡出 */
  0%{transform:translate3d(0,0,0) rotate(0deg) scale(.45);opacity:0}
  8%{opacity:1}
  46%{transform:translate3d(calc(var(--dir,1) * var(--dx) * .55),-7vh,0) rotate(calc(var(--dir,1) * var(--r) * .55)) scale(var(--s));opacity:1}
  70%{transform:translate3d(calc(var(--dir,1) * var(--dx) * .9),12vh,0) rotate(calc(var(--dir,1) * var(--r) * .8)) scale(var(--s));opacity:1}
  100%{transform:translate3d(calc(var(--dir,1) * var(--dx)),var(--fall,52vh),0) rotate(calc(var(--dir,1) * var(--r))) scale(calc(var(--s) * .86));opacity:0}
}

/* 中央「填写完成」徽章：粒子汇聚后弹出 */
.cf-done{
  position:fixed;left:50%;top:36%;z-index:10000;
  display:flex;flex-direction:column;align-items:center;gap:12px;
  animation:cfDone 2.3s cubic-bezier(.2,.9,.3,1) both;
}
.cf-done-badge{
  width:78px;height:78px;border-radius:50%;
  background:var(--grad);color:#fff;
  display:flex;align-items:center;justify-content:center;
  font-size:38px;font-weight:900;
  box-shadow:0 18px 50px -12px rgba(59,91,254,.65),0 0 0 10px rgba(59,91,254,.12);
}
.cf-done-text{
  font-size:26px;font-weight:800;color:var(--text);
  letter-spacing:.14em;text-indent:.14em;
  text-shadow:0 2px 18px rgba(16,24,40,.18);
}
:root.dark .cf-done-text{text-shadow:0 2px 18px rgba(0,0,0,.5)}
/* 徽章外扩冲击环 */
.cf-done::before{
  content:"";position:absolute;left:50%;top:39px;width:78px;height:78px;border-radius:50%;
  border:2px solid var(--primary);
  animation:cfRing 1.1s cubic-bezier(.2,.8,.3,1) .12s both;
}
@keyframes cfRing{
  0%{opacity:.85;transform:translate(-50%,-50%) scale(1)}
  100%{opacity:0;transform:translate(-50%,-50%) scale(2.8)}
}
@keyframes cfDone{
  0%{opacity:0;transform:translate(-50%,-50%) scale(.4)}
  9%{opacity:1;transform:translate(-50%,-50%) scale(1.14)}
  17%{transform:translate(-50%,-50%) scale(1)}
  76%{opacity:1;transform:translate(-50%,-50%) scale(1)}
  100%{opacity:0;transform:translate(-50%,-50%) scale(1.05)}
}
@media (max-width:760px){
  .cf-done{top:34%}
  .cf-done-badge{width:64px;height:64px;font-size:31px;box-shadow:0 14px 40px -10px rgba(59,91,254,.65),0 0 0 8px rgba(59,91,254,.12)}
  .cf-done::before{top:32px;width:64px;height:64px}
  .cf-done-text{font-size:22px}
}

@media (max-width:760px){
  .fill-head.has-cover{min-height:190px;padding:36px 18px 28px}
  .fill-head.cover-lg{min-height:250px;padding:46px 20px 34px}
  .mbti-card{padding:30px 20px 22px;border-radius:22px;margin:16px auto}
  .mbti-type{font-size:clamp(48px,17vw,64px)}
  .mbti-desc{font-size:14px}
}

/* ============================================================
   15. 问卷设置弹窗 / 逻辑跳转弹窗
   ============================================================ */
.qs-modal{max-width:520px;max-height:88vh;overflow-y:auto}
.qs-modal .m-actions{position:sticky;bottom:-2px;background:var(--card);padding:14px 0 2px;margin-top:18px}
.qs-field{display:flex;flex-direction:column;gap:6px;margin-top:14px}
.qs-field label{font-size:12.5px;color:var(--muted);font-weight:600}
.qs-field label b{color:var(--primary);font-weight:700}
.qs-cover-row{display:flex;gap:8px}
.qs-cover-row .input{flex:1;min-width:0}
.qs-cover-preview{margin-top:8px}
.qs-cover-thumb{height:96px;border-radius:11px;background-size:cover;background-position:center;border:1px solid var(--border)}
.qs-hint{font-size:11.5px;color:var(--placeholder);line-height:1.65}

.logic-modal{max-width:560px;max-height:84vh;overflow-y:auto}
.logic-list{display:flex;flex-direction:column;gap:9px;margin-top:14px}
.logic-row{display:grid;grid-template-columns:minmax(0,1fr) 1.15fr;gap:9px;align-items:center}
.logic-opt{
  font-size:13px;color:var(--text-2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
  background:var(--soft);padding:9px 11px;border-radius:9px;border:1px solid transparent;
}
.q-tools .icon-btn.on{color:var(--primary);border-color:var(--primary-border);background:var(--primary-soft)}

@media (max-width:640px){
  .logic-row{grid-template-columns:1fr}
  .qs-modal,.logic-modal{width:calc(100vw - 28px);padding:20px 16px}
}

.done-wrap{max-width:520px;margin:11vh auto 0}
@media (max-width:760px){.done-wrap{margin:6vh auto 0}}

/* ---------- 16. 长文案按钮防溢出 ---------- */
/* AI 生成按钮运行时长文案再长也自动换行收缩，绝不伸出屏幕 */
#aiGenBtn{max-width:100%;white-space:normal;line-height:1.5;min-height:46px}
.gen-actions{display:flex;gap:10px;margin-top:18px;flex-wrap:wrap}
.gen-actions .btn{max-width:100%}

/* ============================================================
   17. 移动端体验重构：主页卡片 / 编辑页 / 全屏封面 / 等待层
   ============================================================ */

/* ---------- 17.1 主页问卷卡片：一眼区分「出结果」与「收集」 ---------- */
.survey-row{
  display:flex;align-items:center;gap:12px;flex-wrap:wrap;
  padding:15px 16px 15px 20px;border-radius:18px;
}
.survey-row::before{top:0;bottom:0;width:5px;border-radius:0;opacity:1}
.survey-row.is-survey::before{background:linear-gradient(180deg,#3B5BFE,#22D3EE)}
.survey-row.is-test::before{background:linear-gradient(180deg,#8B5CF6,#EC4899)}
.survey-row.is-test{
  border-color:rgba(139,92,246,.26);
  background:linear-gradient(135deg,rgba(139,92,246,.07),rgba(236,72,153,.04) 45%,transparent 70%),var(--card);
}
:root.dark .survey-row.is-test{
  border-color:rgba(167,139,250,.34);
  background:linear-gradient(135deg,rgba(139,92,246,.16),rgba(236,72,153,.08) 45%,transparent 70%),var(--card);
}
.survey-row .s-title{display:flex;align-items:center;gap:6px;white-space:normal;overflow:visible;text-overflow:clip}
.survey-row .s-title-text{overflow-wrap:anywhere;word-break:break-word;line-height:1.45}
.survey-row .s-pet{font-size:17px;flex:none;line-height:1}
.chip-test{background:rgba(139,92,246,.13);color:#7C3AED;border:1px solid rgba(139,92,246,.26)}
.chip-survey{background:rgba(59,91,254,.10);color:#3451E8;border:1px solid rgba(59,91,254,.22)}
:root.dark .chip-test{background:rgba(167,139,250,.18);color:#C4B5FD;border-color:rgba(167,139,250,.32)}
:root.dark .chip-survey{background:rgba(96,124,255,.16);color:#A5B4FC;border-color:rgba(96,124,255,.3)}
.survey-row .s-actions{gap:6px;flex-wrap:wrap}
.survey-row .s-actions .btn{padding:7px 11px;font-size:12.5px}
.survey-row .s-copy{color:var(--text-2)}

/* ---------- 17.2 编辑页：手机上标题独占一行，绝不横向溢出 ---------- */
@media (max-width:640px){
  .app-header{position:static}          /* 手机上不做吸顶，彻底避免内容钻到状态栏下 */
  .q-head{flex-wrap:wrap;row-gap:9px;gap:8px;margin-bottom:10px}
  .q-drag{display:none}
  .q-type-badge{order:1;flex:none}
  .q-req{order:2;margin-left:auto;flex:none}
  .q-tools{order:3;margin-left:0;flex:none}
  .q-tools .icon-btn{width:32px;height:32px}
  .q-title-input{
    order:4;flex:1 1 100%;width:100%;min-width:0;
    font-size:14.5px;line-height:1.55;padding:10px 12px;
    background:var(--soft);border-color:var(--border);
  }
  .q-opt{gap:8px}
  .q-opt-input{min-width:0;flex:1 1 auto;width:100%}
  .add-bar{grid-template-columns:repeat(2,minmax(0,1fr))}
  /* 手机上隐藏右侧预览（与填答页重复且占空间），需要时点「预览」 */
  .editor-right{display:none}
  .page-head .right .btn{padding:8px 11px;font-size:12.5px}
}

/* ---------- 17.3 填答页全屏封面：图片模糊 / 模板渐变铺满整屏 ---------- */
#bgLayer.cover{
  background-size:cover !important;background-position:center !important;
  filter:blur(26px) saturate(1.45) contrast(1.06);
  transform:scale(1.2);
  animation:none !important;
  transition:filter .3s;
}
#bgShade.cover{background:var(--bg-start);opacity:var(--shade-light,.22);transition:opacity .35s}
:root.dark #bgShade.cover{background:#080B14;opacity:var(--shade-dark,.45)}
:root.dark #bgLayer.cover{filter:blur(26px) saturate(1.5) brightness(1.14) contrast(1.02)}
.fill-wrap.has-backdrop{
  background:color-mix(in srgb,var(--card) 90%,transparent);
  backdrop-filter:blur(20px) saturate(1.05);
  -webkit-backdrop-filter:blur(20px) saturate(1.05);
  border-color:color-mix(in srgb,var(--border) 72%,transparent);
}
.fill-head.has-cover{box-shadow:inset 0 -30px 40px -30px rgba(0,0,0,.35)}
.container.fill-page{padding-bottom:calc(70px + max(env(safe-area-inset-bottom,0px),var(--safe-bottom,0px)))}

/* ---------- 17.4 提交后「正在分析结果」等待层 ---------- */
.calc-overlay{
  position:fixed;inset:0;z-index:420;display:flex;align-items:center;justify-content:center;
  padding:calc(24px + var(--safe-top,0px)) 24px calc(24px + var(--safe-bottom,0px));
  background:color-mix(in srgb,var(--bg-start) 76%,transparent);
  backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);
  opacity:0;transition:opacity .25s ease;
}
.calc-overlay.show{opacity:1}
.calc-box{
  width:100%;max-width:330px;text-align:center;
  background:var(--card);border:1px solid var(--border);border-radius:22px;
  padding:30px 24px 26px;box-shadow:var(--shadow-xl);
}
.calc-spin{
  width:40px;height:40px;margin:0 auto 16px;border-radius:50%;
  border:3px solid var(--line);border-top-color:var(--primary);
  animation:spin .85s linear infinite;
}
.calc-box h3{font-size:16px;font-weight:800}
.calc-box p{font-size:12.5px;color:var(--muted);margin-top:7px;line-height:1.65}
.calc-dots{display:flex;gap:6px;justify-content:center;margin-top:16px}
.calc-dots i{width:7px;height:7px;border-radius:50%;background:var(--primary);opacity:.25;animation:calcDot 1.2s infinite ease-in-out}
.calc-dots i:nth-child(2){animation-delay:.18s}
.calc-dots i:nth-child(3){animation-delay:.36s}
@keyframes calcDot{0%,80%,100%{opacity:.22;transform:scale(.85)}40%{opacity:1;transform:scale(1)}}

/* ---------- 17.5 设置弹窗：手机比例的真实封面预览 ---------- */
.qs-cover-preview{margin-top:10px}
.qs-cover-empty{font-size:12px;color:var(--muted);padding:12px;border:1px dashed var(--border-strong);border-radius:12px;text-align:center}
.qs-phone{
  position:relative;width:100%;max-width:220px;margin:0 auto;aspect-ratio:9 / 16;
  border-radius:24px;overflow:hidden;border:1px solid var(--border-strong);
  box-shadow:var(--shadow-lg);background:var(--bg-start);
}
.qs-phone-bg{position:absolute;inset:-20%;background-size:cover;background-position:center;filter:blur(15px) saturate(1.15)}
.qs-phone-shade{position:absolute;inset:0;background:var(--bg-start)}
.qs-phone-ui{position:relative;z-index:1;height:100%;display:flex;flex-direction:column}
.qs-phone-hero{
  padding:14px 13px 22px;color:#fff;
  background:linear-gradient(180deg,rgba(0,0,0,.42),rgba(0,0,0,.12) 70%,transparent);
}
.qs-phone-hero b{display:block;font-size:12.5px;line-height:1.4;text-shadow:0 1px 8px rgba(0,0,0,.5)}
.qs-phone-hero span{display:block;font-size:9.5px;opacity:.88;margin-top:3px;line-height:1.5}
.qs-phone-card{
  margin:10px 10px 12px;padding:11px;border-radius:13px;flex:1;
  background:color-mix(in srgb,var(--card) 92%,transparent);
  border:1px solid color-mix(in srgb,var(--border) 80%,transparent);
  display:flex;flex-direction:column;gap:7px;
}
.qs-phone-card i{display:block;height:7px;border-radius:4px;background:var(--line)}
.qs-phone-card i:nth-child(2){width:78%}
.qs-phone-card i:nth-child(3){width:60%}
.qs-phone-card em{display:block;height:24px;border-radius:8px;background:var(--grad);margin-top:auto}
.qs-preview-tip{font-size:11px;color:var(--muted);text-align:center;margin-top:8px}

/* ---------- 17.6 填答链接弹窗 ---------- */
.link-modal{max-width:420px}
.link-input{width:100%;font-size:12.5px;padding:11px 12px;word-break:break-all}

/* 设置弹窗：底部操作条贴边，滚动时不与预览内容重叠 */
@media (max-width:640px){
  .qs-modal{padding-bottom:0}
  .qs-modal .m-actions{
    position:sticky;bottom:0;z-index:3;
    margin:18px -16px 0;padding:12px 16px calc(14px + max(env(safe-area-inset-bottom,0px),var(--safe-bottom,0px)));
    background:var(--card);border-top:1px solid var(--border);
  }
  .qs-phone{max-width:190px}
}

/* ---------- 17.7 首页紧凑概览（替代四张大卡片） ---------- */
#statGrid{display:block;margin:2px 0 2px}
.dash-summary{
  display:flex;flex-wrap:wrap;align-items:center;gap:4px 9px;
  padding:9px 13px;font-size:12.5px;color:var(--muted);
  background:color-mix(in srgb,var(--card) 72%,transparent);
  border:1px solid var(--border);border-radius:12px;
}
.dash-summary b{color:var(--text);font-size:14px;font-weight:800;margin-right:1px}
.dash-summary i{font-style:normal;opacity:.3}
.dash-summary .sum-test{color:#7C3AED}
:root.dark .dash-summary .sum-test{color:#C4B5FD}

/* 结果明细表：手机上提示可横向滑动 */
.table-hint{display:none;margin-left:auto;font-size:11px;font-weight:400;color:var(--muted)}
@media (max-width:640px){.table-hint{display:inline}}

/* ---------- 17.8 深色模式：封面图要看得见 ---------- */
:root.dark #bgShade.cover{background:#05070E;opacity:var(--shade-dark,.22)}
:root.dark .fill-wrap.has-backdrop{
  background:color-mix(in srgb,var(--card) 76%,transparent);
  backdrop-filter:blur(22px) saturate(1.05);
  -webkit-backdrop-filter:blur(22px) saturate(1.05);
}
:root.dark #bgLayer.cover{filter:blur(26px) saturate(1.55) brightness(1.22) contrast(1.02)}

/* ---------- 17.9 封面裁剪器 ---------- */
.crop-mask{
  position:fixed;inset:0;z-index:500;display:flex;align-items:center;justify-content:center;
  padding:20px;background:rgba(6,10,20,.72);backdrop-filter:blur(6px);-webkit-backdrop-filter:blur(6px);
  animation:fade .18s ease;
}
.crop-box{
  width:100%;max-width:600px;background:var(--card);border:1px solid var(--border);
  border-radius:20px;padding:18px;box-shadow:var(--shadow-xl);
}
.crop-head{display:flex;flex-direction:column;gap:3px;margin-bottom:12px}
.crop-head b{font-size:15px}
.crop-head span{font-size:11.5px;color:var(--muted)}
.crop-stage{
  position:relative;margin:0 auto;border-radius:14px;overflow:hidden;
  background:#000;touch-action:none;cursor:grab;
}
.crop-stage:active{cursor:grabbing}
.crop-stage canvas{display:block}
.crop-grid{
  position:absolute;inset:0;pointer-events:none;
  background-image:
    linear-gradient(to right,transparent 33.33%,rgba(255,255,255,.28) 33.33%,rgba(255,255,255,.28) 33.66%,transparent 33.66%,transparent 66.66%,rgba(255,255,255,.28) 66.66%,rgba(255,255,255,.28) 67%,transparent 67%),
    linear-gradient(to bottom,transparent 33.33%,rgba(255,255,255,.28) 33.33%,rgba(255,255,255,.28) 33.66%,transparent 33.66%,transparent 66.66%,rgba(255,255,255,.28) 66.66%,rgba(255,255,255,.28) 67%,transparent 67%);
}
.crop-tools{display:flex;align-items:center;gap:10px;margin:14px 0 2px;font-size:12px;color:var(--muted)}
.crop-tools input[type=range]{flex:1;accent-color:var(--primary)}
.crop-tools b{min-width:42px;text-align:right;color:var(--text)}
.crop-actions{display:flex;gap:10px;justify-content:flex-end;margin-top:12px}
@media (max-width:640px){.crop-box{padding:14px}.crop-actions .btn{flex:1}}

/* ---------- 17.10 Canvas 彩带 ---------- */
.cf-canvas{position:fixed;inset:0;z-index:9999;pointer-events:none}
.cf-done{
  top:44%;left:50%;transform:translate(-50%,-50%) scale(.72);
  opacity:0;animation:none !important;
  transition:opacity .28s ease,transform .42s cubic-bezier(.2,.9,.3,1);
}
.cf-done.show{opacity:1;transform:translate(-50%,-50%) scale(1)}
.cf-done.out{opacity:0;transform:translate(-50%,-50%) scale(.94)}
