:root {
  color-scheme: light;
  --green: #4b5320;
  --khaki: #c3b091;
  --char: #2b2b22;
  --paper: #c3b091;
  --card: #f2ece1;
  --card-2: #e6dcc9;
  --ink: #2b2b22;
  --ink-2: #35352b;
  --ink-3: #4b5320;
  --brass: #4b5320;
  --brass-lt: #c3b091;
  --brass-hover: #5c6528;
  --brass-soft: #dfd9c2;
  --signal: #2b2b22;
  --signal-soft: #e0d8c6;
  --field: #4b5320;
  --field-soft: #e2e0cd;
  --steel: #63604f;
  --steel-soft: #eae4d6;
  --line: #b3a184;
  --line-soft: #cfc3a9;
  --text: #2b2b22;
  --muted: #5c5a4a;
  --muted-2: #63604f;
  --font-ui: "Segoe UI", "Noto Sans", Tahoma, Arial, sans-serif;
  --font-data: Consolas, "Cascadia Mono", "DejaVu Sans Mono", "Courier New", monospace;
  --radius: 2px;
  --shadow: 0 1px 2px rgba(43, 43, 34, .08), 0 8px 24px -16px rgba(43, 43, 34, .32);
  --input-bg: #f7f3ea;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { background: var(--paper); }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
}

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

header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 72px;
  margin: 0;
  padding: 12px 26px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

header h1,
header p {
  width: min(760px, 100%);
}

header h1 {
  font-size: 19px;
  line-height: 1.25;
}

header p,
footer,
.hint {
  color: var(--muted);
  font-size: 12px;
}

header p { margin: 2px 0 0; }

.card {
  width: min(760px, calc(100% - 52px));
  margin: 18px auto;
  padding: 6px 18px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-top: 3px solid var(--brass);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 16px 0 6px;
  border: 0;
  border-top: 1px solid var(--line-soft);
}

fieldset:first-of-type {
  border-top: 0;
  padding-top: 12px;
}

legend {
  padding: 0 0 0 8px;
  border-left: 3px solid var(--brass);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

label.field,
.person label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted-2);
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}

textarea {
  min-height: 64px;
  resize: vertical;
}

input, select, textarea, fieldset {
  scroll-margin-top: 96px;
  scroll-margin-bottom: 88px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(75, 83, 32, .18);
}

::placeholder { color: var(--muted); opacity: 1; }

.span2 { grid-column: 1 / -1; }

.ticks,
.levels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 8px;
  margin-bottom: 12px;
}

.ticks label,
.levels label,
label.ticks {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  margin-top: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

label.ticks { margin-top: 8px; }

.ticks input,
.levels input,
label.ticks input {
  width: 15px;
  height: 15px;
  margin: 0;
  padding: 0;
  accent-color: var(--brass);
}

input[type="checkbox"],
input[type="radio"] {
  width: 15px;
  height: 15px;
  accent-color: var(--brass);
}

fieldset > p.hint:has(+ .ticks),
fieldset > p.hint:has(+ .levels),
fieldset > p.hint:has(+ label.ticks) {
  margin: 14px 0 0;
  color: var(--muted-2);
  font-family: var(--font-data);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.person {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--input-bg);
  border: 1px solid var(--line-soft);
  border-top: 3px solid var(--brass);
  border-radius: var(--radius);
}

.person h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.person .grid { gap: 14px; }

.bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  margin: 0;
  padding: 12px 26px calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
}

.bar button,
.bar .hint { width: min(760px, 100%); }

.bar .hint { margin: 8px 0 0; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  background: var(--brass);
  color: #f2ece1;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}

button:hover:not(:disabled) {
  background: var(--brass-hover);
  border-color: var(--brass-hover);
}

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

button.secondary:hover:not(:disabled) {
  background: var(--card-2);
  border-color: var(--muted-2);
  color: var(--ink);
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

#qrActions button { width: 100%; }

.error {
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--signal-soft);
  border: 1px solid var(--line);
  border-left: 4px solid var(--signal);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 700;
}

footer {
  width: min(760px, calc(100% - 52px));
  margin: 0 auto;
  padding: 4px 0 28px;
}

#qrView {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  flex-direction: column;
  padding: 16px 16px 12px;
  background: var(--paper);
  color: var(--text);
}

#qrView.show { display: flex; }

#qrView h2 {
  margin: 0;
  font-size: 15px;
  text-align: center;
}

#qrMeta,
#qrHint {
  margin: 4px auto;
  max-width: 62ch;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

#qrMeta {
  font-family: var(--font-data);
  font-size: 12px;
  color: var(--muted-2);
}

#qrBox {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qrBox canvas {
  display: block;
  background: #fff;
  border: 1px solid var(--line);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#qrActions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(760px, 100%);
  margin: 8px auto 0;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 2px solid var(--paper);
  border-radius: 8px;
}

@media (min-width: 900px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.three { grid-template-columns: 1fr 1fr 1fr; }
  #qrActions { flex-direction: row; }
  #qrActions button { width: auto; flex: 1; }
}

@media (max-width: 900px) {
  header,
  .bar { padding-left: 16px; padding-right: 16px; }
  .card,
  footer { width: min(760px, calc(100% - 32px)); }
  .span2 { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media print {
  body { background: #fff; }
  header {
    position: static;
    border-bottom: 2px solid #2b2b22;
    padding: 0 0 8px;
    min-height: 0;
  }
  .bar, #qrView { display: none !important; }
  .card {
    width: 100%;
    margin: 10px 0;
    box-shadow: none;
    border: 1px solid #b3a184;
    border-top-width: 2px;
  }
  .person, fieldset { break-inside: avoid; }
  a { text-decoration: none; color: #2b2b22; }
}
