/* Nova Forms: phone-first. One column, a sticky "Make" bar at the bottom while setting up. */
:root {
  --bg: #0b0b12;
  --panel: #14141d;
  --panel-2: #1c1c28;
  --line: #2a2a3a;
  --text: #ecebf7;
  --muted: #8f8eaa;
  --accent: #7DFABC;
  --accent-ink: #08080E;
  --danger: #ff6b6b;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
button, a, input, select { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#fm-app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }

/* Top bar */
#fm-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.fm-ibtn { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 0; padding: 0; background: none; border-radius: 10px; color: var(--text); text-decoration: none; }
.fm-ibtn:active { background: var(--panel-2); }
.fm-ibtn:disabled { opacity: .4; cursor: default; }
.fm-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; white-space: nowrap; min-width: 0; }
.fm-brand { flex-shrink: 0; }
.fm-brand span { color: var(--accent); margin-left: -4px; }
.fm-tool { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-weight: 500; font-size: 14px; }
.fm-tool:empty { display: none; }
.fm-tool::before { content: "\00b7"; margin-right: 6px; }
.fm-logo { color: var(--accent); }
.fm-grow { flex: 1; min-width: 0; }
@media (max-width: 340px) { .fm-logo { display: none; } }

/* Menu: a sheet from the bottom on phones, a card under the top bar on bigger screens */
.fm-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .55); }
.fm-sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; max-height: min(86vh, 640px); max-height: min(86dvh, 640px); background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); box-shadow: 0 -12px 40px rgba(0, 0, 0, .45); animation: fm-rise .18s ease-out; }
@keyframes fm-rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .fm-sheet { animation: none; } }
.fm-sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 0 18px; }
.fm-sheet-head h2 { margin: 0; font-size: 18px; }
.fm-sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 16px; }
.fm-sheet .fm-label { margin: 10px 4px 6px; }
.fm-menulist { display: flex; flex-direction: column; gap: 6px; }
.fm-menulist > button, .fm-menulist > a { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); color: var(--text); text-align: left; text-decoration: none; }
.fm-menulist > button:active, .fm-menulist > a:active { background: var(--line); }
.fm-menulist span { display: flex; flex-direction: column; min-width: 0; }
.fm-menulist b { font-weight: 600; }
.fm-menulist small { color: var(--muted); font-size: 12px; font-weight: 400; }
.fm-menulist > button[aria-current="true"] { border-color: var(--accent); background: rgba(125, 250, 188, .1); box-shadow: inset 0 0 0 1px var(--accent); }
.fm-menulist .fm-tick { margin-left: auto; color: var(--accent); visibility: hidden; }
.fm-menulist > button[aria-current="true"] .fm-tick { visibility: visible; }
@media (min-width: 700px) {
  .fm-sheet { left: auto; right: 12px; bottom: auto; top: calc(56px + env(safe-area-inset-top)); width: 380px; max-height: calc(100vh - 80px); border: 1px solid var(--line); border-radius: 16px; padding: 0; animation-duration: .12s; box-shadow: 0 16px 48px rgba(0, 0, 0, .5); }
  .fm-scrim { background: rgba(0, 0, 0, .3); }
}

