:root {
  --ink: #17352f;
  --ink-soft: #516760;
  --green: #176b58;
  --green-dark: #0d4f41;
  --green-pale: #e8f3ef;
  --cream: #f7f4eb;
  --paper: #fffefa;
  --line: #dbe3de;
  --gold: #b88735;
  --gold-pale: #f8efd9;
  --danger: #a94e43;
  --shadow: 0 18px 50px rgba(32, 65, 56, .09);
  --shadow-sm: 0 8px 26px rgba(32, 65, 56, .07);
  --radius: 22px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 4%, rgba(184, 135, 53, .09), transparent 24rem),
    radial-gradient(circle at 92% 10%, rgba(23, 107, 88, .10), transparent 27rem),
    var(--cream);
  font-family: "Noto Sans TC", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }

button, summary, .drop, .file-label { -webkit-tap-highlight-color: transparent; }

button, .drop, summary, .file-label { cursor: pointer; }

.wrap {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

header {
  position: relative;
  overflow: hidden;
  padding: 38px 42px 34px;
  color: #fff;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, .06), transparent 48%),
    var(--green-dark);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 28px;
  box-shadow: 0 22px 54px rgba(13, 79, 65, .19);
}

header::before,
header::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 50%;
  pointer-events: none;
}

header::before { width: 320px; height: 320px; right: -108px; top: -190px; }
header::after { width: 210px; height: 210px; right: 22px; top: -138px; }

.brand-row,
.step-head,
.export-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow,
.step-kicker {
  display: block;
  margin-bottom: 5px;
  color: #f0d49c;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-family: "Noto Serif TC", serif;
  font-weight: 600;
  letter-spacing: .035em;
}

h1 { font-size: clamp(34px, 5vw, 52px); line-height: 1.2; }
h2 { color: var(--ink); font-size: clamp(24px, 3vw, 30px); line-height: 1.35; }

.privacy,
.local-note {
  flex: none;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.privacy {
  color: #e9f7f2;
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .14);
  backdrop-filter: blur(8px);
}

.privacy span {
  margin-right: 6px;
  color: #7ed8bb;
  font-size: 9px;
}

.lead {
  max-width: 660px;
  margin: 13px 0 28px;
  color: rgba(255, 255, 255, .76);
  font-size: 16px;
}

