/* ============================================================
   PDF SIGN — clean, minimal, app-style layout.
   ============================================================ */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --ink: #14181d;
  --muted: #6a747e;
  --subtle: #9aa3ac;
  --line: #e6e9ed;
  --line-2: #d7dce1;
  --accent: #2f6f6a;
  --accent-ink: #ffffff;
  --danger: #b3402f;
  --shadow-sm: 0 1px 2px rgba(20, 30, 40, 0.06), 0 2px 8px rgba(20, 30, 40, 0.05);
  --shadow-lg: 0 24px 60px -24px rgba(20, 30, 40, 0.35);
  --radius: 12px;
  --header-h: 56px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e242b;
    --ink: #e7ecf1;
    --muted: #95a0aa;
    --subtle: #69727b;
    --line: #262d35;
    --line-2: #323b44;
    --accent: #5fb6ad;
    --accent-ink: #0c1012;
    --danger: #e0826f;
    --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }

/* ---- header ---- */
.site-header {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 clamp(16px, 4vw, 32px);
  background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.logo-link { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; }
.logo-link small { display: block; font-size: 10px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; }
.home-link { color: var(--muted); font-size: 13px; font-weight: 600; }
.home-link:hover { color: var(--accent); }

/* ============================================================
   LANDING
   ============================================================ */
.landing { display: block; }
body.has-doc .landing { display: none; }

.hero {
  min-height: calc(100dvh - var(--header-h));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 14px; padding: 40px clamp(16px, 5vw, 40px);
}
.eyebrow { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.hero h1 { font-size: clamp(28px, 5vw, 46px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; }
.hero .sub { max-width: 540px; color: var(--muted); font-size: 15px; }

.dropzone {
  margin-top: 10px; width: min(560px, 100%); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 44px 28px; border: 1.5px dashed var(--line-2); border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); transform: translateY(-1px); }
.dropzone input { display: none; }
.dz-ico { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); color: var(--accent); }
.dz-ico svg { width: 26px; height: 26px; }
.dz-title { font-size: 17px; font-weight: 700; }
.dz-sub { font-size: 13px; color: var(--muted); }
.dz-sub strong, .dz-title strong { color: var(--accent); }

.feat { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 10px; justify-content: center; }
.feat li { font-size: 12.5px; color: var(--muted); padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.trust-line { margin: 12px 0 0; font-size: 13px; font-weight: 600; color: var(--accent); display: inline-flex; align-items: center; gap: 7px; }
.trust-line .lock { font-size: 14px; }

/* shared section scaffolding */
.eyebrow.center { text-align: center; }
.privacy, .how { max-width: 960px; margin: 0 auto; padding: 18px clamp(16px, 5vw, 40px) 12px; text-align: center; }
.privacy h2, .how h2 { font-size: clamp(22px, 3.4vw, 30px); font-weight: 800; letter-spacing: -0.015em; margin: 6px 0 8px; }
.section-sub { max-width: 620px; margin: 0 auto; color: var(--muted); font-size: 14.5px; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 26px; text-align: left; }
.card { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.card-ico { font-size: 22px; }
.card h3 { font-size: 15px; font-weight: 750; margin: 10px 0 5px; }
.card p { font-size: 13px; color: var(--muted); }

.steps { list-style: none; counter-reset: s; margin: 26px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; text-align: left; }
.steps li { position: relative; padding: 22px 20px 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); }
.step-n { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); color: var(--accent); font-weight: 800; font-size: 15px; }
.steps h3 { font-size: 15px; font-weight: 750; margin: 12px 0 5px; }
.steps p { font-size: 13px; color: var(--muted); }

.faq-wrap { max-width: 760px; margin: 0 auto; padding: 26px clamp(16px, 5vw, 40px) 60px; }
.faq-wrap h2 { font-size: clamp(22px, 3.4vw, 28px); font-weight: 800; letter-spacing: -0.01em; margin-bottom: 16px; text-align: center; }
.faq { display: grid; gap: 10px; }
.faq details { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 0 16px; box-shadow: var(--shadow-sm); }
.faq summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 0; font-weight: 650; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-weight: 700; font-size: 18px; }
.faq details[open] summary::after { content: "\2013"; }
.faq details > p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }

