/* 心理健康评估量表系统 · 全局样式（心理健康绿 × AI 紫蓝） */
:root {
  --bg: #f2f7f6;
  --bg-grad: linear-gradient(180deg, #eef6f4 0%, #f2f7f6 30%);
  --card: #ffffff;
  --ink: #24332f;
  --ink-soft: #647770;
  --mint: #1fae8f;
  --mint-dark: #178c74;
  --mint-soft: #e2f4ee;
  --ai1: #7b4fd8;
  --ai2: #4f86e8;
  --ai-grad: linear-gradient(135deg, #7b4fd8, #4f86e8);
  --ai-soft: #f0edfc;
  --heal-grad: linear-gradient(135deg, #1fae8f, #4f86e8);
  --warn: #c0552e;
  --warn-soft: #fbeae2;
  --line: #dce8e4;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(36, 51, 47, .06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  background-image: var(--bg-grad);
  color: var(--ink);
  line-height: 1.65;
  padding-bottom: 76px;
}
@media (min-width: 861px) { body { padding-bottom: 0; } }
a { color: var(--mint-dark); }

/* ===== 头部 ===== */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { max-width: 920px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { font-size: 17px; font-weight: 800; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 9px; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; background: var(--heal-grad); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-logo svg { display: block; }
.brand-sub { font-size: 12px; font-weight: 400; color: var(--ink-soft); margin-left: 6px; }
.app-header nav { display: flex; gap: 6px; }
.app-header nav a { text-decoration: none; font-size: 14px; color: var(--ink-soft); padding: 6px 12px; border-radius: 20px; }
.app-header nav a:hover { color: var(--mint-dark); background: var(--mint-soft); }
@media (max-width: 860px) { .app-header nav { display: none; } }

main { max-width: 920px; margin: 0 auto; padding: 18px 14px 40px; }

.storage-warn { max-width: 920px; margin: 10px auto 0; padding: 8px 16px; background: var(--warn-soft); color: var(--warn); font-size: 13px; border-radius: 8px; }

.app-footer { max-width: 920px; margin: 0 auto; padding: 0 16px 32px; font-size: 12.5px; color: var(--ink-soft); }
@media (max-width: 860px) { .app-footer { padding-bottom: 96px; } }

/* ===== 底部导航（移动端） ===== */
.tabbar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255,255,255,.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); }
.tabbar a { flex: 1; text-align: center; padding: 8px 0 10px; text-decoration: none; color: var(--ink-soft); font-size: 11.5px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tabbar a.active { color: var(--mint-dark); }
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.active svg { color: var(--mint-dark); }
@media (max-width: 860px) { .tabbar { display: flex; } }

/* ===== 卡片 ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 6px; font-size: 17px; }
.card .meta { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }

.btn { display: inline-block; border: 1px solid var(--mint); background: var(--mint); color: #fff; border-radius: 10px; padding: 9px 18px; font-size: 14px; cursor: pointer; text-decoration: none; transition: transform .12s, box-shadow .12s; }
.btn:hover { background: var(--mint-dark); border-color: var(--mint-dark); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(31, 174, 143, .25); }
.btn:active { transform: translateY(0); }
.btn.ai { background: var(--ai-grad); border: none; }
.btn.ai:hover { box-shadow: 0 4px 12px rgba(123, 79, 216, .35); }
.btn.secondary { background: var(--card); color: var(--mint-dark); }
.btn.secondary:hover { background: var(--mint-soft); box-shadow: none; }
.btn.danger { background: var(--card); color: var(--warn); border-color: var(--warn); }
.btn.danger:hover { box-shadow: none; background: var(--warn-soft); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn[disabled] { opacity: .6; pointer-events: none; }

/* ===== 首页 hero ===== */
.hero { position: relative; overflow: hidden; background: var(--heal-grad); border-radius: 18px; color: #fff; padding: 26px 190px 26px 24px; margin-bottom: 18px; box-shadow: 0 6px 20px rgba(31, 174, 143, .25); }
.hero-side { position: absolute; right: 24px; top: 50%; transform: translateY(-50%); text-align: center; z-index: 2; }
.hero-qr { background: #fff; border-radius: 12px; padding: 8px 8px 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, .18); display: flex; flex-direction: column; align-items: center; gap: 3px; }
.hero-qr img { width: 116px; height: 116px; display: block; border-radius: 6px; }
.hero-qr span { font-size: 11.5px; color: var(--mint-dark); letter-spacing: 1px; }
.hero::after { content: ""; position: absolute; right: -46px; top: -46px; width: 190px; height: 190px; border-radius: 50%; background: rgba(255,255,255,.12); }
.hero::before { content: ""; position: absolute; right: 60px; bottom: -70px; width: 150px; height: 150px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: .5px; }
.hero p { margin: 0 0 12px; font-size: 13.5px; opacity: .92; max-width: 560px; }
.hero .ai-badge { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); border-radius: 20px; padding: 3px 12px; font-size: 12px; letter-spacing: 1px; }
.ai-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #c7f7e8; box-shadow: 0 0 8px #c7f7e8; animation: pulse 1.8s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

/* ===== 量表卡片网格 ===== */
.scale-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.scale-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.scale-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(36, 51, 47, .1); }
.scale-card .head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.scale-icon { width: 46px; height: 46px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 15px; font-weight: 800; letter-spacing: .5px; flex-shrink: 0; }
.ic-scl { background: linear-gradient(135deg, #2bb3a3, #167d6d); }
.ic-bsi { background: linear-gradient(135deg, #4f86e8, #3868c9); }
.ic-sds { background: linear-gradient(135deg, #55a7e0, #3982b8); }
.ic-ces { background: linear-gradient(135deg, #4fc3b5, #2e9c8e); }
.ic-bdi { background: linear-gradient(135deg, #8a7bf0, #6a56d6); }
.ic-deq { background: linear-gradient(135deg, #6fbf6f, #4b9e4b); }
.scale-card .t { font-size: 16px; font-weight: 700; }
.scale-card .meta { font-size: 12.5px; color: var(--ink-soft); margin: 0 0 8px; }
.scale-card .desc { font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; flex: 1; }
.scale-card .actions { display: flex; gap: 10px; }
.scale-card .actions .btn { flex: 1; text-align: center; padding: 9px 8px; }

/* ===== 答题页 ===== */
.quiz-top { position: sticky; top: 52px; z-index: 20; background: var(--bg); padding: 10px 0 8px; }
.quiz-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.progress-track { height: 8px; background: #e3eeea; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--heal-grad); border-radius: 4px; transition: width .25s; }
.progress-text { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.q-card { padding: 24px 20px; animation: fadeup .25s; }
.q-text { font-size: 16.5px; font-weight: 600; margin-bottom: 16px; }
.q-text .q-no { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 6px; margin-right: 8px; background: var(--mint-soft); color: var(--mint-dark); border-radius: 9px; font-size: 14px; }
.opt-list { display: flex; flex-direction: column; gap: 10px; }
.opt-btn { text-align: left; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 13px 15px; font-size: 14.5px; cursor: pointer; color: var(--ink); transition: border-color .18s, background .18s, transform .12s; }
.opt-btn:hover { border-color: var(--mint); }
.opt-btn.selected { border-color: var(--mint); background: var(--mint-soft); font-weight: 600; }
.opt-btn .opt-score { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 22px; margin-right: 6px; border-radius: 6px; background: rgba(100, 119, 112, .14); color: var(--ink-soft); font-size: 12px; }
.opt-btn.selected .opt-score { background: var(--mint); color: #fff; }
.quiz-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.quiz-note { font-size: 12.5px; color: var(--ink-soft); margin-top: 10px; }

/* ===== 录入模式 ===== */
.entry-banner { display: flex; align-items: center; gap: 8px; background: var(--ai-soft); color: var(--ai1); border-radius: 10px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; }
.entry-group h3 { font-size: 14px; margin: 0 0 10px; color: var(--ink-soft); }
.entry-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.entry-item:last-child { border-bottom: none; }
.entry-item .e-text { flex: 1; font-size: 14px; }
.entry-item .e-no { color: var(--mint-dark); font-weight: 600; min-width: 28px; }
.entry-item select { border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; font-size: 13.5px; background: var(--card); color: var(--ink); max-width: 210px; }

/* ===== 结果报告页 ===== */
.report-head { position: relative; overflow: hidden; background: var(--heal-grad); border: none; color: #fff; border-radius: 18px; padding: 24px 22px; box-shadow: 0 6px 20px rgba(31, 174, 143, .22); }
.report-head h1 { font-size: 20px; margin: 0 0 6px; }
.report-head .sub { font-size: 13px; opacity: .92; }
.report-head .badge { background: rgba(255,255,255,.2); color: #fff; border: 1px solid rgba(255,255,255,.4); }
.badge { display: inline-block; background: var(--mint-soft); color: var(--mint-dark); border-radius: 6px; padding: 2px 8px; font-size: 12px; margin-left: 6px; }
table.metric { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
table.metric th, table.metric td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
table.metric th { background: var(--mint-soft); font-weight: 600; }
.interp { border-left: 4px solid var(--mint); background: var(--mint-soft); border-radius: 0 10px 10px 0; padding: 10px 14px; margin: 10px 0; font-size: 14px; }
.interp .lvl { font-weight: 700; }
.screen-warn { border-left: 4px solid var(--warn); background: var(--warn-soft); border-radius: 0 10px 10px 0; padding: 10px 14px; margin: 10px 0; font-size: 14px; color: var(--warn); }
.bar-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 13.5px; }
.bar-row .bar-label { width: 92px; flex-shrink: 0; color: var(--ink-soft); }
.bar-row .bar-track { flex: 1; height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--heal-grad); border-radius: 6px; }
.bar-row .bar-val { width: 52px; text-align: right; flex-shrink: 0; }
.report-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.norm-note { font-size: 12.5px; color: var(--ink-soft); margin-top: 8px; }

/* AI 评判模块 */
.ai-panel { position: relative; border: 1.5px solid #c9bdf5; background: linear-gradient(180deg, #f8f6ff 0%, #ffffff 60%); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.ai-panel::before { content: ""; position: absolute; top: -1.5px; left: 18px; right: 18px; height: 3px; background: var(--ai-grad); border-radius: 3px; }
.ai-panel .ai-title { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: #fff; background: var(--ai-grad); border-radius: 20px; padding: 3px 14px; letter-spacing: 1px; margin-bottom: 10px; }
.ai-panel .ai-headline { font-size: 14.5px; margin: 4px 0 8px; }
.ai-panel .ai-sec { margin: 8px 0; font-size: 14px; }
.ai-panel .ai-sec-title { font-weight: 700; color: var(--ai1); }
.ai-panel .ai-tips-title { font-weight: 700; color: var(--ai1); margin-top: 10px; font-size: 14px; }
.ai-panel ul { margin: 6px 0 0; padding-left: 20px; }
.ai-panel li { font-size: 13.5px; color: var(--ink-soft); margin: 3px 0; }
.ai-nextstep { display: flex; gap: 9px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-top: 10px; font-size: 13.5px; }
.ai-nextstep .step-icon { flex-shrink: 0; margin-top: 2px; }
.ai-level-tag { display: inline-block; margin-left: 8px; padding: 1px 10px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.ai-level-tag.ok { background: var(--mint-soft); color: var(--mint-dark); }
.ai-level-tag.warn { background: var(--warn-soft); color: var(--warn); }

/* ===== 历史页 ===== */
.hist-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.hist-item:last-child { border-bottom: none; }
.hist-info .h-title { font-weight: 600; font-size: 14.5px; }
.hist-info .h-sub { font-size: 12.5px; color: var(--ink-soft); }
.hist-actions { display: flex; gap: 8px; }
.empty { text-align: center; color: var(--ink-soft); padding: 44px 0; font-size: 14px; }

/* ===== 移动端 ===== */
@media (max-width: 860px) {
  .header-inner { padding: 10px 14px; }
  .brand { font-size: 15px; }
  .hero { padding: 22px 18px; }
  .hero-side { display: none; }
  .hero h1 { font-size: 19px; }
  .scale-grid { grid-template-columns: 1fr; }
  .entry-item { flex-direction: column; }
  .entry-item select { max-width: 100%; width: 100%; }
  .bar-row .bar-label { width: 76px; }
  .opt-btn { padding: 14px 14px; }
  .report-actions { flex-direction: column; }
  .report-actions .btn { text-align: center; }
  .quiz-top { top: 51px; }
}

/* ===== 动效体系 ===== */
@keyframes fadeup { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(.96); } 100% { transform: scale(1); } }
@keyframes growx { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(220%); } }
@keyframes floatA { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-12px, 10px); } }
@keyframes floatB { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(10px, -8px); } }

.scale-card { animation: fadeup .45s ease both; }
.report-head { animation: fadeup .4s ease both; }
.ai-panel { animation: slidein .5s ease both; }
.ai-nextstep { animation: fadeup .5s .1s ease both; }
.entry-banner { animation: fadeup .3s ease both; }

/* hero 装饰光晕缓慢浮动 */
.hero::after { animation: floatA 8s ease-in-out infinite; }
.hero::before { animation: floatB 9s ease-in-out infinite; }

/* 进度条流光 */
.progress-fill { position: relative; overflow: hidden; }
.progress-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent); animation: shimmer 2s ease-in-out infinite; }

/* 按钮按压反馈 */
.btn { transition: transform .14s, box-shadow .14s, background .14s, border-color .14s; }
.btn:active { transform: scale(.95); box-shadow: none; }
.opt-btn:active { transform: scale(.985); }
.opt-btn.selected { animation: pop .2s ease; }
.opt-btn { transition: border-color .18s, background .18s, transform .12s; }

/* 分量表条形图生长 */
.bar-fill { transform-origin: left center; animation: growx .8s ease-out both; }

/* 品牌与底部导航微交互 */
.brand-logo svg { transition: transform .25s ease; }
.brand:hover .brand-logo svg { transform: scale(1.12) rotate(-6deg); }
.tabbar a svg { transition: transform .18s ease, color .18s ease; }
.tabbar a:active svg { transform: scale(.82); }
.tabbar a { transition: color .18s ease; }

/* 历史列表项入场 */
.hist-item { animation: fadeup .35s ease both; }

/* 深色模式：跟随系统偏好 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101614;
    --bg-grad: linear-gradient(180deg, #0d1311 0%, #101614 30%);
    --card: #1b2420;
    --ink: #e2ece8;
    --ink-soft: #8fa39b;
    --line: #2a3731;
    --mint-soft: #1d3a31;
    --ai-soft: #241f3d;
    --warn-soft: #3b2720;
    --shadow: 0 2px 14px rgba(0, 0, 0, .4);
  }
  .app-header { background: rgba(21, 29, 25, .88); }
  .tabbar { background: rgba(21, 29, 25, .95); }
  .ai-panel { background: linear-gradient(180deg, #1d1832 0%, #1b2420 60%); border-color: #473b7d; }
  .ai-nextstep { background: var(--card); }
  .hero-qr { background: #fff; }
  .opt-btn:hover { background: rgba(31, 174, 143, .08); }
  .progress-track { background: #24312c; }
}

/* 无障碍：用户偏好减少动效时关闭动画 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ===== 打印 ===== */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; padding-bottom: 0; }
  main { max-width: none; padding: 0; }
  .card { border: none; box-shadow: none; padding: 0; }
  .report-head { border-radius: 0; }
  .ai-panel, .interp, .screen-warn, .ai-nextstep { break-inside: avoid; }
  table.metric { break-inside: auto; }
  tr { break-inside: avoid; }
  @page { margin: 15mm; }
}