:root {
  --ink: #162033;
  --muted: #637083;
  --line: #d9dee7;
  --panel: #ffffff;
  --paper: #f5f7fb;
  --accent: #273c8f;
  --accent-weak: #e9edf9;
  --shadow: 0 18px 45px rgba(22, 32, 51, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 18px;
  min-height: 100vh;
  padding: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel {
  align-self: start;
  position: sticky;
  top: 18px;
  padding: 20px;
}

.workspace {
  display: grid;
  gap: 18px;
}

.preview-panel,
.output-panel,
.instructions-panel {
  padding: 20px;
}

.title-row,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

.signature-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
}

label > span,
legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
}

input {
  min-height: 42px;
  padding: 9px 11px;
}

input:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(39, 60, 143, 0.18);
  border-color: var(--accent);
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
}

.segmented,
.mail-grid {
  display: grid;
  gap: 8px;
}

.segmented {
  grid-template-columns: repeat(3, 1fr);
}

.mail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented label,
.mail-grid label {
  position: relative;
  display: block;
}

.segmented input,
.mail-grid input {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented span,
.mail-grid span {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
  pointer-events: none;
  cursor: pointer;
}

.segmented input:checked + span,
.mail-grid input:checked + span {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-weak);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

button {
  min-height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 13px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

.secondary-button,
.ghost-button {
  color: var(--accent);
  background: #fff;
}

.ghost-button {
  border-color: var(--line);
}

.status {
  min-height: 20px;
  margin: -4px 0 12px;
  color: #1f7a4d;
  font-size: 13px;
  font-weight: 700;
}

.signature-preview {
  min-height: 230px;
  overflow: auto;
  border: 1px dashed #c8cfdb;
  border-radius: 8px;
  padding: 22px;
  background: #fff;
}

textarea {
  min-height: 260px;
  resize: vertical;
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre;
}

.instructions-panel ol {
  margin: 0;
  padding-left: 24px;
}

.instructions-panel li {
  margin: 0 0 9px;
  color: #2d3748;
  line-height: 1.5;
}

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

  .form-panel {
    position: static;
  }
}

@media (max-width: 600px) {
  .app-shell {
    padding: 10px;
  }

  .panel {
    border-radius: 8px;
  }

  .title-row,
  .section-head {
    display: grid;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    width: 100%;
  }

  .segmented,
  .mail-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 25px;
  }
}
