:root {
  --bg: #eef5ef;
  --bg-strong: #dbece0;
  --panel: rgba(255, 255, 255, 0.55);
  --panel-strong: rgba(255, 255, 255, 0.76);
  --line: rgba(46, 114, 65, 0.14);
  --text: #193121;
  --muted: #63806b;
  --brand: #2e7241;
  --brand-soft: #4a9960;
  --shadow: 0 30px 80px rgba(38, 84, 49, 0.12);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(85, 167, 109, 0.26), transparent 26%),
    radial-gradient(circle at right 20%, rgba(46, 114, 65, 0.18), transparent 22%),
    linear-gradient(180deg, #f6fbf7 0%, #ecf5ee 54%, #e8f0e9 100%);
}

.page-shell {
  position: relative;
  padding: 40px 24px 32px;
  overflow: hidden;
}

.ambient {
  position: absolute;
  inset: auto;
  border-radius: 999px;
  filter: blur(48px);
  pointer-events: none;
}

.ambient-left {
  top: 12%;
  left: -120px;
  width: 320px;
  height: 320px;
  background: rgba(116, 209, 141, 0.18);
}

.ambient-right {
  right: -80px;
  top: 30%;
  width: 280px;
  height: 280px;
  background: rgba(46, 114, 65, 0.12);
}

.hero,
.layout {
  position: relative;
  z-index: 1;
  max-width: 1380px;
  margin: 0 auto;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand);
  font-weight: 800;
}

.hero h1,
.section-heading h2,
.settings-head h3,
.section-heading h3 {
  margin: 0;
  letter-spacing: -0.03em;
  font-family: "Libre Baskerville", serif;
}

.hero h1 {
  max-width: 980px;
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 0.96;
}

.hero-copy {
  max-width: 720px;
  margin: 14px 0 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 22px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.control-card,
.preview-card {
  padding: 24px;
}

.preview-card {
  background:
    linear-gradient(180deg, rgba(38, 74, 48, 0.88), rgba(31, 58, 39, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #ecf6ef;
}

.preview-card .section-heading h2,
.preview-card .settings-head h3,
.preview-card pre {
  color: #f4fbf5;
}

.preview-card .pill-live {
  background: rgba(205, 238, 214, 0.14);
  color: #d8f3dd;
}

.section-heading,
.settings-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.heading-with-help {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.section-heading.compact {
  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(46, 114, 65, 0.1);
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.pill-live {
  background: rgba(74, 153, 96, 0.14);
}

.form-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid {
  margin-top: 20px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label span {
  font-size: 13px;
  font-weight: 700;
  color: #34553d;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 13px 16px;
  border: 1px solid rgba(46, 114, 65, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

input:focus {
  border-color: rgba(46, 114, 65, 0.38);
  box-shadow: 0 0 0 4px rgba(46, 114, 65, 0.12);
}

input.is-readonly {
  color: rgba(25, 49, 33, 0.38);
  background: rgba(80, 101, 87, 0.08);
  border-color: rgba(46, 114, 65, 0.08);
}

input.is-readonly:focus {
  border-color: rgba(46, 114, 65, 0.08);
  box-shadow: none;
}

.full-width {
  grid-column: 1 / -1;
}

.upload-panel,
.html-box {
  margin-top: 24px;
}

.dropzone,
.settings-box,
.signature-stage,
.html-box {
  background: var(--panel-strong);
  border: 1px solid rgba(46, 114, 65, 0.12);
  border-radius: 24px;
}

.preview-card .signature-stage,
.preview-card .html-box {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.08);
}

.dropzone {
  position: relative;
  margin-bottom: 16px;
  padding: 22px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.dropzone:hover,
.dropzone.drag-over {
  transform: translateY(-1px);
  border-color: rgba(46, 114, 65, 0.32);
  background: rgba(255, 255, 255, 0.8);
}

.dropzone::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1.5px dashed rgba(46, 114, 65, 0.26);
  border-radius: 18px;
}

.dropzone-copy,
.selected-file {
  position: relative;
  z-index: 1;
}

.dropzone-button {
  position: relative;
  z-index: 1;
  margin-top: 14px;
}

.dropzone-copy strong {
  display: block;
  font-size: 1rem;
}

.dropzone-copy p,
.helper,
.selected-file,
.status {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.selected-file {
  margin-top: 14px;
  font-size: 14px;
}

.settings-box,
.html-box {
  padding: 18px;
}

.crop-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
  align-items: start;
}

.crop-stage {
  min-width: 0;
}

.crop-viewport {
  position: relative;
  width: min(100%, 360px);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(236, 245, 238, 0.95), rgba(217, 232, 220, 0.96));
  border: 1px solid rgba(46, 114, 65, 0.12);
  touch-action: none;
  user-select: none;
}

.crop-viewport img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform-origin: center;
}

#cropBackground {
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

#cropImage {
  object-fit: contain;
  object-position: center;
  cursor: grab;
}

.crop-viewport.is-dragging img {
  cursor: grabbing;
}

.crop-frame {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.9),
    inset 0 0 0 999px rgba(25, 49, 33, 0.08);
  pointer-events: none;
}

.crop-controls {
  display: grid;
  gap: 14px;
}

.crop-controls input[type="range"] {
  padding: 0;
  min-height: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
  accent-color: var(--brand);
}

.crop-controls input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(46, 114, 65, 0.2);
}

.crop-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 999px;
  background: var(--brand);
  border: 2px solid #f7fbf8;
  box-shadow: 0 6px 12px rgba(46, 114, 65, 0.2);
}

.crop-controls input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(46, 114, 65, 0.2);
}

