:root {
  --bg: #dcd8cf;
  --paper: #f7f4ec;
  --ink: #181816;
  --muted: #6d6a63;
  --line: #c8c1b4;
  --line-dark: #777269;
  --accent: #9f1d1d;
  --accent-soft: #f1dede;
  --shadow: 0 24px 70px rgba(25, 23, 18, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,.7), transparent 30%),
    linear-gradient(135deg, #dedbd4 0%, #cbc6bc 100%);
  color: var(--ink);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
  padding: 52px 20px;
}

.paper {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 0 64px 34px;
  background:
    linear-gradient(rgba(247, 244, 236, .97), rgba(247, 244, 236, .97)),
    repeating-linear-gradient(0deg, rgba(80,70,55,.03) 0, rgba(80,70,55,.03) 1px, transparent 1px, transparent 4px);
  border: 1px solid rgba(90, 84, 73, .28);
  box-shadow: var(--shadow);
}

.paper-topline {
  height: 8px;
  margin: 0 -64px;
  background: var(--ink);
}

.form-header {
  padding: 58px 0 36px;
  border-bottom: 2px solid var(--ink);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .19em;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", "Noto Serif KR", serif;
  font-size: clamp(36px, 6vw, 58px);
  line-height: 1.05;
  letter-spacing: -.045em;
}

.subtitle {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.grid-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-top: 30px;
  border-top: 1px solid var(--line-dark);
  border-left: 1px solid var(--line-dark);
}

.field {
  position: relative;
}

.grid-section .field {
  min-height: 94px;
  padding: 17px 18px 14px;
  border-right: 1px solid var(--line-dark);
  border-bottom: 1px solid var(--line-dark);
}

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

.field label,
.signature-block label {
  display: block;
  margin-bottom: 9px;
  color: #3d3a35;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .03em;
}

input,
textarea,
select {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.grid-section input,
.grid-section select {
  min-height: 34px;
  padding: 2px 0 7px;
  border-bottom: 1px solid #b3ada2;
  font-size: 16px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: #a19c92;
}

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 38px 0 28px;
}

.divider span {
  height: 1px;
  background: var(--line);
}

.divider em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  letter-spacing: .22em;
}

.essay-section {
  display: grid;
  gap: 20px;
}

.essay-field {
  padding: 0;
}

.essay-field label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 15px;
}

.essay-field label b {
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 13px;
}

textarea {
  min-height: 128px;
  resize: vertical;
  padding: 16px 18px;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,.23) 0,
      rgba(255,255,255,.23) 31px,
      #cfc8bc 32px,
      rgba(255,255,255,.23) 33px
    );
  border: 1px solid var(--line);
  line-height: 32px;
  font-size: 15px;
}

.consent-section {
  margin-top: 34px;
  padding-top: 30px;
  border-top: 2px solid var(--ink);
}

.warning-box {
  padding: 22px 24px;
  border: 2px solid var(--accent);
  background: var(--accent-soft);
}

.warning-kicker {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
}

.warning-text {
  margin: 0;
  color: #6e0e0e;
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: clamp(18px, 3vw, 24px);
  font-weight: 900;
  line-height: 1.55;
  letter-spacing: -.02em;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 28px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
}

.check-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.custom-check {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 1.5px solid var(--ink);
  display: grid;
  place-items: center;
  background: transparent;
}

.check-row input:checked + .custom-check::after {
  content: "✓";
  transform: translateY(-1px);
  font-size: 18px;
  font-weight: 900;
}

.signature-grid {
  display: grid;
  grid-template-columns: .72fr 1.28fr;
  gap: 26px;
  align-items: stretch;
}

.signature-name {
  padding: 18px;
  border: 1px solid var(--line-dark);
}

.signature-name input {
  min-height: 52px;
  border-bottom: 1px solid #aaa49a;
  font-size: 20px;
  font-family: Georgia, "Noto Serif KR", serif;
}

.signature-block {
  padding: 18px;
  border: 1px solid var(--line-dark);
}

