/* Slap Edit by Nerd Base One: the editor */
@font-face { font-family: "Sora"; src: url(fonts/sora-normal.woff2) format("woff2"); font-weight: 400 800; }
@font-face { font-family: "DM Sans"; src: url(fonts/dmsans-normal.woff2) format("woff2"); font-weight: 400 700; }

:root {
  --brand: #00aa55; --brand-ink: #007a3d; --brand-soft: #e3f6ec;
  --bg: #eceeea; --panel: #ffffff; --fg: #181a17; --muted: #5d625c; --line: #dcdfd9;
  --err-bg: #fdecec; --err: #b42318; --warn-bg: #fff6e0; --warn: #8a5a00;
  --font: "DM Sans", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --display: "Sora", var(--font);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand-ink: #2fd27f; --brand-soft: #10291c;
    --bg: #111311; --panel: #191c19; --fg: #e8eae6; --muted: #9ba19a; --line: #2a2e2a;
    --err-bg: #2d1514; --err: #ff8a80; --warn-bg: #2b2210; --warn: #f1c56b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); }
h1, h2 { font-family: var(--display); letter-spacing: -0.02em; margin: 0 0 .4em; }
.muted { color: var(--muted); }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 20; } /* toolbar + banners: banners always sit right under the toolbar */
.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; font: 600 1.05rem var(--display); margin-right: 6px; }
.brand b { color: var(--brand-ink); }
.btn, .tools button { font: 600 .9rem/1 var(--font); padding: 9px 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--fg); cursor: pointer; display: inline-flex; align-items: center; }
.btn:hover, .tools button:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #06140c; } }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.hist { display: flex; gap: 6px; }
.tools { display: flex; gap: 4px; padding: 3px; border-radius: 11px; background: var(--bg); }
.tools button { border-color: transparent; background: transparent; }
.tools button.on { background: var(--panel); border-color: var(--brand); color: var(--brand-ink); }
.props { display: flex; gap: 6px; align-items: center; }
.props select, .props input { font: inherit; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); padding: 0 8px; }
.props input[type=number] { width: 64px; }
.props input[type=color] { width: 40px; padding: 3px; }
#save { margin-left: auto; }
.hint { margin: 0 auto; width: fit-content; padding: 6px 14px; border-radius: 0 0 9px 9px;
  background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.hint:empty { display: none; }
.locked { margin: 0; padding: 12px 16px; text-align: center; font: 700 1.05rem var(--display);
  background: var(--err-bg); color: var(--err); border-bottom: 2px solid var(--err); }
.locked[hidden] { display: none; }
.locked .unlk, .locked.unlocked .lk { display: none; }
.locked.unlocked .unlk { display: inline; }
.locked.unlocked { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
#signed-dlg:not(.on-save) .anyway { display: none; } /* "save anyway" is only offered when a save was blocked */
.btn.danger { color: var(--err); border-color: var(--err); }
a.btn { text-decoration: none; }
a.btn[hidden] { display: none; }
#key-msg.err { color: var(--err); font-weight: 600; }
#key-input { font-family: "Courier New", monospace; text-transform: uppercase; }
#lic-info { align-self: center; color: var(--muted); }

/* ---------- Clean up review ---------- */
.clean-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 16px;
  padding: 10px 16px; background: var(--brand-soft); color: var(--fg); border-bottom: 2px solid var(--brand); }
.clean-bar[hidden] { display: none; }
.clean-actions { display: flex; gap: 8px; }
.cleaning .tools, .cleaning .props, .cleaning #save, .cleaning #add-btn, .cleaning .hist { opacity: .4; pointer-events: none; }
.cand { position: absolute; z-index: 5; cursor: pointer; border: 2px dashed #8a8f88; background: rgba(140, 145, 136, .12); border-radius: 4px; }
.cand.on { border: 2px solid var(--err); background: rgba(180, 35, 24, .16); }
.cand::after { content: attr(data-label); position: absolute; left: -2px; bottom: 100%; margin-bottom: 2px; white-space: nowrap;
  font: 700 12px/1.4 var(--font); padding: 1px 6px; border-radius: 4px; background: #5d625c; color: #fff; }
.cand.on::after { background: var(--err); }
.cand.scan { inset: 0; cursor: default; border: 0; background: transparent; }
.cand.scan::after { top: 8px; left: 8px; bottom: auto; background: var(--warn); }
.warn-dlg { border: 2px solid var(--err); }
.warn-dlg h2 { color: var(--err); font-size: 1.4rem; }
.warn-dlg p { font-size: 1.05rem; }

/* ---------- pages ---------- */
#viewer { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 24px 16px 80px; }
.empty { text-align: center; margin-top: 12vh; color: var(--muted); border: 2px dashed var(--line); border-radius: 18px; padding: 48px 56px; }
.empty h1 { color: var(--fg); }
.empty .by { margin: -0.4em 0 1em; font-weight: 600; }
.by { font: 500 .8rem var(--font); color: var(--muted); letter-spacing: 0; }
body.dragging .empty { border-color: var(--brand); }
.page { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15), 0 10px 30px -14px rgba(0,0,0,.3); }
.page canvas { display: block; }
.tool-text .page { cursor: text; }
.tool-sign .page, .tool-white .page, .tool-field .page { cursor: crosshair; }

/* the PDF's own fill-in boxes (text form fields) */
.fld { position: absolute; z-index: 1; margin: 0; padding: 0 2px; border: 0; border-radius: 2px; resize: none; overflow: hidden;
  font-family: Helvetica, Arial, sans-serif; line-height: 1.15; color: #000; background: rgba(0, 110, 255, .1); }
.fld:hover { background: rgba(0, 110, 255, .16); }
.fld:focus { outline: 1.5px solid #2f7de1; background: rgba(0, 110, 255, .06); }

/* existing text you can click to replace (Edit text tool only) */
.hit { position: absolute; pointer-events: none; border-radius: 2px; }
.tool-edit .hit { pointer-events: auto; cursor: text; outline: 1px dashed rgba(0,122,61,.45); }
.tool-edit .hit:hover { background: rgba(0,170,85,.18); outline-style: solid; }

/* ---------- placed objects ---------- */
.obj { position: absolute; }
.tool-edit .obj, .tool-white .obj, .tool-field .obj { pointer-events: none; }
.obj[data-type=field] { cursor: move; background: rgba(0, 110, 255, .1); }
.obj[data-type=field]:not(.sel) { outline: 1px dashed #2f7de1; }
.tool-edit .obj .txt { pointer-events: auto; }
.obj[data-type=rect] { background: #fff; cursor: move; }
.obj[data-type=image] { cursor: move; }
.obj[data-type=image] img { display: block; width: 100%; height: 100%; pointer-events: none; }
.obj .txt { white-space: pre; line-height: 1.2; outline: none; min-width: 4px; cursor: text; }
.obj.sel { outline: 1.5px solid var(--brand); outline-offset: 2px; }
.obj[data-type=rect]:not(.sel) { outline: 1px dashed rgba(0,0,0,.12); }
.obj .del, .obj .grip, .obj .rs { position: absolute; display: none; }
.obj.sel .del, .obj.sel .grip, .obj.sel .rs { display: block; }
.obj .del { top: -14px; right: -14px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--err); color: #fff;
  font: 700 14px/22px var(--font); cursor: pointer; padding: 0; }
.obj .grip { top: -14px; left: -14px; width: 22px; height: 22px; border-radius: 6px; background: var(--brand); cursor: move; }
.obj .grip::after { content: "✥"; color: #fff; font-size: 14px; line-height: 22px; display: block; text-align: center; }
.obj .rs { right: -6px; bottom: -6px; width: 12px; height: 12px; border-radius: 3px; background: var(--brand); cursor: nwse-resize; }

/* ---------- signature dialog ---------- */
dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--fg); padding: 22px; width: min(660px, 96vw); }
dialog::backdrop { background: rgba(10,12,10,.5); }
#pad { display: block; width: 100%; aspect-ratio: 3 / 1; background: #fff; border: 1px solid var(--line); border-radius: 10px; touch-action: none; cursor: crosshair; }
.row { display: flex; gap: 8px; margin-top: 14px; }
.small { font-size: .85rem; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; margin-bottom: 12px; }
.field input { font: inherit; font-weight: 400; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; font-weight: 600; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--brand-ink); }
dialog h3 { font: 650 1rem var(--display); margin: 1em 0 .3em; }
dialog ul { margin: 0; padding-left: 1.2em; }
dialog li { margin-bottom: .4em; }
#licenses { margin-top: 1em; }
#licenses summary { cursor: pointer; font-weight: 600; color: var(--brand-ink); }
#notices { max-height: 40vh; overflow: auto; white-space: pre-wrap; font: 12px/1.45 ui-monospace, Consolas, monospace;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.grow { flex: 1; }

/* ---------- Basic / Advanced mode ---------- */
:root:not([data-mode=advanced]) .adv { display: none; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.mode { display: flex; flex-direction: column; gap: 6px; text-align: left; font: inherit; color: var(--fg); background: var(--panel);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 16px; cursor: pointer; }
.mode b { font: 650 1.05rem var(--display); color: var(--brand-ink); }
.mode:hover, .mode[aria-pressed=true] { border-color: var(--brand); }
@media (max-width: 560px) { .modes { grid-template-columns: 1fr; } }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; max-width: 90vw; padding: 12px 18px;
  border-radius: 10px; background: var(--err-bg); color: var(--err); font-weight: 600; box-shadow: 0 8px 24px -10px rgba(0,0,0,.4); }
#toast.ok { background: var(--brand-soft); color: var(--brand-ink); }

/* release number in the bottom-right corner, filled in at build time */
.app-version { position: fixed; right: 6px; bottom: 4px; z-index: 2147483647; font: 11px/1.4 system-ui, sans-serif; color: #888; opacity: .8; pointer-events: none; user-select: none; }
@media print { .app-version { display: none; } }
