:root {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #f0f1f7;
  --text: #16172b;
  --muted: #5d6075;
  --border: #e2e3ee;
  --accent: #e5484d;
  --accent-hover: #cf3a40;
  --accent-soft: #fde8e8;
  --ok: #18a058;
  --shadow: 0 1px 2px rgba(20, 20, 50, .06), 0 8px 24px rgba(20, 20, 50, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111218;
    --surface: #1a1b24;
    --surface-2: #232431;
    --text: #ecedf5;
    --muted: #a0a2b6;
    --border: #2d2f3e;
    --accent: #ff5a5f;
    --accent-hover: #ff7478;
    --accent-soft: #3a1d22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
img, canvas { max-width: 100%; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
[hidden] { display: none !important; }

/* Header / footer */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none; }
.nav { display: flex; align-items: center; gap: 18px; }
.nav a { color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--accent); }
.pass-badge { background: var(--ok); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
footer { border-top: 1px solid var(--border); margin-top: 64px; padding: 32px 0 16px; background: var(--surface); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
.footer-links { display: flex; flex-direction: column; gap: 6px; }
.footer-links a { color: var(--muted); text-decoration: none; font-size: 14px; }
.footer-links a:hover { color: var(--accent); }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 10px; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.big { font-size: 18px; padding: 14px 28px; border-radius: 12px; }
.btn.small { padding: 5px 10px; font-size: 14px; }
.icon-btn { border: 0; background: var(--surface-2); color: var(--text); width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 15px; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

/* Home */
.hero { text-align: center; padding: 56px 0 24px; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); line-height: 1.1; margin: 0 0 14px; letter-spacing: -.02em; }
.hero p { font-size: 19px; color: var(--muted); max-width: 640px; margin: 0 auto; }
.trust { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; margin-top: 20px; color: var(--muted); font-size: 14px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 32px; }
.tool-card {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .12s, border-color .12s;
}
.tool-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.tool-card .ico { font-size: 28px; }
.tool-card h3 { margin: 8px 0 4px; font-size: 18px; }
.tool-card p { margin: 0; color: var(--muted); font-size: 14px; }
section h2 { font-size: 28px; margin: 56px 0 8px; text-align: center; }
section > .muted.center { text-align: center; margin: 0 0 24px; }
.pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.pricing.one { max-width: 380px; margin: 0 auto; }
.price-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.price-card.featured { border: 2px solid var(--accent); }
.price-card .amount { font-size: 36px; font-weight: 800; }
.price-card .amount em { font-size: 16px; font-style: normal; color: var(--muted); font-weight: 500; }
.price-card ul { margin: 0; padding-left: 20px; color: var(--muted); flex: 1; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.step b { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; }

/* Tool pages */
.tool-head { text-align: center; padding: 36px 0 20px; }
.tool-head h1 { font-size: clamp(28px, 5vw, 40px); margin: 0 0 8px; letter-spacing: -.01em; }
.tool-head p { color: var(--muted); margin: 0 auto; max-width: 600px; font-size: 17px; }
.dropzone {
  border: 2px dashed var(--border); background: var(--surface); border-radius: 18px; padding: 48px 16px;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s; max-width: 720px; margin: 0 auto;
}
.dropzone:hover, .dropzone.over, .dropzone:focus-visible { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.dropzone .btn { pointer-events: none; }
.dropzone p { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.toolbar .group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 14px; }
input[type=text], input[type=number], select {
  font: inherit; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-row label { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; flex: 1 1 180px; font-weight: 400; }
.radio-row label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-row small { display: block; color: var(--muted); }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-list li { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.file-list .thumb { width: 44px; height: 56px; object-fit: contain; background: #fff; border-radius: 4px; border: 1px solid var(--border); flex: none; }
.file-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .meta { color: var(--muted); font-size: 13px; }

.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.page-card { background: var(--surface-2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; border: 2px solid transparent; }
.page-card.removed { opacity: .35; }
.page-card .preview { width: 100%; aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; }
.page-card .preview canvas { max-width: 100%; max-height: 100%; box-shadow: 0 1px 4px rgba(0,0,0,.25); transition: transform .2s; background: #fff; }
.page-card .controls { display: flex; gap: 4px; }
.page-card .num { font-size: 13px; color: var(--muted); }
.result { text-align: center; padding: 8px 0 0; }
.result .big-num { font-size: 28px; font-weight: 800; }
.result .good { color: var(--ok); }

/* Fill & sign editor */
.editor-bar { position: sticky; top: 60px; z-index: 10; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; box-shadow: var(--shadow); margin-bottom: 16px; }
.editor-bar .mode { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 600; cursor: pointer; }
.editor-bar .mode.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.editor-bar .spacer { flex: 1; }
.editor-bar .hint { color: var(--muted); font-size: 13px; width: 100%; padding: 0 4px; }
.pages { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.page { position: relative; box-shadow: 0 2px 10px rgba(0,0,0,.2); background: #fff; touch-action: pan-y; }
.page canvas { display: block; width: 100%; height: 100%; }
.page.placing { cursor: crosshair; }
.item { position: absolute; touch-action: none; }
.item .content { outline: 1px dashed transparent; }
.item:hover .content, .item.selected .content { outline-color: #3b82f6; }
.item.text .content { font-family: Helvetica, Arial, sans-serif; color: #000; white-space: pre; line-height: 1.2; min-width: 4px; cursor: text; }
.item .content:focus { outline: 1px solid #3b82f6; }
.item.sig img { display: block; width: 100%; height: 100%; pointer-events: none; }
.item.sig .content, .item.box .content { width: 100%; height: 100%; cursor: move; }
.item.box .content { background: #fff; outline: 1px dashed #9aa; }
.item.mark .content { font-family: Helvetica, Arial, sans-serif; color: #000; line-height: 1; cursor: move; }
.item .handle, .item .del, .item .resize { position: absolute; display: none; width: 22px; height: 22px; border-radius: 50%; border: 0; font-size: 12px; line-height: 22px; text-align: center; padding: 0; cursor: pointer; color: #fff; }
.item:hover .handle, .item:hover .del, .item:hover .resize,
.item.selected .handle, .item.selected .del, .item.selected .resize { display: block; }
.item .handle { left: -26px; top: -2px; background: #3b82f6; cursor: move; }
.item .del { right: -26px; top: -2px; background: #e5484d; }
.item .resize { right: -11px; bottom: -11px; background: #3b82f6; cursor: nwse-resize; }
.size-ctl { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); }
.size-ctl select { padding: 5px 8px; font-size: 14px; }

dialog { border: 0; border-radius: 18px; padding: 24px; background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); max-width: min(520px, calc(100vw - 32px)); width: 100%; }
dialog::backdrop { background: rgba(10, 10, 25, .55); }
dialog h2 { margin: 0 0 8px; }
dialog .close { position: absolute; right: 14px; top: 10px; border: 0; background: none; color: var(--muted); font-size: 26px; cursor: pointer; }
.sig-pad { width: 100%; height: 180px; background: #fff; border: 1px solid var(--border); border-radius: 10px; touch-action: none; cursor: crosshair; display: block; }
.sig-type { width: 100%; font-family: "Dancing Script", cursive; font-size: 34px; }
.tabs { display: flex; gap: 6px; margin: 12px 0; }
.tabs button { flex: 1; }
.tabs button.active { border-color: var(--accent); color: var(--accent); }

/* Paywall */
.paywall .plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 16px 0; }
.pro-offer { border: 2px solid var(--accent); background: var(--accent-soft); border-radius: 14px; padding: 18px; margin: 16px 0; display: flex; flex-direction: column; gap: 10px; }
.pro-offer .amount { font-size: 34px; font-weight: 800; }
.pro-offer .amount em { font-size: 15px; font-style: normal; color: var(--muted); font-weight: 500; }
.pro-offer ul { margin: 0; padding-left: 20px; }
.plan { display: flex; flex-direction: column; gap: 2px; border: 2px solid var(--border); border-radius: 14px; padding: 16px; text-decoration: none; color: var(--text); }
.plan:hover { border-color: var(--accent); }
.plan.featured { border-color: var(--accent); background: var(--accent-soft); }
.plan strong { font-size: 28px; }
.plan strong em { font-size: 14px; font-style: normal; color: var(--muted); }
.plan span { font-weight: 700; }
.plan small { color: var(--muted); }
.notice { background: var(--accent-soft); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: #16172b; color: #fff; padding: 12px 18px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.3); transition: .25s; z-index: 100; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* SEO copy */
.seo { max-width: 760px; margin: 56px auto 0; }
.seo h2 { text-align: left; font-size: 22px; margin: 32px 0 8px; }
.seo h3 { font-size: 17px; margin: 18px 0 4px; }
.seo p, .seo li { color: var(--muted); }
.restore { max-width: 560px; margin: 24px auto 0; text-align: left; }
.restore p { margin: 6px 0 10px; }
.restore-row { display: flex; gap: 8px; }
.restore-row input { flex: 1; min-width: 0; font-size: 13px; }
.prose { max-width: 760px; margin: 0 auto; padding-top: 32px; }

@media (max-width: 600px) {
  .editor-bar { gap: 4px; padding: 6px; }
  .editor-bar .mode { padding: 6px 9px; font-size: 14px; }
  .editor-bar .btn { padding: 6px 10px; font-size: 14px; }
  .editor-bar .hint { font-size: 12px; }
  .size-ctl { font-size: 0; }
}

/* Accounts */
.nav-link { border: 0; background: none; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; padding: 0; }
.nav-link:hover { color: var(--accent); }
.account { position: relative; }
.account summary { list-style: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; cursor: pointer; overflow: hidden; }
.account summary::-webkit-details-marker { display: none; }
.account summary img { width: 100%; height: 100%; object-fit: cover; }
.account-menu { position: absolute; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 12px; min-width: 230px; display: flex; flex-direction: column; gap: 4px; z-index: 30; }
.account-email { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.menu-item { border: 0; background: none; color: var(--text); font: inherit; text-align: left; padding: 8px; border-radius: 8px; cursor: pointer; }
.menu-item:hover { background: var(--surface-2); }
.auth { max-width: min(420px, calc(100vw - 32px)); }
.auth h2 { margin-bottom: 4px; }
.auth form { display: flex; flex-direction: column; gap: 10px; }
.auth input { font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.btn.google { width: 100%; margin-top: 12px; padding: 11px; gap: 10px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.form-error { color: var(--accent); font-size: 14px; margin: 0; }
.link { border: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.auth > .link { margin-top: 10px; font-size: 14px; }
.switch { font-size: 14px; margin: 14px 0 6px; }
@media (max-width: 480px) { .hide-narrow { display: none; } .nav { gap: 12px; } }

/* Editing existing text */
.text-layer { position: absolute; inset: 0; pointer-events: none; }
.orig-run { position: absolute; border-radius: 2px; }
.pages.text-mode .orig-run { pointer-events: auto; cursor: text; }
.pages.text-mode .orig-run:hover { outline: 1px solid #3b82f6; background: rgba(59, 130, 246, .08); }
.orig-run.editing { pointer-events: none !important; }
.cover { position: absolute; }
.item .restore { position: absolute; display: none; width: 22px; height: 22px; border-radius: 50%; border: 0; font-size: 13px; line-height: 22px; padding: 0; cursor: pointer; color: #fff; background: #64748b; right: -50px; top: -2px; }
.item:hover .restore, .item.selected .restore { display: block; }
.item.text .content { font-family: inherit; color: inherit; }
#text-color { width: 34px; height: 30px; padding: 0 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
