@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/Inter-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/Inter-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('../assets/fonts/Inter-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #fafaf9;
  --surface: #ffffff;
  --bg-elevated: #f5f5f4;
  --ink: #0a0a0a;
  --ink-hover: #1a1a1a;
  --muted: #737373;
  --subtle: #e5e5e5;
  --error: #b91c1c;
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' width='12' height='8'%3E%3Cpath fill='none' stroke='%230a0a0a' stroke-width='1.5' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  --radius-sm: 6px;
  --radius-md: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --max-width: 480px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  /* Refined dark palette. Cool undertones (slight blue cast) reduce
     eye strain compared to neutral grays at the same lightness, and
     wider tonal gaps between bg / surface / elevated give inputs
     and cards real separation without resorting to harsh borders. */
  --bg: #0d1117;            /* cool deep base */
  --surface: #161b22;       /* +5L lift for inputs, modal, cards */
  --bg-elevated: #1f242b;   /* +5L again for prominent checkboxes */
  --ink: #e6edf3;           /* soft cool white, ~95% L, ~13.7:1 on bg */
  --ink-hover: #f0f6fc;     /* near-white on primary button hover */
  --muted: #8b949e;         /* ~6.4:1 on bg, comfortable for hints */
  --subtle: #30363d;        /* borders read clearly against surface */
  --error: #f85149;         /* warmer red, visible on cool bg */
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' width='12' height='8'%3E%3Cpath fill='none' stroke='%23e6edf3' stroke-width='1.5' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  position: relative;
  padding: var(--space-6) var(--space-4);
  text-align: center;
  border-bottom: 1px solid var(--subtle);
}
.brand { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; margin: 0; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.theme-toggle {
  position: absolute;
  top: 50%;
  right: var(--space-4);
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--subtle); }
.theme-toggle:focus-visible { outline: none; border-color: var(--ink); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.wizard {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-8) var(--space-4) var(--space-12);
  flex: 1;
}

.progress { display: flex; gap: var(--space-1); margin-bottom: var(--space-8); }
.progress__seg {
  flex: 1; height: 3px; background: var(--subtle); border-radius: 2px;
  transition: background 0.2s;
}
.progress__seg.is-done, .progress__seg.is-current { background: var(--ink); }

.eyebrow {
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: var(--space-2);
}
.step__title { font-size: 24px; font-weight: 600; margin: 0 0 var(--space-1); letter-spacing: -0.02em; }
.step__sub { color: var(--muted); margin: 0 0 var(--space-6); font-size: 13px; }

.field { margin-bottom: var(--space-4); }
.field__label { display: block; font-size: 12px; font-weight: 500; margin-bottom: var(--space-1); }
.field__label .req { color: var(--error); margin-left: 2px; }
.field__row { display: flex; gap: var(--space-2); }
.field__row > .field { flex: 1; }
.field__hint { font-size: 11px; color: var(--muted); margin-top: var(--space-1); }
.field__error { font-size: 12px; color: var(--error); margin-top: var(--space-1); display: none; }
.field.is-error .field__error { display: block; }
.field.is-error .input { border-color: var(--error); }

.input, .select, .textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.15s;
  min-height: 40px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ink);
  border-width: 1px;
}
.input--mono { font-family: var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase; }
.select { appearance: none; background-image: var(--select-chevron); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.radio-group, .checkbox-group { display: flex; flex-direction: column; gap: var(--space-2); }
.radio, .checkbox {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 12px;
  border: 1px solid var(--subtle); border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  min-height: 44px;
}
.radio.is-selected, .checkbox.is-selected { border-color: var(--ink); }
.radio input, .checkbox input { margin: 0; accent-color: var(--ink); }

.actions {
  position: sticky; bottom: 0;
  display: flex; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  margin: 0 calc(-1 * var(--space-4));
}
.btn {
  flex: 1;
  min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 var(--space-4);
  font: 500 14px/1 var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  background: var(--surface);
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s;
}
.btn--ghost { border-color: var(--subtle); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--secondary { color: var(--muted); border-color: var(--subtle); }
.btn--primary { background: var(--ink); color: var(--bg); flex: 2; }
.btn--primary:hover { background: var(--ink-hover); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.searchselect { position: relative; }
.searchselect__input { width: 100%; }
.searchselect__list {
  position: absolute;
  left: 0; right: 0; top: 100%;
  margin: 4px 0 0; padding: 4px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.searchselect__list[hidden] { display: none; }
.searchselect__option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
  transition: background-color 0.1s;
}
.searchselect__option[aria-selected="true"],
.searchselect__option:hover {
  background: var(--subtle);
}
.searchselect__option .abbr {
  flex: 0 0 auto;
  margin-left: var(--space-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 100;
}
.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.4);
  cursor: pointer;
}
.modal__dialog {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--ink);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}
.modal__title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-2);
  color: var(--ink);
}
.modal__body {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 var(--space-6);
  line-height: 1.5;
}
.modal__actions {
  display: flex;
  gap: var(--space-2);
}
.modal__actions .btn { flex: 1; min-height: 44px; }

.checkbox--prominent {
  min-height: 52px;
  padding: 14px 16px;
  border-color: var(--ink);
  background: var(--bg-elevated);
  font-weight: 500;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}
.checkbox--prominent.is-selected {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.checkbox--prominent.is-selected input { accent-color: var(--surface); }

.pdf-preview {
  width: 100%; height: 70vh;
  border: 1px solid var(--subtle); border-radius: var(--radius-md);
  background: var(--surface);
}

.page-footer {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--subtle);
}
.page-footer p { margin: 0; }
.page-footer__credit { margin-top: var(--space-2) !important; }
.page-footer__credit a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.page-footer__credit a:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

@media (max-width: 480px) {
  .wizard { padding: var(--space-6) var(--space-3) var(--space-12); }
  .actions { flex-direction: column; margin: 0 calc(-1 * var(--space-3)); }
  .btn--primary { flex: 1; }
}
