:root {
  color-scheme: light;
  --bg: #f4f2ec;
  --card: #ffffff;
  --ink: #1c2230;
  --muted: #5a6273;
  --line: #d9d5ca;
  --accent: #1d4f7a;
  --accent-dark: #153a5a;
  --accent-soft: #e7eef5;
  --accent-line: #a9bfd4;
  --error: #b3261e;
  --error-soft: #fbeceb;
  --ok-soft: #e8f3ec;
  --ok-line: #9cc7ab;
  --warn-soft: #fdf3e1;
  --warn-line: #e2bf7d;
  --focus: #f2a900;
  --field-line: #767d8a;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-dark);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--ink);
}

h1,
h2,
h3 {
  line-height: 1.3;
  margin: 0 0 0.6rem;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.15rem;
}

h2:focus {
  outline: none;
}

p {
  margin: 0 0 0.6rem;
}

.page {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.masthead {
  padding: 0.5rem 0.25rem 1rem;
}

.org {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.title-ko {
  margin: -0.3rem 0 0;
  font-size: 1.1rem;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  margin: 0 0 1rem;
}

.card > :last-child {
  margin-bottom: 0;
}

.ko {
  color: var(--muted);
  font-weight: inherit;
}

.ko-block {
  display: block;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.footer {
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
}

.summary {
  border: 2px solid var(--ink);
}

.summary-list {
  margin: 0 0 0.75rem;
}

.summary-list dt {
  font-weight: 600;
  margin-top: 0.6rem;
}

.summary-list dt:first-child {
  margin-top: 0;
}

.summary-list dd {
  margin: 0.1rem 0 0;
}

.template-link {
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.template-link a {
  display: inline-block;
  padding: 0.35rem 0;
  font-weight: 600;
}

.field {
  margin: 0 0 1.15rem;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.field label .ko {
  font-weight: 500;
}

.optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.9rem;
}

.help {
  font-size: 0.92rem;
  color: var(--muted);
  margin: -0.1rem 0 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
select,
.field textarea {
  display: block;
  width: 100%;
  min-height: 3rem;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 1.0625rem;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--field-line);
  border-radius: 8px;
  appearance: none;
  -webkit-appearance: none;
}

select {
  padding-right: 2.25rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 1.15rem) 50%, calc(100% - 0.8rem) 50%;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
}

input:focus,
select:focus,
.field textarea:focus {
  border-color: var(--accent);
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  box-shadow: 0 0 0 1px var(--ink);
}

.field textarea {
  min-height: 0;
  line-height: 1.45;
  resize: vertical;
}

input[type="date"] {
  min-width: 10rem;
}

.field-short input,
.field-short select {
  max-width: 12rem;
}

.has-error input:not([type="radio"]):not([type="checkbox"]),
.has-error select,
.has-error textarea,
.has-error .signature-box {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.field-error {
  color: var(--error);
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0 0 0.35rem;
}

.field-error .ko-block {
  color: var(--error);
  font-weight: 500;
}

.error-summary {
  border: 2px solid var(--error);
  background: var(--error-soft);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 0 1rem;
}

.error-summary:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.error-summary h2 {
  color: var(--error);
}

.error-summary ul {
  margin: 0;
  padding-left: 1.2rem;
}

.error-summary li {
  margin: 0.35rem 0;
}

.error-summary a {
  color: var(--error);
  font-weight: 600;
}

.error-summary a .ko-block {
  color: var(--error);
  font-weight: 500;
}

.waiver-list {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.waiver-list li {
  margin: 0 0 1rem;
}

.waiver-list li:last-child {
  margin-bottom: 0;
}

.waiver-list p {
  margin: 0 0 0.35rem;
}

.waiver-list p[lang="ko"] {
  color: var(--muted);
}

.signature-box {
  position: relative;
  border: 1.5px solid var(--field-line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.signature-box canvas {
  display: block;
  width: 100%;
  height: 190px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: crosshair;
}

.signature-line {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 42px;
  border-bottom: 1.5px dashed #8a909c;
  pointer-events: none;
}

.signature-hint {
  position: absolute;
  left: 1rem;
  bottom: 14px;
  font-size: 0.9rem;
  color: var(--muted);
  pointer-events: none;
}

.signature-actions {
  display: flex;
  justify-content: flex-end;
  margin: 0.5rem 0;
}

.checkbox-field {
  margin-top: 1.25rem;
}

.checkbox {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.75rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 400;
}

.field .checkbox {
  display: flex;
  font-weight: 400;
  margin: 0;
}

.checkbox input {
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  margin: 0.1rem 0 0;
  accent-color: var(--accent);
}

.has-error .checkbox {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.hp {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form-status {
  margin: 1.25rem 0 0;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  border: 1.5px solid var(--error);
  background: var(--error-soft);
  color: var(--error);
  font-weight: 600;
}

.form-status .ko-block {
  color: var(--error);
  font-weight: 500;
}

.form-status.info {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.form-status.info .ko-block {
  color: var(--accent-dark);
}

.button {
  display: inline-block;
  min-height: 3rem;
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  border-radius: 8px;
  border: 1.5px solid var(--accent);
  cursor: pointer;
}

.button .ko,
.button .ko-block {
  color: inherit;
}

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

.button.primary:hover {
  background: var(--accent-dark);
  color: #fff;
}

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

.button.secondary:hover {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.button:disabled {
  cursor: default;
  opacity: 0.7;
}

.button.small {
  min-height: 2.5rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.95rem;
}

.submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  margin-top: 1.25rem;
  font-size: 1.1rem;
  min-height: 3.5rem;
}

.email {
  display: inline-block;
  max-width: 100%;
  font-weight: 600;
}

.spinner {
  display: none;
  width: 1.2rem;
  height: 1.2rem;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.is-busy .spinner {
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

.success {
  border: 2px solid var(--ok-line);
}

.notice {
  margin: 0.75rem 0;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  background: var(--ok-soft);
  border: 1px solid var(--ok-line);
}

.notice.warning {
  background: var(--warn-soft);
  border-color: var(--warn-line);
}

.notice.info {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.notice p:last-child {
  margin-bottom: 0;
}

.download-row {
  margin: 1rem 0 0;
}

.download-row .button {
  display: block;
  width: 100%;
  margin: 0 0 0.5rem;
}

.download-row .button:last-child {
  margin-bottom: 0;
}

.radio-set {
  margin: 0;
  padding: 0;
  border: 0;
}

.radio-set legend {
  display: block;
  padding: 0;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.radio-list {
  display: grid;
  gap: 0.5rem;
}

.radio {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
}

.field .radio {
  display: flex;
  font-weight: 500;
  margin: 0;
}

.radio input {
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  accent-color: var(--accent);
}

.has-error .radio {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.amount-line {
  font-weight: 600;
}

.pay {
  border: 2px solid var(--accent);
}

.pay-total {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  background: var(--accent-soft);
}

.pay-total .amount {
  display: block;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent-dark);
}

/* The payment step: the family's forms, the total and Pay. */
.group-list {
  list-style: none;
  margin: 0.75rem 0 1rem;
  padding: 0;
}

.group-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--line);
}

.group-list li:last-child {
  border-bottom: 1px solid var(--line);
}

.group-name {
  flex: 1 1 10rem;
  min-width: 0;
  font-weight: 600;
}

.group-fee {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.pay-total .pay-line {
  margin: 0;
}

.fee-note {
  font-weight: 600;
}

.fee-note .ko-block {
  font-weight: 500;
}

.pay-where {
  margin: 0.75rem 0 0;
  font-size: 0.92rem;
}

.pay-where .ko-block {
  margin-top: 0.2rem;
}

.group-note .button {
  margin-top: 0.25rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0;
}

@media (min-width: 40rem) {
  .page {
    padding: 2rem 1.5rem 3rem;
  }

  h1 {
    font-size: 1.8rem;
  }

  .card {
    padding: 1.4rem 1.5rem;
  }

  .submit {
    display: inline-flex;
  }

  .submit,
  .download-row .button {
    width: auto;
    min-width: 16rem;
  }

  .download-row .button {
    display: inline-block;
    margin: 0 0.5rem 0.5rem 0;
  }

  .button-row .button {
    min-width: 12rem;
  }
}

.admin .page {
  max-width: 78rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
}

.toolbar .who {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.event-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
}

.event-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.event-meta {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0;
}

.event-list .selected {
  font-weight: 700;
}

.badge {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.badge.closed {
  background: #eceae4;
  color: var(--muted);
}

.badge.emailed {
  background: var(--ok-soft);
  color: #1f5d36;
}

.badge.email_failed {
  background: var(--error-soft);
  color: var(--error);
}

.badge.stored,
.badge.email_skipped {
  background: var(--warn-soft);
  color: #7a5200;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -0.25rem;
}

table {
  width: 100%;
  min-width: 60rem;
  border-collapse: collapse;
  font-size: 0.95rem;
  overflow-wrap: break-word;
  word-break: keep-all;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.5rem;
  border-bottom: 1px solid var(--line);
}

th {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

td.actions .button {
  display: block;
  width: 100%;
  margin: 0 0 0.35rem;
  text-align: center;
  white-space: nowrap;
}

td.actions .button:last-child {
  margin-bottom: 0;
}

.row-note {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

.admin-status {
  margin: 0 0 1rem;
}

.badge.paid {
  background: var(--ok-soft);
  color: #1f5d36;
}

.badge.test {
  background: var(--warn-soft);
  color: #7a5200;
}

.badge.off {
  background: var(--error-soft);
  color: var(--error);
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
}

.money {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 40rem) {
  .table-wrap {
    overflow-x: visible;
    margin: 0;
  }

  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .table-wrap thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .table-wrap tr {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--line);
  }

  .table-wrap td {
    position: relative;
    min-height: 1.7rem;
    padding: 0.3rem 0 0.3rem 7rem;
    border-bottom: 0;
    white-space: normal;
  }

  .table-wrap td[data-label]::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 6.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
  }

  .table-wrap td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0 0;
  }

  .table-wrap td.actions .button {
    display: inline-flex;
    align-items: center;
    width: auto;
    margin: 0;
  }
}

.preview-banner {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 2px dashed var(--warn-line);
  border-radius: var(--radius);
  background: var(--warn-soft);
  color: #5c3d00;
  font-weight: 600;
}

.preview-banner [lang="ko"] {
  display: block;
  font-weight: 500;
}
