:root {
  --ink: #1e1e1e;
  --paper: #fffdf7;
  --ground: #faf8f3;
  --red: #e94141;
  --blue: #1959d1;
  --green: #16844b;
  --orange: #d97706;
  --muted: #68645c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: "Montserrat", sans-serif;
  background-color: var(--ground);
  background-image:
    linear-gradient(rgba(218, 212, 195, .42) 1px, transparent 1px),
    linear-gradient(90deg, rgba(218, 212, 195, .42) 1px, transparent 1px);
  background-size: 20px 20px;
}

button, input, select, textarea { font: inherit; }
button, label, select { -webkit-tap-highlight-color: transparent; }

.cg-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.cg-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px 0 18px; }
.cg-logo { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; }
.cg-logo__number { border: 3px solid var(--ink); padding: 5px 8px; font-family: "Neucha", sans-serif; font-size: 24px; transform: rotate(-2deg); background: #fff; }
.cg-logo__name { letter-spacing: 0; }
.cg-header__title { font-family: "Neucha", sans-serif; font-size: clamp(20px, 2vw, 28px); border-bottom: 3px solid var(--ink); padding-bottom: 4px; text-align: center; }
.cg-header__note { color: var(--red); font-family: "Caveat", cursive; font-size: 22px; transform: rotate(2deg); }
.cg-back-row { display: flex; padding: 4px 0 10px; }
.cg-back-row .cg-btn { min-height: 42px; padding: 7px 14px; color: var(--blue); text-decoration: none; background: #eef4ff; }

.cg-intro { text-align: center; padding: 30px 12px 34px; }
.cg-intro h1 { margin: 0 auto 12px; max-width: 840px; font: 700 clamp(38px, 5vw, 64px)/1.02 "Neucha", sans-serif; }
.cg-intro h1 span { border-bottom: 5px solid var(--red); }
.cg-intro p { max-width: 670px; margin: 0 auto; color: var(--muted); line-height: 1.55; }

.cg-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 26px; }
.cg-progress__step { position: relative; min-height: 74px; padding: 12px; border: 2px solid var(--ink); background: rgba(255,255,255,.7); text-align: left; transition: transform .15s, background .15s; }
.cg-progress__step:nth-child(odd) { transform: rotate(-.35deg); }
.cg-progress__step:nth-child(even) { transform: rotate(.35deg); }
.cg-progress__step[aria-current="step"] { background: #fff0ec; box-shadow: 3px 3px 0 var(--ink); }
.cg-progress__step.is-done { background: #eaf8ef; }
.cg-progress__number { display: block; color: var(--red); font: 700 22px "Caveat", cursive; }
.cg-progress__label { font: 700 19px "Neucha", sans-serif; }

.cg-workspace { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr); gap: 34px; align-items: start; padding-bottom: 72px; }
.cg-paper {
  position: relative;
  border: 3px solid var(--ink);
  border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
  background: var(--paper);
  box-shadow: 5px 5px 0 var(--ink);
}
.cg-paper::after { content: ""; position: absolute; top: -3px; right: -3px; width: 44px; height: 44px; background: linear-gradient(45deg, transparent 48%, var(--ink) 49%, var(--ink) 53%, #f0ebdf 54%); }
.cg-form { padding: 30px; min-height: 610px; }
.cg-step { display: none; animation: cg-in .22s ease both; }
.cg-step.is-active { display: block; }
@keyframes cg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.cg-step__eyebrow { color: var(--blue); font: 700 22px "Caveat", cursive; }
.cg-step h2 { margin: 4px 0 8px; font: 700 34px/1.05 "Neucha", sans-serif; }
.cg-step__lead { margin: 0 0 26px; color: var(--muted); line-height: 1.5; }

.cg-field { margin-bottom: 20px; }
.cg-field label, .cg-field legend { display: block; margin-bottom: 8px; font-weight: 700; font-size: 14px; }
.cg-required { color: var(--red); }
.cg-input, .cg-select, .cg-textarea {
  width: 100%; border: 2px solid var(--ink); background: #fff; color: var(--ink);
  border-radius: 18px 7px 16px 8px/8px 17px 7px 18px; padding: 13px 14px; outline: none;
  transition: box-shadow .15s, border-color .15s;
}
.cg-textarea { min-height: 90px; resize: vertical; }
.cg-input:focus, .cg-select:focus, .cg-textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(25,89,209,.14); }
.cg-input.is-error, .cg-select.is-error, .cg-textarea.is-error { border-color: var(--red); box-shadow: 0 0 0 3px rgba(233,65,65,.13); }
.cg-help { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.cg-error { min-height: 16px; margin-top: 5px; color: var(--red); font-size: 12px; font-weight: 700; }

.cg-segments { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cg-segment input { position: absolute; opacity: 0; pointer-events: none; }
.cg-segment span { display: flex; min-height: 48px; align-items: center; justify-content: center; padding: 8px; border: 2px solid var(--ink); background: #fff; text-align: center; font: 700 17px "Neucha", sans-serif; cursor: pointer; }
.cg-segment input:checked + span { background: #dce9ff; box-shadow: 3px 3px 0 var(--ink); transform: translate(-1px,-1px); }

.cg-checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.cg-check { display: flex; align-items: flex-start; gap: 9px; padding: 10px; border: 2px solid #aaa398; background: #fff; cursor: pointer; }
.cg-check input { width: 20px; height: 20px; flex: 0 0 20px; accent-color: var(--blue); }
.cg-check:has(input:checked) { border-color: var(--blue); background: #eef4ff; }

.cg-toggle { display: flex; align-items: flex-start; gap: 12px; padding: 13px; border: 2px dashed #918a7d; background: #fff; cursor: pointer; }
.cg-toggle input { width: 22px; height: 22px; accent-color: var(--green); }
.cg-toggle strong { display: block; margin-bottom: 3px; }
.cg-toggle small { color: var(--muted); }

.cg-processor { display: none; margin: 12px 0 20px; padding: 14px; border-left: 4px solid var(--green); background: #eef8f1; }
.cg-processor.is-visible { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.cg-alert { margin: 14px 0; padding: 13px 14px; border: 2px solid var(--red); background: #fff0ee; color: #9e2222; font-size: 13px; line-height: 1.45; }
.cg-alert:empty { display: none; }

.cg-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; }
.cg-btn { min-height: 48px; border: 3px solid var(--ink); padding: 10px 18px; color: var(--ink); background: #fff; box-shadow: 4px 4px 0 var(--ink); font-weight: 800; cursor: pointer; }
.cg-btn:active { transform: translate(3px,3px); box-shadow: 1px 1px 0 var(--ink); }
.cg-btn--primary { margin-left: auto; background: var(--red); color: #fff; }
.cg-btn--blue { background: var(--blue); color: #fff; }
.cg-btn:disabled { cursor: wait; opacity: .6; }

.cg-preview { position: sticky; top: 18px; }
.cg-preview__paper { min-height: 610px; padding: 28px; }
.cg-preview__top { display: flex; justify-content: space-between; gap: 14px; border-bottom: 2px solid var(--ink); padding-bottom: 12px; }
.cg-preview__top h2 { margin: 0; font: 700 28px "Neucha", sans-serif; }
.cg-status { align-self: flex-start; padding: 5px 9px; border: 2px solid var(--ink); background: #fff4c9; font: 700 14px "Neucha", sans-serif; }
.cg-preview__empty { display: grid; min-height: 450px; place-items: center; text-align: center; color: var(--muted); }
.cg-preview__empty strong { display: block; color: var(--ink); font: 700 28px "Neucha", sans-serif; }
.cg-preview__result { display: none; }
.cg-preview__result.is-visible { display: block; }
.cg-preview__section { margin-top: 20px; }
.cg-preview__section h3 { display: inline-block; margin: 0 0 10px; border-bottom: 4px solid var(--blue); font: 700 21px "Neucha", sans-serif; }
.cg-preview__section:first-child h3 { border-color: var(--red); }
.cg-copybox { position: relative; padding: 14px; border: 2px solid var(--ink); background: #fff; font-size: 13px; line-height: 1.55; white-space: pre-wrap; max-height: 310px; overflow: auto; }
.cg-copy { margin-top: 8px; border: 0; background: none; color: var(--blue); font-weight: 800; cursor: pointer; }
.cg-warning-list { margin: 14px 0 0; padding: 12px 12px 12px 30px; border: 2px solid var(--orange); background: #fff7e8; color: #7b4a04; font-size: 12px; }
.cg-delivery { margin-top: 24px; padding-top: 20px; border-top: 3px solid var(--ink); }
.cg-delivery h3 { border-color: var(--green); }
.cg-delivery > p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.cg-delivery .cg-field { display: block; }
.cg-delivery__consent { display: grid; grid-template-columns: 24px 1fr; gap: 9px; align-items: start; margin: 14px 0; font-size: 12px; line-height: 1.45; cursor: pointer; }
.cg-delivery__consent input { width: 22px; height: 22px; margin: 0; accent-color: var(--red); }
.cg-delivery__consent input.is-error { outline: 3px solid var(--red); outline-offset: 2px; }
.cg-delivery__consent a { color: var(--blue); font-weight: 800; }
.cg-delivery .cg-btn { width: 100%; margin-top: 8px; }
.cg-after-download { margin-top: 20px; padding: 16px; border: 2px dashed var(--green); background: #eef8f1; }
.cg-after-download h3 { margin: 0 0 10px; font: 700 22px "Neucha", sans-serif; }
.cg-after-download ol { margin: 0; padding-left: 20px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.cg-after-download a { color: var(--blue); font-weight: 800; }
.cg-alert.is-success { border-color: var(--green); background: #eaf8ef; color: #145c2d; }

.cg-annotation { position: absolute; z-index: 2; color: var(--blue); font: 700 22px/1 "Caveat", cursive; pointer-events: none; }
.cg-annotation--form { left: -92px; top: 110px; width: 90px; transform: rotate(-5deg); text-align: right; }
.cg-annotation--preview { right: -94px; top: 150px; width: 90px; color: var(--green); transform: rotate(5deg); }

.cg-footer { border-top: 2px solid var(--ink); padding: 24px 0 36px; display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 13px; }
.cg-footer a { color: var(--ink); }

@media (max-width: 1050px) {
  .cg-workspace { grid-template-columns: 1fr; }
  .cg-preview { position: static; }
  .cg-annotation { display: none; }
}

@media (max-width: 720px) {
  .cg-shell { width: min(100% - 24px, 1180px); }
  .cg-header__note { display: none; }
  .cg-header__title { font-size: 18px; }
  .cg-progress { grid-template-columns: repeat(2, 1fr); }
  .cg-form, .cg-preview__paper { padding: 22px 16px; }
  .cg-segments, .cg-checks { grid-template-columns: 1fr; }
  .cg-processor.is-visible { grid-template-columns: 1fr; }
  .cg-footer { flex-direction: column; }
}

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