:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --border: #e5e5ec;
  --text: #1b1b1f;
  --muted: #8a8a99;
  --accent: #d94b64;
  --accent-soft: #fdeef1;
  --danger: #d9484b;
  --ok: #2f9e6a;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 20, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 520px; margin: 0 auto; padding: 26px 20px 0; min-height: 70vh; }

/* 全站页脚：一行小字，不抢视线；完整声明在 #/about */
.site-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin: 22px 0 0;
  padding: 12px 2px 30px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: #a3a3b0;
}
.site-foot a { color: #a3a3b0; text-decoration: none; border-bottom: 1px solid #dcdce4; }
.site-foot a:active { color: var(--accent); }

a.btn { text-align: center; text-decoration: none; padding: 12px 18px; }

.about-sec h3 { margin-bottom: 6px; }
.about-sec p { margin: 0 0 6px; font-size: 13px; color: #4a4a55; line-height: 1.85; }

h1 { font-size: 25px; margin: 14px 0 6px; letter-spacing: -.3px; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 14px;
}

.muted { color: var(--muted); font-size: 13px; }
.tiny { font-size: 11px; }
.center { text-align: center; }

label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }

input, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: none; }

.btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 14px 18px;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn--danger { background: var(--danger); }
.btn--sm { width: auto; display: inline-block; padding: 6px 16px; font-size: 12px; margin: 0 0 0 8px; }

.row { display: flex; gap: 10px; align-items: center; }

.check { display: flex; gap: 9px; align-items: flex-start; margin: 16px 0 4px; font-size: 13px; }
.check input { width: auto; margin-top: 3px; flex: none; }

.pad { border: 1px dashed var(--border); border-radius: 12px; padding: 6px; background: #fff; }
.pad canvas { display: block; width: 100%; height: 130px; touch-action: none; }
.pad-foot { display: flex; justify-content: space-between; align-items: center; padding: 0 8px 4px; }

/* ============================ 正式文书 ============================
 * 目标：像一份真实的纸质协议 —— 米白纸面、宋体正文、双线标题、编号、
 * 当事人栏、条款款号、签字栏、红色专用章、页脚页码与校验码。
 * 免责声明以「第二条 文书性质」正文条款 + 斜向平铺水印 + 页脚三处同时呈现，
 * 因此它既是版式的一部分，又不可被误读为真实法律文件。
 * ================================================================= */

.doc {
  position: relative;
  overflow: hidden;
  margin: 0 0 14px;
  padding: 24px 20px 14px;
  background: #fffdf7;
  background-image:
    repeating-linear-gradient(0deg, rgba(120, 100, 60, .022) 0 1px, transparent 1px 22px),
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, .9), transparent 70%);
  border: 1px solid #e4dcc9;
  border-radius: 3px;
  box-shadow: 0 12px 32px rgba(70, 58, 32, .12), inset 0 0 0 1px rgba(255, 255, 255, .7);
  color: #2a2622;
  font-family: "Songti SC", "SimSun", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  font-size: 12.8px;
  line-height: 1.98;
}