.disclaimer { max-width: 760px; margin: 8px auto 0; padding: 14px 16px; display: flex; align-items: flex-start; gap: 11px; border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.disclaimer .dz-badge { flex-shrink: 0; font-size: 15px; line-height: 1.4; }
.disclaimer span:last-child { font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.disclaimer strong { color: var(--ink); }

.site-footer { max-width: 980px; margin: 0 auto; padding: 22px clamp(16px, 5vw, 40px) 32px; display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; color: var(--subtle); font-size: 12px; border-top: 1px solid var(--line); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 16px; }
.site-footer a:hover { color: var(--accent); }

/* ============================================================
   WORKSPACE
   ============================================================ */
.workspace { display: none; }
body.has-doc .workspace {
  display: grid;
  grid-template-columns: 60px 1fr;
  grid-template-rows: 52px 1fr;
  height: calc(100dvh - var(--header-h));
}
body.has-doc { overflow: hidden; }

.topbar {
  grid-column: 1 / 3; grid-row: 1;
  display: flex; align-items: center; gap: 12px; padding: 0 12px 0 10px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.tb-center { display: flex; align-items: center; gap: 6px; margin: 0 auto; }
.tb-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.tb-center + .tb-right { margin-left: 0; }
.doc-title { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; font-size: 13.5px; }

.ico-btn { min-width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 16px; font-weight: 700; line-height: 1; cursor: pointer; }
.ico-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ico-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ind { font-size: 12px; font-weight: 700; color: var(--muted); min-width: 50px; text-align: center; font-variant-numeric: tabular-nums; }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

.tb-btn { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-weight: 650; font-size: 13px; cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.tb-btn svg { width: 17px; height: 17px; }
.tb-btn.ghost:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.tb-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tb-btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #000); }
.tb-btn:disabled { opacity: 0.5; cursor: not-allowed; }
#close-doc { border-color: transparent; background: transparent; padding-left: 6px; }
#close-doc:hover { color: var(--accent); }
#close-doc svg { width: 18px; height: 18px; }

/* side rail */
.rail { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; background: var(--surface); border-right: 1px solid var(--line); }
.rail-btn { width: 48px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 0; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--muted); cursor: pointer; transition: background 0.12s, color 0.12s; }
.rail-btn svg { width: 22px; height: 22px; }
.rail-btn span { font-size: 10.5px; font-weight: 700; letter-spacing: 0.01em; }
.rail-btn:hover { background: var(--surface-2); color: var(--accent); }
.rail-btn:active { transform: translateY(1px); }

/* viewer */
.viewer { grid-column: 2; grid-row: 2; position: relative; overflow: auto; padding: 28px; display: flex; justify-content: center; align-items: flex-start; background: var(--surface-2); }
.page-holder { position: relative; line-height: 0; box-shadow: var(--shadow-lg); background: #fff; }
#page-canvas { display: block; }
#overlay { position: absolute; inset: 0; }

.hint { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); margin: 0; padding: 9px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.hint.show { opacity: 0.94; }
.hint strong { color: #fff; }

/* placements */
.place { position: absolute; cursor: grab; border: 1px solid transparent; border-radius: 2px; touch-action: none; }
.place img { width: 100%; height: 100%; display: block; pointer-events: none; -webkit-user-drag: none; }
.place.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent); }
.place.dragging { cursor: grabbing; box-shadow: none; will-change: transform; }
.place-del { position: absolute; top: -11px; right: -11px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); color: var(--danger); cursor: pointer; display: none; place-items: center; padding: 0; z-index: 3; box-shadow: var(--shadow-sm); }
.place-del svg { width: 12px; height: 12px; }
.place.is-selected .place-del { display: grid; }
.place-handle { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; border-radius: 3px; background: var(--accent); border: 2px solid var(--surface); cursor: nwse-resize; display: none; z-index: 3; }
.place.is-selected .place-handle { display: block; }

/* ============================================================
   MODALS
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; padding: 18px; background: color-mix(in srgb, #0a0d10 52%, transparent); backdrop-filter: blur(3px); }
.modal.open { display: flex; }
.modal-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop 0.16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; }
.modal-head h3 { font-size: 16px; font-weight: 750; }
.x-btn { width: 30px; height: 30px; border: 0; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.x-btn:hover { color: var(--ink); }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px 18px; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 0 18px; padding: 4px; background: var(--surface-2); border-radius: 10px; }
.seg-btn { border: 0; background: transparent; color: var(--muted); height: 32px; border-radius: 7px; font-weight: 650; font-size: 13px; cursor: pointer; }
.seg-btn.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

.sign-panel { padding: 16px 18px 4px; display: grid; gap: 12px; }
.sign-panel.hidden { display: none; }
.pad { width: 100%; height: 160px; display: block; touch-action: none; cursor: crosshair; border: 1px solid var(--line-2); border-radius: 10px; background: linear-gradient(var(--line-2), var(--line-2)) no-repeat left calc(100% - 40px) / 100% 1px, var(--surface); }
.type-preview { min-height: 70px; display: grid; place-items: center; padding: 8px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(var(--line-2), var(--line-2)) no-repeat left calc(100% - 16px) / 100% 1px, var(--surface); }
.type-preview img { max-height: 58px; max-width: 100%; }

input[type="text"], select { width: 100%; height: 38px; padding: 0 11px; border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface); outline: none; }
input[type="text"]:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }

.row { display: flex; align-items: flex-end; gap: 10px; }
.row.between { justify-content: space-between; align-items: center; }
.inline { display: grid; gap: 5px; font-size: 11.5px; font-weight: 650; color: var(--muted); }
.inline.grow { flex: 1; }
.inline select { width: auto; min-width: 96px; }
.inline.grow select { width: 100%; }

.upload-drop { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 28px; border: 1.5px dashed var(--line-2); border-radius: 12px; background: var(--surface-2); cursor: pointer; text-align: center; }
.upload-drop:hover { border-color: var(--accent); }
.upload-drop input { display: none; }

.btn, .primary, .ghost { height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line-2); font-weight: 650; font-size: 13px; cursor: pointer; background: var(--surface); transition: background 0.12s, border-color 0.12s; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.ghost:hover { border-color: var(--accent); color: var(--accent); }
.ghost.sm { height: 34px; padding: 0 13px; font-size: 12.5px; }

/* stamps */
.stamp-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 16px 18px 6px; }
.stamp-card { display: grid; place-items: center; min-height: 64px; padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); cursor: pointer; transition: border-color 0.12s, transform 0.1s; }
.stamp-card:hover { border-color: var(--accent); }
.stamp-card:active { transform: scale(0.98); }
.stamp-card img { max-width: 100%; max-height: 42px; }
.stamp-extra { padding: 6px 18px 18px; display: grid; gap: 10px; border-top: 1px solid var(--line); margin-top: 8px; }
.stamp-extra .row input[type="text"] { flex: 1; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(10px); z-index: 60; padding: 10px 18px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 0.96; transform: translateX(-50%) translateY(0); }

@media (max-width: 600px) {
  body.has-doc .workspace { grid-template-columns: 54px 1fr; }
  .doc-title { max-width: 22vw; }
  .tb-btn span { display: none; }
  .tb-btn { padding: 0 11px; }
  .viewer { padding: 14px; }
  .stamp-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .cards, .steps { grid-template-columns: 1fr; }
}
