:root {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --ink: #12141c;
  --muted: #5c6478;
  --line: #e2e7f0;
  --brand: #2f5bff;
  --brand-2: #6b8cff;
  --brand-soft: #eef2ff;
  --ok: #0f9d6b;
  --ok-soft: #e8f8f1;
  --warn: #b45309;
  --shadow: 0 18px 50px rgba(18, 28, 60, 0.08);
  --radius: 18px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #dfe7ff 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #e8fff6 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 8px;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #22c55e);
  display: grid; place-items: center; color: #fff; font-size: 14px;
  box-shadow: 0 8px 20px rgba(47, 91, 255, 0.28);
}
.brand small {
  display: block; font-weight: 500; color: var(--muted); font-size: 12px;
  letter-spacing: 0;
}
.claim {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ok-soft); color: var(--ok);
  border: 1px solid #b7ebd4; border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600;
}
.claim::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 0 4px rgba(15, 157, 107, 0.18);
}

.hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 28px;
  padding: 28px 0 18px;
  align-items: start;
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
}

h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin: 0 0 14px;
}
.lead {
  color: var(--muted); font-size: 1.05rem; line-height: 1.55;
  margin: 0 0 22px; max-width: 42ch;
}
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.pill {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 12px; font-size: 12.5px; color: var(--muted);
}
.cta-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn {
  appearance: none; border: none; cursor: pointer;
  border-radius: 12px; padding: 12px 18px; font-weight: 650;
  font-size: 14px; transition: transform .15s ease, box-shadow .15s ease, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; box-shadow: 0 10px 24px rgba(47, 91, 255, 0.28);
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--ink);
}
.btn-ghost:hover { background: #f8faff; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none !important; }
.soft-cta {
  margin-top: 18px; font-size: 13.5px; color: var(--muted);
}
.soft-cta a { font-weight: 650; }

.panel {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfcff, #f5f7fc);
}
.panel-head h2 { margin: 0; font-size: 15px; letter-spacing: -0.01em; }
.panel-body { padding: 16px; }

.drop {
  border: 1.5px dashed #c5cee0; border-radius: 14px;
  background: #f8faff; padding: 28px 18px; text-align: center;
  transition: border-color .15s, background .15s;
}
.drop.dragover { border-color: var(--brand); background: var(--brand-soft); }
.drop strong { display: block; margin-bottom: 6px; }
.drop span { color: var(--muted); font-size: 13px; }
.file-input { display: none; }

.tools {
  display: grid; gap: 12px; margin-top: 14px;
}
.tabs {
  display: flex; gap: 6px; background: #eef1f8; padding: 4px; border-radius: 12px;
}
.tab {
  flex: 1; border: none; background: transparent; border-radius: 9px;
  padding: 9px 10px; font-weight: 650; font-size: 13px; color: var(--muted); cursor: pointer;
}
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.06); }

.sig-box {
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  min-height: 140px; position: relative; overflow: hidden;
}
#drawCanvas { width: 100%; height: 140px; display: block; touch-action: none; cursor: crosshair; }
.type-pane, .image-pane { padding: 14px; display: none; }
.type-pane.active, .image-pane.active { display: block; }
.draw-pane { display: none; }
.draw-pane.active { display: block; }

input[type="text"], select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; font-size: 15px; outline: none; background: #fff;
}
input[type="text"]:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,91,255,.12); }

.sig-preview {
  margin-top: 10px; min-height: 64px; border-radius: 10px;
  border: 1px dashed #cfd6e6; display: grid; place-items: center;
  font-family: "Segoe Script", "Brush Script MT", cursive; font-size: 32px;
  color: #1a2340; background: #fafbff;
}

.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

.viewer-wrap { margin-top: 22px; }
.viewer-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 10px;
}
.viewer-toolbar .meta { color: var(--muted); font-size: 13px; margin-left: auto; }
.canvas-stage {
  position: relative; background: #d8dee9; border-radius: 16px;
  padding: 18px; overflow: auto; max-height: min(72vh, 820px);
  border: 1px solid var(--line);
}
#pdfCanvas {
  display: block; margin: 0 auto; background: #fff;
  box-shadow: 0 12px 40px rgba(20, 30, 60, 0.18);
  max-width: 100%;
}
#sigOverlay {
  position: absolute; border: 2px dashed var(--brand); border-radius: 4px;
  background: rgba(47, 91, 255, 0.06); cursor: move;
  display: none; touch-action: none; user-select: none;
  box-shadow: 0 8px 24px rgba(47, 91, 255, 0.15);
}
#sigOverlay img, #sigOverlay canvas {
  width: 100%; height: 100%; object-fit: contain; pointer-events: none;
  display: block;
}
#sigOverlay .handle {
  position: absolute; right: -7px; bottom: -7px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--brand); border: 2px solid #fff; cursor: nwse-resize;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.footer {
  padding: 36px 0 48px; color: var(--muted); font-size: 13px;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between;
  border-top: 1px solid transparent; margin-top: 28px;
}
.footer strong { color: var(--ink); }

.status {
  display: none; margin-top: 12px; padding: 10px 12px; border-radius: 10px;
  font-size: 13px; background: var(--ok-soft); color: var(--ok); border: 1px solid #b7ebd4;
}
.status.show { display: block; }
.status.error { background: #fff1f1; color: #b42318; border-color: #f3c1bc; }

.hidden { display: none !important; }
