:root {
  --bg: #f3f4ef;
  --panel: #fffdf8;
  --ink: #1b1f18;
  --muted: #4f5b4f;
  --accent: #12725e;
  --accent-soft: #d7efe5;
  --border: #c8d1c6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, #dde9dc 0, transparent 35%),
    linear-gradient(145deg, #edf0e7 0%, #f8f7f3 60%, #eef4ef 100%);
  min-height: 100vh;
}

.app {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1rem;
  padding: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 10px 24px rgba(22, 31, 18, 0.08);
}

h1 {
  margin: 0 0 0.4rem;
  letter-spacing: 0.02em;
}

.muted {
  color: var(--muted);
}

.small {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.field {
  display: grid;
  gap: 0.45rem;
  margin: 0.9rem 0;
}

.inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.9rem 0;
}

input[type="file"],
input[type="range"],
input[type="text"] {
  width: 100%;
}

input[type="text"] {
  border: 1px solid #b7c5b7;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  font-size: 0.98rem;
}

button {
  border: 1px solid #0f5f4e;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  font-weight: 600;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.status {
  margin: 0.9rem 0;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  border: 1px solid #bcd4c9;
  background: var(--accent-soft);
  color: #154f42;
}

#signaturePad {
  width: 100%;
  border: 1px dashed #97a897;
  border-radius: 10px;
  background: #fff;
  touch-action: none;
}

.pdf-container {
  min-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7f8f4;
  padding: 0.75rem;
}

.page-stage {
  position: relative;
  width: fit-content;
  margin: 0 auto;
}

#pdfCanvas {
  display: block;
  margin: 0 auto;
  border: 1px solid #d5ddd2;
  background: white;
}

.signature-overlay {
  position: absolute;
  pointer-events: none;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.signature-box {
  position: absolute;
  border: 2px solid rgba(18, 114, 94, 0.7);
  border-radius: 6px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  box-shadow: 0 3px 8px rgba(14, 47, 39, 0.2);
}

.mode-picker {
  margin: 0.3rem 0 0;
}

.mode-picker label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  color: #224135;
}

.annotation-text {
  position: absolute;
  color: #1b1f18;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: rgba(255, 255, 255, 0.8);
  border: 1px dashed rgba(27, 31, 24, 0.45);
  border-radius: 4px;
  padding: 1px 4px;
  white-space: nowrap;
}

@media (max-width: 920px) {
  .app {
    grid-template-columns: 1fr;
  }
}
