:root {
  --bg: #faf6ee;
  --card: #ffffff;
  --text: #2b2118;
  --muted: #6b5d50;
  --primary: #7a4f26;
  --primary-dark: #5c3a1a;
  --soft: #f3e9d8;
  --line: #d8c6a8;
  --ok: #2e6b45;
  --ok-soft: #e4f1e8;
  --warn-soft: #fff3d6;
  --warn-line: #e3c178;
  --danger: #a12b2b;
  font-size: 20px;
}
html.big { font-size: 24px; }
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", sans-serif;
  line-height: 1.6; -webkit-text-size-adjust: 100%;
}
#app { max-width: 640px; margin: 0 auto; padding: 16px 16px 140px; }
h1 { font-size: 1.5rem; margin: 8px 0 4px; line-height: 1.35; }
h2 { font-size: 1.25rem; margin: 0 0 8px; line-height: 1.4; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* 按鈕：一律大、好按 */
button, .btn {
  font: inherit; font-size: 1rem; border: 2px solid var(--primary); background: var(--card);
  color: var(--primary-dark); border-radius: 14px; padding: 14px 18px; min-height: 60px;
  cursor: pointer; width: 100%; text-align: center; font-weight: 600; display: block;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
}
button:active, .btn:active { transform: scale(.98); }
button.primary, .btn.primary { background: var(--primary); color: #fff; }
button.text-btn { border: none; background: none; min-height: 48px; width: auto; padding: 8px 4px; color: var(--primary-dark); text-decoration: underline; }
button.danger { border-color: var(--danger); color: var(--danger); }
:focus-visible { outline: 4px solid #e0a040; outline-offset: 2px; }
.stack > * + * { margin-top: 12px; }

/* 頂列 */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.topbar button { white-space: nowrap; width: auto; min-height: 52px; padding: 8px 14px; font-size: .9rem; }

/* 卡片 */
.card { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 16px; }
.notice { background: var(--soft); border-radius: 14px; padding: 14px 16px; }
.warn { background: var(--warn-soft); border: 2px solid var(--warn-line); border-radius: 14px; padding: 14px 16px; }
.help { background: var(--soft); border-radius: 12px; padding: 12px 14px; color: var(--text); font-size: .95rem; margin: 8px 0 14px; }

/* 首頁四段 */
.section-card { display: flex; align-items: center; gap: 14px; text-align: left; border-color: var(--line); color: var(--text); padding: 16px; }
.section-card .ico { font-size: 2.2rem; line-height: 1; flex: none; }
.section-card .t { font-size: 1.1rem; font-weight: 700; display: block; }
.section-card .p { font-size: .9rem; color: var(--muted); font-weight: 500; display: block; }
.section-card.done { border-color: var(--ok); background: var(--ok-soft); }
.section-card .arrow { margin-left: auto; font-size: 1.4rem; color: var(--primary); }

/* 進度 */
.progress { display: flex; gap: 6px; margin: 6px 0 14px; }
.progress span { flex: 1; height: 10px; border-radius: 5px; background: #e6dccb; }
.progress span.filled { background: var(--primary); }
.progress span.now { background: #e0a040; }

/* 題目 */
.qtext { font-size: 1.3rem; font-weight: 700; line-height: 1.45; margin: 4px 0 10px; }
.opts > * + * { margin-top: 10px; }
.opt { text-align: left; border-color: var(--line); color: var(--text); font-weight: 600; display: flex; align-items: center; gap: 12px; }
.opt .box { flex: none; width: 34px; height: 34px; border: 3px solid var(--line); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; color: #fff; }
.opt.multi .box { border-radius: 8px; }
.opt[aria-pressed="true"] { border-color: var(--primary); background: var(--soft); }
.opt[aria-pressed="true"] .box { background: var(--primary); border-color: var(--primary); }
label.lbl { display: block; font-weight: 600; margin: 16px 0 6px; }
textarea {
  font: inherit; font-size: 1.05rem; width: 100%; border: 2px solid var(--line); border-radius: 12px;
  padding: 12px 14px; background: #fff; color: var(--text); line-height: 1.6; resize: vertical;
}
textarea:focus { border-color: var(--primary); outline: none; }
.mic-tip { font-size: .85rem; color: var(--muted); margin-top: 6px; }

/* 底部固定按鈕列 */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; background: rgba(250,246,238,.97);
  border-top: 2px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.bottombar .inner { max-width: 640px; margin: 0 auto; display: flex; gap: 10px; }
.bottombar button { white-space: nowrap; padding-left: 10px; padding-right: 10px; }
.bottombar .inner > :first-child { flex: 1; }
.bottombar .inner > :last-child { flex: 2; }

/* 自動存檔提示 */
#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ok); color: #fff; padding: 10px 20px; border-radius: 30px; font-size: 1rem;
  font-weight: 700; transition: transform .25s, opacity .25s; z-index: 10; pointer-events: none; white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* 總覽／列印 */
.view-sec { margin-top: 22px; }
.view-sec h2 { border-bottom: 3px solid var(--primary); padding-bottom: 4px; }
.qa { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.qa .q { font-weight: 700; }
.qa .a { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.qa .a.empty { color: #9b8c7c; }
.qa .edit { float: right; margin-left: 8px; }
.sign { margin-top: 28px; display: none; }
.sign div { border-bottom: 2px solid var(--text); height: 44px; margin-bottom: 16px; }
.print-only { display: none; }
.blank { display: none; }

textarea.code { font-family: monospace; font-size: .8rem; }

@media print {
  :root, html.big { font-size: 13pt; }
  body { background: #fff; }
  #app { padding: 0; max-width: none; }
  .no-print, .bottombar, #toast, .edit { display: none !important; }
  .print-only, .sign { display: block; }
  .blank { display: block; border-bottom: 1px solid #555; height: 2.2em; }
  .blank + .blank { margin-top: 0; }
  .view-sec { break-inside: auto; }
  .qa { break-inside: avoid; }
  .card, .notice { border: 1px solid #999; }
}
