html:has(.LicenceDialog[open]) {
    overflow: hidden;
    scrollbar-gutter: stable;
}

.LicenceDialog {
    --DialogPadding: 1.75rem;
    --AcrylicTint: rgb(17 20 27 / 0.66);
    --AcrylicSheen: linear-gradient(180deg, rgb(255 255 255 / 0.045), rgb(255 255 255 / 0) 9rem);
    --AcrylicEdge: rgb(255 255 255 / 0.12);
    --FooterSurface: rgb(0 0 0 / 0.2);
    --FieldSurface: rgb(0 0 0 / 0.3);
    --ControlRadius: 0.5rem;
    --ErrorInk: #f19b8f;
    --ErrorBorder: rgb(241 155 143 / 0.55);
    width: min(28rem, 100% - 2 * var(--SpaceBase));
    max-width: none;
    max-height: calc(100dvh - 2 * var(--SpaceBase));
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--AcrylicEdge);
    border-radius: var(--RadiusMedium);
    color: var(--InkStrong);
    background: var(--AcrylicSheen), var(--AcrylicTint);
    backdrop-filter: blur(1.75rem) saturate(1.7);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08), 0 24px 56px -28px rgb(0 0 0 / 0.6);
}

.LicenceDialog[open] {
    display: grid;
    animation:
        FadeIn var(--DurationBase) var(--EaseOut) both,
        DialogRise var(--DurationSlow) var(--EaseOut) both;
}

.LicenceDialog::backdrop {
    background: rgb(4 7 12 / 0.4);
}

.LicenceDialog[open]::backdrop {
    animation: FadeIn var(--DurationSlow) var(--EaseOut) both;
}

.LicenceDialog[data-state="closing"] {
    pointer-events: none;
    animation: DialogExit var(--DurationBase) var(--EaseIn) both;
}

.LicenceDialog[data-state="closing"]::backdrop {
    animation: BackdropOut var(--DurationBase) var(--EaseIn) both;
}

.DialogClose {
    grid-area: 1 / 1;
    z-index: var(--LayerRaised);
    justify-self: end;
    align-self: start;
    display: grid;
    place-items: center;
    width: 1.75rem;
    height: 1.75rem;
    margin: 0.75rem;
    border-radius: var(--ControlRadius);
    color: var(--InkMuted);
    transition:
        color var(--DurationFast) var(--EaseOut),
        background-color var(--DurationFast) var(--EaseOut),
        scale var(--DurationFast) var(--EaseOut);
}

.DialogClose svg {
    width: 0.625rem;
    height: auto;
    aspect-ratio: 8 / 7;
    fill: currentColor;
}

.DialogClose:hover {
    color: var(--InkStrong);
    background: rgb(255 255 255 / 0.06);
}

.DialogClose:active {
    scale: 0.92;
}

.LicenceView {
    grid-area: 1 / 1;
    align-self: start;
    display: grid;
    gap: 1.125rem;
    min-width: 0;
    padding: 1.625rem var(--DialogPadding) 0;
}

.SuccessView {
    padding-bottom: var(--DialogPadding);
}

.LicenceView[hidden] {
    display: none;
}

.LicenceView > * {
    animation: LicenceRise var(--DurationSlow) var(--EaseOut) both;
    animation-delay: calc(var(--Stagger, 0) * 45ms + 60ms);
}

.LicenceView > :nth-child(2) {
    --Stagger: 1;
}

.LicenceView > :nth-child(3) {
    --Stagger: 2;
}

.LicenceView > :nth-child(4) {
    --Stagger: 3;
}

.LicenceView[data-state="leaving"] {
    animation: LicenceLeave var(--DurationFast) var(--EaseIn) both;
}

.LicenceView[data-state="entering"] {
    animation: FadeIn var(--DurationSlow) var(--EaseOut) var(--DurationFast) both;
}

.LicenceHeader {
    display: grid;
    justify-items: center;
    gap: 0.25rem;
    text-align: center;
}

.LicenceMark,
.SuccessCheck {
    width: 2.75rem;
    height: 2.75rem;
    margin-bottom: 0.5rem;
}

.LicenceMark {
    padding: 0.5rem;
    border: 1px solid var(--AcrylicEdge);
    border-radius: var(--RadiusSmall);
    background: rgb(255 255 255 / 0.06);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06);
}

.LicenceTitle {
    font-size: 1.1875rem;
    font-weight: var(--WeightBold);
    line-height: var(--LeadingSnug);
    letter-spacing: var(--TrackingSnug);
    color: var(--InkStrong);
}

