:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #68736f;
  --paper: #fffefa;
  --cream: #f3efe6;
  --panel: #faf8f3;
  --line: #d9d5ca;
  --green: #174c3b;
  --green-2: #0e6a4d;
  --gold: #d9ae55;
  --shadow: 0 24px 70px rgba(43, 46, 41, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(217, 174, 85, .13), transparent 25rem),
    var(--cream);
}

button, input, textarea { font: inherit; }

button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px clamp(20px, 4vw, 56px);
  border-bottom: 1px solid rgba(29, 47, 41, .12);
  background: rgba(250, 248, 243, .9);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  box-shadow: inset 0 0 0 3px #fff, 0 0 0 1px var(--green);
  font-family: Georgia, serif;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -.03em;
}

.brand strong, .brand small { display: block; }
.brand strong { font-family: Georgia, serif; font-size: 17px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

.top-actions { display: flex; align-items: center; gap: 10px; }

.save-status { display: flex; align-items: center; gap: 7px; margin-right: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.save-status span { width: 7px; height: 7px; border-radius: 50%; background: #61a879; }
.save-status.saving span { background: var(--gold); animation: pulse 1s infinite; }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.button-primary { color: white; background: var(--green); box-shadow: 0 8px 20px rgba(23, 76, 59, .2); }
.button-primary:hover { background: var(--green-2); }
.button[aria-busy="true"] { opacity: .78; cursor: wait; }
.button-secondary { color: var(--ink); border-color: var(--line); background: #fff; }

.workspace {
  width: min(1600px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(520px, .95fr);
  min-height: calc(100vh - 76px);
}

.editor { padding: clamp(38px, 5vw, 72px) clamp(24px, 5vw, 72px) 100px; }
.intro { max-width: 690px; margin-bottom: 28px; }
.eyebrow { margin: 0 0 12px; color: var(--green-2); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(38px, 4vw, 58px); font-weight: 500; letter-spacing: -.04em; line-height: 1.02; }
.intro > p:last-child { max-width: 620px; margin: 16px 0 0; color: var(--muted); line-height: 1.65; }

.form-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 254, 250, .75);
  box-shadow: 0 10px 34px rgba(44, 49, 44, .045);
  overflow: hidden;
}

.form-card summary {
  min-height: 82px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  list-style: none;
  cursor: pointer;
}
.form-card summary::-webkit-details-marker { display: none; }
.form-card summary strong, .form-card summary small { display: block; }
.form-card summary strong { font-family: Georgia, serif; font-size: 18px; font-weight: 600; }
.form-card summary small { margin-top: 4px; color: var(--muted); font-size: 12px; }
.step { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: #e8eee9; font-size: 11px; font-weight: 800; }
.chevron { color: var(--muted); font-size: 20px; transition: transform .2s ease; }
details[open] .chevron { transform: rotate(180deg); }
.card-content { padding: 4px 20px 22px; border-top: 1px solid rgba(217, 213, 202, .75); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 20px; }
label { display: grid; gap: 7px; color: #52605b; font-size: 11px; font-weight: 750; letter-spacing: .02em; }
label.wide { grid-column: 1 / -1; }
.label-note { margin-left: 4px; color: #8b928f; font-size: 10px; font-weight: 500; }
input, textarea {
  width: 100%;
  border: 1px solid #d7d4ca;
  border-radius: 9px;
  outline: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, .82);
  transition: border .15s ease, box-shadow .15s ease, background .15s ease;
}
input { height: 43px; padding: 0 12px; }
textarea { padding: 11px 12px; resize: vertical; line-height: 1.4; }
input:focus, textarea:focus { border-color: #4b8b73; background: #fff; box-shadow: 0 0 0 3px rgba(75, 139, 115, .12); }
input::placeholder, textarea::placeholder { color: #a3aaa6; font-weight: 450; }

.items-head, .item-row { display: grid; grid-template-columns: 38px 66px minmax(140px, 1fr) 112px 92px; align-items: center; gap: 8px; }
.items-note { margin: 16px 0 2px; padding: 10px 12px; border-radius: 9px; color: #5d675f; background: #edf2ed; font-size: 11px; line-height: 1.45; }
.items-note strong { color: var(--green); }
.items-head { padding: 15px 0 7px; color: #7b8581; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.items-head span:first-child { grid-column: 2; }
.item-row { padding: 6px 0; border-bottom: 1px solid #ebe8df; }
.row-number { color: #a0a6a3; font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.item-row label { display: block; }
.item-row input { height: 38px; }
.money-input { position: relative; display: block; }
.money-input > span { position: absolute; z-index: 1; top: 9px; left: 10px; color: #7a827f; font-size: 13px; font-weight: 600; }
.money-input input { padding-right: 31px; padding-left: 24px; }
.sign-toggle { position: absolute; top: 7px; right: 6px; width: 25px; height: 25px; padding: 0; border: 0; border-radius: 6px; color: var(--green); background: #e8eee9; font-size: 13px; font-weight: 900; line-height: 1; }
.sign-toggle:hover { color: white; background: var(--green); }
.line-total { color: var(--ink); font-size: 13px; font-weight: 750; text-align: right; }
.line-total.negative { color: #9c3b2e; }
.mobile-label { display: none; }
.total-card { display: flex; align-items: baseline; justify-content: space-between; margin-top: 15px; padding: 17px 18px; border-radius: 11px; color: white; background: var(--green); }
.total-card span { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.total-card output { font-family: Georgia, serif; font-size: 25px; }

.canvass { margin-top: 18px; padding: 18px; border: 1px solid #d8d4c9; border-radius: 13px; background: #fff; }
.canvass-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.canvass-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; color: #fff; background: var(--green); font-family: Georgia, serif; font-size: 18px; font-weight: 700; }
.canvass-heading p { margin: 0 0 2px; color: var(--green-2); font-size: 9px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.canvass-heading h3 { margin: 0; font-family: Georgia, serif; font-size: 21px; letter-spacing: .03em; }
.canvass-toggle { position: relative; display: flex; grid-auto-flow: column; align-items: center; gap: 8px; margin-left: auto; cursor: pointer; }
.canvass-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.canvass-toggle > span { position: relative; width: 42px; height: 23px; border-radius: 999px; background: #c8ccc8; transition: .18s ease; }
.canvass-toggle > span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: .18s ease; }
.canvass-toggle input:checked + span { background: var(--green); }
.canvass-toggle input:checked + span::after { transform: translateX(19px); }
.canvass-toggle input:focus-visible + span { outline: 3px solid rgba(75, 139, 115, .25); outline-offset: 2px; }
.canvass-toggle b { color: #46534e; font-size: 11px; white-space: nowrap; }
.canvass-help { margin: 0 0 13px; color: #6d7773; font-size: 11px; line-height: 1.45; }
.canvass-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.canvass-grid.disabled { opacity: .48; }
.canvass-group { min-width: 0; margin: 0; padding: 13px; border: 1px solid #dedbd2; border-radius: 10px; background: #faf9f5; }
.canvass-group:disabled { cursor: not-allowed; }
.canvass-group-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.group-toggle { display: flex; grid-auto-flow: column; align-items: center; justify-content: start; gap: 7px; color: var(--green); cursor: pointer; }
.group-toggle input { width: 16px; height: 16px; accent-color: var(--green); }
.group-toggle span { font-size: 11px; font-weight: 800; }
.canvass-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.canvass-meta input, .canvass-options input { height: 36px; padding: 0 9px; font-size: 12px; }
.canvass-options { display: grid; grid-template-columns: minmax(0, 1fr) 92px; gap: 7px; margin-top: 10px; }
.canvass-options > span { color: #89918e; font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.canvass-options > span:nth-child(2) { text-align: right; }
.canvass-price { position: relative; }
.canvass-price > span { position: absolute; z-index: 1; top: 10px; left: 9px; color: #79817e; font-size: 12px; }
.canvass-price input { padding-left: 21px; text-align: right; }

.preview-pane {
  position: sticky;
  top: 76px;
  align-self: start;
  min-height: calc(100vh - 76px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px clamp(24px, 4vw, 56px) 46px;
  border-left: 1px solid rgba(34, 54, 47, .1);
  background: #e8e4dc;
}

.preview-header { width: min(100%, 680px); display: flex; justify-content: space-between; margin-bottom: 12px; color: #69716e; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.preview-header small { font-size: inherit; font-weight: 550; }
.paper {
  position: relative;
  container-type: inline-size;
  width: min(100%, 680px);
  aspect-ratio: 8.5 / 11;
  background: var(--paper);
  box-shadow: var(--shadow), 0 0 0 1px rgba(37, 43, 40, .08);
  overflow: hidden;
}
.paper > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; }
.form-overlay { position: absolute; inset: 0; font-family: "Courier New", ui-monospace, monospace; color: #101817; }
.ink { position: absolute; height: 1.7%; padding: 0 .22%; overflow: hidden; font-weight: 700; line-height: 1.35; white-space: nowrap; text-align: center; text-overflow: ellipsis; }
.ink.signature { font-family: "Courier New", ui-monospace, monospace; font-style: normal; font-weight: 700; }
.ink.purpose-ink { padding: 0; overflow: visible; text-overflow: clip; }
.ink.amount-words { padding: 0 .15%; text-align: left; text-overflow: clip; }
.table-ink { height: 1.4%; font-size: 1.48cqw; line-height: 1.05; text-align: left; }
.table-ink.centered { text-align: center; }
.table-ink.money-dollars { padding-right: .35%; text-align: right; }
.table-ink.money-cents { padding: 0; text-align: center; }
.print-tip { max-width: 580px; margin: 18px 0 0; color: #6e7672; font-size: 12px; text-align: center; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 50; padding: 12px 18px; border-radius: 999px; color: white; background: #1c2c26; box-shadow: 0 10px 30px rgba(0,0,0,.18); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.canvass-form-overlay { position: absolute; left: 21.05%; z-index: 4; width: 44.45%; height: 8.4%; padding: .3%; border: 0; color: #17201d; background: transparent; font-family: "Courier New", ui-monospace, monospace; }
.canvass-form-title { height: 18%; display: grid; place-items: center; border: 0; font-size: 1.55cqw; font-weight: 900; letter-spacing: .12em; }
.canvass-form-grid { height: 82%; display: grid; grid-template-columns: 1fr 1fr; }
.canvass-form-grid.single { grid-template-columns: 1fr; }
.canvass-mini-table:first-child { border: 0; }
.canvass-mini-table { display: grid; grid-template-rows: repeat(4, 1fr); min-width: 0; }
.canvass-mini-table > strong, .canvass-mini-table > span { display: flex; align-items: center; justify-content: space-between; padding: 0 3%; border: 0; font-size: 1.3cqw; line-height: 1; }
.canvass-mini-table > strong { font-size: 1.32cqw; letter-spacing: .04em; }
.canvass-mini-table small { font-size: 1cqw; font-weight: 600; }
.canvass-mini-table b { font-weight: 700; }
.canvass-mini-table em { font-style: normal; font-weight: 900; }

@keyframes pulse { 50% { opacity: .45; } }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .editor { max-width: 820px; width: 100%; margin: auto; }
  .preview-pane { position: relative; top: auto; border-top: 1px solid var(--line); border-left: 0; }
  .paper, .preview-header { width: min(100%, 720px); }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; padding: 12px 16px; }
  .brand small, .save-status { display: none; }
  .brand strong { max-width: 105px; font-size: 15px; line-height: 1.05; }
  .button { min-height: 40px; padding: 0 12px; }
  .button-secondary { display: none; }
  .button-primary { font-size: 12px; }
  .workspace { min-height: auto; }
  .editor { padding: 35px 16px 60px; }
  h1 { font-size: 40px; }
  .field-grid { grid-template-columns: 1fr; }
  label.wide { grid-column: auto; }
  .form-card summary { padding: 16px; }
  .card-content { padding: 4px 16px 20px; }
  .items-head { display: none; }
  .item-row { grid-template-columns: 28px 62px 1fr 88px; gap: 7px; padding: 10px 0; }
  .item-row label:nth-of-type(1) { grid-column: 2; }
  .item-row label:nth-of-type(2) { grid-column: 3 / 5; }
  .item-row label:nth-of-type(3) { grid-column: 3; }
  .row-number { grid-row: 1 / 3; align-self: start; padding-top: 27px; }
  .line-total { grid-column: 4; }
  .mobile-label { display: block; margin-bottom: 4px; color: #8b928f; font-size: 9px; text-transform: uppercase; }
  .canvass { padding: 14px; }
  .canvass-grid { grid-template-columns: 1fr; }
  .preview-pane { min-height: 0; padding: 26px 12px 34px; }
  .preview-header, .print-tip { padding: 0 8px; }
}

@page { size: letter portrait; margin: 0; }

@media print {
  html, body { width: 8.5in; height: 11in; margin: 0 !important; overflow: hidden !important; background: white !important; }
  .topbar, .editor, .preview-header, .print-tip, .toast { display: none !important; }
  .workspace { display: block !important; width: 8.5in !important; min-height: 0 !important; margin: 0 !important; }
  .preview-pane {
    position: static !important;
    display: block !important;
    width: 8.5in !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: white !important;
  }
  #printArea {
    position: relative !important;
    width: 8.5in !important;
    height: 11in !important;
    max-width: none !important;
    margin: 0 !important;
    box-shadow: none !important;
  }
}
