:root {
  --text: #1b1f24;
  --muted: #4a5360;
  --line: #c9d0d9;
  --panel: #ffffff;
  --page: #f3f5f8;
  --accent: #1f5fbf;
  --accent-dark: #174a96;
  --danger: #a3241b;
  --warning: #7a4b00;
  --focus: #f0a400;
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  line-height: 1.55;
  color: var(--text);
  background: var(--page);
}

* { box-sizing: border-box; }

body { margin: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { margin: 0; font-size: 0.95rem; color: var(--muted); }
.brand-name { font-weight: 700; color: var(--text); }

.page { max-width: 46rem; margin: 0 auto; padding: 1rem; }

h1 { font-size: 1.6rem; margin: 0.5rem 0; line-height: 1.3; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
.lead { margin: 0 0 1rem; color: var(--muted); }

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

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.5rem 1.1rem;
  border-radius: 0.5rem;
  border: 2px solid var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.secondary { background: #fff; color: var(--accent); }
.button.small { min-height: 2.5rem; padding: 0.25rem 0.75rem; }
.button.large { width: 100%; margin-top: 0.5rem; font-size: 1.05rem; }
.button:disabled { cursor: not-allowed; opacity: 0.5; }

.button:focus-visible,
input:focus-visible,
.visually-hidden:focus-visible + label.button {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.file-name { margin: 0.75rem 0 0.25rem; font-weight: 600; overflow-wrap: anywhere; }
.break { overflow-wrap: anywhere; }

.help { margin: 0.25rem 0; font-size: 0.9rem; color: var(--muted); }
.help.warning { color: var(--warning); font-weight: 600; }

.preview-row { display: grid; gap: 1rem; }
.preview {
  display: block;
  max-width: 100%;
  max-height: 22rem;
  width: auto;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
  /* checkerboard so transparent areas stay visible */
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #e3e6ea 25%, transparent 25%),
    linear-gradient(-45deg, #e3e6ea 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e3e6ea 75%),
    linear-gradient(-45deg, transparent 75%, #e3e6ea 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.facts { margin: 0; display: grid; gap: 0.4rem; }
.facts div { display: grid; grid-template-columns: 8rem 1fr; gap: 0.5rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.exact-size { margin-top: 0.2rem; font-size: 0.9rem; color: var(--muted); }
.exact-size summary { width: fit-content; padding: 0.2rem 0; cursor: pointer; }
.exact-size summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.exact-size p { margin: 0.15rem 0 0; }

fieldset { border: 0; margin: 0 0 1rem; padding: 0; }
legend { font-weight: 700; margin-bottom: 0.5rem; padding: 0; }

.choices .choice {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.6rem;
  align-items: center;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
}
.choices .choice .help { grid-column: 2; margin: 0; }
.choices.inline { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choices.inline legend { width: 100%; }
.choices.inline .choice { margin: 0; min-width: 7rem; }
.choice input[type="radio"] { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--accent); }
.choice label { font-weight: 600; padding: 0.35rem 0; cursor: pointer; }

.field { margin: 0 0 1rem; }
.field label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
.field input[type="text"] {
  width: 100%;
  max-width: 14rem;
  min-height: 2.75rem;
  padding: 0.4rem 0.6rem;
  font: inherit;
  font-size: 1.1rem;
  border: 2px solid var(--line);
  border-radius: 0.5rem;
}
.field input[aria-invalid="true"] { border-color: var(--danger); }
.percent-controls { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.percent-controls input[type="range"] { flex: 1 1 12rem; min-width: 0; min-height: 2.75rem; margin: 0; accent-color: var(--accent); }
.field .percent-controls input[type="text"] { width: 5.5rem; }
.target-summary { margin: 0.4rem 0 0; font-weight: 600; overflow-wrap: anywhere; }
.target-summary:empty { display: none; }
.field-error { margin: 0.25rem 0 0; color: var(--danger); font-weight: 600; }
.field-error:empty { display: none; }

.notes { margin: 0 0 0.5rem; padding-left: 1.25rem; font-size: 0.9rem; color: var(--muted); }

.status { margin: 0.75rem 0 0; font-weight: 600; }

.alert:not(:empty) {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--danger);
  border-radius: 0.5rem;
  background: #fdf1f0;
  color: var(--danger);
}
.alert .alert-title { margin: 0; font-weight: 700; }
.alert ul { margin: 0.4rem 0 0; padding-left: 1.25rem; color: var(--text); }

.site-footer { max-width: 46rem; margin: 0 auto; padding: 0 1rem 2rem; font-size: 0.85rem; color: var(--muted); }

[hidden] { display: none !important; }

@media (min-width: 40rem) {
  .preview-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .button.large { width: auto; min-width: 12rem; }
}