/* Page */
#fm-main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 20px 16px 28px; }
.fm-screen > h1 { font-size: 28px; line-height: 1.15; margin: 8px 0 8px; letter-spacing: -.01em; }
.fm-screen > h2, .fm-h2 { font-size: 20px; margin: 4px 0 8px; }
.fm-count { color: var(--muted); font-weight: 400; font-size: 15px; }
.fm-lede { color: var(--muted); margin: 0 0 20px; font-size: 16px; }
.fm-center { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 36px; }
.fm-hint { color: var(--muted); font-size: 13px; margin: 8px 0; }
.fm-hint.fm-formats { margin-top: 2px; }
.fm-steptext { font-size: 14px; margin: 0 0 8px; }
.fm-steptext b { color: var(--text); }
.fm-privacy { text-align: center; margin-top: 18px; }
.fm-msg { min-height: 20px; margin: 8px 0 0; color: var(--danger); font-size: 14px; }
.fm-msg.ok { color: var(--accent); }
.fm-note { margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--muted); font-size: 13px; }
.fm-note.warn { border-color: var(--danger); color: #ffb0b0; }

/* Buttons */
.fm-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; }
.fm-primary:active { filter: brightness(.9); }
.fm-primary:disabled, .fm-primary[aria-disabled="true"] { opacity: .45; cursor: default; }
.fm-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); text-decoration: none; }
.fm-ghost:active { background: var(--line); }
.fm-ghost:disabled { opacity: .45; cursor: default; }
.fm-big { min-height: 54px; font-size: 16px; }
.fm-wide { width: 100%; }
.fm-link-btn { border: 0; background: none; color: var(--accent); padding: 8px 4px; font-size: 14px; }
.fm-center-btn { display: block; margin: 8px auto 0; }
.fm-chip { height: 36px; padding: 0 13px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--text); font-size: 13px; white-space: nowrap; }
.fm-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.fm-icon-chip { width: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.fm-icon-chip .ic { width: 20px; height: 20px; }

/* Start */
.fm-drop { border: 2px dashed var(--line); border-radius: 16px; padding: 18px 14px 12px; margin-bottom: 14px; text-align: center; transition: border-color .15s, background .15s; display: flex; flex-direction: column; gap: 10px; }
.fm-drop.over { border-color: var(--accent); background: rgba(125, 250, 188, .06); }
.fm-drop .fm-hint { margin: 0; }

/* Working */
.fm-spin { width: 38px; height: 38px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: fm-spin .9s linear infinite; }
@keyframes fm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .fm-spin { animation-duration: 3s; } }
.fm-bar { width: 100%; max-width: 420px; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.fm-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

/* Setting up */
.fm-fileinfo { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.fm-fi-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fm-fi-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-fi-text span { color: var(--muted); font-size: 13px; }
.fm-stagewrap { margin: 6px auto 12px; width: 100%; max-width: 440px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #fff; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.fm-stagewrap.drag { cursor: grabbing; }
#fm-stage { display: block; }
.fm-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 4px; }
.fm-zoom { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 150px; color: var(--muted); font-size: 13px; }
.fm-zoom input { flex: 1; min-width: 0; }
input[type="range"] { accent-color: var(--accent); height: 36px; }
.fm-slider { width: 100%; }
.fm-ends { display: flex; justify-content: space-between; margin-top: -4px; font-size: 12px; color: var(--muted); }
.fm-label { margin: 16px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.fm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fm-chips .fm-chip { height: auto; min-height: 38px; padding: 6px 12px; line-height: 1.2; text-align: left; white-space: normal; }
.fm-chips .fm-chip small { display: block; font-weight: 400; font-size: 11px; opacity: .8; }
.fm-custom { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.fm-custom label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.fm-custom .fm-wide-row { grid-column: 1 / -1; margin: 0; }
input[type="number"], input[type="text"], select { min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); width: 100%; font-size: 16px; }
input[type="number"]:focus, input[type="text"]:focus, select:focus { border-color: var(--accent); outline: none; }
.fm-kbrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.fm-kbrow label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.fm-numwrap { position: relative; display: block; }
.fm-numwrap input { padding-right: 40px; }
.fm-numwrap i { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: 13px; pointer-events: none; }
.fm-opts { margin-top: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); padding: 0 12px; }
.fm-opts[open] { padding-bottom: 12px; }
.fm-opts > summary { list-style: none; cursor: pointer; padding: 13px 0; font-weight: 600; font-size: 14px; }
.fm-opts > summary::-webkit-details-marker { display: none; }
.fm-opts > summary::after { content: "\25be"; float: right; color: var(--muted); }
.fm-opts[open] > summary::after { content: "\25b4"; }
.fm-check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 8px; font-size: 14px; }
.fm-check input { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; }
.fm-field { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.fm-seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.fm-seg3 { grid-template-columns: repeat(3, 1fr); }
.fm-seg button { min-height: 46px; padding: 6px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); font-weight: 600; }
.fm-seg button small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.fm-seg button[aria-pressed="true"] { border-color: var(--accent); background: rgba(125, 250, 188, .12); box-shadow: inset 0 0 0 1px var(--accent); }

/* Signature: crop box and the clean preview */
.fm-cropwrap { display: block; margin: 6px auto 12px; width: fit-content; max-width: 100%; padding: 16px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--panel-2); touch-action: none; user-select: none; -webkit-user-select: none; }
.fm-cropin { position: relative; line-height: 0; }
#fm-cropcv { display: block; max-width: 100%; background: #fff; }
.fm-croprect { position: absolute; left: 0; top: 0; width: 100%; height: 100%; border: 2px solid var(--accent); box-shadow: 0 0 0 4000px rgba(0, 0, 0, .55); cursor: move; }
.fm-ch { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; touch-action: none; }
.fm-ch::after { content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--accent); border: 2px solid #08080E; }
.fm-ch-n::after, .fm-ch-s::after, .fm-ch-w::after, .fm-ch-e::after { background: rgba(125, 250, 188, .85); }
.fm-ch-nw { left: 0; top: 0; cursor: nwse-resize; } .fm-ch-ne { left: 100%; top: 0; cursor: nesw-resize; }
.fm-ch-sw { left: 0; top: 100%; cursor: nesw-resize; } .fm-ch-se { left: 100%; top: 100%; cursor: nwse-resize; }
.fm-ch-n { left: 50%; top: 0; cursor: ns-resize; } .fm-ch-s { left: 50%; top: 100%; cursor: ns-resize; }
.fm-ch-w { left: 0; top: 50%; cursor: ew-resize; } .fm-ch-e { left: 100%; top: 50%; cursor: ew-resize; }
.fm-signwrap { margin: 6px auto 8px; width: fit-content; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 0; overflow: hidden; }
#fm-sgprev { display: block; max-width: 100%; height: auto; image-rendering: auto; }

