

.main-container:has(.auth-container) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: calc(100dvh - var(--header-height) - 4rem);
    padding-top: calc(var(--header-height) + clamp(1.5rem, 4vh, 2.25rem));
    padding-bottom: clamp(2rem, 6vh, 3rem);
    box-sizing: border-box;
}

.auth-container {
    width: 100%;
    max-width: 20rem;
    margin: 0 auto;
    padding: 0 var(--space-1) var(--space-5);
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    font-family: var(--font-family);
    font-size: var(--text-size-subhead);
    line-height: var(--line-body);
    letter-spacing: -0.01em;
    text-transform: none;
    color: var(--label-primary);
    text-align: left;
    box-sizing: border-box;
}

.auth-back {
    display: inline-flex;
    align-items: center;
    margin: 0 0 1.25rem;
    padding: 0;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 400;
    transition: color 0.2s ease;
}

.auth-back:hover {
    color: var(--text);
}

.auth-container h1,
.auth-container .auth-title {
    margin: 0 0 var(--space-5);
    font-size: var(--text-size-title1);
    font-weight: var(--text-weight-bold);
    line-height: var(--line-tight);
    letter-spacing: -0.025em;
    color: var(--label-primary);
    text-align: center;
}

.auth-container form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}

.auth-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    width: 100%;
    max-width: none;
    margin: 0 0 0.85rem;
    --field-input-ch: 100%;
}

.auth-field label,
.auth-label-wrap {
    display: block;
    margin: 0;
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.3;
}

.auth-label-text::after {
    content: none;
}

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"],
.auth-field input[type="number"],
.auth-field select {
    width: 100%;
    max-width: none;
    flex: none;
    box-sizing: border-box;
    min-height: var(--control-height);
    padding: 0 var(--control-pad-x);
    border: none;
    border-radius: 12px;
    background: var(--fill-tertiary, #2c2c2e);
    color: var(--label-primary);
    font-family: inherit;
    font-size: var(--text-size-body);
    letter-spacing: -0.01em;
    text-transform: none;
    text-align: left;
    box-shadow: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease,
        box-shadow 0.2s ease;
}

.auth-field input:focus,
.auth-field select:focus {
    border-color: var(--system-blue);
    background: var(--fill-secondary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--system-blue) 18%, transparent);
}

.auth-field input::placeholder {
    color: var(--label-quaternary);
    opacity: 1;
    font-weight: var(--text-weight-regular);
    text-transform: none;
    text-align: left;
}

.auth-field.is-invalid input,
.auth-field.is-invalid select {
    border-color: var(--system-red);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--system-red) 18%, transparent);
}

.auth-field .form-errors,
.auth-field + .form-errors {
    margin: 0.25rem 0 0;
    font-size: 0.8125rem;
    color: var(--system-red);
    text-transform: none;
    letter-spacing: normal;
    text-align: left;
}

.form-errors[data-auth-toast-error],
.form-errors.is-toasted,
.errorlist.is-toasted {
    display: none !important;
}

