:root {
  --paper: #f3ead7;
  --paper-deep: #e9dcc0;
  --ink: #3a2f23;
  --ink-soft: #6b5a44;
  --seal-red: #b3341f;
  --line: #c9b58d;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 50% -10%, #4a3b2a 0%, transparent 60%),
    #2b241c;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 12px 40px;
}

.page-head {
  width: 100%;
  max-width: 620px;
  text-align: center;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: .4em;
  text-indent: .4em;
  color: #e8dcc3;
}

.page-head .sub {
  margin: 8px 0 0;
  font-size: .8rem;
  color: #a89a82;
}

main {
  width: 100%;
  max-width: 620px;
}

.contract {
  position: relative;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,.5), transparent 55%),
    radial-gradient(ellipse at 85% 90%, rgba(140,110,60,.25), transparent 55%),
    var(--paper);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 0 40px rgba(120,90,40,.18),
    0 12px 40px rgba(0,0,0,.45);
  padding: 34px 26px 30px;
}

.contract::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid var(--line);
  pointer-events: none;
}

.title {
  text-align: center;
  font-size: 2.3rem;
  font-weight: 700;
  letter-spacing: .5em;
  text-indent: .5em;
  margin-bottom: 22px;
  color: var(--ink);
}

.party {
  margin: 0 0 18px;
  line-height: 2;
  font-size: 1.02rem;
}

.clause {
  margin: 0 0 12px;
  line-height: 1.95;
  font-size: .95rem;
  color: var(--ink);
  text-align: justify;
}

.pledge {
  font-size: 1.02rem;
  color: var(--ink);
}

.edit {
  cursor: text;
  border-bottom: 1px dashed transparent;
  transition: border-color .15s, background .15s;
  outline: none;
  white-space: pre-wrap;
}

.edit:hover, .edit:focus {
  border-bottom-color: var(--seal-red);
  background: rgba(179,52,31,.06);
}

.sign-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  position: relative;
  min-height: 56px;
}

.sign {
  font-size: .9rem;
  color: var(--ink-soft);
}

.seal {
  position: absolute;
  right: 8%;
  top: 22px;
  width: 74px;
  height: 74px;
  border: 3px solid var(--seal-red);
  color: var(--seal-red);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: .1em;
  transform: rotate(8deg);
  opacity: .85;
  mix-blend-mode: multiply;
  text-align: center;
  padding: 4px;
}

.date {
  margin-top: 20px;
  text-align: right;
  font-size: .9rem;
  color: var(--ink-soft);
}

.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 22px 0 0;
  flex-wrap: wrap;
}

.actions button {
  font-family: inherit;
  font-size: .9rem;
  padding: 10px 22px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid #7d6b4f;
  background: #4a3f30;
  color: #eadfc8;
  transition: transform .1s, background .15s;
}

.actions button:hover { background: #5a4d3b; }
.actions button:active { transform: scale(.97); }

#btn-img {
  background: var(--seal-red);
  border-color: var(--seal-red);
  color: #fff5ec;
  font-weight: 600;
}
#btn-img:hover { background: #9c2c19; }

.hint {
  margin: 18px auto 0;
  max-width: 560px;
  text-align: center;
  font-size: .78rem;
  color: #a89a82;
  line-height: 1.8;
}

.page-foot {
  margin-top: 28px;
  font-size: .72rem;
  color: #6e6353;
  letter-spacing: .2em;
}

@media (max-width: 480px) {
  .contract { padding: 26px 16px 22px; }
  .title { font-size: 1.8rem; }
  .seal { width: 60px; height: 60px; font-size: .85rem; }
  .sign-row { flex-direction: column; align-items: flex-start; }
}