.flow {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow::before {
  content: "";
  position: absolute;
  top: 17px;
  left: 7%;
  right: 7%;
  height: 1px;
  background: rgba(255, 255, 255, .18);
}

.flow li {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 36px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  padding-right: 12px;
  /* 深綠底上的說明文字。.5 的白在這個底色上對比不足（約 2.6:1），
     提高到 .72 才達得到 WCAG AA 的 4.5:1。 */
  color: rgba(255, 255, 255, .72);
}

.flow li > span {
  grid-row: 1 / 3;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  font: 600 12.5px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .02em;
  color: rgba(255, 255, 255, .85);
  background: #1d5b4e;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 50%;
  font-weight: 600;
}

.flow li b { color: rgba(255, 255, 255, .88); font-size: 13px; line-height: 1.4; }
.flow li small { font-size: 11.5px; }
.flow li.active { color: #fff; }
.flow li.active > span { color: var(--green-dark); background: #f0d49c; border-color: #f0d49c; }
.flow li.active b { color: #fff; }

.step {
  margin-top: 24px;
  padding: 34px;
  background: rgba(255, 254, 250, .94);
  border: 1px solid rgba(219, 227, 222, .92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.step-head { margin-bottom: 24px; }
.step-kicker { color: var(--gold); }

.hint {
  max-width: 760px;
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.local-note {
  margin-top: 3px;
  color: var(--green);
  background: var(--green-pale);
}

.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.upload-card {
  position: relative;
  padding: 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 2px 0 rgba(23, 53, 47, .02);
}

.upload-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.upload-label span {
  padding: 2px 7px;
  color: var(--green-dark);
  background: var(--green-pale);
  border-radius: 5px;
}

.source-guide {
  min-height: 125px;
  margin-bottom: 14px;
  padding: 14px 15px;
  color: var(--ink-soft);
  background: #f8faf8;
  border: 1px solid #e8ede9;
  border-radius: 12px;
}

.source-title {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.source-path { color: var(--green); font-size: 12px; font-weight: 600; }
.source-path i { padding: 0 3px; color: #a1b0aa; font-style: normal; }
.source-guide p { margin: 7px 0 0; font-size: 12px; line-height: 1.55; }
.source-guide strong { color: var(--gold); }

.drop {
  position: relative;
  display: flex;
  min-height: 210px;
  padding: 27px 20px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  background: linear-gradient(180deg, #fcfefd, #f6faf8);
  border: 1.5px dashed #a9c7bc;
  border-radius: 16px;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
  outline: none;
}

.drop:hover,
.drop:focus-visible {
  transform: translateY(-2px);
  background: #f4faf7;
  border-color: var(--green);
  box-shadow: 0 10px 28px rgba(23, 107, 88, .10);
}

.drop input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 12px;
  place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 15px;
  font-family: "Noto Serif TC", serif;
  font-size: 16px;
  box-shadow: 0 7px 15px rgba(23, 107, 88, .18);
}

.drop-icon.pdf { font-family: inherit; font-size: 11px; letter-spacing: .05em; }
.drop strong { margin-bottom: 2px; color: var(--ink); font-size: 16px; }
.drop > span:not(.drop-icon) { max-width: 330px; color: #71837d; font-size: 12px; }

.drop em {
  margin-top: 15px;
  padding: 7px 15px;
  color: var(--green);
  background: #fff;
  border: 1px solid #b9d0c7;
  border-radius: 9px;
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
}

.ocr-info,
.demo-box {
  margin-top: 12px;
  padding: 11px 13px;
  color: #6f624a;
  background: #fcf7ea;
  border: 1px solid #efe2c2;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.6;
}

.ocr-info b,
.demo-box b { color: #7f6028; }

.demo-link,
.link-btn {
  padding: 0;
  color: var(--green);
  background: none;
  border: 0;
  font-size: 12px;
  font-weight: 600;
}

.demo-link {
  display: flex;
  margin-top: 13px;
  align-items: center;
  gap: 7px;
}

.demo-link:hover,
.link-btn:hover { color: var(--green-dark); text-decoration: underline; }

.demo-ico {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: var(--gold);
  background: var(--gold-pale);
  border-radius: 50%;
  font-size: 10px;
}

.demo-dl { margin-top: 6px; }
.demo-dl summary { color: #7f6028; font-weight: 600; }
.demo-links { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 7px; }
.demo-links a { color: var(--green); text-underline-offset: 2px; }

.loaded,
.warnbox {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 12px;
  padding: 11px 14px;
  color: var(--green-dark);
  background: var(--green-pale);
  border: 1px solid #cfe4dc;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  animation: fadein .35s both;
}

/* 成功狀態前面加個勾號，一眼看出「這一步完成了」 */
.loaded:not(.err):not(.progress)::before {
  content: "✓";
  flex: none;
  font: 600 12px ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--green);
}

details {
  margin-top: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

details > summary {
  display: flex;
  padding: 15px 17px;
  align-items: center;
  gap: 12px;
  list-style: none;
  font-weight: 600;
}

details > summary::-webkit-details-marker { display: none; }

details > summary::after {
  content: "+";
  margin-left: auto;
  color: var(--green);
  font-size: 21px;
  font-weight: 400;
  line-height: 1;
}

details[open] > summary::after { content: "−"; }
details > summary small { color: #80908a; font-size: 11px; font-weight: 400; }

.compact-drop,
.panel-body,
.settings {
  margin: 0 16px 16px;
  border-top: 1px solid #edf0ee;
}

.compact-drop {
  min-height: 90px;
  padding: 14px 16px;
  flex-direction: row;
  justify-content: flex-start;
  text-align: left;
}

.compact-drop .drop-icon { flex: none; width: 42px; height: 42px; margin: 0 12px 0 0; }
.compact-copy { display: flex; flex-direction: column; }
.compact-copy small { color: #7c8d87; }
.compact-drop em { margin: 0 0 0 auto; }

.settings {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 15px;
  padding-top: 16px;
  align-items: end;
}

.panel-body { padding-top: 2px; }

.field-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 15px;
  align-items: end;
}

.field-row > label:not(.check-label) { min-width: 210px; flex: 1; }

.field-label,
.field-row > label:not(.check-label) {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

input[type="text"],
input[type="url"],
input[type="password"],
select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cdd8d3;
  border-radius: 9px;
  outline: none;
}

input:focus,
select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 88, .10); }

.check-label {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--green);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 20px;
}

.primary,
.ghost,
.file-label {
  display: inline-flex;
  min-height: 42px;
  padding: 0 15px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.primary {
  color: #fff;
  background: var(--green);
  border: 1px solid var(--green);
  box-shadow: 0 8px 18px rgba(23, 107, 88, .18);
}

.primary:hover:not(:disabled) { transform: translateY(-1px); background: var(--green-dark); }
.primary:disabled { cursor: not-allowed; opacity: .45; box-shadow: none; }

.ghost,
.file-label {
  color: var(--green-dark);
  background: #fff;
  border: 1px solid #c9d6d1;
}

.ghost:hover,
.file-label:hover { background: #f4f8f6; border-color: #99b7ac; }
.file-label { position: relative; }

.summary {
  padding: 6px 11px;
  color: #7f6028;
  background: var(--gold-pale);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.tally,
.hist {
  margin-top: 15px;
  padding: 14px;
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.history-global { width: min(1180px, calc(100% - 40px)); margin: 18px auto 0; }
.warnbox { color: #7b3b34; background: #fbefec; border-color: #efd3ce; }

.foot {
  margin: 22px 8px 0;
  padding: 20px 22px;
  color: #6d7d77;
  background: rgba(255, 255, 255, .52);
  border: 1px solid rgba(219, 227, 222, .8);
  border-radius: 15px;
  font-size: 11px;
}

.foot code {
  padding: 2px 6px;
  color: var(--green-dark);
  background: #e7efeb;
  border-radius: 5px;
  font-family: inherit;
}

.foot-meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; color: #91a099; }

@media (max-width: 760px) {
  .wrap { width: min(100% - 24px, 1180px); padding-top: 12px; }
  header { padding: 27px 22px 24px; border-radius: 20px; }
  .brand-row, .step-head, .export-title { flex-direction: column; gap: 12px; }
  .privacy, .local-note { align-self: flex-start; }
  .lead { margin-bottom: 24px; }
  .flow { grid-template-columns: repeat(2, 1fr); row-gap: 16px; }
  .flow::before { display: none; }
  .flow li { grid-template-columns: 31px 1fr; }
  .flow li > span { width: 31px; height: 31px; }
  .step { padding: 23px 18px; border-radius: 18px; }
  .grid2, .settings { grid-template-columns: 1fr; }
  .source-guide { min-height: auto; }
  details > summary { align-items: flex-start; }
  details > summary small { display: none; }
  .compact-drop { align-items: flex-start; }
  .compact-drop em { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}


/* ===========================================================
   逐筆核對區與其餘元件
   沿用上方的配色變數，色彩對應：
     --indigo → --green      主色
     --vermil → --danger     警示、核章
     --stone  → --ink-soft   次要文字
     --hair   → --line       框線
   =========================================================== */

/* 頁首與流程列的樣式在檔案前段（深綠底那組），這裡不重複定義。
   舊版是淺色底的寫法，留著會覆蓋前面的設定，把金色的目前步驟蓋成深綠。 */

/* 已完成的步驟：比未完成亮，但不搶走目前步驟的金色 */
.flow li.done > span { background: rgba(255, 255, 255, .22); color: #fff; }
.flow li.done b { color: rgba(255, 255, 255, .92); }

/* ---------- 步驟區塊 ---------- */

.step-head h2, .export-title h2 {
  font-family: "Noto Serif TC", serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .04em;
  margin: 1px 0 2px;
}

.step-head .hint { margin: 0; color: var(--ink-soft); font-size: 13.5px; }

.step[hidden] { display: none; }

/* ---------- 檔案投放區 ---------- */

.drop span { color: var(--ink-soft); font-size: 12.5px; }

.drop .drop-icon {
  display: grid; place-items: center; width: 34px; height: 34px; margin: 0 auto;
  border-radius: 9px; color: var(--green); background: var(--green-pale);
  font: 600 12px "Noto Serif TC", serif;
}

.drop .drop-icon.pdf { width: 42px; font: 600 10px ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .03em; }

.drop input { display: none; }

/* 兩欄的內容量不同（左邊多一塊下載路徑說明），用 flex 讓上傳框自己撐開，
   標籤與範例按鈕才會左右對齊。 */

.upload-card .drop { flex: none; }

/* 說明框高度可能不同，設個下限讓兩邊的上傳框從同一條線開始 */
.upload-card .source-guide { min-height: 92px; }

/* 說明區塊固定在上傳框之後，不參與撐開 */
.upload-card .loaded,
.upload-card .ocr-info,
.upload-card .demo-link,
.upload-card .demo-box { flex: none; }

.upload-label.optional span { color: var(--green); background: var(--green-pale); }

.source-guide p strong { color: var(--danger); margin-right: 3px; }

/* ---------- 已載入摘要 ---------- */

.loaded.err { background: var(--gold-pale); color: var(--danger); border-color: #F0D3CF; }

.loaded b { font-weight: 600; }

/* ---------- 設定 ---------- */
.settings-panel, .optional-panel { margin-top: 18px; border-top: 1px solid var(--line); }

.settings-panel summary, .optional-panel summary {
  display: flex; align-items: baseline; gap: 10px; padding-top: 14px;
  color: var(--green); cursor: pointer; list-style: none; width: fit-content;
}

.settings-panel summary::-webkit-details-marker, .optional-panel summary::-webkit-details-marker { display: none; }

.settings-panel summary::before, .optional-panel summary::before { content: "＋"; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.settings-panel[open] summary::before, .optional-panel[open] summary::before { content: "−"; }

.settings-panel summary span, .optional-panel summary span { font-weight: 600; font-size: 13.5px; }

.settings-panel summary small, .optional-panel summary small { color: var(--ink-soft); font-size: 12px; }

.compact-drop .compact-copy { flex: 1; color: var(--ink); }

.compact-drop .compact-copy strong { margin: 0; }

.compact-drop .compact-copy small { display: block; color: var(--ink-soft); font-size: 11.5px; }

.settings label {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  background: #F8FAFB; border: 1px solid #E7EBEE; border-radius: 7px; padding: 10px 12px;
}

.settings .field-label { justify-content: space-between; }

.settings .field-label > span { color: var(--ink-soft); font-size: 12px; }

.settings .check-label small { display: block; color: var(--ink-soft); font-size: 10.5px; line-height: 1.3; }

.settings input[type=text] {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; width: 112px;
  padding: 5px 7px; border: 1px solid var(--line); border-radius: 5px; background: #fff;
}

.settings select { max-width: 170px; }

/* ---------- 公文分組 ---------- */
.doc { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 16px; background: var(--paper); overflow: hidden; }

.doc-head { padding: 14px 18px; border-bottom: 1px solid var(--line); background: #FBFBFA; }

.doc-head h3 {
  font-family: "Noto Serif TC", serif; font-size: 15.5px; font-weight: 600;
  margin: 0 0 4px; line-height: 1.5;
}

.doc-meta { font-size: 12.5px; color: var(--ink-soft); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.doc-note {
  margin-top: 9px; font-size: 13px; padding: 7px 11px; border-radius: 2px;
  border-left: 3px solid var(--gold); background: var(--gold-pale); color: var(--gold);
}

.doc-note.fail { border-left-color: var(--danger); background: var(--gold-pale); color: var(--danger); }

/* ---------- 人員列 ---------- */
.row { display: grid; grid-template-columns: 46px 1fr; border-top: 1px solid #EFEEE9; }

.doc-body > .row:first-child { border-top: none; }

.row.off { opacity: .78; }

/* 未核章的列正是需要操作的列，按鈕和下拉不能看起來像停用 */
.row.off select,
.row.off button,
.row.off textarea { opacity: 1; }

/* 核章 */
.seal { display: flex; align-items: flex-start; justify-content: center; padding: 16px 0 0; }

.seal button {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
  border: 1.5px solid var(--line); background: #fff;
  font-family: "Noto Serif TC", serif; font-size: 13px; color: transparent;
  transition: transform .12s ease, background .12s, border-color .12s, color .12s;
}

.seal button:hover { border-color: var(--danger); }

.seal button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.seal button[aria-pressed="true"] {
  background: var(--danger); border-color: var(--danger); color: #fff;
  animation: press .22s ease;
}

.fields { padding: 12px 18px 16px 4px; }

.line1 { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 9px; }

.badge {
  font-size: 11.5px; padding: 2px 8px; border-radius: 2px; font-weight: 600; letter-spacing: .02em;
}

.badge.ok    { background: var(--green-pale); color: var(--green); }

.badge.typo  { background: var(--gold-pale); color: var(--gold); }

.badge.check { background: #f7e9e6; color: var(--danger); }

select:focus-visible, textarea:focus-visible, input:focus-visible {
  outline: 2px solid var(--green); outline-offset: 1px;
}

.pid { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; color: var(--ink-soft); }

.title-txt { font-size: 13px; color: var(--ink-soft); }

.written { font-size: 12.5px; color: var(--gold); }

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

.reason textarea {
  flex: 1; min-height: 34px; resize: vertical; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 2px; font-size: 13.5px; line-height: 1.6;
}

.count { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 11.5px; color: var(--ink-soft); min-width: 52px; text-align: right; padding-top: 8px; }

.count.over { color: var(--danger); font-weight: 600; }

details.more { margin-top: 9px; }

details.more summary {
  cursor: pointer; font-size: 12.5px; color: var(--green); list-style: none; width: fit-content;
}

details.more summary::-webkit-details-marker { display: none; }

details.more summary::before { content: "▸ "; }

details.more[open] summary::before { content: "▾ "; }

.more-grid {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  margin-top: 9px; padding: 11px 13px; background: #FAFAF8;
  border: 1px solid #EFEEE9; border-radius: 2px; font-size: 12.5px;
}

.more-grid label { display: flex; align-items: center; gap: 5px; color: var(--ink-soft); }

.more-grid .law { font-size: 12.5px; color: var(--ink-soft); }

.more-grid .num { width: 46px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; padding: 3px 5px; }

/* ---------- 動作列 ---------- */

#step4 { position: sticky; bottom: 12px; z-index: 5; border-color: #CAD5DD; box-shadow: 0 12px 38px rgba(28, 49, 67, .16); }

button.primary, button.ghost {
  font-family: inherit; font-size: 14px; padding: 9px 20px;
  border-radius: 6px; cursor: pointer; border: 1px solid;
}

button.primary { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; letter-spacing: .04em; }

button.primary:hover { background: #A82D24; border-color: #A82D24; }

button.primary:disabled { background: var(--line); border-color: var(--line); color: #999; cursor: not-allowed; }

button.ghost { background: #fff; border-color: var(--line); color: var(--ink); }

button.ghost:hover { border-color: var(--green); color: var(--green); }

button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.summary b { color: var(--ink); font-weight: 600; }

/* ---------- 職稱沿革 ---------- */

.hist-head { color: var(--green); font-size: 12.5px; margin-bottom: 7px; }

.hist-row { display: flex; gap: 12px; padding: 3px 0; align-items: baseline; }

.hist-title {
  font-weight: 600; min-width: 80px; font-family: "Noto Serif TC", serif; letter-spacing: .04em;
}

/* ---------- 手動新增一筆 ---------- */
.add-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 18px; border-top: 1px dashed var(--line); background: #FCFCFB;
}

.add-btn { font-size: 13px; padding: 5px 14px; }

.add-hint { font-size: 12.5px; color: var(--ink-soft); }

.link-btn:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- 候選人直接點選 ---------- */
.picks { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.picks-label { font-size: 12.5px; color: var(--danger); margin-right: 2px; }

.pick {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 4px 11px; cursor: pointer; background: #fff;
  border: 1px solid var(--line); border-radius: 2px;
  font-family: inherit; text-align: left;
}

.pick:hover { border-color: var(--green); }

.pick:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.pick.on { border-color: var(--danger); background: #f7e9e6; }

.pick-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }

.pick.on .pick-name { color: var(--danger); }

.pick-sub { font-size: 11.5px; color: var(--ink-soft); }

/* ---------- 公文檔名 ---------- */
.doc-file {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 5px; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; color: var(--ink-soft);
}

/* 檔名可能很長，截斷但保留 title 讓滑鼠停留看得到全名 */
.doc-file span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.file-mark {
  flex: none; width: 9px; height: 11px; border: 1px solid var(--ink-soft);
  border-radius: 1px; border-top-right-radius: 3px; opacity: .65;
}

/* ---------- 依據子句（每份公文只顯示一次） ---------- */
.doc-basis {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-soft);
}

.doc-basis-tag {
  flex: none; font-size: 11.5px; color: var(--green);
  border: 1px solid #C8D4DF; border-radius: 2px; padding: 1px 7px;
}

/* ---------- 每份公文的核章計數 ---------- */
.doc-head-main { display: flex; align-items: flex-start; gap: 16px; }

.doc-titles { flex: 1; min-width: 0; }

.doc-count {
  flex: none; margin-top: 2px; padding: 3px 11px; border-radius: 2px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
}

.doc-count.all  { border-color: var(--line); background: var(--green-pale); color: var(--green); }

.doc-count.part { border-color: #E5D5AE; background: var(--gold-pale); color: var(--gold); }

/* info 只是說明資料來源，不是警告，用中性的靛色 */
.doc-note.info {
  border-left-color: var(--green); background: #F6F8FA; color: var(--green);
}

/* ---------- 本次獎度統計 ---------- */

.tally-item {
  display: flex; align-items: baseline; gap: 7px;
  padding: 5px 13px; border: 1px solid var(--line); border-radius: 2px; background: #fff;
}

.tally-label { font-size: 12.5px; color: var(--ink-soft); }

.tally-num { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 15px; font-weight: 600; color: var(--ink); }

/* ---------- 版本與累計 ---------- */

.lifetime { color: var(--green); }

.visits { color: var(--ink-soft); }

/* ---------- 每份公文的一鍵核章 ---------- */
.doc-tools { display: flex; align-items: center; gap: 8px; flex: none; }

.doc-seal {
  padding: 4px 12px; border-radius: 2px; cursor: pointer; white-space: nowrap;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--danger); background: #fff; color: var(--danger);
}

.doc-seal:hover { background: var(--danger); color: #fff; }

.doc-seal.on { border-color: var(--line); color: var(--ink-soft); font-weight: 400; }

.doc-seal.on:hover { background: #fff; border-color: var(--danger); color: var(--danger); }

.doc-seal:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- Mac OCR 設定 ---------- */

.field-row label {
  display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-soft);
}

.field-row input {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; padding: 6px 9px; min-width: 240px;
  border: 1px solid var(--line); border-radius: 2px; background: #fff;
}

.field-row input:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }

.field-row button { align-self: flex-end; }

/* ---------- 記憶 ---------- */
.from-memory {
  font-size: 12.5px; color: var(--green);
  border-bottom: 1px dotted var(--green); padding-bottom: 1px;
}

.file-label:focus-within { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---------- 「目」選單 ---------- */
.item-label { flex: 1 1 100%; }

.item-sel {
  max-width: 100%; font-size: 12.5px; padding: 3px 6px;
  border: 1px solid var(--line); border-radius: 2px; background: #fff;
}

/* ---------- 辨識進度 ---------- */
.loaded.progress {
  display: block;   /* 進度條是縱向的三塊，不套用 .loaded 的橫向 flex */
  background: #F6F8FA; border-color: #DCE3EA; color: var(--ink);
  padding: 14px 16px;
}

.pg-head {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 9px;
}

.pg-count {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; color: var(--green); flex: none;
}

.pg-file {
  flex: 1; min-width: 0; font-size: 13px; color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 百分比是使用者最關心的資訊，放大到一眼就看得到 */
.pg-pct {
  flex: none; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 26px; font-weight: 600;
  line-height: 1; color: var(--green); font-variant-numeric: tabular-nums;
}

.pg-detail { margin-top: 8px; font-size: 13px; color: var(--ink-soft); }

.pb {
  height: 8px; border-radius: 4px; background: #E4E9EE; overflow: hidden;
}

.pb-fill {
  height: 100%; border-radius: 4px; background: var(--green);
  transition: width .3s ease;
}

/* 進度未知時（例如等待對方接收）用來回移動的動畫表示還在運作 */
.pb-fill.indeterminate {
  width: 35%; animation: slide 1.4s ease-in-out infinite;
}

/* ---------- 範例檔下載 ---------- */

.demo-links a:hover { border-color: var(--green); background: #EEF3F8; }

.demo-links a:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

/* 範例入口：放在各自的上傳區底下，點了直接載入該項 */

.demo-link:disabled { opacity: .55; cursor: wait; }

.demo-link:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.demo-dl summary::-webkit-details-marker { display: none; }

.demo-dl summary::before { content: "▸ "; }

.demo-dl[open] summary::before { content: "▾ "; }

@keyframes press {
  0% { transform: scale(1.28); } 60% { transform: scale(.94); } 100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .seal button[aria-pressed="true"] { animation: none; }
}

@media (max-width: 900px) {
  .settings { grid-template-columns: 1fr 1fr; }
  .flow li { padding: 13px 12px; }
  .flow small { display: none; }
}

@media (max-width: 720px) {
  .wrap { padding: 0 14px 72px; }
  header { padding-top: 22px; }
  .brand-row { align-items: flex-start; }
  header h1 { font-size: 27px; }
  .privacy { font-size: 0; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }
  .privacy span { font-size: 9px; margin: 0; }
  .flow { grid-template-columns: repeat(4, 1fr); }
  .flow li { display: flex; justify-content: center; padding: 10px 4px; border-left: 0; }
  .flow li span { width: 25px; height: 25px; }
  .flow b, .flow small { display: none; }
  .step { padding: 22px 18px; border-radius: 8px; }
  .step-head { display: block; }
  .local-note { display: inline-block; margin-top: 10px; }
  .grid2, .settings { grid-template-columns: 1fr; }
  .source-path i { padding: 0 1px; }
  .settings-panel summary small, .optional-panel summary small { display: none; }
  .compact-drop { align-items: flex-start; flex-wrap: wrap; }
  .compact-drop .compact-copy { min-width: calc(100% - 50px); }
  .compact-drop em { margin-left: 46px; }
  .settings .field-label { justify-content: flex-start; }
  .export-title { display: block; }
  .export-title .summary { display: block; margin-top: 5px; }
  #step4 { position: static; }
  .actions button { flex: 1 1 auto; }
  .row { grid-template-columns: 42px 1fr; }
  .fields { padding-right: 12px; }
  .reason { display: block; }
  .count { display: block; margin-left: auto; padding-top: 2px; }
}

@keyframes slide {
  0% { margin-left: -35%; } 100% { margin-left: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .pb-fill.indeterminate { animation: none; width: 100%; opacity: .4; }
}


/* ---------- 進場動畫 ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 卡片依序浮現。只做一次，不干擾後續操作 */
.step { animation: rise .5s both; }
.step:nth-of-type(2) { animation-delay: .06s; }
.step:nth-of-type(3) { animation-delay: .12s; }

/* 公文解析完逐份出現 */
.doc { animation: rise .38s both; }

@media (prefers-reduced-motion: reduce) {
  .step, .doc, .loaded, .warnbox { animation: none; }
}
