/* ---------- 작성 화면 ---------- */
.is-form .wrap { max-width: 1160px; }
.is-form .page-head, .is-form .article, .is-form .related, .is-form .ad { max-width: 720px; margin-left: auto; margin-right: auto; }
.is-form .page-head { padding-left: 4px; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; align-items: start; }
.editor > section { min-width: 0; }
@media (min-width: 980px) {
  .editor { grid-template-columns: minmax(0, 420px) minmax(0, 1fr); }
  .editor-preview { position: sticky; top: 72px; }
}
.editor-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.editor-bar strong { font-size: 17px; }
.editor-preview { background: var(--surface); border-radius: var(--radius-l); padding: 20px; }
.small { font-size: 13px; margin: 10px 0 0; }
.field-section { font-size: 15px; font-weight: 800; color: var(--text); margin: 8px 0 -6px; padding-top: 12px; border-top: 1px solid var(--line); }
.calc-form > .field-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.input-wrap.plain input { padding-right: 18px; font-size: 17px; font-weight: 500; }
.input-wrap.plain.has-unit input { padding-right: 48px; }
.field textarea {
  width: 100%; padding: 14px 18px; font: inherit; font-size: 16px; line-height: 1.6; color: var(--text);
  background: var(--fill); border: 2px solid transparent; border-radius: var(--radius-m); resize: vertical;
}
.field textarea:focus { outline: none; border-color: var(--blue); background: var(--surface); }
.input-wrap input::placeholder, .field textarea::placeholder { color: var(--muted); font-weight: 400; }

.field small.counter { color: var(--sub); }
.field small.counter b { color: var(--blue); }
.field small.counter b.over { color: var(--red); }
.rows { display: grid; gap: 10px; }
.row-card { border: 2px solid var(--fill); border-radius: var(--radius-m); padding: 12px 14px 14px; }
.row-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.row-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-grid .field.wide { grid-column: 1 / -1; }
.row-grid .field > span { font-size: 13px; }
.row-grid .input-wrap input, .row-grid select, .row-grid input[type="date"] { height: 46px; font-size: 15.5px; }

.paper-frame { position: relative; overflow: hidden; background: var(--fill); border-radius: var(--radius-m); }
.paper { transform-origin: top left; }
.editor-actions { display: grid; grid-template-columns: 3fr 2fr; gap: 8px; margin-top: 14px; }
.editor-actions .btn { white-space: nowrap; padding: 0 10px; }
.btn-primary { background: var(--blue); color: var(--on-blue); }

/* ---------- A4 문서 (미리보기와 인쇄 공통) ---------- */
.paper, #print-root {
  font-family: "Pretendard Variable", Pretendard, "Malgun Gothic", sans-serif;
  color: #111; background: #fff; font-size: 14.5px; line-height: 1.65; letter-spacing: -0.01em;
  word-break: keep-all; overflow-wrap: anywhere;
}
.paper { width: 794px; min-height: 1123px; padding: 76px 72px; box-shadow: 0 2px 12px rgba(0, 0, 0, .08); }
.doc-title { text-align: center; font-size: 28px; font-weight: 800; letter-spacing: 0.5em; margin: 0 0 30px; padding-left: 0.5em; }
.doc-sub { text-align: center; margin: -28px 0 36px; color: #444; }
.doc p { margin: 0 0 14px; }
.doc h4 { font-size: 15px; margin: 18px 0 6px; }
.doc table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 14px; }
.doc th, .doc td { border: 1px solid #333; padding: 6px 10px; text-align: left; vertical-align: middle; overflow-wrap: normal; }
.doc th { background: #f3f4f6; font-weight: 700; white-space: nowrap; width: 1%; }
.doc th.c { width: auto; }
.doc td.num, .doc th.num { text-align: right; white-space: nowrap; }
.doc td.c, .doc th.c { text-align: center; }
.doc tr.sum td { font-weight: 800; background: #fafafa; }
.doc .center { text-align: center; }
.doc .right { text-align: right; }
.doc .date { text-align: center; margin: 32px 0 26px; font-size: 16px; }
.doc .sign { margin-left: auto; width: max-content; min-width: 300px; }
.doc .sign p { margin: 0 0 10px; display: flex; gap: 12px; }
.doc .sign b { display: inline-block; min-width: 4.5em; font-weight: 600; }
.doc .seal { color: #888; margin-left: 8px; }
.doc .to { font-size: 18px; font-weight: 700; margin-top: 40px; }
.doc .box { border: 1px solid #333; padding: 14px 18px; min-height: 120px; margin: 0 0 20px; }
.doc ol, .doc ul { margin: 0 0 14px; padding-left: 22px; }
.doc li { margin-bottom: 6px; }
.doc td.photo { width: 116px; height: 150px; text-align: center; color: #999; font-size: 13px; line-height: 1.4; }
.doc .clauses li { margin-bottom: 10px; }
.doc.compact .doc-title { margin-bottom: 20px; }
.doc.compact h4 { margin: 12px 0 3px; }
.doc.compact li { margin-bottom: 0 !important; line-height: 1.55; }
.doc .stamp-row { display: flex; justify-content: space-between; gap: 24px; }
.blank { display: inline-block; border-bottom: 1px solid #555; height: 1.2em; vertical-align: -0.2em; }
.blank-area { display: block; min-height: 7em; }
.doc .muted-note { color: #666; font-size: 13px; }

/* ---------- 인쇄 ---------- */
#print-root { display: none; }
@media print {
  @page { size: A4; margin: 18mm 17mm; }
  body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block !important; }
  .doc th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc table, .doc .box { break-inside: avoid; }
}