/* Image to PDF: the pages */
.fm-pages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.fm-page { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.fm-page img { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 8px; }
.fm-page-text { min-width: 0; display: flex; flex-direction: column; }
.fm-page-text b { font-size: 14px; }
.fm-page-text span { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-page-btns { display: flex; gap: 4px; }
.fm-page-btns button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--text); display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.fm-page-btns button:disabled { opacity: .3; }
.fm-page-btns .ic { width: 18px; height: 18px; }
.fm-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Make bar */
.fm-actions { position: sticky; bottom: 0; z-index: 15; background: var(--panel); border-top: 1px solid var(--line); padding: 8px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; }
.fm-actions > * { width: 100%; max-width: 608px; }
.fm-summary { margin: 0 auto 8px; text-align: center; color: var(--muted); font-size: 13px; min-height: 18px; }
.fm-summary.warn { color: var(--danger); }

/* Done */
.fm-result-wrap { display: flex; justify-content: center; margin: 6px 0 14px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
#fm-result { display: block; max-width: 100%; max-height: 52vh; width: auto; height: auto; image-rendering: -webkit-optimize-contrast; }
.fm-pdfcard { display: flex; align-items: center; gap: 12px; margin: 6px 0 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.fm-pdfcard .ic { width: 36px; height: 36px; color: var(--accent); }
.fm-pdfcard div { min-width: 0; display: flex; flex-direction: column; }
.fm-pdfcard strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-pdfcard span { color: var(--muted); font-size: 13px; }
#fm-download { margin-bottom: 8px; }
#fm-done .fm-ghost { margin-bottom: 8px; }

@media (min-width: 700px) {
  #fm-main { padding-top: 36px; }
  .fm-screen > h1 { font-size: 34px; }
}

/* On a computer with a mouse the camera buttons would only open the file window again */
@media (hover: hover) and (pointer: fine) { #fm-cam-btn, #fm-addcam { display: none; } .fm-addrow { grid-template-columns: 1fr; } }
.fm-addrow.one { grid-template-columns: 1fr; }
.fm-lefthint { text-align: left; margin: 6px 2px 0; }
