:root {
  --ink: #f8fafc;
  --muted: #94a3b8;
  --paper: #07070a;
  --panel: rgba(7, 7, 10, 0.75);
  --line: rgba(255, 255, 255, 0.08);
  --brand: #6366f1; /* Electric Indigo */
  --brand-dark: #4f46e5;
  --gold: #d946ef; /* Neon Violet */
  --sage: #10b981; /* Success Mint */
  --cyber: #06b6d4; /* Cyber Cyan */
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --font-body: 'Manrope', sans-serif;
  --font-display: 'Space Grotesk', sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 18% 8%, rgba(99, 102, 241, 0.15), transparent 38rem),
    radial-gradient(circle at 85% 18%, rgba(217, 70, 239, 0.12), transparent 32rem),
    radial-gradient(circle at 50% 60%, rgba(6, 182, 212, 0.08), transparent 40rem),
    linear-gradient(180deg, #09090b 0%, var(--paper) 52%, #020204 100%);
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, #000, transparent 78%);
  z-index: -1;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.doc-hero { padding: 24px clamp(18px, 5vw, 72px) 56px; }
.doc-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 56px;
}
.brand {
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.brand-svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.35));
}
.nav-actions { display: flex; align-items: center; gap: 14px; }
.nav-actions a { color: var(--muted); font-weight: 700; text-decoration: none; transition: color 0.2s ease; }
.nav-actions a:hover { color: var(--ink); }
.nav-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 16px;
  background: rgba(255, 255, 255, 0.04);
  transition: all 0.2s ease;
}
.nav-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--muted);
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 42px;
  align-items: end;
  max-width: 1180px;
  margin: 0 auto;
}
.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
}
h1, h2, h3 { margin: 0; line-height: 1.02; }
h1, h2 { font-family: var(--font-display); letter-spacing: -0.045em; }
h1 { max-width: 840px; font-size: clamp(3rem, 9vw, 7.2rem); background: linear-gradient(135deg, #f8fafc 0%, #cbd5e1 50%, #94a3b8 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
h2 { font-size: clamp(2rem, 5vw, 4.2rem); color: var(--ink); }
h3 { font-size: 1.05rem; color: var(--ink); }
.hero-copy { max-width: 720px; color: var(--muted); font-size: 1.1rem; line-height: 1.8; }
.privacy-card {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.02);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}
.privacy-card span { color: var(--cyber); font-weight: 800; text-transform: uppercase; font-size: 0.78rem; letter-spacing: 0.1em; }
.privacy-card strong { display: block; margin: 12px 0; font-size: 1.45rem; color: var(--ink); }
.privacy-card p, .converter-card p, .side-panel p { color: var(--muted); }

main { padding: 0 clamp(18px, 5vw, 72px) 72px; }
.panel {
  max-width: 1240px;
  margin: 0 auto 28px;
  padding: clamp(18px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: 34px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}
.primary-action, .secondary-action {
  border: 0;
  border-radius: 999px;
  padding: 11px 22px;
  font-weight: 800;
  transition: all 0.3s ease;
}
.primary-action { color: #ffffff; background: var(--brand); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25); }
.primary-action:hover:not(:disabled) { background: var(--brand-dark); transform: translateY(-1px); box-shadow: 0 4px 20px rgba(99, 102, 241, 0.45); }
.secondary-action { color: var(--ink); background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.secondary-action:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); border-color: var(--muted); }
button:disabled { cursor: not-allowed; opacity: 0.48; box-shadow: none; transform: none; }

.pdf-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) repeat(4, minmax(120px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 20px;
}
.pdf-controls label, .converter-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.86rem;
}
.file-drop {
  min-height: 74px;
  justify-content: center;
  padding: 12px 16px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  transition: all 0.2s ease;
}
.file-drop:hover {
  border-color: var(--brand);
  background: rgba(99, 102, 241, 0.03);
}
.file-drop input { display: none; }
.file-drop span { color: var(--ink); font-size: 1rem; }
.file-drop small { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.03);
  outline: none;
  transition: all 0.2s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
textarea { resize: vertical; line-height: 1.5; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
}
.canvas-shell {
  position: relative;
  min-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: #020204;
}
#pdf-canvas { display: block; max-width: 100%; margin: 20px auto; background: #07070a; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5); }
.annotation-layer { position: absolute; inset: 20px auto auto 50%; transform: translateX(-50%); pointer-events: none; }
.placed-annotation {
  position: absolute;
  border: 2px solid var(--brand);
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.2);
  color: var(--ink);
  font-weight: 800;
  padding: 4px 7px;
  white-space: nowrap;
}
.placed-annotation.signatureImage { background: rgba(255, 255, 255, 0.9); }
.empty-state {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 80%);
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}
.side-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.02);
}
#signature-pad {
  width: 100%;
  height: 138px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.2);
  touch-action: none;
}
.inline-actions { display: flex; gap: 10px; flex-wrap: wrap; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.annotation-list { padding-left: 22px; color: var(--muted); }
.annotation-list li { margin-bottom: 8px; }
.converter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.converter-card {
  min-height: 280px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.3s ease;
}
.converter-card:hover {
  border-color: rgba(99, 102, 241, 0.2);
}
.converter-card h3 { color: var(--ink); }
.converter-card p { font-weight: 600; line-height: 1.55; }
.status-log {
  margin-top: 18px;
  min-height: 28px;
  color: var(--sage);
  font-weight: 800;
}

@media (max-width: 980px) {
  .hero-grid, .workspace-grid { grid-template-columns: 1fr; }
  .pdf-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .converter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .doc-nav, .panel-heading { align-items: flex-start; flex-direction: column; }
  .nav-actions { width: 100%; justify-content: space-between; }
  .pdf-controls, .converter-grid { grid-template-columns: 1fr; }
  .canvas-shell { min-height: 360px; }
}
