/* Signing experience */
html, body { height: 100%; }
body.sign { display: flex; flex-direction: column; background: var(--bg-soft); overflow: hidden; }

.sg-top {
  height: 52px; flex: none; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 16px; gap: 12px;
}
.sg-top h1 { margin: 0; font-size: 19px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-actions { display: flex; align-items: center; gap: 10px; }
.split { display: inline-flex; border: 1px solid rgba(255,255,255,.55); border-radius: 4px; overflow: hidden; }
.split button { height: 36px; border: 0; background: transparent; color: #fff; cursor: pointer; font-size: 16px; }
.split .main { padding: 0 20px; }
.split .caret { width: 36px; border-left: 1px solid rgba(255,255,255,.55); display: grid; place-items: center; }
.split button:hover { background: rgba(255,255,255,.1); }
.split.ready { border-color: var(--amber); }
.split.ready button { background: var(--amber); color: var(--amber-ink); }
.split.ready .caret { border-left-color: rgba(0,0,0,.15); }
.split.ready button:hover { background: var(--amber-hover); }
.kebab { width: 38px; height: 38px; border-radius: 4px; border: 0; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; cursor: pointer; }
.kebab:hover { background: rgba(255,255,255,.2); }

.sg-banner { flex: none; background: var(--pink-soft); color: var(--ink); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px 10px 20px; font-size: 14.5px; border-bottom: 1px solid #f1cfd6; }
.sg-banner b { font-weight: 600; }

.sg-body { flex: 1; min-height: 0; display: flex; position: relative; }
.sg-scroll { flex: 1; overflow: auto; position: relative; }
.sg-scroll .doc-stack { position: relative; min-width: max-content; padding-left: 150px; padding-right: 150px; }
.sg-finish-bottom { margin: 6px 0 30px; }

/* guide tag ("Start" / "Next" / "Sign") */
.guide {
  position: absolute; z-index: var(--z-raised); height: 40px; padding: 0 22px 0 18px; display: flex; align-items: center;
  background: var(--amber); color: var(--amber-ink); font-weight: 500; font-size: 16px; border: 0; cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 0 100%);
  transition: top .35s ease, left .35s ease; box-shadow: none;
}
.guide:hover { background: var(--amber-hover); }

/* right tool rail */
.rail { width: 76px; flex: none; background: #fff; border-left: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 12px 0; gap: 6px; }
.rail-btn { width: 70px; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--ink); padding: 0 0 6px; }
.rail-btn .rb-ico { width: 44px; height: 44px; border-radius: 6px; display: grid; place-items: center; }
.rail-btn .rb-ico .ico, .rail-btn .rb-ico .sparkle { width: 24px; height: 24px; }
.rail-btn:hover .rb-ico { background: var(--bg-soft); }
.rail-btn.on .rb-ico { background: var(--violet-900); color: #fff; }
.rail-spacer { flex: 1; }
.zoom-label { font-size: 13px; font-weight: 500; margin: 2px 0; }
.rail .icon-btn[disabled] { opacity: .35; cursor: default; }

/* floating panels */
.panel {
  position: absolute; top: 12px; right: 86px; z-index: var(--z-panel); width: 360px; max-height: calc(100% - 24px);
  background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
  animation: rise .15s ease-out;
}
.panel-hd { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 14px 24px; }
.panel-hd h2 { margin: 0; font-size: 23px; font-weight: 500; }
.panel-bd { background: var(--bg-soft); padding: 16px 20px 20px; overflow: auto; }
.panel.drawer { top: 0; right: 76px; bottom: 0; max-height: none; border-radius: 0; width: 420px; box-shadow: -6px 0 22px rgba(0,0,0,.08); }
.panel.drawer .panel-bd { background: #fff; padding: 0 28px 24px; flex: 1; }
.panel.tip { width: 300px; padding: 18px 18px 18px 22px; }
.panel.tip h3 { margin: 10px 0 8px; font-size: 19px; font-weight: 500; }
.panel.tip p { margin: 0 0 16px; color: var(--ink-2); font-size: 14.5px; }
.panel.tip .modal-close { top: 10px; right: 10px; }

.find-box { display: flex; align-items: center; gap: 8px; height: 44px; border: 2px solid var(--violet-800); border-radius: 4px; padding: 0 10px; background: #fff; }
.find-box input { border: 0; outline: none; flex: 1; font-size: 16px; min-width: 0; }
.find-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 14px; color: var(--ink-2); }
.find-results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.find-results button { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 8px 10px; cursor: pointer; font-size: 13.5px; }
.find-results button:hover { border-color: var(--violet-500); }
.find-results small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 2px; }

.thumbs-doc { font-weight: 700; font-size: 17px; display: flex; gap: 8px; align-items: center; }
.thumbs-doc::before { content: ""; border: 6px solid transparent; border-top: 8px solid var(--ink); border-bottom: 0; }
.thumbs-count { color: var(--muted); margin: 0 0 14px 22px; }
.thumbs { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.thumb { position: relative; border: 1px solid #9c97ad; cursor: pointer; background: #fff; overflow: hidden; flex: none; }
.thumb.on { outline: 3px solid var(--violet-800); outline-offset: 0; }
.thumb .num { position: absolute; left: 0; bottom: 0; width: 44px; height: 44px; background: linear-gradient(45deg, var(--violet-900) 50%, transparent 50%); color: #fff; font-size: 13px; display: flex; align-items: flex-end; padding: 0 0 4px 6px; }

/* AI overview */
.ai-head { padding: 22px 0 6px; }
.ai-head h2 { margin: 10px 0 6px; font-size: 26px; font-weight: 500; }
.ai-head p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.skel { height: 20px; border-radius: 99px; margin: 22px 0; background: linear-gradient(90deg, #e9ebf4 0%, #d9dcef 30%, #eef0f6 60%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.ai-sum h3 { font-size: 19px; font-weight: 500; margin: 22px 0 8px; }
.ai-sum p { margin: 0; line-height: 1.75; font-size: 16px; color: var(--ink-2); }
.ai-sum ul { padding-left: 20px; margin: 0; }
.ai-sum li { margin: 0 0 12px; line-height: 1.6; font-size: 15.5px; }
.cite { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; margin-left: 6px; border-radius: 4px; background: var(--bg-soft); border: 0; cursor: pointer; font-size: 14px; vertical-align: middle; }
.cite:hover { background: var(--violet-100); }
.helpful { display: flex; align-items: center; justify-content: space-between; margin: 26px 0 8px; }
.helpful .icon-btn.on { color: var(--violet-500); }
.ai-qa { margin-top: 10px; display: flex; flex-direction: column; gap: 12px; }
.qa-q { align-self: flex-end; background: var(--violet-50); border-radius: 12px 12px 2px 12px; padding: 8px 12px; max-width: 85%; }
.qa-a { background: var(--bg-soft); border-radius: 12px 12px 12px 2px; padding: 10px 12px; font-size: 14.5px; line-height: 1.6; }
.ai-ask { border-top: 1px solid var(--line); padding: 16px 28px 18px; background: #fff; }
.ai-ask .input { height: 48px; font-size: 16px; }
.ai-ask-row { display: flex; align-items: flex-start; gap: 14px; margin-top: 10px; }
.ai-ask-row p { margin: 0; font-size: 12px; color: var(--ink-2); flex: 1; }
.ai-ask-row .btn { width: 52px; height: 48px; padding: 0; }

/* footer */
.sg-foot { flex: none; height: 44px; background: #fff; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; font-size: 12px; color: var(--ink-2); gap: 12px; }
.sg-foot .mid { display: flex; align-items: center; gap: 14px; }
.sg-foot a { color: var(--ink-2); text-decoration: none; }
.sg-foot a:hover { text-decoration: underline; }
.lang-select { border: 0; background: var(--bg-soft); border-radius: 4px; height: 26px; font-size: 12px; padding: 0 6px; }
.powered { display: flex; align-items: center; gap: 4px; }

/* review & continue modal */
.review-modal { width: min(760px, 100%) !important; border-radius: 14px; }
.review-modal .modal-bd { padding: 32px 34px 8px; }
.sender-logo { display: inline-flex; align-items: center; gap: 8px; font-family: Georgia, serif; font-size: 18px; color: #1d4d7a; }
.sender-logo i { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(#f29a3a 0 25%, #1d4d7a 0 50%, #f29a3a 0 75%, #1d4d7a 0); display: inline-block; }
.review-modal h2 { font-size: 22px; font-weight: 500; margin: 26px 0 18px; }
.review-modal .from { font-weight: 600; margin: 0 0 4px; }
.review-modal .msg { white-space: pre-wrap; color: var(--ink-2); line-height: 1.7; margin: 0; }
.review-modal .agree { display: flex; gap: 10px; align-items: flex-start; margin-top: 20px; padding: 12px 14px; background: var(--bg-soft); border-radius: 8px; font-size: 14px; }
.review-modal .agree input { margin-top: 3px; accent-color: var(--violet-600); }
.review-ft { display: flex; align-items: center; gap: 10px; padding: 24px 34px 30px; }
.review-ft .grow { flex: 1; }

/* adopt signature modal */
.adopt { width: min(780px, 100%) !important; border-radius: 4px; }
.adopt .modal-hd { border-bottom: 1px solid var(--line); padding: 18px 26px; }
.adopt .modal-hd h2 { font-size: 20px; font-weight: 600; }
.adopt .modal-bd { padding: 18px 26px 6px; font-size: 14px; }
.adopt .modal-ft { padding: 18px 26px; }
.adopt-names { display: grid; grid-template-columns: 1fr 220px; gap: 16px; margin: 14px 0 6px; }
.adopt-names .input { font-weight: 600; }
.tabs { display: flex; gap: 32px; border-bottom: 1px solid var(--line); margin: 14px -26px 0; padding: 0 26px; }
.tabs button { border: 0; background: none; padding: 14px 0 12px; font-size: 14px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--blue); border-bottom-color: var(--blue); }
.adopt-sec { padding-top: 18px; }
.adopt-sec .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.adopt-sec .cap { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 13px; }
.linkish { border: 0; background: none; color: var(--blue); cursor: pointer; font-size: 14px; padding: 0; }
.sig-preview { border: 1px solid var(--line-2); border-radius: 3px; min-height: 92px; padding: 12px 18px; display: flex; gap: 40px; align-items: center; }
.sig-preview .stamp-box { height: 64px; position: relative; }
.style-list { border: 1px solid var(--line-2); border-radius: 3px; max-height: 270px; overflow: auto; }
.style-opt { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); cursor: pointer; }
.style-opt:last-child { border-bottom: 0; }
.style-opt input { accent-color: var(--blue); }
.style-opt .stamp-box { height: 58px; position: relative; }
.draw-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.draw-pad { position: relative; border: 2px solid var(--line-2); border-radius: 3px; background: #fff; height: 150px; touch-action: none; }
.draw-pad canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.draw-pad .hint { position: absolute; inset: auto 12px 10px; border-top: 1px solid #ddd; padding-top: 4px; font-size: 11px; color: var(--muted); pointer-events: none; }
.upload-preview { border: 1px solid var(--line-2); border-radius: 3px; height: 110px; display: grid; place-items: center; background: #fff; }
.upload-preview img { max-height: 92px; max-width: 90%; }
.legal { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 16px 0 8px; }

/* done / declined / waiting screens */
.done-screen { flex: 1; overflow: auto; background: linear-gradient(180deg, #2c58d6 0, #3a7bd5 180px, var(--bg-soft) 180px); padding: 40px 16px; }
.done-card { max-width: 760px; margin: 0 auto; background: #fff; border-radius: 6px; box-shadow: var(--shadow-lg); padding: 36px 40px 40px; text-align: center; }
.done-card h1 { font-size: 32px; font-weight: 400; line-height: 1.25; margin: 16px auto 30px; max-width: 600px; }
.done-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; text-align: left; }
.done-grid > div + div { border-left: 1px solid var(--line); padding-left: 36px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 34px 34px; color: var(--ink-2); }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: #e5e5e5; }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 22px; bottom: 0; border-left: 2px dashed #e5e5e5; }
.timeline li:last-child::after { display: none; }
.timeline li.on::before { background: var(--green); box-shadow: 0 0 0 5px var(--green-soft); }
.timeline li.on { color: var(--ink); }
.timeline li.on b { font-weight: 600; }
.timeline small { display: block; color: var(--muted); font-size: 13px; }
.timeline a { font-size: 14px; display: inline-block; margin-top: 8px; }
.done-grid h2 { font-size: 24px; font-weight: 400; margin: 0 0 12px; }
.done-grid .fine { font-size: 12px; color: var(--muted); margin: 14px 0; }
.done-icon { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--green-soft); color: #0b6b3f; }
.done-icon .ico { width: 34px; height: 34px; }
.done-icon.bad { background: var(--pink-soft); color: var(--red); }
.done-icon.wait { background: var(--violet-100); color: var(--violet-600); }

.cert-wrap { max-height: 70vh; overflow: auto; border: 1px solid var(--line); }
.cert-wrap > div { transform-origin: 0 0; }
.hist { width: 100%; border-collapse: collapse; font-size: 14px; }
.hist th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.hist td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

@media (max-width: 860px) {
  .sg-scroll .doc-stack { padding-left: 16px; padding-right: 16px; align-items: flex-start; }
  .guide { display: none; }
  .panel, .panel.drawer { right: 0; left: 0; width: auto; top: 0; bottom: 0; max-height: none; border-radius: 0; }
  .rail { width: 58px; }
  .rail-btn { width: 56px; font-size: 10.5px; }
  .sg-foot .mid a, .sg-foot .copy { display: none; }
  .done-grid { grid-template-columns: 1fr; }
  .done-grid > div + div { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 24px; }
  .adopt-names, .draw-grid { grid-template-columns: 1fr; }
  .sg-top h1 { font-size: 16px; }
}

@media print {
  body.sign { display: block; overflow: visible; background: #fff; height: auto; }
  .sg-top, .sg-banner, .rail, .sg-foot, .panel, .guide, .page-meta, .sg-finish-bottom, .overlay, .toast-host { display: none !important; }
  .sg-body, .sg-scroll { display: block; overflow: visible; }
  .sg-scroll .doc-stack { padding: 0; display: block; }
  .page-wrap { box-shadow: none; break-after: page; margin: 0 auto; }
  .fld.todo { background: transparent !important; outline: 1px dashed #999 !important; color: #999 !important; }
  .fld.todo.sign-like * { display: none; }
}
