/* ─────────────────────────────────────────────────────────────
   survey.css —— 问卷页专属样式（封面 / 作答 / 结果三段 + 进度条 + 底部操作条）
   约束：点击热区 ≥44×44px、正文 ≥16px、行高 ≥1.6、安全区适配、360px 无横向滚动。
   ───────────────────────────────────────────────────────────── */

/* ── 页面容器 ── */
.survey {
  position: relative;
  z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter) calc(96px + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
}

/* ── 顶部进度条（sticky） ── */
.progress {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 calc(var(--gutter) * -1);
  padding: 10px var(--gutter) 8px;
  background: rgba(246, 242, 233, .92);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: var(--hairline);
}

.progress__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--color-muted);
}

.progress__part {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-ink);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress__count {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.progress__track {
  margin-top: 8px;
  height: 6px;
  border-radius: 999px;
  background: var(--color-surface-2);
  overflow: hidden;
  border: var(--hairline);
}

.progress__bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-teal), var(--color-accent));
  transition: width var(--dur-slow) var(--ease-out);
}

/* ── 封面区 ── */
.cover {
  padding: 28px 0 8px;
}

.cover__org {
  font-size: 12px;
  letter-spacing: .18em;
  color: var(--color-muted);
  text-transform: none;
}

.cover__title {
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 900;
}

.cover__title em {
  font-style: normal;
  color: var(--color-accent);
}

.cover__intro {
  margin-top: 14px;
  padding: 16px;
  background: var(--color-surface);
  border: var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-ink);
}

.cover__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.cover__actions {
  margin-top: 22px;
}

/* ── 作答区 ── */
.quiz { padding-top: 12px; }

.part-head {
  margin: 6px 0 14px;
  padding-bottom: 10px;
  border-bottom: var(--hairline);
}

.part-head__title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
}

.part-head__sub {
  margin-top: 4px;
  font-size: 13px;
  color: var(--color-muted);
}

/* ── 题目卡片 ── */
.q-card {
  margin-bottom: 14px;
  padding: 16px 14px;
  background: var(--color-surface);
  border: var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}

.q-card.is-error {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(192, 71, 43, .14);
}

.q-card.is-flash {
  animation: q-flash var(--dur-slow) var(--ease-out);
}

@keyframes q-flash {
  0% { box-shadow: 0 0 0 0 rgba(192, 71, 43, .38); }
  100% { box-shadow: var(--shadow-1); }
}

.q-card__head {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.q-card__no {
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--color-accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
}

.q-card__title {
  flex: 1 1 auto;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.6;
  word-break: break-word;
}

.q-card__req {
  color: var(--color-accent);
  font-weight: 700;
  margin-left: 2px;
}

.q-card__note {
  margin-top: 8px;
  font-size: 13px;
  color: var(--color-muted);
  line-height: 1.55;
}

.q-card__note--limit {
  color: var(--color-accent-ink);
}

.q-card__error {
  margin-top: 10px;
  font-size: 13px;
  color: var(--color-accent-ink);
  min-height: 0;
}

/* ── 选项行 ── */
.opts { margin-top: 12px; }

.opt-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  margin-bottom: 8px;
  border: var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  text-align: left;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.opt-row:last-child { margin-bottom: 0; }
.opt-row:hover { background: var(--color-surface-2); }
.opt-row:active { transform: scale(.995); }

.opt-row.is-on {
  background: rgba(47, 93, 98, .10);
  border-color: rgba(47, 93, 98, .45);
}

.opt-row__mark {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin-top: 3px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  position: relative;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}

.opt-row[data-shape="square"] .opt-row__mark { border-radius: 5px; }

.opt-row.is-on .opt-row__mark {
  border-color: var(--color-teal);
  background: var(--color-teal);
}

.opt-row.is-on .opt-row__mark::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  width: 8px;
  height: 4px;
  border-left: 2px solid #FFFDF7;
  border-bottom: 2px solid #FFFDF7;
  transform: rotate(-45deg) translateY(-1px);
}