/* 斜向平铺水印：整份文书都带着它 */
.doc-wm {
  position: absolute;
  inset: -22%;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 30px 22px;
  transform: rotate(-26deg);
  pointer-events: none;
  z-index: 0;
}
.doc-wm span {
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 2px;
  color: rgba(158, 140, 106, .17);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
/* 水印之上再压正文：排除两个绝对定位的印章/戳记，否则会被拉回文档流 */
.doc > *:not(.doc-wm):not(.doc-seal):not(.doc-void-mark) {
  position: relative;
  z-index: 1;
}

/* 编号 / 页眉 */
.doc-no {
  margin: 0;
  text-align: right;
  font-size: 10.5px;
  letter-spacing: .6px;
  color: #948a76;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.doc-title {
  margin: 8px 0 4px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 9px;
  text-indent: 9px;
  color: #211d18;
}
.doc-sub {
  margin: 0 0 12px;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 1.5px;
  color: #8f8571;
}
.doc-rule { height: 3px; border-top: 2px solid #2a2622; border-bottom: 1px solid #2a2622; }

/* 当事人栏 */
.doc-parties { width: 100%; border-collapse: collapse; margin: 14px 0 14px; font-size: 12.3px; }
.doc-parties th, .doc-parties td { border: 1px solid #ded4bd; padding: 6px 9px; text-align: left; font-weight: 400; }
/* nowrap + width:1% = 收缩到内容宽度，避免「甲方（男方）」被挤成两行 */
.doc-parties th { white-space: nowrap; width: 1%; background: #faf6ea; color: #6d6350; letter-spacing: .5px; }
.doc-party-name { font-weight: 700; color: #211d18; }
.doc-party-state { white-space: nowrap; width: 1%; text-align: right; color: #948a76; }

.doc-preamble { margin: 0 0 6px; text-indent: 2em; text-align: justify; }

/* 条款 */
.doc-articles h3 {
  margin: 15px 0 5px;
  font-size: 13px;
  letter-spacing: 1.5px;
  color: #211d18;
}
.doc-articles p {
  margin: 0 0 4px;
  padding-left: 2.9em;
  text-indent: -2.9em;
  text-align: justify;
}
.doc-articles p i {
  display: inline-block;
  width: 2.9em;
  text-indent: 0;
  font-style: normal;
  font-size: 11px;
  color: #a99e88;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* 签字栏 */
.doc-sign { display: flex; gap: 12px; margin: 26px 0 8px; }
.doc-sign-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 92px;
  padding: 8px 9px;
  border: 1px solid #ded4bd;
  border-radius: 2px;
  background: rgba(255, 255, 255, .5);
}
.doc-sign-label { font-size: 11.5px; color: #6d6350; letter-spacing: .5px; }
.doc-sign-img {
  width: 100%;
  height: 62px;
  margin: 5px 0;
  object-fit: contain;
  object-position: left center;
}
.doc-sign-blank {
  display: grid;
  place-items: center;
  height: 62px;
  margin: 5px 0;
  border-bottom: 1px dashed #ddd3bb;
  color: #c3b9a3;
  font-size: 12px;
  letter-spacing: 3px;
}
.doc-sign-date { margin-top: auto; font-size: 10px; color: #8f8571; white-space: nowrap; }

/* 专用章：压在乙方签字栏上（真实合同就是这样骑缝盖的），
   位置略微上移，避免挡住下方的签署日期 */
.doc-seal {
  position: absolute;
  right: 12px;
  /* 印章直径 102px、旋转 9° 后视觉包围盒约 117px。
     底边必须落在「签署日期」行之上（该行贴单元格底部），
     76px 时正好压住日期，96px 可避开且不越出签字栏上边框。 */
  bottom: 96px;
  width: 102px;
  height: 102px;
  transform: rotate(-9deg);
  pointer-events: none;
  z-index: 2;
}
.doc-seal svg { display: block; width: 100%; height: 100%; }
.doc-seal .seal-ring { fill: none; stroke: #c0392b; stroke-width: 2.6; }
.doc-seal .seal-ring--in { stroke-width: 1.1; }
.doc-seal .seal-arc { fill: #c0392b; font-size: 9.2px; letter-spacing: .5px; }
.doc-seal .seal-core { fill: #c0392b; font-size: 19px; font-weight: 700; text-anchor: middle; letter-spacing: 2px; }
.doc-seal .seal-sub { fill: #c0392b; font-size: 7.4px; text-anchor: middle; letter-spacing: 1.8px; }
.doc-seal--ok { opacity: .82; }
.doc-seal--pending { opacity: .30; filter: grayscale(1); }
.doc-seal--void { opacity: .5; }
.doc-seal--void .seal-ring { stroke: #8c8375; }
.doc-seal--void .seal-arc,
.doc-seal--void .seal-core,
.doc-seal--void .seal-sub { fill: #8c8375; }

/* 作废 / 失效戳 */
.doc-void-mark {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) rotate(-15deg);
  padding: 4px 22px 6px 34px;
  border: 5px double rgba(192, 57, 43, .34);
  border-radius: 5px;
  color: rgba(192, 57, 43, .34);
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 10px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}
.doc--void .doc-title, .doc--void .doc-party-name { color: #6d6350; }

/* 页脚 */
.doc-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 7px;
  border-top: 1px solid #e4dcc9;
  font-size: 10px;
  letter-spacing: .5px;
  color: #a1967f;
}

/* 打印：只留文书本体，A4 友好 */
@media print {
  body { background: #fff; }
  #app { max-width: none; padding: 0; margin: 0; }
  .no-print { display: none !important; }
  .doc {
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    font-size: 12pt;
  }
  .doc-seal--ok { opacity: .85; }
  /* 页脚小字不隐藏：导出成 PDF 后文书会离开应用，这一行是它自己的说明 */
  .site-foot { border-top: none; padding-bottom: 0; }
}

.spinner {
  width: 32px; height: 32px; margin: 6px auto 14px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.share-link {
  word-break: break-all;
  font-size: 12px;
  background: var(--accent-soft);
  color: #8a2740;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
}

.divider { border-top: 1px dashed var(--border); margin: 22px 0 0; padding-top: 18px; }

.mask {
  position: fixed; inset: 0; background: rgba(20, 20, 30, .45);
  display: grid; place-items: center; padding: 24px; z-index: 9;
}
.dialog { background: #fff; border-radius: 16px; padding: 22px; max-width: 340px; width: 100%; }
.dialog .row { margin-top: 16px; }
.dialog .row .btn { margin-top: 0; }
.dialog a { color: var(--accent); text-decoration: none; border-bottom: 1px solid currentColor; }