.crop-controls input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--brand);
  border: 2px solid #f7fbf8;
  box-shadow: 0 6px 12px rgba(46, 114, 65, 0.2);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.preview-action-row {
  margin-top: 16px;
}

.info-popover {
  position: relative;
}

.info-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(46, 114, 65, 0.12);
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  border: 0;
}

.info-popover:hover .info-trigger,
.info-popover:focus-within .info-trigger {
  background: rgba(46, 114, 65, 0.18);
}

.popover-card {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 20;
  width: min(320px, 75vw);
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(46, 114, 65, 0.12);
  box-shadow: 0 18px 40px rgba(24, 48, 31, 0.16);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 140ms ease;
  pointer-events: none;
}

.popover-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #35533d;
}

.popover-card p + p {
  margin-top: 8px;
}

.popover-card a {
  color: var(--brand);
}

.info-popover:hover .popover-card,
.info-popover:focus-within .popover-card {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.preview-card .info-trigger {
  background: rgba(255, 255, 255, 0.14);
  color: #e9f8ec;
}

.preview-card .popover-card {
  background: rgba(247, 252, 248, 0.98);
}

button {
  font: inherit;
  border: 0;
  cursor: pointer;
}

.primary-button,
.ghost-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  font-weight: 700;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  background: linear-gradient(135deg, #2e7241 0%, #56a36a 100%);
  color: white;
  box-shadow: 0 16px 28px rgba(46, 114, 65, 0.24);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  border: 1px solid rgba(46, 114, 65, 0.12);
}

.preview-copy-button {
  width: 100%;
  background: rgba(255, 255, 255, 0.14);
  color: #f4fbf5;
  border-color: rgba(255, 255, 255, 0.12);
}

.ghost-button.small {
  min-height: 40px;
  padding: 0 14px;
  font-size: 14px;
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.status {
  margin-top: 16px;
  min-height: 28px;
}

.status.error {
  color: #9a3444;
}

.status.success {
  color: #256236;
}

.signature-stage {
  margin-top: 20px;
  padding: 24px;
}

.signature-wrap {
  overflow: auto;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(245, 249, 246, 0.9));
  padding: 20px;
}

#signaturePreview {
  min-width: 620px;
}

pre {
  margin: 16px 0 0;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #24402c;
}

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

  #signaturePreview {
    min-width: 0;
  }

  .crop-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-shell {
    padding: 24px 14px;
  }

  .hero {
    flex-direction: column;
  }

  .form-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .control-card,
  .preview-card {
    padding: 18px;
  }

  .signature-stage {
    padding: 16px;
  }
}