.opt-row__text {
  flex: 1 1 auto;
  font-size: 16px;
  line-height: 1.6;
  word-break: break-word;
}

.opt-row.is-none .opt-row__text { color: var(--color-muted); }

/* ── 「其他」联动输入 ── */
.other-input {
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid var(--color-accent);
  animation: other-in var(--dur-base) var(--ease-out);
}

@keyframes other-in {
  from { opacity: 0; transform: translate3d(0, -6px, 0); }
  to { opacity: 1; transform: none; }
}

.other-input__field {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  font-size: 16px;
  line-height: 1.5;
}

.other-input__field:focus {
  outline: none;
  border-color: var(--color-accent);
  background: var(--color-surface);
}

/* ── 开放题 ── */
.text-area {
  width: 100%;
  min-height: 96px;
  padding: 12px;
  margin-top: 12px;
  border: var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  font-size: 16px;
  line-height: 1.7;
  resize: vertical;
}

.text-area:focus {
  outline: none;
  border-color: var(--color-accent);
  background: var(--color-surface);
}

.text-area__counter {
  margin-top: 6px;
  text-align: right;
  font-size: 12px;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

/* ── 排序题 ── */
.rank {
  margin-top: 12px;
  border: var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.rank__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-surface-2);
  font-size: 13px;
  color: var(--color-muted);
}

.rank__count { font-variant-numeric: tabular-nums; }

.rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  border: 0;
  border-top: var(--hairline);
  background: var(--color-surface);
  text-align: left;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.rank-item:first-of-type { border-top: 0; }
.rank-item:hover { background: var(--color-surface-2); }
.rank-item.is-on { background: rgba(192, 71, 43, .07); }
.rank-item.is-dragging { opacity: .5; }
.rank-item.is-over { box-shadow: inset 0 2px 0 var(--color-accent); }

.rank-item__seq {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1.5px dashed var(--color-border);
  color: var(--color-muted);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.rank-item.is-on .rank-item__seq {
  border-style: solid;
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #FFF8F2;
}

.rank-item__text {
  flex: 1 1 auto;
  font-size: 16px;
  line-height: 1.55;
  word-break: break-word;
}

.rank-item__ops {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

.rank-item__btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 13px;
  line-height: 1;
}

.rank-item__btn[disabled] { opacity: .35; pointer-events: none; }

.rank-item__grip {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  cursor: grab;
  touch-action: none;
}

.rank__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: var(--hairline);
  background: var(--color-surface-2);
  font-size: 13px;
  color: var(--color-muted);
}

/* ── 底部操作条 ── */
.action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom, 0px));
  background: rgba(246, 242, 233, .94);
  backdrop-filter: saturate(140%) blur(8px);
  border-top: var(--hairline);
}

.action-bar__inner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
}

.action-bar .btn { flex: 1 1 0; }
.action-bar .btn--step { flex: 0 0 auto; min-width: 96px; }

/* ── 结果页 ── */
.result {
  padding: 40px 0 20px;
  text-align: center;
}

.result__seal {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 2px solid var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 900;
  color: var(--color-accent);
  background: rgba(192, 71, 43, .08);
}

.result__title {
  font-size: 22px;
  font-weight: 700;
}

.result__desc {
  margin-top: 10px;
  font-size: 15px;
  color: var(--color-muted);
  line-height: 1.75;
}

.result__code {
  margin: 20px auto 0;
  padding: 14px 16px;
  max-width: 320px;
  border: 1px dashed rgba(192, 71, 43, .45);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.result__code-label {
  font-size: 12px;
  color: var(--color-muted);
  letter-spacing: .08em;
}

.result__code-value {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.result__actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ── 加载 / 错误态 ── */
.state {
  padding: 64px 16px;
  text-align: center;
  color: var(--color-muted);
}

.state__title {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--color-ink);
  margin-bottom: 8px;
}

.state__actions { margin-top: 16px; }

/* ── 桌面端：问卷居中限宽 ── */
@media (min-width: 768px) {
  .survey { padding-bottom: 120px; }
  .cover__title { font-size: 34px; }
  .q-card { padding: 20px 18px; }
}
