/* ==========================================================
   昕屿心理 · 睡眠测评（PSQI + ISI）样式
   移动端优先，睡眠主题（深蓝靛紫）
   ========================================================== */
:root {
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --bg: #f2f4fb;
  --card: #ffffff;
  --text: #1f2430;
  --text-2: #6b7280;
  --line: #e5e7ef;
  --green: #16a34a;
  --yellow: #d97706;
  --orange: #ea580c;
  --red: #dc2626;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(79, 70, 229, 0.08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

.app { max-width: 640px; margin: 0 auto; min-height: 100vh; }

.hidden { display: none !important; }

/* ---------- 顶部品牌条 ---------- */
.brand-bar {
  background: var(--grad);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 10px rgba(79, 70, 229, 0.25);
}
.brand-bar .logo {
  width: 38px; height: 38px;
  background: #fff;
  border-radius: 10px;
  padding: 3px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-bar .logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-bar .brand-name { font-weight: 700; font-size: 16px; letter-spacing: 1px; }
.brand-bar .brand-sub { font-size: 11px; opacity: 0.85; }

/* ---------- 欢迎页 ---------- */
.welcome { padding: 22px 18px 40px; }
.hero-card {
  background: var(--grad);
  color: #fff;
  border-radius: 20px;
  padding: 26px 22px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: "🌙";
  position: absolute; right: -10px; top: -14px;
  font-size: 96px; opacity: 0.16; transform: rotate(-15deg);
}
.hero-card h1 { margin: 0 0 6px; font-size: 22px; }
.hero-card p { margin: 4px 0; font-size: 14px; opacity: 0.92; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 17px; }
.card p { margin: 6px 0; font-size: 14px; color: var(--text-2); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field .req { color: var(--red); margin-left: 2px; }
.field input[type="text"], .field input[type="tel"], .field input[type="number"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  background: #fafbff;
  outline: none;
  transition: border-color .2s;
}
.field input:focus { border-color: var(--primary); background: #fff; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 18px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fafbff;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
}
.chip.active { background: var(--grad); color: #fff; border-color: transparent; }

.consent { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--text-2); margin: 6px 0 4px; }
.consent input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; }
.consent a { color: var(--primary); }

/* ---------- 按钮 ---------- */
.btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, opacity .2s;
  text-align: center;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(79,70,229,.3); }
.btn-primary:disabled { opacity: .45; box-shadow: none; }
.btn-ghost { background: #eef0fb; color: var(--primary); }
.btn-block { margin-top: 16px; }

/* ---------- 答题向导 ---------- */
.quiz { padding: 0 0 30px; }
.quiz-head {
  background: var(--grad);
  color: #fff;
  padding: 16px 18px 20px;
  position: sticky; top: 0; z-index: 20;
  box-shadow: 0 2px 10px rgba(79,70,229,.25);
}
.quiz-head .top-row { display: flex; align-items: center; gap: 10px; }
.back-btn {
  background: rgba(255,255,255,0.16);
  border: none; color: #fff;
  width: 34px; height: 34px; border-radius: 10px;
  font-size: 18px; cursor: pointer; flex-shrink: 0;
}
.progress-wrap { margin-top: 10px; }
.progress-text { font-size: 12px; opacity: .9; margin-bottom: 4px; }
.progress-bar { height: 6px; background: rgba(255,255,255,.25); border-radius: 999px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: #fff; border-radius: 999px; transition: width .3s; }

.q-card {
  background: var(--card);
  margin: 16px 18px;
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: var(--shadow);
}
.q-index { font-size: 12px; color: var(--primary); font-weight: 700; letter-spacing: 1px; margin-bottom: 8px; }
.q-title { font-size: 20px; font-weight: 700; line-height: 1.5; margin-bottom: 10px; color: var(--text); }
.q-sub { font-size: 14px; color: var(--text-2); margin-bottom: 14px; line-height: 1.5; }

.opt-list { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fafbff;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.opt .dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #c9cddc;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.opt.active { border-color: var(--primary); background: #eef0fe; }
.opt.active .dot { border-color: var(--primary); background: var(--primary); }
.opt.active .dot::after { content: "✓"; color: #fff; font-size: 12px; font-weight: 700; }
.opt .opt-text { font-size: 15px; }

.q-input-wrap { margin-top: 6px; }
.q-input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  font-size: 17px;
  background: #fafbff;
  outline: none;
}
.q-input:focus { border-color: var(--primary); background: #fff; }
.input-unit { display: flex; align-items: center; gap: 10px; }
.input-unit .q-input { flex: 1; }
.input-unit .unit { color: var(--text-2); font-size: 14px; white-space: nowrap; }
.q-extra { margin-top: 12px; }

.err-tip {
  margin-top: 12px;
  background: #fef2f2;
  color: var(--red);
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13.5px;
  display: none;
}
.err-tip.show { display: block; }

/* ---------- 提交中 ---------- */
.submitting { text-align: center; padding: 80px 30px; }
.spinner {
  width: 44px; height: 44px;
  border: 4px solid #e5e7ef;
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 18px;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 报告页 ---------- */
.report { padding: 18px 16px 40px; }
.report-head {
  background: var(--grad);
  color: #fff;
  border-radius: 20px;
  padding: 22px 20px;
  margin-bottom: 16px;
}
.report-head .t { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.report-head .s { font-size: 13px; opacity: .9; }

.sec-title { font-size: 16px; font-weight: 700; margin: 20px 2px 10px; display: flex; align-items: center; gap: 8px; }
.sec-title::before { content: ""; width: 4px; height: 16px; background: var(--grad); border-radius: 2px; }

.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.score-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 14px;
  box-shadow: var(--shadow);
  text-align: center;
}
.score-card .name { font-size: 13px; color: var(--text-2); }
.score-card .num { font-size: 34px; font-weight: 800; margin: 2px 0; line-height: 1.2; }
.score-card .denom { font-size: 13px; color: var(--text-2); }
.band-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: #fff;
  margin-top: 4px;
}

.range-bar { position: relative; margin: 14px 0 8px; }
.range-track { height: 12px; border-radius: 999px; overflow: hidden; display: flex; }
.range-track .seg { flex: 1; }
.marker {
  position: absolute;
  top: -6px;
  width: 4px; height: 24px;
  background: var(--text);
  border-radius: 2px;
  transform: translateX(-2px);
  box-shadow: 0 0 0 2px #fff;
}
.marker::after {
  content: "";
  position: absolute; top: 22px; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--text);
}
.range-legend { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-2); }

.dim-list { display: flex; flex-direction: column; gap: 10px; }
.dim-row { background: var(--card); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.dim-row .dim-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.dim-row .dim-name { font-size: 14px; font-weight: 600; }
.dim-row .dim-val { font-size: 13px; color: var(--text-2); }
.dim-bar { height: 8px; background: #eef0f7; border-radius: 999px; overflow: hidden; }
.dim-bar .fill { height: 100%; border-radius: 999px; transition: width .6s; }

.insight-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.insight-list li {
  background: var(--card);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
  display: flex; gap: 8px;
}
.insight-list li::before { content: "💡"; flex-shrink: 0; }

.suggest-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.suggest-list li {
  background: var(--card);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
  display: flex; gap: 10px;
  align-items: flex-start;
}
.suggest-list .idx {
  width: 22px; height: 22px;
  background: var(--grad); color: #fff;
  border-radius: 50%;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}

.risk-card {
  background: linear-gradient(135deg, #fef2f2, #fff7ed);
  border: 1.5px solid #fca5a5;
  border-radius: 16px;
  padding: 16px;
  margin-top: 8px;
}
.risk-card h3 { margin: 0 0 8px; font-size: 15px; color: var(--red); }
.risk-card p { margin: 6px 0; font-size: 13.5px; color: #7f1d1d; }

.disclaimer {
  background: #f8f9fc;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-2);
  margin-top: 16px;
  border: 1px dashed #d6d9e6;
}
.disclaimer strong { color: var(--text); }

.cta-card {
  background: var(--grad);
  color: #fff;
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  margin-top: 18px;
}
.cta-card h3 { margin: 0 0 6px; font-size: 17px; }
.cta-card p { margin: 0 0 14px; font-size: 13.5px; opacity: .92; }
.cta-card .btn { background: #fff; color: var(--primary); box-shadow: none; }
.cta-card .cta-qr {
  display: block;
  width: 200px;
  max-width: 62%;
  margin: 0 auto 8px;
  border-radius: 12px;
  background: #fff;
  padding: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.cta-card .cta-qr-tip { margin: 0; font-size: 13px; font-weight: 600; opacity: .95; }

.report-foot { text-align: center; font-size: 12px; color: var(--text-2); margin-top: 24px; line-height: 1.8; }

/* ---------- 测评说明页 ---------- */
.intro-card {
  background: var(--card);
  margin: 16px 18px;
  border-radius: var(--radius);
  padding: 30px 22px;
  box-shadow: var(--shadow);
  text-align: center;
}
.intro-icon { font-size: 52px; margin-bottom: 12px; }
.intro-title { font-size: 21px; font-weight: 700; margin-bottom: 12px; }
.intro-desc { font-size: 15px; color: var(--text); line-height: 1.7; margin: 0 0 16px; text-align: left; }
.intro-points { list-style: none; margin: 0 0 22px; padding: 0; text-align: left; }
.intro-points li {
  padding: 9px 14px;
  margin-bottom: 8px;
  background: #eef0fe;
  color: var(--primary);
  border-radius: 12px;
  font-size: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.intro-points li::before { content: "✓"; font-weight: 700; flex-shrink: 0; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 18, 34, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 24px;
}
.modal {
  background: #fff;
  border-radius: 18px;
  padding: 22px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal h3 { margin: 0 0 10px; font-size: 17px; }
.modal p { font-size: 14px; color: var(--text-2); margin: 8px 0; }
.modal .consult-line { color: var(--text); font-weight: 600; }
.modal .btn { margin-top: 14px; }

/* ---------- 打印 ---------- */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  body { background: #fff !important; }
  .no-print { display: none !important; }
  .app { max-width: none; }
  .report { padding: 0; }
  .report-head { border-radius: 0; margin: 0 0 14px; }
  .score-card, .dim-row, .insight-list li, .suggest-list li, .risk-card, .cta-card, .disclaimer, .report-foot {
    box-shadow: none !important;
    break-inside: avoid;
  }
  .sec-title { break-after: avoid; }
}