.auth-field.is-valid input {
    border-color: var(--system-green, #34c759);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--system-green, #34c759) 16%, transparent);
}

.auth-username-status {
    margin: 0.35rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.35;
    text-align: left;
    letter-spacing: normal;
    text-transform: none;
    color: var(--label-secondary, #98989d);
}

.auth-username-status.is-checking {
    color: var(--label-tertiary, #636366);
}

.auth-username-status.is-available {
    color: var(--system-green, #34c759);
}

.auth-username-status.is-taken,
.auth-username-status.is-invalid {
    color: var(--system-red, #ff453a);
}

.auth-container .form-group {
    width: 100%;
    display: block;
    margin: 0;
}

.form-group {
    margin-bottom: 0;
}

.form-group label {
    display: block;
}

.role-select {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.15rem;
    width: 100%;
}

.role-select input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.role-select label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 2.5rem;
    padding: 0 0.875rem;
    margin: 0;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: var(--input-bg);
    text-align: left;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.9375rem;
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease,
        color 0.2s ease;
}

.role-select label:hover {
    border-color: var(--input-border-focus);
    color: var(--text);
}

.role-select input[type="radio"]:checked + label {
    border-color: var(--text);
    background: color-mix(in srgb, var(--card) 40%, var(--input-bg));
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.role-select.is-invalid label {
    border-color: var(--system-red);
    color: var(--system-red);
}

.form-errors--block {
  margin: 0 0 1rem;
  padding: 0.75rem 0.875rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--system-red) 12%, transparent);
}

.auth-field-role {
  display: none !important;
}

.auth-field-role .auth-role-heading {
    width: auto;
    color: var(--text-tertiary);
}

.form-buttons {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.625rem;
    margin-top: 0.5rem;
}

#reg-step2 .form-buttons {
    flex-direction: row;
    flex-wrap: wrap;
}

#reg-step2 .form-buttons .auth-btn {
    flex: 1 1 calc(50% - 0.3125rem);
    min-width: 7.5rem;
}

.auth-btn {
  width: 100%;
  max-width: none;
  min-height: 2.5rem;
  margin: 0;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 12px;
  background: var(--button-primary-bg);
  color: var(--button-primary-text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: opacity 0.2s ease, transform 0.15s ease;
  box-shadow: none;
  outline: none;
}

.auth-btn:hover {
    opacity: 0.88;
    color: var(--button-primary-text);
    background: var(--button-primary-bg);
    border: none;
}

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

#reg-back-to-step1.auth-btn {
    background: var(--button-secondary-bg);
    color: var(--button-secondary-text);
    border: 1px solid var(--border);
}

#reg-back-to-step1.auth-btn:hover {
    background: var(--button-hover-bg);
    color: var(--button-secondary-text);
    opacity: 1;
}

.auth-btn-secondary {
  background: var(--button-secondary-bg);
  color: var(--button-secondary-text);
}

.auth-btn-secondary:hover {
  background: var(--button-hover-bg);
  color: var(--button-secondary-text);
  opacity: 1;
}

