:root {
  --navy: #0c2856;
  --blue: #1e4588;
  --cyan: #34c2e3;
  --ink: #172033;
  --muted: #687386;
  --line: #dce3ec;
  --soft: #f3f6fa;
  --white: #ffffff;
  --success: #16845b;
  --shadow: 0 22px 58px rgba(17, 43, 80, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #eef3f8;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 6%, rgba(52, 194, 227, 0.13), transparent 25rem),
    linear-gradient(180deg, #f8fafc 0%, #edf2f7 100%);
  font-family: Arial, "Tahoma", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  height: 78px;
  padding: 0 clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255, 255, 255, 0.88);
  border-bottom: 1px solid rgba(30, 69, 136, 0.1);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  display: block;
  height: auto;
}

.brand-copy {
  display: grid;
  gap: 3px;
  padding-right: 18px;
  border-right: 1px solid var(--line);
}

.brand-copy strong {
  color: var(--navy);
  font-size: 15px;
}

.brand-copy small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.status-pill,
.live-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  padding: 9px 13px;
  background: #edf9f4;
  border: 1px solid #ccece0;
  border-radius: 999px;
}

.status-pill i,
.live-label i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(22, 132, 91, 0.11);
}

.app-shell {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 66px 0 80px;
}

.intro {
  max-width: 780px;
  margin-bottom: 40px;
}

.eyebrow {
  margin: 0 0 11px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.intro h1 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.intro > p:last-child {
  max-width: 670px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.9;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 0.82fr) minmax(620px, 1.55fr);
  gap: 24px;
  align-items: stretch;
}

.editor-card,
.preview-panel {
  min-width: 0;
  background: var(--white);
  border: 1px solid rgba(30, 69, 136, 0.1);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.editor-card {
  padding: 28px;
}

.preview-panel {
  padding: 28px;
}

.section-heading {
  min-height: 38px;
  margin-bottom: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading > div {
  display: flex;
  align-items: center;
  gap: 11px;
}

.section-heading h2 {
  margin: 0;
  color: var(--navy);
  font-size: 18px;
}

.step-number {
  display: grid;
  width: 33px;
  height: 33px;
  place-items: center;
  color: var(--blue);
  background: #edf3fb;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 800;
}

.text-button {
  padding: 6px 0;
  color: var(--blue);
  background: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 700;
}

.text-button:hover {
  color: var(--cyan);
}

#signatureForm {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 14px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field label {
  color: #2e3b50;
  font-size: 12px;
  font-weight: 700;
}

.field label span {
  color: #99a2b0;
  font-size: 10px;
  font-weight: 400;
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid #d9e0e9;
  border-radius: 9px;
  outline: 0;
  font-size: 13px;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.field input:hover {
  border-color: #b7c4d4;
}

.field input:focus {
  background: #fff;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(52, 194, 227, 0.14);
}

.field small {
  color: #8a94a4;
  font-size: 10px;
  line-height: 1.6;
}

.note-box {
  margin-top: 24px;
  padding: 13px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #536176;
  background: #f4f8fc;
  border-radius: 10px;
}

.note-box svg {
  flex: 0 0 auto;
  width: 17px;
  fill: var(--blue);
}

.note-box p {
  margin: 0;
  font-size: 10px;
  line-height: 1.7;
}

.preview-stage {
  min-height: 435px;
  overflow: hidden;
  background: #f3f6fa;
  border: 1px solid #e1e7ee;
  border-radius: 13px;
}

.email-chrome {
  height: 45px;
  padding: 0 16px;
  display: flex;
  direction: ltr;
  align-items: center;
  gap: 7px;
  background: #e9eef4;
  border-bottom: 1px solid #dde4ec;
}

.email-chrome span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c8d1dd;
}

.email-chrome p {
  margin: 0 0 0 7px;
  color: #758195;
  font-size: 10px;
}

.email-body {
  min-height: 390px;
  padding: 44px 36px;
  direction: ltr;
  background: #fff;
}

.sample-copy {
  margin: 0 0 24px;
  color: #7b8493;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
}

.signature-scroll {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: #bdc8d7 transparent;
}

.signature-preview {
  width: 500px;
  min-width: 500px;
}

.actions {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.button {
  min-height: 48px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.button:active {
  transform: translateY(1px);
}

.button svg {
  width: 17px;
  fill: currentColor;
}

.button-primary {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 9px 22px rgba(30, 69, 136, 0.2);
}

.button-primary:hover {
  background: var(--navy);
  box-shadow: 0 12px 26px rgba(30, 69, 136, 0.25);
}

.button-secondary {
  color: var(--blue);
  background: #f7f9fc;
  border-color: #d7e0eb;
}

.button-secondary:hover {
  background: #eef4fa;
  border-color: #bccbdd;
}

.copy-hint {
  margin: 12px 2px 0;
  color: #8b95a4;
  text-align: center;
  font-size: 10px;
}

.code-dialog {
  width: min(900px, calc(100% - 32px));
  padding: 0;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-radius: 17px;
  box-shadow: 0 32px 90px rgba(5, 22, 48, 0.28);
}

.code-dialog::backdrop {
  background: rgba(4, 17, 38, 0.6);
  backdrop-filter: blur(4px);
}

.dialog-header {
  padding: 25px 26px 15px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.dialog-header h2 {
  margin: 0;
  color: var(--navy);
  font-size: 20px;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #647187;
  background: #f1f4f8;
  border: 0;
  border-radius: 8px;
  font-size: 23px;
  line-height: 1;
}

.dialog-description {
  margin: 0;
  padding: 0 26px 14px;
  color: var(--muted);
  font-size: 12px;
}

#codeOutput {
  width: calc(100% - 52px);
  height: min(48vh, 420px);
  margin: 0 26px;
  padding: 18px;
  resize: vertical;
  color: #dce8ff;
  background: #101a2b;
  border: 0;
  border-radius: 10px;
  outline: 0;
  font: 11px/1.65 "SFMono-Regular", Consolas, monospace;
  white-space: pre;
}

.dialog-actions {
  padding: 18px 26px 25px;
  display: flex;
  gap: 10px;
}

.toast {
  position: fixed;
  inset: auto 50% 24px auto;
  z-index: 100;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  color: #fff;
  background: #12233e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  box-shadow: 0 14px 40px rgba(5, 20, 45, 0.28);
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(50%, 0);
}

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

  .preview-panel {
    order: 2;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: auto;
    min-height: 70px;
    padding: 12px 18px;
  }

  .brand {
    gap: 11px;
  }

  .brand img {
    width: 82px;
  }

  .brand-copy {
    padding-right: 11px;
  }

  .brand-copy small,
  .status-pill {
    display: none;
  }

  .app-shell {
    width: min(100% - 24px, 1440px);
    padding: 38px 0 50px;
  }

  .intro {
    margin-bottom: 26px;
  }

  .intro h1 {
    font-size: 31px;
  }

  .editor-card,
  .preview-panel {
    padding: 20px;
    border-radius: 14px;
  }

  .section-heading {
    align-items: flex-start;
  }

  #signatureForm,
  .actions {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .preview-stage {
    min-height: 390px;
  }

  .email-body {
    min-height: 345px;
    padding: 33px 20px;
  }

  .dialog-actions {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
