/* ============ document constructor ============ */
body.builder{background:var(--bg-2)}

.builder-top{background:var(--surface);border-bottom:1px solid var(--line)}
.builder-top .wrap{display:flex;align-items:center;gap:16px;padding-top:16px;padding-bottom:16px}
.builder-top .doc-name{font-size:17px;font-weight:800;display:flex;align-items:center;gap:10px}
.builder-top .doc-name .di{width:34px;height:34px;border-radius:9px;background:var(--accent-soft);color:var(--accent-600);display:grid;place-items:center}
.builder-top .doc-name .di svg{width:19px;height:19px}
.builder-top .save{margin-left:auto;display:flex;align-items:center;gap:8px;font-size:13.5px;color:var(--muted);font-weight:600}
.builder-top .save i{width:16px;height:16px;color:var(--emerald)}.builder-top .save i svg{width:16px;height:16px}

.builder-wrap{display:grid;grid-template-columns:236px 1fr 440px;gap:0;min-height:calc(100vh - var(--header-h))}
.builder-steps{padding:28px 20px;border-right:1px solid var(--line);background:var(--surface)}
.builder-steps .sh{font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);font-weight:800;margin-bottom:18px}
.bstep{display:flex;gap:13px;align-items:flex-start;padding:11px 12px;border-radius:12px;cursor:pointer;margin-bottom:3px;transition:background .15s}
.bstep:hover{background:var(--bg-2)}
.bstep.active{background:var(--accent-soft)}
.bstep .bnum{width:26px;height:26px;border-radius:50%;flex:none;display:grid;place-items:center;font-size:12.5px;font-weight:800;background:var(--bg-2);color:var(--muted);border:1.5px solid var(--line-strong);transition:all .15s}
.bstep.active .bnum{background:var(--accent);color:#fff;border-color:var(--accent)}
.bstep.done .bnum{background:var(--emerald);color:#fff;border-color:var(--emerald)}
.bstep .bnum svg{width:14px;height:14px}
.bstep .bl b{font-size:14px;font-weight:700;display:block;color:var(--ink);line-height:1.3}
.bstep .bl span{font-size:12px;color:var(--muted)}
.bstep.active .bl b{color:var(--accent-700)}

.builder-form{padding:40px 48px;overflow:auto}
.builder-form .fprogress{margin-bottom:30px}
.fprogress .pt{display:flex;justify-content:space-between;font-size:13px;font-weight:700;color:var(--muted);margin-bottom:8px}
.fprogress .pt b{color:var(--accent-700)}
.fprogress .bar{height:7px;border-radius:7px;background:var(--line);overflow:hidden}
.fprogress .bar b{display:block;height:100%;background:linear-gradient(90deg,var(--accent),#46a0ff);border-radius:7px;transition:width .4s cubic-bezier(.3,.7,.2,1)}
.builder-form h2{font-size:26px;margin-bottom:6px}
.builder-form .step-desc{color:var(--muted);font-size:16px;margin-bottom:28px;max-width:520px}
.form-max{max-width:560px}

.bfield{margin-bottom:22px}
.bfield > label{display:flex;align-items:center;gap:8px;font-size:14.5px;font-weight:700;color:var(--ink-700);margin-bottom:8px}
.bfield .opt-tag{font-size:11px;font-weight:700;color:var(--muted-2);background:var(--bg-2);padding:2px 8px;border-radius:99px}
.bfield .qhint{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:50%;background:var(--bg-2);color:var(--muted);font-size:11px;font-weight:800;cursor:help;position:relative}
.bfield .qhint svg{width:12px;height:12px}
.tip-box{display:flex;gap:9px;background:var(--accent-softer);border:1px solid var(--accent-soft);border-radius:10px;padding:10px 12px;margin-top:8px;font-size:13px;color:var(--accent-700);line-height:1.45}
.tip-box i{width:16px;height:16px;flex:none;margin-top:1px}.tip-box i svg{width:16px;height:16px}

.two{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.switch{width:48px;height:28px;border-radius:99px;background:var(--line-strong);position:relative;cursor:pointer;transition:background .2s;flex:none;border:none}
.switch::after{content:"";position:absolute;top:3px;left:3px;width:22px;height:22px;border-radius:50%;background:#fff;transition:transform .2s;box-shadow:0 1px 3px rgba(0,0,0,.2)}
.switch.on{background:var(--accent)}
.switch.on::after{transform:translateX(20px)}
.switch-row{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:16px;border:1.5px solid var(--line);border-radius:12px;background:var(--surface);margin-bottom:12px}
.switch-row .sl b{font-size:14.5px;display:block;margin-bottom:3px}
.switch-row .sl span{font-size:13px;color:var(--muted)}
.seg-full{display:flex;background:var(--bg-2);border-radius:12px;padding:4px;gap:3px}
.seg-full button{flex:1;border:none;background:none;padding:11px;border-radius:9px;font-family:inherit;font-size:14px;font-weight:700;color:var(--muted);cursor:pointer;transition:all .15s}
.seg-full button.on{background:var(--surface);color:var(--accent-700);box-shadow:var(--shadow-xs)}

.bnav{display:flex;justify-content:space-between;gap:14px;margin-top:36px;padding-top:24px;border-top:1px solid var(--line)}

/* AI helper inline */
.ai-inline{display:flex;gap:13px;background:linear-gradient(160deg,#0a1a35,#16294a);border-radius:var(--r-md);padding:18px;margin-top:8px;color:#fff}
.ai-inline .av{width:40px;height:40px;border-radius:11px;background:rgba(15,121,240,.25);display:grid;place-items:center;flex:none}
.ai-inline .av img{width:26px;height:26px}
.ai-inline b{font-size:14.5px}
.ai-inline p{font-size:13.5px;color:#aebfd8;margin-top:3px;line-height:1.5}

/* preview pane */
.builder-preview{background:var(--bg-2);border-left:1px solid var(--line);padding:28px 24px;overflow:auto}
.bp-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:16px}
.bp-head b{font-size:12.5px;text-transform:uppercase;letter-spacing:.04em;color:var(--muted)}
.bp-paper{background:#fff;border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow-md);padding:32px 34px;font-size:13px;line-height:1.7;color:var(--ink-800);min-height:560px}
.bp-paper .pt-title{text-align:center;font-weight:800;font-size:14px;margin-bottom:3px}
.bp-paper .pt-meta{text-align:center;font-size:11px;color:var(--muted);font-family:var(--mono);margin-bottom:20px}
.bp-paper h5{font-size:12.5px;font-weight:800;margin:16px 0 7px}
.bp-paper p{margin-bottom:8px}
.bp-paper .v{background:var(--accent-soft);color:var(--accent-700);border-radius:4px;padding:1px 5px;font-weight:600;transition:background .3s}
.bp-paper .v.blank{background:var(--bg-2);color:var(--muted-2);font-style:normal}
.bp-paper .v.flash{background:#cfe4fe}
.bp-paper .muted-clause{color:var(--muted-2)}

/* completion screen */
.complete{max-width:600px;margin:0 auto;text-align:center;padding:30px 0}
.complete .seal{width:88px;height:88px;border-radius:50%;background:var(--emerald-soft);color:var(--emerald);display:grid;place-items:center;margin:0 auto 24px}
.complete .seal svg{width:46px;height:46px}
.complete h2{font-size:30px;margin-bottom:12px}
.complete p.sub{font-size:17px;color:var(--muted);margin-bottom:30px}
.dl-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-lg);box-shadow:var(--shadow-sm);padding:24px;text-align:left;margin-bottom:18px;display:flex;align-items:center;gap:16px}
.dl-card .di{width:50px;height:50px;border-radius:12px;background:var(--accent-soft);color:var(--accent-600);display:grid;place-items:center;flex:none}.dl-card .di svg{width:26px;height:26px}
.dl-card .info{flex:1;text-align:left}
.dl-card .info b{font-size:16px;display:block}.dl-card .info span{font-size:13px;color:var(--muted)}
.dl-formats{display:flex;gap:10px}
.pay-row{display:flex;align-items:center;justify-content:space-between;background:var(--surface);border:1px solid var(--line);border-radius:var(--r-md);padding:18px 22px;margin-bottom:20px}
.pay-row .amt{font-size:24px;font-weight:800}
.pay-row .amt span{font-size:14px;color:var(--muted);font-weight:600}

@media (max-width:1100px){
  .builder-wrap{grid-template-columns:200px 1fr}
  .builder-preview{display:none}
}
@media (max-width:760px){
  .builder-wrap{grid-template-columns:1fr}
  .builder-steps{display:none}
  .builder-form{padding:28px 20px}
  .two{grid-template-columns:1fr}
}