.LicenceTitle:focus-visible {
    outline: none;
}

.TitleMuted {
    display: block;
    font-weight: var(--WeightMedium);
    color: var(--InkMuted);
}

.LicenceSummary {
    max-width: 22rem;
    font-size: var(--SizeSmall);
    line-height: 1.5;
    color: var(--InkMuted);
}

.LicenceForm {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    row-gap: 0.5rem;
}

.LicenceCheck {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
}

.LicenceCheck:empty {
    display: none;
}

.FieldLabel,
.KeyCount,
.FieldHint,
.FieldError {
    font-size: var(--SizeCaption);
    line-height: var(--LeadingSnug);
}

.FieldLabel {
    font-weight: var(--WeightMedium);
    color: var(--InkStrong);
}

.KeyCount {
    color: var(--InkSubtle);
    font-variant-numeric: tabular-nums;
    transition: color var(--DurationBase) var(--EaseOut);
}

.LicenceForm[data-complete] .KeyCount {
    color: var(--InkStrong);
}

.KeyField {
    --KeyTracking: 0.05em;
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    height: 2.5rem;
    overflow: clip;
    border: 1px solid var(--AcrylicEdge);
    border-radius: var(--ControlRadius);
    background: var(--FieldSurface);
    cursor: text;
    transition: border-color var(--DurationBase) var(--EaseOut);
}

.KeyField:hover {
    border-color: var(--BorderStrong);
}

.KeyField:focus-within {
    border-color: var(--AccentBlue);
}

.LicenceForm[data-message="error"] .KeyField {
    border-color: var(--ErrorBorder);
}

.KeyField[data-shake] {
    animation: KeyShake 420ms var(--EaseOut);
}

.KeyIcon {
    grid-area: 1 / 1;
    width: 1rem;
    height: 1rem;
    margin-inline-start: 0.875rem;
    fill: none;
    stroke: var(--InkSubtle);
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
    transition: stroke var(--DurationBase) var(--EaseOut);
}

.KeyField:focus-within .KeyIcon {
    stroke: var(--InkMuted);
}

.KeyGhost,
.KeyInput {
    grid-area: 1 / 2;
    padding-inline-start: 0.625rem;
    font-size: 0.9375rem;
    font-weight: var(--WeightMedium);
    font-variant-numeric: tabular-nums;
    line-height: var(--LeadingBody);
    letter-spacing: var(--KeyTracking);
}

.KeyGhost {
    overflow: hidden;
    white-space: pre;
    color: var(--InkSubtle);
    pointer-events: none;
    user-select: none;
}

.KeyField[data-overflow] .KeyGhost {
    visibility: hidden;
}

.GhostTyped {
    color: transparent;
}

.KeyInput {
    width: 100%;
    min-width: 0;
    height: 100%;
    padding-block: 0;
    padding-inline-end: var(--SpaceTiny);
    border: 0;
    color: var(--InkStrong);
    background: transparent;
    caret-color: var(--AccentBright);
}

.KeyInput::placeholder {
    color: transparent;
}

.KeyField[data-overflow] .KeyInput::placeholder {
    color: var(--InkSubtle);
}

.KeyInput:focus-visible {
    outline: none;
}

.PasteButton {
    grid-area: 1 / 3;
    height: 1.625rem;
    margin-inline-end: 0.4375rem;
    padding-inline: 0.625rem;
    border: 1px solid var(--AcrylicEdge);
    border-radius: 0.375rem;
    font-size: var(--SizeCaption);
    font-weight: var(--WeightMedium);
    color: var(--InkMuted);
    background: rgb(255 255 255 / 0.04);
    transition:
        color var(--DurationFast) var(--EaseOut),
        background-color var(--DurationFast) var(--EaseOut),
        border-color var(--DurationFast) var(--EaseOut);
}

.PasteButton:hover {
    border-color: var(--BorderStrong);
    color: var(--InkStrong);
    background: rgb(255 255 255 / 0.08);
}

.PasteButton[hidden] {
    display: none;
}

.FieldHint,
.FieldError {
    grid-area: 3 / 1 / 4 / -1;
    transition:
        opacity var(--DurationBase) var(--EaseOut),
        translate var(--DurationBase) var(--EaseOut),
        visibility var(--DurationBase) var(--EaseOut);
}

.FieldHint {
    color: var(--InkSubtle);
}

.FieldError {
    color: var(--ErrorInk);
    text-wrap: pretty;
    opacity: 0;
    translate: 0 0.1875rem;
}

