/*
 * 版面規格依 spec 4.2：訪員年齡層偏高、站姿訪問、單手持握。
 * 本文 17px 起、選項整列可點且高度不低於 48px、不使用淺色系。
 */

:root {
  --brand: #E41C2B;          /* 思多葛識別色 */
  --ink: #16181c;
  --ink-soft: #3d434d;
  --line: #b9bfc9;
  --bg: #ffffff;
  --bg-sunk: #eef1f5;
  --bg-locked: #d8dde5;
  --ok: #0f7a3d;
  --warn: #8a4b00;
  --warn-bg: #fff3e0;
  --alert: #b3121f;
  --alert-bg: #fdecee;
  --tap-min: 48px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 0;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg-sunk);
  -webkit-tap-highlight-color: transparent;
}

/* ---- 常駐頁首：訪員編號、車站、時段。錯了會看到 130 餘次（spec 4.2） ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  border-bottom: 4px solid var(--brand);
}

.topbar .sep { opacity: .5; }
.topbar .pending {
  margin-left: auto;
  background: var(--brand);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 15px;
}
.topbar .pending[hidden] { display: none; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 12px 128px;
}

h1 { font-size: 22px; margin: 8px 0 4px; }
h2 {
  font-size: 19px;
  margin: 26px 0 10px;
  padding-bottom: 6px;
  border-bottom: 3px solid var(--brand);
}

/* ---- 題目卡 ---- */
.q {
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin: 0 0 14px;
}

.q-label {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.5;
}
.q-num { color: var(--brand); margin-right: 6px; }

.q-hint {
  color: var(--alert);
  font-weight: 700;
  font-size: 16px;
  margin: -2px 0 10px;
}

.q-scope {
  background: var(--bg-sunk);
  border-left: 5px solid var(--ink-soft);
  padding: 8px 10px;
  margin: 0 0 10px;
  font-size: 16px;
}

.q-card {
  background: #fffbe8;
  border: 2px dashed var(--warn);
  color: var(--warn);
  font-weight: 700;
  padding: 10px 12px;
  margin: 0 0 10px;
  border-radius: 8px;
  font-size: 17px;
}

/* ---- 選項：整列可點，最小 48px ---- */
.opts { display: flex; flex-direction: column; gap: 8px; }

.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--tap-min);
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  font-size: 18px;
}
.opt:active { background: var(--bg-sunk); }
.opt input { width: 26px; height: 26px; flex: none; accent-color: var(--brand); }
.opt.checked { border-color: var(--brand); background: #fdf0f1; font-weight: 700; }
.opt.separated { margin-top: 10px; border-style: dashed; }

/* 特殊值與主量表之間的分隔（spec 4.3） */
.opt.separated::before {
  content: "";
  position: absolute;
}

textarea, input[type="text"], select {
  width: 100%;
  min-height: var(--tap-min);
  font-size: 18px;
  font-family: inherit;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
}
textarea { min-height: 92px; resize: vertical; }
select { min-height: 52px; }

/* ---- 封鎖狀態：灰化但不隱藏，並標示觸發理由（spec 4.4） ---- */
.q.locked { background: var(--bg-locked); border-color: #a8afba; }
.q.locked .opts, .q.locked textarea, .q.locked input, .q.locked select { display: none; }
.q.locked .q-label { color: var(--ink-soft); }
.q-locked-reason {
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--bg);
  border: 2px solid #a8afba;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 16px;
}

/* ---- 錯誤與提示 ---- */
.q.invalid { border-color: var(--alert); box-shadow: 0 0 0 3px var(--alert-bg); }
.q-error { color: var(--alert); font-weight: 700; margin-top: 8px; }

.notice {
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 600;
}
.notice.warn { background: var(--warn-bg); border: 2px solid var(--warn); color: var(--warn); }
.notice.alert { background: var(--alert-bg); border: 2px solid var(--alert); color: var(--alert); }
.notice.ok { background: #e9f7ee; border: 2px solid var(--ok); color: var(--ok); }

/* ---- 底部操作區：單手持握時拇指可及（spec 4.2） ---- */
.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--bg);
  border-top: 3px solid var(--ink);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  z-index: 30;
}
.actionbar > * { flex: 1; }

button {
  min-height: 56px;
  font-size: 19px;
  font-weight: 700;
  font-family: inherit;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.ghost { background: var(--bg-sunk); }
button:disabled { opacity: .55; cursor: default; }

/* ---- 對話框：提示與確認 ---- */
dialog {
  width: min(560px, 94vw);
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 0;
  color: var(--ink);
  background: var(--bg);
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dlg-head {
  background: var(--ink);
  color: #fff;
  padding: 12px 16px;
  font-size: 19px;
  font-weight: 700;
}
.dlg-body { padding: 16px; font-size: 17px; }
.dlg-body ul { margin: 8px 0 0; padding-left: 22px; }
.dlg-body li { margin-bottom: 6px; font-weight: 600; }
.dlg-foot { display: flex; gap: 10px; padding: 0 16px 16px; }
.dlg-foot > * { flex: 1; }

/* ---- 首頁 ---- */
.setup label { display: block; font-weight: 700; font-size: 18px; margin: 16px 0 6px; }
.setup .derived {
  background: var(--bg-sunk);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 700;
}

/* ---- 檢測頁 ---- */
table.check { width: 100%; border-collapse: collapse; background: var(--bg); }
table.check th, table.check td {
  border: 2px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-size: 17px;
}
table.check th { width: 42%; background: var(--bg-sunk); }
.pass { color: var(--ok); font-weight: 700; }
.fail { color: var(--alert); font-weight: 700; }

@media (min-width: 768px) {
  body { font-size: 18px; }
  main { padding: 20px 16px 132px; }
  .opts.compact { flex-direction: row; flex-wrap: wrap; }
  .opts.compact .opt { flex: 1 1 auto; min-width: 150px; }
}
