:root {
  color-scheme: light dark;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --border: #d8dce6;
  --border-strong: #b9c0d0;
  --text: #1a1d24;
  --text-muted: #5a6072;
  --accent: #397cff;
  --accent-contrast: #ffffff;
  --accent-soft: #e6efff;
  --danger: #c2334d;
  --focus-ring: 0 0 0 3px rgba(57, 124, 255, 0.45);
  --shadow-sm: 0 1px 2px rgba(15, 20, 35, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 20, 35, 0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --gap: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11141b;
    --surface: #1a1f2a;
    --surface-2: #232938;
    --border: #303747;
    --border-strong: #455066;
    --text: #e7eaf2;
    --text-muted: #a3aac0;
    --accent: #6c9bff;
    --accent-contrast: #0a0f1a;
    --accent-soft: #20304f;
    --danger: #ff7a8e;
    --focus-ring: 0 0 0 3px rgba(108, 155, 255, 0.5);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.4);
  }
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 4rem;
}

.page-header {
  max-width: 880px;
  margin: 0 auto;
  padding: 2rem 1.25rem 0.5rem;
  text-align: center;
}

.page-header h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
  letter-spacing: -0.01em;
}

.help {
  margin: 0 auto;
  color: var(--text-muted);
  max-width: 60ch;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  z-index: 100;
}
.skip-link:focus {
  left: 1rem;
  top: 1rem;
  outline: none;
  box-shadow: var(--focus-ring);
}

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

h2 {
  font-size: 1.15rem;
  margin: 0 0 0.75rem;
  letter-spacing: -0.005em;
}

section.list-section,
section.signature-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: var(--gap);
  box-shadow: var(--shadow-sm);
}

@media (min-width: 760px) {
  .list-section + .list-section {
    margin-top: 0;
  }
}

ul.bullet-list {
  list-style: none;
  padding-left: 0.25rem;
  margin: 0 0 0.75rem;
}

.bullet-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0;
  position: relative;
  padding-left: 1rem;
}
.bullet-row::before {
  content: "";
  position: absolute;
  left: 0.1rem;
  top: 50%;
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  transform: translateY(-50%);
}

.bullet-row input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  font: inherit;
  color: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.625rem;
}

input[type="text"]:focus,
input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.remove-row {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.remove-row:hover {
  color: var(--danger);
  border-color: var(--danger);
}
.remove-row:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.bullet-list[data-only-row="true"] .remove-row {
  visibility: hidden;
}

.add-row {
  font: inherit;
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  display: block;
  margin-left: auto;
}
.add-row:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.add-row:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.toggle-button {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.875rem;
  cursor: pointer;
}
.toggle-button:hover {
  border-color: var(--accent);
}
.toggle-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.toggle-indicator {
  width: 28px;
  height: 16px;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  transition: background-color 120ms ease;
}
.toggle-indicator::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-radius: 50%;
  transition: transform 120ms ease;
}
.toggle-button[aria-pressed="true"] .toggle-indicator {
  background: var(--accent);
}
.toggle-button[aria-pressed="true"] .toggle-indicator::after {
  transform: translateX(12px);
}

.identity-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}
.identity-fields[hidden] {
  display: none;
}
@media (min-width: 560px) {
  .identity-fields {
    grid-template-columns: 2fr 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.field span {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.field input {
  font: inherit;
  color: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.625rem;
}

.signature-frame {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  height: 180px;
  overflow: hidden;
}
#signature-pad {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.signature-line {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1.25rem;
  border-bottom: 1px dashed var(--border-strong);
  pointer-events: none;
}

.signature-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}
.signature-actions #toggle-identity {
  margin-left: auto;
}
.hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
}
.actions #print-button {
  margin-left: auto;
}

.primary-button,
.secondary-button,
.ghost-button {
  font: inherit;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}
.primary-button {
  background: var(--accent);
  color: var(--accent-contrast);
}
.primary-button:hover {
  filter: brightness(1.05);
}
.secondary-button {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.ghost-button {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.ghost-button:hover {
  color: var(--text);
  border-color: var(--border-strong);
}
.primary-button:focus-visible,
.secondary-button:focus-visible,
.ghost-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(0);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  opacity: 0;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
  z-index: 50;
}
.toast[data-visible="true"] {
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

.print-view {
  display: none;
}

.print-view h1 {
  font-size: 1.6rem;
  margin: 0 0 0.5rem;
}
.print-view .meta {
  color: #444;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.print-view section {
  margin: 0 0 1rem;
  break-inside: avoid;
}
.print-view section h2 {
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
}
.print-view ul {
  margin: 0 0 0.75rem 1.25rem;
  padding: 0;
}
.print-view ul li {
  margin: 0.15rem 0;
}
.print-view .signature-block {
  margin-top: 1.25rem;
  break-inside: avoid;
}
.print-view .signature-block img.signature {
  display: block;
  max-width: 320px;
  max-height: 120px;
  border-bottom: 1px solid #333;
  padding-bottom: 4px;
}
.print-view .signature-block .name-line {
  margin-top: 0.35rem;
  color: #333;
}

@page {
  size: letter;
  margin: 0.75in;
}

@media print {
  html,
  body {
    background: #fff;
    color: #000;
  }
  .page-header,
  form,
  .toast,
  .skip-link {
    display: none !important;
  }
  .no-print {
    display: none !important;
  }
  main {
    padding: 0;
    max-width: none;
  }
  .print-view {
    display: block;
    color: #000;
  }
}