.LicenceForm[data-message] .FieldHint {
    opacity: 0;
    visibility: hidden;
    translate: 0 -0.1875rem;
}

.LicenceForm[data-message] .FieldError {
    opacity: 1;
    translate: none;
}

.LicenceForm[data-message="hint"] .FieldError {
    color: var(--InkMuted);
}

.LicenceActions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--SpaceSmall);
}

.LicenceActions [hidden] {
    display: none;
}

.LicenceActions .Button {
    --ButtonHeight: 2.375rem;
    --ButtonPadding: 1.125rem;
    border-radius: var(--ControlRadius);
}

.SubmitButton {
    display: inline-grid;
    place-items: center;
    transition:
        opacity var(--DurationBase) var(--EaseOut),
        scale var(--DurationFast) var(--EaseOut),
        background-color 280ms var(--EaseOut),
        color 280ms var(--EaseOut);
}

.SubmitButton > * {
    grid-area: 1 / 1;
}

.SubmitButton:disabled {
    opacity: 0.45;
}

.SubmitButton[aria-busy="true"] {
    cursor: progress;
}

.SubmitButton[aria-busy="true"] .SubmitLabel {
    visibility: hidden;
}

.ButtonSpinner {
    display: none;
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 0.7 1;
    animation: Spin 800ms linear infinite;
}

.SubmitButton[aria-busy="true"] .ButtonSpinner {
    display: block;
}

.LicenceFooter {
    margin-inline: calc(-1 * var(--DialogPadding));
    padding: 0.75rem var(--DialogPadding);
    border-top: 1px solid rgb(255 255 255 / 0.07);
    font-size: var(--SizeSmall);
    text-align: center;
    color: var(--InkMuted);
    background: var(--FooterSurface);
}

.LicenceFooter .TextButton {
    font-size: inherit;
}

.SuccessCheck {
    overflow: visible;
    fill: none;
    stroke: var(--AccentBright);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.TickRing,
.TickMark {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
}

.TickRing {
    rotate: -90deg;
    transform-box: fill-box;
    transform-origin: center;
    animation: CheckStroke var(--DurationReveal) var(--EaseOut) 220ms forwards;
}

.TickMark {
    stroke-width: 4;
    animation: CheckStroke var(--DurationBase) var(--EaseOut) 620ms forwards;
}

@keyframes DialogRise {
    from {
        scale: 0.98;
        translate: 0 0.5rem;
    }
}

@keyframes DialogExit {
    to {
        opacity: 0;
        scale: 0.98;
        translate: 0 0.375rem;
    }
}

@keyframes DialogSheet {
    from {
        translate: 0 100%;
    }
}

@keyframes DialogSink {
    to {
        translate: 0 100%;
    }
}

@keyframes BackdropOut {
    to {
        opacity: 0;
    }
}

@keyframes LicenceRise {
    from {
        opacity: 0;
        translate: 0 0.375rem;
    }
}

@keyframes LicenceLeave {
    to {
        opacity: 0;
        scale: 0.98;
    }
}

@keyframes KeyShake {
    15% {
        translate: -0.25rem 0;
    }

    35% {
        translate: 0.1875rem 0;
    }

    55% {
        translate: -0.125rem 0;
    }

    75% {
        translate: 0.0625rem 0;
    }
}

@keyframes CheckStroke {
    to {
        stroke-dashoffset: 0;
    }
}

@media (max-height: 40rem) {
    .LicenceDialog {
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (max-width: 34rem) {
    .LicenceDialog {
        --DialogPadding: 1.25rem;
        width: 100%;
        max-height: calc(100dvh - var(--SpaceLarge));
        margin: auto 0 0;
        border-width: 1px 0 0;
        border-radius: var(--RadiusMedium) var(--RadiusMedium) 0 0;
    }

    .LicenceDialog[open] {
        animation:
            FadeIn var(--DurationBase) var(--EaseOut) both,
            DialogSheet var(--DurationSlow) var(--EaseOut) both;
    }

    .LicenceDialog[data-state="closing"] {
        animation: DialogSink var(--DurationBase) var(--EaseIn) both;
    }

    .LicenceView {
        padding-top: 1.375rem;
    }

    .LicenceFooter,
    .SuccessView {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }

    .KeyGhost,
    .KeyInput {
        font-size: 0.875rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .LicenceDialog[open],
    .LicenceView > * {
        animation: FadeIn var(--DurationFast) var(--EaseOut) both;
    }

    .TickRing,
    .TickMark {
        animation: none;
        stroke-dashoffset: 0;
    }
}