.signature-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.signature-title-row label {
  margin: 0;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.signature-pad-wrap {
  position: relative;
  height: 150px;
  overflow: hidden;
  background: rgba(255,255,255,.38);
  border-bottom: 1px solid var(--ink);
  touch-action: none;
}

#signaturePad {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.signature-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #aaa49a;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}

.completion-date {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.completion-date span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
}

.completion-date strong {
  color: var(--ink);
  font-family: Georgia, "Noto Serif KR", serif;
  font-size: 16px;
  font-weight: 700;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 30px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid var(--ink);
  cursor: pointer;
  font-weight: 800;
  transition: .18s ease;
}

.primary-button {
  background: var(--ink);
  color: #fff;
}

.secondary-button {
  background: transparent;
  color: var(--ink);
}

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

.form-message {
  min-height: 24px;
  margin: 14px 0 0;
  text-align: right;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.form-message.success {
  color: #2b5e39;
}

.paper-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 52px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: #8b867c;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .14em;
}

@media (max-width: 720px) {
  html {
    background: var(--paper);
  }

  body {
    min-width: 0;
    background: var(--paper);
    -webkit-text-size-adjust: 100%;
  }

  .page-shell {
    min-height: 100svh;
    padding: 0;
  }

  .paper {
    width: 100%;
    min-height: 100svh;
    margin: 0;
    padding: 0 max(18px, env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
    border: 0;
    box-shadow: none;
    background: var(--paper);
  }

  .paper-topline {
    height: 6px;
    margin: 0 calc(-1 * max(18px, env(safe-area-inset-right))) 0 calc(-1 * max(18px, env(safe-area-inset-left)));
  }

  .form-header {
    padding: 30px 2px 22px;
  }

  .eyebrow {
    margin-bottom: 8px;
    font-size: 10px;
    letter-spacing: .16em;
  }

  h1 {
    font-size: clamp(32px, 10vw, 44px);
    line-height: 1.08;
  }

  .subtitle {
    margin-top: 11px;
    font-size: 13px;
    line-height: 1.55;
  }

  .grid-section {
    grid-template-columns: 1fr;
    margin-top: 22px;
    border-left: 0;
    border-top: 1.5px solid var(--ink);
  }

  .grid-section .field,
  .grid-section .field.full {
    grid-column: 1;
    min-height: auto;
    padding: 14px 2px 13px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .field label,
  .signature-block label {
    margin-bottom: 7px;
    font-size: 11px;
  }

  .grid-section input,
  .grid-section select {
    min-height: 42px;
    padding: 4px 0 8px;
    border-bottom: 1px solid #aaa49a;
    font-size: 16px;
  }

  .consent-section {
    margin-top: 28px;
    padding-top: 24px;
  }

  .warning-box {
    padding: 17px 16px;
  }

  .warning-kicker {
    font-size: 9px;
    line-height: 1.4;
  }

  .warning-text {
    font-size: 18px;
    line-height: 1.55;
    word-break: keep-all;
  }

  .check-row {
    align-items: flex-start;
    margin: 18px 0 22px;
    font-size: 13px;
    line-height: 1.5;
  }

  .custom-check {
    margin-top: 1px;
  }

  .signature-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .signature-name,
  .signature-block {
    padding: 15px;
  }

  .signature-name input {
    min-height: 45px;
    font-size: 18px;
  }

  .signature-pad-wrap {
    height: 180px;
  }

  .signature-hint {
    font-size: 11px;
  }

  .completion-date {
    justify-content: center;
    gap: 9px;
    margin-top: 24px;
    padding-top: 16px;
  }

  .completion-date span { font-size: 10px; }
  .completion-date strong { font-size: 15px; }

  .actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    flex-direction: column-reverse;
    gap: 8px;
    margin: 24px -18px 0;
    padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--paper) 78%, rgba(247,244,236,.88));
  }

  .primary-button,
  .secondary-button {
    width: 100%;
    min-height: 52px;
    font-size: 15px;
  }

  .form-message {
    margin-top: 10px;
    text-align: left;
    font-size: 12px;
  }

  .paper-footer {
    margin-top: 32px;
    padding-top: 13px;
    font-size: 8px;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  body {
    background: white;
  }

  .page-shell {
    padding: 0;
  }

  .paper {
    width: 100%;
    max-width: none;
    padding: 0 8mm 6mm;
    border: 0;
    box-shadow: none;
  }

  .paper-topline {
    margin: 0 -8mm;
  }

  .actions,
  .form-message,
  .text-button,
  .signature-hint {
    display: none !important;
  }

  textarea {
    resize: none;
  }

  .consent-section,
  .essay-field,
  .warning-box,
  .signature-grid {
    break-inside: avoid;
  }
}
