:root{
  --ink:#111827;--muted:#64748b;--line:#dbe3ee;--panel:#fff;
  --brand:#082651;--brand2:#123d73;--gold:#b8892f;--gold2:#d4aa55;
  --soft:#eef4fa;--danger:#b42318;--warning:#9a6700;--success:#147a45;
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
html,body{margin:0;background:#f4f7fb;color:var(--ink);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans TC","PingFang TC","Microsoft JhengHei",sans-serif;font-size:17px;line-height:1.65}
body{min-width:320px}
button,input,textarea,select{font:inherit}
button{cursor:pointer}
img{max-width:100%}
:focus-visible{outline:3px solid #2563eb;outline-offset:2px}
.skip-link{position:fixed;left:12px;top:-60px;z-index:100;background:#fff;color:var(--brand);padding:10px 14px;border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.2)}
.skip-link:focus{top:12px}
.visually-hidden{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
.topbar{position:sticky;top:0;z-index:20;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:12px 24px;gap:18px}
.brand-lockup{display:flex;align-items:center;gap:12px;min-width:0;flex-wrap:wrap}
.brand-mark{width:54px;height:48px;object-fit:contain;flex:0 0 auto}
.brand-copy{display:flex;flex-direction:column;line-height:1.15;min-width:0}
.brand-copy strong{font-size:24px;letter-spacing:.02em}
.brand-copy small{font-size:14px;color:#53657a;margin-top:4px;font-weight:750}
.version-badge{font-size:13px;font-weight:800;color:#6b4b00;background:#fff7db;border:1px solid #e9d08c;border-radius:999px;padding:6px 10px}
.security-summary{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.security-pill{display:inline-flex;align-items:center;gap:6px;padding:7px 11px;border:1px solid #c8d7e7;border-radius:999px;background:#f7fbff;color:#244866;font-size:14px;font-weight:750}
.security-pill::before{content:"✓";display:inline-grid;place-items:center;width:17px;height:17px;border-radius:50%;background:#16834a;color:#fff;font-size:11px}
.wrap{max-width:1600px;margin:auto;padding:22px}
.brand-banner{margin:0 0 18px;border:1px solid #d6e2ee;border-radius:16px;background:linear-gradient(135deg,#fff 0%,#f5faff 100%);padding:14px 18px;display:flex;align-items:center;justify-content:space-between;gap:16px}
.brand-banner-text strong{display:block;font-size:20px;margin-bottom:6px}
.brand-banner-text span{font-size:16px;color:var(--muted);line-height:1.7}
.grid{display:grid;grid-template-columns:minmax(400px,520px) minmax(560px,1fr);gap:22px;align-items:start}
.panel{background:#fff;border:1px solid var(--line);border-radius:18px;box-shadow:0 8px 30px rgba(15,39,71,.06)}
.panel-head{padding:18px 20px;border-bottom:1px solid var(--line)}
.panel-head h1,.panel-head h2{margin:0 0 6px;font-size:28px}
.panel-head p{margin:0;color:var(--muted);font-size:17px;line-height:1.7}
.form-body{padding:18px 20px}
.section{border:1px solid var(--line);border-radius:14px;margin-bottom:14px;overflow:hidden}
.section summary{list-style:none;font-weight:800;padding:16px 18px;background:#f8fafc;cursor:pointer;font-size:19px}
.section summary::-webkit-details-marker{display:none}
.section summary::after{content:"＋";float:right;color:var(--muted)}
.section[open] summary::after{content:"－"}
.section .inside{padding:15px}
.row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.field{margin-bottom:12px}
label{display:block;font-size:16px;font-weight:700;margin-bottom:7px}
input,textarea,select{width:100%;border:1px solid #cbd5e1;border-radius:10px;padding:12px 14px;background:#fff;color:#111827;font-size:17px;min-height:48px}
input:focus,textarea:focus,select:focus{border-color:#2563eb;box-shadow:0 0 0 3px rgba(37,99,235,.12);outline:0}
textarea{min-height:120px;resize:vertical;line-height:1.8}
.draft-area{min-height:260px}
.hint{font-size:14px;color:var(--muted);line-height:1.7}
.actions{display:flex;gap:9px;flex-wrap:wrap}
.action-gap-top{margin-top:10px}.action-gap-bottom{margin-bottom:10px}
.btn{border:1px solid #b8c5d4;background:#fff;color:var(--ink);padding:12px 16px;border-radius:10px;font-weight:750;min-height:48px;font-size:16px}
.btn:hover:not(:disabled){background:#f8fafc}
.btn:disabled{opacity:.5;cursor:not-allowed}
.btn.primary{background:var(--brand);border-color:var(--brand);color:#fff}
.btn.primary:hover:not(:disabled){background:var(--brand2)}
.btn.soft{background:var(--soft);border-color:#c9d9ea;color:#15385d}
.btn.danger{color:var(--danger);border-color:#efc2bd}
.btn.security{border-color:#94b5d3;color:#173d62;background:#f4f9fd}
.btn.security:hover:not(:disabled){background:#eaf4fb}
.file-button{display:inline-flex;align-items:center}
.text-action{border:0;background:transparent;color:#1d4ed8;padding:8px 0 0;font-weight:750;font-size:15px;text-decoration:underline;text-underline-offset:3px}
.recipient{border:1px solid var(--line);border-radius:12px;padding:12px;margin-bottom:10px;background:#fbfdff}
.recipient-top{display:flex;align-items:center;justify-content:space-between;margin-bottom:9px;gap:10px}
.recipient-title{font-weight:800;font-size:18px}.badge{font-size:14px;background:#e8f0f8;border-radius:999px;padding:5px 9px;color:#20466d}
.notice{border-left:4px solid #2563eb;background:#eff6ff;padding:13px 14px;border-radius:8px;font-size:16px;line-height:1.8}
.legal-notice{margin-top:4px}.reminder-content h2{font-size:21px;margin:0 0 12px}.reminder-content p{font-size:16px;line-height:1.9;margin:9px 0}
.preview-panel{position:sticky;top:86px;max-height:calc(100vh - 102px);overflow:hidden;display:flex;flex-direction:column}
.preflight-card{margin:14px 18px 0;border:1px solid var(--line);border-radius:14px;padding:14px;background:#fbfdff}
.preflight-card.pass{border-color:#99d3b2;background:#f3fbf6}.preflight-card.warn{border-color:#e7ca7f;background:#fffaf0}.preflight-card.error{border-color:#efb4ae;background:#fff6f5}
.preflight-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}.preflight-head h3{margin:0 0 6px;font-size:20px}.preflight-head p{margin:0;color:var(--muted);font-size:15px;line-height:1.7}
.preflight-badge{font-size:14px;font-weight:800;border-radius:999px;padding:6px 10px;background:#e5e7eb;color:#374151;white-space:nowrap}
.pass .preflight-badge{background:#dff4e7;color:#0e6538}.warn .preflight-badge{background:#fff0bd;color:#795300}.error .preflight-badge{background:#ffe0dd;color:#8f1d14}
.preflight-list{margin:10px 0 0;padding-left:22px;font-size:15px;line-height:1.8}.preflight-list:empty{display:none}
.preflight-list .error-item{color:#9f1c14}.preflight-list .warn-item{color:#795300}
.print-metrics{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.metric{font-size:14px;border:1px solid #d6e2ee;background:#fff;border-radius:999px;padding:6px 10px}
.preview-tools{display:flex;gap:10px;flex-wrap:wrap;padding:14px 18px;border-bottom:1px solid var(--line);align-items:end}
.tool-field{min-width:170px;flex:1}.tool-field label{margin-bottom:4px}.preview-tools select{min-width:170px}
.preview-stage{padding:22px;background:#eaf0f7;overflow:auto;flex:1;min-height:350px}
.preview-warning{max-width:760px;margin:0 auto 16px;padding:12px 14px;border:1px solid #e7ca7f;background:#fffaf0;border-radius:10px;font-size:15px;line-height:1.8}
.sheet-wrap{display:flex;flex-direction:column;align-items:center;margin:0 auto 22px;min-width:max-content}
.sheet-caption{width:210mm;max-width:100%;display:flex;justify-content:space-between;gap:12px;background:#082651;color:#fff;padding:8px 12px;border-radius:10px 10px 0 0;font-size:14px;font-weight:750}
.sheet{position:relative;width:210mm;height:297mm;background:#fff;box-shadow:0 12px 35px rgba(15,23,42,.18);overflow:hidden;flex:0 0 auto}
.sheet-bg{position:absolute;inset:0;width:100%;height:100%;object-fit:fill;z-index:0}
.overlay{position:absolute;z-index:2;color:#000}
.header-value{font-family:"Noto Serif TC","PMingLiU","Songti TC",serif;font-size:11.5pt;line-height:1.2;white-space:nowrap;overflow:hidden;text-overflow:clip}
.sender-name{left:56.7%;top:10.4%;width:30%}.sender-address{left:56.7%;top:13.2%;width:30%}.recipient-name{left:56.7%;top:15.9%;width:30%}.recipient-address{left:56.7%;top:18.7%;width:30%}
.content-grid{position:absolute;left:15%;top:30.3133903%;width:79.6774194%;height:40.3988604%;z-index:3;display:grid;grid-template-columns:50fr 49fr 49fr 50fr 49fr 50fr 49fr 49fr 50fr 49fr 49fr 50fr 49fr 50fr 49fr 49fr 50fr 49fr 50fr 49fr;grid-template-rows:71fr 71fr 71fr 71fr 71fr 70fr 71fr 71fr 71fr 71fr}
.char-cell{display:flex;align-items:center;justify-content:center;font-family:"Noto Serif TC","PMingLiU","Songti TC",serif;font-size:18pt;line-height:1;overflow:hidden}
.empty{padding:50px;text-align:center;color:var(--muted)}
.footer-note{padding:14px 18px;color:var(--muted);font-size:15px;line-height:1.75;border-top:1px solid var(--line)}
.app-status{position:fixed;left:50%;bottom:18px;z-index:60;transform:translateX(-50%);max-width:min(90vw,640px);background:#0f172a;color:#fff;border-radius:999px;padding:10px 16px;font-size:15px;box-shadow:0 8px 30px rgba(0,0,0,.25);opacity:0;pointer-events:none;transition:opacity .2s}
.app-status.show{opacity:1}
.modal{position:fixed;inset:0;background:rgba(15,23,42,.55);display:none;align-items:center;justify-content:center;z-index:50;padding:20px}
.modal.open{display:flex}.modal-card{width:min(680px,100%);max-height:90vh;overflow:auto;background:#fff;border-radius:16px;padding:22px;box-shadow:0 20px 60px rgba(0,0,0,.25)}
.modal-card h3{margin-top:0;font-size:24px}.modal-card ol{line-height:2;font-size:16px}.security-list{padding-left:22px;line-height:2;font-size:16px}
.privacy-warning{border:1px solid #f0d38b;background:#fff9e8;border-radius:10px;padding:12px 14px;font-size:15px;line-height:1.8;margin-top:12px}
.site-footer{max-width:1600px;margin:0 auto 30px;padding:18px 22px}.footer-card{border:1px solid var(--line);border-radius:16px;background:#fff;padding:18px;display:grid;grid-template-columns:auto 1fr auto;align-items:center;gap:18px;box-shadow:0 8px 30px rgba(15,39,71,.05)}
.footer-logo{width:112px;height:auto}.footer-copy strong{display:block;font-size:20px;margin-bottom:8px}.footer-copy p{margin:0;color:var(--muted);font-size:15px;line-height:1.8}.footer-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.mobile-tabs{display:none}
@media (max-width:1080px){
  .grid{grid-template-columns:1fr}.preview-panel{position:static;max-height:none}.preview-stage{max-height:none}.security-summary{justify-content:flex-start}
}
@media(max-width:760px){
  .topbar{position:static;align-items:flex-start;gap:12px;flex-direction:column;padding:12px 16px}.brand-mark{width:46px;height:42px}.brand-copy strong{font-size:20px}.security-summary{display:none}
  .wrap{padding:12px}.brand-banner{align-items:flex-start;flex-direction:column;margin-bottom:12px}.row{grid-template-columns:1fr}.panel{border-radius:14px}.form-body{padding:14px}.panel-head{padding:15px}
  .mobile-tabs{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:12px;position:sticky;top:8px;z-index:15;background:#f4f7fb;padding:6px 0}
  .mobile-tab{border:1px solid #b8c5d4;background:#fff;border-radius:10px;padding:12px;font-weight:800;color:#334155;font-size:18px}.mobile-tab.active{background:var(--brand);color:#fff;border-color:var(--brand)}
  body[data-mobile-view="form"] .preview-panel{display:none}body[data-mobile-view="preview"] .form-panel{display:none}
  .preview-tools{align-items:stretch}.tool-field{min-width:100%}.preview-tools .btn{width:100%}.preflight-card{margin:12px}
  .preview-stage{padding:12px}.sheet-caption{justify-content:flex-start;flex-direction:column;width:210mm}.footer-card{grid-template-columns:1fr;text-align:center}.footer-logo{margin:auto}.footer-actions{justify-content:center}.site-footer{padding:12px}
}
@media print{
  @page{size:A4 portrait;margin:0}
  html,body{background:#fff!important}
  .topbar,.form-panel,.preview-panel>.panel-head,.preflight-card,.preview-tools,.footer-note,.sheet-caption,.modal,.site-footer,.brand-banner,.mobile-tabs,.app-status,.screen-only,.skip-link{display:none!important}
  .wrap,.grid,.preview-panel,.preview-stage{display:block!important;margin:0!important;padding:0!important;border:0!important;box-shadow:none!important;background:#fff!important;max-width:none!important;overflow:visible!important}
  .preview-panel{border:0!important;max-height:none!important;position:static!important}.sheet-wrap{display:block!important;width:210mm!important;height:297mm!important;margin:0!important;padding:0!important;overflow:hidden!important;line-height:0!important;page-break-inside:avoid!important;break-inside:avoid-page!important;page-break-after:always;break-after:page}.sheet-wrap:last-child{page-break-after:auto;break-after:auto}
  .sheet{display:block!important;width:210mm!important;height:297mm!important;box-shadow:none!important;margin:0!important}.sheet-bg{print-color-adjust:exact;-webkit-print-color-adjust:exact}
}


/* v1.2.4 field validation, fast navigation, and clear confirmation states */
.field.validation-error{border:2px solid #dc2626;background:#fff1f2;border-radius:12px;padding:10px;box-shadow:0 0 0 4px rgba(220,38,38,.08)}
.field.validation-warning{border:2px solid #d97706;background:#fffbeb;border-radius:12px;padding:10px;box-shadow:0 0 0 4px rgba(217,119,6,.07)}
.field.validation-error>label,.field.validation-error .recipient-title{color:#b91c1c}
.field.validation-warning>label,.field.validation-warning .recipient-title{color:#92400e}
input.validation-error,textarea.validation-error,select.validation-error{border-color:#dc2626!important;background:#fff7f7!important;box-shadow:0 0 0 3px rgba(220,38,38,.14)!important}
input.validation-warning,textarea.validation-warning,select.validation-warning{border-color:#d97706!important;background:#fffdf5!important;box-shadow:0 0 0 3px rgba(217,119,6,.12)!important}
.field-validation{display:flex;align-items:flex-start;gap:7px;margin-top:7px;font-size:14px;font-weight:750;line-height:1.55}
.field-validation.error{color:#b91c1c}.field-validation.warning{color:#92400e}
.field-validation::before{content:"!";display:inline-flex;align-items:center;justify-content:center;flex:0 0 20px;height:20px;border-radius:999px;color:#fff;background:currentColor;font-size:12px;line-height:1}
.field-validation span{color:inherit}
.preflight-guide{margin:10px 0 4px;color:#475569;font-size:14px;line-height:1.65}
.preflight-list{list-style:none;padding-left:0}
.preflight-list li{margin:7px 0}
.issue-link{width:100%;display:flex;justify-content:space-between;align-items:flex-start;gap:12px;text-align:left;border:1px solid currentColor;border-radius:10px;padding:9px 11px;background:#fff;font:inherit;font-weight:700;line-height:1.55}
.issue-link:hover{filter:brightness(.98)}
.issue-link .issue-action{white-space:nowrap;text-decoration:underline;font-size:13px;font-weight:800}
.error-item .issue-link{color:#9f1c14;background:#fff8f7}.warn-item .issue-link{color:#795300;background:#fffdf6}
.review-confirm{display:flex;align-items:flex-start;gap:10px;margin-top:12px;padding:11px 12px;border:1px solid #cbd5e1;border-radius:10px;background:#fff;font-size:14px;line-height:1.6}
.review-confirm input{width:22px;min-width:22px;height:22px;min-height:22px;margin:1px 0 0;padding:0}
.review-confirm.required{border-color:#d97706;background:#fffbeb;color:#78350f}
.review-confirm.disabled{opacity:.62}

.review-confirm.status-only{cursor:default;font-weight:700}
.review-confirm.status-only input{display:none}
.review-confirm.pass-state{border-color:#86d2a5;background:#f0fdf4;color:#166534}
.review-confirm.error-state{border-color:#f2aaa5;background:#fff5f4;color:#9f1c14}
.validation-flash{animation:validationFlash 1.2s ease-out}
@keyframes validationFlash{0%{box-shadow:0 0 0 8px rgba(220,38,38,.28)}100%{box-shadow:0 0 0 0 rgba(220,38,38,0)}}
@media(max-width:760px){.issue-link{flex-direction:column;gap:3px}.issue-link .issue-action{align-self:flex-end}.field.validation-error,.field.validation-warning{padding:9px}}
@media print{.field-validation,.preflight-guide,.review-confirm{display:none!important}}
