.auth-page,
.auth-page * {
  box-sizing: border-box
}

.auth-page {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--surface);
  color: var(--on-surface)
}

.auth-page {
  --auth-outline: #757b86;
  min-height: 100dvh;
  padding: 12px;
  line-height: 1.5;
  color-scheme: light;
}

.auth-shell {
  width: min(960px, 100%);
  margin: 0 auto 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: #fff;
  border: 1px solid var(--outline-variant);
  border-radius: 12px;
}

.auth-brand {
  min-width: 0;
  padding: 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 11px 11px 0 0;
}

.auth-brand img {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
}

.auth-form {
  min-width: 0;
  padding: 24px 20px;
}

.auth-form h1 {
  margin: 0;
  color: var(--primary);
  font-size: clamp(1.65rem, 2.5vw, 2rem);
  line-height: 1.2;
  text-wrap: balance;
}

.auth-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px
}

.choice-grid {
  display: grid;
  /* Flexible tracks keep category cards readable before they stack. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
  align-items: start;
  gap: 12px
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  cursor: pointer
}

.choice input {
  /* Native controls keep checked and focused states accessible without scripts. */
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 3px 0 0;
  accent-color: var(--primary)
}

.choice-group {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--auth-outline);
  border-radius: 10px;
  padding: 10px 14px 14px;
  transition: border-color .15s ease, background-color .15s ease;
}

.choice-group legend {
  padding: 0 4px;
}

.choice--interest {
  min-height: 44px;
  align-items: center;
  font-weight: 700;
}

.choice__text {
  min-width: 0;
}

.choice__state {
  display: none;
  margin-left: 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}

.related-skills {
  display: none;
  gap: 6px;
  padding-top: 4px;
}

.related-skills__hint {
  margin: 0 0 2px;
  color: var(--on-surface-variant);
  font-size: 13px;
}

.choice--compact {
  min-height: 44px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--auth-outline);
  border-radius: 8px;
}

.choice-group:has(> legend input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}

.choice-group:has(> legend input:checked) .choice__state {
  display: inline;
}

.choice-group:has(> legend input:checked) .related-skills {
  display: grid;
}

.choice--compact:has(input:checked) {
  border-color: var(--primary);
  background: #fff;
  color: var(--primary);
}

.choice-group:focus-within,
.choice:has(input:focus-visible) {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.auth-modal {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--auth-outline);
  border-radius: 12px;
  color: var(--on-surface);
  background: #fff;
  overscroll-behavior: contain;
}

.auth-modal::backdrop { background: rgba(17, 28, 44, .55); }

.auth-modal__card {
  padding: 28px;
  overflow-wrap: anywhere;
}

@media(min-width:48rem) {
  .auth-page { padding: 16px 32px 32px; }
  .auth-shell {
    grid-template-columns: minmax(240px, .75fr) minmax(0, 1.25fr);
    margin-top: 24px;
  }
  .auth-shell--signup { width: min(1160px, 100%); grid-template-columns: minmax(240px, .6fr) minmax(0, 1.4fr); }
  .auth-brand {
    padding: 36px 28px;
    border-radius: 11px 0 0 11px;
  }
  .auth-brand img { width: 128px; height: 128px; }
  .auth-form { padding: 36px; }
}

@media(min-width:64rem) {
  .auth-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.auth-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  width: min(1160px, 100%);
  margin: 0 auto 12px;
  padding: max(0px, env(safe-area-inset-top)) 12px 0;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
}

.auth-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

.auth-nav__brand img { object-fit: contain; }

.auth-nav__links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-nav a,
.auth-text-link,
.auth-switch a,
.auth-errors a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-block: 8px;
  color: var(--primary);
  text-underline-offset: 3px;
}

