/* 扫码调研填报：手机竖屏优先，电脑上居中成一列。字号不小于 16px，避免 iOS 输入框自动放大。 */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1d2129;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1f5fd6;
  --primary-weak: #e9f0fd;
  --danger: #e5484d;
  --danger-weak: #fdecec;
  --ok: #16a34a;
  --warn: #c2410c;
  --radius: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; flex: none; }

.boot, .loading { padding: 48px 16px; text-align: center; color: var(--muted); }

/* 顶栏 */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px 10px;
  background: rgba(244, 245, 247, 0.94);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.top h1 { margin: 0; font-size: 18px; line-height: 1.35; font-weight: 650; }
.top .sub { font-size: 14px; color: var(--muted); margin-top: 2px; }
.back { display: grid; place-items: center; width: 36px; height: 36px; margin-left: -8px; border-radius: 10px; color: var(--text); }
.back .icon { width: 24px; height: 24px; }
.inline-link { margin-left: 4px; }

/* 正文 */
.page { padding: 4px 14px calc(108px + env(safe-area-inset-bottom)); }
.page.center { min-height: 80vh; display: grid; place-items: center; }
.message { text-align: center; padding: 24px 12px; }
.message h2 { margin: 0 0 8px; font-size: 20px; }
.message p { color: var(--muted); margin: 0 0 18px; }
.intro { margin: 4px 2px 10px; color: #374151; white-space: pre-wrap; }
.tip { margin: 2px 2px 8px; font-size: 14px; color: var(--muted); }
.notice {
  margin: 8px 0; padding: 10px 12px; border-radius: 10px;
  background: #fff7ed; color: #9a3412; font-size: 14px;
}
.muted { color: var(--muted); }
.center { text-align: center; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px; margin: 12px 0;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

/* 表单 */
.field-label { display: flex; align-items: baseline; gap: 6px; margin: 4px 0 10px; font-weight: 600; }
.field-label em, .req { font-style: normal; font-size: 12px; font-weight: 500; color: var(--danger); }
.chips + .field-label, .entry-region + .field-label { margin-top: 20px; }
.entry-region { display: block; }
input[type=text], input[type=password], textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fafbfc; font-size: 16px; outline: none; -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-weak); }
textarea { display: block; min-height: 112px; resize: none; line-height: 1.6; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 16px; line-height: 1.25; word-break: break-all;
}
.chips.scroll .chip { flex: none; min-height: 36px; border-radius: 18px; padding: 4px 14px; font-size: 15px; word-break: keep-all; }
.chip[aria-pressed=true] { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 16px; border: 0; border-radius: 12px;
  font-size: 17px; font-weight: 600; text-align: center;
}
.btn.primary { background: var(--primary); color: #fff; }
.btn.ghost { background: var(--primary-weak); color: var(--primary); }
.btn.danger { background: var(--danger-weak); color: var(--danger); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 15px; border-radius: 10px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled { cursor: default; }
.btn.primary:disabled { background: #a8bdf0; }
.btn.ghost:disabled { background: #f0f2f5; color: #a3acb9; }
.btn.danger:disabled { background: #f6f7f9; color: #c4c9d2; }
.link { border: 0; background: none; padding: 4px 2px; color: var(--primary); font-size: 14px; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; gap: 10px;
  max-width: 640px; margin: 0 auto;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97); border-top: 1px solid var(--line);
}
.bar .btn { flex: 1; }

/* 题目卡片 */
.q-title { display: flex; align-items: flex-start; gap: 8px; margin: 0 0 8px; font-size: 17px; line-height: 1.45; font-weight: 650; }
.q-no {
  flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px;
  border-radius: 50%; background: var(--primary-weak); color: var(--primary); font-size: 14px; font-weight: 700;
}
.q-title .req { flex: none; margin-top: 4px; }
.hint { margin: -2px 0 10px 32px; font-size: 14px; color: var(--muted); }
.q-tools { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.status { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); }
.status[data-tone=rec] { color: var(--danger); font-variant-numeric: tabular-nums; }
.status[data-tone=busy] { color: var(--primary); }
.status[data-tone=ok] { color: var(--ok); }
.status[data-tone=warn] { color: var(--warn); }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count.over { color: var(--danger); font-weight: 600; }

.mic {
  --level: 0;
  position: relative; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  height: 42px; padding: 0 18px; border: 0; border-radius: 21px;
  background: var(--primary-weak); color: var(--primary); font-size: 16px; font-weight: 600;
}
.mic.recording { background: var(--danger); color: #fff; }
.mic.recording::before {
  content: ""; position: absolute; inset: -5px; border-radius: 26px;
  border: 2px solid var(--danger); opacity: 0.45;
  transform: scale(calc(1 + var(--level) * 0.18)); transition: transform 0.12s linear;
}
.mic:disabled { opacity: 0.55; }

.raw-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 8px; }
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  background: #ecfdf3; color: var(--ok); font-size: 12px; font-weight: 600;
}
.raw {
  flex-basis: 100%; margin: 4px 0 0; padding: 10px 12px; border-radius: 10px;
  background: #f6f7f9; color: #4b5563; font-size: 14px; white-space: pre-wrap;
}

/* 确认页 */
.who { display: flex; gap: 28px; }
.who div { display: flex; flex-direction: column; gap: 2px; }
.who b { font-size: 17px; }
.answer { margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.65; }
.answer.empty { color: var(--muted); }
.review.bad { box-shadow: inset 0 0 0 1.5px var(--danger); }
.problem { margin: 8px 0 0; color: var(--danger); font-size: 14px; }

/* 完成页 */
.done { text-align: center; padding: 56px 16px 24px; }
.done-mark {
  display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 18px;
  border-radius: 50%; background: var(--ok); color: #fff;
}
.done-mark .icon { width: 44px; height: 44px; }
.done h2 { margin: 0 0 8px; font-size: 24px; }
.done p { margin: 2px 0; }

/* 汇总页 */
.stat { display: flex; align-items: baseline; gap: 6px; margin-bottom: 8px; }
.stat b { font-size: 36px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.counts { width: 100%; border-collapse: collapse; font-size: 15px; }
.counts th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.counts td { padding: 9px 0; border-bottom: 1px solid #f0f1f3; }
.counts tr:last-child td { border-bottom: 0; }
.counts td:first-child { display: flex; align-items: center; gap: 10px; }
.counts td:first-child span:first-child { flex: none; min-width: 4em; }
.counts .num { text-align: right; width: 6em; font-variant-numeric: tabular-nums; font-weight: 600; }
.counts tr.zero td { color: var(--muted); font-weight: 400; }
.meter { flex: 1; height: 6px; border-radius: 3px; background: #eef0f3; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--primary); }

.section-title { margin: 22px 2px 4px; font-size: 16px; font-weight: 650; color: #374151; }
.empty-note { margin: 28px 0; text-align: center; color: var(--muted); }

.insight .q-title { font-size: 16px; }
.points { margin: 0; padding: 0; list-style: none; counter-reset: point; }
.points li { padding: 10px 0; border-top: 1px dashed var(--line); }
.points li:first-child { border-top: 0; padding-top: 2px; }
.point-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.point-n { flex: none; color: var(--primary); font-weight: 650; font-size: 15px; font-variant-numeric: tabular-nums; }
.points p { margin: 4px 0 0; font-size: 15px; color: #374151; }
.points blockquote {
  margin: 6px 0 0; padding: 2px 0 2px 10px; border-left: 3px solid var(--line);
  color: var(--muted); font-size: 14px;
}
.foot { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
.insight .btn { margin-top: 8px; }

.entry-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.entry-head .muted { margin-left: auto; font-size: 13px; }
.entry.mine { box-shadow: inset 0 0 0 1.5px var(--primary-weak); }
.entry-qa h4 { margin: 12px 0 4px; font-size: 14px; font-weight: 500; color: var(--muted); }
.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* 管理页 */
.admin-title { margin: 0 0 4px; font-size: 18px; }
summary.admin-title { cursor: pointer; font-weight: 600; }
.admin-form { display: grid; gap: 16px; margin-top: 16px; }
.admin-form input[type=text], .admin-form input[type=password], .admin-form textarea { margin-top: 6px; }
.admin-form .problem:empty { display: none; }
.admin-question { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; margin: 8px 0; }
.admin-check { display: inline-flex; align-items: center; gap: 6px; }
.link-box {
  margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: #f6f7f9;
  font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; word-break: break-all;
}
.row { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-list { margin-top: 8px; }
.admin-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid #f0f1f3; }

/* 提示与遮罩 */
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); z-index: 50;
  max-width: 86vw; padding: 10px 16px; border-radius: 12px;
  background: rgba(29, 33, 41, 0.92); color: #fff; font-size: 15px; text-align: center;
  transform: translate(-50%, -12px); opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(255, 255, 255, 0.88); color: #374151;
}
.overlay p { margin: 0; }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid var(--primary-weak); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
  .mic.recording::before, .toast { transition: none; }
}
