/* Forms and sign-in pages: fields, buttons that need a border, errors, the narrow page frame, panels and the passkey list (logical properties only). */
:where(button).btn {
  border: 0;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

.btn-outline {
  border: 2px solid var(--text);
  background: transparent;
  color: var(--text);
}

.btn-danger {
  border: 2px solid var(--c-coral);
  background: transparent;
  color: var(--text);
}

.btn-danger:hover,
.btn-danger:focus-visible {
  background: var(--c-coral);
  color: var(--on-coral);
}

.btn-link {
  min-block-size: 44px;
  padding-inline: 0;
  background: none;
  color: var(--link);
  text-transform: none;
}

/* Narrow page frame for sign-in, settings and passkey pages */
main.auth {
  max-inline-size: 36rem;
  margin-inline: auto;
  padding: var(--s-6) var(--s-4) var(--s-7);
}

main.auth h1 {
  font-size: var(--fs-4);
}

main.auth h2 {
  font-size: var(--fs-2);
}

.auth-intro {
  color: var(--text-muted);
  font-size: var(--fs-2);
  line-height: 1.45;
}

.form {
  display: grid;
  gap: var(--s-4);
  margin-block-end: var(--s-5);
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: var(--s-2);
}

.field label {
  font-weight: 700;
}

.field input:not([type="checkbox"], [type="radio"]),
.field select,
.field textarea {
  inline-size: 100%;
  min-block-size: 48px;
  padding: var(--s-2) var(--s-3);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  border-color: var(--focus);
}

.field-check {
  grid-template-columns: auto 1fr;
  align-items: start;
  column-gap: var(--s-3);
}

.field-check input {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  margin: 0;
  accent-color: var(--accent-text);
}

.field-check label {
  font-weight: 600;
}

.field-check .help,
.field-check .errorlist {
  grid-column: 2;
}

.help {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-0);
}

.has-error input:not([type="checkbox"]) {
  border-color: var(--c-coral);
}

.errorlist,
.form-error {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-weight: 700;
  list-style: none;
}

.errorlist li,
.form-error li {
  padding: var(--s-2) var(--s-3);
  background: color-mix(in srgb, var(--c-coral) 22%, var(--surface));
  border-inline-start: 4px solid var(--c-coral);
  border-radius: var(--radius-sm);
}

.form-actions,
.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}

.form-actions .btn,
.button-group .btn {
  flex: 1 1 12rem;
  padding-inline: var(--s-4);
  text-align: center;
}

.or {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-block: var(--s-4);
  color: var(--text-muted);
}

.or::before,
.or::after {
  flex: 1;
  block-size: 1px;
  background: var(--border);
  content: "";
}

.aside {
  margin-block-start: var(--s-5);
  color: var(--text-muted);
}

.pilot-note {
  padding: var(--s-3) var(--s-4);
  background: color-mix(in srgb, var(--c-sand) 28%, var(--surface));
  border-inline-start: 4px solid var(--c-sand);
  border-radius: var(--radius-sm);
}

/* Settings: one panel per topic */
.panel {
  margin-block-end: var(--s-5);
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel > :last-child {
  margin-block-end: 0;
}

.panel .form {
  padding: 0;
  border: 0;
  box-shadow: none;
}

.panel .help {
  margin-block-end: var(--s-3);
}

.panel-danger {
  border-color: var(--c-coral);
}

/* Passkey list: one panel per key, with a small badge for its kind */
.keys {
  margin: 0 0 var(--s-5);
  padding: 0;
  list-style: none;
}

.keys h2 {
  margin-block-end: var(--s-1);
}

.badge {
  display: inline-block;
  margin-inline-start: var(--s-2);
  padding: 0 var(--s-2);
  background: color-mix(in srgb, var(--c-teal) 28%, var(--surface));
  border-radius: 999px;
  font-size: var(--fs-0);
  font-weight: 700;
  vertical-align: middle;
}

/* A group of checkboxes (a multiple-choice field) is a fieldset with a legend */
fieldset.field {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset.field legend {
  margin-block-end: var(--s-2);
  padding: 0;
  font-weight: 700;
}

fieldset.field > div {
  display: grid;
  gap: var(--s-1);
}

fieldset.field label {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  min-block-size: 44px;
  font-weight: 600;
}

fieldset.field input {
  inline-size: 1.5rem;
  block-size: 1.5rem;
  margin: 0;
  accent-color: var(--accent-text);
}

/* Authenticator app setup: the QR picture, the typed key and the recovery codes */
.qr {
  display: block;
  max-inline-size: 14rem;
  margin-block: var(--s-3);
  padding: var(--s-2);
  background: var(--c-white);
}

.secret,
.codes {
  display: block;
  padding: var(--s-2) var(--s-3);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  overflow-wrap: anywhere;
  user-select: all;
}

.codes {
  margin-block: var(--s-3);
  white-space: pre-line;
}