.auth-nav a { padding-inline: 8px; }
.auth-nav__link { text-decoration: none; }
.auth-page a:hover { color: var(--primary-hover); text-decoration-thickness: 2px; }
.auth-page :where(a, button, input, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}
.auth-page .flash-stack { width: min(1160px, calc(100% - 2rem)); margin: 1rem auto 16px; }
.auth-page .flash { color: #fff; }
.auth-page .auth-skip-link {
  position: absolute;
  top: 8px;
  left: 12px;
  padding: 12px;
  color: var(--primary);
  background: #fff;
  transform: translateY(-200%);
  z-index: 20;
}
.auth-page .auth-skip-link:focus { transform: none; }
.auth-identity { display: flex; align-items: center; justify-content: center; }
.auth-brand__name { margin: 0; font-weight: 700; font-size: 1.15rem; line-height: 1.3; }
.auth-brand__intro { display: none; }
.auth-brand__intro .auth-brand__title { margin: 0; font-weight: 700; font-size: clamp(1.8rem, 2.7vw, 2.5rem); line-height: 1.15; text-wrap: balance; }
.auth-brand__title::after { content: ''; display: block; width: 40px; height: 4px; margin-top: 24px; background: var(--gold); }
.auth-brand__intro > p:last-child { margin-top: 24px; }
.auth-form__heading { margin-bottom: 28px; }
.auth-form__heading > p { margin: 12px 0 0; color: var(--on-surface-variant); }
.auth-form__heading .auth-step { margin: 0 0 12px; color: var(--primary); font-weight: 600; font-size: .875rem; }
.auth-form .field { min-width: 0; margin: 0 0 20px; }
.auth-form label { font-weight: 600; }
.auth-form .input,
.auth-form .select { min-height: 48px; min-width: 0; border-color: var(--auth-outline); }
.auth-form [aria-invalid="true"] { border-color: var(--error); }
.auth-form .password-input { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.auth-form .button[hidden] { display: none; }
.auth-form .button--secondary { border-color: var(--auth-outline); }
.auth-form .button--secondary:hover { background: var(--surface-container-low); }
.auth-form .button:active { transform: translateY(1px); }
.auth-forgot { margin: -8px 0 12px; }
.auth-switch { margin: 24px 0 0; border-top: 1px solid var(--outline-variant); padding-top: 12px; }
.auth-switch a { margin-inline-start: 4px; font-weight: 600; }
.auth-fieldset { min-width: 0; margin: 0 0 28px; padding: 0; border: 0; }
.auth-fieldset legend { padding: 0; margin-bottom: 16px; font-size: 1.1rem; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 20px; }
.field--wide { grid-column: 1 / -1; }
.field-hint { margin: 0; color: var(--on-surface-variant); font-size: .875rem; font-weight: 400; line-height: 1.5; }
.field-error { margin: 4px 0 0; color: var(--error); font-size: .875rem; font-weight: 600; }
.auth-errors { padding: 16px; margin: 0 0 24px; border: 1px solid var(--error); border-radius: 8px; }
.auth-errors h2 { margin: 0; font-size: 1rem; color: var(--error); }
.auth-errors p { margin: 0; color: var(--error); }
.auth-errors ul { margin: 8px 0 0; padding-left: 20px; }
.auth-errors a { padding: 4px 0; }
.auth-preferences { margin: 0 0 28px; padding-block: 16px; border-block: 1px solid var(--outline-variant); }
.auth-preferences p { margin: 0; }
.auth-role-note { margin-top: 16px; }
.auth-form .check-row { min-height: 44px; align-items: flex-start; padding-block: 8px; font-weight: 400; cursor: pointer; }
.auth-form .check-row input { width: 20px; height: 20px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--primary); }
.form-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 24px; }
.form-actions .button { flex: 1 1 200px; }
.auth-notice { padding: 16px; border: 1px solid var(--auth-outline); border-radius: 8px; }
.auth-form, .auth-errors, .auth-brand { overflow-wrap: anywhere; }

@media(min-width:48rem) {
  .auth-identity { flex-direction: column; align-items: center; }
  .auth-brand__intro { display: block; margin-top: 48px; }
}

@media(prefers-reduced-motion:reduce) {
  .auth-page *, .auth-page *::before, .auth-page *::after {
    transition: none;
    animation: none;
  }
}

.policy-copy {
  margin: 1rem 0;
  padding: 1rem;
  white-space: pre-wrap;
  border: 1px solid var(--outline-variant);
  border-radius: .5rem;
  background: var(--surface-container-low);
  line-height: 1.55;
}

details.policy-copy { white-space: normal; padding: 0; border-color: var(--auth-outline); }
.policy-copy summary { min-height: 44px; padding: 12px 16px; cursor: pointer; color: var(--primary); font-weight: 600; }
.policy-copy__body { padding: 0 16px 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
