:root {
  --bg: #f6f7f9;
  --fg: #1a1d24;
  --muted: #5c6470;
  --border: #c9ced8;
  --err: #c41e3a;
  --err-bg: #fdecef;
  --accent: #1e5a96;
  --accent-hover: #164a7d;
  --radius: 10px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --fg: #e8eaef;
    --muted: #9aa3b2;
    --border: #3a404c;
    --err: #ff6b7a;
    --err-bg: #3a1f24;
    --accent: #6eb3f0;
    --accent-hover: #8fc4f5;
  }
}

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

html {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
}

main.form-screen {
  max-width: 32rem;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

h1 {
  font-size: 1.35rem;
  margin: 0 0 0.5rem;
}

.lede {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field.row {
  flex-direction: row;
  align-items: center;
  gap: 0.75rem;
}

.field.row.tight {
  margin-top: -0.15rem;
}

label:not(.check) {
  font-weight: 600;
  font-size: 0.9rem;
}

.check {
  font-weight: normal;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  cursor: pointer;
  user-select: none;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  min-height: var(--tap);
  padding: 0.55rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
}

select:required:invalid {
  color: var(--muted);
}

select option {
  color: var(--fg);
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field.is-invalid input:not(:focus),
.field.is-invalid select:not(:focus) {
  border-color: var(--err);
}

.hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.helper-copy {
  margin-top: 0.25rem;
}

.maps-helper {
  margin: 0.65rem 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  max-width: 22rem;
}

@media (prefers-color-scheme: dark) {
  .maps-helper {
    background: #1e2228;
  }
}

.maps-helper img {
  display: block;
  width: 100%;
  height: auto;
}

.err {
  display: none;
  font-size: 0.8rem;
  color: var(--err);
  background: var(--err-bg);
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--err) 35%, transparent);
}

.field.is-invalid .err {
  display: block;
}

.actions {
  margin-top: 0.5rem;
}

.btn {
  min-height: var(--tap);
  padding: 0 1rem;
  font-size: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
}

.btn.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}

.btn.primary:hover,
.btn.primary:focus-visible {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* QR full-screen view */
body.view-qr {
  overflow: hidden;
}

body.view-qr .form-screen {
  display: none;
}

body.view-qr .qr-screen {
  display: flex;
}

.qr-screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
  background: var(--bg);
}

.qr-bar {
  flex-shrink: 0;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
}

.qr-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.qr-wrap {
  width: min(calc(100vw - 24px), calc(100dvh - 120px), calc(100vh - 120px));
  max-width: min(100vw - 24px, calc(100dvh - 120px));
  aspect-ratio: 1;
  max-height: min(calc(100vw - 24px), calc(100dvh - 120px), calc(100vh - 120px));
}

.qr-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qr-footer {
  flex-shrink: 0;
  padding: 0.75rem 1rem 1.25rem;
  text-align: center;
}

.site-line {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-all;
}

.site-line code {
  font-size: 0.85rem;
}
