/* ============================================================
   PDF Signer — refined dark UI (Linear / Raycast inspired)
   Two-pane app shell: fixed left sidebar (controls) + document
   canvas. Functional positioning rules are preserved; the date
   preview stays Arial (it mirrors the embedded PDF font).
   ============================================================ */

:root {
  --bg:          #08090a;
  --bg-grad:     rgba(59, 130, 246, 0.10);
  --surface:     #131417;
  --surface-2:   #1a1c20;
  --surface-3:   #212329;
  --border:      rgba(255, 255, 255, 0.07);
  --border-2:    rgba(255, 255, 255, 0.13);

  --text:        #f7f8f8;
  --text-2:      #c3c7cf;
  --text-3:      #8a8f98;

  --accent:      #3b82f6;
  --accent-hi:   #5b9dff;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --accent-glow: rgba(59, 130, 246, 0.45);

  --green:       #4cb782;
  --amber:       #e0a84e;
  --danger:      #eb5757;

  --radius:      11px;
  --radius-sm:   8px;
  --shadow:      0 10px 34px rgba(0, 0, 0, 0.45);
  --shadow-pop:  0 24px 64px rgba(0, 0, 0, 0.6);
  --sidebar-w:   320px;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;                 /* panes scroll, not the page */
  font-family: var(--font);
  font-feature-settings: 'cv11', 'ss01';
  letter-spacing: -0.011em;
  color: var(--text);
  background:
    radial-gradient(1100px 460px at 70% -260px, var(--bg-grad), transparent 70%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body::before {                      /* faint grain for atmosphere */
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- app shell ---------- */
.app {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

.sidebar {
  display: flex; flex-direction: column; gap: 13px;
  padding: 18px 16px 24px; overflow-y: auto;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.015), transparent 220px);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 2px 8px; }
.brand-text { display: flex; flex-direction: column; gap: 4px; }
.brand-text h1 { font-size: 14px; margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.logo {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center; font-size: 15px; color: #fff;
  background: linear-gradient(150deg, var(--accent-hi), var(--accent) 60%, #2563eb);
  box-shadow: 0 2px 10px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.25);
}
.tag {
  align-self: flex-start;
  font-size: 10px; font-weight: 600; color: var(--text-3);
  border: 1px solid var(--border-2); border-radius: 999px; padding: 2px 9px;
  letter-spacing: 0.06em; text-transform: uppercase;
}

.canvas { overflow-y: auto; padding: 30px 26px 72px; }
#viewer { display: flex; flex-direction: column; gap: 18px; align-items: center; }
#viewer:empty::before {
  content: 'Your document preview will appear here';
  display: grid; place-items: center; min-height: 62vh; width: 100%;
  color: var(--text-3); font-size: 13.5px; letter-spacing: 0;
}

/* ---------- landing / hero ---------- */
.landing {
  position: relative; z-index: 1;
  min-height: 100vh; overflow-y: auto;
  display: grid; place-items: center; padding: 28px 24px;
}
/* Raycast-style spotlight: a focused colored glow blooming from above,
   plus a faint conic sheen — sits behind the hero, above the grain. */
.landing::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(1100px 500px at 50% -240px, rgba(255,255,255,0.06), transparent 70%);
}
.hero { width: min(540px, 100%); text-align: center; animation: rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* pill badge above the title */
.hero-badge {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 22px;
  font-size: 11.5px; font-weight: 500; letter-spacing: -0.005em; color: var(--text-2);
  padding: 5px 13px 5px 10px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border: 1px solid var(--border-2);
  box-shadow: 0 1px 0 rgba(255,255,255,0.05) inset, 0 6px 18px rgba(0,0,0,0.3);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.hero-badge .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 3px rgba(76,183,130,0.18), 0 0 8px rgba(76,183,130,0.7);
}

.hero-brand { display: flex; align-items: center; justify-content: center; gap: 13px; margin-bottom: 18px; }
.hero-brand .logo { width: 46px; height: 46px; border-radius: 13px; font-size: 23px; }
.hero-brand h1 {
  font-size: 46px; font-weight: 700; letter-spacing: -0.035em; margin: 0;
  line-height: 1.15; padding-bottom: 2px;
  background: linear-gradient(180deg, #ffffff 30%, #b9bdd4 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { color: var(--text-3); font-size: 15.5px; line-height: 1.55; margin: 0 auto 30px; max-width: 432px; }
.hero-divider { display: none; }

/* glassy product card that holds the upload box / unlock form */
.hero-card {
  position: relative; max-width: 420px; margin: 0 auto; text-align: left;
  background: linear-gradient(180deg, rgba(26,28,32,0.9), rgba(15,16,19,0.86));
  border: 1px solid var(--border-2); border-radius: 18px; padding: 14px;
  box-shadow: var(--shadow-pop), 0 0 0 1px rgba(255,255,255,0.02) inset;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.hero-card::before {  /* top edge highlight, like Raycast's window cards */
  content: ''; position: absolute; left: 16px; right: 16px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.22), transparent);
}

.file-drop-lg { padding: 46px 32px; border-radius: 12px; }
.drop-inner { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.drop-inner strong { font-size: 15px; font-weight: 600; color: var(--text); }
.drop-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  color: var(--accent-hi); background: var(--accent-soft); margin-bottom: 8px;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.file-drop-lg:hover .drop-icon, .file-drop-lg.drag .drop-icon { color: #fff; background: var(--accent); transform: translateY(-2px); }

.unlock-card { padding: 8px 6px 6px; }
.unlock-card .field { padding-left: 4px; }

/* feature chips below the card */
.hero-feats { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 22px; }
.hero-feats span {
  font-size: 11.5px; color: var(--text-3); padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: rgba(255,255,255,0.02);
}

/* ---------- sidebar panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 15px 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  animation: rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.panel h2 {
  margin: 0 0 6px; font-size: 12.5px; font-weight: 600; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 8px;
}
.panel h2::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.panel p.hint { margin: 0 0 12px; color: var(--text-3); font-size: 12px; line-height: 1.5; }
.panel p.hint b { color: var(--text-2); font-weight: 600; }
.panel-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.step-hint { margin: 11px 0 0; font-size: 11.5px; color: var(--accent-hi); font-weight: 500; }
.fname { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); word-break: break-all; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
label.field { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 7px; font-weight: 500; }

/* ---------- inputs ---------- */
input[type="password"], input[type="text"] {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px; font-family: var(--font);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input::placeholder { color: var(--text-3); }
input:focus {
  outline: none; border-color: var(--accent); background: var(--surface-3);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- buttons ---------- */
button {
  font-family: var(--font); font-size: 13px; font-weight: 500; letter-spacing: -0.005em;
  border-radius: var(--radius-sm); padding: 9px 15px; cursor: pointer; color: #fff;
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset, 0 2px 10px rgba(0,0,0,0.3);
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s, border-color 0.15s, opacity 0.15s;
}
button:hover { background: linear-gradient(180deg, #79b0ff, var(--accent-hi)); transform: translateY(-1px); box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, 0 6px 18px var(--accent-glow); }
button:active { transform: translateY(0); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft), 0 2px 10px rgba(0,0,0,0.3); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

button.secondary { background: var(--surface-2); border-color: var(--border-2); color: var(--text-2); box-shadow: none; }
button.secondary:hover { background: var(--surface-3); color: var(--text); box-shadow: 0 4px 14px rgba(0,0,0,0.3); }
button.danger { background: transparent; border-color: rgba(235,87,87,0.5); color: #ff8585; box-shadow: none; }
button.danger:hover { background: rgba(235,87,87,0.12); border-color: var(--danger); color: #ffa0a0; box-shadow: none; }
button.block { width: 100%; }

/* ---------- file drop ---------- */
.file-drop {
  display: block;
  border: 1.5px dashed var(--border-2); border-radius: var(--radius);
  padding: 30px 18px; text-align: center; color: var(--text-3);
  font-size: 13px; line-height: 1.5; cursor: pointer; background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.file-drop:hover, .file-drop.drag {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft), var(--surface-2));
  color: var(--text-2);
}
.file-drop input { display: none; }

/* ---------- document pages ---------- */
.page-wrap {
  position: relative; line-height: 0;
  box-shadow: 0 6px 24px rgba(0,0,0,0.55), 0 0 0 1px var(--border);
  background: #fff; border-radius: 6px;
}
.page-wrap canvas { display: block; border-radius: 6px; }

/* ---------- uploader overlays (on the white page) ---------- */
.box-overlay { position: absolute; inset: 0; cursor: crosshair; }

.sig-box { position: absolute; border: 2px solid var(--accent); background: rgba(59,130,246,0.14); border-radius: 4px; pointer-events: none; }
.sig-box .lbl {
  position: absolute; top: -23px; left: 0;
  font-family: var(--font); font-size: 10.5px; font-weight: 600; letter-spacing: 0.01em;
  color: #fff; background: var(--accent); padding: 2px 8px; border-radius: 999px; line-height: 1.5; white-space: nowrap;
}
.sig-box .del, .date-box .del {
  position: absolute; top: -10px; right: -10px;
  width: 22px; height: 22px; padding: 0; border-radius: 50%;
  background: var(--danger); color: #fff; border: 2px solid var(--bg);
  font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center;
  pointer-events: auto; cursor: pointer; box-shadow: none;
}
.sig-box .del:hover, .date-box .del:hover { background: #ff7b7b; transform: none; }
.sig-box.pending { border-style: dashed; }
.sig-box.pending .skip {
  position: absolute; bottom: -13px; right: 0;
  font-size: 10.5px; font-weight: 600; line-height: 1; padding: 4px 9px; border-radius: 999px;
  background: var(--green); color: #06371f; border: 2px solid var(--bg);
  pointer-events: auto; cursor: pointer; white-space: nowrap; box-shadow: none;
}
.sig-box.pending .skip:hover { background: #6fe0a0; transform: none; }

.date-box { position: absolute; border: 2px solid var(--amber); background: rgba(224,168,78,0.12); border-radius: 4px; pointer-events: none; display: flex; align-items: center; }
.date-box .lbl {
  position: absolute; top: -23px; left: 0;
  font-family: var(--font); font-size: 10.5px; font-weight: 600;
  color: #1a1206; background: var(--amber); padding: 2px 8px; border-radius: 999px; line-height: 1.5; white-space: nowrap;
}
.date-box .date-preview {
  font-family: Arial, sans-serif; color: #000;          /* mirrors embedded PDF font */
  background: rgba(255,255,255,0.9); padding: 0 3px; white-space: nowrap; line-height: 1;
  max-width: 100%; overflow: hidden;                    /* clip text only, not the × / label */
}

/* move/resize on placed boxes */
.sig-box, .date-box { touch-action: none; }
.handle {
  position: absolute; width: 10px; height: 10px; box-sizing: border-box;
  background: #fff; border: 1.5px solid var(--accent); border-radius: 2px;
  z-index: 4; pointer-events: auto;
}
.date-box .handle { border-color: var(--amber); }
.h-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.h-n  { top: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.h-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.h-e  { top: 50%; right: -5px; margin-top: -5px; cursor: ew-resize; }
.h-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.h-s  { bottom: -5px; left: 50%; margin-left: -5px; cursor: ns-resize; }
.h-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.h-w  { top: 50%; left: -5px; margin-top: -5px; cursor: ew-resize; }
.sig-box .del, .date-box .del { z-index: 6; }

.draft-box { position: absolute; pointer-events: none; border-radius: 4px; }
.draft-box.sig { border: 2px dashed var(--accent); background: rgba(59,130,246,0.14); }
.draft-box.date { border: 2px dashed var(--amber); background: rgba(224,168,78,0.14); }

/* ---------- signer slot ---------- */
.sign-slot {
  position: absolute; border: 1.5px dashed var(--accent); background: rgba(59,130,246,0.12);
  border-radius: 5px; cursor: pointer; overflow: visible;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, box-shadow 0.15s;
}
.sign-slot:not(.signed):hover { background: rgba(59,130,246,0.24); box-shadow: 0 0 0 4px var(--accent-soft); }
.sign-slot:not(.signed):hover .slot-label { transform: translateY(-1px); box-shadow: 0 6px 16px var(--accent-glow); }
.sign-slot.signed { border-style: solid; background: rgba(255,255,255,0.92); cursor: default; overflow: hidden; }
.sign-slot .slot-label {
  font-family: var(--font); font-size: 13px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  padding: 8px 18px; border-radius: 999px; line-height: 1;
  pointer-events: none; white-space: nowrap;
  box-shadow: 0 2px 10px var(--accent-glow), 0 1px 0 rgba(255,255,255,0.18) inset;
  transition: transform 0.12s, box-shadow 0.15s;
}
.sign-slot.signed .slot-label { position: absolute; top: 3px; right: 3px; font-size: 10px; opacity: 1; background: var(--green); color: #06371f; box-shadow: none; padding: 2px 8px; }
.sign-slot .sig-img { width: 100%; height: 100%; object-fit: fill; display: block; pointer-events: none; }

.date-field {
  position: absolute; border: 1px dashed var(--amber); background: rgba(255,255,255,0.92);
  color: #000; font-family: Arial, sans-serif;          /* mirrors embedded PDF font */
  display: flex; align-items: center; padding: 0 3px; overflow: hidden; white-space: nowrap; line-height: 1;
  pointer-events: none;
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(4,5,7,0.66);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade 0.18s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: linear-gradient(180deg, var(--surface), #101114);
  border: 1px solid var(--border-2); border-radius: 16px; padding: 18px;
  box-shadow: var(--shadow-pop); max-width: 95vw;
  animation: pop 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; margin-bottom: 14px; }
.modal-head strong { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.icon-btn { margin-left: auto; background: transparent; border: none; color: var(--text-3); font-size: 22px; line-height: 1; padding: 0 6px; cursor: pointer; box-shadow: none; }
.icon-btn:hover { color: var(--text); background: transparent; transform: none; box-shadow: none; }
.modal-canvas-wrap { position: relative; background: #fff; border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08), inset 0 2px 8px rgba(0,0,0,0.06); }
#m-canvas { display: block; border-radius: 10px; cursor: crosshair; touch-action: none; }
.modal-baseline { position: absolute; left: 6%; right: 6%; bottom: 24%; border-bottom: 1px dashed #c9cdd6; pointer-events: none; }
.modal-foot { display: flex; gap: 10px; align-items: center; margin-top: 14px; }

/* confirm-finalize dialog (sits above the signing modal) */
#confirm { z-index: 70; }
.confirm-modal { width: min(380px, 92vw); text-align: center; padding: 24px 22px 18px; }
.confirm-icon {
  width: 46px; height: 46px; border-radius: 50%; margin: 0 auto 14px;
  display: grid; place-items: center; font-size: 22px;
  color: var(--amber); background: rgba(224,168,78,0.14);
}
.confirm-title { display: block; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.confirm-text { color: var(--text-3); font-size: 13px; line-height: 1.55; margin: 9px 0 20px; }
.confirm-text b { color: var(--text-2); font-weight: 600; }
.confirm-foot { display: flex; gap: 10px; }
.confirm-foot button { flex: 1; }

/* ---------- banners ---------- */
.banner {
  position: relative; border-radius: var(--radius-sm); padding: 11px 12px 11px 15px; font-size: 12.5px;
  color: var(--text-2); border: 1px solid var(--border); background: var(--surface-2); overflow: hidden; line-height: 1.45;
}
.banner::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--text-3); }
.banner.error { border-color: rgba(235,87,87,0.3); color: #ffb3b3; }
.banner.error::before { background: var(--danger); }
.banner.ok { border-color: rgba(76,183,130,0.3); color: #9be8c1; }
.banner.ok::before { background: var(--green); }

/* floating message toast (works over both the landing and the workspace) */
#msg {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 60; width: min(440px, 92vw); pointer-events: none;
}
#msg:empty { display: none; }
#msg .banner { margin: 0 0 8px; background: var(--surface); box-shadow: var(--shadow); pointer-events: auto; }

/* ---------- share link ---------- */
.link-out { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.link-out input { flex: 1; font-family: var(--mono); font-size: 11px; color: var(--text-2); letter-spacing: 0; }

/* ---------- misc ---------- */
.muted { color: var(--text-3); font-size: 12px; }
.hidden { display: none !important; }
.spacer { flex: 1; }
a { color: var(--accent-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }

/* ---------- responsive: stack on narrow screens ---------- */
@media (max-width: 760px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .canvas { overflow: visible; }
}