.google-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: none;
  min-height: 2.75rem;
  margin: 0;
  padding: 0.65rem 1rem;
  background: transparent;
  color: var(--label-primary, var(--text));
  border: 1px solid color-mix(in srgb, var(--label-primary, #fff) 22%, transparent);
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
  text-decoration: none;
  box-shadow: none;
  gap: 0.625rem;
  box-sizing: border-box;
  transition:
        border-color 0.2s ease,
        background-color 0.2s ease;
}

.google-btn::before {
    content: none;
}

.google-btn:hover {
    color: var(--label-primary, var(--text));
    background: color-mix(in srgb, var(--label-primary, #fff) 6%, transparent);
    border-color: color-mix(in srgb, var(--label-primary, #fff) 35%, transparent);
}

.google-btn svg {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
}

.auth-switch {
    text-align: left;
    margin-top: 1.15rem;
    padding-top: 0;
    border-top: none;
}

.auth-switch--compact {
    display: none;
}

.auth-switch > p + p {
    margin-top: 0.75rem;
}

.auth-grey-text {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.875rem;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.5;
}

.auth-grey-text a,
.auth-switch a {
    color: var(--text);
    font-weight: 500;
    text-decoration: none;
}

.auth-grey-text a:hover,
.auth-switch a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-bw-link {
    color: var(--text) !important;
    font-weight: 500;
    text-decoration: none !important;
    filter: none;
}

.auth-bw-link:hover {
    color: var(--text-secondary) !important;
    text-decoration: underline !important;
    text-underline-offset: 2px;
}

.consent-group {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    margin: 0.25rem 0 1rem;
    max-width: none;
    font-size: 0.8125rem;
    line-height: 1.5;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
    color: var(--text-muted);
}

.consent-checkbox {
    width: 1rem;
    height: 1rem;
    margin: 0.15rem 0 0;
    flex-shrink: 0;
    accent-color: var(--button-primary-bg);
}

.consent-label {
    color: inherit;
}

.consent-label a {
    color: var(--text);
    font-weight: 500;
    text-decoration: none;
}

.consent-label a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-steps {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}

.step-indicator {
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.8125rem;
    letter-spacing: normal;
    text-transform: none;
}

.step-indicator.active {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.register-steps {
    margin: 0;
    width: 100%;
}

.step-block {
    margin: 0;
    width: 100%;
}

ul.errorlist,
.form-group ul.errorlist {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    color: var(--system-red);
    font-size: 0.8125rem;
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
}

ul.errorlist li,
.form-group ul.errorlist li {
    list-style: none;
    margin: 0.25rem 0 0;
    color: var(--system-red);
}

.auth-container form > ul.errorlist {
    margin-bottom: 1rem;
    padding: 0.75rem 0.875rem;
    border-radius: 10px;
    background: color-mix(in srgb, var(--system-red) 8%, var(--bg));
    border: 1px solid color-mix(in srgb, var(--system-red) 25%, transparent);
}

.ml-2 {
    margin-left: 0;
}

@media (max-width: 480px) {
    .main-container:has(.auth-container) {
        padding-top: calc(var(--header-height) + 1.25rem);
    }

    .auth-container {
        max-width: min(20rem, 100%);
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .auth-container h1,
    .auth-container .auth-title {
        font-size: 1.25rem;
    }

    #reg-step2 .form-buttons {
        flex-direction: column;
    }

    #reg-step2 .form-buttons .auth-btn {
        flex: 1 1 auto;
        width: 100%;
    }
}

/* Auth as modal — split panel with visual art */
.auth-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
    box-sizing: border-box;
    background: color-mix(in srgb, var(--fill-grouped, #000) 55%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.auth-modal-overlay.is-open {
    display: flex;
}

body:has(.auth-modal-overlay.is-open),
body.auth-modal-open {
    overflow: hidden;
}

.main-container:has(.auth-modal-overlay.is-page-auth) {
    min-height: 100dvh;
    padding: 0;
    margin: 0;
    display: block;
}

.auth-modal {
    position: relative;
    width: min(26rem, 100%);
    max-height: min(92dvh, 52rem);
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 18px;
    background: var(--card, var(--bg-secondary));
    box-shadow: none;
    outline: none;
    overflow: hidden;
}

.auth-modal--split {
    width: min(920px, calc(100vw - 2rem));
    max-height: min(94dvh, 760px);
    height: auto;
    flex-direction: row;
    align-items: stretch;
    background: var(--fill-primary, #1c1c1e);
}

.auth-modal__visual {
    position: relative;
    flex: 0 0 44%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    min-width: 0;
    padding: 2rem 1.5rem;
    background: #0a0a0b;
    overflow: hidden;
}

.auth-modal__visual-img {
    display: block;
    width: min(100%, 340px);
    height: auto;
    max-height: min(48vh, 360px);
    object-fit: contain;
    filter: drop-shadow(0 18px 40px rgba(0, 0, 0, 0.45));
}

.auth-modal__visual-title {
    margin: 0;
    max-width: 14em;
    text-align: center;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    font-weight: 650;
    letter-spacing: -0.03em;
    line-height: 1.25;
    color: var(--label-primary, #fff);
    text-wrap: balance;
}

.auth-modal__panel {
    position: relative;
    flex: 1 1 56%;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background: var(--fill-primary, #1c1c1e);
    overflow: hidden;
}

.auth-modal-scroll {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 1.75rem 1.5rem 1.5rem;
    flex: 1 1 auto;
    scrollbar-width: thin;
}

.auth-container--modal {
    max-width: none;
    margin: 0;
    padding: 0;
}

.auth-container--modal .auth-back {
    display: none;
}

.auth-container--modal h1,
.auth-container--modal .auth-title {
    text-align: left;
    margin: 0 0 0.35rem;
    font-size: clamp(1.4rem, 2.2vw, 1.7rem);
}

.auth-container--modal .auth-lead {
    margin: 0 0 1rem;
}

.auth-container--modal .auth-field {
    margin: 0 0 0.65rem;
}

.auth-container--modal .auth-field input[type="text"],
.auth-container--modal .auth-field input[type="email"],
.auth-container--modal .auth-field input[type="password"],
.auth-container--modal .auth-field input[type="number"],
.auth-container--modal .auth-field select {
    min-height: 2.6rem;
}

.auth-container--modal .form-buttons {
    margin-top: 0.25rem;
}

.auth-container--modal .consent-group {
    margin: 0.35rem 0 0.85rem;
}

.auth-container--modal .auth-divider {
    margin: 0.9rem 0 0.75rem;
}

.auth-container--modal .auth-switch {
    margin-top: 0.85rem;
}

.auth-container--modal .auth-username-status {
    margin: 0.25rem 0 0;
}

.auth-lead {
    margin: 0 0 1.35rem;
    font-size: 0.9375rem;
    line-height: 1.4;
    color: var(--label-secondary, #98989d);
}

.auth-lead a {
    color: var(--label-primary, #fff);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 1.15rem 0 0.9rem;
    color: var(--label-tertiary, #636366);
    font-size: 0.8125rem;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
    background: color-mix(in srgb, var(--label-primary, #fff) 12%, transparent);
}

.auth-divider span {
    flex: 0 0 auto;
}

.auth-modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: none;
    border-radius: 980px;
    background: color-mix(in srgb, var(--label-primary, var(--text)) 8%, transparent);
    color: var(--text-secondary, var(--label-secondary));
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.auth-modal-close:hover {
    opacity: 0.9;
    background: color-mix(in srgb, var(--label-primary, var(--text)) 12%, transparent);
    color: var(--label-primary, var(--text));
}

.auth-modal-overlay.is-open .auth-modal {
    animation: auth-modal-in 0.28s ease;
}

@keyframes auth-modal-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 820px) {
    .auth-modal-overlay.is-open {
        align-items: center;
        padding:
          max(0.5rem, env(safe-area-inset-top, 0px))
          0.75rem
          max(0.5rem, env(safe-area-inset-bottom, 0px));
    }

    .auth-modal--split {
        width: min(28rem, calc(100vw - 1.5rem));
        height: min(94dvh, calc(100dvh - 1rem));
        max-height: min(94dvh, calc(100dvh - 1rem));
        flex-direction: column;
        border-radius: 18px;
        min-height: 0;
    }

    .auth-modal__visual {
        flex: 0 0 auto;
        min-height: 140px;
        max-height: 180px;
        padding: 1rem 1.25rem 0.5rem;
        gap: 0.5rem;
    }

    .auth-modal__visual-img {
        max-height: 120px;
        width: min(100%, 220px);
    }

    .auth-modal__visual-title {
        display: none;
    }

    .auth-modal__panel {
        flex: 1 1 auto;
        min-height: 0;
        overflow: hidden;
    }

    .auth-modal-scroll {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 1.25rem 1.15rem 1.35rem;
        touch-action: pan-y;
    }
}

@media (max-width: 480px) {
    .auth-modal,
    .auth-modal--split {
        width: calc(100vw - 1rem);
        height: min(96dvh, calc(100dvh - 0.75rem));
        max-height: min(96dvh, calc(100dvh - 0.75rem));
        border-radius: 16px;
        min-height: 0;
    }

    .auth-modal__visual {
        max-height: 150px;
        min-height: 120px;
    }

    .auth-modal-scroll {
        padding: 1.15rem 1rem 1.2rem;
        min-height: 0;
    }
}
